@solana/web3.js 2.0.0-rc.1 → 2.0.0-rc.3
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 +1 -4
- package/dist/index.browser.cjs +15 -3
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +12 -4
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.development.js +1352 -909
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.mjs +12 -4
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +15 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +12 -4
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.production.min.js +564 -552
- package/dist/types/airdrop-internal.d.ts +2 -2
- package/dist/types/airdrop-internal.d.ts.map +1 -1
- package/dist/types/compute-limit-internal.d.ts.map +1 -1
- package/dist/types/decompile-transaction-message-fetching-lookup-tables.d.ts +9 -0
- package/dist/types/decompile-transaction-message-fetching-lookup-tables.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/send-transaction-internal.d.ts +1 -2
- package/dist/types/send-transaction-internal.d.ts.map +1 -1
- package/package.json +31 -19
- package/dist/types/decode-transaction-message.d.ts +0 -9
- package/dist/types/decode-transaction-message.d.ts.map +0 -1
@@ -156,6 +156,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
156
156
|
var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = 5663016;
|
157
157
|
var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
|
158
158
|
var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
|
159
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
|
159
160
|
var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
|
160
161
|
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
|
161
162
|
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
|
@@ -219,15 +220,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
219
220
|
var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
|
220
221
|
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
|
221
222
|
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
|
222
|
-
var
|
223
|
+
var SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = 8100003;
|
224
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = 819e4;
|
223
225
|
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
|
224
|
-
var
|
225
|
-
var
|
226
|
-
var
|
227
|
-
var
|
228
|
-
var
|
226
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
|
227
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = 8190003;
|
228
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = 8190004;
|
229
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = 99e5;
|
230
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
|
229
231
|
var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
|
230
232
|
var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
|
233
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = 9900004;
|
231
234
|
var SolanaErrorMessages = {
|
232
235
|
[SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
|
233
236
|
[SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
|
@@ -332,9 +335,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
332
335
|
[SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
|
333
336
|
[SOLANA_ERROR__INVALID_NONCE]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
|
334
337
|
[SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING]: "Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
338
|
+
[SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED]: "Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",
|
339
|
+
[SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
340
|
+
[SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
335
341
|
[SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE]: "Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
336
|
-
[SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
337
|
-
[SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
|
338
342
|
[SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR]: "JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",
|
339
343
|
[SOLANA_ERROR__JSON_RPC__INVALID_PARAMS]: "JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",
|
340
344
|
[SOLANA_ERROR__JSON_RPC__INVALID_REQUEST]: "JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",
|
@@ -365,11 +369,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
365
369
|
[SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
|
366
370
|
[SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
|
367
371
|
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
|
368
|
-
[
|
372
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN]: "The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",
|
373
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
|
374
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED]: "WebSocket connection closed",
|
375
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT]: "WebSocket failed to connect",
|
369
376
|
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
|
370
|
-
[
|
371
|
-
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED]: "WebSocket connection closed",
|
372
|
-
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT]: "WebSocket failed to connect",
|
377
|
+
[SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD]: "Could not find an API plan for RPC method: `$method`",
|
373
378
|
[SOLANA_ERROR__RPC__INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
|
374
379
|
[SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
|
375
380
|
[SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
|
@@ -393,7 +398,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
393
398
|
[SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED]: "No key generation implementation could be found.",
|
394
399
|
[SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED]: "No signing implementation could be found.",
|
395
400
|
[SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED]: "No key export implementation could be found.",
|
396
|
-
[SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-
|
401
|
+
[SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",
|
397
402
|
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
|
398
403
|
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE]: "Account in use",
|
399
404
|
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE]: "Account loaded twice",
|
@@ -441,6 +446,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
441
446
|
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
|
442
447
|
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
|
443
448
|
[SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT]: "Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",
|
449
|
+
[SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT]: "Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",
|
444
450
|
[SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING]: "Transaction is missing a fee payer.",
|
445
451
|
[SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
|
446
452
|
[SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
|
@@ -1417,7 +1423,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1417
1423
|
getSizeFromValue: (value) => {
|
1418
1424
|
try {
|
1419
1425
|
return atob(value).length;
|
1420
|
-
} catch
|
1426
|
+
} catch {
|
1421
1427
|
throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
|
1422
1428
|
alphabet: alphabet3,
|
1423
1429
|
base: 64,
|
@@ -1430,7 +1436,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1430
1436
|
const bytesToAdd = atob(value).split("").map((c) => c.charCodeAt(0));
|
1431
1437
|
bytes.set(bytesToAdd, offset);
|
1432
1438
|
return bytesToAdd.length + offset;
|
1433
|
-
} catch
|
1439
|
+
} catch {
|
1434
1440
|
throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
|
1435
1441
|
alphabet: alphabet3,
|
1436
1442
|
base: 64,
|
@@ -1490,7 +1496,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1490
1496
|
return encodedAccount;
|
1491
1497
|
}
|
1492
1498
|
return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) });
|
1493
|
-
} catch
|
1499
|
+
} catch {
|
1494
1500
|
throw new SolanaError(SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT, {
|
1495
1501
|
address: encodedAccount.address
|
1496
1502
|
});
|
@@ -1587,10 +1593,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1587
1593
|
/* extractable */
|
1588
1594
|
false,
|
1589
1595
|
["sign", "verify"]
|
1590
|
-
).
|
1591
|
-
resolve(cachedEd25519Decision = false);
|
1592
|
-
}).then(() => {
|
1596
|
+
).then(() => {
|
1593
1597
|
resolve(cachedEd25519Decision = true);
|
1598
|
+
}).catch(() => {
|
1599
|
+
resolve(cachedEd25519Decision = false);
|
1594
1600
|
});
|
1595
1601
|
});
|
1596
1602
|
}
|
@@ -1664,12 +1670,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
1664
1670
|
return false;
|
1665
1671
|
}
|
1666
1672
|
const base58Encoder2 = getMemoizedBase58Encoder();
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1673
|
+
try {
|
1674
|
+
return base58Encoder2.encode(putativeAddress).byteLength === 32;
|
1675
|
+
} catch {
|
1670
1676
|
return false;
|
1671
1677
|
}
|
1672
|
-
return true;
|
1673
1678
|
}
|
1674
1679
|
function assertIsAddress(putativeAddress) {
|
1675
1680
|
if (
|
@@ -2564,9 +2569,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
2564
2569
|
var getDataEnumDecoder = getDiscriminatedUnionDecoder;
|
2565
2570
|
var getDataEnumCodec = getDiscriminatedUnionCodec;
|
2566
2571
|
function getEnumStats(constructor) {
|
2567
|
-
const numericalValues = [
|
2568
|
-
...new Set(Object.values(constructor).filter((v) => typeof v === "number"))
|
2569
|
-
].sort();
|
2572
|
+
const numericalValues = [...new Set(Object.values(constructor).filter((v) => typeof v === "number"))].sort();
|
2570
2573
|
const enumRecord = Object.fromEntries(Object.entries(constructor).slice(numericalValues.length));
|
2571
2574
|
const enumKeys = Object.keys(enumRecord);
|
2572
2575
|
const enumValues = Object.values(enumRecord);
|
@@ -3239,20 +3242,90 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3239
3242
|
}
|
3240
3243
|
|
3241
3244
|
// ../rpc-spec-types/dist/index.browser.mjs
|
3242
|
-
|
3245
|
+
function parseJsonWithBigInts(json) {
|
3246
|
+
return JSON.parse(wrapIntegersInBigIntValueObject(json), (_, value) => {
|
3247
|
+
return isBigIntValueObject(value) ? unwrapBigIntValueObject(value) : value;
|
3248
|
+
});
|
3249
|
+
}
|
3250
|
+
function wrapIntegersInBigIntValueObject(json) {
|
3251
|
+
const out = [];
|
3252
|
+
let inQuote = false;
|
3253
|
+
for (let ii = 0; ii < json.length; ii++) {
|
3254
|
+
let isEscaped = false;
|
3255
|
+
if (json[ii] === "\\") {
|
3256
|
+
out.push(json[ii++]);
|
3257
|
+
isEscaped = !isEscaped;
|
3258
|
+
}
|
3259
|
+
if (json[ii] === '"') {
|
3260
|
+
out.push(json[ii]);
|
3261
|
+
if (!isEscaped) {
|
3262
|
+
inQuote = !inQuote;
|
3263
|
+
}
|
3264
|
+
continue;
|
3265
|
+
}
|
3266
|
+
if (!inQuote) {
|
3267
|
+
const consumedNumber = consumeNumber(json, ii);
|
3268
|
+
if (consumedNumber == null ? void 0 : consumedNumber.length) {
|
3269
|
+
ii += consumedNumber.length - 1;
|
3270
|
+
if (consumedNumber.match(/\.|[eE]-/)) {
|
3271
|
+
out.push(consumedNumber);
|
3272
|
+
} else {
|
3273
|
+
out.push(wrapBigIntValueObject(consumedNumber));
|
3274
|
+
}
|
3275
|
+
continue;
|
3276
|
+
}
|
3277
|
+
}
|
3278
|
+
out.push(json[ii]);
|
3279
|
+
}
|
3280
|
+
return out.join("");
|
3281
|
+
}
|
3282
|
+
function consumeNumber(json, ii) {
|
3283
|
+
var _a;
|
3284
|
+
const JSON_NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
|
3285
|
+
if (!((_a = json[ii]) == null ? void 0 : _a.match(/[-\d]/))) {
|
3286
|
+
return null;
|
3287
|
+
}
|
3288
|
+
const numberMatch = json.slice(ii).match(JSON_NUMBER_REGEX);
|
3289
|
+
return numberMatch ? numberMatch[0] : null;
|
3290
|
+
}
|
3291
|
+
function wrapBigIntValueObject(value) {
|
3292
|
+
return `{"$n":"${value}"}`;
|
3293
|
+
}
|
3294
|
+
function unwrapBigIntValueObject({ $n }) {
|
3295
|
+
if ($n.match(/[eE]/)) {
|
3296
|
+
const [units, exponent] = $n.split(/[eE]/);
|
3297
|
+
return BigInt(units) * BigInt(10) ** BigInt(exponent);
|
3298
|
+
}
|
3299
|
+
return BigInt($n);
|
3300
|
+
}
|
3301
|
+
function isBigIntValueObject(value) {
|
3302
|
+
return !!value && typeof value === "object" && "$n" in value && typeof value.$n === "string";
|
3303
|
+
}
|
3304
|
+
var _nextMessageId = 0n;
|
3243
3305
|
function getNextMessageId() {
|
3244
3306
|
const id = _nextMessageId;
|
3245
|
-
_nextMessageId
|
3246
|
-
return id;
|
3307
|
+
_nextMessageId++;
|
3308
|
+
return id.toString();
|
3247
3309
|
}
|
3248
|
-
function createRpcMessage(
|
3310
|
+
function createRpcMessage(request) {
|
3249
3311
|
return {
|
3250
3312
|
id: getNextMessageId(),
|
3251
3313
|
jsonrpc: "2.0",
|
3252
|
-
method,
|
3253
|
-
params
|
3314
|
+
method: request.methodName,
|
3315
|
+
params: request.params
|
3254
3316
|
};
|
3255
3317
|
}
|
3318
|
+
function stringifyJsonWithBigints(value, space) {
|
3319
|
+
return unwrapBigIntValueObject2(
|
3320
|
+
JSON.stringify(value, (_, v) => typeof v === "bigint" ? wrapBigIntValueObject2(v) : v, space)
|
3321
|
+
);
|
3322
|
+
}
|
3323
|
+
function wrapBigIntValueObject2(value) {
|
3324
|
+
return { $n: `${value}` };
|
3325
|
+
}
|
3326
|
+
function unwrapBigIntValueObject2(value) {
|
3327
|
+
return value.replace(/\{\s*"\$n"\s*:\s*"(-?\d+)"\s*\}/g, "$1");
|
3328
|
+
}
|
3256
3329
|
|
3257
3330
|
// ../rpc-spec/dist/index.browser.mjs
|
3258
3331
|
function createRpc(rpcConfig) {
|
@@ -3269,27 +3342,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3269
3342
|
get(target, p, receiver) {
|
3270
3343
|
return function(...rawParams) {
|
3271
3344
|
const methodName = p.toString();
|
3272
|
-
const
|
3273
|
-
|
3274
|
-
|
3345
|
+
const getApiPlan = Reflect.get(target, methodName, receiver);
|
3346
|
+
if (!getApiPlan) {
|
3347
|
+
throw new SolanaError(SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD, {
|
3348
|
+
method: methodName,
|
3349
|
+
params: rawParams
|
3350
|
+
});
|
3351
|
+
}
|
3352
|
+
const apiPlan = getApiPlan(...rawParams);
|
3353
|
+
return createPendingRpcRequest(rpcConfig, apiPlan);
|
3275
3354
|
};
|
3276
3355
|
}
|
3277
3356
|
});
|
3278
3357
|
}
|
3279
|
-
function createPendingRpcRequest(
|
3358
|
+
function createPendingRpcRequest({ transport }, plan) {
|
3280
3359
|
return {
|
3281
3360
|
async send(options) {
|
3282
|
-
|
3283
|
-
const payload = createRpcMessage(methodName, params);
|
3284
|
-
const response = await rpcConfig.transport({
|
3285
|
-
payload,
|
3286
|
-
signal: options == null ? void 0 : options.abortSignal
|
3287
|
-
});
|
3288
|
-
return responseTransformer ? responseTransformer(response, methodName) : response;
|
3361
|
+
return await plan.execute({ signal: options == null ? void 0 : options.abortSignal, transport });
|
3289
3362
|
}
|
3290
3363
|
};
|
3291
3364
|
}
|
3292
|
-
function
|
3365
|
+
function createJsonRpcApi(config) {
|
3293
3366
|
return new Proxy({}, {
|
3294
3367
|
defineProperty() {
|
3295
3368
|
return false;
|
@@ -3301,19 +3374,106 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3301
3374
|
const [_, p] = args;
|
3302
3375
|
const methodName = p.toString();
|
3303
3376
|
return function(...rawParams) {
|
3304
|
-
const
|
3305
|
-
const
|
3306
|
-
return {
|
3307
|
-
|
3308
|
-
|
3309
|
-
|
3310
|
-
|
3377
|
+
const rawRequest = Object.freeze({ methodName, params: rawParams });
|
3378
|
+
const request = (config == null ? void 0 : config.requestTransformer) ? config == null ? void 0 : config.requestTransformer(rawRequest) : rawRequest;
|
3379
|
+
return Object.freeze({
|
3380
|
+
execute: async ({ signal, transport }) => {
|
3381
|
+
const payload = createRpcMessage(request);
|
3382
|
+
const response = await transport({ payload, signal });
|
3383
|
+
if (!(config == null ? void 0 : config.responseTransformer)) {
|
3384
|
+
return response;
|
3385
|
+
}
|
3386
|
+
return config.responseTransformer(response, request);
|
3387
|
+
}
|
3388
|
+
});
|
3311
3389
|
};
|
3312
3390
|
}
|
3313
3391
|
});
|
3314
3392
|
}
|
3393
|
+
function isJsonRpcPayload(payload) {
|
3394
|
+
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
3395
|
+
return false;
|
3396
|
+
}
|
3397
|
+
return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
|
3398
|
+
}
|
3315
3399
|
|
3316
3400
|
// ../rpc-transformers/dist/index.browser.mjs
|
3401
|
+
var KEYPATH_WILDCARD = {};
|
3402
|
+
function getTreeWalker(visitors) {
|
3403
|
+
return function traverse(node, state) {
|
3404
|
+
if (Array.isArray(node)) {
|
3405
|
+
return node.map((element, ii) => {
|
3406
|
+
const nextState = {
|
3407
|
+
...state,
|
3408
|
+
keyPath: [...state.keyPath, ii]
|
3409
|
+
};
|
3410
|
+
return traverse(element, nextState);
|
3411
|
+
});
|
3412
|
+
} else if (typeof node === "object" && node !== null) {
|
3413
|
+
const out = {};
|
3414
|
+
for (const propName in node) {
|
3415
|
+
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
|
3416
|
+
continue;
|
3417
|
+
}
|
3418
|
+
const nextState = {
|
3419
|
+
...state,
|
3420
|
+
keyPath: [...state.keyPath, propName]
|
3421
|
+
};
|
3422
|
+
out[propName] = traverse(node[propName], nextState);
|
3423
|
+
}
|
3424
|
+
return out;
|
3425
|
+
} else {
|
3426
|
+
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
|
3427
|
+
}
|
3428
|
+
};
|
3429
|
+
}
|
3430
|
+
function getTreeWalkerRequestTransformer(visitors, initialState) {
|
3431
|
+
return (request) => {
|
3432
|
+
const traverse = getTreeWalker(visitors);
|
3433
|
+
return Object.freeze({
|
3434
|
+
...request,
|
3435
|
+
params: traverse(request.params, initialState)
|
3436
|
+
});
|
3437
|
+
};
|
3438
|
+
}
|
3439
|
+
function getTreeWalkerResponseTransformer(visitors, initialState) {
|
3440
|
+
return (json) => getTreeWalker(visitors)(json, initialState);
|
3441
|
+
}
|
3442
|
+
function getBigIntDowncastRequestTransformer() {
|
3443
|
+
return getTreeWalkerRequestTransformer([downcastNodeToNumberIfBigint], { keyPath: [] });
|
3444
|
+
}
|
3445
|
+
function downcastNodeToNumberIfBigint(value) {
|
3446
|
+
return typeof value === "bigint" ? (
|
3447
|
+
// FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
|
3448
|
+
// JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
|
3449
|
+
// downcasting `bigints` to `numbers`.
|
3450
|
+
Number(value)
|
3451
|
+
) : value;
|
3452
|
+
}
|
3453
|
+
function getDefaultCommitmentRequestTransformer({
|
3454
|
+
defaultCommitment,
|
3455
|
+
optionsObjectPositionByMethod
|
3456
|
+
}) {
|
3457
|
+
return (request) => {
|
3458
|
+
const { params, methodName } = request;
|
3459
|
+
if (!Array.isArray(params)) {
|
3460
|
+
return request;
|
3461
|
+
}
|
3462
|
+
const optionsObjectPositionInParams = optionsObjectPositionByMethod[methodName];
|
3463
|
+
if (optionsObjectPositionInParams == null) {
|
3464
|
+
return request;
|
3465
|
+
}
|
3466
|
+
return Object.freeze({
|
3467
|
+
methodName,
|
3468
|
+
params: applyDefaultCommitment({
|
3469
|
+
commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment",
|
3470
|
+
optionsObjectPositionInParams,
|
3471
|
+
overrideCommitment: defaultCommitment,
|
3472
|
+
params
|
3473
|
+
})
|
3474
|
+
});
|
3475
|
+
};
|
3476
|
+
}
|
3317
3477
|
function applyDefaultCommitment({
|
3318
3478
|
commitmentPropertyName,
|
3319
3479
|
params,
|
@@ -3359,13 +3519,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3359
3519
|
}
|
3360
3520
|
return params;
|
3361
3521
|
}
|
3362
|
-
function
|
3363
|
-
return
|
3364
|
-
|
3365
|
-
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3522
|
+
function getIntegerOverflowRequestTransformer(onIntegerOverflow) {
|
3523
|
+
return (request) => {
|
3524
|
+
const transformer = getTreeWalkerRequestTransformer(
|
3525
|
+
[getIntegerOverflowNodeVisitor((...args) => onIntegerOverflow(request, ...args))],
|
3526
|
+
{ keyPath: [] }
|
3527
|
+
);
|
3528
|
+
return transformer(request);
|
3529
|
+
};
|
3369
3530
|
}
|
3370
3531
|
function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
|
3371
3532
|
return (value, { keyPath }) => {
|
@@ -3387,15 +3548,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3387
3548
|
getBlockProduction: 0,
|
3388
3549
|
getBlocks: 2,
|
3389
3550
|
getBlocksWithLimit: 2,
|
3390
|
-
getConfirmedBlock: 1,
|
3391
|
-
getConfirmedBlocks: 1,
|
3392
|
-
getConfirmedBlocksWithLimit: 2,
|
3393
|
-
getConfirmedSignaturesForAddress2: 1,
|
3394
|
-
getConfirmedTransaction: 1,
|
3395
3551
|
getEpochInfo: 0,
|
3396
|
-
getFeeCalculatorForBlockhash: 1,
|
3397
3552
|
getFeeForMessage: 1,
|
3398
|
-
getFees: 1,
|
3399
3553
|
getInflationGovernor: 0,
|
3400
3554
|
getInflationReward: 1,
|
3401
3555
|
getLargestAccounts: 0,
|
@@ -3404,11 +3558,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3404
3558
|
getMinimumBalanceForRentExemption: 1,
|
3405
3559
|
getMultipleAccounts: 1,
|
3406
3560
|
getProgramAccounts: 1,
|
3407
|
-
getRecentBlockhash: 1,
|
3408
3561
|
getSignaturesForAddress: 1,
|
3409
3562
|
getSlot: 0,
|
3410
3563
|
getSlotLeader: 0,
|
3411
|
-
getStakeActivation: 1,
|
3412
3564
|
getStakeMinimumDelegation: 0,
|
3413
3565
|
getSupply: 0,
|
3414
3566
|
getTokenAccountBalance: 1,
|
@@ -3427,73 +3579,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3427
3579
|
signatureNotifications: 1,
|
3428
3580
|
simulateTransaction: 1
|
3429
3581
|
};
|
3430
|
-
|
3431
|
-
function getTreeWalker(visitors) {
|
3432
|
-
return function traverse(node, state) {
|
3433
|
-
if (Array.isArray(node)) {
|
3434
|
-
return node.map((element, ii) => {
|
3435
|
-
const nextState = {
|
3436
|
-
...state,
|
3437
|
-
keyPath: [...state.keyPath, ii]
|
3438
|
-
};
|
3439
|
-
return traverse(element, nextState);
|
3440
|
-
});
|
3441
|
-
} else if (typeof node === "object" && node !== null) {
|
3442
|
-
const out = {};
|
3443
|
-
for (const propName in node) {
|
3444
|
-
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
|
3445
|
-
continue;
|
3446
|
-
}
|
3447
|
-
const nextState = {
|
3448
|
-
...state,
|
3449
|
-
keyPath: [...state.keyPath, propName]
|
3450
|
-
};
|
3451
|
-
out[propName] = traverse(node[propName], nextState);
|
3452
|
-
}
|
3453
|
-
return out;
|
3454
|
-
} else {
|
3455
|
-
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
|
3456
|
-
}
|
3457
|
-
};
|
3458
|
-
}
|
3459
|
-
function getDefaultParamsTransformerForSolanaRpc(config) {
|
3460
|
-
const defaultCommitment = config == null ? void 0 : config.defaultCommitment;
|
3582
|
+
function getDefaultRequestTransformerForSolanaRpc(config) {
|
3461
3583
|
const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
|
3462
|
-
return (
|
3463
|
-
const traverse = getTreeWalker([
|
3464
|
-
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
|
3465
|
-
downcastNodeToNumberIfBigint
|
3466
|
-
]);
|
3467
|
-
const initialState = {
|
3468
|
-
keyPath: []
|
3469
|
-
};
|
3470
|
-
const patchedParams = traverse(rawParams, initialState);
|
3471
|
-
if (!Array.isArray(patchedParams)) {
|
3472
|
-
return patchedParams;
|
3473
|
-
}
|
3474
|
-
const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName];
|
3475
|
-
if (optionsObjectPositionInParams == null) {
|
3476
|
-
return patchedParams;
|
3477
|
-
}
|
3584
|
+
return (request) => {
|
3478
3585
|
return pipe(
|
3479
|
-
|
3480
|
-
(
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
})
|
3486
|
-
// FIXME Remove when https://github.com/anza-xyz/agave/pull/483 is deployed.
|
3487
|
-
(params) => methodName === "sendTransaction" ? applyFixForIssue479(params) : params
|
3586
|
+
request,
|
3587
|
+
handleIntegerOverflow ? getIntegerOverflowRequestTransformer(handleIntegerOverflow) : (r) => r,
|
3588
|
+
getBigIntDowncastRequestTransformer(),
|
3589
|
+
getDefaultCommitmentRequestTransformer({
|
3590
|
+
defaultCommitment: config == null ? void 0 : config.defaultCommitment,
|
3591
|
+
optionsObjectPositionByMethod: OPTIONS_OBJECT_POSITION_BY_METHOD
|
3592
|
+
})
|
3488
3593
|
);
|
3489
3594
|
};
|
3490
3595
|
}
|
3491
|
-
function
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
}
|
3496
|
-
|
3596
|
+
function getBigIntUpcastResponseTransformer(allowedNumericKeyPaths) {
|
3597
|
+
return getTreeWalkerResponseTransformer([getBigIntUpcastVisitor(allowedNumericKeyPaths)], { keyPath: [] });
|
3598
|
+
}
|
3599
|
+
function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
|
3600
|
+
return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
|
3601
|
+
const isInteger = typeof value === "number" && Number.isInteger(value) || typeof value === "bigint";
|
3602
|
+
if (!isInteger) return value;
|
3603
|
+
if (keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
|
3604
|
+
return Number(value);
|
3605
|
+
} else {
|
3606
|
+
return BigInt(value);
|
3607
|
+
}
|
3608
|
+
};
|
3497
3609
|
}
|
3498
3610
|
function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
|
3499
3611
|
return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
|
@@ -3510,26 +3622,35 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3510
3622
|
return true;
|
3511
3623
|
});
|
3512
3624
|
}
|
3513
|
-
function
|
3514
|
-
return
|
3515
|
-
|
3516
|
-
|
3517
|
-
|
3518
|
-
|
3625
|
+
function getResultResponseTransformer() {
|
3626
|
+
return (json) => json.result;
|
3627
|
+
}
|
3628
|
+
function getThrowSolanaErrorResponseTransformer() {
|
3629
|
+
return (json) => {
|
3630
|
+
const jsonRpcResponse = json;
|
3631
|
+
if ("error" in jsonRpcResponse) {
|
3632
|
+
throw getSolanaErrorFromJsonRpcError(jsonRpcResponse.error);
|
3519
3633
|
}
|
3634
|
+
return jsonRpcResponse;
|
3520
3635
|
};
|
3521
3636
|
}
|
3522
3637
|
function getDefaultResponseTransformerForSolanaRpc(config) {
|
3523
|
-
return (
|
3524
|
-
|
3525
|
-
throw getSolanaErrorFromJsonRpcError(rawResponse.error);
|
3526
|
-
}
|
3638
|
+
return (response, request) => {
|
3639
|
+
const methodName = request.methodName;
|
3527
3640
|
const keyPaths = (config == null ? void 0 : config.allowedNumericKeyPaths) && methodName ? config.allowedNumericKeyPaths[methodName] : void 0;
|
3528
|
-
|
3529
|
-
|
3530
|
-
|
3531
|
-
|
3532
|
-
|
3641
|
+
return pipe(
|
3642
|
+
response,
|
3643
|
+
(r) => getThrowSolanaErrorResponseTransformer()(r, request),
|
3644
|
+
(r) => getResultResponseTransformer()(r, request),
|
3645
|
+
(r) => getBigIntUpcastResponseTransformer(keyPaths != null ? keyPaths : [])(r, request)
|
3646
|
+
);
|
3647
|
+
};
|
3648
|
+
}
|
3649
|
+
function getDefaultResponseTransformerForSolanaRpcSubscriptions(config) {
|
3650
|
+
return (response, request) => {
|
3651
|
+
const methodName = request.methodName;
|
3652
|
+
const keyPaths = (config == null ? void 0 : config.allowedNumericKeyPaths) && methodName ? config.allowedNumericKeyPaths[methodName] : void 0;
|
3653
|
+
return pipe(response, (r) => getBigIntUpcastResponseTransformer(keyPaths != null ? keyPaths : [])(r, request));
|
3533
3654
|
};
|
3534
3655
|
}
|
3535
3656
|
var jsonParsedTokenAccountsConfigs = [
|
@@ -3585,8 +3706,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3585
3706
|
|
3586
3707
|
// ../rpc-api/dist/index.browser.mjs
|
3587
3708
|
function createSolanaRpcApi(config) {
|
3588
|
-
return
|
3589
|
-
|
3709
|
+
return createJsonRpcApi({
|
3710
|
+
requestTransformer: getDefaultRequestTransformerForSolanaRpc(config),
|
3590
3711
|
responseTransformer: getDefaultResponseTransformerForSolanaRpc({
|
3591
3712
|
allowedNumericKeyPaths: getAllowedNumericKeypaths()
|
3592
3713
|
})
|
@@ -3598,7 +3719,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3598
3719
|
memoizedKeypaths = {
|
3599
3720
|
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
3600
3721
|
getBlock: [
|
3601
|
-
["blockTime"],
|
3602
3722
|
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
3603
3723
|
[
|
3604
3724
|
"transactions",
|
@@ -3631,7 +3751,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3631
3751
|
...messageConfig.map((c) => ["transactions", KEYPATH_WILDCARD, "transaction", "message", ...c]),
|
3632
3752
|
["rewards", KEYPATH_WILDCARD, "commission"]
|
3633
3753
|
],
|
3634
|
-
getBlockTime: [[]],
|
3635
3754
|
getClusterNodes: [
|
3636
3755
|
[KEYPATH_WILDCARD, "featureSet"],
|
3637
3756
|
[KEYPATH_WILDCARD, "shredVersion"]
|
@@ -3698,31 +3817,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3698
3817
|
"content-length": true,
|
3699
3818
|
"content-type": true
|
3700
3819
|
};
|
3701
|
-
var FORBIDDEN_HEADERS =
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
3820
|
+
var FORBIDDEN_HEADERS = /* @__PURE__ */ Object.assign(
|
3821
|
+
{
|
3822
|
+
"accept-charset": true,
|
3823
|
+
"access-control-request-headers": true,
|
3824
|
+
"access-control-request-method": true,
|
3825
|
+
connection: true,
|
3826
|
+
"content-length": true,
|
3827
|
+
cookie: true,
|
3828
|
+
date: true,
|
3829
|
+
dnt: true,
|
3830
|
+
expect: true,
|
3831
|
+
host: true,
|
3832
|
+
"keep-alive": true,
|
3833
|
+
origin: true,
|
3834
|
+
"permissions-policy": true,
|
3835
|
+
// Prefix matching is implemented in code, below.
|
3836
|
+
// 'proxy-': true,
|
3837
|
+
// 'sec-': true,
|
3838
|
+
referer: true,
|
3839
|
+
te: true,
|
3840
|
+
trailer: true,
|
3841
|
+
"transfer-encoding": true,
|
3842
|
+
upgrade: true,
|
3843
|
+
via: true
|
3844
|
+
},
|
3845
|
+
{ "accept-encoding": true }
|
3846
|
+
);
|
3726
3847
|
function assertIsAllowedHttpRequestHeaders(headers) {
|
3727
3848
|
const badHeaders = Object.keys(headers).filter((headerName) => {
|
3728
3849
|
const lowercaseHeaderName = headerName.toLowerCase();
|
@@ -3755,7 +3876,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3755
3876
|
if ("dispatcher_NODE_ONLY" in config) {
|
3756
3877
|
warnDispatcherWasSuppliedInNonNodeEnvironment();
|
3757
3878
|
}
|
3758
|
-
const { headers, url } = config;
|
3879
|
+
const { fromJson, headers, toJson, url } = config;
|
3759
3880
|
if (headers) {
|
3760
3881
|
assertIsAllowedHttpRequestHeaders(headers);
|
3761
3882
|
}
|
@@ -3765,7 +3886,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3765
3886
|
payload,
|
3766
3887
|
signal
|
3767
3888
|
}) {
|
3768
|
-
const body = JSON.stringify(payload);
|
3889
|
+
const body = toJson ? toJson(payload) : JSON.stringify(payload);
|
3769
3890
|
const requestInfo = {
|
3770
3891
|
...dispatcherConfig,
|
3771
3892
|
body,
|
@@ -3786,9 +3907,87 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3786
3907
|
statusCode: response.status
|
3787
3908
|
});
|
3788
3909
|
}
|
3910
|
+
if (fromJson) {
|
3911
|
+
return fromJson(await response.text(), payload);
|
3912
|
+
}
|
3789
3913
|
return await response.json();
|
3790
3914
|
};
|
3791
3915
|
}
|
3916
|
+
var SOLANA_RPC_METHODS = [
|
3917
|
+
"getAccountInfo",
|
3918
|
+
"getBalance",
|
3919
|
+
"getBlock",
|
3920
|
+
"getBlockCommitment",
|
3921
|
+
"getBlockHeight",
|
3922
|
+
"getBlockProduction",
|
3923
|
+
"getBlocks",
|
3924
|
+
"getBlocksWithLimit",
|
3925
|
+
"getBlockTime",
|
3926
|
+
"getClusterNodes",
|
3927
|
+
"getEpochInfo",
|
3928
|
+
"getEpochSchedule",
|
3929
|
+
"getFeeForMessage",
|
3930
|
+
"getFirstAvailableBlock",
|
3931
|
+
"getGenesisHash",
|
3932
|
+
"getHealth",
|
3933
|
+
"getHighestSnapshotSlot",
|
3934
|
+
"getIdentity",
|
3935
|
+
"getInflationGovernor",
|
3936
|
+
"getInflationRate",
|
3937
|
+
"getInflationReward",
|
3938
|
+
"getLargestAccounts",
|
3939
|
+
"getLatestBlockhash",
|
3940
|
+
"getLeaderSchedule",
|
3941
|
+
"getMaxRetransmitSlot",
|
3942
|
+
"getMaxShredInsertSlot",
|
3943
|
+
"getMinimumBalanceForRentExemption",
|
3944
|
+
"getMultipleAccounts",
|
3945
|
+
"getProgramAccounts",
|
3946
|
+
"getRecentPerformanceSamples",
|
3947
|
+
"getRecentPrioritizationFees",
|
3948
|
+
"getSignaturesForAddress",
|
3949
|
+
"getSignatureStatuses",
|
3950
|
+
"getSlot",
|
3951
|
+
"getSlotLeader",
|
3952
|
+
"getSlotLeaders",
|
3953
|
+
"getStakeMinimumDelegation",
|
3954
|
+
"getSupply",
|
3955
|
+
"getTokenAccountBalance",
|
3956
|
+
"getTokenAccountsByDelegate",
|
3957
|
+
"getTokenAccountsByOwner",
|
3958
|
+
"getTokenLargestAccounts",
|
3959
|
+
"getTokenSupply",
|
3960
|
+
"getTransaction",
|
3961
|
+
"getTransactionCount",
|
3962
|
+
"getVersion",
|
3963
|
+
"getVoteAccounts",
|
3964
|
+
"index",
|
3965
|
+
"isBlockhashValid",
|
3966
|
+
"minimumLedgerSlot",
|
3967
|
+
"requestAirdrop",
|
3968
|
+
"sendTransaction",
|
3969
|
+
"simulateTransaction"
|
3970
|
+
];
|
3971
|
+
function isSolanaRequest(payload) {
|
3972
|
+
return isJsonRpcPayload(payload) && SOLANA_RPC_METHODS.includes(payload.method);
|
3973
|
+
}
|
3974
|
+
function createHttpTransportForSolanaRpc(config) {
|
3975
|
+
return createHttpTransport({
|
3976
|
+
...config,
|
3977
|
+
fromJson: (rawResponse, payload) => {
|
3978
|
+
if (!isSolanaRequest(payload)) return JSON.parse(rawResponse);
|
3979
|
+
const response = parseJsonWithBigInts(rawResponse);
|
3980
|
+
if (isErrorResponse(response)) {
|
3981
|
+
return { ...response, error: { ...response.error, code: Number(response.error.code) } };
|
3982
|
+
}
|
3983
|
+
return response;
|
3984
|
+
},
|
3985
|
+
toJson: (payload) => isSolanaRequest(payload) ? stringifyJsonWithBigints(payload) : JSON.stringify(payload)
|
3986
|
+
});
|
3987
|
+
}
|
3988
|
+
function isErrorResponse(value) {
|
3989
|
+
return !!value && typeof value === "object" && "error" in value && !!value.error && typeof value.error === "object" && "code" in value.error;
|
3990
|
+
}
|
3792
3991
|
|
3793
3992
|
// ../fast-stable-stringify/dist/index.browser.mjs
|
3794
3993
|
var objToString = Object.prototype.toString;
|
@@ -3897,8 +4096,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3897
4096
|
}
|
3898
4097
|
var DEFAULT_RPC_CONFIG = {
|
3899
4098
|
defaultCommitment: "confirmed",
|
3900
|
-
onIntegerOverflow(
|
3901
|
-
throw createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
4099
|
+
onIntegerOverflow(request, keyPath, value) {
|
4100
|
+
throw createSolanaJsonRpcIntegerOverflowError(request.methodName, keyPath, value);
|
3902
4101
|
}
|
3903
4102
|
};
|
3904
4103
|
var EXPLICIT_ABORT_TOKEN;
|
@@ -3909,14 +4108,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3909
4108
|
}
|
3910
4109
|
function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
3911
4110
|
let coalescedRequestsByDeduplicationKey;
|
3912
|
-
return async function makeCoalescedHttpRequest(
|
3913
|
-
const { payload, signal } =
|
4111
|
+
return async function makeCoalescedHttpRequest(request) {
|
4112
|
+
const { payload, signal } = request;
|
3914
4113
|
const deduplicationKey = getDeduplicationKey(payload);
|
3915
4114
|
if (deduplicationKey === void 0) {
|
3916
|
-
return await transport(
|
4115
|
+
return await transport(request);
|
3917
4116
|
}
|
3918
4117
|
if (!coalescedRequestsByDeduplicationKey) {
|
3919
|
-
|
4118
|
+
queueMicrotask(() => {
|
3920
4119
|
coalescedRequestsByDeduplicationKey = void 0;
|
3921
4120
|
});
|
3922
4121
|
coalescedRequestsByDeduplicationKey = {};
|
@@ -3926,7 +4125,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3926
4125
|
const responsePromise = (async () => {
|
3927
4126
|
try {
|
3928
4127
|
return await transport({
|
3929
|
-
...
|
4128
|
+
...request,
|
3930
4129
|
signal: abortController.signal
|
3931
4130
|
});
|
3932
4131
|
} catch (e3) {
|
@@ -3950,7 +4149,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3950
4149
|
const handleAbort = (e3) => {
|
3951
4150
|
signal.removeEventListener("abort", handleAbort);
|
3952
4151
|
coalescedRequest.numConsumers -= 1;
|
3953
|
-
|
4152
|
+
queueMicrotask(() => {
|
3954
4153
|
if (coalescedRequest.numConsumers === 0) {
|
3955
4154
|
const abortController = coalescedRequest.abortController;
|
3956
4155
|
abortController.abort(EXPLICIT_ABORT_TOKEN || (EXPLICIT_ABORT_TOKEN = createExplicitAbortToken()));
|
@@ -3968,12 +4167,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3968
4167
|
}
|
3969
4168
|
};
|
3970
4169
|
}
|
3971
|
-
function isJsonRpcPayload(payload) {
|
3972
|
-
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
3973
|
-
return false;
|
3974
|
-
}
|
3975
|
-
return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
|
3976
|
-
}
|
3977
4170
|
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
3978
4171
|
return isJsonRpcPayload(payload) ? src_default([payload.method, payload.params]) : void 0;
|
3979
4172
|
}
|
@@ -3985,15 +4178,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3985
4178
|
return out;
|
3986
4179
|
}
|
3987
4180
|
function createDefaultRpcTransport(config) {
|
3988
|
-
var _a;
|
3989
4181
|
return pipe(
|
3990
|
-
|
4182
|
+
createHttpTransportForSolanaRpc({
|
3991
4183
|
...config,
|
3992
4184
|
headers: {
|
4185
|
+
...false,
|
3993
4186
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
3994
4187
|
...{
|
3995
4188
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
3996
|
-
"solana-client":
|
4189
|
+
"solana-client": `js/${"2.0.0-rc.3"}`
|
3997
4190
|
}
|
3998
4191
|
}
|
3999
4192
|
}),
|
@@ -4010,100 +4203,287 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4010
4203
|
});
|
4011
4204
|
}
|
4012
4205
|
|
4013
|
-
// ../
|
4014
|
-
|
4015
|
-
|
4206
|
+
// ../subscribable/dist/index.browser.mjs
|
4207
|
+
var EXPLICIT_ABORT_TOKEN2;
|
4208
|
+
function createExplicitAbortToken2() {
|
4209
|
+
return Symbol(
|
4210
|
+
"This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
|
4211
|
+
);
|
4016
4212
|
}
|
4017
|
-
|
4018
|
-
|
4019
|
-
|
4020
|
-
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
|
4037
|
-
unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
|
4038
|
-
};
|
4039
|
-
return createPendingRpcSubscription(rpcConfig, newRequest);
|
4040
|
-
};
|
4213
|
+
var UNINITIALIZED = Symbol();
|
4214
|
+
function createAsyncIterableFromDataPublisher({
|
4215
|
+
abortSignal,
|
4216
|
+
dataChannelName,
|
4217
|
+
dataPublisher,
|
4218
|
+
errorChannelName
|
4219
|
+
}) {
|
4220
|
+
const iteratorState = /* @__PURE__ */ new Map();
|
4221
|
+
function publishErrorToAllIterators(reason) {
|
4222
|
+
for (const [iteratorKey, state] of iteratorState.entries()) {
|
4223
|
+
if (state.__hasPolled) {
|
4224
|
+
iteratorState.delete(iteratorKey);
|
4225
|
+
state.onError(reason);
|
4226
|
+
} else {
|
4227
|
+
state.publishQueue.push({
|
4228
|
+
__type: 1,
|
4229
|
+
err: reason
|
4230
|
+
});
|
4231
|
+
}
|
4041
4232
|
}
|
4233
|
+
}
|
4234
|
+
const abortController = new AbortController();
|
4235
|
+
abortSignal.addEventListener("abort", () => {
|
4236
|
+
abortController.abort();
|
4237
|
+
publishErrorToAllIterators(EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()));
|
4042
4238
|
});
|
4043
|
-
|
4044
|
-
|
4045
|
-
(
|
4046
|
-
|
4047
|
-
|
4048
|
-
|
4049
|
-
|
4050
|
-
|
4051
|
-
|
4052
|
-
|
4053
|
-
|
4054
|
-
|
4055
|
-
|
4056
|
-
|
4057
|
-
|
4058
|
-
|
4059
|
-
|
4060
|
-
if (
|
4061
|
-
const
|
4062
|
-
|
4063
|
-
|
4064
|
-
});
|
4239
|
+
const options = { signal: abortController.signal };
|
4240
|
+
let firstError = UNINITIALIZED;
|
4241
|
+
dataPublisher.on(
|
4242
|
+
errorChannelName,
|
4243
|
+
(err) => {
|
4244
|
+
if (firstError === UNINITIALIZED) {
|
4245
|
+
firstError = err;
|
4246
|
+
abortController.abort();
|
4247
|
+
publishErrorToAllIterators(err);
|
4248
|
+
}
|
4249
|
+
},
|
4250
|
+
options
|
4251
|
+
);
|
4252
|
+
dataPublisher.on(
|
4253
|
+
dataChannelName,
|
4254
|
+
(data) => {
|
4255
|
+
iteratorState.forEach((state, iteratorKey) => {
|
4256
|
+
if (state.__hasPolled) {
|
4257
|
+
const { onData } = state;
|
4258
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, publishQueue: [] });
|
4259
|
+
onData(data);
|
4065
4260
|
} else {
|
4066
|
-
|
4261
|
+
state.publishQueue.push({
|
4262
|
+
__type: 0,
|
4263
|
+
data
|
4264
|
+
});
|
4067
4265
|
}
|
4068
|
-
}
|
4069
|
-
abortSignal.addEventListener("abort", handleCleanup);
|
4070
|
-
const connectionAbortController = new AbortController();
|
4071
|
-
const subscribeMessage = createRpcMessage(subscribeMethodName, params);
|
4072
|
-
const connection = await rpcConfig.transport({
|
4073
|
-
payload: subscribeMessage,
|
4074
|
-
signal: connectionAbortController.signal
|
4075
4266
|
});
|
4076
|
-
|
4077
|
-
|
4078
|
-
|
4079
|
-
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
throw getSolanaErrorFromJsonRpcError(message.error);
|
4084
|
-
} else {
|
4085
|
-
subscriptionId = message.result;
|
4086
|
-
break;
|
4087
|
-
}
|
4088
|
-
}
|
4267
|
+
},
|
4268
|
+
options
|
4269
|
+
);
|
4270
|
+
return {
|
4271
|
+
async *[Symbol.asyncIterator]() {
|
4272
|
+
if (abortSignal.aborted) {
|
4273
|
+
return;
|
4089
4274
|
}
|
4090
|
-
if (
|
4091
|
-
throw
|
4275
|
+
if (firstError !== UNINITIALIZED) {
|
4276
|
+
throw firstError;
|
4092
4277
|
}
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
|
4278
|
+
const iteratorKey = Symbol();
|
4279
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, publishQueue: [] });
|
4280
|
+
try {
|
4281
|
+
while (true) {
|
4282
|
+
const state = iteratorState.get(iteratorKey);
|
4283
|
+
if (!state) {
|
4284
|
+
throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING);
|
4101
4285
|
}
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4286
|
+
if (state.__hasPolled) {
|
4287
|
+
throw new SolanaError(
|
4288
|
+
SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE
|
4289
|
+
);
|
4290
|
+
}
|
4291
|
+
const publishQueue = state.publishQueue;
|
4292
|
+
try {
|
4293
|
+
if (publishQueue.length) {
|
4294
|
+
state.publishQueue = [];
|
4295
|
+
for (const item of publishQueue) {
|
4296
|
+
if (item.__type === 0) {
|
4297
|
+
yield item.data;
|
4298
|
+
} else {
|
4299
|
+
throw item.err;
|
4300
|
+
}
|
4301
|
+
}
|
4302
|
+
} else {
|
4303
|
+
yield await new Promise((resolve, reject) => {
|
4304
|
+
iteratorState.set(iteratorKey, {
|
4305
|
+
__hasPolled: true,
|
4306
|
+
onData: resolve,
|
4307
|
+
onError: reject
|
4308
|
+
});
|
4309
|
+
});
|
4310
|
+
}
|
4311
|
+
} catch (e3) {
|
4312
|
+
if (e3 === (EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()))) {
|
4313
|
+
return;
|
4314
|
+
} else {
|
4315
|
+
throw e3;
|
4316
|
+
}
|
4317
|
+
}
|
4318
|
+
}
|
4319
|
+
} finally {
|
4320
|
+
iteratorState.delete(iteratorKey);
|
4321
|
+
}
|
4322
|
+
}
|
4323
|
+
};
|
4324
|
+
}
|
4325
|
+
function getDataPublisherFromEventEmitter(eventEmitter) {
|
4326
|
+
return {
|
4327
|
+
on(channelName, subscriber, options) {
|
4328
|
+
function innerListener(ev) {
|
4329
|
+
if (ev instanceof CustomEvent) {
|
4330
|
+
const data = ev.detail;
|
4331
|
+
subscriber(data);
|
4332
|
+
} else {
|
4333
|
+
subscriber();
|
4334
|
+
}
|
4335
|
+
}
|
4336
|
+
eventEmitter.addEventListener(channelName, innerListener, options);
|
4337
|
+
return () => {
|
4338
|
+
eventEmitter.removeEventListener(channelName, innerListener);
|
4339
|
+
};
|
4340
|
+
}
|
4341
|
+
};
|
4342
|
+
}
|
4343
|
+
function demultiplexDataPublisher(publisher, sourceChannelName, messageTransformer) {
|
4344
|
+
let innerPublisherState;
|
4345
|
+
const eventTarget = new EventTarget();
|
4346
|
+
const demultiplexedDataPublisher = getDataPublisherFromEventEmitter(eventTarget);
|
4347
|
+
return {
|
4348
|
+
...demultiplexedDataPublisher,
|
4349
|
+
on(channelName, subscriber, options) {
|
4350
|
+
if (!innerPublisherState) {
|
4351
|
+
const innerPublisherUnsubscribe = publisher.on(sourceChannelName, (sourceMessage) => {
|
4352
|
+
const transformResult = messageTransformer(sourceMessage);
|
4353
|
+
if (!transformResult) {
|
4354
|
+
return;
|
4355
|
+
}
|
4356
|
+
const [destinationChannelName, message] = transformResult;
|
4357
|
+
eventTarget.dispatchEvent(
|
4358
|
+
new CustomEvent(destinationChannelName, {
|
4359
|
+
detail: message
|
4360
|
+
})
|
4361
|
+
);
|
4362
|
+
});
|
4363
|
+
innerPublisherState = {
|
4364
|
+
dispose: innerPublisherUnsubscribe,
|
4365
|
+
numSubscribers: 0
|
4366
|
+
};
|
4367
|
+
}
|
4368
|
+
innerPublisherState.numSubscribers++;
|
4369
|
+
const unsubscribe = demultiplexedDataPublisher.on(channelName, subscriber, options);
|
4370
|
+
let isActive = true;
|
4371
|
+
function handleUnsubscribe() {
|
4372
|
+
if (!isActive) {
|
4373
|
+
return;
|
4374
|
+
}
|
4375
|
+
isActive = false;
|
4376
|
+
options == null ? void 0 : options.signal.removeEventListener("abort", handleUnsubscribe);
|
4377
|
+
innerPublisherState.numSubscribers--;
|
4378
|
+
if (innerPublisherState.numSubscribers === 0) {
|
4379
|
+
innerPublisherState.dispose();
|
4380
|
+
innerPublisherState = void 0;
|
4381
|
+
}
|
4382
|
+
unsubscribe();
|
4383
|
+
}
|
4384
|
+
options == null ? void 0 : options.signal.addEventListener("abort", handleUnsubscribe);
|
4385
|
+
return handleUnsubscribe;
|
4386
|
+
}
|
4387
|
+
};
|
4388
|
+
}
|
4389
|
+
|
4390
|
+
// ../promises/dist/index.browser.mjs
|
4391
|
+
function isObject(value) {
|
4392
|
+
return value !== null && (typeof value === "object" || typeof value === "function");
|
4393
|
+
}
|
4394
|
+
function addRaceContender(contender) {
|
4395
|
+
const deferreds = /* @__PURE__ */ new Set();
|
4396
|
+
const record = { deferreds, settled: false };
|
4397
|
+
Promise.resolve(contender).then(
|
4398
|
+
(value) => {
|
4399
|
+
for (const { resolve } of deferreds) {
|
4400
|
+
resolve(value);
|
4401
|
+
}
|
4402
|
+
deferreds.clear();
|
4403
|
+
record.settled = true;
|
4404
|
+
},
|
4405
|
+
(err) => {
|
4406
|
+
for (const { reject } of deferreds) {
|
4407
|
+
reject(err);
|
4408
|
+
}
|
4409
|
+
deferreds.clear();
|
4410
|
+
record.settled = true;
|
4411
|
+
}
|
4412
|
+
);
|
4413
|
+
return record;
|
4414
|
+
}
|
4415
|
+
var wm = /* @__PURE__ */ new WeakMap();
|
4416
|
+
async function safeRace(contenders) {
|
4417
|
+
let deferred;
|
4418
|
+
const result = new Promise((resolve, reject) => {
|
4419
|
+
deferred = { reject, resolve };
|
4420
|
+
for (const contender of contenders) {
|
4421
|
+
if (!isObject(contender)) {
|
4422
|
+
Promise.resolve(contender).then(resolve, reject);
|
4423
|
+
continue;
|
4424
|
+
}
|
4425
|
+
let record = wm.get(contender);
|
4426
|
+
if (record === void 0) {
|
4427
|
+
record = addRaceContender(contender);
|
4428
|
+
record.deferreds.add(deferred);
|
4429
|
+
wm.set(contender, record);
|
4430
|
+
} else if (record.settled) {
|
4431
|
+
Promise.resolve(contender).then(resolve, reject);
|
4432
|
+
} else {
|
4433
|
+
record.deferreds.add(deferred);
|
4434
|
+
}
|
4435
|
+
}
|
4436
|
+
});
|
4437
|
+
return await result.finally(() => {
|
4438
|
+
for (const contender of contenders) {
|
4439
|
+
if (isObject(contender)) {
|
4440
|
+
const record = wm.get(contender);
|
4441
|
+
record.deferreds.delete(deferred);
|
4442
|
+
}
|
4443
|
+
}
|
4444
|
+
});
|
4445
|
+
}
|
4446
|
+
|
4447
|
+
// ../rpc-subscriptions-spec/dist/index.browser.mjs
|
4448
|
+
function createSubscriptionRpc(rpcConfig) {
|
4449
|
+
return new Proxy(rpcConfig.api, {
|
4450
|
+
defineProperty() {
|
4451
|
+
return false;
|
4452
|
+
},
|
4453
|
+
deleteProperty() {
|
4454
|
+
return false;
|
4455
|
+
},
|
4456
|
+
get(target, p, receiver) {
|
4457
|
+
return function(...rawParams) {
|
4458
|
+
const notificationName = p.toString();
|
4459
|
+
const createRpcSubscriptionPlan = Reflect.get(target, notificationName, receiver);
|
4460
|
+
if (!createRpcSubscriptionPlan) {
|
4461
|
+
throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN, {
|
4462
|
+
notificationName
|
4463
|
+
});
|
4464
|
+
}
|
4465
|
+
const subscriptionPlan = createRpcSubscriptionPlan(...rawParams);
|
4466
|
+
return createPendingRpcSubscription(rpcConfig.transport, subscriptionPlan);
|
4467
|
+
};
|
4468
|
+
}
|
4469
|
+
});
|
4470
|
+
}
|
4471
|
+
function createPendingRpcSubscription(transport, subscriptionsPlan) {
|
4472
|
+
return {
|
4473
|
+
async subscribe({ abortSignal }) {
|
4474
|
+
const notificationsDataPublisher = await transport({
|
4475
|
+
signal: abortSignal,
|
4476
|
+
...subscriptionsPlan
|
4477
|
+
});
|
4478
|
+
return createAsyncIterableFromDataPublisher({
|
4479
|
+
abortSignal,
|
4480
|
+
dataChannelName: "notification",
|
4481
|
+
dataPublisher: notificationsDataPublisher,
|
4482
|
+
errorChannelName: "error"
|
4483
|
+
});
|
4484
|
+
}
|
4485
|
+
};
|
4486
|
+
}
|
4107
4487
|
function createRpcSubscriptionsApi(config) {
|
4108
4488
|
return new Proxy({}, {
|
4109
4489
|
defineProperty() {
|
@@ -4114,32 +4494,206 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4114
4494
|
},
|
4115
4495
|
get(...args) {
|
4116
4496
|
const [_, p] = args;
|
4117
|
-
const
|
4118
|
-
return function(...
|
4119
|
-
const
|
4120
|
-
const
|
4121
|
-
const subscribeMethodName = (config == null ? void 0 : config.subscribeNotificationNameTransformer) ? config == null ? void 0 : config.subscribeNotificationNameTransformer(notificationName) : notificationName;
|
4122
|
-
const unsubscribeMethodName = (config == null ? void 0 : config.unsubscribeNotificationNameTransformer) ? config == null ? void 0 : config.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
|
4497
|
+
const methodName = p.toString();
|
4498
|
+
return function(...params) {
|
4499
|
+
const rawRequest = { methodName, params };
|
4500
|
+
const request = config.requestTransformer ? config.requestTransformer(rawRequest) : rawRequest;
|
4123
4501
|
return {
|
4124
|
-
|
4125
|
-
|
4126
|
-
|
4127
|
-
|
4502
|
+
execute(planConfig) {
|
4503
|
+
return config.planExecutor({ ...planConfig, request });
|
4504
|
+
},
|
4505
|
+
request
|
4128
4506
|
};
|
4129
4507
|
};
|
4130
4508
|
}
|
4131
4509
|
});
|
4132
4510
|
}
|
4511
|
+
function transformChannelInboundMessages(channel, transform) {
|
4512
|
+
return Object.freeze({
|
4513
|
+
...channel,
|
4514
|
+
on(type, subscriber, options) {
|
4515
|
+
if (type !== "message") {
|
4516
|
+
return channel.on(
|
4517
|
+
type,
|
4518
|
+
subscriber,
|
4519
|
+
options
|
4520
|
+
);
|
4521
|
+
}
|
4522
|
+
return channel.on(
|
4523
|
+
"message",
|
4524
|
+
(message) => subscriber(transform(message)),
|
4525
|
+
options
|
4526
|
+
);
|
4527
|
+
}
|
4528
|
+
});
|
4529
|
+
}
|
4530
|
+
function transformChannelOutboundMessages(channel, transform) {
|
4531
|
+
return Object.freeze({
|
4532
|
+
...channel,
|
4533
|
+
send: (message) => channel.send(transform(message))
|
4534
|
+
});
|
4535
|
+
}
|
4536
|
+
var subscriberCountBySubscriptionIdByChannel = /* @__PURE__ */ new WeakMap();
|
4537
|
+
function decrementSubscriberCountAndReturnNewCount(channel, subscriptionId) {
|
4538
|
+
return augmentSubscriberCountAndReturnNewCount(-1, channel, subscriptionId);
|
4539
|
+
}
|
4540
|
+
function incrementSubscriberCount(channel, subscriptionId) {
|
4541
|
+
augmentSubscriberCountAndReturnNewCount(1, channel, subscriptionId);
|
4542
|
+
}
|
4543
|
+
function augmentSubscriberCountAndReturnNewCount(amount, channel, subscriptionId) {
|
4544
|
+
if (subscriptionId === void 0) {
|
4545
|
+
return;
|
4546
|
+
}
|
4547
|
+
let subscriberCountBySubscriptionId = subscriberCountBySubscriptionIdByChannel.get(channel);
|
4548
|
+
if (!subscriberCountBySubscriptionId && amount > 0) {
|
4549
|
+
subscriberCountBySubscriptionIdByChannel.set(
|
4550
|
+
channel,
|
4551
|
+
subscriberCountBySubscriptionId = { [subscriptionId]: 0 }
|
4552
|
+
);
|
4553
|
+
}
|
4554
|
+
if ((subscriberCountBySubscriptionId == null ? void 0 : subscriberCountBySubscriptionId[subscriptionId]) !== void 0) {
|
4555
|
+
return subscriberCountBySubscriptionId[subscriptionId] = amount + subscriberCountBySubscriptionId[subscriptionId];
|
4556
|
+
}
|
4557
|
+
}
|
4558
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
4559
|
+
function getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer(channel, subscribeRequest, responseTransformer) {
|
4560
|
+
let publisherByResponseTransformer = cache.get(channel);
|
4561
|
+
if (!publisherByResponseTransformer) {
|
4562
|
+
cache.set(channel, publisherByResponseTransformer = /* @__PURE__ */ new WeakMap());
|
4563
|
+
}
|
4564
|
+
const responseTransformerKey = responseTransformer != null ? responseTransformer : channel;
|
4565
|
+
let publisher = publisherByResponseTransformer.get(responseTransformerKey);
|
4566
|
+
if (!publisher) {
|
4567
|
+
publisherByResponseTransformer.set(
|
4568
|
+
responseTransformerKey,
|
4569
|
+
publisher = demultiplexDataPublisher(channel, "message", (rawMessage) => {
|
4570
|
+
const message = rawMessage;
|
4571
|
+
if (!("method" in message)) {
|
4572
|
+
return;
|
4573
|
+
}
|
4574
|
+
const transformedNotification = responseTransformer ? responseTransformer(message.params.result, subscribeRequest) : message.params.result;
|
4575
|
+
return [`notification:${message.params.subscription}`, transformedNotification];
|
4576
|
+
})
|
4577
|
+
);
|
4578
|
+
}
|
4579
|
+
return publisher;
|
4580
|
+
}
|
4581
|
+
async function executeRpcPubSubSubscriptionPlan({
|
4582
|
+
channel,
|
4583
|
+
responseTransformer,
|
4584
|
+
signal,
|
4585
|
+
subscribeRequest,
|
4586
|
+
unsubscribeMethodName
|
4587
|
+
}) {
|
4588
|
+
let subscriptionId;
|
4589
|
+
channel.on(
|
4590
|
+
"error",
|
4591
|
+
() => {
|
4592
|
+
subscriptionId = void 0;
|
4593
|
+
subscriberCountBySubscriptionIdByChannel.delete(channel);
|
4594
|
+
},
|
4595
|
+
{ signal }
|
4596
|
+
);
|
4597
|
+
const abortPromise = new Promise((_, reject) => {
|
4598
|
+
function handleAbort() {
|
4599
|
+
if (decrementSubscriberCountAndReturnNewCount(channel, subscriptionId) === 0) {
|
4600
|
+
const unsubscribePayload = createRpcMessage({
|
4601
|
+
methodName: unsubscribeMethodName,
|
4602
|
+
params: [subscriptionId]
|
4603
|
+
});
|
4604
|
+
subscriptionId = void 0;
|
4605
|
+
channel.send(unsubscribePayload).catch(() => {
|
4606
|
+
});
|
4607
|
+
}
|
4608
|
+
reject(this.reason);
|
4609
|
+
}
|
4610
|
+
if (signal.aborted) {
|
4611
|
+
handleAbort.call(signal);
|
4612
|
+
} else {
|
4613
|
+
signal.addEventListener("abort", handleAbort);
|
4614
|
+
}
|
4615
|
+
});
|
4616
|
+
const subscribePayload = createRpcMessage(subscribeRequest);
|
4617
|
+
await channel.send(subscribePayload);
|
4618
|
+
const subscriptionIdPromise = new Promise((resolve, reject) => {
|
4619
|
+
const abortController = new AbortController();
|
4620
|
+
signal.addEventListener("abort", abortController.abort.bind(abortController));
|
4621
|
+
const options = { signal: abortController.signal };
|
4622
|
+
channel.on(
|
4623
|
+
"error",
|
4624
|
+
(err) => {
|
4625
|
+
abortController.abort();
|
4626
|
+
reject(err);
|
4627
|
+
},
|
4628
|
+
options
|
4629
|
+
);
|
4630
|
+
channel.on(
|
4631
|
+
"message",
|
4632
|
+
(message) => {
|
4633
|
+
if (message && typeof message === "object" && "id" in message && message.id === subscribePayload.id) {
|
4634
|
+
abortController.abort();
|
4635
|
+
if ("error" in message) {
|
4636
|
+
reject(getSolanaErrorFromJsonRpcError(message.error));
|
4637
|
+
} else {
|
4638
|
+
resolve(message.result);
|
4639
|
+
}
|
4640
|
+
}
|
4641
|
+
},
|
4642
|
+
options
|
4643
|
+
);
|
4644
|
+
});
|
4645
|
+
subscriptionId = await safeRace([abortPromise, subscriptionIdPromise]);
|
4646
|
+
if (subscriptionId == null) {
|
4647
|
+
throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID);
|
4648
|
+
}
|
4649
|
+
incrementSubscriberCount(channel, subscriptionId);
|
4650
|
+
const notificationPublisher = getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer(
|
4651
|
+
channel,
|
4652
|
+
subscribeRequest,
|
4653
|
+
responseTransformer
|
4654
|
+
);
|
4655
|
+
const notificationKey = `notification:${subscriptionId}`;
|
4656
|
+
return {
|
4657
|
+
on(type, listener, options) {
|
4658
|
+
switch (type) {
|
4659
|
+
case "notification":
|
4660
|
+
return notificationPublisher.on(
|
4661
|
+
notificationKey,
|
4662
|
+
listener,
|
4663
|
+
options
|
4664
|
+
);
|
4665
|
+
case "error":
|
4666
|
+
return channel.on(
|
4667
|
+
"error",
|
4668
|
+
listener,
|
4669
|
+
options
|
4670
|
+
);
|
4671
|
+
default:
|
4672
|
+
throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED, {
|
4673
|
+
channelName: type,
|
4674
|
+
supportedChannelNames: ["notification", "error"]
|
4675
|
+
});
|
4676
|
+
}
|
4677
|
+
}
|
4678
|
+
};
|
4679
|
+
}
|
4133
4680
|
|
4134
4681
|
// ../rpc-subscriptions-api/dist/index.browser.mjs
|
4135
4682
|
function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
|
4683
|
+
const requestTransformer = getDefaultRequestTransformerForSolanaRpc(config);
|
4684
|
+
const responseTransformer = getDefaultResponseTransformerForSolanaRpcSubscriptions({
|
4685
|
+
allowedNumericKeyPaths: getAllowedNumericKeypaths2()
|
4686
|
+
});
|
4136
4687
|
return createRpcSubscriptionsApi({
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4688
|
+
planExecutor({ request, ...rest }) {
|
4689
|
+
return executeRpcPubSubSubscriptionPlan({
|
4690
|
+
...rest,
|
4691
|
+
responseTransformer,
|
4692
|
+
subscribeRequest: { ...request, methodName: request.methodName.replace(/Notifications$/, "Subscribe") },
|
4693
|
+
unsubscribeMethodName: request.methodName.replace(/Notifications$/, "Unsubscribe")
|
4694
|
+
});
|
4695
|
+
},
|
4696
|
+
requestTransformer
|
4143
4697
|
});
|
4144
4698
|
}
|
4145
4699
|
function createSolanaRpcSubscriptionsApi(config) {
|
@@ -4156,7 +4710,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4156
4710
|
memoizedKeypaths2 = {
|
4157
4711
|
accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
4158
4712
|
blockNotifications: [
|
4159
|
-
["value", "block", "blockTime"],
|
4160
4713
|
[
|
4161
4714
|
"value",
|
4162
4715
|
"block",
|
@@ -4323,587 +4876,464 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
4323
4876
|
return memoizedKeypaths2;
|
4324
4877
|
}
|
4325
4878
|
|
4326
|
-
// ../
|
4327
|
-
function isObject(value) {
|
4328
|
-
return value !== null && (typeof value === "object" || typeof value === "function");
|
4329
|
-
}
|
4330
|
-
function addRaceContender(contender) {
|
4331
|
-
const deferreds = /* @__PURE__ */ new Set();
|
4332
|
-
const record = { deferreds, settled: false };
|
4333
|
-
Promise.resolve(contender).then(
|
4334
|
-
(value) => {
|
4335
|
-
for (const { resolve } of deferreds) {
|
4336
|
-
resolve(value);
|
4337
|
-
}
|
4338
|
-
deferreds.clear();
|
4339
|
-
record.settled = true;
|
4340
|
-
},
|
4341
|
-
(err) => {
|
4342
|
-
for (const { reject } of deferreds) {
|
4343
|
-
reject(err);
|
4344
|
-
}
|
4345
|
-
deferreds.clear();
|
4346
|
-
record.settled = true;
|
4347
|
-
}
|
4348
|
-
);
|
4349
|
-
return record;
|
4350
|
-
}
|
4351
|
-
var wm = /* @__PURE__ */ new WeakMap();
|
4352
|
-
async function safeRace(contenders) {
|
4353
|
-
let deferred;
|
4354
|
-
const result = new Promise((resolve, reject) => {
|
4355
|
-
deferred = { reject, resolve };
|
4356
|
-
for (const contender of contenders) {
|
4357
|
-
if (!isObject(contender)) {
|
4358
|
-
Promise.resolve(contender).then(resolve, reject);
|
4359
|
-
continue;
|
4360
|
-
}
|
4361
|
-
let record = wm.get(contender);
|
4362
|
-
if (record === void 0) {
|
4363
|
-
record = addRaceContender(contender);
|
4364
|
-
record.deferreds.add(deferred);
|
4365
|
-
wm.set(contender, record);
|
4366
|
-
} else if (record.settled) {
|
4367
|
-
Promise.resolve(contender).then(resolve, reject);
|
4368
|
-
} else {
|
4369
|
-
record.deferreds.add(deferred);
|
4370
|
-
}
|
4371
|
-
}
|
4372
|
-
});
|
4373
|
-
return await result.finally(() => {
|
4374
|
-
for (const contender of contenders) {
|
4375
|
-
if (isObject(contender)) {
|
4376
|
-
const record = wm.get(contender);
|
4377
|
-
record.deferreds.delete(deferred);
|
4378
|
-
}
|
4379
|
-
}
|
4380
|
-
});
|
4381
|
-
}
|
4382
|
-
|
4383
|
-
// ../rpc-subscriptions-transport-websocket/dist/index.browser.mjs
|
4879
|
+
// ../rpc-subscriptions-channel-websocket/dist/index.browser.mjs
|
4384
4880
|
var e2 = globalThis.WebSocket;
|
4385
|
-
var
|
4386
|
-
function
|
4387
|
-
return Symbol(
|
4388
|
-
"This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
|
4389
|
-
);
|
4390
|
-
}
|
4391
|
-
async function createWebSocketConnection({
|
4881
|
+
var NORMAL_CLOSURE_CODE = 1e3;
|
4882
|
+
function createWebSocketChannel({
|
4392
4883
|
sendBufferHighWatermark,
|
4393
4884
|
signal,
|
4394
4885
|
url
|
4395
4886
|
}) {
|
4396
|
-
|
4397
|
-
signal.
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
} catch {
|
4406
|
-
}
|
4407
|
-
});
|
4408
|
-
}
|
4409
|
-
function handleAbort() {
|
4410
|
-
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()));
|
4411
|
-
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
|
4412
|
-
webSocket.close(1e3);
|
4413
|
-
}
|
4414
|
-
}
|
4415
|
-
function handleClose(ev) {
|
4416
|
-
bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
|
4417
|
-
signal.removeEventListener("abort", handleAbort);
|
4418
|
-
webSocket.removeEventListener("close", handleClose);
|
4419
|
-
webSocket.removeEventListener("error", handleError);
|
4420
|
-
webSocket.removeEventListener("open", handleOpen);
|
4421
|
-
webSocket.removeEventListener("message", handleMessage);
|
4422
|
-
errorAndClearAllIteratorStates(ev);
|
4423
|
-
}
|
4424
|
-
function handleError(ev) {
|
4425
|
-
if (!hasConnected) {
|
4426
|
-
reject(
|
4427
|
-
new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT, {
|
4428
|
-
errorEvent: ev
|
4429
|
-
})
|
4430
|
-
);
|
4431
|
-
}
|
4432
|
-
}
|
4433
|
-
let hasConnected = false;
|
4434
|
-
let bufferDrainWatcher;
|
4435
|
-
function handleOpen() {
|
4436
|
-
hasConnected = true;
|
4437
|
-
resolve({
|
4438
|
-
async send(payload) {
|
4439
|
-
const message = JSON.stringify(payload);
|
4440
|
-
if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
4441
|
-
let onCancel;
|
4442
|
-
const promise = new Promise((resolve2, reject2) => {
|
4443
|
-
const intervalId = setInterval(() => {
|
4444
|
-
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
4445
|
-
clearInterval(intervalId);
|
4446
|
-
bufferDrainWatcher = void 0;
|
4447
|
-
resolve2();
|
4448
|
-
}
|
4449
|
-
}, 16);
|
4450
|
-
onCancel = () => {
|
4451
|
-
bufferDrainWatcher = void 0;
|
4452
|
-
clearInterval(intervalId);
|
4453
|
-
reject2(
|
4454
|
-
new SolanaError(
|
4455
|
-
SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED
|
4456
|
-
)
|
4457
|
-
);
|
4458
|
-
};
|
4459
|
-
});
|
4460
|
-
bufferDrainWatcher = {
|
4461
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
4462
|
-
// @ts-ignore
|
4463
|
-
onCancel,
|
4464
|
-
promise
|
4465
|
-
};
|
4466
|
-
}
|
4467
|
-
if (bufferDrainWatcher) {
|
4468
|
-
await bufferDrainWatcher.promise;
|
4469
|
-
}
|
4470
|
-
webSocket.send(message);
|
4471
|
-
},
|
4472
|
-
async *[Symbol.asyncIterator]() {
|
4473
|
-
const iteratorKey = Symbol();
|
4474
|
-
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
4475
|
-
try {
|
4476
|
-
while (true) {
|
4477
|
-
const state = iteratorState.get(iteratorKey);
|
4478
|
-
if (!state) {
|
4479
|
-
throw new SolanaError(
|
4480
|
-
SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING
|
4481
|
-
);
|
4482
|
-
}
|
4483
|
-
if (state.__hasPolled) {
|
4484
|
-
throw new SolanaError(
|
4485
|
-
SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE
|
4486
|
-
);
|
4487
|
-
}
|
4488
|
-
const queuedMessages = state.queuedMessages;
|
4489
|
-
if (queuedMessages.length) {
|
4490
|
-
state.queuedMessages = [];
|
4491
|
-
yield* queuedMessages;
|
4492
|
-
} else {
|
4493
|
-
try {
|
4494
|
-
yield await new Promise((resolve2, reject2) => {
|
4495
|
-
iteratorState.set(iteratorKey, {
|
4496
|
-
__hasPolled: true,
|
4497
|
-
onError: reject2,
|
4498
|
-
onMessage: resolve2
|
4499
|
-
});
|
4500
|
-
});
|
4501
|
-
} catch (e22) {
|
4502
|
-
if (e22 === (EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()))) {
|
4503
|
-
return;
|
4504
|
-
} else {
|
4505
|
-
throw new SolanaError(
|
4506
|
-
SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED,
|
4507
|
-
{
|
4508
|
-
cause: e22
|
4509
|
-
}
|
4510
|
-
);
|
4511
|
-
}
|
4512
|
-
}
|
4513
|
-
}
|
4514
|
-
}
|
4515
|
-
} finally {
|
4516
|
-
iteratorState.delete(iteratorKey);
|
4517
|
-
}
|
4518
|
-
}
|
4519
|
-
});
|
4520
|
-
}
|
4521
|
-
function handleMessage({ data }) {
|
4522
|
-
const message = JSON.parse(data);
|
4523
|
-
iteratorState.forEach((state, iteratorKey) => {
|
4524
|
-
if (state.__hasPolled) {
|
4525
|
-
const { onMessage } = state;
|
4526
|
-
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
4527
|
-
onMessage(message);
|
4528
|
-
} else {
|
4529
|
-
state.queuedMessages.push(message);
|
4530
|
-
}
|
4531
|
-
});
|
4532
|
-
}
|
4533
|
-
const webSocket = new e2(url);
|
4534
|
-
webSocket.addEventListener("close", handleClose);
|
4535
|
-
webSocket.addEventListener("error", handleError);
|
4536
|
-
webSocket.addEventListener("open", handleOpen);
|
4537
|
-
webSocket.addEventListener("message", handleMessage);
|
4538
|
-
});
|
4539
|
-
}
|
4540
|
-
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
|
4541
|
-
if (/^wss?:/i.test(url) === false) {
|
4542
|
-
const protocolMatch = url.match(/^([^:]+):/);
|
4543
|
-
throw new DOMException(
|
4544
|
-
protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
|
4545
|
-
);
|
4546
|
-
}
|
4547
|
-
return async function sendWebSocketMessage({ payload, signal }) {
|
4548
|
-
signal == null ? void 0 : signal.throwIfAborted();
|
4549
|
-
const connection = await createWebSocketConnection({
|
4550
|
-
sendBufferHighWatermark,
|
4551
|
-
signal,
|
4552
|
-
url
|
4887
|
+
if (signal.aborted) {
|
4888
|
+
return Promise.reject(signal.reason);
|
4889
|
+
}
|
4890
|
+
let bufferDrainWatcher;
|
4891
|
+
let hasConnected = false;
|
4892
|
+
const listenerRemovers = /* @__PURE__ */ new Set();
|
4893
|
+
function cleanupListeners() {
|
4894
|
+
listenerRemovers.forEach((r) => {
|
4895
|
+
r();
|
4553
4896
|
});
|
4554
|
-
|
4555
|
-
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4897
|
+
listenerRemovers.clear();
|
4898
|
+
}
|
4899
|
+
function handleAbort() {
|
4900
|
+
cleanupListeners();
|
4901
|
+
if (!hasConnected) {
|
4902
|
+
rejectOpen(signal.reason);
|
4903
|
+
}
|
4904
|
+
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
|
4905
|
+
webSocket.close(NORMAL_CLOSURE_CODE);
|
4906
|
+
}
|
4907
|
+
}
|
4908
|
+
function handleClose(ev) {
|
4909
|
+
cleanupListeners();
|
4910
|
+
bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
|
4911
|
+
signal.removeEventListener("abort", handleAbort);
|
4912
|
+
webSocket.removeEventListener("close", handleClose);
|
4913
|
+
webSocket.removeEventListener("error", handleError);
|
4914
|
+
webSocket.removeEventListener("message", handleMessage);
|
4915
|
+
webSocket.removeEventListener("open", handleOpen);
|
4916
|
+
if (!signal.aborted && !(ev.wasClean && ev.code === NORMAL_CLOSURE_CODE)) {
|
4917
|
+
eventTarget.dispatchEvent(
|
4918
|
+
new CustomEvent("error", {
|
4919
|
+
detail: new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED, {
|
4920
|
+
cause: ev
|
4921
|
+
})
|
4922
|
+
})
|
4923
|
+
);
|
4578
4924
|
}
|
4579
|
-
} else {
|
4580
|
-
argumentLabel = `\`${keyPath[0].toString()}\``;
|
4581
|
-
}
|
4582
|
-
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
|
4583
|
-
const error = new SolanaError(SOLANA_ERROR__RPC__INTEGER_OVERFLOW, {
|
4584
|
-
argumentLabel,
|
4585
|
-
keyPath,
|
4586
|
-
methodName,
|
4587
|
-
optionalPathLabel: path ? ` at path \`${path}\`` : "",
|
4588
|
-
value,
|
4589
|
-
...path !== void 0 ? { path } : void 0
|
4590
|
-
});
|
4591
|
-
safeCaptureStackTrace(error, createSolanaJsonRpcIntegerOverflowError2);
|
4592
|
-
return error;
|
4593
|
-
}
|
4594
|
-
var DEFAULT_RPC_SUBSCRIPTIONS_CONFIG = {
|
4595
|
-
defaultCommitment: "confirmed",
|
4596
|
-
onIntegerOverflow(methodName, keyPath, value) {
|
4597
|
-
throw createSolanaJsonRpcIntegerOverflowError2(methodName, keyPath, value);
|
4598
4925
|
}
|
4599
|
-
|
4600
|
-
|
4601
|
-
|
4602
|
-
try {
|
4603
|
-
for await (const _ of iterable) ;
|
4604
|
-
} catch {
|
4605
|
-
} finally {
|
4606
|
-
cleanupFn();
|
4926
|
+
function handleError(ev) {
|
4927
|
+
if (signal.aborted) {
|
4928
|
+
return;
|
4607
4929
|
}
|
4608
|
-
|
4609
|
-
|
4610
|
-
|
4611
|
-
getAbortSignalFromInputArgs,
|
4612
|
-
getCacheKeyFromInputArgs,
|
4613
|
-
onCacheHit,
|
4614
|
-
onCreateIterable
|
4615
|
-
}) {
|
4616
|
-
const cache = /* @__PURE__ */ new Map();
|
4617
|
-
function getCacheEntryOrThrow(cacheKey) {
|
4618
|
-
const currentCacheEntry = cache.get(cacheKey);
|
4619
|
-
if (!currentCacheEntry) {
|
4620
|
-
throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING, {
|
4621
|
-
cacheKey: cacheKey.toString()
|
4930
|
+
if (!hasConnected) {
|
4931
|
+
const failedToConnectError = new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT, {
|
4932
|
+
errorEvent: ev
|
4622
4933
|
});
|
4934
|
+
rejectOpen(failedToConnectError);
|
4935
|
+
eventTarget.dispatchEvent(
|
4936
|
+
new CustomEvent("error", {
|
4937
|
+
detail: failedToConnectError
|
4938
|
+
})
|
4939
|
+
);
|
4623
4940
|
}
|
4624
|
-
return currentCacheEntry;
|
4625
4941
|
}
|
4626
|
-
|
4627
|
-
|
4628
|
-
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4633
|
-
|
4634
|
-
|
4635
|
-
|
4636
|
-
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
4641
|
-
cacheEntry.purgeScheduled = false;
|
4642
|
-
if (cacheEntry.referenceCount === 0) {
|
4643
|
-
cacheEntry.abortController.abort();
|
4644
|
-
cleanup();
|
4645
|
-
}
|
4646
|
-
});
|
4647
|
-
}
|
4648
|
-
cacheEntry.referenceCount--;
|
4649
|
-
};
|
4650
|
-
signal.addEventListener("abort", handleAbort);
|
4651
|
-
try {
|
4652
|
-
const cacheEntry = cache.get(cacheKey);
|
4653
|
-
if (!cacheEntry) {
|
4654
|
-
const singletonAbortController = new AbortController();
|
4655
|
-
const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
|
4656
|
-
const newCacheEntry = {
|
4657
|
-
abortController: singletonAbortController,
|
4658
|
-
iterable: newIterablePromise,
|
4659
|
-
purgeScheduled: false,
|
4660
|
-
referenceCount: 1
|
4661
|
-
};
|
4662
|
-
cache.set(cacheKey, newCacheEntry);
|
4663
|
-
const newIterable = await newIterablePromise;
|
4664
|
-
registerIterableCleanup2(newIterable, cleanup);
|
4665
|
-
newCacheEntry.iterable = newIterable;
|
4666
|
-
return newIterable;
|
4667
|
-
} else {
|
4668
|
-
cacheEntry.referenceCount++;
|
4669
|
-
const iterableOrIterablePromise = cacheEntry.iterable;
|
4670
|
-
const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
|
4671
|
-
await onCacheHit(cachedIterable, ...args);
|
4672
|
-
return cachedIterable;
|
4673
|
-
}
|
4674
|
-
} catch (e3) {
|
4675
|
-
cleanup();
|
4676
|
-
throw e3;
|
4677
|
-
}
|
4678
|
-
};
|
4679
|
-
}
|
4680
|
-
var EXPLICIT_ABORT_TOKEN3;
|
4681
|
-
function createExplicitAbortToken3() {
|
4682
|
-
return Symbol(
|
4683
|
-
"This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
|
4684
|
-
);
|
4685
|
-
}
|
4686
|
-
function registerIterableCleanup22(iterable, cleanupFn) {
|
4687
|
-
(async () => {
|
4688
|
-
try {
|
4689
|
-
for await (const _ of iterable) ;
|
4690
|
-
} catch {
|
4691
|
-
} finally {
|
4692
|
-
cleanupFn();
|
4693
|
-
}
|
4694
|
-
})();
|
4695
|
-
}
|
4696
|
-
function getRpcSubscriptionsWithSubscriptionCoalescing({
|
4697
|
-
getDeduplicationKey,
|
4698
|
-
rpcSubscriptions
|
4699
|
-
}) {
|
4700
|
-
const cache = /* @__PURE__ */ new Map();
|
4701
|
-
return new Proxy(rpcSubscriptions, {
|
4702
|
-
defineProperty() {
|
4703
|
-
return false;
|
4704
|
-
},
|
4705
|
-
deleteProperty() {
|
4706
|
-
return false;
|
4707
|
-
},
|
4708
|
-
get(target, p, receiver) {
|
4709
|
-
const subscriptionMethod = Reflect.get(target, p, receiver);
|
4710
|
-
if (typeof subscriptionMethod !== "function") {
|
4711
|
-
return subscriptionMethod;
|
4712
|
-
}
|
4713
|
-
return function(...rawParams) {
|
4714
|
-
const deduplicationKey = getDeduplicationKey(p, rawParams);
|
4715
|
-
if (deduplicationKey === void 0) {
|
4716
|
-
return subscriptionMethod(...rawParams);
|
4717
|
-
}
|
4718
|
-
if (cache.has(deduplicationKey)) {
|
4719
|
-
return cache.get(deduplicationKey);
|
4942
|
+
function handleMessage(ev) {
|
4943
|
+
if (signal.aborted) {
|
4944
|
+
return;
|
4945
|
+
}
|
4946
|
+
eventTarget.dispatchEvent(new CustomEvent("message", { detail: ev.data }));
|
4947
|
+
}
|
4948
|
+
const eventTarget = new EventTarget();
|
4949
|
+
const dataPublisher = getDataPublisherFromEventEmitter(eventTarget);
|
4950
|
+
function handleOpen() {
|
4951
|
+
hasConnected = true;
|
4952
|
+
resolveOpen({
|
4953
|
+
...dataPublisher,
|
4954
|
+
async send(message) {
|
4955
|
+
if (webSocket.readyState !== e2.OPEN) {
|
4956
|
+
throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED);
|
4720
4957
|
}
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
);
|
4730
|
-
const iterable = await pendingSubscription2.subscribe({
|
4731
|
-
...config,
|
4732
|
-
abortSignal
|
4733
|
-
});
|
4734
|
-
registerIterableCleanup22(iterable, () => {
|
4735
|
-
cache.delete(deduplicationKey);
|
4736
|
-
});
|
4737
|
-
return iterable;
|
4738
|
-
}
|
4739
|
-
});
|
4740
|
-
const pendingSubscription = {
|
4741
|
-
async subscribe(...args) {
|
4742
|
-
const iterable = await iterableFactory(...args);
|
4743
|
-
const { abortSignal } = args[0];
|
4744
|
-
let abortPromise;
|
4745
|
-
return {
|
4746
|
-
...iterable,
|
4747
|
-
async *[Symbol.asyncIterator]() {
|
4748
|
-
abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN3 || (EXPLICIT_ABORT_TOKEN3 = createExplicitAbortToken3())) : new Promise((_, reject) => {
|
4749
|
-
abortSignal.addEventListener("abort", () => {
|
4750
|
-
reject(EXPLICIT_ABORT_TOKEN3 || (EXPLICIT_ABORT_TOKEN3 = createExplicitAbortToken3()));
|
4751
|
-
});
|
4752
|
-
}));
|
4753
|
-
try {
|
4754
|
-
const iterator = iterable[Symbol.asyncIterator]();
|
4755
|
-
while (true) {
|
4756
|
-
const iteratorResult = await safeRace([iterator.next(), abortPromise]);
|
4757
|
-
if (iteratorResult.done) {
|
4758
|
-
return;
|
4759
|
-
} else {
|
4760
|
-
yield iteratorResult.value;
|
4761
|
-
}
|
4762
|
-
}
|
4763
|
-
} catch (e3) {
|
4764
|
-
if (e3 === (EXPLICIT_ABORT_TOKEN3 || (EXPLICIT_ABORT_TOKEN3 = createExplicitAbortToken3()))) {
|
4765
|
-
return;
|
4766
|
-
}
|
4767
|
-
cache.delete(deduplicationKey);
|
4768
|
-
throw e3;
|
4769
|
-
}
|
4958
|
+
if (!bufferDrainWatcher && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
4959
|
+
let onCancel;
|
4960
|
+
const promise = new Promise((resolve, reject) => {
|
4961
|
+
const intervalId = setInterval(() => {
|
4962
|
+
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
4963
|
+
clearInterval(intervalId);
|
4964
|
+
bufferDrainWatcher = void 0;
|
4965
|
+
resolve();
|
4770
4966
|
}
|
4967
|
+
}, 16);
|
4968
|
+
onCancel = () => {
|
4969
|
+
bufferDrainWatcher = void 0;
|
4970
|
+
clearInterval(intervalId);
|
4971
|
+
reject(
|
4972
|
+
new SolanaError(
|
4973
|
+
SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED
|
4974
|
+
)
|
4975
|
+
);
|
4771
4976
|
};
|
4977
|
+
});
|
4978
|
+
bufferDrainWatcher = {
|
4979
|
+
onCancel,
|
4980
|
+
promise
|
4981
|
+
};
|
4982
|
+
}
|
4983
|
+
if (bufferDrainWatcher) {
|
4984
|
+
if (ArrayBuffer.isView(message) && !(message instanceof DataView)) {
|
4985
|
+
const TypedArrayConstructor = message.constructor;
|
4986
|
+
message = new TypedArrayConstructor(message);
|
4772
4987
|
}
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
}
|
4988
|
+
await bufferDrainWatcher.promise;
|
4989
|
+
}
|
4990
|
+
webSocket.send(message);
|
4991
|
+
}
|
4992
|
+
});
|
4993
|
+
}
|
4994
|
+
const webSocket = new e2(url);
|
4995
|
+
signal.addEventListener("abort", handleAbort);
|
4996
|
+
webSocket.addEventListener("close", handleClose);
|
4997
|
+
webSocket.addEventListener("error", handleError);
|
4998
|
+
webSocket.addEventListener("message", handleMessage);
|
4999
|
+
webSocket.addEventListener("open", handleOpen);
|
5000
|
+
let rejectOpen;
|
5001
|
+
let resolveOpen;
|
5002
|
+
return new Promise((resolve, reject) => {
|
5003
|
+
rejectOpen = reject;
|
5004
|
+
resolveOpen = resolve;
|
5005
|
+
});
|
5006
|
+
}
|
5007
|
+
|
5008
|
+
// ../rpc-subscriptions/dist/index.browser.mjs
|
5009
|
+
function createSolanaJsonRpcIntegerOverflowError2(methodName, keyPath, value) {
|
5010
|
+
let argumentLabel = "";
|
5011
|
+
if (typeof keyPath[0] === "number") {
|
5012
|
+
const argPosition = keyPath[0] + 1;
|
5013
|
+
const lastDigit = argPosition % 10;
|
5014
|
+
const lastTwoDigits = argPosition % 100;
|
5015
|
+
if (lastDigit == 1 && lastTwoDigits != 11) {
|
5016
|
+
argumentLabel = argPosition + "st";
|
5017
|
+
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
5018
|
+
argumentLabel = argPosition + "nd";
|
5019
|
+
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
5020
|
+
argumentLabel = argPosition + "rd";
|
5021
|
+
} else {
|
5022
|
+
argumentLabel = argPosition + "th";
|
4777
5023
|
}
|
5024
|
+
} else {
|
5025
|
+
argumentLabel = `\`${keyPath[0].toString()}\``;
|
5026
|
+
}
|
5027
|
+
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
|
5028
|
+
const error = new SolanaError(SOLANA_ERROR__RPC__INTEGER_OVERFLOW, {
|
5029
|
+
argumentLabel,
|
5030
|
+
keyPath,
|
5031
|
+
methodName,
|
5032
|
+
optionalPathLabel: path ? ` at path \`${path}\`` : "",
|
5033
|
+
value,
|
5034
|
+
...path !== void 0 ? { path } : void 0
|
4778
5035
|
});
|
5036
|
+
safeCaptureStackTrace(error, createSolanaJsonRpcIntegerOverflowError2);
|
5037
|
+
return error;
|
4779
5038
|
}
|
5039
|
+
var DEFAULT_RPC_SUBSCRIPTIONS_CONFIG = {
|
5040
|
+
defaultCommitment: "confirmed",
|
5041
|
+
onIntegerOverflow(request, keyPath, value) {
|
5042
|
+
throw createSolanaJsonRpcIntegerOverflowError2(request.methodName, keyPath, value);
|
5043
|
+
}
|
5044
|
+
};
|
4780
5045
|
var PING_PAYLOAD = {
|
4781
5046
|
jsonrpc: "2.0",
|
4782
5047
|
method: "ping"
|
4783
5048
|
};
|
4784
|
-
function
|
4785
|
-
|
4786
|
-
|
5049
|
+
function getRpcSubscriptionsChannelWithAutoping({
|
5050
|
+
abortSignal: callerAbortSignal,
|
5051
|
+
channel,
|
5052
|
+
intervalMs
|
4787
5053
|
}) {
|
4788
|
-
|
4789
|
-
|
4790
|
-
|
4791
|
-
|
4792
|
-
|
4793
|
-
|
4794
|
-
}
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
|
4815
|
-
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4819
|
-
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
}
|
4824
|
-
|
5054
|
+
let intervalId;
|
5055
|
+
function sendPing() {
|
5056
|
+
channel.send(PING_PAYLOAD).catch((e3) => {
|
5057
|
+
if (isSolanaError(e3, SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED)) {
|
5058
|
+
pingerAbortController.abort();
|
5059
|
+
}
|
5060
|
+
});
|
5061
|
+
}
|
5062
|
+
function restartPingTimer() {
|
5063
|
+
clearInterval(intervalId);
|
5064
|
+
intervalId = setInterval(sendPing, intervalMs);
|
5065
|
+
}
|
5066
|
+
const pingerAbortController = new AbortController();
|
5067
|
+
pingerAbortController.signal.addEventListener("abort", () => {
|
5068
|
+
clearInterval(intervalId);
|
5069
|
+
});
|
5070
|
+
callerAbortSignal.addEventListener("abort", () => {
|
5071
|
+
pingerAbortController.abort();
|
5072
|
+
});
|
5073
|
+
channel.on(
|
5074
|
+
"error",
|
5075
|
+
() => {
|
5076
|
+
pingerAbortController.abort();
|
5077
|
+
},
|
5078
|
+
{ signal: pingerAbortController.signal }
|
5079
|
+
);
|
5080
|
+
channel.on("message", restartPingTimer, { signal: pingerAbortController.signal });
|
5081
|
+
if (globalThis.navigator.onLine) {
|
5082
|
+
restartPingTimer();
|
5083
|
+
}
|
5084
|
+
{
|
5085
|
+
globalThis.window.addEventListener(
|
5086
|
+
"offline",
|
5087
|
+
function handleOffline() {
|
5088
|
+
clearInterval(intervalId);
|
5089
|
+
},
|
5090
|
+
{ signal: pingerAbortController.signal }
|
5091
|
+
);
|
5092
|
+
globalThis.window.addEventListener(
|
5093
|
+
"online",
|
5094
|
+
function handleOnline() {
|
5095
|
+
sendPing();
|
5096
|
+
restartPingTimer();
|
5097
|
+
},
|
5098
|
+
{ signal: pingerAbortController.signal }
|
5099
|
+
);
|
5100
|
+
}
|
5101
|
+
return {
|
5102
|
+
...channel,
|
5103
|
+
send(...args) {
|
5104
|
+
if (!pingerAbortController.signal.aborted) {
|
4825
5105
|
restartPingTimer();
|
4826
5106
|
}
|
4827
|
-
|
4828
|
-
|
4829
|
-
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
5107
|
+
return channel.send(...args);
|
5108
|
+
}
|
5109
|
+
};
|
5110
|
+
}
|
5111
|
+
function createChannelPool() {
|
5112
|
+
return {
|
5113
|
+
entries: [],
|
5114
|
+
freeChannelIndex: -1
|
5115
|
+
};
|
5116
|
+
}
|
5117
|
+
function getChannelPoolingChannelCreator(createChannel, { maxSubscriptionsPerChannel, minChannels }) {
|
5118
|
+
const pool = createChannelPool();
|
5119
|
+
function recomputeFreeChannelIndex() {
|
5120
|
+
var _a;
|
5121
|
+
if (pool.entries.length < minChannels) {
|
5122
|
+
pool.freeChannelIndex = -1;
|
5123
|
+
return;
|
5124
|
+
}
|
5125
|
+
let mostFreeChannel;
|
5126
|
+
for (let ii = 0; ii < pool.entries.length; ii++) {
|
5127
|
+
const nextPoolIndex = (pool.freeChannelIndex + ii + 2) % pool.entries.length;
|
5128
|
+
const nextPoolEntry = (
|
5129
|
+
// Start from the item two positions after the current item. This way, the
|
5130
|
+
// search will finish on the item after the current one. This ensures that, if
|
5131
|
+
// any channels tie for having the most capacity, the one that will be chosen is
|
5132
|
+
// the one immediately to the current one's right (wrapping around).
|
5133
|
+
pool.entries[nextPoolIndex]
|
5134
|
+
);
|
5135
|
+
if (nextPoolEntry.subscriptionCount < maxSubscriptionsPerChannel && (!mostFreeChannel || mostFreeChannel.subscriptionCount >= nextPoolEntry.subscriptionCount)) {
|
5136
|
+
mostFreeChannel = {
|
5137
|
+
poolIndex: nextPoolIndex,
|
5138
|
+
subscriptionCount: nextPoolEntry.subscriptionCount
|
4836
5139
|
};
|
4837
|
-
globalThis.window.addEventListener("offline", handleOffline);
|
4838
|
-
globalThis.window.addEventListener("online", handleOnline);
|
4839
5140
|
}
|
4840
5141
|
}
|
4841
|
-
|
5142
|
+
pool.freeChannelIndex = (_a = mostFreeChannel == null ? void 0 : mostFreeChannel.poolIndex) != null ? _a : -1;
|
5143
|
+
}
|
5144
|
+
return function getExistingChannelWithMostCapacityOrCreateChannel({ abortSignal }) {
|
5145
|
+
let poolEntry;
|
5146
|
+
function destroyPoolEntry() {
|
5147
|
+
const index = pool.entries.findIndex((entry) => entry === poolEntry);
|
5148
|
+
pool.entries.splice(index, 1);
|
5149
|
+
poolEntry.dispose();
|
5150
|
+
recomputeFreeChannelIndex();
|
5151
|
+
}
|
5152
|
+
if (pool.freeChannelIndex === -1) {
|
5153
|
+
const abortController = new AbortController();
|
5154
|
+
const newChannelPromise = createChannel({ abortSignal: abortController.signal });
|
5155
|
+
newChannelPromise.then((newChannel) => {
|
5156
|
+
newChannel.on("error", destroyPoolEntry, { signal: abortController.signal });
|
5157
|
+
}).catch(destroyPoolEntry);
|
5158
|
+
poolEntry = {
|
5159
|
+
channel: newChannelPromise,
|
5160
|
+
dispose() {
|
5161
|
+
abortController.abort();
|
5162
|
+
},
|
5163
|
+
subscriptionCount: 0
|
5164
|
+
};
|
5165
|
+
pool.entries.push(poolEntry);
|
5166
|
+
} else {
|
5167
|
+
poolEntry = pool.entries[pool.freeChannelIndex];
|
5168
|
+
}
|
5169
|
+
poolEntry.subscriptionCount++;
|
5170
|
+
abortSignal.addEventListener("abort", function destroyConsumer() {
|
5171
|
+
poolEntry.subscriptionCount--;
|
5172
|
+
if (poolEntry.subscriptionCount === 0) {
|
5173
|
+
destroyPoolEntry();
|
5174
|
+
} else if (pool.freeChannelIndex !== -1) {
|
5175
|
+
pool.freeChannelIndex--;
|
5176
|
+
recomputeFreeChannelIndex();
|
5177
|
+
}
|
5178
|
+
});
|
5179
|
+
recomputeFreeChannelIndex();
|
5180
|
+
return poolEntry.channel;
|
4842
5181
|
};
|
4843
5182
|
}
|
4844
|
-
|
4845
|
-
|
4846
|
-
|
5183
|
+
function getRpcSubscriptionsChannelWithJSONSerialization(channel) {
|
5184
|
+
return pipe(
|
5185
|
+
channel,
|
5186
|
+
(c) => transformChannelInboundMessages(c, JSON.parse),
|
5187
|
+
(c) => transformChannelOutboundMessages(c, JSON.stringify)
|
5188
|
+
);
|
4847
5189
|
}
|
4848
|
-
function
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
})
|
5190
|
+
function getRpcSubscriptionsChannelWithBigIntJSONSerialization(channel) {
|
5191
|
+
return pipe(
|
5192
|
+
channel,
|
5193
|
+
(c) => transformChannelInboundMessages(c, parseJsonWithBigInts),
|
5194
|
+
(c) => transformChannelOutboundMessages(c, stringifyJsonWithBigints)
|
5195
|
+
);
|
5196
|
+
}
|
5197
|
+
function createDefaultSolanaRpcSubscriptionsChannelCreator(config) {
|
5198
|
+
return createDefaultRpcSubscriptionsChannelCreatorImpl({
|
5199
|
+
...config,
|
5200
|
+
jsonSerializer: getRpcSubscriptionsChannelWithBigIntJSONSerialization
|
4860
5201
|
});
|
4861
5202
|
}
|
4862
|
-
function
|
4863
|
-
|
4864
|
-
|
4865
|
-
|
4866
|
-
|
5203
|
+
function createDefaultRpcSubscriptionsChannelCreator(config) {
|
5204
|
+
return createDefaultRpcSubscriptionsChannelCreatorImpl({
|
5205
|
+
...config,
|
5206
|
+
jsonSerializer: getRpcSubscriptionsChannelWithJSONSerialization
|
5207
|
+
});
|
5208
|
+
}
|
5209
|
+
function createDefaultRpcSubscriptionsChannelCreatorImpl(config) {
|
5210
|
+
var _a, _b;
|
5211
|
+
if (/^wss?:/i.test(config.url) === false) {
|
5212
|
+
const protocolMatch = config.url.match(/^([^:]+):/);
|
5213
|
+
throw new DOMException(
|
5214
|
+
protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${config.url}' is invalid.`
|
5215
|
+
);
|
5216
|
+
}
|
5217
|
+
const { intervalMs, ...rest } = config;
|
5218
|
+
const createDefaultRpcSubscriptionsChannel = ({ abortSignal }) => {
|
5219
|
+
var _a2;
|
5220
|
+
return createWebSocketChannel({
|
4867
5221
|
...rest,
|
4868
|
-
sendBufferHighWatermark: (
|
5222
|
+
sendBufferHighWatermark: (_a2 = config.sendBufferHighWatermark) != null ? _a2 : (
|
4869
5223
|
// Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
4870
5224
|
131072
|
4871
|
-
)
|
4872
|
-
|
4873
|
-
(
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
4880
|
-
|
5225
|
+
),
|
5226
|
+
signal: abortSignal
|
5227
|
+
}).then(config.jsonSerializer).then(
|
5228
|
+
(channel) => getRpcSubscriptionsChannelWithAutoping({
|
5229
|
+
abortSignal,
|
5230
|
+
channel,
|
5231
|
+
intervalMs: intervalMs != null ? intervalMs : 5e3
|
5232
|
+
})
|
5233
|
+
);
|
5234
|
+
};
|
5235
|
+
return getChannelPoolingChannelCreator(createDefaultRpcSubscriptionsChannel, {
|
5236
|
+
maxSubscriptionsPerChannel: (_a = config.maxSubscriptionsPerChannel) != null ? _a : (
|
5237
|
+
/**
|
5238
|
+
* A note about this default. The idea here is that, because some RPC providers impose
|
5239
|
+
* an upper limit on the number of subscriptions you can make per channel, we must
|
5240
|
+
* choose a number low enough to avoid hitting that limit. Without knowing what provider
|
5241
|
+
* a given person is using, or what their limit is, we have to choose the lowest of all
|
5242
|
+
* known limits. As of this writing (October 2024) that is the public mainnet RPC node
|
5243
|
+
* (api.mainnet-beta.solana.com) at 100 subscriptions.
|
5244
|
+
*/
|
5245
|
+
100
|
5246
|
+
),
|
5247
|
+
minChannels: (_b = config.minChannels) != null ? _b : 1
|
5248
|
+
});
|
5249
|
+
}
|
5250
|
+
function getRpcSubscriptionsTransportWithSubscriptionCoalescing(transport) {
|
5251
|
+
const cache2 = /* @__PURE__ */ new Map();
|
5252
|
+
return function rpcSubscriptionsTransportWithSubscriptionCoalescing(config) {
|
5253
|
+
const { request, signal } = config;
|
5254
|
+
const subscriptionConfigurationHash = src_default([request.methodName, request.params]);
|
5255
|
+
let cachedDataPublisherPromise = cache2.get(subscriptionConfigurationHash);
|
5256
|
+
if (!cachedDataPublisherPromise) {
|
5257
|
+
const abortController = new AbortController();
|
5258
|
+
const dataPublisherPromise = transport({
|
5259
|
+
...config,
|
5260
|
+
signal: abortController.signal
|
5261
|
+
});
|
5262
|
+
dataPublisherPromise.then((dataPublisher) => {
|
5263
|
+
dataPublisher.on(
|
5264
|
+
"error",
|
5265
|
+
() => {
|
5266
|
+
cache2.delete(subscriptionConfigurationHash);
|
5267
|
+
abortController.abort();
|
5268
|
+
},
|
5269
|
+
{ signal: abortController.signal }
|
5270
|
+
);
|
5271
|
+
}).catch(() => {
|
5272
|
+
});
|
5273
|
+
cache2.set(
|
5274
|
+
subscriptionConfigurationHash,
|
5275
|
+
cachedDataPublisherPromise = {
|
5276
|
+
abortController,
|
5277
|
+
dataPublisherPromise,
|
5278
|
+
numSubscribers: 0
|
5279
|
+
}
|
5280
|
+
);
|
5281
|
+
}
|
5282
|
+
cachedDataPublisherPromise.numSubscribers++;
|
5283
|
+
signal.addEventListener(
|
5284
|
+
"abort",
|
5285
|
+
() => {
|
5286
|
+
cachedDataPublisherPromise.numSubscribers--;
|
5287
|
+
if (cachedDataPublisherPromise.numSubscribers === 0) {
|
5288
|
+
queueMicrotask(() => {
|
5289
|
+
if (cachedDataPublisherPromise.numSubscribers === 0) {
|
5290
|
+
cache2.delete(subscriptionConfigurationHash);
|
5291
|
+
cachedDataPublisherPromise.abortController.abort();
|
5292
|
+
}
|
5293
|
+
});
|
5294
|
+
}
|
5295
|
+
},
|
5296
|
+
{ signal: cachedDataPublisherPromise.abortController.signal }
|
5297
|
+
);
|
5298
|
+
return cachedDataPublisherPromise.dataPublisherPromise;
|
5299
|
+
};
|
5300
|
+
}
|
5301
|
+
function createDefaultRpcSubscriptionsTransport({
|
5302
|
+
createChannel
|
5303
|
+
}) {
|
5304
|
+
return pipe(
|
5305
|
+
createRpcSubscriptionsTransportFromChannelCreator(
|
5306
|
+
createChannel
|
5307
|
+
),
|
5308
|
+
(transport) => getRpcSubscriptionsTransportWithSubscriptionCoalescing(transport)
|
4881
5309
|
);
|
4882
5310
|
}
|
4883
|
-
function
|
4884
|
-
|
5311
|
+
function createRpcSubscriptionsTransportFromChannelCreator(createChannel) {
|
5312
|
+
return async ({ execute, signal }) => {
|
5313
|
+
const channel = await createChannel({ abortSignal: signal });
|
5314
|
+
return await execute({ channel, signal });
|
5315
|
+
};
|
5316
|
+
}
|
5317
|
+
function createSolanaRpcSubscriptionsImpl(clusterUrl, config) {
|
5318
|
+
const transport = createDefaultRpcSubscriptionsTransport({
|
5319
|
+
createChannel: createDefaultSolanaRpcSubscriptionsChannelCreator({ ...config, url: clusterUrl })
|
5320
|
+
});
|
4885
5321
|
return createSolanaRpcSubscriptionsFromTransport(transport);
|
4886
5322
|
}
|
5323
|
+
function createSolanaRpcSubscriptions(clusterUrl, config) {
|
5324
|
+
return createSolanaRpcSubscriptionsImpl(clusterUrl, config);
|
5325
|
+
}
|
4887
5326
|
function createSolanaRpcSubscriptions_UNSTABLE(clusterUrl, config) {
|
4888
|
-
return
|
5327
|
+
return createSolanaRpcSubscriptionsImpl(
|
4889
5328
|
clusterUrl,
|
4890
5329
|
config
|
4891
5330
|
);
|
4892
5331
|
}
|
4893
5332
|
function createSolanaRpcSubscriptionsFromTransport(transport) {
|
4894
|
-
return
|
4895
|
-
|
4896
|
-
|
4897
|
-
|
4898
|
-
}),
|
4899
|
-
(rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
|
4900
|
-
getDeduplicationKey: (...args) => src_default(args),
|
4901
|
-
rpcSubscriptions
|
4902
|
-
})
|
4903
|
-
);
|
4904
|
-
}
|
4905
|
-
function createSolanaRpcSubscriptionsFromTransport_UNSTABLE(transport) {
|
4906
|
-
return createSolanaRpcSubscriptionsFromTransport(transport);
|
5333
|
+
return createSubscriptionRpc({
|
5334
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_SUBSCRIPTIONS_CONFIG),
|
5335
|
+
transport
|
5336
|
+
});
|
4907
5337
|
}
|
4908
5338
|
|
4909
5339
|
// ../rpc-types/dist/index.browser.mjs
|
@@ -5055,7 +5485,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
5055
5485
|
try {
|
5056
5486
|
BigInt(putativeBigInt);
|
5057
5487
|
return true;
|
5058
|
-
} catch
|
5488
|
+
} catch {
|
5059
5489
|
return false;
|
5060
5490
|
}
|
5061
5491
|
}
|
@@ -5086,14 +5516,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
5086
5516
|
assertIsStringifiedNumber(putativeNumber);
|
5087
5517
|
return putativeNumber;
|
5088
5518
|
}
|
5519
|
+
var maxI64Value = 9223372036854775807n;
|
5520
|
+
var minI64Value = -9223372036854775808n;
|
5089
5521
|
function isUnixTimestamp(putativeTimestamp) {
|
5090
|
-
|
5091
|
-
return false;
|
5092
|
-
}
|
5093
|
-
return true;
|
5522
|
+
return putativeTimestamp >= minI64Value && putativeTimestamp <= maxI64Value;
|
5094
5523
|
}
|
5095
5524
|
function assertIsUnixTimestamp(putativeTimestamp) {
|
5096
|
-
if (putativeTimestamp
|
5525
|
+
if (putativeTimestamp < minI64Value || putativeTimestamp > maxI64Value) {
|
5097
5526
|
throw new SolanaError(SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE, {
|
5098
5527
|
value: putativeTimestamp
|
5099
5528
|
});
|
@@ -5678,7 +6107,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
5678
6107
|
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
5679
6108
|
}
|
5680
6109
|
function compileTransactionMessage(transaction) {
|
5681
|
-
const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
|
6110
|
+
const addressMap = getAddressMapFromInstructions(transaction.feePayer.address, transaction.instructions);
|
5682
6111
|
const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
|
5683
6112
|
return {
|
5684
6113
|
...transaction.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
|
@@ -5817,17 +6246,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
5817
6246
|
})
|
5818
6247
|
});
|
5819
6248
|
}
|
5820
|
-
function setTransactionMessageFeePayer(feePayer,
|
5821
|
-
|
5822
|
-
|
6249
|
+
function setTransactionMessageFeePayer(feePayer, transactionMessage) {
|
6250
|
+
var _a;
|
6251
|
+
if ("feePayer" in transactionMessage && feePayer === ((_a = transactionMessage.feePayer) == null ? void 0 : _a.address) && isAddressOnlyFeePayer(transactionMessage.feePayer)) {
|
6252
|
+
return transactionMessage;
|
5823
6253
|
}
|
5824
6254
|
const out = {
|
5825
|
-
...
|
5826
|
-
feePayer
|
6255
|
+
...transactionMessage,
|
6256
|
+
feePayer: Object.freeze({ address: feePayer })
|
5827
6257
|
};
|
5828
6258
|
Object.freeze(out);
|
5829
6259
|
return out;
|
5830
6260
|
}
|
6261
|
+
function isAddressOnlyFeePayer(feePayer) {
|
6262
|
+
return !!feePayer && "address" in feePayer && typeof feePayer.address === "string" && Object.keys(feePayer).length === 1;
|
6263
|
+
}
|
5831
6264
|
function appendTransactionMessageInstruction(instruction, transaction) {
|
5832
6265
|
return appendTransactionMessageInstructions([instruction], transaction);
|
5833
6266
|
}
|
@@ -6061,9 +6494,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6061
6494
|
}
|
6062
6495
|
function compileTransaction(transactionMessage) {
|
6063
6496
|
const compiledMessage = compileTransactionMessage(transactionMessage);
|
6064
|
-
const messageBytes = getCompiledTransactionMessageEncoder().encode(
|
6065
|
-
compiledMessage
|
6066
|
-
);
|
6497
|
+
const messageBytes = getCompiledTransactionMessageEncoder().encode(compiledMessage);
|
6067
6498
|
const transactionSigners = compiledMessage.staticAccounts.slice(0, compiledMessage.header.numSignerAccounts);
|
6068
6499
|
const signatures = {};
|
6069
6500
|
for (const signerAddress of transactionSigners) {
|
@@ -6180,6 +6611,46 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6180
6611
|
});
|
6181
6612
|
return Object.values(deduplicated);
|
6182
6613
|
}
|
6614
|
+
function isTransactionModifyingSigner(value) {
|
6615
|
+
return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";
|
6616
|
+
}
|
6617
|
+
function assertIsTransactionModifyingSigner(value) {
|
6618
|
+
if (!isTransactionModifyingSigner(value)) {
|
6619
|
+
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
|
6620
|
+
address: value.address
|
6621
|
+
});
|
6622
|
+
}
|
6623
|
+
}
|
6624
|
+
function isTransactionPartialSigner(value) {
|
6625
|
+
return "signTransactions" in value && typeof value.signTransactions === "function";
|
6626
|
+
}
|
6627
|
+
function assertIsTransactionPartialSigner(value) {
|
6628
|
+
if (!isTransactionPartialSigner(value)) {
|
6629
|
+
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
|
6630
|
+
address: value.address
|
6631
|
+
});
|
6632
|
+
}
|
6633
|
+
}
|
6634
|
+
function isTransactionSendingSigner(value) {
|
6635
|
+
return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";
|
6636
|
+
}
|
6637
|
+
function assertIsTransactionSendingSigner(value) {
|
6638
|
+
if (!isTransactionSendingSigner(value)) {
|
6639
|
+
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
|
6640
|
+
address: value.address
|
6641
|
+
});
|
6642
|
+
}
|
6643
|
+
}
|
6644
|
+
function isTransactionSigner(value) {
|
6645
|
+
return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);
|
6646
|
+
}
|
6647
|
+
function assertIsTransactionSigner(value) {
|
6648
|
+
if (!isTransactionSigner(value)) {
|
6649
|
+
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
|
6650
|
+
address: value.address
|
6651
|
+
});
|
6652
|
+
}
|
6653
|
+
}
|
6183
6654
|
function getSignersFromInstruction(instruction) {
|
6184
6655
|
var _a;
|
6185
6656
|
return deduplicateSigners(
|
@@ -6188,7 +6659,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6188
6659
|
}
|
6189
6660
|
function getSignersFromTransactionMessage(transaction) {
|
6190
6661
|
return deduplicateSigners([
|
6191
|
-
...transaction.
|
6662
|
+
...transaction.feePayer && isTransactionSigner(transaction.feePayer) ? [transaction.feePayer] : [],
|
6192
6663
|
...transaction.instructions.flatMap(getSignersFromInstruction)
|
6193
6664
|
]);
|
6194
6665
|
}
|
@@ -6217,19 +6688,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6217
6688
|
instructions: transactionMessage.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
|
6218
6689
|
});
|
6219
6690
|
}
|
6220
|
-
function setTransactionMessageFeePayerSigner(
|
6221
|
-
|
6222
|
-
|
6223
|
-
return transactionMessage;
|
6224
|
-
const out2 = { ...transactionMessage, feePayerSigner };
|
6225
|
-
Object.freeze(out2);
|
6226
|
-
return out2;
|
6227
|
-
}
|
6228
|
-
const out = {
|
6229
|
-
...transactionMessage,
|
6230
|
-
feePayer: feePayerSigner.address,
|
6231
|
-
feePayerSigner
|
6232
|
-
};
|
6691
|
+
function setTransactionMessageFeePayerSigner(feePayer, transactionMessage) {
|
6692
|
+
Object.freeze(feePayer);
|
6693
|
+
const out = { ...transactionMessage, feePayer };
|
6233
6694
|
Object.freeze(out);
|
6234
6695
|
return out;
|
6235
6696
|
}
|
@@ -6243,16 +6704,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6243
6704
|
});
|
6244
6705
|
}
|
6245
6706
|
}
|
6246
|
-
function isTransactionPartialSigner(value) {
|
6247
|
-
return "signTransactions" in value && typeof value.signTransactions === "function";
|
6248
|
-
}
|
6249
|
-
function assertIsTransactionPartialSigner(value) {
|
6250
|
-
if (!isTransactionPartialSigner(value)) {
|
6251
|
-
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
|
6252
|
-
address: value.address
|
6253
|
-
});
|
6254
|
-
}
|
6255
|
-
}
|
6256
6707
|
function isKeyPairSigner(value) {
|
6257
6708
|
return "keyPair" in value && typeof value.keyPair === "object" && isMessagePartialSigner(value) && isTransactionPartialSigner(value);
|
6258
6709
|
}
|
@@ -6319,36 +6770,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6319
6770
|
};
|
6320
6771
|
return Object.freeze(out);
|
6321
6772
|
}
|
6322
|
-
function isTransactionModifyingSigner(value) {
|
6323
|
-
return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";
|
6324
|
-
}
|
6325
|
-
function assertIsTransactionModifyingSigner(value) {
|
6326
|
-
if (!isTransactionModifyingSigner(value)) {
|
6327
|
-
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
|
6328
|
-
address: value.address
|
6329
|
-
});
|
6330
|
-
}
|
6331
|
-
}
|
6332
|
-
function isTransactionSendingSigner(value) {
|
6333
|
-
return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";
|
6334
|
-
}
|
6335
|
-
function assertIsTransactionSendingSigner(value) {
|
6336
|
-
if (!isTransactionSendingSigner(value)) {
|
6337
|
-
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
|
6338
|
-
address: value.address
|
6339
|
-
});
|
6340
|
-
}
|
6341
|
-
}
|
6342
|
-
function isTransactionSigner(value) {
|
6343
|
-
return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);
|
6344
|
-
}
|
6345
|
-
function assertIsTransactionSigner(value) {
|
6346
|
-
if (!isTransactionSigner(value)) {
|
6347
|
-
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
|
6348
|
-
address: value.address
|
6349
|
-
});
|
6350
|
-
}
|
6351
|
-
}
|
6352
6773
|
function isTransactionMessageWithSingleSendingSigner(transaction) {
|
6353
6774
|
try {
|
6354
6775
|
assertIsTransactionMessageWithSingleSendingSigner(transaction);
|
@@ -6484,6 +6905,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6484
6905
|
commitment,
|
6485
6906
|
lastValidBlockHeight
|
6486
6907
|
}) {
|
6908
|
+
callerAbortSignal.throwIfAborted();
|
6487
6909
|
const abortController = new AbortController();
|
6488
6910
|
const handleAbort = () => {
|
6489
6911
|
abortController.abort();
|
@@ -6501,6 +6923,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6501
6923
|
rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal }),
|
6502
6924
|
getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight()
|
6503
6925
|
]);
|
6926
|
+
callerAbortSignal.throwIfAborted();
|
6504
6927
|
let currentBlockHeight = initialBlockHeight;
|
6505
6928
|
if (currentBlockHeight <= lastValidBlockHeight) {
|
6506
6929
|
let lastKnownDifferenceBetweenSlotHeightAndBlockHeight = differenceBetweenSlotHeightAndBlockHeight;
|
@@ -6520,6 +6943,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6520
6943
|
}
|
6521
6944
|
}
|
6522
6945
|
}
|
6946
|
+
callerAbortSignal.throwIfAborted();
|
6523
6947
|
throw new SolanaError(SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, {
|
6524
6948
|
currentBlockHeight,
|
6525
6949
|
lastValidBlockHeight
|
@@ -6845,7 +7269,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6845
7269
|
const wireTransactionBytes = getBase64EncodedWireTransaction(compiledTransaction);
|
6846
7270
|
try {
|
6847
7271
|
const {
|
6848
|
-
value: { unitsConsumed }
|
7272
|
+
value: { err: transactionError, unitsConsumed }
|
6849
7273
|
} = await rpc.simulateTransaction(wireTransactionBytes, {
|
6850
7274
|
...simulateConfig,
|
6851
7275
|
encoding: "base64",
|
@@ -6856,8 +7280,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6856
7280
|
throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);
|
6857
7281
|
}
|
6858
7282
|
const downcastUnitsConsumed = unitsConsumed > 4294967295n ? 4294967295 : Number(unitsConsumed);
|
7283
|
+
if (transactionError) {
|
7284
|
+
throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {
|
7285
|
+
cause: transactionError,
|
7286
|
+
unitsConsumed: downcastUnitsConsumed
|
7287
|
+
});
|
7288
|
+
}
|
6859
7289
|
return downcastUnitsConsumed;
|
6860
7290
|
} catch (e3) {
|
7291
|
+
if (isSolanaError(e3, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e3;
|
6861
7292
|
throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {
|
6862
7293
|
cause: e3
|
6863
7294
|
});
|
@@ -6877,7 +7308,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6877
7308
|
};
|
6878
7309
|
}
|
6879
7310
|
|
6880
|
-
// src/
|
7311
|
+
// src/decompile-transaction-message-fetching-lookup-tables.ts
|
6881
7312
|
async function fetchLookupTables(lookupTableAddresses, rpc, config) {
|
6882
7313
|
const fetchedLookupTables = await fetchJsonParsedAccounts(
|
6883
7314
|
rpc,
|
@@ -6893,7 +7324,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
6893
7324
|
};
|
6894
7325
|
}, {});
|
6895
7326
|
}
|
6896
|
-
async function
|
7327
|
+
async function decompileTransactionMessageFetchingLookupTables(compiledTransactionMessage, rpc, config) {
|
6897
7328
|
const lookupTables = "addressTableLookups" in compiledTransactionMessage && compiledTransactionMessage.addressTableLookups !== void 0 && compiledTransactionMessage.addressTableLookups.length > 0 ? compiledTransactionMessage.addressTableLookups : [];
|
6898
7329
|
const lookupTableAddresses = lookupTables.map((l) => l.lookupTableAddress);
|
6899
7330
|
const { lastValidBlockHeight, ...fetchAccountsConfig } = config != null ? config : {};
|
@@ -7162,9 +7593,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7162
7593
|
exports.SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH;
|
7163
7594
|
exports.SOLANA_ERROR__INVALID_NONCE = SOLANA_ERROR__INVALID_NONCE;
|
7164
7595
|
exports.SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING;
|
7596
|
+
exports.SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED;
|
7597
|
+
exports.SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE;
|
7598
|
+
exports.SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING;
|
7165
7599
|
exports.SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE;
|
7166
|
-
exports.SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE;
|
7167
|
-
exports.SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING = SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING;
|
7168
7600
|
exports.SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR = SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR;
|
7169
7601
|
exports.SOLANA_ERROR__JSON_RPC__INVALID_PARAMS = SOLANA_ERROR__JSON_RPC__INVALID_PARAMS;
|
7170
7602
|
exports.SOLANA_ERROR__JSON_RPC__INVALID_REQUEST = SOLANA_ERROR__JSON_RPC__INVALID_REQUEST;
|
@@ -7195,11 +7627,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7195
7627
|
exports.SOLANA_ERROR__MALFORMED_BIGINT_STRING = SOLANA_ERROR__MALFORMED_BIGINT_STRING;
|
7196
7628
|
exports.SOLANA_ERROR__MALFORMED_NUMBER_STRING = SOLANA_ERROR__MALFORMED_NUMBER_STRING;
|
7197
7629
|
exports.SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;
|
7198
|
-
exports.
|
7630
|
+
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN;
|
7631
|
+
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED;
|
7632
|
+
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED;
|
7633
|
+
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT;
|
7199
7634
|
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID;
|
7200
|
-
exports.
|
7201
|
-
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED;
|
7202
|
-
exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT = SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT;
|
7635
|
+
exports.SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD;
|
7203
7636
|
exports.SOLANA_ERROR__RPC__INTEGER_OVERFLOW = SOLANA_ERROR__RPC__INTEGER_OVERFLOW;
|
7204
7637
|
exports.SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR;
|
7205
7638
|
exports.SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN;
|
@@ -7271,6 +7704,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7271
7704
|
exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING;
|
7272
7705
|
exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND;
|
7273
7706
|
exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT;
|
7707
|
+
exports.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT;
|
7274
7708
|
exports.SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING;
|
7275
7709
|
exports.SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING;
|
7276
7710
|
exports.SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE;
|
@@ -7338,9 +7772,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7338
7772
|
exports.createAddressWithSeed = createAddressWithSeed;
|
7339
7773
|
exports.createCodec = createCodec;
|
7340
7774
|
exports.createDecoder = createDecoder;
|
7775
|
+
exports.createDefaultRpcSubscriptionsChannelCreator = createDefaultRpcSubscriptionsChannelCreator;
|
7341
7776
|
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
7342
7777
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
7778
|
+
exports.createDefaultSolanaRpcSubscriptionsChannelCreator = createDefaultSolanaRpcSubscriptionsChannelCreator;
|
7343
7779
|
exports.createEncoder = createEncoder;
|
7780
|
+
exports.createJsonRpcApi = createJsonRpcApi;
|
7344
7781
|
exports.createKeyPairFromBytes = createKeyPairFromBytes;
|
7345
7782
|
exports.createKeyPairFromPrivateKeyBytes = createKeyPairFromPrivateKeyBytes;
|
7346
7783
|
exports.createKeyPairSignerFromBytes = createKeyPairSignerFromBytes;
|
@@ -7348,8 +7785,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7348
7785
|
exports.createNoopSigner = createNoopSigner;
|
7349
7786
|
exports.createPrivateKeyFromBytes = createPrivateKeyFromBytes;
|
7350
7787
|
exports.createRpc = createRpc;
|
7351
|
-
exports.
|
7788
|
+
exports.createRpcMessage = createRpcMessage;
|
7352
7789
|
exports.createRpcSubscriptionsApi = createRpcSubscriptionsApi;
|
7790
|
+
exports.createRpcSubscriptionsTransportFromChannelCreator = createRpcSubscriptionsTransportFromChannelCreator;
|
7353
7791
|
exports.createSignableMessage = createSignableMessage;
|
7354
7792
|
exports.createSignerFromKeyPair = createSignerFromKeyPair;
|
7355
7793
|
exports.createSolanaRpc = createSolanaRpc;
|
@@ -7359,16 +7797,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7359
7797
|
exports.createSolanaRpcSubscriptionsApi = createSolanaRpcSubscriptionsApi;
|
7360
7798
|
exports.createSolanaRpcSubscriptionsApi_UNSTABLE = createSolanaRpcSubscriptionsApi_UNSTABLE;
|
7361
7799
|
exports.createSolanaRpcSubscriptionsFromTransport = createSolanaRpcSubscriptionsFromTransport;
|
7362
|
-
exports.createSolanaRpcSubscriptionsFromTransport_UNSTABLE = createSolanaRpcSubscriptionsFromTransport_UNSTABLE;
|
7363
7800
|
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
7364
7801
|
exports.createSubscriptionRpc = createSubscriptionRpc;
|
7365
7802
|
exports.createTransactionMessage = createTransactionMessage;
|
7366
7803
|
exports.decodeAccount = decodeAccount;
|
7367
|
-
exports.decodeTransactionMessage = decodeTransactionMessage;
|
7368
7804
|
exports.decompileTransactionMessage = decompileTransactionMessage;
|
7805
|
+
exports.decompileTransactionMessageFetchingLookupTables = decompileTransactionMessageFetchingLookupTables;
|
7369
7806
|
exports.devnet = devnet;
|
7370
7807
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
7371
7808
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
7809
|
+
exports.executeRpcPubSubSubscriptionPlan = executeRpcPubSubSubscriptionPlan;
|
7372
7810
|
exports.fetchEncodedAccount = fetchEncodedAccount;
|
7373
7811
|
exports.fetchEncodedAccounts = fetchEncodedAccounts;
|
7374
7812
|
exports.fetchJsonParsedAccount = fetchJsonParsedAccount;
|
@@ -7479,6 +7917,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7479
7917
|
exports.getOptionDecoder = getOptionDecoder;
|
7480
7918
|
exports.getOptionEncoder = getOptionEncoder;
|
7481
7919
|
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
7920
|
+
exports.getPublicKeyFromPrivateKey = getPublicKeyFromPrivateKey;
|
7921
|
+
exports.getRpcSubscriptionsChannelWithJSONSerialization = getRpcSubscriptionsChannelWithJSONSerialization;
|
7482
7922
|
exports.getScalarEnumCodec = getScalarEnumCodec;
|
7483
7923
|
exports.getScalarEnumDecoder = getScalarEnumDecoder;
|
7484
7924
|
exports.getScalarEnumEncoder = getScalarEnumEncoder;
|
@@ -7538,6 +7978,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7538
7978
|
exports.isInstructionForProgram = isInstructionForProgram;
|
7539
7979
|
exports.isInstructionWithAccounts = isInstructionWithAccounts;
|
7540
7980
|
exports.isInstructionWithData = isInstructionWithData;
|
7981
|
+
exports.isJsonRpcPayload = isJsonRpcPayload;
|
7541
7982
|
exports.isKeyPairSigner = isKeyPairSigner;
|
7542
7983
|
exports.isLamports = isLamports;
|
7543
7984
|
exports.isMessageModifyingSigner = isMessageModifyingSigner;
|
@@ -7610,6 +8051,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
7610
8051
|
exports.stringifiedBigInt = stringifiedBigInt;
|
7611
8052
|
exports.stringifiedNumber = stringifiedNumber;
|
7612
8053
|
exports.testnet = testnet;
|
8054
|
+
exports.transformChannelInboundMessages = transformChannelInboundMessages;
|
8055
|
+
exports.transformChannelOutboundMessages = transformChannelOutboundMessages;
|
7613
8056
|
exports.transformCodec = transformCodec;
|
7614
8057
|
exports.transformDecoder = transformDecoder;
|
7615
8058
|
exports.transformEncoder = transformEncoder;
|