@solana/web3.js 2.0.0-experimental.91615fc → 2.0.0-experimental.91700ed
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 +19 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +16 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +612 -127
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +16 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +19 -4
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +16 -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/index.d.ts.map +1 -0
- package/dist/types/rpc-default-config.d.ts.map +1 -0
- package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -0
- package/dist/types/rpc-request-coalescer.d.ts.map +1 -0
- package/dist/types/rpc-request-deduplication.d.ts.map +1 -0
- package/dist/types/rpc-transport.d.ts.map +1 -0
- package/dist/types/rpc-websocket-transport.d.ts +6 -0
- package/dist/types/rpc-websocket-transport.d.ts.map +1 -0
- package/dist/types/rpc.d.ts +4 -3
- package/dist/types/rpc.d.ts.map +1 -0
- package/package.json +14 -13
|
@@ -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,99 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1936
2149
|
function createJsonRpc(rpcConfig) {
|
|
1937
2150
|
return makeProxy(rpcConfig);
|
|
1938
2151
|
}
|
|
2152
|
+
function registerIterableFatal(iterable, catchFn) {
|
|
2153
|
+
(async () => {
|
|
2154
|
+
try {
|
|
2155
|
+
for await (const _ of iterable)
|
|
2156
|
+
;
|
|
2157
|
+
} catch (e3) {
|
|
2158
|
+
catchFn(e3);
|
|
2159
|
+
}
|
|
2160
|
+
})();
|
|
2161
|
+
}
|
|
2162
|
+
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
|
|
2163
|
+
return {
|
|
2164
|
+
async subscribe(options) {
|
|
2165
|
+
options?.abortSignal?.throwIfAborted();
|
|
2166
|
+
let subscriptionId;
|
|
2167
|
+
function handleCleanup() {
|
|
2168
|
+
if (subscriptionId !== void 0) {
|
|
2169
|
+
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
|
|
2170
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
|
|
2171
|
+
connectionAbortController.abort();
|
|
2172
|
+
});
|
|
2173
|
+
} else {
|
|
2174
|
+
connectionAbortController.abort();
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
options?.abortSignal?.addEventListener("abort", handleCleanup);
|
|
2178
|
+
const connectionAbortController = new AbortController();
|
|
2179
|
+
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
|
|
2180
|
+
const connection = await rpcConfig.transport({
|
|
2181
|
+
payload: subscribeMessage,
|
|
2182
|
+
signal: connectionAbortController.signal
|
|
2183
|
+
});
|
|
2184
|
+
function handleConnectionFatal() {
|
|
2185
|
+
options?.abortSignal?.removeEventListener("abort", handleCleanup);
|
|
2186
|
+
}
|
|
2187
|
+
registerIterableFatal(connection, handleConnectionFatal);
|
|
2188
|
+
for await (const message of connection) {
|
|
2189
|
+
if ("id" in message && message.id === subscribeMessage.id) {
|
|
2190
|
+
if ("error" in message) {
|
|
2191
|
+
throw new SolanaJsonRpcError(message.error);
|
|
2192
|
+
} else {
|
|
2193
|
+
subscriptionId = message.result;
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
if (subscriptionId == null) {
|
|
2199
|
+
throw new Error("Failed to obtain a subscription id from the server");
|
|
2200
|
+
}
|
|
2201
|
+
return {
|
|
2202
|
+
async *[Symbol.asyncIterator]() {
|
|
2203
|
+
for await (const message of connection) {
|
|
2204
|
+
if (!("params" in message) || message.params.subscription !== subscriptionId) {
|
|
2205
|
+
continue;
|
|
2206
|
+
}
|
|
2207
|
+
const notification = message.params.result;
|
|
2208
|
+
yield responseProcessor ? responseProcessor(notification) : notification;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2215
|
+
function makeProxy2(rpcConfig) {
|
|
2216
|
+
return new Proxy(rpcConfig.api, {
|
|
2217
|
+
defineProperty() {
|
|
2218
|
+
return false;
|
|
2219
|
+
},
|
|
2220
|
+
deleteProperty() {
|
|
2221
|
+
return false;
|
|
2222
|
+
},
|
|
2223
|
+
get(target, p, receiver) {
|
|
2224
|
+
return function(...rawParams) {
|
|
2225
|
+
const methodName = p.toString();
|
|
2226
|
+
const createRpcSubscription = Reflect.get(target, methodName, receiver);
|
|
2227
|
+
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
|
|
2228
|
+
throw new Error(
|
|
2229
|
+
"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."
|
|
2230
|
+
);
|
|
2231
|
+
}
|
|
2232
|
+
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
|
|
2233
|
+
params: rawParams,
|
|
2234
|
+
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
|
|
2235
|
+
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
|
|
2236
|
+
};
|
|
2237
|
+
return createPendingRpcSubscription(rpcConfig, newRequest);
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
function createJsonSubscriptionRpc(rpcConfig) {
|
|
2243
|
+
return makeProxy2(rpcConfig);
|
|
2244
|
+
}
|
|
1939
2245
|
var e = globalThis.fetch;
|
|
1940
2246
|
var SolanaHttpError = class extends Error {
|
|
1941
2247
|
constructor(details) {
|
|
@@ -2034,6 +2340,166 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2034
2340
|
return await response.json();
|
|
2035
2341
|
};
|
|
2036
2342
|
}
|
|
2343
|
+
var e2 = globalThis.WebSocket;
|
|
2344
|
+
async function createWebSocketConnection({
|
|
2345
|
+
sendBufferHighWatermark,
|
|
2346
|
+
signal,
|
|
2347
|
+
url
|
|
2348
|
+
}) {
|
|
2349
|
+
return new Promise((resolve, reject) => {
|
|
2350
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
2351
|
+
const iteratorState = /* @__PURE__ */ new Map();
|
|
2352
|
+
function handleAbort() {
|
|
2353
|
+
if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
|
|
2354
|
+
webSocket.close(1e3);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function handleClose(ev) {
|
|
2358
|
+
bufferDrainWatcher?.onCancel();
|
|
2359
|
+
signal.removeEventListener("abort", handleAbort);
|
|
2360
|
+
webSocket.removeEventListener("close", handleClose);
|
|
2361
|
+
webSocket.removeEventListener("error", handleError);
|
|
2362
|
+
webSocket.removeEventListener("open", handleOpen);
|
|
2363
|
+
webSocket.removeEventListener("message", handleMessage);
|
|
2364
|
+
iteratorState.forEach((state, iteratorKey) => {
|
|
2365
|
+
if (state.__hasPolled) {
|
|
2366
|
+
const { onError } = state;
|
|
2367
|
+
iteratorState.delete(iteratorKey);
|
|
2368
|
+
onError(ev);
|
|
2369
|
+
} else {
|
|
2370
|
+
iteratorState.delete(iteratorKey);
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
function handleError(ev) {
|
|
2375
|
+
if (!hasConnected) {
|
|
2376
|
+
reject(
|
|
2377
|
+
// TODO: Coded error
|
|
2378
|
+
new Error("WebSocket failed to connect", { cause: ev })
|
|
2379
|
+
);
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
let hasConnected = false;
|
|
2383
|
+
let bufferDrainWatcher;
|
|
2384
|
+
function handleOpen() {
|
|
2385
|
+
hasConnected = true;
|
|
2386
|
+
resolve({
|
|
2387
|
+
async send(payload) {
|
|
2388
|
+
const message = JSON.stringify(payload);
|
|
2389
|
+
if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
|
2390
|
+
let onCancel;
|
|
2391
|
+
const promise = new Promise((resolve2, reject2) => {
|
|
2392
|
+
const intervalId = setInterval(() => {
|
|
2393
|
+
if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
|
2394
|
+
clearInterval(intervalId);
|
|
2395
|
+
bufferDrainWatcher = void 0;
|
|
2396
|
+
resolve2();
|
|
2397
|
+
}
|
|
2398
|
+
}, 16);
|
|
2399
|
+
onCancel = () => {
|
|
2400
|
+
bufferDrainWatcher = void 0;
|
|
2401
|
+
clearInterval(intervalId);
|
|
2402
|
+
reject2(
|
|
2403
|
+
// TODO: Coded error
|
|
2404
|
+
new Error("WebSocket was closed before payload could be sent")
|
|
2405
|
+
);
|
|
2406
|
+
};
|
|
2407
|
+
});
|
|
2408
|
+
bufferDrainWatcher = {
|
|
2409
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2410
|
+
// @ts-ignore
|
|
2411
|
+
onCancel,
|
|
2412
|
+
promise
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
if (bufferDrainWatcher) {
|
|
2416
|
+
await bufferDrainWatcher.promise;
|
|
2417
|
+
}
|
|
2418
|
+
webSocket.send(message);
|
|
2419
|
+
},
|
|
2420
|
+
async *[Symbol.asyncIterator]() {
|
|
2421
|
+
const iteratorKey = Symbol();
|
|
2422
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
2423
|
+
try {
|
|
2424
|
+
while (true) {
|
|
2425
|
+
const state = iteratorState.get(iteratorKey);
|
|
2426
|
+
if (!state) {
|
|
2427
|
+
throw new Error("Invariant: WebSocket message iterator is missing state storage");
|
|
2428
|
+
}
|
|
2429
|
+
if (state.__hasPolled) {
|
|
2430
|
+
throw new Error(
|
|
2431
|
+
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
|
|
2432
|
+
);
|
|
2433
|
+
}
|
|
2434
|
+
const queuedMessages = state.queuedMessages;
|
|
2435
|
+
if (queuedMessages.length) {
|
|
2436
|
+
state.queuedMessages = [];
|
|
2437
|
+
yield* queuedMessages;
|
|
2438
|
+
} else {
|
|
2439
|
+
try {
|
|
2440
|
+
yield await new Promise((onMessage, onError) => {
|
|
2441
|
+
iteratorState.set(iteratorKey, {
|
|
2442
|
+
__hasPolled: true,
|
|
2443
|
+
onError,
|
|
2444
|
+
onMessage
|
|
2445
|
+
});
|
|
2446
|
+
});
|
|
2447
|
+
} catch (e3) {
|
|
2448
|
+
if (e3 !== null && typeof e3 === "object" && "type" in e3 && e3.type === "close" && "wasClean" in e3 && e3.wasClean) {
|
|
2449
|
+
return;
|
|
2450
|
+
} else {
|
|
2451
|
+
throw new Error("WebSocket connection closed", { cause: e3 });
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
} finally {
|
|
2457
|
+
iteratorState.delete(iteratorKey);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
function handleMessage({ data }) {
|
|
2463
|
+
const message = JSON.parse(data);
|
|
2464
|
+
iteratorState.forEach((state, iteratorKey) => {
|
|
2465
|
+
if (state.__hasPolled) {
|
|
2466
|
+
const { onMessage } = state;
|
|
2467
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
2468
|
+
onMessage(message);
|
|
2469
|
+
} else {
|
|
2470
|
+
state.queuedMessages.push(message);
|
|
2471
|
+
}
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
const webSocket = new e2(url);
|
|
2475
|
+
webSocket.addEventListener("close", handleClose);
|
|
2476
|
+
webSocket.addEventListener("error", handleError);
|
|
2477
|
+
webSocket.addEventListener("open", handleOpen);
|
|
2478
|
+
webSocket.addEventListener("message", handleMessage);
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
|
|
2482
|
+
if (/^wss?:/i.test(url) === false) {
|
|
2483
|
+
const protocolMatch = url.match(/^([^:]+):/);
|
|
2484
|
+
throw new DOMException(
|
|
2485
|
+
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.`
|
|
2486
|
+
);
|
|
2487
|
+
}
|
|
2488
|
+
return async function sendWebSocketMessage({ payload, signal }) {
|
|
2489
|
+
signal?.throwIfAborted();
|
|
2490
|
+
const connection = await createWebSocketConnection({
|
|
2491
|
+
sendBufferHighWatermark,
|
|
2492
|
+
signal,
|
|
2493
|
+
url
|
|
2494
|
+
});
|
|
2495
|
+
signal?.throwIfAborted();
|
|
2496
|
+
await connection.send(payload);
|
|
2497
|
+
return {
|
|
2498
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
2499
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
|
|
2500
|
+
};
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2037
2503
|
|
|
2038
2504
|
// src/rpc-default-config.ts
|
|
2039
2505
|
init_env_shim();
|
|
@@ -2082,6 +2548,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2082
2548
|
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
2083
2549
|
});
|
|
2084
2550
|
}
|
|
2551
|
+
function createSolanaRpcSubscriptions(config) {
|
|
2552
|
+
return createJsonSubscriptionRpc({
|
|
2553
|
+
...config,
|
|
2554
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2085
2557
|
|
|
2086
2558
|
// src/rpc-transport.ts
|
|
2087
2559
|
init_env_shim();
|
|
@@ -2118,14 +2590,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2118
2590
|
if (signal) {
|
|
2119
2591
|
const responsePromise = coalescedRequest.responsePromise;
|
|
2120
2592
|
return await new Promise((resolve, reject) => {
|
|
2121
|
-
const handleAbort = (
|
|
2593
|
+
const handleAbort = (e3) => {
|
|
2122
2594
|
signal.removeEventListener("abort", handleAbort);
|
|
2123
2595
|
coalescedRequest.numConsumers -= 1;
|
|
2124
2596
|
if (coalescedRequest.numConsumers === 0) {
|
|
2125
2597
|
const abortController = coalescedRequest.abortController;
|
|
2126
2598
|
abortController.abort();
|
|
2127
2599
|
}
|
|
2128
|
-
const abortError = new DOMException(
|
|
2600
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
2129
2601
|
reject(abortError);
|
|
2130
2602
|
};
|
|
2131
2603
|
signal.addEventListener("abort", handleAbort);
|
|
@@ -2175,20 +2647,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2175
2647
|
);
|
|
2176
2648
|
}
|
|
2177
2649
|
|
|
2650
|
+
// src/rpc-websocket-transport.ts
|
|
2651
|
+
init_env_shim();
|
|
2652
|
+
function createDefaultRpcSubscriptionsTransport(config) {
|
|
2653
|
+
return createWebSocketTransport({
|
|
2654
|
+
...config,
|
|
2655
|
+
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
2656
|
+
131072
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2178
2660
|
exports.AccountRole = AccountRole;
|
|
2179
2661
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
2180
2662
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
2181
2663
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
2182
2664
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
2665
|
+
exports.createAddressWithSeed = createAddressWithSeed;
|
|
2666
|
+
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
2183
2667
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
2184
2668
|
exports.createSolanaRpc = createSolanaRpc;
|
|
2669
|
+
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
2185
2670
|
exports.createTransaction = createTransaction;
|
|
2186
2671
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
2187
2672
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
2188
2673
|
exports.generateKeyPair = generateKeyPair;
|
|
2674
|
+
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
2189
2675
|
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
2190
2676
|
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
2191
|
-
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
|
|
2192
2677
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2193
2678
|
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
2194
2679
|
exports.isSignerRole = isSignerRole;
|