@bounded-sh/core 0.0.64 → 0.0.66
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.
- package/dist/client/decline.d.ts +2 -0
- package/dist/client/functions.d.ts +8 -0
- package/dist/client/live-effects.d.ts +4 -2
- package/dist/client/operations.d.ts +90 -5
- package/dist/client/reconcile.d.ts +51 -0
- package/dist/client/solana-operations.d.ts +13 -3
- package/dist/{index-BIdD2yUB.js → index-DNZifL5j.js} +4015 -3326
- package/dist/index-DNZifL5j.js.map +1 -0
- package/dist/{index-BQ6e4MeP.mjs → index-TyXiW4Uf.mjs} +4014 -3325
- package/dist/index-TyXiW4Uf.mjs.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{realtime-store-Bz4Ob6K6.js → realtime-store-CINyAkPw.js} +2 -3
- package/dist/{realtime-store-Bz4Ob6K6.js.map → realtime-store-CINyAkPw.js.map} +1 -1
- package/dist/{realtime-store-DKngqviG.mjs → realtime-store-CpbnXM7q.mjs} +2 -3
- package/dist/{realtime-store-DKngqviG.mjs.map → realtime-store-CpbnXM7q.mjs.map} +1 -1
- package/dist/{solana-message-B0NoE4nC.js → solana-message-Bycv-L5n.js} +10 -8
- package/dist/solana-message-Bycv-L5n.js.map +1 -0
- package/dist/{solana-message-QUfJi1Qm.mjs → solana-message-DXXwC95Z.mjs} +10 -8
- package/dist/solana-message-DXXwC95Z.mjs.map +1 -0
- package/dist/{solana-operations-B2Oy9T7D.mjs → solana-operations-ChHG25O0.mjs} +161 -88
- package/dist/solana-operations-ChHG25O0.mjs.map +1 -0
- package/dist/{solana-operations-ngqIkN9W.js → solana-operations-Dm_4VnlB.js} +162 -88
- package/dist/solana-operations-Dm_4VnlB.js.map +1 -0
- package/dist/types.d.ts +370 -4
- package/dist/utils/auth-api.d.ts +15 -2
- package/dist/utils/core-platform.d.ts +7 -0
- package/dist/utils/rn-session-manager.d.ts +57 -7
- package/dist/utils/server-session-manager.d.ts +6 -1
- package/dist/utils/sol/sol-accessors.d.ts +0 -27
- package/dist/utils/sol/solana-message.d.ts +1 -1
- package/package.json +2 -2
- package/dist/index-BIdD2yUB.js.map +0 -1
- package/dist/index-BQ6e4MeP.mjs.map +0 -1
- package/dist/sol-utils-Cwxyl2h6.js +0 -232
- package/dist/sol-utils-Cwxyl2h6.js.map +0 -1
- package/dist/sol-utils-DVjPeoMy.mjs +0 -229
- package/dist/sol-utils-DVjPeoMy.mjs.map +0 -1
- package/dist/solana-message-B0NoE4nC.js.map +0 -1
- package/dist/solana-message-QUfJi1Qm.mjs.map +0 -1
- package/dist/solana-operations-B2Oy9T7D.mjs.map +0 -1
- package/dist/solana-operations-ngqIkN9W.js.map +0 -1
- package/dist/utils/sol/openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6FDevnet-program.d.ts +0 -2906
- package/dist/utils/sol/openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6FMainnet-program.d.ts +0 -2906
- package/dist/utils/sol/sol-utils.d.ts +0 -34
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var BN = require('bn.js');
|
|
4
|
-
|
|
5
|
-
// ─────────────────────────────────────────────────────────────
|
|
6
|
-
// Local implementation of getSimulationComputeUnits
|
|
7
|
-
// (Replaces @solana-developers/helpers to avoid Wallet import issue in browser/ESM builds)
|
|
8
|
-
// Source: https://github.com/solana-developers/helpers/blob/main/src/lib/transaction.ts
|
|
9
|
-
// ─────────────────────────────────────────────────────────────
|
|
10
|
-
/**
|
|
11
|
-
* Check if a given instruction is a SetComputeUnitLimit instruction
|
|
12
|
-
* See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29
|
|
13
|
-
*/
|
|
14
|
-
function isSetComputeLimitInstruction(ix, computeBudgetProgram) {
|
|
15
|
-
return (ix.programId.equals(computeBudgetProgram.programId) &&
|
|
16
|
-
ix.data[0] === 2 // opcode for setComputeUnitLimit is 2
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Get the compute units required for a set of instructions via simulation.
|
|
21
|
-
* Credit https://twitter.com/stegabob, originally from https://x.com/stegaBOB/status/1766662289392889920
|
|
22
|
-
*/
|
|
23
|
-
async function getSimulationComputeUnits(connection, instructions, payer, lookupTables, chainSdk, commitment = "confirmed") {
|
|
24
|
-
var _a, _b, _c;
|
|
25
|
-
const simulationInstructions = [...instructions];
|
|
26
|
-
// Replace or add compute limit instruction
|
|
27
|
-
const computeLimitIndex = simulationInstructions.findIndex(ix => isSetComputeLimitInstruction(ix, chainSdk.ComputeBudgetProgram));
|
|
28
|
-
const simulationLimitIx = chainSdk.ComputeBudgetProgram.setComputeUnitLimit({
|
|
29
|
-
units: 1400000,
|
|
30
|
-
});
|
|
31
|
-
if (computeLimitIndex >= 0) {
|
|
32
|
-
simulationInstructions[computeLimitIndex] = simulationLimitIx;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
simulationInstructions.unshift(simulationLimitIx);
|
|
36
|
-
}
|
|
37
|
-
const testTransaction = new chainSdk.VersionedTransaction(new chainSdk.TransactionMessage({
|
|
38
|
-
instructions: simulationInstructions,
|
|
39
|
-
payerKey: payer,
|
|
40
|
-
// RecentBlockhash can by any public key during simulation
|
|
41
|
-
// since 'replaceRecentBlockhash' is set to 'true' below
|
|
42
|
-
recentBlockhash: chainSdk.PublicKey.default.toString(),
|
|
43
|
-
}).compileToV0Message(lookupTables));
|
|
44
|
-
const rpcResponse = await connection.simulateTransaction(testTransaction, {
|
|
45
|
-
replaceRecentBlockhash: true,
|
|
46
|
-
sigVerify: false,
|
|
47
|
-
commitment,
|
|
48
|
-
});
|
|
49
|
-
if ((_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _a === void 0 ? void 0 : _a.err) {
|
|
50
|
-
const logs = ((_b = rpcResponse.value.logs) === null || _b === void 0 ? void 0 : _b.join("\n • ")) || "No logs available";
|
|
51
|
-
throw new Error(`Transaction simulation failed:\n •${logs}` +
|
|
52
|
-
JSON.stringify((_c = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _c === void 0 ? void 0 : _c.err));
|
|
53
|
-
}
|
|
54
|
-
return rpcResponse.value.unitsConsumed || null;
|
|
55
|
-
}
|
|
56
|
-
// ─────────────────────────────────────────────────────────────
|
|
57
|
-
// Serialization Helpers
|
|
58
|
-
// ─────────────────────────────────────────────────────────────
|
|
59
|
-
function isHexString(value) {
|
|
60
|
-
// Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back
|
|
61
|
-
// from the API for u64Val/i64Val should fall through to `new BN(value)` which
|
|
62
|
-
// accepts those shapes natively. Without this guard, calling .startsWith on a
|
|
63
|
-
// non-string blows up with TypeError.
|
|
64
|
-
if (typeof value !== "string")
|
|
65
|
-
return false;
|
|
66
|
-
// Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)
|
|
67
|
-
let testValue = value;
|
|
68
|
-
// Handle negative values
|
|
69
|
-
if (value.startsWith("-")) {
|
|
70
|
-
testValue = value.slice(1);
|
|
71
|
-
}
|
|
72
|
-
const hexRegex = /^(0x)?[0-9a-fA-F]+$/;
|
|
73
|
-
return hexRegex.test(testValue);
|
|
74
|
-
}
|
|
75
|
-
function prepareProgramArgs(documents, PublicKeyClass) {
|
|
76
|
-
return documents.map((doc) => ({
|
|
77
|
-
path: doc.path,
|
|
78
|
-
operations: doc.operations.map((op) => {
|
|
79
|
-
let preparedValue = null;
|
|
80
|
-
if (op.value) {
|
|
81
|
-
if ("u64Val" in op.value) {
|
|
82
|
-
if (isHexString(op.value.u64Val.value)) {
|
|
83
|
-
preparedValue = { u64Val: { value: new BN(op.value.u64Val.value, "hex") } };
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
preparedValue = { u64Val: { value: new BN(op.value.u64Val.value) } };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else if ("i64Val" in op.value) {
|
|
90
|
-
if (isHexString(op.value.i64Val.value)) {
|
|
91
|
-
if (op.value.i64Val.value.startsWith("-")) {
|
|
92
|
-
preparedValue = { i64Val: { value: new BN(op.value.i64Val.value.slice(1), "hex").mul(new BN(-1)) } };
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
preparedValue = { i64Val: { value: new BN(op.value.i64Val.value, "hex") } };
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
preparedValue = { i64Val: { value: new BN(op.value.i64Val.value) } };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (op.value.boolVal) {
|
|
103
|
-
preparedValue = { boolVal: { value: !!op.value.boolVal.value } };
|
|
104
|
-
}
|
|
105
|
-
else if (op.value.stringVal) {
|
|
106
|
-
preparedValue = { stringVal: { value: String(op.value.stringVal.value) } };
|
|
107
|
-
}
|
|
108
|
-
else if (op.value.addressVal) {
|
|
109
|
-
preparedValue = { addressVal: { value: new PublicKeyClass(op.value.addressVal.value) } };
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
preparedValue = op.value;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
key: op.key,
|
|
117
|
-
value: preparedValue,
|
|
118
|
-
operation: op.operation,
|
|
119
|
-
};
|
|
120
|
-
}),
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
// ─────────────────────────────────────────────────────────────
|
|
124
|
-
// Updated Transaction Builder: It now accepts a PublicKey for the payer
|
|
125
|
-
// ─────────────────────────────────────────────────────────────
|
|
126
|
-
async function buildSetDocumentsTransaction(connection, idl, programProvider, payerPublicKey, args, remainingAccounts, lutKey, preInstructions, simulate, additionalLutAddresses) {
|
|
127
|
-
// LITERAL dynamic import specifiers on purpose: bundlers can only code-split
|
|
128
|
-
// a lazy chunk when the specifier is statically analyzable. (An earlier pass
|
|
129
|
-
// obfuscated these to satisfy a bundle-grep check — that breaks Vite/webpack
|
|
130
|
-
// consumers at runtime. Verify laziness with esbuild --splitting instead.)
|
|
131
|
-
const [chainSdk, programSdk] = await Promise.all([
|
|
132
|
-
import('@solana/web3.js'),
|
|
133
|
-
import('@coral-xyz/anchor'),
|
|
134
|
-
]);
|
|
135
|
-
const { ComputeBudgetProgram, PublicKey } = chainSdk;
|
|
136
|
-
const { Program } = programSdk;
|
|
137
|
-
// The sync convertRemainingAccounts facade produces PublicKey DUCK-TYPES
|
|
138
|
-
// (base58/bytes/equals only) so callers can dedupe without loading web3.
|
|
139
|
-
// Anything entering Anchor/web3 internals must be a REAL PublicKey —
|
|
140
|
-
// instanceof checks and _bn internals are not part of the duck contract.
|
|
141
|
-
// web3 is loaded here, so rehydrate at this seam.
|
|
142
|
-
const asRealPublicKey = (value) => value instanceof PublicKey ? value : new PublicKey(value.toBytes());
|
|
143
|
-
remainingAccounts = remainingAccounts.map((account) => ({
|
|
144
|
-
pubkey: asRealPublicKey(account.pubkey),
|
|
145
|
-
isWritable: account.isWritable,
|
|
146
|
-
isSigner: account.isSigner,
|
|
147
|
-
}));
|
|
148
|
-
payerPublicKey = asRealPublicKey(payerPublicKey);
|
|
149
|
-
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
150
|
-
units: 1400000,
|
|
151
|
-
});
|
|
152
|
-
//TODO: Figure out long term solution to estimate heap frame size
|
|
153
|
-
const requestHeapFrameIx = ComputeBudgetProgram.requestHeapFrame({
|
|
154
|
-
bytes: 1024 * 160,
|
|
155
|
-
});
|
|
156
|
-
const instructions = [];
|
|
157
|
-
instructions.unshift(requestHeapFrameIx);
|
|
158
|
-
instructions.unshift(computeBudgetIx);
|
|
159
|
-
instructions.push(...preInstructions);
|
|
160
|
-
let tx = null;
|
|
161
|
-
if (idl.address === "openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F") {
|
|
162
|
-
const program = new Program(idl, programProvider);
|
|
163
|
-
// Single canonical set_documents wire format (ra_indices Vec<u8>).
|
|
164
|
-
tx = await program.methods
|
|
165
|
-
.setDocuments(args.app_id, prepareProgramArgs(args.documents, PublicKey), args.delete_paths, args.txData, simulate)
|
|
166
|
-
.preInstructions(instructions)
|
|
167
|
-
.accounts({
|
|
168
|
-
payer: payerPublicKey
|
|
169
|
-
})
|
|
170
|
-
.remainingAccounts(remainingAccounts)
|
|
171
|
-
.transaction();
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
throw new Error(`Invalid program id: ${idl.address}`);
|
|
175
|
-
}
|
|
176
|
-
tx.feePayer = payerPublicKey;
|
|
177
|
-
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
178
|
-
tx.recentBlockhash = blockhash;
|
|
179
|
-
// Resolve LUTs: additionalLutAddresses (when present) is the authoritative set.
|
|
180
|
-
// Falls back to lutKey alone for backwards compatibility.
|
|
181
|
-
const lookupTables = [];
|
|
182
|
-
if (additionalLutAddresses && additionalLutAddresses.length > 0) {
|
|
183
|
-
const results = await Promise.all(additionalLutAddresses.map(addr => connection.getAddressLookupTable(new PublicKey(addr)).catch(() => null)));
|
|
184
|
-
for (const result of results) {
|
|
185
|
-
if (result === null || result === void 0 ? void 0 : result.value) {
|
|
186
|
-
lookupTables.push(result.value);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
else if (lutKey != null) {
|
|
191
|
-
// The LUT may have just been created server-side and the client's RPC node
|
|
192
|
-
// may not have indexed it yet (load-balancer split). Retry with exponential
|
|
193
|
-
// back-off; first retry at 100 ms almost always resolves it.
|
|
194
|
-
let table = null;
|
|
195
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
196
|
-
const { value } = await connection.getAddressLookupTable(new PublicKey(lutKey));
|
|
197
|
-
if (value) {
|
|
198
|
-
table = value;
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
if (attempt < 4)
|
|
202
|
-
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
203
|
-
}
|
|
204
|
-
if (!table)
|
|
205
|
-
throw new Error('LUT not found after creation/extend');
|
|
206
|
-
lookupTables.push(table);
|
|
207
|
-
}
|
|
208
|
-
if (lookupTables.length === 0) {
|
|
209
|
-
const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [], chainSdk);
|
|
210
|
-
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
211
|
-
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
212
|
-
}); // 20% buffer
|
|
213
|
-
tx.instructions[0] = computeBudgetIxOptimized;
|
|
214
|
-
return { tx, blockhash, lastValidBlockHeight };
|
|
215
|
-
}
|
|
216
|
-
const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, lookupTables, chainSdk);
|
|
217
|
-
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
218
|
-
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
219
|
-
}); // 20% buffer
|
|
220
|
-
tx.instructions[0] = computeBudgetIxOptimized;
|
|
221
|
-
const msgV0 = new chainSdk.TransactionMessage({
|
|
222
|
-
payerKey: payerPublicKey,
|
|
223
|
-
recentBlockhash: blockhash,
|
|
224
|
-
instructions: tx.instructions,
|
|
225
|
-
}).compileToV0Message(lookupTables);
|
|
226
|
-
const vTx = new chainSdk.VersionedTransaction(msgV0);
|
|
227
|
-
return { tx: vTx, blockhash, lastValidBlockHeight };
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
exports.buildSetDocumentsTransaction = buildSetDocumentsTransaction;
|
|
231
|
-
exports.isHexString = isHexString;
|
|
232
|
-
//# sourceMappingURL=sol-utils-Cwxyl2h6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sol-utils-Cwxyl2h6.js","sources":["../.rollup-tmp/utils/sol/sol-utils.js"],"sourcesContent":["import BN from \"bn.js\";\n// ─────────────────────────────────────────────────────────────\n// Local implementation of getSimulationComputeUnits\n// (Replaces @solana-developers/helpers to avoid Wallet import issue in browser/ESM builds)\n// Source: https://github.com/solana-developers/helpers/blob/main/src/lib/transaction.ts\n// ─────────────────────────────────────────────────────────────\n/**\n * Check if a given instruction is a SetComputeUnitLimit instruction\n * See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29\n */\nfunction isSetComputeLimitInstruction(ix, computeBudgetProgram) {\n return (ix.programId.equals(computeBudgetProgram.programId) &&\n ix.data[0] === 2 // opcode for setComputeUnitLimit is 2\n );\n}\n/**\n * Get the compute units required for a set of instructions via simulation.\n * Credit https://twitter.com/stegabob, originally from https://x.com/stegaBOB/status/1766662289392889920\n */\nasync function getSimulationComputeUnits(connection, instructions, payer, lookupTables, chainSdk, commitment = \"confirmed\") {\n var _a, _b, _c;\n const simulationInstructions = [...instructions];\n // Replace or add compute limit instruction\n const computeLimitIndex = simulationInstructions.findIndex(ix => isSetComputeLimitInstruction(ix, chainSdk.ComputeBudgetProgram));\n const simulationLimitIx = chainSdk.ComputeBudgetProgram.setComputeUnitLimit({\n units: 1400000,\n });\n if (computeLimitIndex >= 0) {\n simulationInstructions[computeLimitIndex] = simulationLimitIx;\n }\n else {\n simulationInstructions.unshift(simulationLimitIx);\n }\n const testTransaction = new chainSdk.VersionedTransaction(new chainSdk.TransactionMessage({\n instructions: simulationInstructions,\n payerKey: payer,\n // RecentBlockhash can by any public key during simulation\n // since 'replaceRecentBlockhash' is set to 'true' below\n recentBlockhash: chainSdk.PublicKey.default.toString(),\n }).compileToV0Message(lookupTables));\n const rpcResponse = await connection.simulateTransaction(testTransaction, {\n replaceRecentBlockhash: true,\n sigVerify: false,\n commitment,\n });\n if ((_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _a === void 0 ? void 0 : _a.err) {\n const logs = ((_b = rpcResponse.value.logs) === null || _b === void 0 ? void 0 : _b.join(\"\\n • \")) || \"No logs available\";\n throw new Error(`Transaction simulation failed:\\n •${logs}` +\n JSON.stringify((_c = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _c === void 0 ? void 0 : _c.err));\n }\n return rpcResponse.value.unitsConsumed || null;\n}\n// ─────────────────────────────────────────────────────────────\n// Serialization Helpers\n// ─────────────────────────────────────────────────────────────\nexport function isHexString(value) {\n // Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back\n // from the API for u64Val/i64Val should fall through to `new BN(value)` which\n // accepts those shapes natively. Without this guard, calling .startsWith on a\n // non-string blows up with TypeError.\n if (typeof value !== \"string\")\n return false;\n // Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)\n let testValue = value;\n // Handle negative values\n if (value.startsWith(\"-\")) {\n testValue = value.slice(1);\n }\n const hexRegex = /^(0x)?[0-9a-fA-F]+$/;\n return hexRegex.test(testValue);\n}\nfunction prepareProgramArgs(documents, PublicKeyClass) {\n return documents.map((doc) => ({\n path: doc.path,\n operations: doc.operations.map((op) => {\n let preparedValue = null;\n if (op.value) {\n if (\"u64Val\" in op.value) {\n if (isHexString(op.value.u64Val.value)) {\n preparedValue = { u64Val: { value: new BN(op.value.u64Val.value, \"hex\") } };\n }\n else {\n preparedValue = { u64Val: { value: new BN(op.value.u64Val.value) } };\n }\n }\n else if (\"i64Val\" in op.value) {\n if (isHexString(op.value.i64Val.value)) {\n if (op.value.i64Val.value.startsWith(\"-\")) {\n preparedValue = { i64Val: { value: new BN(op.value.i64Val.value.slice(1), \"hex\").mul(new BN(-1)) } };\n }\n else {\n preparedValue = { i64Val: { value: new BN(op.value.i64Val.value, \"hex\") } };\n }\n }\n else {\n preparedValue = { i64Val: { value: new BN(op.value.i64Val.value) } };\n }\n }\n else if (op.value.boolVal) {\n preparedValue = { boolVal: { value: !!op.value.boolVal.value } };\n }\n else if (op.value.stringVal) {\n preparedValue = { stringVal: { value: String(op.value.stringVal.value) } };\n }\n else if (op.value.addressVal) {\n preparedValue = { addressVal: { value: new PublicKeyClass(op.value.addressVal.value) } };\n }\n else {\n preparedValue = op.value;\n }\n }\n return {\n key: op.key,\n value: preparedValue,\n operation: op.operation,\n };\n }),\n }));\n}\n// ─────────────────────────────────────────────────────────────\n// Updated Transaction Builder: It now accepts a PublicKey for the payer\n// ─────────────────────────────────────────────────────────────\nexport async function buildSetDocumentsTransaction(connection, idl, programProvider, payerPublicKey, args, remainingAccounts, lutKey, preInstructions, simulate, additionalLutAddresses) {\n // LITERAL dynamic import specifiers on purpose: bundlers can only code-split\n // a lazy chunk when the specifier is statically analyzable. (An earlier pass\n // obfuscated these to satisfy a bundle-grep check — that breaks Vite/webpack\n // consumers at runtime. Verify laziness with esbuild --splitting instead.)\n const [chainSdk, programSdk] = await Promise.all([\n import(\"@solana/web3.js\"),\n import(\"@coral-xyz/anchor\"),\n ]);\n const { ComputeBudgetProgram, PublicKey } = chainSdk;\n const { Program } = programSdk;\n // The sync convertRemainingAccounts facade produces PublicKey DUCK-TYPES\n // (base58/bytes/equals only) so callers can dedupe without loading web3.\n // Anything entering Anchor/web3 internals must be a REAL PublicKey —\n // instanceof checks and _bn internals are not part of the duck contract.\n // web3 is loaded here, so rehydrate at this seam.\n const asRealPublicKey = (value) => value instanceof PublicKey ? value : new PublicKey(value.toBytes());\n remainingAccounts = remainingAccounts.map((account) => ({\n pubkey: asRealPublicKey(account.pubkey),\n isWritable: account.isWritable,\n isSigner: account.isSigner,\n }));\n payerPublicKey = asRealPublicKey(payerPublicKey);\n const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({\n units: 1400000,\n });\n //TODO: Figure out long term solution to estimate heap frame size\n const requestHeapFrameIx = ComputeBudgetProgram.requestHeapFrame({\n bytes: 1024 * 160,\n });\n const instructions = [];\n instructions.unshift(requestHeapFrameIx);\n instructions.unshift(computeBudgetIx);\n instructions.push(...preInstructions);\n let tx = null;\n if (idl.address === \"openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F\") {\n const program = new Program(idl, programProvider);\n // Single canonical set_documents wire format (ra_indices Vec<u8>).\n tx = await program.methods\n .setDocuments(args.app_id, prepareProgramArgs(args.documents, PublicKey), args.delete_paths, args.txData, simulate)\n .preInstructions(instructions)\n .accounts({\n payer: payerPublicKey\n })\n .remainingAccounts(remainingAccounts)\n .transaction();\n }\n else {\n throw new Error(`Invalid program id: ${idl.address}`);\n }\n tx.feePayer = payerPublicKey;\n const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(\"confirmed\");\n tx.recentBlockhash = blockhash;\n // Resolve LUTs: additionalLutAddresses (when present) is the authoritative set.\n // Falls back to lutKey alone for backwards compatibility.\n const lookupTables = [];\n if (additionalLutAddresses && additionalLutAddresses.length > 0) {\n const results = await Promise.all(additionalLutAddresses.map(addr => connection.getAddressLookupTable(new PublicKey(addr)).catch(() => null)));\n for (const result of results) {\n if (result === null || result === void 0 ? void 0 : result.value) {\n lookupTables.push(result.value);\n }\n }\n }\n else if (lutKey != null) {\n // The LUT may have just been created server-side and the client's RPC node\n // may not have indexed it yet (load-balancer split). Retry with exponential\n // back-off; first retry at 100 ms almost always resolves it.\n let table = null;\n for (let attempt = 0; attempt < 5; attempt++) {\n const { value } = await connection.getAddressLookupTable(new PublicKey(lutKey));\n if (value) {\n table = value;\n break;\n }\n if (attempt < 4)\n await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));\n }\n if (!table)\n throw new Error('LUT not found after creation/extend');\n lookupTables.push(table);\n }\n if (lookupTables.length === 0) {\n const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [], chainSdk);\n const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({\n units: computeUnits ? computeUnits * 1.2 : 1400000,\n }); // 20% buffer\n tx.instructions[0] = computeBudgetIxOptimized;\n return { tx, blockhash, lastValidBlockHeight };\n }\n const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, lookupTables, chainSdk);\n const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({\n units: computeUnits ? computeUnits * 1.2 : 1400000,\n }); // 20% buffer\n tx.instructions[0] = computeBudgetIxOptimized;\n const msgV0 = new chainSdk.TransactionMessage({\n payerKey: payerPublicKey,\n recentBlockhash: blockhash,\n instructions: tx.instructions,\n }).compileToV0Message(lookupTables);\n const vTx = new chainSdk.VersionedTransaction(msgV0);\n return { tx: vTx, blockhash, lastValidBlockHeight };\n}\n"],"names":[],"mappings":";;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B,CAAC,EAAE,EAAE,oBAAoB,EAAE;AAChE,IAAI,QAAQ,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC;AAC/D,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,GAAG,WAAW,EAAE;AAC5H,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE;AAClB,IAAI,MAAM,sBAAsB,GAAG,CAAC,GAAG,YAAY,CAAC;AACpD;AACA,IAAI,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,SAAS,CAAC,EAAE,IAAI,4BAA4B,CAAC,EAAE,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AACrI,IAAI,MAAM,iBAAiB,GAAG,QAAQ,CAAC,oBAAoB,CAAC,mBAAmB,CAAC;AAChF,QAAQ,KAAK,EAAE,OAAO;AACtB,KAAK,CAAC;AACN,IAAI,IAAI,iBAAiB,IAAI,CAAC,EAAE;AAChC,QAAQ,sBAAsB,CAAC,iBAAiB,CAAC,GAAG,iBAAiB;AACrE,IAAI;AACJ,SAAS;AACT,QAAQ,sBAAsB,CAAC,OAAO,C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AM,KAAK,GAAG,IAAI,QAAQ,CAAC,kBAAkB,CAAC;AAClD,QAAQ,QAAQ,EAAE,cAAc;AAChC,QAAQ,eAAe,EAAE,SAAS;AAClC,QAAQ,YAAY,EAAE,EAAE,CAAC,YAAY;AACrC,KAAK,CAAC,CAAC,kBAAkB,CAAC,YAAY,CAAC;AACvC,IAAI,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,oBAAoB,CAAC,KAAK,CAAC;AACxD,IAAI,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,oBAAoB,EAAE;AACvD;;;;;"}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import BN from 'bn.js';
|
|
2
|
-
|
|
3
|
-
// ─────────────────────────────────────────────────────────────
|
|
4
|
-
// Local implementation of getSimulationComputeUnits
|
|
5
|
-
// (Replaces @solana-developers/helpers to avoid Wallet import issue in browser/ESM builds)
|
|
6
|
-
// Source: https://github.com/solana-developers/helpers/blob/main/src/lib/transaction.ts
|
|
7
|
-
// ─────────────────────────────────────────────────────────────
|
|
8
|
-
/**
|
|
9
|
-
* Check if a given instruction is a SetComputeUnitLimit instruction
|
|
10
|
-
* See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29
|
|
11
|
-
*/
|
|
12
|
-
function isSetComputeLimitInstruction(ix, computeBudgetProgram) {
|
|
13
|
-
return (ix.programId.equals(computeBudgetProgram.programId) &&
|
|
14
|
-
ix.data[0] === 2 // opcode for setComputeUnitLimit is 2
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get the compute units required for a set of instructions via simulation.
|
|
19
|
-
* Credit https://twitter.com/stegabob, originally from https://x.com/stegaBOB/status/1766662289392889920
|
|
20
|
-
*/
|
|
21
|
-
async function getSimulationComputeUnits(connection, instructions, payer, lookupTables, chainSdk, commitment = "confirmed") {
|
|
22
|
-
var _a, _b, _c;
|
|
23
|
-
const simulationInstructions = [...instructions];
|
|
24
|
-
// Replace or add compute limit instruction
|
|
25
|
-
const computeLimitIndex = simulationInstructions.findIndex(ix => isSetComputeLimitInstruction(ix, chainSdk.ComputeBudgetProgram));
|
|
26
|
-
const simulationLimitIx = chainSdk.ComputeBudgetProgram.setComputeUnitLimit({
|
|
27
|
-
units: 1400000,
|
|
28
|
-
});
|
|
29
|
-
if (computeLimitIndex >= 0) {
|
|
30
|
-
simulationInstructions[computeLimitIndex] = simulationLimitIx;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
simulationInstructions.unshift(simulationLimitIx);
|
|
34
|
-
}
|
|
35
|
-
const testTransaction = new chainSdk.VersionedTransaction(new chainSdk.TransactionMessage({
|
|
36
|
-
instructions: simulationInstructions,
|
|
37
|
-
payerKey: payer,
|
|
38
|
-
// RecentBlockhash can by any public key during simulation
|
|
39
|
-
// since 'replaceRecentBlockhash' is set to 'true' below
|
|
40
|
-
recentBlockhash: chainSdk.PublicKey.default.toString(),
|
|
41
|
-
}).compileToV0Message(lookupTables));
|
|
42
|
-
const rpcResponse = await connection.simulateTransaction(testTransaction, {
|
|
43
|
-
replaceRecentBlockhash: true,
|
|
44
|
-
sigVerify: false,
|
|
45
|
-
commitment,
|
|
46
|
-
});
|
|
47
|
-
if ((_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _a === void 0 ? void 0 : _a.err) {
|
|
48
|
-
const logs = ((_b = rpcResponse.value.logs) === null || _b === void 0 ? void 0 : _b.join("\n • ")) || "No logs available";
|
|
49
|
-
throw new Error(`Transaction simulation failed:\n •${logs}` +
|
|
50
|
-
JSON.stringify((_c = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _c === void 0 ? void 0 : _c.err));
|
|
51
|
-
}
|
|
52
|
-
return rpcResponse.value.unitsConsumed || null;
|
|
53
|
-
}
|
|
54
|
-
// ─────────────────────────────────────────────────────────────
|
|
55
|
-
// Serialization Helpers
|
|
56
|
-
// ─────────────────────────────────────────────────────────────
|
|
57
|
-
function isHexString(value) {
|
|
58
|
-
// Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back
|
|
59
|
-
// from the API for u64Val/i64Val should fall through to `new BN(value)` which
|
|
60
|
-
// accepts those shapes natively. Without this guard, calling .startsWith on a
|
|
61
|
-
// non-string blows up with TypeError.
|
|
62
|
-
if (typeof value !== "string")
|
|
63
|
-
return false;
|
|
64
|
-
// Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)
|
|
65
|
-
let testValue = value;
|
|
66
|
-
// Handle negative values
|
|
67
|
-
if (value.startsWith("-")) {
|
|
68
|
-
testValue = value.slice(1);
|
|
69
|
-
}
|
|
70
|
-
const hexRegex = /^(0x)?[0-9a-fA-F]+$/;
|
|
71
|
-
return hexRegex.test(testValue);
|
|
72
|
-
}
|
|
73
|
-
function prepareProgramArgs(documents, PublicKeyClass) {
|
|
74
|
-
return documents.map((doc) => ({
|
|
75
|
-
path: doc.path,
|
|
76
|
-
operations: doc.operations.map((op) => {
|
|
77
|
-
let preparedValue = null;
|
|
78
|
-
if (op.value) {
|
|
79
|
-
if ("u64Val" in op.value) {
|
|
80
|
-
if (isHexString(op.value.u64Val.value)) {
|
|
81
|
-
preparedValue = { u64Val: { value: new BN(op.value.u64Val.value, "hex") } };
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
preparedValue = { u64Val: { value: new BN(op.value.u64Val.value) } };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else if ("i64Val" in op.value) {
|
|
88
|
-
if (isHexString(op.value.i64Val.value)) {
|
|
89
|
-
if (op.value.i64Val.value.startsWith("-")) {
|
|
90
|
-
preparedValue = { i64Val: { value: new BN(op.value.i64Val.value.slice(1), "hex").mul(new BN(-1)) } };
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
preparedValue = { i64Val: { value: new BN(op.value.i64Val.value, "hex") } };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
preparedValue = { i64Val: { value: new BN(op.value.i64Val.value) } };
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (op.value.boolVal) {
|
|
101
|
-
preparedValue = { boolVal: { value: !!op.value.boolVal.value } };
|
|
102
|
-
}
|
|
103
|
-
else if (op.value.stringVal) {
|
|
104
|
-
preparedValue = { stringVal: { value: String(op.value.stringVal.value) } };
|
|
105
|
-
}
|
|
106
|
-
else if (op.value.addressVal) {
|
|
107
|
-
preparedValue = { addressVal: { value: new PublicKeyClass(op.value.addressVal.value) } };
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
preparedValue = op.value;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
key: op.key,
|
|
115
|
-
value: preparedValue,
|
|
116
|
-
operation: op.operation,
|
|
117
|
-
};
|
|
118
|
-
}),
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
// ─────────────────────────────────────────────────────────────
|
|
122
|
-
// Updated Transaction Builder: It now accepts a PublicKey for the payer
|
|
123
|
-
// ─────────────────────────────────────────────────────────────
|
|
124
|
-
async function buildSetDocumentsTransaction(connection, idl, programProvider, payerPublicKey, args, remainingAccounts, lutKey, preInstructions, simulate, additionalLutAddresses) {
|
|
125
|
-
// LITERAL dynamic import specifiers on purpose: bundlers can only code-split
|
|
126
|
-
// a lazy chunk when the specifier is statically analyzable. (An earlier pass
|
|
127
|
-
// obfuscated these to satisfy a bundle-grep check — that breaks Vite/webpack
|
|
128
|
-
// consumers at runtime. Verify laziness with esbuild --splitting instead.)
|
|
129
|
-
const [chainSdk, programSdk] = await Promise.all([
|
|
130
|
-
import('@solana/web3.js'),
|
|
131
|
-
import('@coral-xyz/anchor'),
|
|
132
|
-
]);
|
|
133
|
-
const { ComputeBudgetProgram, PublicKey } = chainSdk;
|
|
134
|
-
const { Program } = programSdk;
|
|
135
|
-
// The sync convertRemainingAccounts facade produces PublicKey DUCK-TYPES
|
|
136
|
-
// (base58/bytes/equals only) so callers can dedupe without loading web3.
|
|
137
|
-
// Anything entering Anchor/web3 internals must be a REAL PublicKey —
|
|
138
|
-
// instanceof checks and _bn internals are not part of the duck contract.
|
|
139
|
-
// web3 is loaded here, so rehydrate at this seam.
|
|
140
|
-
const asRealPublicKey = (value) => value instanceof PublicKey ? value : new PublicKey(value.toBytes());
|
|
141
|
-
remainingAccounts = remainingAccounts.map((account) => ({
|
|
142
|
-
pubkey: asRealPublicKey(account.pubkey),
|
|
143
|
-
isWritable: account.isWritable,
|
|
144
|
-
isSigner: account.isSigner,
|
|
145
|
-
}));
|
|
146
|
-
payerPublicKey = asRealPublicKey(payerPublicKey);
|
|
147
|
-
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
148
|
-
units: 1400000,
|
|
149
|
-
});
|
|
150
|
-
//TODO: Figure out long term solution to estimate heap frame size
|
|
151
|
-
const requestHeapFrameIx = ComputeBudgetProgram.requestHeapFrame({
|
|
152
|
-
bytes: 1024 * 160,
|
|
153
|
-
});
|
|
154
|
-
const instructions = [];
|
|
155
|
-
instructions.unshift(requestHeapFrameIx);
|
|
156
|
-
instructions.unshift(computeBudgetIx);
|
|
157
|
-
instructions.push(...preInstructions);
|
|
158
|
-
let tx = null;
|
|
159
|
-
if (idl.address === "openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F") {
|
|
160
|
-
const program = new Program(idl, programProvider);
|
|
161
|
-
// Single canonical set_documents wire format (ra_indices Vec<u8>).
|
|
162
|
-
tx = await program.methods
|
|
163
|
-
.setDocuments(args.app_id, prepareProgramArgs(args.documents, PublicKey), args.delete_paths, args.txData, simulate)
|
|
164
|
-
.preInstructions(instructions)
|
|
165
|
-
.accounts({
|
|
166
|
-
payer: payerPublicKey
|
|
167
|
-
})
|
|
168
|
-
.remainingAccounts(remainingAccounts)
|
|
169
|
-
.transaction();
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
throw new Error(`Invalid program id: ${idl.address}`);
|
|
173
|
-
}
|
|
174
|
-
tx.feePayer = payerPublicKey;
|
|
175
|
-
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
176
|
-
tx.recentBlockhash = blockhash;
|
|
177
|
-
// Resolve LUTs: additionalLutAddresses (when present) is the authoritative set.
|
|
178
|
-
// Falls back to lutKey alone for backwards compatibility.
|
|
179
|
-
const lookupTables = [];
|
|
180
|
-
if (additionalLutAddresses && additionalLutAddresses.length > 0) {
|
|
181
|
-
const results = await Promise.all(additionalLutAddresses.map(addr => connection.getAddressLookupTable(new PublicKey(addr)).catch(() => null)));
|
|
182
|
-
for (const result of results) {
|
|
183
|
-
if (result === null || result === void 0 ? void 0 : result.value) {
|
|
184
|
-
lookupTables.push(result.value);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else if (lutKey != null) {
|
|
189
|
-
// The LUT may have just been created server-side and the client's RPC node
|
|
190
|
-
// may not have indexed it yet (load-balancer split). Retry with exponential
|
|
191
|
-
// back-off; first retry at 100 ms almost always resolves it.
|
|
192
|
-
let table = null;
|
|
193
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
194
|
-
const { value } = await connection.getAddressLookupTable(new PublicKey(lutKey));
|
|
195
|
-
if (value) {
|
|
196
|
-
table = value;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
if (attempt < 4)
|
|
200
|
-
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
201
|
-
}
|
|
202
|
-
if (!table)
|
|
203
|
-
throw new Error('LUT not found after creation/extend');
|
|
204
|
-
lookupTables.push(table);
|
|
205
|
-
}
|
|
206
|
-
if (lookupTables.length === 0) {
|
|
207
|
-
const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [], chainSdk);
|
|
208
|
-
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
209
|
-
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
210
|
-
}); // 20% buffer
|
|
211
|
-
tx.instructions[0] = computeBudgetIxOptimized;
|
|
212
|
-
return { tx, blockhash, lastValidBlockHeight };
|
|
213
|
-
}
|
|
214
|
-
const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, lookupTables, chainSdk);
|
|
215
|
-
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
216
|
-
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
217
|
-
}); // 20% buffer
|
|
218
|
-
tx.instructions[0] = computeBudgetIxOptimized;
|
|
219
|
-
const msgV0 = new chainSdk.TransactionMessage({
|
|
220
|
-
payerKey: payerPublicKey,
|
|
221
|
-
recentBlockhash: blockhash,
|
|
222
|
-
instructions: tx.instructions,
|
|
223
|
-
}).compileToV0Message(lookupTables);
|
|
224
|
-
const vTx = new chainSdk.VersionedTransaction(msgV0);
|
|
225
|
-
return { tx: vTx, blockhash, lastValidBlockHeight };
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export { buildSetDocumentsTransaction, isHexString };
|
|
229
|
-
//# sourceMappingURL=sol-utils-DVjPeoMy.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sol-utils-DVjPeoMy.mjs","sources":["../.rollup-tmp/utils/sol/sol-utils.js"],"sourcesContent":["import BN from \"bn.js\";\n// ─────────────────────────────────────────────────────────────\n// Local implementation of getSimulationComputeUnits\n// (Replaces @solana-developers/helpers to avoid Wallet import issue in browser/ESM builds)\n// Source: https://github.com/solana-developers/helpers/blob/main/src/lib/transaction.ts\n// ─────────────────────────────────────────────────────────────\n/**\n * Check if a given instruction is a SetComputeUnitLimit instruction\n * See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29\n */\nfunction isSetComputeLimitInstruction(ix, computeBudgetProgram) {\n return (ix.programId.equals(computeBudgetProgram.programId) &&\n ix.data[0] === 2 // opcode for setComputeUnitLimit is 2\n );\n}\n/**\n * Get the compute units required for a set of instructions via simulation.\n * Credit https://twitter.com/stegabob, originally from https://x.com/stegaBOB/status/1766662289392889920\n */\nasync function getSimulationComputeUnits(connection, instructions, payer, lookupTables, chainSdk, commitment = \"confirmed\") {\n var _a, _b, _c;\n const simulationInstructions = [...instructions];\n // Replace or add compute limit instruction\n const computeLimitIndex = simulationInstructions.findIndex(ix => isSetComputeLimitInstruction(ix, chainSdk.ComputeBudgetProgram));\n const simulationLimitIx = chainSdk.ComputeBudgetProgram.setComputeUnitLimit({\n units: 1400000,\n });\n if (computeLimitIndex >= 0) {\n simulationInstructions[computeLimitIndex] = simulationLimitIx;\n }\n else {\n simulationInstructions.unshift(simulationLimitIx);\n }\n const testTransaction = new chainSdk.VersionedTransaction(new chainSdk.TransactionMessage({\n instructions: simulationInstructions,\n payerKey: payer,\n // RecentBlockhash can by any public key during simulation\n // since 'replaceRecentBlockhash' is set to 'true' below\n recentBlockhash: chainSdk.PublicKey.default.toString(),\n }).compileToV0Message(lookupTables));\n const rpcResponse = await connection.simulateTransaction(testTransaction, {\n replaceRecentBlockhash: true,\n sigVerify: false,\n commitment,\n });\n if ((_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _a === void 0 ? void 0 : _a.err) {\n const logs = ((_b = rpcResponse.value.logs) === null || _b === void 0 ? void 0 : _b.join(\"\\n • \")) || \"No logs available\";\n throw new Error(`Transaction simulation failed:\\n •${logs}` +\n JSON.stringify((_c = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) === null || _c === void 0 ? void 0 : _c.err));\n }\n return rpcResponse.value.unitsConsumed || null;\n}\n// ─────────────────────────────────────────────────────────────\n// Serialization Helpers\n// ─────────────────────────────────────────────────────────────\nexport function isHexString(value) {\n // Only strings can be hex-encoded. Numbers, BNs, and other shapes coming back\n // from the API for u64Val/i64Val should fall through to `new BN(value)` which\n // accepts those shapes natively. Without this guard, calling .startsWith on a\n // non-string blows up with TypeError.\n if (typeof value !== \"string\")\n return false;\n // Matches strings containing only 0-9, a-f, or A-F (optionally prefixed with 0x)\n let testValue = value;\n // Handle negative values\n if (value.startsWith(\"-\")) {\n testValue = value.slice(1);\n }\n const hexRegex = /^(0x)?[0-9a-fA-F]+$/;\n return hexRegex.test(testValue);\n}\nfunction prepareProgramArgs(documents, PublicKeyClass) {\n return documents.map((doc) => ({\n path: doc.path,\n operations: doc.operations.map((op) => {\n let preparedValue = null;\n if (op.value) {\n if (\"u64Val\" in op.value) {\n if (isHexString(op.value.u64Val.value)) {\n preparedValue = { u64Val: { value: new BN(op.value.u64Val.value, \"hex\") } };\n }\n else {\n preparedValue = { u64Val: { value: new BN(op.value.u64Val.value) } };\n }\n }\n else if (\"i64Val\" in op.value) {\n if (isHexString(op.value.i64Val.value)) {\n if (op.value.i64Val.value.startsWith(\"-\")) {\n preparedValue = { i64Val: { value: new BN(op.value.i64Val.value.slice(1), \"hex\").mul(new BN(-1)) } };\n }\n else {\n preparedValue = { i64Val: { value: new BN(op.value.i64Val.value, \"hex\") } };\n }\n }\n else {\n preparedValue = { i64Val: { value: new BN(op.value.i64Val.value) } };\n }\n }\n else if (op.value.boolVal) {\n preparedValue = { boolVal: { value: !!op.value.boolVal.value } };\n }\n else if (op.value.stringVal) {\n preparedValue = { stringVal: { value: String(op.value.stringVal.value) } };\n }\n else if (op.value.addressVal) {\n preparedValue = { addressVal: { value: new PublicKeyClass(op.value.addressVal.value) } };\n }\n else {\n preparedValue = op.value;\n }\n }\n return {\n key: op.key,\n value: preparedValue,\n operation: op.operation,\n };\n }),\n }));\n}\n// ─────────────────────────────────────────────────────────────\n// Updated Transaction Builder: It now accepts a PublicKey for the payer\n// ─────────────────────────────────────────────────────────────\nexport async function buildSetDocumentsTransaction(connection, idl, programProvider, payerPublicKey, args, remainingAccounts, lutKey, preInstructions, simulate, additionalLutAddresses) {\n // LITERAL dynamic import specifiers on purpose: bundlers can only code-split\n // a lazy chunk when the specifier is statically analyzable. (An earlier pass\n // obfuscated these to satisfy a bundle-grep check — that breaks Vite/webpack\n // consumers at runtime. Verify laziness with esbuild --splitting instead.)\n const [chainSdk, programSdk] = await Promise.all([\n import(\"@solana/web3.js\"),\n import(\"@coral-xyz/anchor\"),\n ]);\n const { ComputeBudgetProgram, PublicKey } = chainSdk;\n const { Program } = programSdk;\n // The sync convertRemainingAccounts facade produces PublicKey DUCK-TYPES\n // (base58/bytes/equals only) so callers can dedupe without loading web3.\n // Anything entering Anchor/web3 internals must be a REAL PublicKey —\n // instanceof checks and _bn internals are not part of the duck contract.\n // web3 is loaded here, so rehydrate at this seam.\n const asRealPublicKey = (value) => value instanceof PublicKey ? value : new PublicKey(value.toBytes());\n remainingAccounts = remainingAccounts.map((account) => ({\n pubkey: asRealPublicKey(account.pubkey),\n isWritable: account.isWritable,\n isSigner: account.isSigner,\n }));\n payerPublicKey = asRealPublicKey(payerPublicKey);\n const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({\n units: 1400000,\n });\n //TODO: Figure out long term solution to estimate heap frame size\n const requestHeapFrameIx = ComputeBudgetProgram.requestHeapFrame({\n bytes: 1024 * 160,\n });\n const instructions = [];\n instructions.unshift(requestHeapFrameIx);\n instructions.unshift(computeBudgetIx);\n instructions.push(...preInstructions);\n let tx = null;\n if (idl.address === \"openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F\") {\n const program = new Program(idl, programProvider);\n // Single canonical set_documents wire format (ra_indices Vec<u8>).\n tx = await program.methods\n .setDocuments(args.app_id, prepareProgramArgs(args.documents, PublicKey), args.delete_paths, args.txData, simulate)\n .preInstructions(instructions)\n .accounts({\n payer: payerPublicKey\n })\n .remainingAccounts(remainingAccounts)\n .transaction();\n }\n else {\n throw new Error(`Invalid program id: ${idl.address}`);\n }\n tx.feePayer = payerPublicKey;\n const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(\"confirmed\");\n tx.recentBlockhash = blockhash;\n // Resolve LUTs: additionalLutAddresses (when present) is the authoritative set.\n // Falls back to lutKey alone for backwards compatibility.\n const lookupTables = [];\n if (additionalLutAddresses && additionalLutAddresses.length > 0) {\n const results = await Promise.all(additionalLutAddresses.map(addr => connection.getAddressLookupTable(new PublicKey(addr)).catch(() => null)));\n for (const result of results) {\n if (result === null || result === void 0 ? void 0 : result.value) {\n lookupTables.push(result.value);\n }\n }\n }\n else if (lutKey != null) {\n // The LUT may have just been created server-side and the client's RPC node\n // may not have indexed it yet (load-balancer split). Retry with exponential\n // back-off; first retry at 100 ms almost always resolves it.\n let table = null;\n for (let attempt = 0; attempt < 5; attempt++) {\n const { value } = await connection.getAddressLookupTable(new PublicKey(lutKey));\n if (value) {\n table = value;\n break;\n }\n if (attempt < 4)\n await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));\n }\n if (!table)\n throw new Error('LUT not found after creation/extend');\n lookupTables.push(table);\n }\n if (lookupTables.length === 0) {\n const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [], chainSdk);\n const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({\n units: computeUnits ? computeUnits * 1.2 : 1400000,\n }); // 20% buffer\n tx.instructions[0] = computeBudgetIxOptimized;\n return { tx, blockhash, lastValidBlockHeight };\n }\n const computeUnits = await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, lookupTables, chainSdk);\n const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({\n units: computeUnits ? computeUnits * 1.2 : 1400000,\n }); // 20% buffer\n tx.instructions[0] = computeBudgetIxOptimized;\n const msgV0 = new chainSdk.TransactionMessage({\n payerKey: payerPublicKey,\n recentBlockhash: blockhash,\n instructions: tx.instructions,\n }).compileToV0Message(lookupTables);\n const vTx = new chainSdk.VersionedTransaction(msgV0);\n return { tx: vTx, blockhash, lastValidBlockHeight };\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B,CAAC,EAAE,EAAE,oBAAoB,EAAE;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-B0NoE4nC.js","sources":["../.rollup-tmp/utils/sol/solana-message.js"],"sourcesContent":["import { getConfig } from \"../../client/config\";\n// NOTE: this message text must stay BYTE-IDENTICAL to what the wallet-auth\n// verifier reconstructs — any drift breaks every SIWS login.\nexport async function genSolanaMessage(address, nonce) {\n var _a, _b;\n /* Domain / origin aren't available server-side – fall back to envs\n or simple placeholders. */\n const domain = (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.SESSION_DOMAIN)) || \"server\";\n const origin = (typeof process !== 'undefined' && ((_b = process.env) === null || _b === void 0 ? void 0 : _b.SESSION_ORIGIN)) || \"server\";\n // SECURITY (audit-4 CRITICAL-1): bind the signed prompt to the target app.\n // appId is read from the SAME global config that genAuthNonce + /session use,\n // so the signed \"App ID\" is guaranteed to equal the app the session is minted\n // for; the server verifier rejects any mismatch.\n const appId = (await getConfig()).appId;\n const statement = \"Sign this message to authenticate with our application.\";\n const currentDate = new Date();\n const issuedAt = currentDate.toISOString();\n const expirationTime = new Date(currentDate.getTime() + 5 * 60 * 1000).toISOString();\n return `${statement}\\n\\n` +\n `Wallet address:\\n${address}\\n\\n` +\n `App ID: ${appId}\\n` +\n `Domain: ${domain}\\n` +\n `Origin: ${origin}\\n` +\n `Nonce: ${nonce}\\n` +\n `Issued At: ${issuedAt}\\n` +\n `Expiration Time: ${expirationTime}`;\n}\n"],"names":["getConfig"],"mappings":";;;;;;;;AACA;AACA;AACO,eAAe,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE;AACvD,IAAI,IAAI,EAAE,EAAE,EAAE;AACd;AACA;AACA,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,QAAQ;AAC9I,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,QAAQ;AAC9I;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG,CAAC,MAAMA,eAAS,EAAE,EAAE,KAAK;AAC3C,IAAI,MAAM,SAAS,GAAG,yDAAyD;AAC/E,IAAI,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE;AAClC,IAAI,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,EAAE;AAC9C,IAAI,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE;AACxF,IAAI,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;AAC7B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC,IAAI,CAAC;AACzC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;AAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;AAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;AAC7B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;AAC3B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC;AAClC,QAAQ,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;AAC5C;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solana-message-QUfJi1Qm.mjs","sources":["../.rollup-tmp/utils/sol/solana-message.js"],"sourcesContent":["import { getConfig } from \"../../client/config\";\n// NOTE: this message text must stay BYTE-IDENTICAL to what the wallet-auth\n// verifier reconstructs — any drift breaks every SIWS login.\nexport async function genSolanaMessage(address, nonce) {\n var _a, _b;\n /* Domain / origin aren't available server-side – fall back to envs\n or simple placeholders. */\n const domain = (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.SESSION_DOMAIN)) || \"server\";\n const origin = (typeof process !== 'undefined' && ((_b = process.env) === null || _b === void 0 ? void 0 : _b.SESSION_ORIGIN)) || \"server\";\n // SECURITY (audit-4 CRITICAL-1): bind the signed prompt to the target app.\n // appId is read from the SAME global config that genAuthNonce + /session use,\n // so the signed \"App ID\" is guaranteed to equal the app the session is minted\n // for; the server verifier rejects any mismatch.\n const appId = (await getConfig()).appId;\n const statement = \"Sign this message to authenticate with our application.\";\n const currentDate = new Date();\n const issuedAt = currentDate.toISOString();\n const expirationTime = new Date(currentDate.getTime() + 5 * 60 * 1000).toISOString();\n return `${statement}\\n\\n` +\n `Wallet address:\\n${address}\\n\\n` +\n `App ID: ${appId}\\n` +\n `Domain: ${domain}\\n` +\n `Origin: ${origin}\\n` +\n `Nonce: ${nonce}\\n` +\n `Issued At: ${issuedAt}\\n` +\n `Expiration Time: ${expirationTime}`;\n}\n"],"names":[],"mappings":";;;;;;AACA;AACA;AACO,eAAe,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE;AACvD,IAAI,IAAI,EAAE,EAAE,EAAE;AACd;AACA;AACA,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,QAAQ;AAC9I,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,QAAQ;AAC9I;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG,CAAC,MAAM,SAAS,EA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