From 4fcb71d30b34fb98ad5717c3fdc4d0d0ffa6e803 Mon Sep 17 00:00:00 2001 From: remilio nubilio Date: Wed, 9 Sep 2026 18:14:37 -0400 Subject: [PATCH 1/2] core: request v1 transactions and move web3.js to ^1.99.0 The solana-sdk is moving to Solana v1 transactions (IQCoreTeam/iqlabs-solana-sdk#22). Readers break first: a getTransaction that asks for maxSupportedTransactionVersion 0 is refused for a v1 tx, and web3.js 1.98 cannot parse a version 1 response at all, its TransactionVersion struct only knows 'legacy' and 0. Writers can lag; readers cannot. Move the one AgentNet-owned read site, txErrorDetail in nft/workflow.ts, from 0 to 1 so the failure logs it fetches for our own just-sent tx keep working once those are v1, and pin @solana/web3.js at ^1.99.0 in core (peer and dev) and mcp so every bundle that inlines core carries a parser that accepts version 1. The lockfile resolves to a single web3.js 1.99.0 that the sdk 0.1.28 dependency dedupes onto; the rest of the lock churn is that package's own subtree (codecs-numbers 5.5.1, bn.js 5.2.5). The existing sendTx regression now asserts the version option instead of only that getTransaction was called. The @iqlabs-official/solana-sdk pin stays at ^0.1.28: the release with v1 readers (feat/v1-tx-4096) is not published yet, and 0.1.28's readTableRows and readCodeIn still ask for version 0 internally, so the two SDK fallbacks in core/chain.ts (readRowsByPda, readCodeIn) keep that limit until the pin can move. --- packages/core/package.json | 4 +- packages/core/src/nft/workflow.spec.ts | 2 +- packages/core/src/nft/workflow.ts | 2 +- packages/mcp/package.json | 2 +- pnpm-lock.yaml | 109 ++++++++++++++----------- 5 files changed, 68 insertions(+), 51 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index d7d8fdaf..bcf23ca5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -21,11 +21,11 @@ }, "peerDependencies": { "@iqlabs-official/solana-sdk": "^0.1.28", - "@solana/web3.js": "^1.98.0" + "@solana/web3.js": "^1.99.0" }, "devDependencies": { "@iqlabs-official/solana-sdk": "^0.1.28", - "@solana/web3.js": "^1.98.0", + "@solana/web3.js": "^1.99.0", "@types/jsdom": "^30.0.0", "@types/node": "^20.0.0", "jsdom": "^30.0.1", diff --git a/packages/core/src/nft/workflow.spec.ts b/packages/core/src/nft/workflow.spec.ts index 1985d843..a2165cc1 100644 --- a/packages/core/src/nft/workflow.spec.ts +++ b/packages/core/src/nft/workflow.spec.ts @@ -127,6 +127,6 @@ Workflow body here, long enough to pass the body length check easily.`; const dummyIx = new TransactionInstruction({ programId: PublicKey.default, keys: [], data: Buffer.from([]) }); await expect(sendTx(mockConn as any, signer, [dummyIx])).rejects.toThrow(/failed on-chain/); - expect(mockConn.getTransaction).toHaveBeenCalled(); + expect(mockConn.getTransaction).toHaveBeenCalledWith("mockTxSig", expect.objectContaining({ maxSupportedTransactionVersion: 1 })); }); }); diff --git a/packages/core/src/nft/workflow.ts b/packages/core/src/nft/workflow.ts index 4cdd3f15..e172a259 100644 --- a/packages/core/src/nft/workflow.ts +++ b/packages/core/src/nft/workflow.ts @@ -211,7 +211,7 @@ export async function sendTx( async function txErrorDetail(conn: Connection, sig: string): Promise { try { const tx = await conn.getTransaction(sig, { - maxSupportedTransactionVersion: 0, + maxSupportedTransactionVersion: 1, commitment: "confirmed", }); const err = JSON.stringify(tx?.meta?.err); diff --git a/packages/mcp/package.json b/packages/mcp/package.json index 88e6e8f2..152f3db5 100644 --- a/packages/mcp/package.json +++ b/packages/mcp/package.json @@ -28,7 +28,7 @@ "devDependencies": { "@iqlabs-official/agent-sdk": "workspace:*", "@iqlabs-official/solana-sdk": "^0.1.28", - "@solana/web3.js": "^1.98.0", + "@solana/web3.js": "^1.99.0", "tsup": "^8.0.0", "typescript": "^5.6.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f57ff507..7d83ebd9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,13 +21,13 @@ importers: version: 0.139.0 '@solana/spl-token': specifier: ^0.4.14 - version: 0.4.14(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(bufferutil@4.1.0)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)(utf-8-validate@6.0.6) + version: 0.4.14(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(bufferutil@4.1.0)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)(utf-8-validate@6.0.6) '@solana/spl-token-group': specifier: ^0.0.7 - version: 0.0.7(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + version: 0.0.7(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) '@solana/spl-token-metadata': specifier: ^0.1.6 - version: 0.1.6(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + version: 0.1.6(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) dompurify: specifier: ^3.4.9 version: 3.4.9 @@ -42,8 +42,8 @@ importers: specifier: ^0.1.28 version: 0.1.28(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) '@solana/web3.js': - specifier: ^1.98.0 - version: 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + specifier: ^1.99.0 + version: 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) '@types/jsdom': specifier: ^30.0.0 version: 30.0.0 @@ -78,8 +78,8 @@ importers: specifier: ^0.1.28 version: 0.1.28(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) '@solana/web3.js': - specifier: ^1.98.0 - version: 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + specifier: ^1.99.0 + version: 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) tsup: specifier: ^8.0.0 version: 8.5.1(jiti@2.7.0)(postcss@8.5.15)(tsx@4.22.4)(typescript@5.9.3) @@ -992,11 +992,14 @@ packages: peerDependencies: typescript: '>=5' - '@solana/codecs-core@2.3.0': - resolution: {integrity: sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw==} + '@solana/codecs-core@5.5.1': + resolution: {integrity: sha512-TgBt//bbKBct0t6/MpA8ElaOA3sa8eYVvR7LGslCZ84WiAwwjCY0lW/lOYsFHJQzwREMdUyuEyy5YWBKtdh8Rw==} engines: {node: '>=20.18.0'} peerDependencies: - typescript: '>=5.3.3' + typescript: ^5.0.0 + peerDependenciesMeta: + typescript: + optional: true '@solana/codecs-data-structures@2.0.0-rc.1': resolution: {integrity: sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog==} @@ -1008,11 +1011,14 @@ packages: peerDependencies: typescript: '>=5' - '@solana/codecs-numbers@2.3.0': - resolution: {integrity: sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg==} + '@solana/codecs-numbers@5.5.1': + resolution: {integrity: sha512-rllMIZAHqmtvC0HO/dc/21wDuWaD0B8Ryv8o+YtsICQBuiL/0U4AGwH7Pi5GNFySYk0/crSuwfIqQFtmxNSPFw==} engines: {node: '>=20.18.0'} peerDependencies: - typescript: '>=5.3.3' + typescript: ^5.0.0 + peerDependenciesMeta: + typescript: + optional: true '@solana/codecs-strings@2.0.0-rc.1': resolution: {integrity: sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g==} @@ -1031,12 +1037,15 @@ packages: peerDependencies: typescript: '>=5' - '@solana/errors@2.3.0': - resolution: {integrity: sha512-66RI9MAbwYV0UtP7kGcTBVLxJgUxoZGm8Fbc0ah+lGiAw17Gugco6+9GrJCV83VyF2mDWyYnYM9qdI3yjgpnaQ==} + '@solana/errors@5.5.1': + resolution: {integrity: sha512-vFO3p+S7HoyyrcAectnXbdsMfwUzY2zYFUc2DEe5BwpiE9J1IAxPBGjOWO6hL1bbYdBrlmjNx8DXCslqS+Kcmg==} engines: {node: '>=20.18.0'} hasBin: true peerDependencies: - typescript: '>=5.3.3' + typescript: ^5.0.0 + peerDependenciesMeta: + typescript: + optional: true '@solana/options@2.0.0-rc.1': resolution: {integrity: sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA==} @@ -1061,8 +1070,8 @@ packages: peerDependencies: '@solana/web3.js': ^1.95.5 - '@solana/web3.js@1.98.4': - resolution: {integrity: sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw==} + '@solana/web3.js@1.99.0': + resolution: {integrity: sha512-QZYQ2T1z6xWisoyALPq25i/QZTsRlM02BABtAsfaQ1p8wX4SdTfxrKTRue/ZZqrhNVh5oL7T/DUFiTS9DRgxow==} '@stablelib/base64@1.0.1': resolution: {integrity: sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==} @@ -1345,6 +1354,9 @@ packages: bn.js@5.2.3: resolution: {integrity: sha512-EAcmnPkxpntVL+DS7bO1zhcZNvCkxqtkd0ZY53h06GNQ3DEkkGZ/gKgmDv6DdZQGj9BgfSPKtJJ7Dp1GPP8f7w==} + bn.js@5.2.5: + resolution: {integrity: sha512-Vq886eXykuP5E6HcKSSStP3bJgrE6In5WKxVUvJ8XGpWWYs2xZHWqUwzCtGgEtBcxyd57KBFDPFoUfNzdaHCNg==} + body-parser@2.2.2: resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==} engines: {node: '>=18'} @@ -1464,8 +1476,8 @@ packages: resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} engines: {node: '>=18'} - commander@14.0.3: - resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==} + commander@14.0.2: + resolution: {integrity: sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==} engines: {node: '>=20'} commander@2.20.3: @@ -3003,9 +3015,9 @@ snapshots: '@coral-xyz/anchor@0.32.1(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)': dependencies: '@coral-xyz/anchor-errors': 0.31.1 - '@coral-xyz/borsh': 0.31.1(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)) + '@coral-xyz/borsh': 0.31.1(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)) '@noble/hashes': 1.8.0 - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) bn.js: 5.2.3 bs58: 4.0.1 buffer-layout: 1.2.2 @@ -3021,9 +3033,9 @@ snapshots: - typescript - utf-8-validate - '@coral-xyz/borsh@0.31.1(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3))': + '@coral-xyz/borsh@0.31.1(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3))': dependencies: - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) bn.js: 5.2.3 buffer-layout: 1.2.2 @@ -3228,7 +3240,7 @@ snapshots: '@coral-xyz/anchor': 0.32.1(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) '@noble/curves': 2.2.0 '@noble/hashes': 1.8.0 - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) transitivePeerDependencies: - bufferutil - encoding @@ -3399,7 +3411,7 @@ snapshots: '@solana/buffer-layout-utils@0.2.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)': dependencies: '@solana/buffer-layout': 4.0.1 - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) bigint-buffer: 1.1.5 bignumber.js: 9.3.1 transitivePeerDependencies: @@ -3417,9 +3429,10 @@ snapshots: '@solana/errors': 2.0.0-rc.1(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-core@2.3.0(typescript@5.9.3)': + '@solana/codecs-core@5.5.1(typescript@5.9.3)': dependencies: - '@solana/errors': 2.3.0(typescript@5.9.3) + '@solana/errors': 5.5.1(typescript@5.9.3) + optionalDependencies: typescript: 5.9.3 '@solana/codecs-data-structures@2.0.0-rc.1(typescript@5.9.3)': @@ -3435,10 +3448,11 @@ snapshots: '@solana/errors': 2.0.0-rc.1(typescript@5.9.3) typescript: 5.9.3 - '@solana/codecs-numbers@2.3.0(typescript@5.9.3)': + '@solana/codecs-numbers@5.5.1(typescript@5.9.3)': dependencies: - '@solana/codecs-core': 2.3.0(typescript@5.9.3) - '@solana/errors': 2.3.0(typescript@5.9.3) + '@solana/codecs-core': 5.5.1(typescript@5.9.3) + '@solana/errors': 5.5.1(typescript@5.9.3) + optionalDependencies: typescript: 5.9.3 '@solana/codecs-strings@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': @@ -3466,10 +3480,11 @@ snapshots: commander: 12.1.0 typescript: 5.9.3 - '@solana/errors@2.3.0(typescript@5.9.3)': + '@solana/errors@5.5.1(typescript@5.9.3)': dependencies: chalk: 5.6.2 - commander: 14.0.3 + commander: 14.0.2 + optionalDependencies: typescript: 5.9.3 '@solana/options@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': @@ -3483,29 +3498,29 @@ snapshots: transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/spl-token-group@0.0.7(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': + '@solana/spl-token-group@0.0.7(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) transitivePeerDependencies: - fastestsmallesttextencoderdecoder - typescript - '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': + '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)': dependencies: '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) transitivePeerDependencies: - fastestsmallesttextencoderdecoder - typescript - '@solana/spl-token@0.4.14(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(bufferutil@4.1.0)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)(utf-8-validate@6.0.6)': + '@solana/spl-token@0.4.14(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(bufferutil@4.1.0)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3)(utf-8-validate@6.0.6)': dependencies: '@solana/buffer-layout': 4.0.1 '@solana/buffer-layout-utils': 0.2.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) - '@solana/spl-token-group': 0.0.7(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/spl-token-metadata': 0.1.6(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) - '@solana/web3.js': 1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + '@solana/spl-token-group': 0.0.7(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + '@solana/spl-token-metadata': 0.1.6(@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.9.3) + '@solana/web3.js': 1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) buffer: 6.0.3 transitivePeerDependencies: - bufferutil @@ -3514,15 +3529,15 @@ snapshots: - typescript - utf-8-validate - '@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)': + '@solana/web3.js@1.99.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)': dependencies: '@babel/runtime': 7.29.7 '@noble/curves': 1.9.7 '@noble/hashes': 1.8.0 '@solana/buffer-layout': 4.0.1 - '@solana/codecs-numbers': 2.3.0(typescript@5.9.3) + '@solana/codecs-numbers': 5.5.1(typescript@5.9.3) agentkeepalive: 4.6.0 - bn.js: 5.2.3 + bn.js: 5.2.5 borsh: 0.7.0 bs58: 4.0.1 buffer: 6.0.3 @@ -3811,6 +3826,8 @@ snapshots: bn.js@5.2.3: {} + bn.js@5.2.5: {} + body-parser@2.2.2: dependencies: bytes: 3.1.2 @@ -3827,7 +3844,7 @@ snapshots: borsh@0.7.0: dependencies: - bn.js: 5.2.3 + bn.js: 5.2.5 bs58: 4.0.1 text-encoding-utf-8: 1.0.2 @@ -3940,7 +3957,7 @@ snapshots: commander@12.1.0: {} - commander@14.0.3: {} + commander@14.0.2: {} commander@2.20.3: {} From 942fb8be93b22ab7931aa992e7308bc23b15af4c Mon Sep 17 00:00:00 2001 From: NubsCarson <192162056+NubsCarson@users.noreply.github.com> Date: Mon, 14 Sep 2026 18:03:12 -0400 Subject: [PATCH 2/2] test: decode legacy v0 and v1 workflow failure responses --- packages/core/src/nft/workflow.spec.ts | 44 ++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/core/src/nft/workflow.spec.ts b/packages/core/src/nft/workflow.spec.ts index a2165cc1..27b65c3e 100644 --- a/packages/core/src/nft/workflow.spec.ts +++ b/packages/core/src/nft/workflow.spec.ts @@ -1,5 +1,5 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; -import { Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js"; +import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js"; import { publishWorkflow, unlockWorkflow, sendTx } from "./workflow.js"; import { FormatError } from "./checkFormat.js"; import * as chain from "../core/chain.js"; @@ -119,14 +119,46 @@ Workflow body here, long enough to pass the body length check easily.`; // value.err. sendTx must throw on it — otherwise a reverted buy_item returns a // signature, the surface reports "Successfully purchased", and the soulbound // token is never minted (→ later "balance: 0" on the comment gate). - it("sendTx throws (with logs) when a confirmed tx carries an execution error", async () => { + it.each(["legacy", 0, 1] as const)("preserves failure logs from a %s RPC response", async (version) => { mockConn.confirmTransaction.mockResolvedValueOnce({ value: { err: { InstructionError: [0, "Custom"] } } }); - mockConn.getTransaction = vi.fn().mockResolvedValue({ - meta: { err: { InstructionError: [0, "Custom"] }, logMessages: ["Program log: buy_item", "Program failed: insufficient funds"] }, + // Exercise web3's response decoder, not just a mocked getTransaction result. + const rpcFetch = vi.fn(async (_url, init) => { + const request = JSON.parse(init!.body as string); + return new Response(JSON.stringify({ + jsonrpc: "2.0", id: request.id, + result: { + slot: 1, version, + transaction: { + signatures: [], + message: { + accountKeys: [PublicKey.default.toBase58()], + header: { numRequiredSignatures: 1, numReadonlySignedAccounts: 0, numReadonlyUnsignedAccounts: 0 }, + recentBlockhash: PublicKey.default.toBase58(), + instructions: [], + ...(version === 0 ? { addressTableLookups: [] } : {}), + ...(version === 1 ? { transactionConfig: { + computeUnitLimit: 200000, loadedAccountsDataSizeLimit: 33554432, + heapSize: null, priorityFee: null, + } } : {}), + }, + }, + meta: { + err: { InstructionError: [0, "Custom"] }, fee: 5000, + preBalances: [10000], postBalances: [5000], + logMessages: ["Program log: buy_item", "Program failed: insufficient funds"], + }, + }, + })); }); + const connection = new Connection("http://rpc.test", { fetch: rpcFetch }); + mockConn.getTransaction = connection.getTransaction.bind(connection); const dummyIx = new TransactionInstruction({ programId: PublicKey.default, keys: [], data: Buffer.from([]) }); - await expect(sendTx(mockConn as any, signer, [dummyIx])).rejects.toThrow(/failed on-chain/); - expect(mockConn.getTransaction).toHaveBeenCalledWith("mockTxSig", expect.objectContaining({ maxSupportedTransactionVersion: 1 })); + await expect(sendTx(mockConn as any, signer, [dummyIx])).rejects.toThrow(/failed on-chain:[\s\S]*insufficient funds/); + const request = JSON.parse(rpcFetch.mock.calls[0][1]!.body as string); + expect(request.method).toBe("getTransaction"); + expect(request.params).toEqual(["mockTxSig", { + maxSupportedTransactionVersion: 1, commitment: "confirmed", + }]); }); });