@solana/web3.js 2.0.0-experimental.91405cb → 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 +25 -3
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +17 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +869 -210
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +17 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +25 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +17 -3
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +33 -29
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- 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 -1
- package/package.json +14 -16
|
@@ -12,8 +12,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
12
12
|
var __esm = (fn, res) => function __init() {
|
|
13
13
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
14
|
};
|
|
15
|
-
var __commonJS = (cb,
|
|
16
|
-
return
|
|
15
|
+
var __commonJS = (cb, mod2) => function __require() {
|
|
16
|
+
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
17
17
|
};
|
|
18
18
|
var __copyProps = (to, from, except, desc) => {
|
|
19
19
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -23,13 +23,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
23
23
|
}
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
|
-
var __toESM = (
|
|
26
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
27
27
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
28
|
// file that has been converted to a CommonJS file using a Babel-
|
|
29
29
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
30
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !
|
|
32
|
-
|
|
31
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
32
|
+
mod2
|
|
33
33
|
));
|
|
34
34
|
var __publicField = (obj, key, value) => {
|
|
35
35
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -122,53 +122,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
122
122
|
// src/index.ts
|
|
123
123
|
init_env_shim();
|
|
124
124
|
|
|
125
|
-
// ../
|
|
126
|
-
init_env_shim();
|
|
127
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
128
|
-
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
129
|
-
3] = "WRITABLE_SIGNER";
|
|
130
|
-
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
131
|
-
2] = "READONLY_SIGNER";
|
|
132
|
-
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
133
|
-
1] = "WRITABLE";
|
|
134
|
-
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
135
|
-
0] = "READONLY";
|
|
136
|
-
return AccountRole22;
|
|
137
|
-
})(AccountRole || {});
|
|
138
|
-
var IS_SIGNER_BITMASK = 2;
|
|
139
|
-
var IS_WRITABLE_BITMASK = 1;
|
|
140
|
-
function downgradeRoleToNonSigner(role) {
|
|
141
|
-
return role & ~IS_SIGNER_BITMASK;
|
|
142
|
-
}
|
|
143
|
-
function downgradeRoleToReadonly(role) {
|
|
144
|
-
return role & ~IS_WRITABLE_BITMASK;
|
|
145
|
-
}
|
|
146
|
-
function isSignerRole(role) {
|
|
147
|
-
return role >= 2;
|
|
148
|
-
}
|
|
149
|
-
function isWritableRole(role) {
|
|
150
|
-
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
151
|
-
}
|
|
152
|
-
function mergeRoles(roleA, roleB) {
|
|
153
|
-
return roleA | roleB;
|
|
154
|
-
}
|
|
155
|
-
function upgradeRoleToSigner(role) {
|
|
156
|
-
return role | IS_SIGNER_BITMASK;
|
|
157
|
-
}
|
|
158
|
-
function upgradeRoleToWritable(role) {
|
|
159
|
-
return role | IS_WRITABLE_BITMASK;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ../keys/dist/index.browser.js
|
|
125
|
+
// ../addresses/dist/index.browser.js
|
|
163
126
|
init_env_shim();
|
|
164
127
|
|
|
165
|
-
// ../../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
|
|
166
129
|
init_env_shim();
|
|
167
130
|
|
|
168
|
-
// ../../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
|
|
169
132
|
init_env_shim();
|
|
170
133
|
|
|
171
|
-
// ../../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
|
|
172
135
|
init_env_shim();
|
|
173
136
|
var mergeBytes = (bytesArr) => {
|
|
174
137
|
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
@@ -189,7 +152,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
189
152
|
};
|
|
190
153
|
var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
|
|
191
154
|
|
|
192
|
-
// ../../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
|
|
193
156
|
init_env_shim();
|
|
194
157
|
var DeserializingEmptyBufferError = class extends Error {
|
|
195
158
|
constructor(serializer) {
|
|
@@ -211,7 +174,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
211
174
|
}
|
|
212
175
|
};
|
|
213
176
|
|
|
214
|
-
// ../../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
|
|
215
178
|
init_env_shim();
|
|
216
179
|
function fixSerializer(serializer, fixedBytes, description) {
|
|
217
180
|
return {
|
|
@@ -233,7 +196,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
233
196
|
};
|
|
234
197
|
}
|
|
235
198
|
|
|
236
|
-
// ../../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
|
|
237
200
|
init_env_shim();
|
|
238
201
|
function mapSerializer(serializer, unmap, map) {
|
|
239
202
|
return {
|
|
@@ -248,13 +211,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
248
211
|
};
|
|
249
212
|
}
|
|
250
213
|
|
|
251
|
-
// ../../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
|
|
252
215
|
init_env_shim();
|
|
253
216
|
|
|
254
|
-
// ../../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
|
|
255
218
|
init_env_shim();
|
|
256
219
|
|
|
257
|
-
// ../../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
|
|
258
221
|
init_env_shim();
|
|
259
222
|
var InvalidBaseStringError = class extends Error {
|
|
260
223
|
constructor(value, base, cause) {
|
|
@@ -265,7 +228,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
265
228
|
}
|
|
266
229
|
};
|
|
267
230
|
|
|
268
|
-
// ../../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
|
|
269
232
|
var baseX = (alphabet) => {
|
|
270
233
|
const base = alphabet.length;
|
|
271
234
|
const baseBigInt = BigInt(base);
|
|
@@ -319,18 +282,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
319
282
|
};
|
|
320
283
|
};
|
|
321
284
|
|
|
322
|
-
// ../../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
|
|
323
286
|
init_env_shim();
|
|
324
287
|
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
325
288
|
|
|
326
|
-
// ../../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
|
|
327
290
|
init_env_shim();
|
|
328
291
|
var removeNullCharacters = (value) => (
|
|
329
292
|
// eslint-disable-next-line no-control-regex
|
|
330
293
|
value.replace(/\u0000/g, "")
|
|
331
294
|
);
|
|
332
295
|
|
|
333
|
-
// ../../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
|
|
334
297
|
init_env_shim();
|
|
335
298
|
var utf8 = {
|
|
336
299
|
description: "utf8",
|
|
@@ -345,10 +308,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
345
308
|
}
|
|
346
309
|
};
|
|
347
310
|
|
|
348
|
-
// ../../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
|
|
349
312
|
init_env_shim();
|
|
350
313
|
|
|
351
|
-
// ../../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
|
|
352
315
|
init_env_shim();
|
|
353
316
|
var Endian;
|
|
354
317
|
(function(Endian2) {
|
|
@@ -356,7 +319,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
356
319
|
Endian2["Big"] = "be";
|
|
357
320
|
})(Endian || (Endian = {}));
|
|
358
321
|
|
|
359
|
-
// ../../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
|
|
360
323
|
init_env_shim();
|
|
361
324
|
var NumberOutOfRangeError = class extends RangeError {
|
|
362
325
|
constructor(serializer, min, max, actual) {
|
|
@@ -365,7 +328,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
365
328
|
}
|
|
366
329
|
};
|
|
367
330
|
|
|
368
|
-
// ../../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
|
|
369
332
|
init_env_shim();
|
|
370
333
|
function numberFactory(input) {
|
|
371
334
|
let littleEndian;
|
|
@@ -410,7 +373,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
410
373
|
}
|
|
411
374
|
};
|
|
412
375
|
|
|
413
|
-
// ../../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
|
|
414
377
|
init_env_shim();
|
|
415
378
|
var u8 = (options = {}) => numberFactory({
|
|
416
379
|
name: "u8",
|
|
@@ -421,7 +384,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
421
384
|
options
|
|
422
385
|
});
|
|
423
386
|
|
|
424
|
-
// ../../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
|
|
425
388
|
init_env_shim();
|
|
426
389
|
var u32 = (options = {}) => numberFactory({
|
|
427
390
|
name: "u32",
|
|
@@ -432,7 +395,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
432
395
|
options
|
|
433
396
|
});
|
|
434
397
|
|
|
435
|
-
// ../../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
|
|
436
399
|
init_env_shim();
|
|
437
400
|
var shortU16 = (options = {}) => ({
|
|
438
401
|
description: options.description ?? "shortU16",
|
|
@@ -470,10 +433,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
470
433
|
}
|
|
471
434
|
});
|
|
472
435
|
|
|
473
|
-
// ../../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
|
|
474
437
|
init_env_shim();
|
|
475
438
|
|
|
476
|
-
// ../../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
|
|
477
440
|
init_env_shim();
|
|
478
441
|
var InvalidNumberOfItemsError = class extends Error {
|
|
479
442
|
constructor(serializer, expected, actual) {
|
|
@@ -494,16 +457,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
494
457
|
}
|
|
495
458
|
};
|
|
496
459
|
|
|
497
|
-
// ../../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
|
|
498
461
|
init_env_shim();
|
|
499
462
|
|
|
500
|
-
// ../../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
|
|
501
464
|
init_env_shim();
|
|
502
465
|
function sumSerializerSizes(sizes) {
|
|
503
466
|
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
504
467
|
}
|
|
505
468
|
|
|
506
|
-
// ../../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
|
|
507
470
|
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
508
471
|
if (typeof size === "number") {
|
|
509
472
|
return [size, offset];
|
|
@@ -539,7 +502,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
539
502
|
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
540
503
|
}
|
|
541
504
|
|
|
542
|
-
// ../../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
|
|
543
506
|
function array(item, options = {}) {
|
|
544
507
|
const size = options.size ?? u32();
|
|
545
508
|
if (size === "remainder" && item.fixedSize === null) {
|
|
@@ -572,7 +535,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
572
535
|
};
|
|
573
536
|
}
|
|
574
537
|
|
|
575
|
-
// ../../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
|
|
576
539
|
init_env_shim();
|
|
577
540
|
function bytes(options = {}) {
|
|
578
541
|
const size = options.size ?? "variable";
|
|
@@ -620,7 +583,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
620
583
|
};
|
|
621
584
|
}
|
|
622
585
|
|
|
623
|
-
// ../../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
|
|
624
587
|
init_env_shim();
|
|
625
588
|
function string(options = {}) {
|
|
626
589
|
const size = options.size ?? u32();
|
|
@@ -662,7 +625,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
662
625
|
};
|
|
663
626
|
}
|
|
664
627
|
|
|
665
|
-
// ../../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
|
|
666
629
|
init_env_shim();
|
|
667
630
|
function struct(fields, options = {}) {
|
|
668
631
|
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
@@ -685,43 +648,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
685
648
|
}
|
|
686
649
|
};
|
|
687
650
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
// Lowest address (32 bytes of zeroes)
|
|
692
|
-
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
693
|
-
putativeBase58EncodedAddress.length > 44
|
|
694
|
-
) {
|
|
695
|
-
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
696
|
-
}
|
|
697
|
-
const bytes2 = base58.serialize(putativeBase58EncodedAddress);
|
|
698
|
-
const numBytes = bytes2.byteLength;
|
|
699
|
-
if (numBytes !== 32) {
|
|
700
|
-
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
701
|
-
}
|
|
702
|
-
} catch (e2) {
|
|
703
|
-
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
704
|
-
cause: e2
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
function getBase58EncodedAddressCodec(config) {
|
|
709
|
-
return string({
|
|
710
|
-
description: config?.description ?? ("A 32-byte account address" ),
|
|
711
|
-
encoding: base58,
|
|
712
|
-
size: 32
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
function getBase58EncodedAddressComparator() {
|
|
716
|
-
return new Intl.Collator("en", {
|
|
717
|
-
caseFirst: "lower",
|
|
718
|
-
ignorePunctuation: false,
|
|
719
|
-
localeMatcher: "best fit",
|
|
720
|
-
numeric: false,
|
|
721
|
-
sensitivity: "variant",
|
|
722
|
-
usage: "sort"
|
|
723
|
-
}).compare;
|
|
724
|
-
}
|
|
651
|
+
|
|
652
|
+
// ../assertions/dist/index.browser.js
|
|
653
|
+
init_env_shim();
|
|
725
654
|
function assertIsSecureContext() {
|
|
726
655
|
if (!globalThis.isSecureContext) {
|
|
727
656
|
throw new Error(
|
|
@@ -751,6 +680,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
751
680
|
return await cachedEd25519Decision;
|
|
752
681
|
}
|
|
753
682
|
}
|
|
683
|
+
async function assertDigestCapabilityIsAvailable() {
|
|
684
|
+
assertIsSecureContext();
|
|
685
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
|
|
686
|
+
throw new Error("No digest implementation could be found");
|
|
687
|
+
}
|
|
688
|
+
}
|
|
754
689
|
async function assertKeyGenerationIsAvailable() {
|
|
755
690
|
assertIsSecureContext();
|
|
756
691
|
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
|
|
@@ -780,6 +715,274 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
780
715
|
throw new Error("No signature verification implementation could be found");
|
|
781
716
|
}
|
|
782
717
|
}
|
|
718
|
+
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
719
|
+
try {
|
|
720
|
+
if (
|
|
721
|
+
// Lowest address (32 bytes of zeroes)
|
|
722
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
723
|
+
putativeBase58EncodedAddress.length > 44
|
|
724
|
+
) {
|
|
725
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
726
|
+
}
|
|
727
|
+
const bytes2 = base58.serialize(putativeBase58EncodedAddress);
|
|
728
|
+
const numBytes = bytes2.byteLength;
|
|
729
|
+
if (numBytes !== 32) {
|
|
730
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
731
|
+
}
|
|
732
|
+
} catch (e3) {
|
|
733
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
734
|
+
cause: e3
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function getBase58EncodedAddressCodec(config) {
|
|
739
|
+
return string({
|
|
740
|
+
description: config?.description ?? ("A 32-byte account address" ),
|
|
741
|
+
encoding: base58,
|
|
742
|
+
size: 32
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
function getBase58EncodedAddressComparator() {
|
|
746
|
+
return new Intl.Collator("en", {
|
|
747
|
+
caseFirst: "lower",
|
|
748
|
+
ignorePunctuation: false,
|
|
749
|
+
localeMatcher: "best fit",
|
|
750
|
+
numeric: false,
|
|
751
|
+
sensitivity: "variant",
|
|
752
|
+
usage: "sort"
|
|
753
|
+
}).compare;
|
|
754
|
+
}
|
|
755
|
+
var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
|
|
756
|
+
var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
|
|
757
|
+
var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
|
|
758
|
+
function mod(a) {
|
|
759
|
+
const r = a % P;
|
|
760
|
+
return r >= 0n ? r : P + r;
|
|
761
|
+
}
|
|
762
|
+
function pow2(x, power) {
|
|
763
|
+
let r = x;
|
|
764
|
+
while (power-- > 0n) {
|
|
765
|
+
r *= r;
|
|
766
|
+
r %= P;
|
|
767
|
+
}
|
|
768
|
+
return r;
|
|
769
|
+
}
|
|
770
|
+
function pow_2_252_3(x) {
|
|
771
|
+
const x2 = x * x % P;
|
|
772
|
+
const b2 = x2 * x % P;
|
|
773
|
+
const b4 = pow2(b2, 2n) * b2 % P;
|
|
774
|
+
const b5 = pow2(b4, 1n) * x % P;
|
|
775
|
+
const b10 = pow2(b5, 5n) * b5 % P;
|
|
776
|
+
const b20 = pow2(b10, 10n) * b10 % P;
|
|
777
|
+
const b40 = pow2(b20, 20n) * b20 % P;
|
|
778
|
+
const b80 = pow2(b40, 40n) * b40 % P;
|
|
779
|
+
const b160 = pow2(b80, 80n) * b80 % P;
|
|
780
|
+
const b240 = pow2(b160, 80n) * b80 % P;
|
|
781
|
+
const b250 = pow2(b240, 10n) * b10 % P;
|
|
782
|
+
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
783
|
+
return pow_p_5_8;
|
|
784
|
+
}
|
|
785
|
+
function uvRatio(u, v) {
|
|
786
|
+
const v3 = mod(v * v * v);
|
|
787
|
+
const v7 = mod(v3 * v3 * v);
|
|
788
|
+
const pow = pow_2_252_3(u * v7);
|
|
789
|
+
let x = mod(u * v3 * pow);
|
|
790
|
+
const vx2 = mod(v * x * x);
|
|
791
|
+
const root1 = x;
|
|
792
|
+
const root2 = mod(x * RM1);
|
|
793
|
+
const useRoot1 = vx2 === u;
|
|
794
|
+
const useRoot2 = vx2 === mod(-u);
|
|
795
|
+
const noRoot = vx2 === mod(-u * RM1);
|
|
796
|
+
if (useRoot1)
|
|
797
|
+
x = root1;
|
|
798
|
+
if (useRoot2 || noRoot)
|
|
799
|
+
x = root2;
|
|
800
|
+
if ((mod(x) & 1n) === 1n)
|
|
801
|
+
x = mod(-x);
|
|
802
|
+
if (!useRoot1 && !useRoot2) {
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
return x;
|
|
806
|
+
}
|
|
807
|
+
function pointIsOnCurve(y, lastByte) {
|
|
808
|
+
const y2 = mod(y * y);
|
|
809
|
+
const u = mod(y2 - 1n);
|
|
810
|
+
const v = mod(D * y2 + 1n);
|
|
811
|
+
const x = uvRatio(u, v);
|
|
812
|
+
if (x === null) {
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
816
|
+
if (x === 0n && isLastByteOdd) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
function byteToHex(byte) {
|
|
822
|
+
const hexString = byte.toString(16);
|
|
823
|
+
if (hexString.length === 1) {
|
|
824
|
+
return `0${hexString}`;
|
|
825
|
+
} else {
|
|
826
|
+
return hexString;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
function decompressPointBytes(bytes2) {
|
|
830
|
+
const hexString = bytes2.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
|
|
831
|
+
const integerLiteralString = `0x${hexString}`;
|
|
832
|
+
return BigInt(integerLiteralString);
|
|
833
|
+
}
|
|
834
|
+
async function compressedPointBytesAreOnCurve(bytes2) {
|
|
835
|
+
if (bytes2.byteLength !== 32) {
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
838
|
+
const y = decompressPointBytes(bytes2);
|
|
839
|
+
return pointIsOnCurve(y, bytes2[31]);
|
|
840
|
+
}
|
|
841
|
+
var MAX_SEED_LENGTH = 32;
|
|
842
|
+
var MAX_SEEDS = 16;
|
|
843
|
+
var PDA_MARKER_BYTES = [
|
|
844
|
+
// The string 'ProgramDerivedAddress'
|
|
845
|
+
80,
|
|
846
|
+
114,
|
|
847
|
+
111,
|
|
848
|
+
103,
|
|
849
|
+
114,
|
|
850
|
+
97,
|
|
851
|
+
109,
|
|
852
|
+
68,
|
|
853
|
+
101,
|
|
854
|
+
114,
|
|
855
|
+
105,
|
|
856
|
+
118,
|
|
857
|
+
101,
|
|
858
|
+
100,
|
|
859
|
+
65,
|
|
860
|
+
100,
|
|
861
|
+
100,
|
|
862
|
+
114,
|
|
863
|
+
101,
|
|
864
|
+
115,
|
|
865
|
+
115
|
|
866
|
+
];
|
|
867
|
+
var PointOnCurveError = class extends Error {
|
|
868
|
+
};
|
|
869
|
+
async function createProgramDerivedAddress({ programAddress, seeds }) {
|
|
870
|
+
await assertDigestCapabilityIsAvailable();
|
|
871
|
+
if (seeds.length > MAX_SEEDS) {
|
|
872
|
+
throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
|
|
873
|
+
}
|
|
874
|
+
let textEncoder;
|
|
875
|
+
const seedBytes = seeds.reduce((acc, seed, ii) => {
|
|
876
|
+
const bytes2 = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
|
|
877
|
+
if (bytes2.byteLength > MAX_SEED_LENGTH) {
|
|
878
|
+
throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
|
|
879
|
+
}
|
|
880
|
+
acc.push(...bytes2);
|
|
881
|
+
return acc;
|
|
882
|
+
}, []);
|
|
883
|
+
const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
|
|
884
|
+
const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
|
|
885
|
+
const addressBytesBuffer = await crypto.subtle.digest(
|
|
886
|
+
"SHA-256",
|
|
887
|
+
new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
|
|
888
|
+
);
|
|
889
|
+
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
890
|
+
if (await compressedPointBytesAreOnCurve(addressBytes)) {
|
|
891
|
+
throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
|
|
892
|
+
}
|
|
893
|
+
return base58EncodedAddressCodec.deserialize(addressBytes)[0];
|
|
894
|
+
}
|
|
895
|
+
async function getProgramDerivedAddress({ programAddress, seeds }) {
|
|
896
|
+
let bumpSeed = 255;
|
|
897
|
+
while (bumpSeed > 0) {
|
|
898
|
+
try {
|
|
899
|
+
return {
|
|
900
|
+
bumpSeed,
|
|
901
|
+
pda: await createProgramDerivedAddress({
|
|
902
|
+
programAddress,
|
|
903
|
+
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
904
|
+
})
|
|
905
|
+
};
|
|
906
|
+
} catch (e3) {
|
|
907
|
+
if (e3 instanceof PointOnCurveError) {
|
|
908
|
+
bumpSeed--;
|
|
909
|
+
} else {
|
|
910
|
+
throw e3;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
throw new Error("Unable to find a viable program address bump seed");
|
|
915
|
+
}
|
|
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) {
|
|
938
|
+
await assertKeyExporterIsAvailable();
|
|
939
|
+
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
940
|
+
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
941
|
+
}
|
|
942
|
+
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
943
|
+
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
944
|
+
return base58EncodedAddress;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// ../instructions/dist/index.browser.js
|
|
948
|
+
init_env_shim();
|
|
949
|
+
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
950
|
+
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
951
|
+
3] = "WRITABLE_SIGNER";
|
|
952
|
+
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
953
|
+
2] = "READONLY_SIGNER";
|
|
954
|
+
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
955
|
+
1] = "WRITABLE";
|
|
956
|
+
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
957
|
+
0] = "READONLY";
|
|
958
|
+
return AccountRole22;
|
|
959
|
+
})(AccountRole || {});
|
|
960
|
+
var IS_SIGNER_BITMASK = 2;
|
|
961
|
+
var IS_WRITABLE_BITMASK = 1;
|
|
962
|
+
function downgradeRoleToNonSigner(role) {
|
|
963
|
+
return role & ~IS_SIGNER_BITMASK;
|
|
964
|
+
}
|
|
965
|
+
function downgradeRoleToReadonly(role) {
|
|
966
|
+
return role & ~IS_WRITABLE_BITMASK;
|
|
967
|
+
}
|
|
968
|
+
function isSignerRole(role) {
|
|
969
|
+
return role >= 2;
|
|
970
|
+
}
|
|
971
|
+
function isWritableRole(role) {
|
|
972
|
+
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
973
|
+
}
|
|
974
|
+
function mergeRoles(roleA, roleB) {
|
|
975
|
+
return roleA | roleB;
|
|
976
|
+
}
|
|
977
|
+
function upgradeRoleToSigner(role) {
|
|
978
|
+
return role | IS_SIGNER_BITMASK;
|
|
979
|
+
}
|
|
980
|
+
function upgradeRoleToWritable(role) {
|
|
981
|
+
return role | IS_WRITABLE_BITMASK;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// ../keys/dist/index.browser.js
|
|
985
|
+
init_env_shim();
|
|
783
986
|
async function generateKeyPair() {
|
|
784
987
|
await assertKeyGenerationIsAvailable();
|
|
785
988
|
const keyPair = await crypto.subtle.generateKey(
|
|
@@ -794,15 +997,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
794
997
|
);
|
|
795
998
|
return keyPair;
|
|
796
999
|
}
|
|
797
|
-
async function getBase58EncodedAddressFromPublicKey(publicKey) {
|
|
798
|
-
await assertKeyExporterIsAvailable();
|
|
799
|
-
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
800
|
-
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
801
|
-
}
|
|
802
|
-
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
803
|
-
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
804
|
-
return base58EncodedAddress;
|
|
805
|
-
}
|
|
806
1000
|
async function signBytes(key, data) {
|
|
807
1001
|
await assertSigningCapabilityIsAvailable();
|
|
808
1002
|
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
@@ -841,9 +1035,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
841
1035
|
if (numBytes !== 32) {
|
|
842
1036
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
843
1037
|
}
|
|
844
|
-
} catch (
|
|
1038
|
+
} catch (e3) {
|
|
845
1039
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
846
|
-
cause:
|
|
1040
|
+
cause: e3
|
|
847
1041
|
});
|
|
848
1042
|
}
|
|
849
1043
|
}
|
|
@@ -1311,7 +1505,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1311
1505
|
)
|
|
1312
1506
|
],
|
|
1313
1507
|
[
|
|
1314
|
-
"
|
|
1508
|
+
"accountIndices",
|
|
1315
1509
|
array(
|
|
1316
1510
|
u8({
|
|
1317
1511
|
description: "The index of an account, according to the well-ordered accounts list for this transaction"
|
|
@@ -1331,23 +1525,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1331
1525
|
]
|
|
1332
1526
|
]),
|
|
1333
1527
|
(value) => {
|
|
1334
|
-
if (value.
|
|
1528
|
+
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1335
1529
|
return value;
|
|
1336
1530
|
}
|
|
1337
1531
|
return {
|
|
1338
1532
|
...value,
|
|
1339
|
-
|
|
1533
|
+
accountIndices: value.accountIndices ?? [],
|
|
1340
1534
|
data: value.data ?? new Uint8Array(0)
|
|
1341
1535
|
};
|
|
1342
1536
|
},
|
|
1343
1537
|
(value) => {
|
|
1344
|
-
if (value.
|
|
1538
|
+
if (value.accountIndices.length && value.data.byteLength) {
|
|
1345
1539
|
return value;
|
|
1346
1540
|
}
|
|
1347
|
-
const {
|
|
1541
|
+
const { accountIndices, data, ...rest } = value;
|
|
1348
1542
|
return {
|
|
1349
1543
|
...rest,
|
|
1350
|
-
...
|
|
1544
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1351
1545
|
...data.byteLength ? { data } : null
|
|
1352
1546
|
};
|
|
1353
1547
|
}
|
|
@@ -1470,7 +1664,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1470
1664
|
async function signTransaction(keyPair, transaction) {
|
|
1471
1665
|
const compiledMessage = compileMessage(transaction);
|
|
1472
1666
|
const [signerPublicKey, signature] = await Promise.all([
|
|
1473
|
-
|
|
1667
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1474
1668
|
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1475
1669
|
]);
|
|
1476
1670
|
const nextSignatures = {
|
|
@@ -1563,85 +1757,246 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1563
1757
|
return visitNode(params, [], onIntegerOverflow);
|
|
1564
1758
|
}
|
|
1565
1759
|
var KEYPATH_WILDCARD = {};
|
|
1566
|
-
var
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
"
|
|
1580
|
-
"data",
|
|
1581
|
-
"parsed",
|
|
1582
|
-
"info",
|
|
1583
|
-
"
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
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
|
+
}
|
|
1645
2000
|
function getNextAllowedKeypaths(keyPaths, property) {
|
|
1646
2001
|
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
1647
2002
|
}
|
|
@@ -1668,7 +2023,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1668
2023
|
}
|
|
1669
2024
|
}
|
|
1670
2025
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
1671
|
-
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;
|
|
1672
2031
|
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
1673
2032
|
}
|
|
1674
2033
|
function createSolanaRpcApi(config) {
|
|
@@ -1697,6 +2056,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1697
2056
|
}
|
|
1698
2057
|
});
|
|
1699
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
|
+
}
|
|
1700
2086
|
|
|
1701
2087
|
// ../rpc-transport/dist/index.browser.js
|
|
1702
2088
|
init_env_shim();
|
|
@@ -1763,6 +2149,99 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1763
2149
|
function createJsonRpc(rpcConfig) {
|
|
1764
2150
|
return makeProxy(rpcConfig);
|
|
1765
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
|
+
}
|
|
1766
2245
|
var e = globalThis.fetch;
|
|
1767
2246
|
var SolanaHttpError = class extends Error {
|
|
1768
2247
|
constructor(details) {
|
|
@@ -1861,6 +2340,166 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1861
2340
|
return await response.json();
|
|
1862
2341
|
};
|
|
1863
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
|
+
}
|
|
1864
2503
|
|
|
1865
2504
|
// src/rpc-default-config.ts
|
|
1866
2505
|
init_env_shim();
|
|
@@ -1909,6 +2548,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1909
2548
|
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
1910
2549
|
});
|
|
1911
2550
|
}
|
|
2551
|
+
function createSolanaRpcSubscriptions(config) {
|
|
2552
|
+
return createJsonSubscriptionRpc({
|
|
2553
|
+
...config,
|
|
2554
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
1912
2557
|
|
|
1913
2558
|
// src/rpc-transport.ts
|
|
1914
2559
|
init_env_shim();
|
|
@@ -1945,14 +2590,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1945
2590
|
if (signal) {
|
|
1946
2591
|
const responsePromise = coalescedRequest.responsePromise;
|
|
1947
2592
|
return await new Promise((resolve, reject) => {
|
|
1948
|
-
const handleAbort = (
|
|
2593
|
+
const handleAbort = (e3) => {
|
|
1949
2594
|
signal.removeEventListener("abort", handleAbort);
|
|
1950
2595
|
coalescedRequest.numConsumers -= 1;
|
|
1951
2596
|
if (coalescedRequest.numConsumers === 0) {
|
|
1952
2597
|
const abortController = coalescedRequest.abortController;
|
|
1953
2598
|
abortController.abort();
|
|
1954
2599
|
}
|
|
1955
|
-
const abortError = new DOMException(
|
|
2600
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
1956
2601
|
reject(abortError);
|
|
1957
2602
|
};
|
|
1958
2603
|
signal.addEventListener("abort", handleAbort);
|
|
@@ -2002,21 +2647,35 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2002
2647
|
);
|
|
2003
2648
|
}
|
|
2004
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
|
+
|
|
2005
2660
|
exports.AccountRole = AccountRole;
|
|
2006
2661
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
2007
2662
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
2008
2663
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
2009
2664
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
2665
|
+
exports.createAddressWithSeed = createAddressWithSeed;
|
|
2666
|
+
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
2010
2667
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
2011
2668
|
exports.createSolanaRpc = createSolanaRpc;
|
|
2669
|
+
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
2012
2670
|
exports.createTransaction = createTransaction;
|
|
2013
2671
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
2014
2672
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
2015
2673
|
exports.generateKeyPair = generateKeyPair;
|
|
2674
|
+
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
2016
2675
|
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
2017
2676
|
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
2018
|
-
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
|
|
2019
2677
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2678
|
+
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
2020
2679
|
exports.isSignerRole = isSignerRole;
|
|
2021
2680
|
exports.isWritableRole = isWritableRole;
|
|
2022
2681
|
exports.mergeRoles = mergeRoles;
|