Skip to content

Commit

Permalink
core: fix wrong minimal amount estimation while minting a token.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobsn committed Aug 8, 2023
1 parent 76d4c3d commit fffd1ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-buses-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fleet-sdk/core": patch
---

Fix wrong minimal amount estimation while minting a token.
3 changes: 3 additions & 0 deletions packages/core/src/builder/outputBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/builder/outputBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<bigint> = {
value,
ergoTree: this.ergoTree,
Expand Down

0 comments on commit fffd1ed

Please sign in to comment.