Skip to content

Conversation

@arobsn
Copy link
Member

@arobsn arobsn commented Jul 25, 2025

This PR introduces ErgoTree construction from ergoc JSON output and named constant replacement.

Example

Given the following output:

const compilerOutput = {
  header: "1a",
  expressionTree: "d191b283010573007301007302",
  constants: [
    { value: "0580897a", type: "Long" },
    { value: "0400", type: "Int" },
    { value: "059003", type: "Long", name: "price2" }
  ]
};

const ergoTree = ErgoTree.from(compilerOutput) // reconstruct from json object
  .replaceConstant("price2", SLong(2n));       // replace constant by name

@changeset-bot
Copy link

changeset-bot bot commented Jul 25, 2025

🦋 Changeset detected

Latest commit: b41cc45

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@fleet-sdk/core Minor
@fleet-sdk/blockchain-providers Minor
@fleet-sdk/compiler Minor
@fleet-sdk/mock-chain Minor
@fleet-sdk/wallet Minor
@fleet-sdk/ageusd-plugin Patch
@fleet-sdk/babel-fees-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8642255) to head (b41cc45).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #202   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          124       124           
  Lines        14157     14204   +47     
  Branches      1762      1776   +14     
=========================================
+ Hits         14157     14204   +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 25, 2025

@fleet-sdk/blockchain-providers

npm i https://pkg.pr.new/@fleet-sdk/blockchain-providers@202

@fleet-sdk/common

npm i https://pkg.pr.new/@fleet-sdk/common@202

@fleet-sdk/compiler

npm i https://pkg.pr.new/@fleet-sdk/compiler@202

@fleet-sdk/core

npm i https://pkg.pr.new/@fleet-sdk/core@202

@fleet-sdk/crypto

npm i https://pkg.pr.new/@fleet-sdk/crypto@202

@fleet-sdk/mock-chain

npm i https://pkg.pr.new/@fleet-sdk/mock-chain@202

@fleet-sdk/serializer

npm i https://pkg.pr.new/@fleet-sdk/serializer@202

@fleet-sdk/wallet

npm i https://pkg.pr.new/@fleet-sdk/wallet@202

@fleet-sdk/ageusd-plugin

npm i https://pkg.pr.new/@fleet-sdk/ageusd-plugin@202

@fleet-sdk/babel-fees-plugin

npm i https://pkg.pr.new/@fleet-sdk/babel-fees-plugin@202

commit: b41cc45

@arobsn arobsn requested a review from Copilot July 25, 2025 01:16

This comment was marked as outdated.

@arobsn arobsn requested a review from Copilot July 25, 2025 23:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for constructing ErgoTree instances from ergoc compiler JSON output and enables replacing constants by name. The changes allow developers to work with compiler output more directly and manage constants using meaningful names instead of just numeric indices.

  • Add ErgoTree.from() static method to construct from JSON compiler output
  • Extend replaceConstant() to accept string names in addition to numeric indices
  • Add named constant mapping functionality with private #nameConstant() method

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
packages/core/src/models/ergoTree.ts Core implementation of JSON construction and named constant support
packages/core/src/models/ergoTree.spec.ts Comprehensive test coverage for new functionality
.changeset/sour-ideas-flow.md Changelog entry for JSON construction feature
.changeset/loose-ears-cheat.md Changelog entry for named constants feature

@arobsn arobsn merged commit fbdd781 into master Jul 26, 2025
16 checks passed
@arobsn arobsn deleted the add-json-ergotree-construction branch July 26, 2025 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants