@bounded-sh/core 0.0.89 → 0.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/client/client-transaction-versions.d.ts +2 -0
  2. package/dist/client/solana-operations.d.ts +63 -0
  3. package/dist/client/solana-transaction-read.d.ts +13 -0
  4. package/dist/client/solana-v1-operations.d.ts +9 -0
  5. package/dist/{index-BxzaztPl.js → index-BjLa1c_O.js} +71 -10
  6. package/dist/index-BjLa1c_O.js.map +1 -0
  7. package/dist/{index-P9HgYxQ6.mjs → index-DM016I43.mjs} +70 -11
  8. package/dist/index-DM016I43.mjs.map +1 -0
  9. package/dist/index.js +1 -1
  10. package/dist/index.mjs +1 -1
  11. package/dist/{realtime-store-BfnJefdw.js → realtime-store-O-5CDrGm.js} +2 -2
  12. package/dist/{realtime-store-BfnJefdw.js.map → realtime-store-O-5CDrGm.js.map} +1 -1
  13. package/dist/{realtime-store-65vgABGG.mjs → realtime-store-zORqBwjW.mjs} +2 -2
  14. package/dist/{realtime-store-65vgABGG.mjs.map → realtime-store-zORqBwjW.mjs.map} +1 -1
  15. package/dist/{solana-message-CIwmajWk.mjs → solana-message-CmvedcGr.mjs} +2 -2
  16. package/dist/{solana-message-CIwmajWk.mjs.map → solana-message-CmvedcGr.mjs.map} +1 -1
  17. package/dist/{solana-message-CfwyiOZc.js → solana-message-DY0FVgHp.js} +2 -2
  18. package/dist/{solana-message-CfwyiOZc.js.map → solana-message-DY0FVgHp.js.map} +1 -1
  19. package/dist/{solana-operations-BFH2w7qn.js → solana-operations-DSAWnjWi.js} +146 -28
  20. package/dist/solana-operations-DSAWnjWi.js.map +1 -0
  21. package/dist/{solana-operations-BbyfKGSN.mjs → solana-operations-D_e7AMhd.mjs} +139 -29
  22. package/dist/solana-operations-D_e7AMhd.mjs.map +1 -0
  23. package/dist/solana-v1-operations-ByWdgO_7.js +175 -0
  24. package/dist/solana-v1-operations-ByWdgO_7.js.map +1 -0
  25. package/dist/solana-v1-operations-DF6Cp0IX.mjs +173 -0
  26. package/dist/solana-v1-operations-DF6Cp0IX.mjs.map +1 -0
  27. package/dist/types.d.ts +36 -0
  28. package/package.json +2 -1
  29. package/dist/index-BxzaztPl.js.map +0 -1
  30. package/dist/index-P9HgYxQ6.mjs.map +0 -1
  31. package/dist/solana-operations-BFH2w7qn.js.map +0 -1
  32. package/dist/solana-operations-BbyfKGSN.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-v1-operations-ByWdgO_7.js","sources":["../.rollup-tmp/client/solana-v1-operations.js"],"sourcesContent":["// solana-v1-operations.ts - the SIMD-0385 v1 half of the pre-built write lane.\n//\n// The realtime worker hands the SDK a serialized, possibly partially-signed\n// transaction (sponsor and attestation signatures may already be attached). For\n// v1 wires (first byte 0x81) @solana/web3.js's legacy/v0 classes cannot even\n// deserialize the bytes, so this lane decodes with @solana/kit, runs the SAME\n// semantic validation the v0 lane runs (program allow-list, setup-shape\n// recomputation, OA-0001 intent binding), refreshes the lifetime only while the\n// transaction is still unsigned, signs through the provider's `signTransactionV1`,\n// and submits base64 over the same RPC handle the v0 lane uses.\n//\n// Lazy-loaded: `@solana/kit` must never enter the SDK's initial chunk.\nimport { Buffer } from 'buffer';\nimport { getConfig } from './config';\nimport { BoundedOnchainRuleRejection, decodeBase58, encodeBase58, errorText, isBoundedOnchainRuleRejection, isDefinitiveSolanaSendFailure, validateServerTransactionSemantics, } from './solana-operations';\nimport { getTransactionJson } from './solana-transaction-read';\nfunction transactionHasSignature(transaction) {\n return Object.values(transaction.signatures).some((sig) => !!sig && sig.some((byte) => byte !== 0));\n}\nfunction sameBytes(a, b) {\n if (a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i += 1)\n if (a[i] !== b[i])\n return false;\n return true;\n}\nasync function decodeAndValidate(serializedTransaction, options) {\n const kit = await import('@solana/kit');\n const transaction = kit.getTransactionDecoder().decode(Buffer.from(serializedTransaction, 'base64'));\n const compiledMessage = kit.getCompiledTransactionMessageDecoder().decode(transaction.messageBytes);\n if (compiledMessage.version !== 1) {\n throw new Error(`${options.label} announced SIMD-0385 v1 but decoded as version ${String(compiledMessage.version)}`);\n }\n if (compiledMessage.instructionHeaders.length !== compiledMessage.instructionPayloads.length) {\n throw new Error(`${options.label} has mismatched v1 instruction headers and payloads`);\n }\n const { PublicKey } = await import('@solana/web3.js');\n const accountKeys = compiledMessage.staticAccounts.map((key) => new PublicKey(key));\n const instructions = compiledMessage.instructionHeaders.map((header, index) => {\n if (header.programAccountIndex >= accountKeys.length)\n throw new Error(`${options.label} has an invalid program account index`);\n const payload = compiledMessage.instructionPayloads[index];\n return {\n programId: accountKeys[header.programAccountIndex].toBase58(),\n accountKeyIndexes: [...payload.instructionAccountIndices],\n data: Uint8Array.from(payload.instructionData),\n };\n });\n validateServerTransactionSemantics(Object.assign(Object.assign({}, options), { accountKeys, isAccountSigner: (index) => index >= 0 && index < compiledMessage.header.numSignerAccounts, instructions, PublicKeyCtor: PublicKey }));\n return { transaction, compiledMessage, kit };\n}\n/**\n * LF-003 parity with the v0 lane: an UNSIGNED transaction is re-based on a live\n * blockhash before the wallet signs it; a transaction that already carries a\n * co-signer's signature must keep the exact message it was co-signed against,\n * and its fence must name that same blockhash.\n */\nasync function refreshLifetime(transaction, compiledMessage, kit, rpc, serverFence) {\n var _a;\n const fence = { blockhash: serverFence.blockhash, lastValidBlockHeight: serverFence.lastValidBlockHeight };\n if (transactionHasSignature(transaction)) {\n if (String(compiledMessage.lifetimeToken) !== fence.blockhash) {\n throw new Error(`The pre-built v1 transaction was co-signed against blockhash ${String(compiledMessage.lifetimeToken)} ` +\n `but its expiry fence names ${fence.blockhash}. Nothing was signed.`);\n }\n return { transaction, fence };\n }\n if (!rpc)\n return { transaction, fence };\n if (typeof rpc.getLatestBlockhash !== 'function') {\n throw new Error('Pre-built v1 signing needs a current blockhash, but the configured Solana RPC cannot report one. Nothing was signed.');\n }\n const latest = await rpc.getLatestBlockhash('confirmed');\n const decoded = decodeBase58(String((_a = latest === null || latest === void 0 ? void 0 : latest.blockhash) !== null && _a !== void 0 ? _a : ''));\n if (decoded === null || decoded.length !== 32) {\n throw new Error(`The configured Solana RPC returned \"${latest === null || latest === void 0 ? void 0 : latest.blockhash}\" as the current blockhash, which is not a 32-byte base58 value. Nothing was signed.`);\n }\n const decompiled = kit.decompileTransactionMessage(compiledMessage, { lastValidBlockHeight: BigInt(serverFence.lastValidBlockHeight) });\n const refreshed = kit.setTransactionMessageLifetimeUsingBlockhash({ blockhash: kit.blockhash(latest.blockhash), lastValidBlockHeight: BigInt(latest.lastValidBlockHeight) }, decompiled);\n return {\n transaction: kit.compileTransaction(refreshed),\n fence: { blockhash: latest.blockhash, lastValidBlockHeight: latest.lastValidBlockHeight },\n };\n}\nexport async function handlePreBuiltV1Transaction(tx, authProvider, options, expectedIntent) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;\n const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await getConfig();\n const decoded = await decodeAndValidate(tx.serializedTransaction, {\n label: 'Pre-built v1 transaction', expectedAppId: config.appId, expectedIntent,\n });\n if (typeof authProvider.signTransactionV1 !== 'function') {\n // The worker only builds v1 for a client that advertised it; reaching this\n // means the provider changed underneath the write. Refuse before any RPC.\n throw new Error('The write came back as a Solana transaction v1 (SIMD-0385) but this auth provider cannot sign v1. Nothing was signed.');\n }\n const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;\n const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();\n const injectedRpc = (_d = options === null || options === void 0 ? void 0 : options._overrides) === null || _d === void 0 ? void 0 : _d._solanaRpc;\n if (shouldSubmit && !rpcUrl && !injectedRpc) {\n throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}. ` +\n `Pass a TOP-LEVEL rpcUrl (with chain) to init(), e.g. ` +\n `init({ appId, chain: '${tx.network}', rpcUrl: '<your ${tx.network} RPC endpoint>' }); ` +\n `a nested walletLogin.rpcUrl only configures wallet login and does not enable submission.`);\n }\n const { Connection } = await import('@solana/web3.js');\n const connection = injectedRpc !== null && injectedRpc !== void 0 ? injectedRpc : (rpcUrl ? new Connection(rpcUrl, 'confirmed') : null);\n const refreshed = await refreshLifetime(decoded.transaction, decoded.compiledMessage, decoded.kit, connection, tx);\n const signedTx = await authProvider.signTransactionV1(refreshed.transaction);\n if (!sameBytes(signedTx.messageBytes, refreshed.transaction.messageBytes)) {\n throw new Error('The signer changed the v1 transaction message instead of signing the exact transaction. Nothing was submitted.');\n }\n const feePayerAddress = String((_e = decoded.compiledMessage.staticAccounts[0]) !== null && _e !== void 0 ? _e : '');\n const feePayerSignature = signedTx.signatures[feePayerAddress];\n const rawTx = Uint8Array.from(decoded.kit.getTransactionEncoder().encode(signedTx));\n const signedTransaction = Buffer.from(rawTx).toString('base64');\n if (!shouldSubmit) {\n return { outcome: 'signed', lane: 'solana', transactionSignature: null, signedTransaction, fence: refreshed.fence };\n }\n if (!feePayerSignature || feePayerSignature.every((byte) => byte === 0)) {\n throw new Error('The signed v1 transaction carries no fee-payer signature; it cannot be submitted.');\n }\n // The transaction id is the fee payer's signature, derived from the signed bytes\n // BEFORE broadcasting so a lost send response still yields a reconcilable id.\n const signature = encodeBase58(Uint8Array.from(feePayerSignature));\n const submitRpc = connection;\n try {\n await submitRpc.sendRawTransaction(rawTx, { skipPreflight: false, maxRetries: 3 });\n }\n catch (error) {\n if (isDefinitiveSolanaSendFailure(error)) {\n if (isBoundedOnchainRuleRejection(error))\n throw new BoundedOnchainRuleRejection(error);\n throw error;\n }\n return {\n outcome: 'submitted', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,\n reason: `Broadcast response was lost or inconclusive: ${errorText(error)}`,\n };\n }\n let confirmation;\n try {\n confirmation = await submitRpc.confirmTransaction({ signature, blockhash: refreshed.fence.blockhash, lastValidBlockHeight: refreshed.fence.lastValidBlockHeight }, 'confirmed');\n }\n catch (error) {\n return {\n outcome: 'submitted', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,\n reason: `Confirmation outcome unknown: ${errorText(error)}`,\n };\n }\n if ((_f = confirmation.value) === null || _f === void 0 ? void 0 : _f.err) {\n let logMessages;\n try {\n logMessages = (_h = (_g = (await getTransactionJson(submitRpc, signature, 'confirmed'))) === null || _g === void 0 ? void 0 : _g.meta) === null || _h === void 0 ? void 0 : _h.logMessages;\n }\n catch (_l) {\n // Diagnostic only; the on-chain error is the verdict.\n }\n if (isBoundedOnchainRuleRejection(confirmation.value.err, logMessages)) {\n throw new BoundedOnchainRuleRejection(confirmation.value.err, logMessages);\n }\n throw new Error(`Transaction failed: ${logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err)}`);\n }\n return {\n outcome: 'confirmed', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,\n confirmationContextSlot: (_k = (_j = confirmation.context) === null || _j === void 0 ? void 0 : _j.slot) !== null && _k !== void 0 ? _k : 0,\n };\n}\n"],"names":["Buffer","validateServerTransactionSemantics","decodeBase58","getConfig","encodeBase58","isDefinitiveSolanaSendFailure","isBoundedOnchainRuleRejection","BoundedOnchainRuleRejection","errorText","getTransactionJson"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA,SAAS,uBAAuB,CAAC,WAAW,EAAE;AAC9C,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;AACvG;AACA,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;AACzB,IAAI,IAAI,CAAC,CAAC,M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ACL;;;;"}
@@ -0,0 +1,173 @@
1
+ import { g as getConfig, b as bufferExports, a as getTransactionJson } from './index-DM016I43.mjs';
2
+ import { encodeBase58, isDefinitiveSolanaSendFailure, isBoundedOnchainRuleRejection, BoundedOnchainRuleRejection, errorText, validateServerTransactionSemantics, decodeBase58 } from './solana-operations-D_e7AMhd.mjs';
3
+ import 'axios';
4
+ import 'tweetnacl';
5
+ import 'reconnecting-websocket';
6
+
7
+ // solana-v1-operations.ts - the SIMD-0385 v1 half of the pre-built write lane.
8
+ //
9
+ // The realtime worker hands the SDK a serialized, possibly partially-signed
10
+ // transaction (sponsor and attestation signatures may already be attached). For
11
+ // v1 wires (first byte 0x81) @solana/web3.js's legacy/v0 classes cannot even
12
+ // deserialize the bytes, so this lane decodes with @solana/kit, runs the SAME
13
+ // semantic validation the v0 lane runs (program allow-list, setup-shape
14
+ // recomputation, OA-0001 intent binding), refreshes the lifetime only while the
15
+ // transaction is still unsigned, signs through the provider's `signTransactionV1`,
16
+ // and submits base64 over the same RPC handle the v0 lane uses.
17
+ //
18
+ // Lazy-loaded: `@solana/kit` must never enter the SDK's initial chunk.
19
+ function transactionHasSignature(transaction) {
20
+ return Object.values(transaction.signatures).some((sig) => !!sig && sig.some((byte) => byte !== 0));
21
+ }
22
+ function sameBytes(a, b) {
23
+ if (a.length !== b.length)
24
+ return false;
25
+ for (let i = 0; i < a.length; i += 1)
26
+ if (a[i] !== b[i])
27
+ return false;
28
+ return true;
29
+ }
30
+ async function decodeAndValidate(serializedTransaction, options) {
31
+ const kit = await import('@solana/kit');
32
+ const transaction = kit.getTransactionDecoder().decode(bufferExports.Buffer.from(serializedTransaction, 'base64'));
33
+ const compiledMessage = kit.getCompiledTransactionMessageDecoder().decode(transaction.messageBytes);
34
+ if (compiledMessage.version !== 1) {
35
+ throw new Error(`${options.label} announced SIMD-0385 v1 but decoded as version ${String(compiledMessage.version)}`);
36
+ }
37
+ if (compiledMessage.instructionHeaders.length !== compiledMessage.instructionPayloads.length) {
38
+ throw new Error(`${options.label} has mismatched v1 instruction headers and payloads`);
39
+ }
40
+ const { PublicKey } = await import('@solana/web3.js');
41
+ const accountKeys = compiledMessage.staticAccounts.map((key) => new PublicKey(key));
42
+ const instructions = compiledMessage.instructionHeaders.map((header, index) => {
43
+ if (header.programAccountIndex >= accountKeys.length)
44
+ throw new Error(`${options.label} has an invalid program account index`);
45
+ const payload = compiledMessage.instructionPayloads[index];
46
+ return {
47
+ programId: accountKeys[header.programAccountIndex].toBase58(),
48
+ accountKeyIndexes: [...payload.instructionAccountIndices],
49
+ data: Uint8Array.from(payload.instructionData),
50
+ };
51
+ });
52
+ validateServerTransactionSemantics(Object.assign(Object.assign({}, options), { accountKeys, isAccountSigner: (index) => index >= 0 && index < compiledMessage.header.numSignerAccounts, instructions, PublicKeyCtor: PublicKey }));
53
+ return { transaction, compiledMessage, kit };
54
+ }
55
+ /**
56
+ * LF-003 parity with the v0 lane: an UNSIGNED transaction is re-based on a live
57
+ * blockhash before the wallet signs it; a transaction that already carries a
58
+ * co-signer's signature must keep the exact message it was co-signed against,
59
+ * and its fence must name that same blockhash.
60
+ */
61
+ async function refreshLifetime(transaction, compiledMessage, kit, rpc, serverFence) {
62
+ var _a;
63
+ const fence = { blockhash: serverFence.blockhash, lastValidBlockHeight: serverFence.lastValidBlockHeight };
64
+ if (transactionHasSignature(transaction)) {
65
+ if (String(compiledMessage.lifetimeToken) !== fence.blockhash) {
66
+ throw new Error(`The pre-built v1 transaction was co-signed against blockhash ${String(compiledMessage.lifetimeToken)} ` +
67
+ `but its expiry fence names ${fence.blockhash}. Nothing was signed.`);
68
+ }
69
+ return { transaction, fence };
70
+ }
71
+ if (!rpc)
72
+ return { transaction, fence };
73
+ if (typeof rpc.getLatestBlockhash !== 'function') {
74
+ throw new Error('Pre-built v1 signing needs a current blockhash, but the configured Solana RPC cannot report one. Nothing was signed.');
75
+ }
76
+ const latest = await rpc.getLatestBlockhash('confirmed');
77
+ const decoded = decodeBase58(String((_a = latest === null || latest === void 0 ? void 0 : latest.blockhash) !== null && _a !== void 0 ? _a : ''));
78
+ if (decoded === null || decoded.length !== 32) {
79
+ throw new Error(`The configured Solana RPC returned "${latest === null || latest === void 0 ? void 0 : latest.blockhash}" as the current blockhash, which is not a 32-byte base58 value. Nothing was signed.`);
80
+ }
81
+ const decompiled = kit.decompileTransactionMessage(compiledMessage, { lastValidBlockHeight: BigInt(serverFence.lastValidBlockHeight) });
82
+ const refreshed = kit.setTransactionMessageLifetimeUsingBlockhash({ blockhash: kit.blockhash(latest.blockhash), lastValidBlockHeight: BigInt(latest.lastValidBlockHeight) }, decompiled);
83
+ return {
84
+ transaction: kit.compileTransaction(refreshed),
85
+ fence: { blockhash: latest.blockhash, lastValidBlockHeight: latest.lastValidBlockHeight },
86
+ };
87
+ }
88
+ async function handlePreBuiltV1Transaction(tx, authProvider, options, expectedIntent) {
89
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
90
+ const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await getConfig();
91
+ const decoded = await decodeAndValidate(tx.serializedTransaction, {
92
+ label: 'Pre-built v1 transaction', expectedAppId: config.appId, expectedIntent,
93
+ });
94
+ if (typeof authProvider.signTransactionV1 !== 'function') {
95
+ // The worker only builds v1 for a client that advertised it; reaching this
96
+ // means the provider changed underneath the write. Refuse before any RPC.
97
+ throw new Error('The write came back as a Solana transaction v1 (SIMD-0385) but this auth provider cannot sign v1. Nothing was signed.');
98
+ }
99
+ const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;
100
+ const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();
101
+ const injectedRpc = (_d = options === null || options === void 0 ? void 0 : options._overrides) === null || _d === void 0 ? void 0 : _d._solanaRpc;
102
+ if (shouldSubmit && !rpcUrl && !injectedRpc) {
103
+ throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}. ` +
104
+ `Pass a TOP-LEVEL rpcUrl (with chain) to init(), e.g. ` +
105
+ `init({ appId, chain: '${tx.network}', rpcUrl: '<your ${tx.network} RPC endpoint>' }); ` +
106
+ `a nested walletLogin.rpcUrl only configures wallet login and does not enable submission.`);
107
+ }
108
+ const { Connection } = await import('@solana/web3.js');
109
+ const connection = injectedRpc !== null && injectedRpc !== void 0 ? injectedRpc : (rpcUrl ? new Connection(rpcUrl, 'confirmed') : null);
110
+ const refreshed = await refreshLifetime(decoded.transaction, decoded.compiledMessage, decoded.kit, connection, tx);
111
+ const signedTx = await authProvider.signTransactionV1(refreshed.transaction);
112
+ if (!sameBytes(signedTx.messageBytes, refreshed.transaction.messageBytes)) {
113
+ throw new Error('The signer changed the v1 transaction message instead of signing the exact transaction. Nothing was submitted.');
114
+ }
115
+ const feePayerAddress = String((_e = decoded.compiledMessage.staticAccounts[0]) !== null && _e !== void 0 ? _e : '');
116
+ const feePayerSignature = signedTx.signatures[feePayerAddress];
117
+ const rawTx = Uint8Array.from(decoded.kit.getTransactionEncoder().encode(signedTx));
118
+ const signedTransaction = bufferExports.Buffer.from(rawTx).toString('base64');
119
+ if (!shouldSubmit) {
120
+ return { outcome: 'signed', lane: 'solana', transactionSignature: null, signedTransaction, fence: refreshed.fence };
121
+ }
122
+ if (!feePayerSignature || feePayerSignature.every((byte) => byte === 0)) {
123
+ throw new Error('The signed v1 transaction carries no fee-payer signature; it cannot be submitted.');
124
+ }
125
+ // The transaction id is the fee payer's signature, derived from the signed bytes
126
+ // BEFORE broadcasting so a lost send response still yields a reconcilable id.
127
+ const signature = encodeBase58(Uint8Array.from(feePayerSignature));
128
+ const submitRpc = connection;
129
+ try {
130
+ await submitRpc.sendRawTransaction(rawTx, { skipPreflight: false, maxRetries: 3 });
131
+ }
132
+ catch (error) {
133
+ if (isDefinitiveSolanaSendFailure(error)) {
134
+ if (isBoundedOnchainRuleRejection(error))
135
+ throw new BoundedOnchainRuleRejection(error);
136
+ throw error;
137
+ }
138
+ return {
139
+ outcome: 'submitted', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,
140
+ reason: `Broadcast response was lost or inconclusive: ${errorText(error)}`,
141
+ };
142
+ }
143
+ let confirmation;
144
+ try {
145
+ confirmation = await submitRpc.confirmTransaction({ signature, blockhash: refreshed.fence.blockhash, lastValidBlockHeight: refreshed.fence.lastValidBlockHeight }, 'confirmed');
146
+ }
147
+ catch (error) {
148
+ return {
149
+ outcome: 'submitted', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,
150
+ reason: `Confirmation outcome unknown: ${errorText(error)}`,
151
+ };
152
+ }
153
+ if ((_f = confirmation.value) === null || _f === void 0 ? void 0 : _f.err) {
154
+ let logMessages;
155
+ try {
156
+ logMessages = (_h = (_g = (await getTransactionJson(submitRpc, signature, 'confirmed'))) === null || _g === void 0 ? void 0 : _g.meta) === null || _h === void 0 ? void 0 : _h.logMessages;
157
+ }
158
+ catch (_l) {
159
+ // Diagnostic only; the on-chain error is the verdict.
160
+ }
161
+ if (isBoundedOnchainRuleRejection(confirmation.value.err, logMessages)) {
162
+ throw new BoundedOnchainRuleRejection(confirmation.value.err, logMessages);
163
+ }
164
+ throw new Error(`Transaction failed: ${logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err)}`);
165
+ }
166
+ return {
167
+ outcome: 'confirmed', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,
168
+ confirmationContextSlot: (_k = (_j = confirmation.context) === null || _j === void 0 ? void 0 : _j.slot) !== null && _k !== void 0 ? _k : 0,
169
+ };
170
+ }
171
+
172
+ export { handlePreBuiltV1Transaction };
173
+ //# sourceMappingURL=solana-v1-operations-DF6Cp0IX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-v1-operations-DF6Cp0IX.mjs","sources":["../.rollup-tmp/client/solana-v1-operations.js"],"sourcesContent":["// solana-v1-operations.ts - the SIMD-0385 v1 half of the pre-built write lane.\n//\n// The realtime worker hands the SDK a serialized, possibly partially-signed\n// transaction (sponsor and attestation signatures may already be attached). For\n// v1 wires (first byte 0x81) @solana/web3.js's legacy/v0 classes cannot even\n// deserialize the bytes, so this lane decodes with @solana/kit, runs the SAME\n// semantic validation the v0 lane runs (program allow-list, setup-shape\n// recomputation, OA-0001 intent binding), refreshes the lifetime only while the\n// transaction is still unsigned, signs through the provider's `signTransactionV1`,\n// and submits base64 over the same RPC handle the v0 lane uses.\n//\n// Lazy-loaded: `@solana/kit` must never enter the SDK's initial chunk.\nimport { Buffer } from 'buffer';\nimport { getConfig } from './config';\nimport { BoundedOnchainRuleRejection, decodeBase58, encodeBase58, errorText, isBoundedOnchainRuleRejection, isDefinitiveSolanaSendFailure, validateServerTransactionSemantics, } from './solana-operations';\nimport { getTransactionJson } from './solana-transaction-read';\nfunction transactionHasSignature(transaction) {\n return Object.values(transaction.signatures).some((sig) => !!sig && sig.some((byte) => byte !== 0));\n}\nfunction sameBytes(a, b) {\n if (a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i += 1)\n if (a[i] !== b[i])\n return false;\n return true;\n}\nasync function decodeAndValidate(serializedTransaction, options) {\n const kit = await import('@solana/kit');\n const transaction = kit.getTransactionDecoder().decode(Buffer.from(serializedTransaction, 'base64'));\n const compiledMessage = kit.getCompiledTransactionMessageDecoder().decode(transaction.messageBytes);\n if (compiledMessage.version !== 1) {\n throw new Error(`${options.label} announced SIMD-0385 v1 but decoded as version ${String(compiledMessage.version)}`);\n }\n if (compiledMessage.instructionHeaders.length !== compiledMessage.instructionPayloads.length) {\n throw new Error(`${options.label} has mismatched v1 instruction headers and payloads`);\n }\n const { PublicKey } = await import('@solana/web3.js');\n const accountKeys = compiledMessage.staticAccounts.map((key) => new PublicKey(key));\n const instructions = compiledMessage.instructionHeaders.map((header, index) => {\n if (header.programAccountIndex >= accountKeys.length)\n throw new Error(`${options.label} has an invalid program account index`);\n const payload = compiledMessage.instructionPayloads[index];\n return {\n programId: accountKeys[header.programAccountIndex].toBase58(),\n accountKeyIndexes: [...payload.instructionAccountIndices],\n data: Uint8Array.from(payload.instructionData),\n };\n });\n validateServerTransactionSemantics(Object.assign(Object.assign({}, options), { accountKeys, isAccountSigner: (index) => index >= 0 && index < compiledMessage.header.numSignerAccounts, instructions, PublicKeyCtor: PublicKey }));\n return { transaction, compiledMessage, kit };\n}\n/**\n * LF-003 parity with the v0 lane: an UNSIGNED transaction is re-based on a live\n * blockhash before the wallet signs it; a transaction that already carries a\n * co-signer's signature must keep the exact message it was co-signed against,\n * and its fence must name that same blockhash.\n */\nasync function refreshLifetime(transaction, compiledMessage, kit, rpc, serverFence) {\n var _a;\n const fence = { blockhash: serverFence.blockhash, lastValidBlockHeight: serverFence.lastValidBlockHeight };\n if (transactionHasSignature(transaction)) {\n if (String(compiledMessage.lifetimeToken) !== fence.blockhash) {\n throw new Error(`The pre-built v1 transaction was co-signed against blockhash ${String(compiledMessage.lifetimeToken)} ` +\n `but its expiry fence names ${fence.blockhash}. Nothing was signed.`);\n }\n return { transaction, fence };\n }\n if (!rpc)\n return { transaction, fence };\n if (typeof rpc.getLatestBlockhash !== 'function') {\n throw new Error('Pre-built v1 signing needs a current blockhash, but the configured Solana RPC cannot report one. Nothing was signed.');\n }\n const latest = await rpc.getLatestBlockhash('confirmed');\n const decoded = decodeBase58(String((_a = latest === null || latest === void 0 ? void 0 : latest.blockhash) !== null && _a !== void 0 ? _a : ''));\n if (decoded === null || decoded.length !== 32) {\n throw new Error(`The configured Solana RPC returned \"${latest === null || latest === void 0 ? void 0 : latest.blockhash}\" as the current blockhash, which is not a 32-byte base58 value. Nothing was signed.`);\n }\n const decompiled = kit.decompileTransactionMessage(compiledMessage, { lastValidBlockHeight: BigInt(serverFence.lastValidBlockHeight) });\n const refreshed = kit.setTransactionMessageLifetimeUsingBlockhash({ blockhash: kit.blockhash(latest.blockhash), lastValidBlockHeight: BigInt(latest.lastValidBlockHeight) }, decompiled);\n return {\n transaction: kit.compileTransaction(refreshed),\n fence: { blockhash: latest.blockhash, lastValidBlockHeight: latest.lastValidBlockHeight },\n };\n}\nexport async function handlePreBuiltV1Transaction(tx, authProvider, options, expectedIntent) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;\n const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await getConfig();\n const decoded = await decodeAndValidate(tx.serializedTransaction, {\n label: 'Pre-built v1 transaction', expectedAppId: config.appId, expectedIntent,\n });\n if (typeof authProvider.signTransactionV1 !== 'function') {\n // The worker only builds v1 for a client that advertised it; reaching this\n // means the provider changed underneath the write. Refuse before any RPC.\n throw new Error('The write came back as a Solana transaction v1 (SIMD-0385) but this auth provider cannot sign v1. Nothing was signed.');\n }\n const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;\n const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();\n const injectedRpc = (_d = options === null || options === void 0 ? void 0 : options._overrides) === null || _d === void 0 ? void 0 : _d._solanaRpc;\n if (shouldSubmit && !rpcUrl && !injectedRpc) {\n throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}. ` +\n `Pass a TOP-LEVEL rpcUrl (with chain) to init(), e.g. ` +\n `init({ appId, chain: '${tx.network}', rpcUrl: '<your ${tx.network} RPC endpoint>' }); ` +\n `a nested walletLogin.rpcUrl only configures wallet login and does not enable submission.`);\n }\n const { Connection } = await import('@solana/web3.js');\n const connection = injectedRpc !== null && injectedRpc !== void 0 ? injectedRpc : (rpcUrl ? new Connection(rpcUrl, 'confirmed') : null);\n const refreshed = await refreshLifetime(decoded.transaction, decoded.compiledMessage, decoded.kit, connection, tx);\n const signedTx = await authProvider.signTransactionV1(refreshed.transaction);\n if (!sameBytes(signedTx.messageBytes, refreshed.transaction.messageBytes)) {\n throw new Error('The signer changed the v1 transaction message instead of signing the exact transaction. Nothing was submitted.');\n }\n const feePayerAddress = String((_e = decoded.compiledMessage.staticAccounts[0]) !== null && _e !== void 0 ? _e : '');\n const feePayerSignature = signedTx.signatures[feePayerAddress];\n const rawTx = Uint8Array.from(decoded.kit.getTransactionEncoder().encode(signedTx));\n const signedTransaction = Buffer.from(rawTx).toString('base64');\n if (!shouldSubmit) {\n return { outcome: 'signed', lane: 'solana', transactionSignature: null, signedTransaction, fence: refreshed.fence };\n }\n if (!feePayerSignature || feePayerSignature.every((byte) => byte === 0)) {\n throw new Error('The signed v1 transaction carries no fee-payer signature; it cannot be submitted.');\n }\n // The transaction id is the fee payer's signature, derived from the signed bytes\n // BEFORE broadcasting so a lost send response still yields a reconcilable id.\n const signature = encodeBase58(Uint8Array.from(feePayerSignature));\n const submitRpc = connection;\n try {\n await submitRpc.sendRawTransaction(rawTx, { skipPreflight: false, maxRetries: 3 });\n }\n catch (error) {\n if (isDefinitiveSolanaSendFailure(error)) {\n if (isBoundedOnchainRuleRejection(error))\n throw new BoundedOnchainRuleRejection(error);\n throw error;\n }\n return {\n outcome: 'submitted', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,\n reason: `Broadcast response was lost or inconclusive: ${errorText(error)}`,\n };\n }\n let confirmation;\n try {\n confirmation = await submitRpc.confirmTransaction({ signature, blockhash: refreshed.fence.blockhash, lastValidBlockHeight: refreshed.fence.lastValidBlockHeight }, 'confirmed');\n }\n catch (error) {\n return {\n outcome: 'submitted', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,\n reason: `Confirmation outcome unknown: ${errorText(error)}`,\n };\n }\n if ((_f = confirmation.value) === null || _f === void 0 ? void 0 : _f.err) {\n let logMessages;\n try {\n logMessages = (_h = (_g = (await getTransactionJson(submitRpc, signature, 'confirmed'))) === null || _g === void 0 ? void 0 : _g.meta) === null || _h === void 0 ? void 0 : _h.logMessages;\n }\n catch (_l) {\n // Diagnostic only; the on-chain error is the verdict.\n }\n if (isBoundedOnchainRuleRejection(confirmation.value.err, logMessages)) {\n throw new BoundedOnchainRuleRejection(confirmation.value.err, logMessages);\n }\n throw new Error(`Transaction failed: ${logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err)}`);\n }\n return {\n outcome: 'confirmed', lane: 'solana', transactionSignature: signature, signedTransaction, fence: refreshed.fence,\n confirmationContextSlot: (_k = (_j = confirmation.context) === null || _j === void 0 ? void 0 : _j.slot) !== null && _k !== void 0 ? _k : 0,\n };\n}\n"],"names":["Buffer"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA,SAAS,uBAAuB,CAAC,WAAW,EAAE;AAC9C,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC;AACvG;AACA,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;AACzB,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;AAC7B,QAAQ,OAAO,KAAK;AACpB,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;AACxC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzB,YAAY,OAAO,KAAK;AACxB,IAAI,OAAO,IAAI;AACf;AACA,eAAe,iBAAiB,CAAC,qBAAqB,EAAE,OAAO,EAAE;AACjE,IAAI,MAAM,GAAG,GAAG,MAAM,OAAO,aAAa,CAAC;AAC3C,IAAI,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAACA,oBAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACxG,IAAI,MAA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AAY,MAAM,IAAI,2BAA2B,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC;AACtF,QAAQ;AACR,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,oBAAoB,EAAE,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACpI,IAAI;AACJ,IAAI,OAAO;AACX,QAAQ,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK;AACxH,QAAQ,uBAAuB,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC;AACnJ,KAAK;AACL;;;;"}
package/dist/types.d.ts CHANGED
@@ -1,9 +1,38 @@
1
1
  import type { PublicKey, TransactionInstruction, Transaction, VersionedTransaction } from "@solana/web3.js";
2
2
  import type { ClientConfig } from "./client/config";
3
+ /** Solana transaction wire formats: legacy, v0 (lookup tables), or SIMD-0385 v1. */
4
+ export type SolanaTransactionVersion = 'legacy' | 0 | 1;
5
+ /**
6
+ * A SIMD-0385 v1 transaction as @solana/kit represents it: the exact signed
7
+ * message bytes plus one signature slot per required signer keyed by address
8
+ * (null / all-zero = unsigned). Kept structural so wallet providers can sign v1
9
+ * message bytes without routing them through web3.js's legacy/v0-only classes.
10
+ */
11
+ export interface SolanaV1Transaction {
12
+ readonly messageBytes: Uint8Array;
13
+ readonly signatures: Readonly<Record<string, Uint8Array | null>>;
14
+ readonly lifetimeConstraint?: {
15
+ readonly blockhash: string;
16
+ readonly lastValidBlockHeight: bigint;
17
+ };
18
+ }
3
19
  export interface AuthProvider {
4
20
  login(): Promise<User | null>;
5
21
  signMessage(message: string): Promise<string>;
6
22
  signTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
23
+ /**
24
+ * Sign a SIMD-0385 v1 transaction. Optional: a provider that omits it can only
25
+ * sign legacy/v0, and the write request advertises exactly that, so the server
26
+ * never hands such a client a v1 transaction.
27
+ */
28
+ signTransactionV1?(transaction: SolanaV1Transaction): Promise<SolanaV1Transaction>;
29
+ /**
30
+ * The wire formats this provider can sign. Defaults to legacy + v0, plus v1
31
+ * when `signTransactionV1` is implemented. Providers that delegate to an
32
+ * external signer (a browser wallet, a hosted signer) report what THAT signer
33
+ * advertises, since a v1 transaction it cannot sign is a guaranteed failure.
34
+ */
35
+ supportedTransactionVersions?(): SolanaTransactionVersion[] | Promise<SolanaTransactionVersion[]>;
7
36
  /**
8
37
  * Signs and submits a Solana transaction to the network.
9
38
  *
@@ -322,6 +351,13 @@ export interface SolanaWriteRpc {
322
351
  };
323
352
  }>;
324
353
  getTransaction(signature: string, options?: any): Promise<any>;
354
+ /**
355
+ * A real web3.js `Connection` exposes its URL here. When present, the SDK reads
356
+ * transaction history as raw JSON-RPC instead of through `getTransaction`:
357
+ * web3.js 1.98.x throws inside its response parser on a SIMD-0385 v1
358
+ * transaction, and a throw there must not be mistaken for "not landed".
359
+ */
360
+ rpcEndpoint?: string;
325
361
  getSignatureStatuses?(signatures: string[], config?: any): Promise<{
326
362
  value?: Array<any>;
327
363
  context?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bounded-sh/core",
3
- "version": "0.0.89",
3
+ "version": "0.0.91",
4
4
  "description": "Shared client, data-plane, and transport primitives for Bounded, the full-stack app builder and runtime for AI-built apps: policy-enforced operations, files, functions, and realtime.",
5
5
  "homepage": "https://bounded.sh/docs/sdk",
6
6
  "main": "./dist/index.js",
@@ -50,6 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@coral-xyz/anchor": "0.31.1",
53
+ "@solana/kit": "8.2.0",
53
54
  "@solana/web3.js": "1.98.4",
54
55
  "@types/lodash": "4.17.21",
55
56
  "axios": "1.18.1",