Skip to content

Commit

Permalink
fix unsorted inputs and mints
Browse files Browse the repository at this point in the history
  • Loading branch information
twwu123 committed Dec 19, 2024
1 parent 2511e25 commit 6758aa0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/mesh-transaction/src/mesh-tx-builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ export class MeshTxBuilder extends MeshTxBuilderCore {
});
this.addUtxosFromSelection();

// Sort inputs based on txHash and txIndex
this.meshTxBuilderBody.inputs.sort((a, b) => {
if (a.txIn.txHash < b.txIn.txHash) return -1;
if (a.txIn.txHash > b.txIn.txHash) return 1;
if (a.txIn.txIndex < b.txIn.txIndex) return -1;
if (a.txIn.txIndex > b.txIn.txIndex) return 1;
return 0;
});

// Sort mints based on policy id and asset name
this.meshTxBuilderBody.mints.sort((a, b) => {
if (a.policyId < b.policyId) return -1;
if (a.policyId > b.policyId) return 1;
if (a.assetName < b.assetName) return -1;
if (a.assetName > b.assetName) return 1;
return 0;
});

let txHex = this.serializer.serializeTxBody(
this.meshTxBuilderBody,
this._protocolParams,
Expand Down

0 comments on commit 6758aa0

Please sign in to comment.