@solana/web3.js 2.0.0-experimental.63c7492 → 2.0.0-experimental.6466d76
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/README.md +4 -4
- package/dist/index.browser.cjs +82 -25
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +71 -25
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +505 -178
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +71 -25
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +82 -25
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +71 -25
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +88 -74
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rpc-default-config.d.ts.map +1 -1
- package/dist/types/rpc-integer-overflow-error.d.ts +3 -2
- package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -1
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +9 -4
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +1 -1
- package/dist/types/transaction-confirmation.d.ts +2 -2
- package/dist/types/transaction-confirmation.d.ts.map +1 -1
- package/package.json +13 -12
|
@@ -122,7 +122,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
122
122
|
// src/index.ts
|
|
123
123
|
init_env_shim();
|
|
124
124
|
|
|
125
|
-
// ../
|
|
125
|
+
// ../accounts/dist/index.browser.js
|
|
126
|
+
init_env_shim();
|
|
127
|
+
|
|
128
|
+
// ../codecs-strings/dist/index.browser.js
|
|
126
129
|
init_env_shim();
|
|
127
130
|
|
|
128
131
|
// ../codecs-core/dist/index.browser.js
|
|
@@ -168,11 +171,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
168
171
|
function isFixedSize(codec) {
|
|
169
172
|
return "fixedSize" in codec && typeof codec.fixedSize === "number";
|
|
170
173
|
}
|
|
171
|
-
function assertIsFixedSize(codec, message) {
|
|
172
|
-
if (!isFixedSize(codec)) {
|
|
173
|
-
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
174
|
function isVariableSize(codec) {
|
|
177
175
|
return !isFixedSize(codec);
|
|
178
176
|
}
|
|
@@ -242,9 +240,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
242
240
|
});
|
|
243
241
|
}
|
|
244
242
|
|
|
245
|
-
// ../codecs-strings/dist/index.browser.js
|
|
246
|
-
init_env_shim();
|
|
247
|
-
|
|
248
243
|
// ../codecs-numbers/dist/index.browser.js
|
|
249
244
|
init_env_shim();
|
|
250
245
|
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
@@ -535,6 +530,98 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
535
530
|
});
|
|
536
531
|
}
|
|
537
532
|
|
|
533
|
+
// ../accounts/dist/index.browser.js
|
|
534
|
+
var BASE_ACCOUNT_SIZE = 128;
|
|
535
|
+
function decodeAccount(encodedAccount, decoder) {
|
|
536
|
+
try {
|
|
537
|
+
if ("exists" in encodedAccount && !encodedAccount.exists) {
|
|
538
|
+
return encodedAccount;
|
|
539
|
+
}
|
|
540
|
+
return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) });
|
|
541
|
+
} catch (error) {
|
|
542
|
+
const newError = new Error(`Failed to decode account [${encodedAccount.address}].`);
|
|
543
|
+
newError.cause = error;
|
|
544
|
+
throw newError;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function accountExists(account) {
|
|
548
|
+
return !("exists" in account) || "exists" in account && account.exists;
|
|
549
|
+
}
|
|
550
|
+
function assertAccountDecoded(account) {
|
|
551
|
+
if (accountExists(account) && account.data instanceof Uint8Array) {
|
|
552
|
+
throw new Error(`Expected account [${account.address}] to be decoded.`);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function assertAccountsDecoded(accounts) {
|
|
556
|
+
const encoded = accounts.filter((a) => accountExists(a) && a.data instanceof Uint8Array);
|
|
557
|
+
if (encoded.length > 0) {
|
|
558
|
+
const encodedAddresses = encoded.map((a) => a.address).join(", ");
|
|
559
|
+
throw new Error(`Expected accounts [${encodedAddresses}] to be decoded.`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function parseBase64RpcAccount(address2, rpcAccount) {
|
|
563
|
+
if (!rpcAccount)
|
|
564
|
+
return Object.freeze({ address: address2, exists: false });
|
|
565
|
+
const data = getBase64Encoder().encode(rpcAccount.data[0]);
|
|
566
|
+
return Object.freeze({ ...parseBaseAccount(rpcAccount), address: address2, data, exists: true });
|
|
567
|
+
}
|
|
568
|
+
function parseBase58RpcAccount(address2, rpcAccount) {
|
|
569
|
+
if (!rpcAccount)
|
|
570
|
+
return Object.freeze({ address: address2, exists: false });
|
|
571
|
+
const data = getBase58Encoder().encode(typeof rpcAccount.data === "string" ? rpcAccount.data : rpcAccount.data[0]);
|
|
572
|
+
return Object.freeze({ ...parseBaseAccount(rpcAccount), address: address2, data, exists: true });
|
|
573
|
+
}
|
|
574
|
+
function parseJsonRpcAccount(address2, rpcAccount) {
|
|
575
|
+
if (!rpcAccount)
|
|
576
|
+
return Object.freeze({ address: address2, exists: false });
|
|
577
|
+
const data = rpcAccount.data.parsed.info;
|
|
578
|
+
return Object.freeze({ ...parseBaseAccount(rpcAccount), address: address2, data, exists: true });
|
|
579
|
+
}
|
|
580
|
+
function parseBaseAccount(rpcAccount) {
|
|
581
|
+
return Object.freeze({
|
|
582
|
+
executable: rpcAccount.executable,
|
|
583
|
+
lamports: rpcAccount.lamports,
|
|
584
|
+
programAddress: rpcAccount.owner
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
async function fetchEncodedAccount(rpc, address2, config = {}) {
|
|
588
|
+
const { abortSignal, ...rpcConfig } = config;
|
|
589
|
+
const response = await rpc.getAccountInfo(address2, { ...rpcConfig, encoding: "base64" }).send({ abortSignal });
|
|
590
|
+
return parseBase64RpcAccount(address2, response.value);
|
|
591
|
+
}
|
|
592
|
+
async function fetchJsonParsedAccount(rpc, address2, config = {}) {
|
|
593
|
+
const { abortSignal, ...rpcConfig } = config;
|
|
594
|
+
const { value: account } = await rpc.getAccountInfo(address2, { ...rpcConfig, encoding: "jsonParsed" }).send({ abortSignal });
|
|
595
|
+
return !!account && typeof account === "object" && "parsed" in account.data ? parseJsonRpcAccount(address2, account) : parseBase64RpcAccount(address2, account);
|
|
596
|
+
}
|
|
597
|
+
async function fetchEncodedAccounts(rpc, addresses, config = {}) {
|
|
598
|
+
const { abortSignal, ...rpcConfig } = config;
|
|
599
|
+
const response = await rpc.getMultipleAccounts(addresses, { ...rpcConfig, encoding: "base64" }).send({ abortSignal });
|
|
600
|
+
return response.value.map((account, index) => parseBase64RpcAccount(addresses[index], account));
|
|
601
|
+
}
|
|
602
|
+
async function fetchJsonParsedAccounts(rpc, addresses, config = {}) {
|
|
603
|
+
const { abortSignal, ...rpcConfig } = config;
|
|
604
|
+
const response = await rpc.getMultipleAccounts(addresses, { ...rpcConfig, encoding: "jsonParsed" }).send({ abortSignal });
|
|
605
|
+
return response.value.map((account, index) => {
|
|
606
|
+
return !!account && typeof account === "object" && "parsed" in account.data ? parseJsonRpcAccount(addresses[index], account) : parseBase64RpcAccount(addresses[index], account);
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
function assertAccountExists(account) {
|
|
610
|
+
if (!account.exists) {
|
|
611
|
+
throw new Error(`Expected account [${account.address}] to exist.`);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
function assertAccountsExist(accounts) {
|
|
615
|
+
const missingAccounts = accounts.filter((a) => !a.exists);
|
|
616
|
+
if (missingAccounts.length > 0) {
|
|
617
|
+
const missingAddresses = missingAccounts.map((a) => a.address);
|
|
618
|
+
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// ../addresses/dist/index.browser.js
|
|
623
|
+
init_env_shim();
|
|
624
|
+
|
|
538
625
|
// ../assertions/dist/index.browser.js
|
|
539
626
|
init_env_shim();
|
|
540
627
|
function assertIsSecureContext() {
|
|
@@ -886,6 +973,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
886
973
|
return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
887
974
|
}
|
|
888
975
|
|
|
976
|
+
// ../functional/dist/index.browser.js
|
|
977
|
+
init_env_shim();
|
|
978
|
+
function pipe(init, ...fns) {
|
|
979
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
980
|
+
}
|
|
981
|
+
|
|
889
982
|
// ../instructions/dist/index.browser.js
|
|
890
983
|
init_env_shim();
|
|
891
984
|
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
@@ -1162,9 +1255,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1162
1255
|
function getArrayEncoder(item, config = {}) {
|
|
1163
1256
|
var _a, _b;
|
|
1164
1257
|
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
1165
|
-
if (size === "remainder") {
|
|
1166
|
-
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
1167
|
-
}
|
|
1168
1258
|
const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
|
|
1169
1259
|
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
1170
1260
|
return createEncoder({
|
|
@@ -1192,9 +1282,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1192
1282
|
function getArrayDecoder(item, config = {}) {
|
|
1193
1283
|
var _a, _b;
|
|
1194
1284
|
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
1195
|
-
if (size === "remainder") {
|
|
1196
|
-
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
1197
|
-
}
|
|
1198
1285
|
const itemSize = getFixedSize(item);
|
|
1199
1286
|
const fixedSize = computeArrayLikeCodecSize(size, itemSize);
|
|
1200
1287
|
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
@@ -1205,7 +1292,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1205
1292
|
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
1206
1293
|
return [array, offset];
|
|
1207
1294
|
}
|
|
1208
|
-
|
|
1295
|
+
if (size === "remainder") {
|
|
1296
|
+
while (offset < bytes.length) {
|
|
1297
|
+
const [value, newOffset2] = item.read(bytes, offset);
|
|
1298
|
+
offset = newOffset2;
|
|
1299
|
+
array.push(value);
|
|
1300
|
+
}
|
|
1301
|
+
return [array, offset];
|
|
1302
|
+
}
|
|
1303
|
+
const [resolvedSize, newOffset] = typeof size === "number" ? [size, offset] : size.read(bytes, offset);
|
|
1209
1304
|
offset = newOffset;
|
|
1210
1305
|
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1211
1306
|
const [value, newOffset2] = item.read(bytes, offset);
|
|
@@ -1216,27 +1311,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1216
1311
|
}
|
|
1217
1312
|
});
|
|
1218
1313
|
}
|
|
1219
|
-
function readArrayLikeCodecSize(size, itemSize, bytes, offset) {
|
|
1220
|
-
if (typeof size === "number") {
|
|
1221
|
-
return [size, offset];
|
|
1222
|
-
}
|
|
1223
|
-
if (typeof size === "object") {
|
|
1224
|
-
return size.read(bytes, offset);
|
|
1225
|
-
}
|
|
1226
|
-
if (size === "remainder") {
|
|
1227
|
-
if (itemSize === null) {
|
|
1228
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1229
|
-
}
|
|
1230
|
-
const remainder = Math.max(0, bytes.length - offset);
|
|
1231
|
-
if (remainder % itemSize !== 0) {
|
|
1232
|
-
throw new Error(
|
|
1233
|
-
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${itemSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${itemSize} should be equal to zero.`
|
|
1234
|
-
);
|
|
1235
|
-
}
|
|
1236
|
-
return [remainder / itemSize, offset];
|
|
1237
|
-
}
|
|
1238
|
-
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1239
|
-
}
|
|
1240
1314
|
function computeArrayLikeCodecSize(size, itemSize) {
|
|
1241
1315
|
if (typeof size !== "number")
|
|
1242
1316
|
return null;
|
|
@@ -1334,12 +1408,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1334
1408
|
});
|
|
1335
1409
|
}
|
|
1336
1410
|
|
|
1337
|
-
// ../functional/dist/index.browser.js
|
|
1338
|
-
init_env_shim();
|
|
1339
|
-
function pipe(init, ...fns) {
|
|
1340
|
-
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
1411
|
// ../transactions/dist/index.browser.js
|
|
1344
1412
|
function getUnsignedTransaction(transaction) {
|
|
1345
1413
|
if ("signatures" in transaction) {
|
|
@@ -2058,6 +2126,40 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2058
2126
|
}
|
|
2059
2127
|
return accountMetas;
|
|
2060
2128
|
}
|
|
2129
|
+
function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTableAddress) {
|
|
2130
|
+
const compiledAddressTableLookupAddresses = compiledAddressTableLookups.map((l) => l.lookupTableAddress);
|
|
2131
|
+
const missing = compiledAddressTableLookupAddresses.filter((a) => addressesByLookupTableAddress[a] === void 0);
|
|
2132
|
+
if (missing.length > 0) {
|
|
2133
|
+
const missingAddresses = missing.join(", ");
|
|
2134
|
+
throw new Error(`Addresses not provided for lookup tables: [${missingAddresses}]`);
|
|
2135
|
+
}
|
|
2136
|
+
const readOnlyMetas = [];
|
|
2137
|
+
const writableMetas = [];
|
|
2138
|
+
for (const lookup of compiledAddressTableLookups) {
|
|
2139
|
+
const addresses = addressesByLookupTableAddress[lookup.lookupTableAddress];
|
|
2140
|
+
const highestIndex = Math.max(...lookup.readableIndices, ...lookup.writableIndices);
|
|
2141
|
+
if (highestIndex >= addresses.length) {
|
|
2142
|
+
throw new Error(
|
|
2143
|
+
`Cannot look up index ${highestIndex} in lookup table [${lookup.lookupTableAddress}]. The lookup table may have been extended since the addresses provided were retrieved.`
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
const readOnlyForLookup = lookup.readableIndices.map((r) => ({
|
|
2147
|
+
address: addresses[r],
|
|
2148
|
+
addressIndex: r,
|
|
2149
|
+
lookupTableAddress: lookup.lookupTableAddress,
|
|
2150
|
+
role: AccountRole2.READONLY
|
|
2151
|
+
}));
|
|
2152
|
+
readOnlyMetas.push(...readOnlyForLookup);
|
|
2153
|
+
const writableForLookup = lookup.writableIndices.map((w) => ({
|
|
2154
|
+
address: addresses[w],
|
|
2155
|
+
addressIndex: w,
|
|
2156
|
+
lookupTableAddress: lookup.lookupTableAddress,
|
|
2157
|
+
role: AccountRole2.WRITABLE
|
|
2158
|
+
}));
|
|
2159
|
+
writableMetas.push(...writableForLookup);
|
|
2160
|
+
}
|
|
2161
|
+
return [...writableMetas, ...readOnlyMetas];
|
|
2162
|
+
}
|
|
2061
2163
|
function convertInstruction(instruction, accountMetas) {
|
|
2062
2164
|
var _a, _b;
|
|
2063
2165
|
const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
|
|
@@ -2104,23 +2206,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2104
2206
|
return { ...acc, [address2]: sig };
|
|
2105
2207
|
}, {});
|
|
2106
2208
|
}
|
|
2107
|
-
function decompileTransaction(compiledTransaction,
|
|
2209
|
+
function decompileTransaction(compiledTransaction, config) {
|
|
2210
|
+
var _a;
|
|
2108
2211
|
const { compiledMessage } = compiledTransaction;
|
|
2109
|
-
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
2110
|
-
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
2111
|
-
}
|
|
2112
2212
|
const feePayer = compiledMessage.staticAccounts[0];
|
|
2113
2213
|
if (!feePayer)
|
|
2114
2214
|
throw new Error("No fee payer set in CompiledTransaction");
|
|
2115
2215
|
const accountMetas = getAccountMetas(compiledMessage);
|
|
2216
|
+
const accountLookupMetas = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? getAddressLookupMetas(compiledMessage.addressTableLookups, (_a = config == null ? void 0 : config.addressesByLookupTableAddress) != null ? _a : {}) : [];
|
|
2217
|
+
const transactionMetas = [...accountMetas, ...accountLookupMetas];
|
|
2116
2218
|
const instructions = compiledMessage.instructions.map(
|
|
2117
|
-
(compiledInstruction) => convertInstruction(compiledInstruction,
|
|
2219
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, transactionMetas)
|
|
2118
2220
|
);
|
|
2119
2221
|
const firstInstruction = instructions[0];
|
|
2120
2222
|
const lifetimeConstraint = getLifetimeConstraint(
|
|
2121
2223
|
compiledMessage.lifetimeToken,
|
|
2122
2224
|
firstInstruction,
|
|
2123
|
-
lastValidBlockHeight
|
|
2225
|
+
config == null ? void 0 : config.lastValidBlockHeight
|
|
2124
2226
|
);
|
|
2125
2227
|
const signatures = convertSignatures(compiledTransaction);
|
|
2126
2228
|
return pipe(
|
|
@@ -2153,14 +2255,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2153
2255
|
function getTransactionEncoder() {
|
|
2154
2256
|
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
2155
2257
|
}
|
|
2156
|
-
function getTransactionDecoder(
|
|
2258
|
+
function getTransactionDecoder(config) {
|
|
2157
2259
|
return mapDecoder(
|
|
2158
2260
|
getCompiledTransactionDecoder(),
|
|
2159
|
-
(compiledTransaction) => decompileTransaction(compiledTransaction,
|
|
2261
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, config)
|
|
2160
2262
|
);
|
|
2161
2263
|
}
|
|
2162
|
-
function getTransactionCodec(
|
|
2163
|
-
return combineCodec(getTransactionEncoder(), getTransactionDecoder(
|
|
2264
|
+
function getTransactionCodec(config) {
|
|
2265
|
+
return combineCodec(getTransactionEncoder(), getTransactionDecoder(config));
|
|
2164
2266
|
}
|
|
2165
2267
|
var base58Decoder;
|
|
2166
2268
|
function getSignatureFromTransaction(transaction) {
|
|
@@ -2206,11 +2308,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2206
2308
|
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : [];
|
|
2207
2309
|
}).map((a) => a.address);
|
|
2208
2310
|
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
2311
|
+
const missingSigs = [];
|
|
2209
2312
|
requiredSigners.forEach((address2) => {
|
|
2210
2313
|
if (!transaction.signatures[address2]) {
|
|
2211
|
-
|
|
2314
|
+
missingSigs.push(address2);
|
|
2212
2315
|
}
|
|
2213
2316
|
});
|
|
2317
|
+
if (missingSigs.length > 0) {
|
|
2318
|
+
throw new Error("Transaction is missing signatures for addresses: " + missingSigs.join(", "));
|
|
2319
|
+
}
|
|
2214
2320
|
}
|
|
2215
2321
|
function getBase64EncodedWireTransaction(transaction) {
|
|
2216
2322
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
@@ -2388,32 +2494,224 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2388
2494
|
|
|
2389
2495
|
// ../rpc-core/dist/index.browser.js
|
|
2390
2496
|
init_env_shim();
|
|
2391
|
-
function
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2497
|
+
function createJsonRpcApi(config) {
|
|
2498
|
+
return new Proxy({}, {
|
|
2499
|
+
defineProperty() {
|
|
2500
|
+
return false;
|
|
2501
|
+
},
|
|
2502
|
+
deleteProperty() {
|
|
2503
|
+
return false;
|
|
2504
|
+
},
|
|
2505
|
+
get(...args) {
|
|
2506
|
+
const [_, p] = args;
|
|
2507
|
+
const methodName = p.toString();
|
|
2508
|
+
return function(...rawParams) {
|
|
2509
|
+
const params = (config == null ? void 0 : config.parametersTransformer) ? config == null ? void 0 : config.parametersTransformer(rawParams, methodName) : rawParams;
|
|
2510
|
+
const responseTransformer = (config == null ? void 0 : config.responseTransformer) ? config == null ? void 0 : config.responseTransformer : (rawResponse) => rawResponse;
|
|
2511
|
+
return {
|
|
2512
|
+
methodName,
|
|
2513
|
+
params,
|
|
2514
|
+
responseTransformer
|
|
2515
|
+
};
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
function createJsonRpcSubscriptionsApi(config) {
|
|
2521
|
+
return new Proxy({}, {
|
|
2522
|
+
defineProperty() {
|
|
2523
|
+
return false;
|
|
2524
|
+
},
|
|
2525
|
+
deleteProperty() {
|
|
2526
|
+
return false;
|
|
2527
|
+
},
|
|
2528
|
+
get(...args) {
|
|
2529
|
+
const [_, p] = args;
|
|
2530
|
+
const notificationName = p.toString();
|
|
2531
|
+
return function(...rawParams) {
|
|
2532
|
+
const params = (config == null ? void 0 : config.parametersTransformer) ? config == null ? void 0 : config.parametersTransformer(rawParams, notificationName) : rawParams;
|
|
2533
|
+
const responseTransformer = (config == null ? void 0 : config.responseTransformer) ? config == null ? void 0 : config.responseTransformer : (rawResponse) => rawResponse;
|
|
2534
|
+
const subscribeMethodName = (config == null ? void 0 : config.subscribeNotificationNameTransformer) ? config == null ? void 0 : config.subscribeNotificationNameTransformer(notificationName) : notificationName;
|
|
2535
|
+
const unsubscribeMethodName = (config == null ? void 0 : config.unsubscribeNotificationNameTransformer) ? config == null ? void 0 : config.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
|
|
2536
|
+
return {
|
|
2537
|
+
params,
|
|
2538
|
+
responseTransformer,
|
|
2539
|
+
subscribeMethodName,
|
|
2540
|
+
unsubscribeMethodName
|
|
2541
|
+
};
|
|
2542
|
+
};
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
function applyDefaultCommitment({
|
|
2547
|
+
commitmentPropertyName,
|
|
2548
|
+
params,
|
|
2549
|
+
optionsObjectPositionInParams,
|
|
2550
|
+
overrideCommitment
|
|
2551
|
+
}) {
|
|
2552
|
+
const paramInTargetPosition = params[optionsObjectPositionInParams];
|
|
2553
|
+
if (
|
|
2554
|
+
// There's no config.
|
|
2555
|
+
paramInTargetPosition === void 0 || // There is a config object.
|
|
2556
|
+
paramInTargetPosition && typeof paramInTargetPosition === "object" && !Array.isArray(paramInTargetPosition)
|
|
2557
|
+
) {
|
|
2558
|
+
if (
|
|
2559
|
+
// The config object already has a commitment set.
|
|
2560
|
+
paramInTargetPosition && commitmentPropertyName in paramInTargetPosition
|
|
2561
|
+
) {
|
|
2562
|
+
if (!paramInTargetPosition[commitmentPropertyName] || paramInTargetPosition[commitmentPropertyName] === "finalized") {
|
|
2563
|
+
const nextParams = [...params];
|
|
2564
|
+
const {
|
|
2565
|
+
[commitmentPropertyName]: _,
|
|
2566
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2567
|
+
...rest
|
|
2568
|
+
} = paramInTargetPosition;
|
|
2569
|
+
if (Object.keys(rest).length > 0) {
|
|
2570
|
+
nextParams[optionsObjectPositionInParams] = rest;
|
|
2571
|
+
} else {
|
|
2572
|
+
if (optionsObjectPositionInParams === nextParams.length - 1) {
|
|
2573
|
+
nextParams.length--;
|
|
2574
|
+
} else {
|
|
2575
|
+
nextParams[optionsObjectPositionInParams] = void 0;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
return nextParams;
|
|
2401
2579
|
}
|
|
2580
|
+
} else if (overrideCommitment !== "finalized") {
|
|
2581
|
+
const nextParams = [...params];
|
|
2582
|
+
nextParams[optionsObjectPositionInParams] = {
|
|
2583
|
+
...paramInTargetPosition,
|
|
2584
|
+
[commitmentPropertyName]: overrideCommitment
|
|
2585
|
+
};
|
|
2586
|
+
return nextParams;
|
|
2402
2587
|
}
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2588
|
+
}
|
|
2589
|
+
return params;
|
|
2590
|
+
}
|
|
2591
|
+
function downcastNodeToNumberIfBigint(value) {
|
|
2592
|
+
return typeof value === "bigint" ? (
|
|
2593
|
+
// FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
|
|
2594
|
+
// JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
|
|
2595
|
+
// downcasting `bigints` to `numbers`.
|
|
2596
|
+
Number(value)
|
|
2597
|
+
) : value;
|
|
2598
|
+
}
|
|
2599
|
+
function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
|
|
2600
|
+
return (value, { keyPath }) => {
|
|
2601
|
+
if (typeof value === "bigint") {
|
|
2602
|
+
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
|
|
2603
|
+
onIntegerOverflow(keyPath, value);
|
|
2604
|
+
}
|
|
2407
2605
|
}
|
|
2408
|
-
return Number(value);
|
|
2409
|
-
} else {
|
|
2410
2606
|
return value;
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) {
|
|
2414
|
-
return visitNode(params, [], onIntegerOverflow);
|
|
2607
|
+
};
|
|
2415
2608
|
}
|
|
2609
|
+
var OPTIONS_OBJECT_POSITION_BY_METHOD = {
|
|
2610
|
+
accountNotifications: 1,
|
|
2611
|
+
blockNotifications: 1,
|
|
2612
|
+
getAccountInfo: 1,
|
|
2613
|
+
getBalance: 1,
|
|
2614
|
+
getBlock: 1,
|
|
2615
|
+
getBlockHeight: 0,
|
|
2616
|
+
getBlockProduction: 0,
|
|
2617
|
+
getBlocks: 2,
|
|
2618
|
+
getBlocksWithLimit: 2,
|
|
2619
|
+
getConfirmedBlock: 1,
|
|
2620
|
+
getConfirmedBlocks: 1,
|
|
2621
|
+
getConfirmedBlocksWithLimit: 2,
|
|
2622
|
+
getConfirmedSignaturesForAddress2: 1,
|
|
2623
|
+
getConfirmedTransaction: 1,
|
|
2624
|
+
getEpochInfo: 0,
|
|
2625
|
+
getFeeCalculatorForBlockhash: 1,
|
|
2626
|
+
getFeeForMessage: 1,
|
|
2627
|
+
getFees: 1,
|
|
2628
|
+
getInflationGovernor: 0,
|
|
2629
|
+
getInflationReward: 1,
|
|
2630
|
+
getLargestAccounts: 0,
|
|
2631
|
+
getLatestBlockhash: 0,
|
|
2632
|
+
getLeaderSchedule: 1,
|
|
2633
|
+
getMinimumBalanceForRentExemption: 1,
|
|
2634
|
+
getMultipleAccounts: 1,
|
|
2635
|
+
getProgramAccounts: 1,
|
|
2636
|
+
getRecentBlockhash: 1,
|
|
2637
|
+
getSignaturesForAddress: 1,
|
|
2638
|
+
getSlot: 0,
|
|
2639
|
+
getSlotLeader: 0,
|
|
2640
|
+
getStakeActivation: 1,
|
|
2641
|
+
getStakeMinimumDelegation: 0,
|
|
2642
|
+
getSupply: 0,
|
|
2643
|
+
getTokenAccountBalance: 1,
|
|
2644
|
+
getTokenAccountsByDelegate: 2,
|
|
2645
|
+
getTokenAccountsByOwner: 2,
|
|
2646
|
+
getTokenLargestAccounts: 1,
|
|
2647
|
+
getTokenSupply: 1,
|
|
2648
|
+
getTransaction: 1,
|
|
2649
|
+
getTransactionCount: 0,
|
|
2650
|
+
getVoteAccounts: 0,
|
|
2651
|
+
isBlockhashValid: 1,
|
|
2652
|
+
logsNotifications: 1,
|
|
2653
|
+
programNotifications: 1,
|
|
2654
|
+
requestAirdrop: 2,
|
|
2655
|
+
sendTransaction: 1,
|
|
2656
|
+
signatureNotifications: 1,
|
|
2657
|
+
simulateTransaction: 1
|
|
2658
|
+
};
|
|
2416
2659
|
var KEYPATH_WILDCARD = {};
|
|
2660
|
+
function getTreeWalker(visitors) {
|
|
2661
|
+
return function traverse(node, state) {
|
|
2662
|
+
if (Array.isArray(node)) {
|
|
2663
|
+
return node.map((element, ii) => {
|
|
2664
|
+
const nextState = {
|
|
2665
|
+
...state,
|
|
2666
|
+
keyPath: [...state.keyPath, ii]
|
|
2667
|
+
};
|
|
2668
|
+
return traverse(element, nextState);
|
|
2669
|
+
});
|
|
2670
|
+
} else if (typeof node === "object" && node !== null) {
|
|
2671
|
+
const out = {};
|
|
2672
|
+
for (const propName in node) {
|
|
2673
|
+
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
|
|
2674
|
+
continue;
|
|
2675
|
+
}
|
|
2676
|
+
const nextState = {
|
|
2677
|
+
...state,
|
|
2678
|
+
keyPath: [...state.keyPath, propName]
|
|
2679
|
+
};
|
|
2680
|
+
out[propName] = traverse(node[propName], nextState);
|
|
2681
|
+
}
|
|
2682
|
+
return out;
|
|
2683
|
+
} else {
|
|
2684
|
+
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
function getParamsPatcherForSolanaLabsRpc(config) {
|
|
2689
|
+
const defaultCommitment = config == null ? void 0 : config.defaultCommitment;
|
|
2690
|
+
const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
|
|
2691
|
+
return (rawParams, methodName) => {
|
|
2692
|
+
const traverse = getTreeWalker([
|
|
2693
|
+
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
|
|
2694
|
+
downcastNodeToNumberIfBigint
|
|
2695
|
+
]);
|
|
2696
|
+
const initialState = {
|
|
2697
|
+
keyPath: []
|
|
2698
|
+
};
|
|
2699
|
+
const patchedParams = traverse(rawParams, initialState);
|
|
2700
|
+
if (!Array.isArray(patchedParams)) {
|
|
2701
|
+
return patchedParams;
|
|
2702
|
+
}
|
|
2703
|
+
const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName];
|
|
2704
|
+
if (optionsObjectPositionInParams == null) {
|
|
2705
|
+
return patchedParams;
|
|
2706
|
+
}
|
|
2707
|
+
return applyDefaultCommitment({
|
|
2708
|
+
commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment",
|
|
2709
|
+
optionsObjectPositionInParams,
|
|
2710
|
+
overrideCommitment: defaultCommitment,
|
|
2711
|
+
params: patchedParams
|
|
2712
|
+
});
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2417
2715
|
var jsonParsedTokenAccountsConfigs = [
|
|
2418
2716
|
// parsed Token/Token22 token account
|
|
2419
2717
|
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
@@ -2801,94 +3099,65 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2801
3099
|
}
|
|
2802
3100
|
return memoizedResponseKeypaths;
|
|
2803
3101
|
}
|
|
2804
|
-
function
|
|
2805
|
-
return
|
|
3102
|
+
function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
|
|
3103
|
+
return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
|
|
3104
|
+
if (prohibitedKeyPath.length !== keyPath.length) {
|
|
3105
|
+
return false;
|
|
3106
|
+
}
|
|
3107
|
+
for (let ii = keyPath.length - 1; ii >= 0; ii--) {
|
|
3108
|
+
const keyPathPart = keyPath[ii];
|
|
3109
|
+
const prohibitedKeyPathPart = prohibitedKeyPath[ii];
|
|
3110
|
+
if (prohibitedKeyPathPart !== keyPathPart && (prohibitedKeyPathPart !== KEYPATH_WILDCARD || typeof keyPathPart !== "number")) {
|
|
3111
|
+
return false;
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
return true;
|
|
3115
|
+
});
|
|
2806
3116
|
}
|
|
2807
|
-
function
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
} else if (typeof value === "object" && value !== null) {
|
|
2814
|
-
const out = {};
|
|
2815
|
-
for (const [propName, innerValue] of Object.entries(value)) {
|
|
2816
|
-
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
|
|
2817
|
-
out[propName] = visitNode2(innerValue, nextAllowedKeypaths);
|
|
3117
|
+
function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
|
|
3118
|
+
return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
|
|
3119
|
+
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
|
|
3120
|
+
return BigInt(value);
|
|
3121
|
+
} else {
|
|
3122
|
+
return value;
|
|
2818
3123
|
}
|
|
2819
|
-
|
|
2820
|
-
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
|
|
2821
|
-
// Upcast the value to `bigint` unless an allowed keypath is present.
|
|
2822
|
-
allowedKeypaths.length === 0 && // Only try to upcast an Integer to `bigint`
|
|
2823
|
-
Number.isInteger(value)) {
|
|
2824
|
-
return BigInt(value);
|
|
2825
|
-
} else {
|
|
2826
|
-
return value;
|
|
2827
|
-
}
|
|
3124
|
+
};
|
|
2828
3125
|
}
|
|
2829
3126
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
2830
|
-
const
|
|
2831
|
-
|
|
3127
|
+
const allowedNumericKeyPaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
|
|
3128
|
+
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths != null ? allowedNumericKeyPaths : [])]);
|
|
3129
|
+
const initialState = {
|
|
3130
|
+
keyPath: []
|
|
3131
|
+
};
|
|
3132
|
+
return traverse(rawResponse, initialState);
|
|
2832
3133
|
}
|
|
2833
|
-
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse,
|
|
2834
|
-
const
|
|
2835
|
-
|
|
3134
|
+
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName) {
|
|
3135
|
+
const allowedNumericKeyPaths = notificationName ? getAllowedNumericKeypathsForNotification()[notificationName] : void 0;
|
|
3136
|
+
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths != null ? allowedNumericKeyPaths : [])]);
|
|
3137
|
+
const initialState = {
|
|
3138
|
+
keyPath: []
|
|
3139
|
+
};
|
|
3140
|
+
return traverse(rawResponse, initialState);
|
|
2836
3141
|
}
|
|
2837
3142
|
function createSolanaRpcApi(config) {
|
|
2838
|
-
return
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
},
|
|
2842
|
-
deleteProperty() {
|
|
2843
|
-
return false;
|
|
2844
|
-
},
|
|
2845
|
-
get(...args) {
|
|
2846
|
-
const [_, p] = args;
|
|
2847
|
-
const methodName = p.toString();
|
|
2848
|
-
return function(...rawParams) {
|
|
2849
|
-
const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
|
|
2850
|
-
const params = patchParamsForSolanaLabsRpc(
|
|
2851
|
-
rawParams,
|
|
2852
|
-
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
|
|
2853
|
-
);
|
|
2854
|
-
return {
|
|
2855
|
-
methodName,
|
|
2856
|
-
params,
|
|
2857
|
-
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
|
|
2858
|
-
};
|
|
2859
|
-
};
|
|
2860
|
-
}
|
|
3143
|
+
return createJsonRpcApi({
|
|
3144
|
+
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
|
|
3145
|
+
responseTransformer: patchResponseForSolanaLabsRpc
|
|
2861
3146
|
});
|
|
2862
3147
|
}
|
|
2863
|
-
function
|
|
2864
|
-
return
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
return false;
|
|
2870
|
-
},
|
|
2871
|
-
get(...args) {
|
|
2872
|
-
const [_, p] = args;
|
|
2873
|
-
const notificationName = p.toString();
|
|
2874
|
-
return function(...rawParams) {
|
|
2875
|
-
const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
|
|
2876
|
-
const params = patchParamsForSolanaLabsRpc(
|
|
2877
|
-
rawParams,
|
|
2878
|
-
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
|
|
2879
|
-
);
|
|
2880
|
-
return {
|
|
2881
|
-
params,
|
|
2882
|
-
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
|
|
2883
|
-
subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
|
|
2884
|
-
unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2885
|
-
};
|
|
2886
|
-
};
|
|
2887
|
-
}
|
|
3148
|
+
function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
|
|
3149
|
+
return createJsonRpcSubscriptionsApi({
|
|
3150
|
+
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
|
|
3151
|
+
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions,
|
|
3152
|
+
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"),
|
|
3153
|
+
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2888
3154
|
});
|
|
2889
3155
|
}
|
|
3156
|
+
function createSolanaRpcSubscriptionsApi(config) {
|
|
3157
|
+
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
|
|
3158
|
+
}
|
|
2890
3159
|
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
|
|
2891
|
-
return
|
|
3160
|
+
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
|
|
2892
3161
|
}
|
|
2893
3162
|
|
|
2894
3163
|
// ../rpc-transport/dist/index.browser.js
|
|
@@ -2923,7 +3192,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2923
3192
|
function createPendingRpcRequest(rpcConfig, pendingRequest) {
|
|
2924
3193
|
return {
|
|
2925
3194
|
async send(options) {
|
|
2926
|
-
const { methodName, params,
|
|
3195
|
+
const { methodName, params, responseTransformer } = pendingRequest;
|
|
2927
3196
|
const payload = createJsonRpcMessage(methodName, params);
|
|
2928
3197
|
const response = await rpcConfig.transport({
|
|
2929
3198
|
payload,
|
|
@@ -2932,7 +3201,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2932
3201
|
if ("error" in response) {
|
|
2933
3202
|
throw new SolanaJsonRpcError(response.error);
|
|
2934
3203
|
} else {
|
|
2935
|
-
return
|
|
3204
|
+
return responseTransformer ? responseTransformer(response.result, methodName) : response.result;
|
|
2936
3205
|
}
|
|
2937
3206
|
}
|
|
2938
3207
|
};
|
|
@@ -2969,7 +3238,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2969
3238
|
}
|
|
2970
3239
|
})();
|
|
2971
3240
|
}
|
|
2972
|
-
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName,
|
|
3241
|
+
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) {
|
|
2973
3242
|
return {
|
|
2974
3243
|
async subscribe({ abortSignal }) {
|
|
2975
3244
|
abortSignal.throwIfAborted();
|
|
@@ -3015,7 +3284,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3015
3284
|
continue;
|
|
3016
3285
|
}
|
|
3017
3286
|
const notification = message.params.result;
|
|
3018
|
-
yield
|
|
3287
|
+
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
|
|
3019
3288
|
}
|
|
3020
3289
|
}
|
|
3021
3290
|
};
|
|
@@ -3321,22 +3590,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3321
3590
|
init_env_shim();
|
|
3322
3591
|
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
3323
3592
|
constructor(methodName, keyPath, value) {
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3593
|
+
let argumentLabel = "";
|
|
3594
|
+
if (typeof keyPath[0] === "number") {
|
|
3595
|
+
const argPosition = keyPath[0] + 1;
|
|
3596
|
+
const lastDigit = argPosition % 10;
|
|
3597
|
+
const lastTwoDigits = argPosition % 100;
|
|
3598
|
+
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
3599
|
+
argumentLabel = argPosition + "st";
|
|
3600
|
+
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
3601
|
+
argumentLabel = argPosition + "nd";
|
|
3602
|
+
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
3603
|
+
argumentLabel = argPosition + "rd";
|
|
3604
|
+
} else {
|
|
3605
|
+
argumentLabel = argPosition + "th";
|
|
3606
|
+
}
|
|
3334
3607
|
} else {
|
|
3335
|
-
|
|
3608
|
+
argumentLabel = `\`${keyPath[0].toString()}\``;
|
|
3336
3609
|
}
|
|
3337
3610
|
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
|
|
3338
3611
|
super(
|
|
3339
|
-
`The ${
|
|
3612
|
+
`The ${argumentLabel} argument to the \`${methodName}\` RPC method${path ? ` at path \`${path}\`` : ""} was \`${value}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`
|
|
3340
3613
|
);
|
|
3341
3614
|
__publicField(this, "methodName");
|
|
3342
3615
|
__publicField(this, "keyPath");
|
|
@@ -3352,6 +3625,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3352
3625
|
|
|
3353
3626
|
// src/rpc-default-config.ts
|
|
3354
3627
|
var DEFAULT_RPC_CONFIG = {
|
|
3628
|
+
defaultCommitment: "confirmed",
|
|
3355
3629
|
onIntegerOverflow(methodName, keyPath, value) {
|
|
3356
3630
|
throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
3357
3631
|
}
|
|
@@ -3786,22 +4060,52 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3786
4060
|
|
|
3787
4061
|
// src/transaction-confirmation-strategy-blockheight.ts
|
|
3788
4062
|
init_env_shim();
|
|
3789
|
-
function createBlockHeightExceedencePromiseFactory(
|
|
3790
|
-
|
|
4063
|
+
function createBlockHeightExceedencePromiseFactory({
|
|
4064
|
+
rpc,
|
|
4065
|
+
rpcSubscriptions
|
|
4066
|
+
}) {
|
|
4067
|
+
return async function getBlockHeightExceedencePromise({
|
|
4068
|
+
abortSignal: callerAbortSignal,
|
|
4069
|
+
commitment,
|
|
4070
|
+
lastValidBlockHeight
|
|
4071
|
+
}) {
|
|
3791
4072
|
const abortController = new AbortController();
|
|
3792
|
-
|
|
4073
|
+
const handleAbort = () => {
|
|
3793
4074
|
abortController.abort();
|
|
3794
|
-
}
|
|
4075
|
+
};
|
|
3795
4076
|
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3796
|
-
|
|
4077
|
+
async function getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight() {
|
|
4078
|
+
const { absoluteSlot, blockHeight } = await rpc.getEpochInfo({ commitment }).send({ abortSignal: abortController.signal });
|
|
4079
|
+
return {
|
|
4080
|
+
blockHeight,
|
|
4081
|
+
differenceBetweenSlotHeightAndBlockHeight: absoluteSlot - blockHeight
|
|
4082
|
+
};
|
|
4083
|
+
}
|
|
3797
4084
|
try {
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
4085
|
+
const [slotNotifications, { blockHeight, differenceBetweenSlotHeightAndBlockHeight }] = await Promise.all([
|
|
4086
|
+
rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal }),
|
|
4087
|
+
getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight()
|
|
4088
|
+
]);
|
|
4089
|
+
if (blockHeight <= lastValidBlockHeight) {
|
|
4090
|
+
let lastKnownDifferenceBetweenSlotHeightAndBlockHeight = differenceBetweenSlotHeightAndBlockHeight;
|
|
4091
|
+
for await (const slotNotification of slotNotifications) {
|
|
4092
|
+
const { slot } = slotNotification;
|
|
4093
|
+
if (slot - lastKnownDifferenceBetweenSlotHeightAndBlockHeight > lastValidBlockHeight) {
|
|
4094
|
+
const {
|
|
4095
|
+
blockHeight: currentBlockHeight,
|
|
4096
|
+
differenceBetweenSlotHeightAndBlockHeight: currentDifferenceBetweenSlotHeightAndBlockHeight
|
|
4097
|
+
} = await getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight();
|
|
4098
|
+
if (currentBlockHeight > lastValidBlockHeight) {
|
|
4099
|
+
break;
|
|
4100
|
+
} else {
|
|
4101
|
+
lastKnownDifferenceBetweenSlotHeightAndBlockHeight = currentDifferenceBetweenSlotHeightAndBlockHeight;
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
3803
4104
|
}
|
|
3804
4105
|
}
|
|
4106
|
+
throw new Error(
|
|
4107
|
+
"The network has progressed past the last block for which this transaction could have been committed."
|
|
4108
|
+
);
|
|
3805
4109
|
} finally {
|
|
3806
4110
|
abortController.abort();
|
|
3807
4111
|
}
|
|
@@ -3896,7 +4200,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3896
4200
|
rpc,
|
|
3897
4201
|
rpcSubscriptions
|
|
3898
4202
|
}) {
|
|
3899
|
-
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(
|
|
4203
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({
|
|
4204
|
+
rpc,
|
|
4205
|
+
rpcSubscriptions
|
|
4206
|
+
});
|
|
3900
4207
|
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
3901
4208
|
rpc,
|
|
3902
4209
|
rpcSubscriptions
|
|
@@ -3929,10 +4236,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3929
4236
|
await raceStrategies(
|
|
3930
4237
|
getSignatureFromTransaction(config.transaction),
|
|
3931
4238
|
config,
|
|
3932
|
-
function getSpecificStrategiesForRace({
|
|
4239
|
+
function getSpecificStrategiesForRace({
|
|
4240
|
+
abortSignal,
|
|
4241
|
+
commitment,
|
|
4242
|
+
getBlockHeightExceedencePromise,
|
|
4243
|
+
transaction
|
|
4244
|
+
}) {
|
|
3933
4245
|
return [
|
|
3934
4246
|
getBlockHeightExceedencePromise({
|
|
3935
4247
|
abortSignal,
|
|
4248
|
+
commitment,
|
|
3936
4249
|
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
3937
4250
|
})
|
|
3938
4251
|
];
|
|
@@ -4055,8 +4368,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4055
4368
|
}
|
|
4056
4369
|
|
|
4057
4370
|
exports.AccountRole = AccountRole;
|
|
4371
|
+
exports.BASE_ACCOUNT_SIZE = BASE_ACCOUNT_SIZE;
|
|
4058
4372
|
exports.address = address;
|
|
4059
4373
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
4374
|
+
exports.assertAccountDecoded = assertAccountDecoded;
|
|
4375
|
+
exports.assertAccountExists = assertAccountExists;
|
|
4376
|
+
exports.assertAccountsDecoded = assertAccountsDecoded;
|
|
4377
|
+
exports.assertAccountsExist = assertAccountsExist;
|
|
4060
4378
|
exports.assertIsAddress = assertIsAddress;
|
|
4061
4379
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
4062
4380
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
@@ -4086,8 +4404,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4086
4404
|
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
4087
4405
|
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
4088
4406
|
exports.createTransaction = createTransaction;
|
|
4407
|
+
exports.decodeAccount = decodeAccount;
|
|
4089
4408
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
4090
4409
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
4410
|
+
exports.fetchEncodedAccount = fetchEncodedAccount;
|
|
4411
|
+
exports.fetchEncodedAccounts = fetchEncodedAccounts;
|
|
4412
|
+
exports.fetchJsonParsedAccount = fetchJsonParsedAccount;
|
|
4413
|
+
exports.fetchJsonParsedAccounts = fetchJsonParsedAccounts;
|
|
4091
4414
|
exports.generateKeyPair = generateKeyPair;
|
|
4092
4415
|
exports.getAddressCodec = getAddressCodec;
|
|
4093
4416
|
exports.getAddressComparator = getAddressComparator;
|
|
@@ -4115,7 +4438,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4115
4438
|
exports.isWritableRole = isWritableRole;
|
|
4116
4439
|
exports.lamports = lamports;
|
|
4117
4440
|
exports.mergeRoles = mergeRoles;
|
|
4441
|
+
exports.parseBase58RpcAccount = parseBase58RpcAccount;
|
|
4442
|
+
exports.parseBase64RpcAccount = parseBase64RpcAccount;
|
|
4443
|
+
exports.parseJsonRpcAccount = parseJsonRpcAccount;
|
|
4118
4444
|
exports.partiallySignTransaction = partiallySignTransaction;
|
|
4445
|
+
exports.pipe = pipe;
|
|
4119
4446
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
4120
4447
|
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
4121
4448
|
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|