From 169914def55c8d58218f1a55faed81d7ef99b00e Mon Sep 17 00:00:00 2001 From: ByteZhang Date: Mon, 13 Apr 2026 22:51:55 +0800 Subject: [PATCH 1/2] fix: CSL 13 compat for reference_inputs and mint in txToOneKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two runtime crashes triggered by CSL 13 API changes that went unnoticed because the affected code paths (hardware dApp signing with Plutus reference_inputs or mint) had no real test coverage. - reference_inputs: CSL 13 TransactionInput.index() returns a JS number directly, not a BigNum, so the legacy .to_str() call crashes with "not a function". Wrap with String() for safe numeric parsing. - mint: CSL 13 changed Mint.get(policy) to return MintsAssets — a list of MintAssets entries, one per occurrence of that policy in the original CBOR, to preserve byte-level round-trip (tx hash stability). Iterate the list, then each map, instead of the old single-map access. --- src/utils/onekey/txToOneKey.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/utils/onekey/txToOneKey.ts b/src/utils/onekey/txToOneKey.ts index 2283914..0f39af6 100644 --- a/src/utils/onekey/txToOneKey.ts +++ b/src/utils/onekey/txToOneKey.ts @@ -457,17 +457,23 @@ export const txToOneKey = async ( mintBundle = []; for (let j = 0; j < mint.keys().len(); j++) { const policy = mint.keys().get(j); - const assets = mint.get(policy); + // CSL 13: Mint.get(policy) returns MintsAssets — a list, one entry per + // occurrence of that policy in the original CBOR — to preserve byte- + // level round-trip (tx hash stability). Iterate the list, then each map. + const mintsAssets = mint.get(policy); const tokens = []; - for (let k = 0; k < assets.keys().len(); k++) { - const assetName = assets.keys().get(k); - const amount = assets.get(assetName); - tokens.push({ - assetNameBytes: Buffer.from(assetName.name()).toString('hex'), - mintAmount: amount.is_positive() - ? amount.as_positive().to_str() - : '-' + amount.as_negative().to_str(), - }); + for (let mai = 0; mai < mintsAssets.len(); mai++) { + const assets = mintsAssets.get(mai); + for (let k = 0; k < assets.keys().len(); k++) { + const assetName = assets.keys().get(k); + const amount = assets.get(assetName); + tokens.push({ + assetNameBytes: Buffer.from(assetName.name()).toString('hex'), + mintAmount: amount.is_positive() + ? amount.as_positive().to_str() + : '-' + amount.as_negative().to_str(), + }); + } } // sort canonical sortCanonicallyInPlace(tokens, item => item.assetNameBytes); @@ -543,7 +549,7 @@ export const txToOneKey = async ( for (let i = 0; i < ri.len(); i++) { referenceInputs.push({ prev_hash: ri.get(i).transaction_id().to_hex(), - prev_index: parseInt(ri.get(i).index().to_str()), + prev_index: parseInt(String(ri.get(i).index())), }); } signingMode = CardanoTxSigningMode.PLUTUS_TRANSACTION; From 100f67650ab81b6f575202d7249b09e31db3db7c Mon Sep 17 00:00:00 2001 From: ByteZhang Date: Tue, 14 Apr 2026 13:34:14 +0800 Subject: [PATCH 2/2] chore: bump version to 1.1.10 and remove stale comment --- package.json | 2 +- src/utils/onekey/dapp.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 44f9261..3508282 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cardano-coin-selection-asmjs", - "version": "1.1.10-alpha.8", + "version": "1.1.10", "description": "", "keywords": [ "coin selection" diff --git a/src/utils/onekey/dapp.ts b/src/utils/onekey/dapp.ts index abc224a..cb715bb 100644 --- a/src/utils/onekey/dapp.ts +++ b/src/utils/onekey/dapp.ts @@ -108,7 +108,6 @@ const convertCborTxToEncodeTx = async ({ let body: CardanoWasm.TransactionBody; let rawTxHex: string; - // console.log('CARDANO LOCAL_VERSION : 333====>>>'); try { const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(txHex, 'hex')); body = tx.body();