@solana/web3.js 2.0.0-experimental.dc614af → 2.0.0-experimental.e0b865d
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 +321 -8
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +321 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +835 -68
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +310 -11
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +310 -8
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +310 -11
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +36 -30
- package/dist/types/cached-abortable-iterable.d.ts +11 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/rpc-subscription-coalescer.d.ts +10 -0
- package/dist/types/rpc-websocket-autopinger.d.ts +8 -0
- package/dist/types/rpc-websocket-connection-sharding.d.ts +13 -0
- package/dist/types/rpc-websocket-transport.d.ts +13 -0
- package/dist/types/rpc.d.ts +5 -3
- package/package.json +14 -12
- 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(", ");
|
|
@@ -715,6 +715,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
715
715
|
throw new Error("No signature verification implementation could be found");
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
+
function isBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
719
|
+
if (
|
|
720
|
+
// Lowest address (32 bytes of zeroes)
|
|
721
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
722
|
+
putativeBase58EncodedAddress.length > 44
|
|
723
|
+
) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
const bytes2 = base58.serialize(putativeBase58EncodedAddress);
|
|
727
|
+
const numBytes = bytes2.byteLength;
|
|
728
|
+
if (numBytes !== 32) {
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
return true;
|
|
732
|
+
}
|
|
718
733
|
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
719
734
|
try {
|
|
720
735
|
if (
|
|
@@ -729,12 +744,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
729
744
|
if (numBytes !== 32) {
|
|
730
745
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
731
746
|
}
|
|
732
|
-
} catch (
|
|
747
|
+
} catch (e3) {
|
|
733
748
|
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
734
|
-
cause:
|
|
749
|
+
cause: e3
|
|
735
750
|
});
|
|
736
751
|
}
|
|
737
752
|
}
|
|
753
|
+
function address(putativeBase58EncodedAddress) {
|
|
754
|
+
assertIsBase58EncodedAddress(putativeBase58EncodedAddress);
|
|
755
|
+
return putativeBase58EncodedAddress;
|
|
756
|
+
}
|
|
738
757
|
function getBase58EncodedAddressCodec(config) {
|
|
739
758
|
return string({
|
|
740
759
|
description: config?.description ?? ("A 32-byte account address" ),
|
|
@@ -903,16 +922,37 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
903
922
|
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
904
923
|
})
|
|
905
924
|
};
|
|
906
|
-
} catch (
|
|
907
|
-
if (
|
|
925
|
+
} catch (e3) {
|
|
926
|
+
if (e3 instanceof PointOnCurveError) {
|
|
908
927
|
bumpSeed--;
|
|
909
928
|
} else {
|
|
910
|
-
throw
|
|
929
|
+
throw e3;
|
|
911
930
|
}
|
|
912
931
|
}
|
|
913
932
|
}
|
|
914
933
|
throw new Error("Unable to find a viable program address bump seed");
|
|
915
934
|
}
|
|
935
|
+
async function createAddressWithSeed({
|
|
936
|
+
baseAddress,
|
|
937
|
+
programAddress,
|
|
938
|
+
seed
|
|
939
|
+
}) {
|
|
940
|
+
const { serialize: serialize4, deserialize: deserialize2 } = getBase58EncodedAddressCodec();
|
|
941
|
+
const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
|
|
942
|
+
if (seedBytes.byteLength > MAX_SEED_LENGTH) {
|
|
943
|
+
throw new Error(`The seed exceeds the maximum length of 32 bytes`);
|
|
944
|
+
}
|
|
945
|
+
const programAddressBytes = serialize4(programAddress);
|
|
946
|
+
if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
|
|
947
|
+
throw new Error(`programAddress cannot end with the PDA marker`);
|
|
948
|
+
}
|
|
949
|
+
const addressBytesBuffer = await crypto.subtle.digest(
|
|
950
|
+
"SHA-256",
|
|
951
|
+
new Uint8Array([...serialize4(baseAddress), ...seedBytes, ...programAddressBytes])
|
|
952
|
+
);
|
|
953
|
+
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
954
|
+
return deserialize2(addressBytes)[0];
|
|
955
|
+
}
|
|
916
956
|
async function getAddressFromPublicKey(publicKey) {
|
|
917
957
|
await assertKeyExporterIsAvailable();
|
|
918
958
|
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
@@ -1014,9 +1054,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1014
1054
|
if (numBytes !== 32) {
|
|
1015
1055
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1016
1056
|
}
|
|
1017
|
-
} catch (
|
|
1057
|
+
} catch (e3) {
|
|
1018
1058
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
1019
|
-
cause:
|
|
1059
|
+
cause: e3
|
|
1020
1060
|
});
|
|
1021
1061
|
}
|
|
1022
1062
|
}
|
|
@@ -1146,8 +1186,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1146
1186
|
Object.freeze(out);
|
|
1147
1187
|
return out;
|
|
1148
1188
|
}
|
|
1149
|
-
function upsert(addressMap,
|
|
1150
|
-
addressMap[
|
|
1189
|
+
function upsert(addressMap, address2, update) {
|
|
1190
|
+
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole2.READONLY });
|
|
1151
1191
|
}
|
|
1152
1192
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
1153
1193
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -1312,8 +1352,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1312
1352
|
} else {
|
|
1313
1353
|
return addressComparator(leftAddress, rightAddress);
|
|
1314
1354
|
}
|
|
1315
|
-
}).map(([
|
|
1316
|
-
address,
|
|
1355
|
+
}).map(([address2, addressMeta]) => ({
|
|
1356
|
+
address: address2,
|
|
1317
1357
|
...addressMeta
|
|
1318
1358
|
}));
|
|
1319
1359
|
return orderedAccounts;
|
|
@@ -1376,7 +1416,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1376
1416
|
return instructions.map(({ accounts, data, programAddress }) => {
|
|
1377
1417
|
return {
|
|
1378
1418
|
programAddressIndex: accountIndex[programAddress],
|
|
1379
|
-
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[
|
|
1419
|
+
...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
|
|
1380
1420
|
...data ? { data } : null
|
|
1381
1421
|
};
|
|
1382
1422
|
});
|
|
@@ -1390,7 +1430,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1390
1430
|
function getCompiledStaticAccounts(orderedAccounts) {
|
|
1391
1431
|
const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
|
|
1392
1432
|
const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
|
|
1393
|
-
return orderedStaticAccounts.map(({ address }) =>
|
|
1433
|
+
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
|
1394
1434
|
}
|
|
1395
1435
|
function compileMessage(transaction) {
|
|
1396
1436
|
const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
|
|
@@ -1640,16 +1680,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1640
1680
|
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1641
1681
|
return signature;
|
|
1642
1682
|
}
|
|
1643
|
-
async function signTransaction(
|
|
1683
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1644
1684
|
const compiledMessage = compileMessage(transaction);
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1685
|
+
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1686
|
+
const publicKeySignaturePairs = await Promise.all(
|
|
1687
|
+
keyPairs.map(
|
|
1688
|
+
(keyPair) => Promise.all([
|
|
1689
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1690
|
+
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1691
|
+
])
|
|
1692
|
+
)
|
|
1693
|
+
);
|
|
1694
|
+
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
1695
|
+
nextSignatures[signerPublicKey] = signature;
|
|
1696
|
+
}
|
|
1653
1697
|
const out = {
|
|
1654
1698
|
...transaction,
|
|
1655
1699
|
signatures: nextSignatures
|
|
@@ -1708,6 +1752,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1708
1752
|
// src/rpc.ts
|
|
1709
1753
|
init_env_shim();
|
|
1710
1754
|
|
|
1755
|
+
// ../functional/dist/index.browser.js
|
|
1756
|
+
init_env_shim();
|
|
1757
|
+
function pipe(init, ...fns) {
|
|
1758
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1711
1761
|
// ../rpc-core/dist/index.browser.js
|
|
1712
1762
|
init_env_shim();
|
|
1713
1763
|
function visitNode(value, keyPath, onIntegerOverflow) {
|
|
@@ -1736,9 +1786,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1736
1786
|
return visitNode(params, [], onIntegerOverflow);
|
|
1737
1787
|
}
|
|
1738
1788
|
var KEYPATH_WILDCARD = {};
|
|
1739
|
-
var
|
|
1740
|
-
|
|
1741
|
-
|
|
1789
|
+
var memoizedNotificationKeypaths;
|
|
1790
|
+
var memoizedResponseKeypaths;
|
|
1791
|
+
function getAllowedNumericKeypathsForNotification() {
|
|
1792
|
+
if (!memoizedNotificationKeypaths) {
|
|
1793
|
+
memoizedNotificationKeypaths = {};
|
|
1794
|
+
}
|
|
1795
|
+
return memoizedNotificationKeypaths;
|
|
1796
|
+
}
|
|
1797
|
+
function getAllowedNumericKeypathsForResponse() {
|
|
1798
|
+
if (!memoizedResponseKeypaths) {
|
|
1742
1799
|
const jsonParsedTokenAccountsConfigs = [
|
|
1743
1800
|
// parsed Token/Token22 token account
|
|
1744
1801
|
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
@@ -1791,8 +1848,97 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1791
1848
|
["data", "parsed", "info", "commission"],
|
|
1792
1849
|
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
1793
1850
|
];
|
|
1794
|
-
|
|
1851
|
+
memoizedResponseKeypaths = {
|
|
1795
1852
|
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
1853
|
+
getBlock: [
|
|
1854
|
+
["blockTime"],
|
|
1855
|
+
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1856
|
+
[
|
|
1857
|
+
"transactions",
|
|
1858
|
+
KEYPATH_WILDCARD,
|
|
1859
|
+
"meta",
|
|
1860
|
+
"preTokenBalances",
|
|
1861
|
+
KEYPATH_WILDCARD,
|
|
1862
|
+
"uiTokenAmount",
|
|
1863
|
+
"decimals"
|
|
1864
|
+
],
|
|
1865
|
+
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
1866
|
+
[
|
|
1867
|
+
"transactions",
|
|
1868
|
+
KEYPATH_WILDCARD,
|
|
1869
|
+
"meta",
|
|
1870
|
+
"postTokenBalances",
|
|
1871
|
+
KEYPATH_WILDCARD,
|
|
1872
|
+
"uiTokenAmount",
|
|
1873
|
+
"decimals"
|
|
1874
|
+
],
|
|
1875
|
+
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
1876
|
+
["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
1877
|
+
[
|
|
1878
|
+
"transactions",
|
|
1879
|
+
KEYPATH_WILDCARD,
|
|
1880
|
+
"meta",
|
|
1881
|
+
"innerInstructions",
|
|
1882
|
+
KEYPATH_WILDCARD,
|
|
1883
|
+
"instructions",
|
|
1884
|
+
KEYPATH_WILDCARD,
|
|
1885
|
+
"programIdIndex"
|
|
1886
|
+
],
|
|
1887
|
+
[
|
|
1888
|
+
"transactions",
|
|
1889
|
+
KEYPATH_WILDCARD,
|
|
1890
|
+
"meta",
|
|
1891
|
+
"innerInstructions",
|
|
1892
|
+
KEYPATH_WILDCARD,
|
|
1893
|
+
"instructions",
|
|
1894
|
+
KEYPATH_WILDCARD,
|
|
1895
|
+
"accounts",
|
|
1896
|
+
KEYPATH_WILDCARD
|
|
1897
|
+
],
|
|
1898
|
+
[
|
|
1899
|
+
"transactions",
|
|
1900
|
+
KEYPATH_WILDCARD,
|
|
1901
|
+
"transaction",
|
|
1902
|
+
"message",
|
|
1903
|
+
"addressTableLookups",
|
|
1904
|
+
KEYPATH_WILDCARD,
|
|
1905
|
+
"writableIndexes",
|
|
1906
|
+
KEYPATH_WILDCARD
|
|
1907
|
+
],
|
|
1908
|
+
[
|
|
1909
|
+
"transactions",
|
|
1910
|
+
KEYPATH_WILDCARD,
|
|
1911
|
+
"transaction",
|
|
1912
|
+
"message",
|
|
1913
|
+
"addressTableLookups",
|
|
1914
|
+
KEYPATH_WILDCARD,
|
|
1915
|
+
"readonlyIndexes",
|
|
1916
|
+
KEYPATH_WILDCARD
|
|
1917
|
+
],
|
|
1918
|
+
[
|
|
1919
|
+
"transactions",
|
|
1920
|
+
KEYPATH_WILDCARD,
|
|
1921
|
+
"transaction",
|
|
1922
|
+
"message",
|
|
1923
|
+
"instructions",
|
|
1924
|
+
KEYPATH_WILDCARD,
|
|
1925
|
+
"programIdIndex"
|
|
1926
|
+
],
|
|
1927
|
+
[
|
|
1928
|
+
"transactions",
|
|
1929
|
+
KEYPATH_WILDCARD,
|
|
1930
|
+
"transaction",
|
|
1931
|
+
"message",
|
|
1932
|
+
"instructions",
|
|
1933
|
+
KEYPATH_WILDCARD,
|
|
1934
|
+
"accounts",
|
|
1935
|
+
KEYPATH_WILDCARD
|
|
1936
|
+
],
|
|
1937
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
1938
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
1939
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
|
|
1940
|
+
["rewards", KEYPATH_WILDCARD, "commission"]
|
|
1941
|
+
],
|
|
1796
1942
|
getBlockTime: [[]],
|
|
1797
1943
|
getClusterNodes: [
|
|
1798
1944
|
[KEYPATH_WILDCARD, "featureSet"],
|
|
@@ -1874,10 +2020,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1874
2020
|
getVoteAccounts: [
|
|
1875
2021
|
["current", KEYPATH_WILDCARD, "commission"],
|
|
1876
2022
|
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
1877
|
-
]
|
|
2023
|
+
],
|
|
2024
|
+
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
|
|
1878
2025
|
};
|
|
1879
2026
|
}
|
|
1880
|
-
return
|
|
2027
|
+
return memoizedResponseKeypaths;
|
|
1881
2028
|
}
|
|
1882
2029
|
function getNextAllowedKeypaths(keyPaths, property) {
|
|
1883
2030
|
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
@@ -1905,7 +2052,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1905
2052
|
}
|
|
1906
2053
|
}
|
|
1907
2054
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
1908
|
-
const allowedKeypaths = methodName ?
|
|
2055
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
|
|
2056
|
+
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
2057
|
+
}
|
|
2058
|
+
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
|
|
2059
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
|
|
1909
2060
|
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
1910
2061
|
}
|
|
1911
2062
|
function createSolanaRpcApi(config) {
|
|
@@ -1934,6 +2085,36 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1934
2085
|
}
|
|
1935
2086
|
});
|
|
1936
2087
|
}
|
|
2088
|
+
function createSolanaRpcSubscriptionsApi(config) {
|
|
2089
|
+
return new Proxy({}, {
|
|
2090
|
+
defineProperty() {
|
|
2091
|
+
return false;
|
|
2092
|
+
},
|
|
2093
|
+
deleteProperty() {
|
|
2094
|
+
return false;
|
|
2095
|
+
},
|
|
2096
|
+
get(...args) {
|
|
2097
|
+
const [_, p] = args;
|
|
2098
|
+
const notificationName = p.toString();
|
|
2099
|
+
return function(...rawParams) {
|
|
2100
|
+
const handleIntegerOverflow = config?.onIntegerOverflow;
|
|
2101
|
+
const params = patchParamsForSolanaLabsRpc(
|
|
2102
|
+
rawParams,
|
|
2103
|
+
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
|
|
2104
|
+
);
|
|
2105
|
+
return {
|
|
2106
|
+
params,
|
|
2107
|
+
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
|
|
2108
|
+
subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
|
|
2109
|
+
unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2110
|
+
};
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
|
|
2116
|
+
return createSolanaRpcSubscriptionsApi(config);
|
|
2117
|
+
}
|
|
1937
2118
|
|
|
1938
2119
|
// ../rpc-transport/dist/index.browser.js
|
|
1939
2120
|
init_env_shim();
|
|
@@ -2000,6 +2181,100 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2000
2181
|
function createJsonRpc(rpcConfig) {
|
|
2001
2182
|
return makeProxy(rpcConfig);
|
|
2002
2183
|
}
|
|
2184
|
+
function registerIterableCleanup(iterable, cleanupFn) {
|
|
2185
|
+
(async () => {
|
|
2186
|
+
try {
|
|
2187
|
+
for await (const _ of iterable)
|
|
2188
|
+
;
|
|
2189
|
+
} catch {
|
|
2190
|
+
} finally {
|
|
2191
|
+
cleanupFn();
|
|
2192
|
+
}
|
|
2193
|
+
})();
|
|
2194
|
+
}
|
|
2195
|
+
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
|
|
2196
|
+
return {
|
|
2197
|
+
async subscribe({ abortSignal }) {
|
|
2198
|
+
abortSignal.throwIfAborted();
|
|
2199
|
+
let subscriptionId;
|
|
2200
|
+
function handleCleanup() {
|
|
2201
|
+
if (subscriptionId !== void 0) {
|
|
2202
|
+
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
|
|
2203
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
|
|
2204
|
+
connectionAbortController.abort();
|
|
2205
|
+
});
|
|
2206
|
+
} else {
|
|
2207
|
+
connectionAbortController.abort();
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
abortSignal.addEventListener("abort", handleCleanup);
|
|
2211
|
+
const connectionAbortController = new AbortController();
|
|
2212
|
+
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
|
|
2213
|
+
const connection = await rpcConfig.transport({
|
|
2214
|
+
payload: subscribeMessage,
|
|
2215
|
+
signal: connectionAbortController.signal
|
|
2216
|
+
});
|
|
2217
|
+
function handleConnectionCleanup() {
|
|
2218
|
+
abortSignal.removeEventListener("abort", handleCleanup);
|
|
2219
|
+
}
|
|
2220
|
+
registerIterableCleanup(connection, handleConnectionCleanup);
|
|
2221
|
+
for await (const message of connection) {
|
|
2222
|
+
if ("id" in message && message.id === subscribeMessage.id) {
|
|
2223
|
+
if ("error" in message) {
|
|
2224
|
+
throw new SolanaJsonRpcError(message.error);
|
|
2225
|
+
} else {
|
|
2226
|
+
subscriptionId = message.result;
|
|
2227
|
+
break;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
if (subscriptionId == null) {
|
|
2232
|
+
throw new Error("Failed to obtain a subscription id from the server");
|
|
2233
|
+
}
|
|
2234
|
+
return {
|
|
2235
|
+
async *[Symbol.asyncIterator]() {
|
|
2236
|
+
for await (const message of connection) {
|
|
2237
|
+
if (!("params" in message) || message.params.subscription !== subscriptionId) {
|
|
2238
|
+
continue;
|
|
2239
|
+
}
|
|
2240
|
+
const notification = message.params.result;
|
|
2241
|
+
yield responseProcessor ? responseProcessor(notification) : notification;
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
function makeProxy2(rpcConfig) {
|
|
2249
|
+
return new Proxy(rpcConfig.api, {
|
|
2250
|
+
defineProperty() {
|
|
2251
|
+
return false;
|
|
2252
|
+
},
|
|
2253
|
+
deleteProperty() {
|
|
2254
|
+
return false;
|
|
2255
|
+
},
|
|
2256
|
+
get(target, p, receiver) {
|
|
2257
|
+
return function(...rawParams) {
|
|
2258
|
+
const methodName = p.toString();
|
|
2259
|
+
const createRpcSubscription = Reflect.get(target, methodName, receiver);
|
|
2260
|
+
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
|
|
2261
|
+
throw new Error(
|
|
2262
|
+
"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."
|
|
2263
|
+
);
|
|
2264
|
+
}
|
|
2265
|
+
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
|
|
2266
|
+
params: rawParams,
|
|
2267
|
+
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
|
|
2268
|
+
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
|
|
2269
|
+
};
|
|
2270
|
+
return createPendingRpcSubscription(rpcConfig, newRequest);
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
function createJsonSubscriptionRpc(rpcConfig) {
|
|
2276
|
+
return makeProxy2(rpcConfig);
|
|
2277
|
+
}
|
|
2003
2278
|
var e = globalThis.fetch;
|
|
2004
2279
|
var SolanaHttpError = class extends Error {
|
|
2005
2280
|
constructor(details) {
|
|
@@ -2098,6 +2373,175 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2098
2373
|
return await response.json();
|
|
2099
2374
|
};
|
|
2100
2375
|
}
|
|
2376
|
+
var e2 = globalThis.WebSocket;
|
|
2377
|
+
var EXPLICIT_ABORT_TOKEN = Symbol(
|
|
2378
|
+
"This symbol is thrown from a socket's iterator when the connection is explicity aborted by the user"
|
|
2379
|
+
);
|
|
2380
|
+
async function createWebSocketConnection({
|
|
2381
|
+
sendBufferHighWatermark,
|
|
2382
|
+
signal,
|
|
2383
|
+
url
|
|
2384
|
+
}) {
|
|
2385
|
+
return new Promise((resolve, reject) => {
|
|
2386
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
2387
|
+
const iteratorState = /* @__PURE__ */ new Map();
|
|
2388
|
+
function errorAndClearAllIteratorStates(reason) {
|
|
2389
|
+
const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
|
|
2390
|
+
iteratorState.clear();
|
|
2391
|
+
errorCallbacks.forEach((cb) => {
|
|
2392
|
+
try {
|
|
2393
|
+
cb(reason);
|
|
2394
|
+
} catch {
|
|
2395
|
+
}
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
function handleAbort() {
|
|
2399
|
+
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
|
|
2400
|
+
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
|
|
2401
|
+
webSocket.close(1e3);
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
function handleClose(ev) {
|
|
2405
|
+
bufferDrainWatcher?.onCancel();
|
|
2406
|
+
signal.removeEventListener("abort", handleAbort);
|
|
2407
|
+
webSocket.removeEventListener("close", handleClose);
|
|
2408
|
+
webSocket.removeEventListener("error", handleError);
|
|
2409
|
+
webSocket.removeEventListener("open", handleOpen);
|
|
2410
|
+
webSocket.removeEventListener("message", handleMessage);
|
|
2411
|
+
errorAndClearAllIteratorStates(ev);
|
|
2412
|
+
}
|
|
2413
|
+
function handleError(ev) {
|
|
2414
|
+
if (!hasConnected) {
|
|
2415
|
+
reject(
|
|
2416
|
+
// TODO: Coded error
|
|
2417
|
+
new Error("WebSocket failed to connect", { cause: ev })
|
|
2418
|
+
);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
let hasConnected = false;
|
|
2422
|
+
let bufferDrainWatcher;
|
|
2423
|
+
function handleOpen() {
|
|
2424
|
+
hasConnected = true;
|
|
2425
|
+
resolve({
|
|
2426
|
+
async send(payload) {
|
|
2427
|
+
const message = JSON.stringify(payload);
|
|
2428
|
+
if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
|
2429
|
+
let onCancel;
|
|
2430
|
+
const promise = new Promise((resolve2, reject2) => {
|
|
2431
|
+
const intervalId = setInterval(() => {
|
|
2432
|
+
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
|
2433
|
+
clearInterval(intervalId);
|
|
2434
|
+
bufferDrainWatcher = void 0;
|
|
2435
|
+
resolve2();
|
|
2436
|
+
}
|
|
2437
|
+
}, 16);
|
|
2438
|
+
onCancel = () => {
|
|
2439
|
+
bufferDrainWatcher = void 0;
|
|
2440
|
+
clearInterval(intervalId);
|
|
2441
|
+
reject2(
|
|
2442
|
+
// TODO: Coded error
|
|
2443
|
+
new Error("WebSocket was closed before payload could be sent")
|
|
2444
|
+
);
|
|
2445
|
+
};
|
|
2446
|
+
});
|
|
2447
|
+
bufferDrainWatcher = {
|
|
2448
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2449
|
+
// @ts-ignore
|
|
2450
|
+
onCancel,
|
|
2451
|
+
promise
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
if (bufferDrainWatcher) {
|
|
2455
|
+
await bufferDrainWatcher.promise;
|
|
2456
|
+
}
|
|
2457
|
+
webSocket.send(message);
|
|
2458
|
+
},
|
|
2459
|
+
async *[Symbol.asyncIterator]() {
|
|
2460
|
+
const iteratorKey = Symbol();
|
|
2461
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
2462
|
+
try {
|
|
2463
|
+
while (true) {
|
|
2464
|
+
const state = iteratorState.get(iteratorKey);
|
|
2465
|
+
if (!state) {
|
|
2466
|
+
throw new Error("Invariant: WebSocket message iterator is missing state storage");
|
|
2467
|
+
}
|
|
2468
|
+
if (state.__hasPolled) {
|
|
2469
|
+
throw new Error(
|
|
2470
|
+
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
|
|
2471
|
+
);
|
|
2472
|
+
}
|
|
2473
|
+
const queuedMessages = state.queuedMessages;
|
|
2474
|
+
if (queuedMessages.length) {
|
|
2475
|
+
state.queuedMessages = [];
|
|
2476
|
+
yield* queuedMessages;
|
|
2477
|
+
} else {
|
|
2478
|
+
try {
|
|
2479
|
+
yield await new Promise((resolve2, reject2) => {
|
|
2480
|
+
iteratorState.set(iteratorKey, {
|
|
2481
|
+
__hasPolled: true,
|
|
2482
|
+
onError: reject2,
|
|
2483
|
+
onMessage: resolve2
|
|
2484
|
+
});
|
|
2485
|
+
});
|
|
2486
|
+
} catch (e3) {
|
|
2487
|
+
if (e3 === EXPLICIT_ABORT_TOKEN) {
|
|
2488
|
+
return;
|
|
2489
|
+
} else {
|
|
2490
|
+
throw new Error("WebSocket connection closed", { cause: e3 });
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
} finally {
|
|
2496
|
+
iteratorState.delete(iteratorKey);
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
function handleMessage({ data }) {
|
|
2502
|
+
const message = JSON.parse(data);
|
|
2503
|
+
iteratorState.forEach((state, iteratorKey) => {
|
|
2504
|
+
if (state.__hasPolled) {
|
|
2505
|
+
const { onMessage } = state;
|
|
2506
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
2507
|
+
onMessage(message);
|
|
2508
|
+
} else {
|
|
2509
|
+
state.queuedMessages.push(message);
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
const webSocket = new e2(url);
|
|
2514
|
+
webSocket.addEventListener("close", handleClose);
|
|
2515
|
+
webSocket.addEventListener("error", handleError);
|
|
2516
|
+
webSocket.addEventListener("open", handleOpen);
|
|
2517
|
+
webSocket.addEventListener("message", handleMessage);
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
|
|
2521
|
+
if (/^wss?:/i.test(url) === false) {
|
|
2522
|
+
const protocolMatch = url.match(/^([^:]+):/);
|
|
2523
|
+
throw new DOMException(
|
|
2524
|
+
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.`
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
return async function sendWebSocketMessage({ payload, signal }) {
|
|
2528
|
+
signal?.throwIfAborted();
|
|
2529
|
+
const connection = await createWebSocketConnection({
|
|
2530
|
+
sendBufferHighWatermark,
|
|
2531
|
+
signal,
|
|
2532
|
+
url
|
|
2533
|
+
});
|
|
2534
|
+
signal?.throwIfAborted();
|
|
2535
|
+
await connection.send(payload);
|
|
2536
|
+
return {
|
|
2537
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
2538
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
|
|
2539
|
+
};
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
// src/rpc.ts
|
|
2544
|
+
var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
|
|
2101
2545
|
|
|
2102
2546
|
// src/rpc-default-config.ts
|
|
2103
2547
|
init_env_shim();
|
|
@@ -2139,6 +2583,197 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2139
2583
|
}
|
|
2140
2584
|
};
|
|
2141
2585
|
|
|
2586
|
+
// src/rpc-subscription-coalescer.ts
|
|
2587
|
+
init_env_shim();
|
|
2588
|
+
|
|
2589
|
+
// src/cached-abortable-iterable.ts
|
|
2590
|
+
init_env_shim();
|
|
2591
|
+
function registerIterableCleanup2(iterable, cleanupFn) {
|
|
2592
|
+
(async () => {
|
|
2593
|
+
try {
|
|
2594
|
+
for await (const _ of iterable)
|
|
2595
|
+
;
|
|
2596
|
+
} catch {
|
|
2597
|
+
} finally {
|
|
2598
|
+
cleanupFn();
|
|
2599
|
+
}
|
|
2600
|
+
})();
|
|
2601
|
+
}
|
|
2602
|
+
function getCachedAbortableIterableFactory({
|
|
2603
|
+
getAbortSignalFromInputArgs,
|
|
2604
|
+
getCacheEntryMissingError,
|
|
2605
|
+
getCacheKeyFromInputArgs,
|
|
2606
|
+
onCacheHit,
|
|
2607
|
+
onCreateIterable
|
|
2608
|
+
}) {
|
|
2609
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2610
|
+
function getCacheEntryOrThrow(cacheKey) {
|
|
2611
|
+
const currentCacheEntry = cache.get(cacheKey);
|
|
2612
|
+
if (!currentCacheEntry) {
|
|
2613
|
+
throw getCacheEntryMissingError(cacheKey);
|
|
2614
|
+
}
|
|
2615
|
+
return currentCacheEntry;
|
|
2616
|
+
}
|
|
2617
|
+
return async (...args) => {
|
|
2618
|
+
const cacheKey = getCacheKeyFromInputArgs(...args);
|
|
2619
|
+
const signal = getAbortSignalFromInputArgs(...args);
|
|
2620
|
+
if (cacheKey === void 0) {
|
|
2621
|
+
return await onCreateIterable(signal, ...args);
|
|
2622
|
+
}
|
|
2623
|
+
const cleanup = () => {
|
|
2624
|
+
cache.delete(cacheKey);
|
|
2625
|
+
signal.removeEventListener("abort", handleAbort);
|
|
2626
|
+
};
|
|
2627
|
+
const handleAbort = () => {
|
|
2628
|
+
const cacheEntry = getCacheEntryOrThrow(cacheKey);
|
|
2629
|
+
if (cacheEntry.purgeScheduled !== true) {
|
|
2630
|
+
cacheEntry.purgeScheduled = true;
|
|
2631
|
+
globalThis.queueMicrotask(() => {
|
|
2632
|
+
cacheEntry.purgeScheduled = false;
|
|
2633
|
+
if (cacheEntry.referenceCount === 0) {
|
|
2634
|
+
cacheEntry.abortController.abort();
|
|
2635
|
+
cleanup();
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
cacheEntry.referenceCount--;
|
|
2640
|
+
};
|
|
2641
|
+
signal.addEventListener("abort", handleAbort);
|
|
2642
|
+
try {
|
|
2643
|
+
const cacheEntry = cache.get(cacheKey);
|
|
2644
|
+
if (!cacheEntry) {
|
|
2645
|
+
const singletonAbortController = new AbortController();
|
|
2646
|
+
const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
|
|
2647
|
+
const newCacheEntry = {
|
|
2648
|
+
abortController: singletonAbortController,
|
|
2649
|
+
iterable: newIterablePromise,
|
|
2650
|
+
purgeScheduled: false,
|
|
2651
|
+
referenceCount: 1
|
|
2652
|
+
};
|
|
2653
|
+
cache.set(cacheKey, newCacheEntry);
|
|
2654
|
+
const newIterable = await newIterablePromise;
|
|
2655
|
+
registerIterableCleanup2(newIterable, cleanup);
|
|
2656
|
+
newCacheEntry.iterable = newIterable;
|
|
2657
|
+
return newIterable;
|
|
2658
|
+
} else {
|
|
2659
|
+
cacheEntry.referenceCount++;
|
|
2660
|
+
const iterableOrIterablePromise = cacheEntry.iterable;
|
|
2661
|
+
const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
|
|
2662
|
+
await onCacheHit(cachedIterable, ...args);
|
|
2663
|
+
return cachedIterable;
|
|
2664
|
+
}
|
|
2665
|
+
} catch (e3) {
|
|
2666
|
+
cleanup();
|
|
2667
|
+
throw e3;
|
|
2668
|
+
}
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
// src/rpc-subscription-coalescer.ts
|
|
2673
|
+
var EXPLICIT_ABORT_TOKEN2 = Symbol(
|
|
2674
|
+
"This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
|
|
2675
|
+
);
|
|
2676
|
+
function registerIterableCleanup3(iterable, cleanupFn) {
|
|
2677
|
+
(async () => {
|
|
2678
|
+
try {
|
|
2679
|
+
for await (const _ of iterable)
|
|
2680
|
+
;
|
|
2681
|
+
} catch {
|
|
2682
|
+
} finally {
|
|
2683
|
+
cleanupFn();
|
|
2684
|
+
}
|
|
2685
|
+
})();
|
|
2686
|
+
}
|
|
2687
|
+
function getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
2688
|
+
getDeduplicationKey,
|
|
2689
|
+
rpcSubscriptions
|
|
2690
|
+
}) {
|
|
2691
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2692
|
+
return new Proxy(rpcSubscriptions, {
|
|
2693
|
+
defineProperty() {
|
|
2694
|
+
return false;
|
|
2695
|
+
},
|
|
2696
|
+
deleteProperty() {
|
|
2697
|
+
return false;
|
|
2698
|
+
},
|
|
2699
|
+
get(target, p, receiver) {
|
|
2700
|
+
const subscriptionMethod = Reflect.get(target, p, receiver);
|
|
2701
|
+
if (typeof subscriptionMethod !== "function") {
|
|
2702
|
+
return subscriptionMethod;
|
|
2703
|
+
}
|
|
2704
|
+
return function(...rawParams) {
|
|
2705
|
+
const deduplicationKey = getDeduplicationKey(p, rawParams);
|
|
2706
|
+
if (deduplicationKey === void 0) {
|
|
2707
|
+
return subscriptionMethod(...rawParams);
|
|
2708
|
+
}
|
|
2709
|
+
if (cache.has(deduplicationKey)) {
|
|
2710
|
+
return cache.get(deduplicationKey);
|
|
2711
|
+
}
|
|
2712
|
+
const iterableFactory = getCachedAbortableIterableFactory({
|
|
2713
|
+
getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
|
|
2714
|
+
getCacheEntryMissingError(deduplicationKey2) {
|
|
2715
|
+
return new Error(
|
|
2716
|
+
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
|
|
2717
|
+
);
|
|
2718
|
+
},
|
|
2719
|
+
getCacheKeyFromInputArgs: () => deduplicationKey,
|
|
2720
|
+
async onCacheHit(_iterable, _config) {
|
|
2721
|
+
},
|
|
2722
|
+
async onCreateIterable(abortSignal, config) {
|
|
2723
|
+
const pendingSubscription2 = subscriptionMethod(
|
|
2724
|
+
...rawParams
|
|
2725
|
+
);
|
|
2726
|
+
const iterable = await pendingSubscription2.subscribe({
|
|
2727
|
+
...config,
|
|
2728
|
+
abortSignal
|
|
2729
|
+
});
|
|
2730
|
+
registerIterableCleanup3(iterable, () => {
|
|
2731
|
+
cache.delete(deduplicationKey);
|
|
2732
|
+
});
|
|
2733
|
+
return iterable;
|
|
2734
|
+
}
|
|
2735
|
+
});
|
|
2736
|
+
const pendingSubscription = {
|
|
2737
|
+
async subscribe(...args) {
|
|
2738
|
+
const iterable = await iterableFactory(...args);
|
|
2739
|
+
const { abortSignal } = args[0];
|
|
2740
|
+
let abortPromise;
|
|
2741
|
+
return {
|
|
2742
|
+
...iterable,
|
|
2743
|
+
async *[Symbol.asyncIterator]() {
|
|
2744
|
+
abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN2) : new Promise((_, reject) => {
|
|
2745
|
+
abortSignal.addEventListener("abort", () => {
|
|
2746
|
+
reject(EXPLICIT_ABORT_TOKEN2);
|
|
2747
|
+
});
|
|
2748
|
+
}));
|
|
2749
|
+
try {
|
|
2750
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
2751
|
+
while (true) {
|
|
2752
|
+
const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
|
|
2753
|
+
if (iteratorResult.done) {
|
|
2754
|
+
return;
|
|
2755
|
+
} else {
|
|
2756
|
+
yield iteratorResult.value;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
} catch (e3) {
|
|
2760
|
+
if (e3 === EXPLICIT_ABORT_TOKEN2) {
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
cache.delete(deduplicationKey);
|
|
2764
|
+
throw e3;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
}
|
|
2769
|
+
};
|
|
2770
|
+
cache.set(deduplicationKey, pendingSubscription);
|
|
2771
|
+
return pendingSubscription;
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2142
2777
|
// src/rpc.ts
|
|
2143
2778
|
function createSolanaRpc(config) {
|
|
2144
2779
|
return createJsonRpc({
|
|
@@ -2146,6 +2781,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2146
2781
|
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
2147
2782
|
});
|
|
2148
2783
|
}
|
|
2784
|
+
function createSolanaRpcSubscriptions(config) {
|
|
2785
|
+
return pipe(
|
|
2786
|
+
createJsonSubscriptionRpc({
|
|
2787
|
+
...config,
|
|
2788
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
2789
|
+
}),
|
|
2790
|
+
(rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
2791
|
+
getDeduplicationKey: (...args) => (0, import_fast_stable_stringify.default)(args),
|
|
2792
|
+
rpcSubscriptions
|
|
2793
|
+
})
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2796
|
+
function createSolanaRpcSubscriptions_UNSTABLE(config) {
|
|
2797
|
+
return createJsonSubscriptionRpc({
|
|
2798
|
+
...config,
|
|
2799
|
+
api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2149
2802
|
|
|
2150
2803
|
// src/rpc-transport.ts
|
|
2151
2804
|
init_env_shim();
|
|
@@ -2182,14 +2835,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2182
2835
|
if (signal) {
|
|
2183
2836
|
const responsePromise = coalescedRequest.responsePromise;
|
|
2184
2837
|
return await new Promise((resolve, reject) => {
|
|
2185
|
-
const handleAbort = (
|
|
2838
|
+
const handleAbort = (e3) => {
|
|
2186
2839
|
signal.removeEventListener("abort", handleAbort);
|
|
2187
2840
|
coalescedRequest.numConsumers -= 1;
|
|
2188
2841
|
if (coalescedRequest.numConsumers === 0) {
|
|
2189
2842
|
const abortController = coalescedRequest.abortController;
|
|
2190
2843
|
abortController.abort();
|
|
2191
2844
|
}
|
|
2192
|
-
const abortError = new DOMException(
|
|
2845
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
2193
2846
|
reject(abortError);
|
|
2194
2847
|
};
|
|
2195
2848
|
signal.addEventListener("abort", handleAbort);
|
|
@@ -2205,14 +2858,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2205
2858
|
|
|
2206
2859
|
// src/rpc-request-deduplication.ts
|
|
2207
2860
|
init_env_shim();
|
|
2208
|
-
var
|
|
2209
|
-
function
|
|
2861
|
+
var import_fast_stable_stringify2 = __toESM(require_fast_stable_stringify(), 1);
|
|
2862
|
+
function isJsonRpcPayload(payload) {
|
|
2210
2863
|
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
2211
|
-
return;
|
|
2212
|
-
}
|
|
2213
|
-
if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
|
|
2214
|
-
return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
|
|
2864
|
+
return false;
|
|
2215
2865
|
}
|
|
2866
|
+
return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
|
|
2867
|
+
}
|
|
2868
|
+
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
|
2869
|
+
return isJsonRpcPayload(payload) ? (0, import_fast_stable_stringify2.default)([payload.method, payload.params]) : void 0;
|
|
2216
2870
|
}
|
|
2217
2871
|
|
|
2218
2872
|
// src/rpc-transport.ts
|
|
@@ -2224,7 +2878,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2224
2878
|
return out;
|
|
2225
2879
|
}
|
|
2226
2880
|
function createDefaultRpcTransport(config) {
|
|
2227
|
-
return
|
|
2881
|
+
return pipe(
|
|
2228
2882
|
createHttpTransport({
|
|
2229
2883
|
...config,
|
|
2230
2884
|
headers: {
|
|
@@ -2235,17 +2889,129 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2235
2889
|
}
|
|
2236
2890
|
}
|
|
2237
2891
|
}),
|
|
2238
|
-
getSolanaRpcPayloadDeduplicationKey
|
|
2892
|
+
(transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
|
|
2893
|
+
);
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
// src/rpc-websocket-transport.ts
|
|
2897
|
+
init_env_shim();
|
|
2898
|
+
|
|
2899
|
+
// src/rpc-websocket-autopinger.ts
|
|
2900
|
+
init_env_shim();
|
|
2901
|
+
var PING_PAYLOAD = {
|
|
2902
|
+
jsonrpc: "2.0",
|
|
2903
|
+
method: "ping"
|
|
2904
|
+
};
|
|
2905
|
+
function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
|
|
2906
|
+
const pingableConnections = /* @__PURE__ */ new Map();
|
|
2907
|
+
return async (...args) => {
|
|
2908
|
+
const connection = await transport(...args);
|
|
2909
|
+
let intervalId;
|
|
2910
|
+
function sendPing() {
|
|
2911
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
|
|
2912
|
+
}
|
|
2913
|
+
function restartPingTimer() {
|
|
2914
|
+
clearInterval(intervalId);
|
|
2915
|
+
intervalId = setInterval(sendPing, intervalMs);
|
|
2916
|
+
}
|
|
2917
|
+
if (pingableConnections.has(connection) === false) {
|
|
2918
|
+
pingableConnections.set(connection, {
|
|
2919
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
2920
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
|
|
2921
|
+
restartPingTimer();
|
|
2922
|
+
return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
|
|
2923
|
+
}
|
|
2924
|
+
});
|
|
2925
|
+
(async () => {
|
|
2926
|
+
try {
|
|
2927
|
+
for await (const _ of connection) {
|
|
2928
|
+
restartPingTimer();
|
|
2929
|
+
}
|
|
2930
|
+
} catch {
|
|
2931
|
+
} finally {
|
|
2932
|
+
pingableConnections.delete(connection);
|
|
2933
|
+
clearInterval(intervalId);
|
|
2934
|
+
if (handleOffline) {
|
|
2935
|
+
globalThis.window.removeEventListener("offline", handleOffline);
|
|
2936
|
+
}
|
|
2937
|
+
if (handleOnline) {
|
|
2938
|
+
globalThis.window.removeEventListener("online", handleOnline);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
})();
|
|
2942
|
+
if (globalThis.navigator.onLine) {
|
|
2943
|
+
restartPingTimer();
|
|
2944
|
+
}
|
|
2945
|
+
let handleOffline;
|
|
2946
|
+
let handleOnline;
|
|
2947
|
+
{
|
|
2948
|
+
handleOffline = () => {
|
|
2949
|
+
clearInterval(intervalId);
|
|
2950
|
+
};
|
|
2951
|
+
handleOnline = () => {
|
|
2952
|
+
sendPing();
|
|
2953
|
+
restartPingTimer();
|
|
2954
|
+
};
|
|
2955
|
+
globalThis.window.addEventListener("offline", handleOffline);
|
|
2956
|
+
globalThis.window.addEventListener("online", handleOnline);
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
return pingableConnections.get(connection);
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
// src/rpc-websocket-connection-sharding.ts
|
|
2964
|
+
init_env_shim();
|
|
2965
|
+
var NULL_SHARD_CACHE_KEY = Symbol(
|
|
2966
|
+
"Cache key to use when there is no connection sharding strategy"
|
|
2967
|
+
);
|
|
2968
|
+
function getWebSocketTransportWithConnectionSharding({ getShard, transport }) {
|
|
2969
|
+
return getCachedAbortableIterableFactory({
|
|
2970
|
+
getAbortSignalFromInputArgs: ({ signal }) => signal,
|
|
2971
|
+
getCacheEntryMissingError(shardKey) {
|
|
2972
|
+
return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
|
|
2973
|
+
},
|
|
2974
|
+
getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
|
|
2975
|
+
onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
|
|
2976
|
+
onCreateIterable: (abortSignal, config) => transport({
|
|
2977
|
+
...config,
|
|
2978
|
+
signal: abortSignal
|
|
2979
|
+
})
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
// src/rpc-websocket-transport.ts
|
|
2984
|
+
function createDefaultRpcSubscriptionsTransport(config) {
|
|
2985
|
+
const { getShard, intervalMs, ...rest } = config;
|
|
2986
|
+
return pipe(
|
|
2987
|
+
createWebSocketTransport({
|
|
2988
|
+
...rest,
|
|
2989
|
+
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
2990
|
+
131072
|
|
2991
|
+
}),
|
|
2992
|
+
(transport) => getWebSocketTransportWithAutoping({
|
|
2993
|
+
intervalMs: intervalMs ?? 5e3,
|
|
2994
|
+
transport
|
|
2995
|
+
}),
|
|
2996
|
+
(transport) => getWebSocketTransportWithConnectionSharding({
|
|
2997
|
+
getShard,
|
|
2998
|
+
transport
|
|
2999
|
+
})
|
|
2239
3000
|
);
|
|
2240
3001
|
}
|
|
2241
3002
|
|
|
2242
3003
|
exports.AccountRole = AccountRole;
|
|
3004
|
+
exports.address = address;
|
|
2243
3005
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
2244
3006
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
2245
3007
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
2246
3008
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
3009
|
+
exports.createAddressWithSeed = createAddressWithSeed;
|
|
3010
|
+
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
2247
3011
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
2248
3012
|
exports.createSolanaRpc = createSolanaRpc;
|
|
3013
|
+
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
3014
|
+
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
2249
3015
|
exports.createTransaction = createTransaction;
|
|
2250
3016
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
2251
3017
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
@@ -2255,6 +3021,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2255
3021
|
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
2256
3022
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2257
3023
|
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
3024
|
+
exports.isBase58EncodedAddress = isBase58EncodedAddress;
|
|
2258
3025
|
exports.isSignerRole = isSignerRole;
|
|
2259
3026
|
exports.isWritableRole = isWritableRole;
|
|
2260
3027
|
exports.mergeRoles = mergeRoles;
|