diff --git a/.changeset/famous-buses-remain.md b/.changeset/famous-buses-remain.md new file mode 100644 index 00000000..7d25192e --- /dev/null +++ b/.changeset/famous-buses-remain.md @@ -0,0 +1,5 @@ +--- +"@fleet-sdk/core": patch +--- + +Fix wrong minimal amount estimation while minting a token. diff --git a/packages/core/src/builder/outputBuilder.spec.ts b/packages/core/src/builder/outputBuilder.spec.ts index e502f6aa..9d9aa47d 100644 --- a/packages/core/src/builder/outputBuilder.spec.ts +++ b/packages/core/src/builder/outputBuilder.spec.ts @@ -464,6 +464,9 @@ describe("Building", () => { output.addTokens({ tokenId: tokenB, amount: 90n }); expect(output.value).toBe(52200n); + + output.mintToken({ amount: 100n }); + expect(output.value).toBe(64080n); }); it("Should estimate min box value with custom value per byte", () => { diff --git a/packages/core/src/builder/outputBuilder.ts b/packages/core/src/builder/outputBuilder.ts index 53857780..0634ad2e 100644 --- a/packages/core/src/builder/outputBuilder.ts +++ b/packages/core/src/builder/outputBuilder.ts @@ -217,6 +217,13 @@ export class OutputBuilder { assert(!!this.creationHeight, "Creation height must be set"); const tokens = this._tokens.toArray(); + if (this.minting) { + tokens.push({ + tokenId: "0000000000000000000000000000000000000000000000000000000000000000", + amount: this.minting.amount + }); + } + const plainBoxObject: BoxCandidate = { value, ergoTree: this.ergoTree,