@solana/web3.js 2.0.0-experimental.3244e3e → 2.0.0-experimental.3b1c7d5

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.
@@ -8,6 +8,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
8
8
  var __getOwnPropNames = Object.getOwnPropertyNames;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
12
  var __esm = (fn, res) => function __init() {
12
13
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
14
  };
@@ -30,6 +31,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
30
31
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
32
  mod
32
33
  ));
34
+ var __publicField = (obj, key, value) => {
35
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
+ return value;
37
+ };
33
38
 
34
39
  // ../build-scripts/env-shim.ts
35
40
  var init_env_shim = __esm({
@@ -37,153 +42,410 @@ this.globalThis.solanaWeb3 = (function (exports) {
37
42
  }
38
43
  });
39
44
 
40
- // ../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js
41
- var require_src = __commonJS({
42
- "../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js"(exports, module) {
45
+ // ../../node_modules/.pnpm/fast-stable-stringify@1.0.0/node_modules/fast-stable-stringify/index.js
46
+ var require_fast_stable_stringify = __commonJS({
47
+ "../../node_modules/.pnpm/fast-stable-stringify@1.0.0/node_modules/fast-stable-stringify/index.js"(exports, module) {
43
48
  init_env_shim();
44
- function base(ALPHABET) {
45
- if (ALPHABET.length >= 255) {
46
- throw new TypeError("Alphabet too long");
49
+ var objToString = Object.prototype.toString;
50
+ var objKeys = Object.keys || function(obj) {
51
+ var keys = [];
52
+ for (var name in obj) {
53
+ keys.push(name);
47
54
  }
48
- var BASE_MAP = new Uint8Array(256);
49
- for (var j = 0; j < BASE_MAP.length; j++) {
50
- BASE_MAP[j] = 255;
55
+ return keys;
56
+ };
57
+ function stringify(val, isArrayProp) {
58
+ var i, max, str, keys, key, propVal, toStr;
59
+ if (val === true) {
60
+ return "true";
51
61
  }
52
- for (var i = 0; i < ALPHABET.length; i++) {
53
- var x = ALPHABET.charAt(i);
54
- var xc = x.charCodeAt(0);
55
- if (BASE_MAP[xc] !== 255) {
56
- throw new TypeError(x + " is ambiguous");
57
- }
58
- BASE_MAP[xc] = i;
62
+ if (val === false) {
63
+ return "false";
59
64
  }
60
- var BASE = ALPHABET.length;
61
- var LEADER = ALPHABET.charAt(0);
62
- var FACTOR = Math.log(BASE) / Math.log(256);
63
- var iFACTOR = Math.log(256) / Math.log(BASE);
64
- function encode(source) {
65
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
66
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
67
- } else if (Array.isArray(source)) {
68
- source = Uint8Array.from(source);
69
- }
70
- if (!(source instanceof Uint8Array)) {
71
- throw new TypeError("Expected Uint8Array");
72
- }
73
- if (source.length === 0) {
74
- return "";
75
- }
76
- var zeroes = 0;
77
- var length = 0;
78
- var pbegin = 0;
79
- var pend = source.length;
80
- while (pbegin !== pend && source[pbegin] === 0) {
81
- pbegin++;
82
- zeroes++;
83
- }
84
- var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
85
- var b58 = new Uint8Array(size);
86
- while (pbegin !== pend) {
87
- var carry = source[pbegin];
88
- var i2 = 0;
89
- for (var it1 = size - 1; (carry !== 0 || i2 < length) && it1 !== -1; it1--, i2++) {
90
- carry += 256 * b58[it1] >>> 0;
91
- b58[it1] = carry % BASE >>> 0;
92
- carry = carry / BASE >>> 0;
93
- }
94
- if (carry !== 0) {
95
- throw new Error("Non-zero carry");
65
+ switch (typeof val) {
66
+ case "object":
67
+ if (val === null) {
68
+ return null;
69
+ } else if (val.toJSON && typeof val.toJSON === "function") {
70
+ return stringify(val.toJSON(), isArrayProp);
71
+ } else {
72
+ toStr = objToString.call(val);
73
+ if (toStr === "[object Array]") {
74
+ str = "[";
75
+ max = val.length - 1;
76
+ for (i = 0; i < max; i++) {
77
+ str += stringify(val[i], true) + ",";
78
+ }
79
+ if (max > -1) {
80
+ str += stringify(val[i], true);
81
+ }
82
+ return str + "]";
83
+ } else if (toStr === "[object Object]") {
84
+ keys = objKeys(val).sort();
85
+ max = keys.length;
86
+ str = "";
87
+ i = 0;
88
+ while (i < max) {
89
+ key = keys[i];
90
+ propVal = stringify(val[key], false);
91
+ if (propVal !== void 0) {
92
+ if (str) {
93
+ str += ",";
94
+ }
95
+ str += JSON.stringify(key) + ":" + propVal;
96
+ }
97
+ i++;
98
+ }
99
+ return "{" + str + "}";
100
+ } else {
101
+ return JSON.stringify(val);
102
+ }
96
103
  }
97
- length = i2;
98
- pbegin++;
99
- }
100
- var it2 = size - length;
101
- while (it2 !== size && b58[it2] === 0) {
102
- it2++;
103
- }
104
- var str = LEADER.repeat(zeroes);
105
- for (; it2 < size; ++it2) {
106
- str += ALPHABET.charAt(b58[it2]);
107
- }
108
- return str;
104
+ case "function":
105
+ case "undefined":
106
+ return isArrayProp ? null : void 0;
107
+ case "string":
108
+ return JSON.stringify(val);
109
+ default:
110
+ return isFinite(val) ? val : null;
109
111
  }
110
- function decodeUnsafe(source) {
111
- if (typeof source !== "string") {
112
- throw new TypeError("Expected String");
113
- }
114
- if (source.length === 0) {
115
- return new Uint8Array();
116
- }
117
- var psz = 0;
118
- var zeroes = 0;
119
- var length = 0;
120
- while (source[psz] === LEADER) {
121
- zeroes++;
122
- psz++;
123
- }
124
- var size = (source.length - psz) * FACTOR + 1 >>> 0;
125
- var b256 = new Uint8Array(size);
126
- while (source[psz]) {
127
- var carry = BASE_MAP[source.charCodeAt(psz)];
128
- if (carry === 255) {
129
- return;
130
- }
131
- var i2 = 0;
132
- for (var it3 = size - 1; (carry !== 0 || i2 < length) && it3 !== -1; it3--, i2++) {
133
- carry += BASE * b256[it3] >>> 0;
134
- b256[it3] = carry % 256 >>> 0;
135
- carry = carry / 256 >>> 0;
136
- }
137
- if (carry !== 0) {
138
- throw new Error("Non-zero carry");
139
- }
140
- length = i2;
141
- psz++;
142
- }
143
- var it4 = size - length;
144
- while (it4 !== size && b256[it4] === 0) {
145
- it4++;
146
- }
147
- var vch = new Uint8Array(zeroes + (size - it4));
148
- var j2 = zeroes;
149
- while (it4 !== size) {
150
- vch[j2++] = b256[it4++];
151
- }
152
- return vch;
112
+ }
113
+ module.exports = function(val) {
114
+ var returnVal = stringify(val, false);
115
+ if (returnVal !== void 0) {
116
+ return "" + returnVal;
153
117
  }
154
- function decode(string) {
155
- var buffer = decodeUnsafe(string);
156
- if (buffer) {
157
- return buffer;
158
- }
159
- throw new Error("Non-base" + BASE + " character");
118
+ };
119
+ }
120
+ });
121
+
122
+ // src/index.ts
123
+ init_env_shim();
124
+
125
+ // ../instructions/dist/index.browser.js
126
+ init_env_shim();
127
+ var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
128
+ AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
129
+ 3] = "WRITABLE_SIGNER";
130
+ AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
131
+ 2] = "READONLY_SIGNER";
132
+ AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
133
+ 1] = "WRITABLE";
134
+ AccountRole2[AccountRole2["READONLY"] = /* 0 */
135
+ 0] = "READONLY";
136
+ return AccountRole2;
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
163
+ init_env_shim();
164
+
165
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
166
+ init_env_shim();
167
+
168
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
169
+ init_env_shim();
170
+
171
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
172
+ init_env_shim();
173
+ var mergeBytes = (bytesArr) => {
174
+ const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
175
+ const result = new Uint8Array(totalLength);
176
+ let offset = 0;
177
+ bytesArr.forEach((arr) => {
178
+ result.set(arr, offset);
179
+ offset += arr.length;
180
+ });
181
+ return result;
182
+ };
183
+ var padBytes = (bytes, length) => {
184
+ if (bytes.length >= length)
185
+ return bytes;
186
+ const paddedBytes = new Uint8Array(length).fill(0);
187
+ paddedBytes.set(bytes);
188
+ return paddedBytes;
189
+ };
190
+ var fixBytes = (bytes, length) => padBytes(bytes.slice(0, length), length);
191
+
192
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
193
+ init_env_shim();
194
+ var DeserializingEmptyBufferError = class extends Error {
195
+ constructor(serializer) {
196
+ super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
197
+ __publicField(this, "name", "DeserializingEmptyBufferError");
198
+ }
199
+ };
200
+ var NotEnoughBytesError = class extends Error {
201
+ constructor(serializer, expected, actual) {
202
+ super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
203
+ __publicField(this, "name", "NotEnoughBytesError");
204
+ }
205
+ };
206
+
207
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
208
+ init_env_shim();
209
+ function fixSerializer(serializer, fixedBytes, description) {
210
+ return {
211
+ description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
212
+ fixedSize: fixedBytes,
213
+ maxSize: fixedBytes,
214
+ serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes),
215
+ deserialize: (buffer, offset = 0) => {
216
+ buffer = buffer.slice(offset, offset + fixedBytes);
217
+ if (buffer.length < fixedBytes) {
218
+ throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
160
219
  }
161
- return {
162
- encode,
163
- decodeUnsafe,
164
- decode
165
- };
220
+ if (serializer.fixedSize !== null) {
221
+ buffer = fixBytes(buffer, serializer.fixedSize);
222
+ }
223
+ const [value] = serializer.deserialize(buffer, 0);
224
+ return [value, offset + fixedBytes];
166
225
  }
167
- module.exports = base;
226
+ };
227
+ }
228
+
229
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
230
+ init_env_shim();
231
+
232
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
233
+ init_env_shim();
234
+
235
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
236
+ init_env_shim();
237
+ var InvalidBaseStringError = class extends Error {
238
+ constructor(value, base, cause) {
239
+ const message = `Expected a string of base ${base}, got [${value}].`;
240
+ super(message);
241
+ __publicField(this, "name", "InvalidBaseStringError");
242
+ this.cause = cause;
168
243
  }
169
- });
244
+ };
170
245
 
171
- // ../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js
172
- var require_bs58 = __commonJS({
173
- "../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js"(exports, module) {
174
- init_env_shim();
175
- var basex = require_src();
176
- var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
177
- module.exports = basex(ALPHABET);
246
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
247
+ var baseX = (alphabet) => {
248
+ const base = alphabet.length;
249
+ const baseBigInt = BigInt(base);
250
+ return {
251
+ description: `base${base}`,
252
+ fixedSize: null,
253
+ maxSize: null,
254
+ serialize(value) {
255
+ if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
256
+ throw new InvalidBaseStringError(value, base);
257
+ }
258
+ if (value === "")
259
+ return new Uint8Array();
260
+ const chars = [...value];
261
+ let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
262
+ trailIndex = trailIndex === -1 ? chars.length : trailIndex;
263
+ const leadingZeroes = Array(trailIndex).fill(0);
264
+ if (trailIndex === chars.length)
265
+ return Uint8Array.from(leadingZeroes);
266
+ const tailChars = chars.slice(trailIndex);
267
+ let base10Number = 0n;
268
+ let baseXPower = 1n;
269
+ for (let i = tailChars.length - 1; i >= 0; i -= 1) {
270
+ base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
271
+ baseXPower *= baseBigInt;
272
+ }
273
+ const tailBytes = [];
274
+ while (base10Number > 0n) {
275
+ tailBytes.unshift(Number(base10Number % 256n));
276
+ base10Number /= 256n;
277
+ }
278
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
279
+ },
280
+ deserialize(buffer, offset = 0) {
281
+ if (buffer.length === 0)
282
+ return ["", 0];
283
+ const bytes = buffer.slice(offset);
284
+ let trailIndex = bytes.findIndex((n) => n !== 0);
285
+ trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
286
+ const leadingZeroes = alphabet[0].repeat(trailIndex);
287
+ if (trailIndex === bytes.length)
288
+ return [leadingZeroes, buffer.length];
289
+ let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
290
+ const tailChars = [];
291
+ while (base10Number > 0n) {
292
+ tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
293
+ base10Number /= baseBigInt;
294
+ }
295
+ return [leadingZeroes + tailChars.join(""), buffer.length];
296
+ }
297
+ };
298
+ };
299
+
300
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
301
+ init_env_shim();
302
+ var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
303
+
304
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
305
+ init_env_shim();
306
+ var removeNullCharacters = (value) => (
307
+ // eslint-disable-next-line no-control-regex
308
+ value.replace(/\u0000/g, "")
309
+ );
310
+
311
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
312
+ init_env_shim();
313
+ var utf8 = {
314
+ description: "utf8",
315
+ fixedSize: null,
316
+ maxSize: null,
317
+ serialize(value) {
318
+ return new TextEncoder().encode(value);
319
+ },
320
+ deserialize(buffer, offset = 0) {
321
+ const value = new TextDecoder().decode(buffer.slice(offset));
322
+ return [removeNullCharacters(value), buffer.length];
178
323
  }
324
+ };
325
+
326
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
327
+ init_env_shim();
328
+
329
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
330
+ init_env_shim();
331
+ var Endian;
332
+ (function(Endian2) {
333
+ Endian2["Little"] = "le";
334
+ Endian2["Big"] = "be";
335
+ })(Endian || (Endian = {}));
336
+
337
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
338
+ init_env_shim();
339
+ var NumberOutOfRangeError = class extends RangeError {
340
+ constructor(serializer, min, max, actual) {
341
+ super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
342
+ __publicField(this, "name", "NumberOutOfRangeError");
343
+ }
344
+ };
345
+
346
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
347
+ init_env_shim();
348
+ function numberFactory(input) {
349
+ let littleEndian;
350
+ let defaultDescription = input.name;
351
+ if (input.size > 1) {
352
+ littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
353
+ defaultDescription += littleEndian ? "(le)" : "(be)";
354
+ }
355
+ return {
356
+ description: input.options.description ?? defaultDescription,
357
+ fixedSize: input.size,
358
+ maxSize: input.size,
359
+ serialize(value) {
360
+ if (input.range) {
361
+ assertRange(input.name, input.range[0], input.range[1], value);
362
+ }
363
+ const buffer = new ArrayBuffer(input.size);
364
+ input.set(new DataView(buffer), value, littleEndian);
365
+ return new Uint8Array(buffer);
366
+ },
367
+ deserialize(bytes, offset = 0) {
368
+ const slice = bytes.slice(offset, offset + input.size);
369
+ assertEnoughBytes("i8", slice, input.size);
370
+ const view = toDataView(slice);
371
+ return [input.get(view, littleEndian), offset + input.size];
372
+ }
373
+ };
374
+ }
375
+ var toArrayBuffer = (array) => array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
376
+ var toDataView = (array) => new DataView(toArrayBuffer(array));
377
+ var assertRange = (serializer, min, max, value) => {
378
+ if (value < min || value > max) {
379
+ throw new NumberOutOfRangeError(serializer, min, max, value);
380
+ }
381
+ };
382
+ var assertEnoughBytes = (serializer, bytes, expected) => {
383
+ if (bytes.length === 0) {
384
+ throw new DeserializingEmptyBufferError(serializer);
385
+ }
386
+ if (bytes.length < expected) {
387
+ throw new NotEnoughBytesError(serializer, expected, bytes.length);
388
+ }
389
+ };
390
+
391
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
392
+ init_env_shim();
393
+ var u32 = (options = {}) => numberFactory({
394
+ name: "u32",
395
+ size: 4,
396
+ range: [0, Number("0xffffffff")],
397
+ set: (view, value, le) => view.setUint32(0, Number(value), le),
398
+ get: (view, le) => view.getUint32(0, le),
399
+ options
179
400
  });
180
401
 
181
- // src/index.ts
402
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
182
403
  init_env_shim();
404
+ function getSizeDescription(size) {
405
+ return typeof size === "object" ? size.description : `${size}`;
406
+ }
183
407
 
184
- // ../keys/dist/index.browser.js
408
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
185
409
  init_env_shim();
186
- var import_bs58 = __toESM(require_bs58(), 1);
410
+ function string(options = {}) {
411
+ const size = options.size ?? u32();
412
+ const encoding = options.encoding ?? utf8;
413
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
414
+ if (size === "variable") {
415
+ return {
416
+ ...encoding,
417
+ description
418
+ };
419
+ }
420
+ if (typeof size === "number") {
421
+ return fixSerializer(encoding, size, description);
422
+ }
423
+ return {
424
+ description,
425
+ fixedSize: null,
426
+ maxSize: null,
427
+ serialize: (value) => {
428
+ const contentBytes = encoding.serialize(value);
429
+ const lengthBytes = size.serialize(contentBytes.length);
430
+ return mergeBytes([lengthBytes, contentBytes]);
431
+ },
432
+ deserialize: (buffer, offset = 0) => {
433
+ if (buffer.slice(offset).length === 0) {
434
+ throw new DeserializingEmptyBufferError("string");
435
+ }
436
+ const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
437
+ const length = Number(lengthBigInt);
438
+ offset = lengthOffset;
439
+ const contentBuffer = buffer.slice(offset, offset + length);
440
+ if (contentBuffer.length < length) {
441
+ throw new NotEnoughBytesError("string", length, contentBuffer.length);
442
+ }
443
+ const [value, contentOffset] = encoding.deserialize(contentBuffer);
444
+ offset += contentOffset;
445
+ return [value, offset];
446
+ }
447
+ };
448
+ }
187
449
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
188
450
  try {
189
451
  if (
@@ -193,7 +455,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
193
455
  ) {
194
456
  throw new Error("Expected input string to decode to a byte array of length 32.");
195
457
  }
196
- const bytes = import_bs58.default.decode(putativeBase58EncodedAddress);
458
+ const bytes = base58.serialize(putativeBase58EncodedAddress);
197
459
  const numBytes = bytes.byteLength;
198
460
  if (numBytes !== 32) {
199
461
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -204,6 +466,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
204
466
  });
205
467
  }
206
468
  }
469
+ function getBase58EncodedAddressCodec(config) {
470
+ return string({
471
+ description: config?.description ?? ("A 32-byte account address" ),
472
+ encoding: base58,
473
+ size: 32
474
+ });
475
+ }
476
+ function getBase58EncodedAddressComparator() {
477
+ return new Intl.Collator("en", {
478
+ caseFirst: "lower",
479
+ ignorePunctuation: false,
480
+ localeMatcher: "best fit",
481
+ numeric: false,
482
+ sensitivity: "variant",
483
+ usage: "sort"
484
+ }).compare;
485
+ }
207
486
 
208
487
  // src/rpc.ts
209
488
  init_env_shim();
@@ -237,7 +516,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
237
516
  }
238
517
  var KEYPATH_WILDCARD = {};
239
518
  var ALLOWED_NUMERIC_KEYPATHS = {
240
- getInflationReward: [[KEYPATH_WILDCARD, "commission"]]
519
+ getBlockTime: [[]],
520
+ getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
521
+ getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
522
+ getTokenLargestAccounts: [
523
+ ["value", KEYPATH_WILDCARD, "decimals"],
524
+ ["value", KEYPATH_WILDCARD, "uiAmount"]
525
+ ],
526
+ getTransaction: [
527
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
528
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
529
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
530
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
531
+ ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
532
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
533
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
534
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
535
+ ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
536
+ ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
537
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
538
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
539
+ ["transaction", "message", "header", "numReadonlySignedAccounts"],
540
+ ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
541
+ ["transaction", "message", "header", "numRequiredSignatures"]
542
+ ],
543
+ getVoteAccounts: [
544
+ ["current", KEYPATH_WILDCARD, "commission"],
545
+ ["delinquent", KEYPATH_WILDCARD, "commission"]
546
+ ]
241
547
  };
242
548
  function getNextAllowedKeypaths(keyPaths, property) {
243
549
  return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
@@ -294,46 +600,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
294
600
  });
295
601
  }
296
602
 
297
- // src/rpc-default-config.ts
298
- init_env_shim();
299
-
300
- // src/rpc-integer-overflow-error.ts
301
- init_env_shim();
302
- var SolanaJsonRpcIntegerOverflowError = class extends Error {
303
- constructor(methodName, keyPath, value) {
304
- const argPosition = (typeof keyPath[0] === "number" ? keyPath[0] : parseInt(keyPath[0], 10)) + 1;
305
- let ordinal = "";
306
- const lastDigit = argPosition % 10;
307
- const lastTwoDigits = argPosition % 100;
308
- if (lastDigit == 1 && lastTwoDigits != 11) {
309
- ordinal = argPosition + "st";
310
- } else if (lastDigit == 2 && lastTwoDigits != 12) {
311
- ordinal = argPosition + "nd";
312
- } else if (lastDigit == 3 && lastTwoDigits != 13) {
313
- ordinal = argPosition + "rd";
314
- } else {
315
- ordinal = argPosition + "th";
316
- }
317
- const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
318
- super(
319
- `The ${ordinal} argument to the \`${methodName}\` RPC method${path ? ` at path \`${path}\`` : ""} was \`${value}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`
320
- );
321
- this.keyPath = keyPath;
322
- this.methodName = methodName;
323
- this.value = value;
324
- }
325
- get name() {
326
- return "SolanaJsonRpcIntegerOverflowError";
327
- }
328
- };
329
-
330
- // src/rpc-default-config.ts
331
- var DEFAULT_RPC_CONFIG = {
332
- onIntegerOverflow(methodName, keyPath, value) {
333
- throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
334
- }
335
- };
336
-
337
603
  // ../rpc-transport/dist/index.browser.js
338
604
  init_env_shim();
339
605
  var SolanaJsonRpcError = class extends Error {
@@ -399,6 +665,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
399
665
  function createJsonRpc(rpcConfig) {
400
666
  return makeProxy(rpcConfig);
401
667
  }
668
+ var e = globalThis.fetch;
402
669
  var SolanaHttpError = class extends Error {
403
670
  constructor(details) {
404
671
  super(`HTTP error (${details.statusCode}): ${details.message}`);
@@ -457,7 +724,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
457
724
  }
458
725
  return out;
459
726
  }
460
- var e = globalThis.fetch;
461
727
  function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
462
728
  if (headers) {
463
729
  assertIsAllowedHttpRequestHeaders(headers);
@@ -498,6 +764,46 @@ this.globalThis.solanaWeb3 = (function (exports) {
498
764
  };
499
765
  }
500
766
 
767
+ // src/rpc-default-config.ts
768
+ init_env_shim();
769
+
770
+ // src/rpc-integer-overflow-error.ts
771
+ init_env_shim();
772
+ var SolanaJsonRpcIntegerOverflowError = class extends Error {
773
+ constructor(methodName, keyPath, value) {
774
+ const argPosition = (typeof keyPath[0] === "number" ? keyPath[0] : parseInt(keyPath[0], 10)) + 1;
775
+ let ordinal = "";
776
+ const lastDigit = argPosition % 10;
777
+ const lastTwoDigits = argPosition % 100;
778
+ if (lastDigit == 1 && lastTwoDigits != 11) {
779
+ ordinal = argPosition + "st";
780
+ } else if (lastDigit == 2 && lastTwoDigits != 12) {
781
+ ordinal = argPosition + "nd";
782
+ } else if (lastDigit == 3 && lastTwoDigits != 13) {
783
+ ordinal = argPosition + "rd";
784
+ } else {
785
+ ordinal = argPosition + "th";
786
+ }
787
+ const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
788
+ super(
789
+ `The ${ordinal} argument to the \`${methodName}\` RPC method${path ? ` at path \`${path}\`` : ""} was \`${value}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`
790
+ );
791
+ this.keyPath = keyPath;
792
+ this.methodName = methodName;
793
+ this.value = value;
794
+ }
795
+ get name() {
796
+ return "SolanaJsonRpcIntegerOverflowError";
797
+ }
798
+ };
799
+
800
+ // src/rpc-default-config.ts
801
+ var DEFAULT_RPC_CONFIG = {
802
+ onIntegerOverflow(methodName, keyPath, value) {
803
+ throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
804
+ }
805
+ };
806
+
501
807
  // src/rpc.ts
502
808
  function createSolanaRpc(config) {
503
809
  return createJsonRpc({
@@ -508,6 +814,73 @@ this.globalThis.solanaWeb3 = (function (exports) {
508
814
 
509
815
  // src/rpc-transport.ts
510
816
  init_env_shim();
817
+
818
+ // src/rpc-request-coalescer.ts
819
+ init_env_shim();
820
+ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
821
+ let coalescedRequestsByDeduplicationKey;
822
+ return async function makeCoalescedHttpRequest(config) {
823
+ const { payload, signal } = config;
824
+ const deduplicationKey = getDeduplicationKey(payload);
825
+ if (deduplicationKey === void 0) {
826
+ return await transport(config);
827
+ }
828
+ if (!coalescedRequestsByDeduplicationKey) {
829
+ Promise.resolve().then(() => {
830
+ coalescedRequestsByDeduplicationKey = void 0;
831
+ });
832
+ coalescedRequestsByDeduplicationKey = {};
833
+ }
834
+ if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
835
+ const abortController = new AbortController();
836
+ coalescedRequestsByDeduplicationKey[deduplicationKey] = {
837
+ abortController,
838
+ numConsumers: 0,
839
+ responsePromise: transport({
840
+ ...config,
841
+ signal: abortController.signal
842
+ })
843
+ };
844
+ }
845
+ const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
846
+ coalescedRequest.numConsumers++;
847
+ if (signal) {
848
+ const responsePromise = coalescedRequest.responsePromise;
849
+ return await new Promise((resolve, reject) => {
850
+ const handleAbort = (e2) => {
851
+ signal.removeEventListener("abort", handleAbort);
852
+ coalescedRequest.numConsumers -= 1;
853
+ if (coalescedRequest.numConsumers === 0) {
854
+ const abortController = coalescedRequest.abortController;
855
+ abortController.abort();
856
+ }
857
+ const abortError = new DOMException(e2.target.reason, "AbortError");
858
+ reject(abortError);
859
+ };
860
+ signal.addEventListener("abort", handleAbort);
861
+ responsePromise.then(resolve).finally(() => {
862
+ signal.removeEventListener("abort", handleAbort);
863
+ });
864
+ });
865
+ } else {
866
+ return await coalescedRequest.responsePromise;
867
+ }
868
+ };
869
+ }
870
+
871
+ // src/rpc-request-deduplication.ts
872
+ init_env_shim();
873
+ var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
874
+ function getSolanaRpcPayloadDeduplicationKey(payload) {
875
+ if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
876
+ return;
877
+ }
878
+ if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
879
+ return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
880
+ }
881
+ }
882
+
883
+ // src/rpc-transport.ts
511
884
  function normalizeHeaders2(headers) {
512
885
  const out = {};
513
886
  for (const headerName in headers) {
@@ -516,21 +889,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
516
889
  return out;
517
890
  }
518
891
  function createDefaultRpcTransport(config) {
519
- return createHttpTransport({
520
- ...config,
521
- headers: {
522
- ...config.headers ? normalizeHeaders2(config.headers) : void 0,
523
- ...{
524
- // Keep these headers lowercase so they will override any user-supplied headers above.
525
- "solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
892
+ return getRpcTransportWithRequestCoalescing(
893
+ createHttpTransport({
894
+ ...config,
895
+ headers: {
896
+ ...config.headers ? normalizeHeaders2(config.headers) : void 0,
897
+ ...{
898
+ // Keep these headers lowercase so they will override any user-supplied headers above.
899
+ "solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
900
+ }
526
901
  }
527
- }
528
- });
902
+ }),
903
+ getSolanaRpcPayloadDeduplicationKey
904
+ );
529
905
  }
530
906
 
907
+ exports.AccountRole = AccountRole;
531
908
  exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
532
909
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
533
910
  exports.createSolanaRpc = createSolanaRpc;
911
+ exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
912
+ exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
913
+ exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
914
+ exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
915
+ exports.isSignerRole = isSignerRole;
916
+ exports.isWritableRole = isWritableRole;
917
+ exports.mergeRoles = mergeRoles;
918
+ exports.upgradeRoleToSigner = upgradeRoleToSigner;
919
+ exports.upgradeRoleToWritable = upgradeRoleToWritable;
534
920
 
535
921
  return exports;
536
922