@solana/web3.js 2.0.0-experimental.7539d42 → 2.0.0-experimental.777610f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +84 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +87 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +683 -127
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +76 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +73 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +74 -3
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +33 -30
- package/dist/types/index.d.ts +1 -0
- package/dist/types/rpc-websocket-autopinger.d.ts +8 -0
- package/dist/types/rpc-websocket-transport.d.ts +7 -0
- package/dist/types/rpc.d.ts +4 -3
- package/package.json +16 -15
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/rpc-default-config.d.ts.map +0 -1
- package/dist/types/rpc-integer-overflow-error.d.ts.map +0 -1
- package/dist/types/rpc-request-coalescer.d.ts.map +0 -1
- package/dist/types/rpc-request-deduplication.d.ts.map +0 -1
- package/dist/types/rpc-transport.d.ts.map +0 -1
- package/dist/types/rpc.d.ts.map +0 -1
|
@@ -125,13 +125,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
125
125
|
// ../addresses/dist/index.browser.js
|
|
126
126
|
init_env_shim();
|
|
127
127
|
|
|
128
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
128
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
|
|
129
129
|
init_env_shim();
|
|
130
130
|
|
|
131
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
131
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
|
|
132
132
|
init_env_shim();
|
|
133
133
|
|
|
134
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
134
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
135
135
|
init_env_shim();
|
|
136
136
|
var mergeBytes = (bytesArr) => {
|
|
137
137
|
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
@@ -152,7 +152,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
152
152
|
};
|
|
153
153
|
var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
|
|
154
154
|
|
|
155
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
155
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
|
|
156
156
|
init_env_shim();
|
|
157
157
|
var DeserializingEmptyBufferError = class extends Error {
|
|
158
158
|
constructor(serializer) {
|
|
@@ -174,7 +174,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
177
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
178
178
|
init_env_shim();
|
|
179
179
|
function fixSerializer(serializer, fixedBytes, description) {
|
|
180
180
|
return {
|
|
@@ -196,7 +196,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
199
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
|
|
200
200
|
init_env_shim();
|
|
201
201
|
function mapSerializer(serializer, unmap, map) {
|
|
202
202
|
return {
|
|
@@ -211,13 +211,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
214
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
|
|
215
215
|
init_env_shim();
|
|
216
216
|
|
|
217
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
217
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
218
218
|
init_env_shim();
|
|
219
219
|
|
|
220
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
220
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
221
221
|
init_env_shim();
|
|
222
222
|
var InvalidBaseStringError = class extends Error {
|
|
223
223
|
constructor(value, base, cause) {
|
|
@@ -228,7 +228,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
231
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
232
232
|
var baseX = (alphabet) => {
|
|
233
233
|
const base = alphabet.length;
|
|
234
234
|
const baseBigInt = BigInt(base);
|
|
@@ -282,18 +282,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
282
282
|
};
|
|
283
283
|
};
|
|
284
284
|
|
|
285
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
285
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
286
286
|
init_env_shim();
|
|
287
287
|
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
288
288
|
|
|
289
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
289
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
|
|
290
290
|
init_env_shim();
|
|
291
291
|
var removeNullCharacters = (value) => (
|
|
292
292
|
// eslint-disable-next-line no-control-regex
|
|
293
293
|
value.replace(/\u0000/g, "")
|
|
294
294
|
);
|
|
295
295
|
|
|
296
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
296
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
|
|
297
297
|
init_env_shim();
|
|
298
298
|
var utf8 = {
|
|
299
299
|
description: "utf8",
|
|
@@ -308,10 +308,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
311
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
|
|
312
312
|
init_env_shim();
|
|
313
313
|
|
|
314
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
314
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
|
|
315
315
|
init_env_shim();
|
|
316
316
|
var Endian;
|
|
317
317
|
(function(Endian2) {
|
|
@@ -319,7 +319,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
319
319
|
Endian2["Big"] = "be";
|
|
320
320
|
})(Endian || (Endian = {}));
|
|
321
321
|
|
|
322
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
322
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
|
|
323
323
|
init_env_shim();
|
|
324
324
|
var NumberOutOfRangeError = class extends RangeError {
|
|
325
325
|
constructor(serializer, min, max, actual) {
|
|
@@ -328,7 +328,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
330
|
|
|
331
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
331
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
|
|
332
332
|
init_env_shim();
|
|
333
333
|
function numberFactory(input) {
|
|
334
334
|
let littleEndian;
|
|
@@ -373,7 +373,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
375
|
|
|
376
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
376
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
|
|
377
377
|
init_env_shim();
|
|
378
378
|
var u8 = (options = {}) => numberFactory({
|
|
379
379
|
name: "u8",
|
|
@@ -384,7 +384,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
384
384
|
options
|
|
385
385
|
});
|
|
386
386
|
|
|
387
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
387
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
388
388
|
init_env_shim();
|
|
389
389
|
var u32 = (options = {}) => numberFactory({
|
|
390
390
|
name: "u32",
|
|
@@ -395,7 +395,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
395
395
|
options
|
|
396
396
|
});
|
|
397
397
|
|
|
398
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
398
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
399
399
|
init_env_shim();
|
|
400
400
|
var shortU16 = (options = {}) => ({
|
|
401
401
|
description: options.description ?? "shortU16",
|
|
@@ -433,10 +433,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
433
433
|
}
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
436
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
437
437
|
init_env_shim();
|
|
438
438
|
|
|
439
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
439
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
|
|
440
440
|
init_env_shim();
|
|
441
441
|
var InvalidNumberOfItemsError = class extends Error {
|
|
442
442
|
constructor(serializer, expected, actual) {
|
|
@@ -457,16 +457,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
457
457
|
}
|
|
458
458
|
};
|
|
459
459
|
|
|
460
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
460
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
461
461
|
init_env_shim();
|
|
462
462
|
|
|
463
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
463
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
464
464
|
init_env_shim();
|
|
465
465
|
function sumSerializerSizes(sizes) {
|
|
466
466
|
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
469
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
470
470
|
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
471
471
|
if (typeof size === "number") {
|
|
472
472
|
return [size, offset];
|
|
@@ -502,7 +502,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
502
502
|
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
505
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
506
506
|
function array(item, options = {}) {
|
|
507
507
|
const size = options.size ?? u32();
|
|
508
508
|
if (size === "remainder" && item.fixedSize === null) {
|
|
@@ -535,7 +535,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
538
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
539
539
|
init_env_shim();
|
|
540
540
|
function bytes(options = {}) {
|
|
541
541
|
const size = options.size ?? "variable";
|
|
@@ -583,7 +583,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
586
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
587
587
|
init_env_shim();
|
|
588
588
|
function string(options = {}) {
|
|
589
589
|
const size = options.size ?? u32();
|
|
@@ -625,7 +625,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
628
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
629
629
|
init_env_shim();
|
|
630
630
|
function struct(fields, options = {}) {
|
|
631
631
|
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
@@ -729,9 +729,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
729
729
|
if (numBytes !== 32) {
|
|
730
730
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
731
731
|
}
|
|
732
|
-
} catch (
|
|
732
|
+
} catch (e3) {
|
|
733
733
|
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
734
|
-
cause:
|
|
734
|
+
cause: e3
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
737
|
}
|
|
@@ -903,17 +903,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
903
903
|
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
904
904
|
})
|
|
905
905
|
};
|
|
906
|
-
} catch (
|
|
907
|
-
if (
|
|
906
|
+
} catch (e3) {
|
|
907
|
+
if (e3 instanceof PointOnCurveError) {
|
|
908
908
|
bumpSeed--;
|
|
909
909
|
} else {
|
|
910
|
-
throw
|
|
910
|
+
throw e3;
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
914
|
throw new Error("Unable to find a viable program address bump seed");
|
|
915
915
|
}
|
|
916
|
-
async function
|
|
916
|
+
async function createAddressWithSeed({
|
|
917
|
+
baseAddress,
|
|
918
|
+
programAddress,
|
|
919
|
+
seed
|
|
920
|
+
}) {
|
|
921
|
+
const { serialize: serialize4, deserialize: deserialize2 } = getBase58EncodedAddressCodec();
|
|
922
|
+
const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
|
|
923
|
+
if (seedBytes.byteLength > MAX_SEED_LENGTH) {
|
|
924
|
+
throw new Error(`The seed exceeds the maximum length of 32 bytes`);
|
|
925
|
+
}
|
|
926
|
+
const programAddressBytes = serialize4(programAddress);
|
|
927
|
+
if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
|
|
928
|
+
throw new Error(`programAddress cannot end with the PDA marker`);
|
|
929
|
+
}
|
|
930
|
+
const addressBytesBuffer = await crypto.subtle.digest(
|
|
931
|
+
"SHA-256",
|
|
932
|
+
new Uint8Array([...serialize4(baseAddress), ...seedBytes, ...programAddressBytes])
|
|
933
|
+
);
|
|
934
|
+
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
935
|
+
return deserialize2(addressBytes)[0];
|
|
936
|
+
}
|
|
937
|
+
async function getAddressFromPublicKey(publicKey) {
|
|
917
938
|
await assertKeyExporterIsAvailable();
|
|
918
939
|
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
919
940
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
@@ -1014,9 +1035,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1014
1035
|
if (numBytes !== 32) {
|
|
1015
1036
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1016
1037
|
}
|
|
1017
|
-
} catch (
|
|
1038
|
+
} catch (e3) {
|
|
1018
1039
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
1019
|
-
cause:
|
|
1040
|
+
cause: e3
|
|
1020
1041
|
});
|
|
1021
1042
|
}
|
|
1022
1043
|
}
|
|
@@ -1484,7 +1505,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1484
1505
|
)
|
|
1485
1506
|
],
|
|
1486
1507
|
[
|
|
1487
|
-
"
|
|
1508
|
+
"accountIndices",
|
|
1488
1509
|
array(
|
|
1489
1510
|
u8({
|
|
1490
1511
|
description: "The index of an account, according to the well-ordered accounts list for this transaction"
|
|
@@ -1504,23 +1525,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1504
1525
|
]
|
|
1505
1526
|
]),
|
|
1506
1527
|
(value) => {
|
|
1507
|
-
if (value.
|
|
1528
|
+
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1508
1529
|
return value;
|
|
1509
1530
|
}
|
|
1510
1531
|
return {
|
|
1511
1532
|
...value,
|
|
1512
|
-
|
|
1533
|
+
accountIndices: value.accountIndices ?? [],
|
|
1513
1534
|
data: value.data ?? new Uint8Array(0)
|
|
1514
1535
|
};
|
|
1515
1536
|
},
|
|
1516
1537
|
(value) => {
|
|
1517
|
-
if (value.
|
|
1538
|
+
if (value.accountIndices.length && value.data.byteLength) {
|
|
1518
1539
|
return value;
|
|
1519
1540
|
}
|
|
1520
|
-
const {
|
|
1541
|
+
const { accountIndices, data, ...rest } = value;
|
|
1521
1542
|
return {
|
|
1522
1543
|
...rest,
|
|
1523
|
-
...
|
|
1544
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1524
1545
|
...data.byteLength ? { data } : null
|
|
1525
1546
|
};
|
|
1526
1547
|
}
|
|
@@ -1643,7 +1664,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1643
1664
|
async function signTransaction(keyPair, transaction) {
|
|
1644
1665
|
const compiledMessage = compileMessage(transaction);
|
|
1645
1666
|
const [signerPublicKey, signature] = await Promise.all([
|
|
1646
|
-
|
|
1667
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1647
1668
|
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1648
1669
|
]);
|
|
1649
1670
|
const nextSignatures = {
|
|
@@ -1736,85 +1757,246 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1736
1757
|
return visitNode(params, [], onIntegerOverflow);
|
|
1737
1758
|
}
|
|
1738
1759
|
var KEYPATH_WILDCARD = {};
|
|
1739
|
-
var
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
"
|
|
1753
|
-
"data",
|
|
1754
|
-
"parsed",
|
|
1755
|
-
"info",
|
|
1756
|
-
"
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1760
|
+
var memoizedNotificationKeypaths;
|
|
1761
|
+
var memoizedResponseKeypaths;
|
|
1762
|
+
function getAllowedNumericKeypathsForNotification() {
|
|
1763
|
+
if (!memoizedNotificationKeypaths) {
|
|
1764
|
+
memoizedNotificationKeypaths = {};
|
|
1765
|
+
}
|
|
1766
|
+
return memoizedNotificationKeypaths;
|
|
1767
|
+
}
|
|
1768
|
+
function getAllowedNumericKeypathsForResponse() {
|
|
1769
|
+
if (!memoizedResponseKeypaths) {
|
|
1770
|
+
const jsonParsedTokenAccountsConfigs = [
|
|
1771
|
+
// parsed Token/Token22 token account
|
|
1772
|
+
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
1773
|
+
["data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
1774
|
+
["data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
1775
|
+
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
|
|
1776
|
+
["data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
1777
|
+
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
|
|
1778
|
+
[
|
|
1779
|
+
"data",
|
|
1780
|
+
"parsed",
|
|
1781
|
+
"info",
|
|
1782
|
+
"extensions",
|
|
1783
|
+
KEYPATH_WILDCARD,
|
|
1784
|
+
"state",
|
|
1785
|
+
"olderTransferFee",
|
|
1786
|
+
"transferFeeBasisPoints"
|
|
1787
|
+
],
|
|
1788
|
+
[
|
|
1789
|
+
"data",
|
|
1790
|
+
"parsed",
|
|
1791
|
+
"info",
|
|
1792
|
+
"extensions",
|
|
1793
|
+
KEYPATH_WILDCARD,
|
|
1794
|
+
"state",
|
|
1795
|
+
"newerTransferFee",
|
|
1796
|
+
"transferFeeBasisPoints"
|
|
1797
|
+
],
|
|
1798
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
1799
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
|
|
1800
|
+
];
|
|
1801
|
+
const jsonParsedAccountsConfigs = [
|
|
1802
|
+
...jsonParsedTokenAccountsConfigs,
|
|
1803
|
+
// parsed AddressTableLookup account
|
|
1804
|
+
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
1805
|
+
// parsed Config account
|
|
1806
|
+
["data", "parsed", "info", "slashPenalty"],
|
|
1807
|
+
["data", "parsed", "info", "warmupCooldownRate"],
|
|
1808
|
+
// parsed Token/Token22 mint account
|
|
1809
|
+
["data", "parsed", "info", "decimals"],
|
|
1810
|
+
// parsed Token/Token22 multisig account
|
|
1811
|
+
["data", "parsed", "info", "numRequiredSigners"],
|
|
1812
|
+
["data", "parsed", "info", "numValidSigners"],
|
|
1813
|
+
// parsed Stake account
|
|
1814
|
+
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
1815
|
+
// parsed Sysvar rent account
|
|
1816
|
+
["data", "parsed", "info", "exemptionThreshold"],
|
|
1817
|
+
["data", "parsed", "info", "burnPercent"],
|
|
1818
|
+
// parsed Vote account
|
|
1819
|
+
["data", "parsed", "info", "commission"],
|
|
1820
|
+
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
1821
|
+
];
|
|
1822
|
+
memoizedResponseKeypaths = {
|
|
1823
|
+
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
1824
|
+
getBlock: [
|
|
1825
|
+
["blockTime"],
|
|
1826
|
+
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1827
|
+
[
|
|
1828
|
+
"transactions",
|
|
1829
|
+
KEYPATH_WILDCARD,
|
|
1830
|
+
"meta",
|
|
1831
|
+
"preTokenBalances",
|
|
1832
|
+
KEYPATH_WILDCARD,
|
|
1833
|
+
"uiTokenAmount",
|
|
1834
|
+
"decimals"
|
|
1835
|
+
],
|
|
1836
|
+
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1837
|
+
[
|
|
1838
|
+
"transactions",
|
|
1839
|
+
KEYPATH_WILDCARD,
|
|
1840
|
+
"meta",
|
|
1841
|
+
"postTokenBalances",
|
|
1842
|
+
KEYPATH_WILDCARD,
|
|
1843
|
+
"uiTokenAmount",
|
|
1844
|
+
"decimals"
|
|
1845
|
+
],
|
|
1846
|
+
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
1847
|
+
["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
1848
|
+
[
|
|
1849
|
+
"transactions",
|
|
1850
|
+
KEYPATH_WILDCARD,
|
|
1851
|
+
"meta",
|
|
1852
|
+
"innerInstructions",
|
|
1853
|
+
KEYPATH_WILDCARD,
|
|
1854
|
+
"instructions",
|
|
1855
|
+
KEYPATH_WILDCARD,
|
|
1856
|
+
"programIdIndex"
|
|
1857
|
+
],
|
|
1858
|
+
[
|
|
1859
|
+
"transactions",
|
|
1860
|
+
KEYPATH_WILDCARD,
|
|
1861
|
+
"meta",
|
|
1862
|
+
"innerInstructions",
|
|
1863
|
+
KEYPATH_WILDCARD,
|
|
1864
|
+
"instructions",
|
|
1865
|
+
KEYPATH_WILDCARD,
|
|
1866
|
+
"accounts",
|
|
1867
|
+
KEYPATH_WILDCARD
|
|
1868
|
+
],
|
|
1869
|
+
[
|
|
1870
|
+
"transactions",
|
|
1871
|
+
KEYPATH_WILDCARD,
|
|
1872
|
+
"transaction",
|
|
1873
|
+
"message",
|
|
1874
|
+
"addressTableLookups",
|
|
1875
|
+
KEYPATH_WILDCARD,
|
|
1876
|
+
"writableIndexes",
|
|
1877
|
+
KEYPATH_WILDCARD
|
|
1878
|
+
],
|
|
1879
|
+
[
|
|
1880
|
+
"transactions",
|
|
1881
|
+
KEYPATH_WILDCARD,
|
|
1882
|
+
"transaction",
|
|
1883
|
+
"message",
|
|
1884
|
+
"addressTableLookups",
|
|
1885
|
+
KEYPATH_WILDCARD,
|
|
1886
|
+
"readonlyIndexes",
|
|
1887
|
+
KEYPATH_WILDCARD
|
|
1888
|
+
],
|
|
1889
|
+
[
|
|
1890
|
+
"transactions",
|
|
1891
|
+
KEYPATH_WILDCARD,
|
|
1892
|
+
"transaction",
|
|
1893
|
+
"message",
|
|
1894
|
+
"instructions",
|
|
1895
|
+
KEYPATH_WILDCARD,
|
|
1896
|
+
"programIdIndex"
|
|
1897
|
+
],
|
|
1898
|
+
[
|
|
1899
|
+
"transactions",
|
|
1900
|
+
KEYPATH_WILDCARD,
|
|
1901
|
+
"transaction",
|
|
1902
|
+
"message",
|
|
1903
|
+
"instructions",
|
|
1904
|
+
KEYPATH_WILDCARD,
|
|
1905
|
+
"accounts",
|
|
1906
|
+
KEYPATH_WILDCARD
|
|
1907
|
+
],
|
|
1908
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
1909
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
1910
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
|
|
1911
|
+
["rewards", KEYPATH_WILDCARD, "commission"]
|
|
1912
|
+
],
|
|
1913
|
+
getBlockTime: [[]],
|
|
1914
|
+
getClusterNodes: [
|
|
1915
|
+
[KEYPATH_WILDCARD, "featureSet"],
|
|
1916
|
+
[KEYPATH_WILDCARD, "shredVersion"]
|
|
1917
|
+
],
|
|
1918
|
+
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
|
|
1919
|
+
getInflationRate: [["foundation"], ["total"], ["validator"]],
|
|
1920
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
1921
|
+
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
|
|
1922
|
+
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
1923
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
1924
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
1925
|
+
]),
|
|
1926
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
1927
|
+
getTokenAccountBalance: [
|
|
1928
|
+
["value", "decimals"],
|
|
1929
|
+
["value", "uiAmount"]
|
|
1930
|
+
],
|
|
1931
|
+
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
1932
|
+
"value",
|
|
1933
|
+
KEYPATH_WILDCARD,
|
|
1934
|
+
"account",
|
|
1935
|
+
...c
|
|
1936
|
+
]),
|
|
1937
|
+
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
1938
|
+
"value",
|
|
1939
|
+
KEYPATH_WILDCARD,
|
|
1940
|
+
"account",
|
|
1941
|
+
...c
|
|
1942
|
+
]),
|
|
1943
|
+
getTokenLargestAccounts: [
|
|
1944
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
1945
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
1946
|
+
],
|
|
1947
|
+
getTokenSupply: [
|
|
1948
|
+
["value", "decimals"],
|
|
1949
|
+
["value", "uiAmount"]
|
|
1950
|
+
],
|
|
1951
|
+
getTransaction: [
|
|
1952
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1953
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
1954
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1955
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
1956
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
1957
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
1958
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
1959
|
+
[
|
|
1960
|
+
"meta",
|
|
1961
|
+
"innerInstructions",
|
|
1962
|
+
KEYPATH_WILDCARD,
|
|
1963
|
+
"instructions",
|
|
1964
|
+
KEYPATH_WILDCARD,
|
|
1965
|
+
"accounts",
|
|
1966
|
+
KEYPATH_WILDCARD
|
|
1967
|
+
],
|
|
1968
|
+
[
|
|
1969
|
+
"transaction",
|
|
1970
|
+
"message",
|
|
1971
|
+
"addressTableLookups",
|
|
1972
|
+
KEYPATH_WILDCARD,
|
|
1973
|
+
"writableIndexes",
|
|
1974
|
+
KEYPATH_WILDCARD
|
|
1975
|
+
],
|
|
1976
|
+
[
|
|
1977
|
+
"transaction",
|
|
1978
|
+
"message",
|
|
1979
|
+
"addressTableLookups",
|
|
1980
|
+
KEYPATH_WILDCARD,
|
|
1981
|
+
"readonlyIndexes",
|
|
1982
|
+
KEYPATH_WILDCARD
|
|
1983
|
+
],
|
|
1984
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
1985
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
1986
|
+
["transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
1987
|
+
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
1988
|
+
["transaction", "message", "header", "numRequiredSignatures"]
|
|
1989
|
+
],
|
|
1990
|
+
getVersion: [["feature-set"]],
|
|
1991
|
+
getVoteAccounts: [
|
|
1992
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
1993
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
1994
|
+
],
|
|
1995
|
+
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
return memoizedResponseKeypaths;
|
|
1999
|
+
}
|
|
1818
2000
|
function getNextAllowedKeypaths(keyPaths, property) {
|
|
1819
2001
|
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
1820
2002
|
}
|
|
@@ -1841,7 +2023,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1841
2023
|
}
|
|
1842
2024
|
}
|
|
1843
2025
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
1844
|
-
const allowedKeypaths = methodName ?
|
|
2026
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
|
|
2027
|
+
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
2028
|
+
}
|
|
2029
|
+
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
|
|
2030
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
|
|
1845
2031
|
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
1846
2032
|
}
|
|
1847
2033
|
function createSolanaRpcApi(config) {
|
|
@@ -1870,6 +2056,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1870
2056
|
}
|
|
1871
2057
|
});
|
|
1872
2058
|
}
|
|
2059
|
+
function createSolanaRpcSubscriptionsApi(config) {
|
|
2060
|
+
return new Proxy({}, {
|
|
2061
|
+
defineProperty() {
|
|
2062
|
+
return false;
|
|
2063
|
+
},
|
|
2064
|
+
deleteProperty() {
|
|
2065
|
+
return false;
|
|
2066
|
+
},
|
|
2067
|
+
get(...args) {
|
|
2068
|
+
const [_, p] = args;
|
|
2069
|
+
const notificationName = p.toString();
|
|
2070
|
+
return function(...rawParams) {
|
|
2071
|
+
const handleIntegerOverflow = config?.onIntegerOverflow;
|
|
2072
|
+
const params = patchParamsForSolanaLabsRpc(
|
|
2073
|
+
rawParams,
|
|
2074
|
+
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
|
|
2075
|
+
);
|
|
2076
|
+
return {
|
|
2077
|
+
params,
|
|
2078
|
+
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
|
|
2079
|
+
subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
|
|
2080
|
+
unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2081
|
+
};
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
1873
2086
|
|
|
1874
2087
|
// ../rpc-transport/dist/index.browser.js
|
|
1875
2088
|
init_env_shim();
|
|
@@ -1936,6 +2149,100 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1936
2149
|
function createJsonRpc(rpcConfig) {
|
|
1937
2150
|
return makeProxy(rpcConfig);
|
|
1938
2151
|
}
|
|
2152
|
+
function registerIterableCleanup(iterable, cleanupFn) {
|
|
2153
|
+
(async () => {
|
|
2154
|
+
try {
|
|
2155
|
+
for await (const _ of iterable)
|
|
2156
|
+
;
|
|
2157
|
+
} catch {
|
|
2158
|
+
} finally {
|
|
2159
|
+
cleanupFn();
|
|
2160
|
+
}
|
|
2161
|
+
})();
|
|
2162
|
+
}
|
|
2163
|
+
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
|
|
2164
|
+
return {
|
|
2165
|
+
async subscribe(options) {
|
|
2166
|
+
options?.abortSignal?.throwIfAborted();
|
|
2167
|
+
let subscriptionId;
|
|
2168
|
+
function handleCleanup() {
|
|
2169
|
+
if (subscriptionId !== void 0) {
|
|
2170
|
+
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
|
|
2171
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
|
|
2172
|
+
connectionAbortController.abort();
|
|
2173
|
+
});
|
|
2174
|
+
} else {
|
|
2175
|
+
connectionAbortController.abort();
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
options?.abortSignal?.addEventListener("abort", handleCleanup);
|
|
2179
|
+
const connectionAbortController = new AbortController();
|
|
2180
|
+
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
|
|
2181
|
+
const connection = await rpcConfig.transport({
|
|
2182
|
+
payload: subscribeMessage,
|
|
2183
|
+
signal: connectionAbortController.signal
|
|
2184
|
+
});
|
|
2185
|
+
function handleConnectionCleanup() {
|
|
2186
|
+
options?.abortSignal?.removeEventListener("abort", handleCleanup);
|
|
2187
|
+
}
|
|
2188
|
+
registerIterableCleanup(connection, handleConnectionCleanup);
|
|
2189
|
+
for await (const message of connection) {
|
|
2190
|
+
if ("id" in message && message.id === subscribeMessage.id) {
|
|
2191
|
+
if ("error" in message) {
|
|
2192
|
+
throw new SolanaJsonRpcError(message.error);
|
|
2193
|
+
} else {
|
|
2194
|
+
subscriptionId = message.result;
|
|
2195
|
+
break;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
if (subscriptionId == null) {
|
|
2200
|
+
throw new Error("Failed to obtain a subscription id from the server");
|
|
2201
|
+
}
|
|
2202
|
+
return {
|
|
2203
|
+
async *[Symbol.asyncIterator]() {
|
|
2204
|
+
for await (const message of connection) {
|
|
2205
|
+
if (!("params" in message) || message.params.subscription !== subscriptionId) {
|
|
2206
|
+
continue;
|
|
2207
|
+
}
|
|
2208
|
+
const notification = message.params.result;
|
|
2209
|
+
yield responseProcessor ? responseProcessor(notification) : notification;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
function makeProxy2(rpcConfig) {
|
|
2217
|
+
return new Proxy(rpcConfig.api, {
|
|
2218
|
+
defineProperty() {
|
|
2219
|
+
return false;
|
|
2220
|
+
},
|
|
2221
|
+
deleteProperty() {
|
|
2222
|
+
return false;
|
|
2223
|
+
},
|
|
2224
|
+
get(target, p, receiver) {
|
|
2225
|
+
return function(...rawParams) {
|
|
2226
|
+
const methodName = p.toString();
|
|
2227
|
+
const createRpcSubscription = Reflect.get(target, methodName, receiver);
|
|
2228
|
+
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
|
|
2229
|
+
throw new Error(
|
|
2230
|
+
"Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
|
|
2234
|
+
params: rawParams,
|
|
2235
|
+
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
|
|
2236
|
+
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
|
|
2237
|
+
};
|
|
2238
|
+
return createPendingRpcSubscription(rpcConfig, newRequest);
|
|
2239
|
+
};
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
function createJsonSubscriptionRpc(rpcConfig) {
|
|
2244
|
+
return makeProxy2(rpcConfig);
|
|
2245
|
+
}
|
|
1939
2246
|
var e = globalThis.fetch;
|
|
1940
2247
|
var SolanaHttpError = class extends Error {
|
|
1941
2248
|
constructor(details) {
|
|
@@ -2034,6 +2341,166 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2034
2341
|
return await response.json();
|
|
2035
2342
|
};
|
|
2036
2343
|
}
|
|
2344
|
+
var e2 = globalThis.WebSocket;
|
|
2345
|
+
async function createWebSocketConnection({
|
|
2346
|
+
sendBufferHighWatermark,
|
|
2347
|
+
signal,
|
|
2348
|
+
url
|
|
2349
|
+
}) {
|
|
2350
|
+
return new Promise((resolve, reject) => {
|
|
2351
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
2352
|
+
const iteratorState = /* @__PURE__ */ new Map();
|
|
2353
|
+
function handleAbort() {
|
|
2354
|
+
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
|
|
2355
|
+
webSocket.close(1e3);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
function handleClose(ev) {
|
|
2359
|
+
bufferDrainWatcher?.onCancel();
|
|
2360
|
+
signal.removeEventListener("abort", handleAbort);
|
|
2361
|
+
webSocket.removeEventListener("close", handleClose);
|
|
2362
|
+
webSocket.removeEventListener("error", handleError);
|
|
2363
|
+
webSocket.removeEventListener("open", handleOpen);
|
|
2364
|
+
webSocket.removeEventListener("message", handleMessage);
|
|
2365
|
+
iteratorState.forEach((state, iteratorKey) => {
|
|
2366
|
+
if (state.__hasPolled) {
|
|
2367
|
+
const { onError } = state;
|
|
2368
|
+
iteratorState.delete(iteratorKey);
|
|
2369
|
+
onError(ev);
|
|
2370
|
+
} else {
|
|
2371
|
+
iteratorState.delete(iteratorKey);
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
function handleError(ev) {
|
|
2376
|
+
if (!hasConnected) {
|
|
2377
|
+
reject(
|
|
2378
|
+
// TODO: Coded error
|
|
2379
|
+
new Error("WebSocket failed to connect", { cause: ev })
|
|
2380
|
+
);
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
let hasConnected = false;
|
|
2384
|
+
let bufferDrainWatcher;
|
|
2385
|
+
function handleOpen() {
|
|
2386
|
+
hasConnected = true;
|
|
2387
|
+
resolve({
|
|
2388
|
+
async send(payload) {
|
|
2389
|
+
const message = JSON.stringify(payload);
|
|
2390
|
+
if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
|
2391
|
+
let onCancel;
|
|
2392
|
+
const promise = new Promise((resolve2, reject2) => {
|
|
2393
|
+
const intervalId = setInterval(() => {
|
|
2394
|
+
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
|
2395
|
+
clearInterval(intervalId);
|
|
2396
|
+
bufferDrainWatcher = void 0;
|
|
2397
|
+
resolve2();
|
|
2398
|
+
}
|
|
2399
|
+
}, 16);
|
|
2400
|
+
onCancel = () => {
|
|
2401
|
+
bufferDrainWatcher = void 0;
|
|
2402
|
+
clearInterval(intervalId);
|
|
2403
|
+
reject2(
|
|
2404
|
+
// TODO: Coded error
|
|
2405
|
+
new Error("WebSocket was closed before payload could be sent")
|
|
2406
|
+
);
|
|
2407
|
+
};
|
|
2408
|
+
});
|
|
2409
|
+
bufferDrainWatcher = {
|
|
2410
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2411
|
+
// @ts-ignore
|
|
2412
|
+
onCancel,
|
|
2413
|
+
promise
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
if (bufferDrainWatcher) {
|
|
2417
|
+
await bufferDrainWatcher.promise;
|
|
2418
|
+
}
|
|
2419
|
+
webSocket.send(message);
|
|
2420
|
+
},
|
|
2421
|
+
async *[Symbol.asyncIterator]() {
|
|
2422
|
+
const iteratorKey = Symbol();
|
|
2423
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
2424
|
+
try {
|
|
2425
|
+
while (true) {
|
|
2426
|
+
const state = iteratorState.get(iteratorKey);
|
|
2427
|
+
if (!state) {
|
|
2428
|
+
throw new Error("Invariant: WebSocket message iterator is missing state storage");
|
|
2429
|
+
}
|
|
2430
|
+
if (state.__hasPolled) {
|
|
2431
|
+
throw new Error(
|
|
2432
|
+
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2435
|
+
const queuedMessages = state.queuedMessages;
|
|
2436
|
+
if (queuedMessages.length) {
|
|
2437
|
+
state.queuedMessages = [];
|
|
2438
|
+
yield* queuedMessages;
|
|
2439
|
+
} else {
|
|
2440
|
+
try {
|
|
2441
|
+
yield await new Promise((onMessage, onError) => {
|
|
2442
|
+
iteratorState.set(iteratorKey, {
|
|
2443
|
+
__hasPolled: true,
|
|
2444
|
+
onError,
|
|
2445
|
+
onMessage
|
|
2446
|
+
});
|
|
2447
|
+
});
|
|
2448
|
+
} catch (e3) {
|
|
2449
|
+
if (e3 !== null && typeof e3 === "object" && "type" in e3 && e3.type === "close" && "wasClean" in e3 && e3.wasClean) {
|
|
2450
|
+
return;
|
|
2451
|
+
} else {
|
|
2452
|
+
throw new Error("WebSocket connection closed", { cause: e3 });
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
} finally {
|
|
2458
|
+
iteratorState.delete(iteratorKey);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
function handleMessage({ data }) {
|
|
2464
|
+
const message = JSON.parse(data);
|
|
2465
|
+
iteratorState.forEach((state, iteratorKey) => {
|
|
2466
|
+
if (state.__hasPolled) {
|
|
2467
|
+
const { onMessage } = state;
|
|
2468
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
2469
|
+
onMessage(message);
|
|
2470
|
+
} else {
|
|
2471
|
+
state.queuedMessages.push(message);
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
const webSocket = new e2(url);
|
|
2476
|
+
webSocket.addEventListener("close", handleClose);
|
|
2477
|
+
webSocket.addEventListener("error", handleError);
|
|
2478
|
+
webSocket.addEventListener("open", handleOpen);
|
|
2479
|
+
webSocket.addEventListener("message", handleMessage);
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
|
|
2483
|
+
if (/^wss?:/i.test(url) === false) {
|
|
2484
|
+
const protocolMatch = url.match(/^([^:]+):/);
|
|
2485
|
+
throw new DOMException(
|
|
2486
|
+
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.`
|
|
2487
|
+
);
|
|
2488
|
+
}
|
|
2489
|
+
return async function sendWebSocketMessage({ payload, signal }) {
|
|
2490
|
+
signal?.throwIfAborted();
|
|
2491
|
+
const connection = await createWebSocketConnection({
|
|
2492
|
+
sendBufferHighWatermark,
|
|
2493
|
+
signal,
|
|
2494
|
+
url
|
|
2495
|
+
});
|
|
2496
|
+
signal?.throwIfAborted();
|
|
2497
|
+
await connection.send(payload);
|
|
2498
|
+
return {
|
|
2499
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
2500
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
|
|
2501
|
+
};
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2037
2504
|
|
|
2038
2505
|
// src/rpc-default-config.ts
|
|
2039
2506
|
init_env_shim();
|
|
@@ -2082,6 +2549,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2082
2549
|
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
2083
2550
|
});
|
|
2084
2551
|
}
|
|
2552
|
+
function createSolanaRpcSubscriptions(config) {
|
|
2553
|
+
return createJsonSubscriptionRpc({
|
|
2554
|
+
...config,
|
|
2555
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2085
2558
|
|
|
2086
2559
|
// src/rpc-transport.ts
|
|
2087
2560
|
init_env_shim();
|
|
@@ -2118,14 +2591,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2118
2591
|
if (signal) {
|
|
2119
2592
|
const responsePromise = coalescedRequest.responsePromise;
|
|
2120
2593
|
return await new Promise((resolve, reject) => {
|
|
2121
|
-
const handleAbort = (
|
|
2594
|
+
const handleAbort = (e3) => {
|
|
2122
2595
|
signal.removeEventListener("abort", handleAbort);
|
|
2123
2596
|
coalescedRequest.numConsumers -= 1;
|
|
2124
2597
|
if (coalescedRequest.numConsumers === 0) {
|
|
2125
2598
|
const abortController = coalescedRequest.abortController;
|
|
2126
2599
|
abortController.abort();
|
|
2127
2600
|
}
|
|
2128
|
-
const abortError = new DOMException(
|
|
2601
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
2129
2602
|
reject(abortError);
|
|
2130
2603
|
};
|
|
2131
2604
|
signal.addEventListener("abort", handleAbort);
|
|
@@ -2175,20 +2648,103 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2175
2648
|
);
|
|
2176
2649
|
}
|
|
2177
2650
|
|
|
2651
|
+
// src/rpc-websocket-transport.ts
|
|
2652
|
+
init_env_shim();
|
|
2653
|
+
|
|
2654
|
+
// src/rpc-websocket-autopinger.ts
|
|
2655
|
+
init_env_shim();
|
|
2656
|
+
var PING_PAYLOAD = {
|
|
2657
|
+
jsonrpc: "2.0",
|
|
2658
|
+
method: "ping"
|
|
2659
|
+
};
|
|
2660
|
+
function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
|
|
2661
|
+
const pingableConnections = /* @__PURE__ */ new Map();
|
|
2662
|
+
return async (...args) => {
|
|
2663
|
+
const connection = await transport(...args);
|
|
2664
|
+
let intervalId;
|
|
2665
|
+
function sendPing() {
|
|
2666
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
|
|
2667
|
+
}
|
|
2668
|
+
function restartPingTimer() {
|
|
2669
|
+
clearInterval(intervalId);
|
|
2670
|
+
intervalId = setInterval(sendPing, intervalMs);
|
|
2671
|
+
}
|
|
2672
|
+
if (pingableConnections.has(connection) === false) {
|
|
2673
|
+
pingableConnections.set(connection, {
|
|
2674
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
2675
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
|
|
2676
|
+
restartPingTimer();
|
|
2677
|
+
return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
|
|
2678
|
+
}
|
|
2679
|
+
});
|
|
2680
|
+
(async () => {
|
|
2681
|
+
try {
|
|
2682
|
+
for await (const _ of connection) {
|
|
2683
|
+
restartPingTimer();
|
|
2684
|
+
}
|
|
2685
|
+
} catch {
|
|
2686
|
+
} finally {
|
|
2687
|
+
pingableConnections.delete(connection);
|
|
2688
|
+
clearInterval(intervalId);
|
|
2689
|
+
if (handleOffline) {
|
|
2690
|
+
globalThis.window.removeEventListener("offline", handleOffline);
|
|
2691
|
+
}
|
|
2692
|
+
if (handleOnline) {
|
|
2693
|
+
globalThis.window.removeEventListener("online", handleOnline);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
})();
|
|
2697
|
+
if (globalThis.navigator.onLine) {
|
|
2698
|
+
restartPingTimer();
|
|
2699
|
+
}
|
|
2700
|
+
let handleOffline;
|
|
2701
|
+
let handleOnline;
|
|
2702
|
+
{
|
|
2703
|
+
handleOffline = () => {
|
|
2704
|
+
clearInterval(intervalId);
|
|
2705
|
+
};
|
|
2706
|
+
handleOnline = () => {
|
|
2707
|
+
sendPing();
|
|
2708
|
+
restartPingTimer();
|
|
2709
|
+
};
|
|
2710
|
+
globalThis.window.addEventListener("offline", handleOffline);
|
|
2711
|
+
globalThis.window.addEventListener("online", handleOnline);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
return pingableConnections.get(connection);
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
// src/rpc-websocket-transport.ts
|
|
2719
|
+
function createDefaultRpcSubscriptionsTransport(config) {
|
|
2720
|
+
const { intervalMs, ...rest } = config;
|
|
2721
|
+
return getWebSocketTransportWithAutoping({
|
|
2722
|
+
intervalMs: intervalMs ?? 5e3,
|
|
2723
|
+
transport: createWebSocketTransport({
|
|
2724
|
+
...rest,
|
|
2725
|
+
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
2726
|
+
131072
|
|
2727
|
+
})
|
|
2728
|
+
});
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2178
2731
|
exports.AccountRole = AccountRole;
|
|
2179
2732
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
2180
2733
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
2181
2734
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
2182
2735
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
2736
|
+
exports.createAddressWithSeed = createAddressWithSeed;
|
|
2737
|
+
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
2183
2738
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
2184
2739
|
exports.createSolanaRpc = createSolanaRpc;
|
|
2740
|
+
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
2185
2741
|
exports.createTransaction = createTransaction;
|
|
2186
2742
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
2187
2743
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
2188
2744
|
exports.generateKeyPair = generateKeyPair;
|
|
2745
|
+
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
2189
2746
|
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
2190
2747
|
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
2191
|
-
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
|
|
2192
2748
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2193
2749
|
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
2194
2750
|
exports.isSignerRole = isSignerRole;
|