@solana/web3.js 2.0.0-experimental.a77f814 → 2.0.0-experimental.a7f0f86
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/README.md +99 -0
- package/dist/index.browser.cjs +88 -9
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +78 -9
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +713 -183
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +80 -9
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +88 -9
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +78 -9
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +22 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/rpc-request-coalescer.d.ts +5 -0
- package/dist/types/rpc-request-deduplication.d.ts +2 -0
- package/package.json +18 -16
|
@@ -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/
|
|
41
|
-
var
|
|
42
|
-
"../../node_modules/.pnpm/
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
}
|
|
93
103
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
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
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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];
|
|
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)";
|
|
178
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
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 =
|
|
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,113 @@ 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
|
+
}
|
|
486
|
+
function assertIsSecureContext() {
|
|
487
|
+
if (!globalThis.isSecureContext) {
|
|
488
|
+
throw new Error(
|
|
489
|
+
"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
var cachedEd25519Decision;
|
|
494
|
+
async function isEd25519CurveSupported(subtle) {
|
|
495
|
+
if (cachedEd25519Decision === void 0) {
|
|
496
|
+
cachedEd25519Decision = new Promise((resolve) => {
|
|
497
|
+
subtle.generateKey(
|
|
498
|
+
"Ed25519",
|
|
499
|
+
/* extractable */
|
|
500
|
+
false,
|
|
501
|
+
["sign", "verify"]
|
|
502
|
+
).catch(() => {
|
|
503
|
+
resolve(cachedEd25519Decision = false);
|
|
504
|
+
}).then(() => {
|
|
505
|
+
resolve(cachedEd25519Decision = true);
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
if (typeof cachedEd25519Decision === "boolean") {
|
|
510
|
+
return cachedEd25519Decision;
|
|
511
|
+
} else {
|
|
512
|
+
return await cachedEd25519Decision;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async function assertKeyGenerationIsAvailable() {
|
|
516
|
+
assertIsSecureContext();
|
|
517
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
|
|
518
|
+
throw new Error("No key generation implementation could be found");
|
|
519
|
+
}
|
|
520
|
+
if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
|
|
521
|
+
throw new Error(
|
|
522
|
+
"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20"
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async function assertKeyExporterIsAvailable() {
|
|
527
|
+
assertIsSecureContext();
|
|
528
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") {
|
|
529
|
+
throw new Error("No key export implementation could be found");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async function assertSigningCapabilityIsAvailable() {
|
|
533
|
+
assertIsSecureContext();
|
|
534
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.sign !== "function") {
|
|
535
|
+
throw new Error("No signing implementation could be found");
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
async function assertVerificationCapabilityIsAvailable() {
|
|
539
|
+
assertIsSecureContext();
|
|
540
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.verify !== "function") {
|
|
541
|
+
throw new Error("No signature verification implementation could be found");
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
async function generateKeyPair() {
|
|
545
|
+
await assertKeyGenerationIsAvailable();
|
|
546
|
+
const keyPair = await crypto.subtle.generateKey(
|
|
547
|
+
/* algorithm */
|
|
548
|
+
"Ed25519",
|
|
549
|
+
// Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20
|
|
550
|
+
/* extractable */
|
|
551
|
+
false,
|
|
552
|
+
// Prevents the bytes of the private key from being visible to JS.
|
|
553
|
+
/* allowed uses */
|
|
554
|
+
["sign", "verify"]
|
|
555
|
+
);
|
|
556
|
+
return keyPair;
|
|
557
|
+
}
|
|
558
|
+
async function getBase58EncodedAddressFromPublicKey(publicKey) {
|
|
559
|
+
await assertKeyExporterIsAvailable();
|
|
560
|
+
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
561
|
+
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
562
|
+
}
|
|
563
|
+
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
564
|
+
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
565
|
+
return base58EncodedAddress;
|
|
566
|
+
}
|
|
567
|
+
async function signBytes(key, data) {
|
|
568
|
+
await assertSigningCapabilityIsAvailable();
|
|
569
|
+
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
570
|
+
return new Uint8Array(signedData);
|
|
571
|
+
}
|
|
572
|
+
async function verifySignature(key, signature, data) {
|
|
573
|
+
await assertVerificationCapabilityIsAvailable();
|
|
574
|
+
return await crypto.subtle.verify("Ed25519", key, signature, data);
|
|
575
|
+
}
|
|
207
576
|
|
|
208
577
|
// src/rpc.ts
|
|
209
578
|
init_env_shim();
|
|
@@ -237,7 +606,83 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
237
606
|
}
|
|
238
607
|
var KEYPATH_WILDCARD = {};
|
|
239
608
|
var ALLOWED_NUMERIC_KEYPATHS = {
|
|
240
|
-
|
|
609
|
+
getAccountInfo: [
|
|
610
|
+
// parsed AddressTableLookup account
|
|
611
|
+
["value", "data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
612
|
+
// parsed Config account
|
|
613
|
+
["value", "data", "parsed", "info", "slashPenalty"],
|
|
614
|
+
["value", "data", "parsed", "info", "warmupCooldownRate"],
|
|
615
|
+
// parsed Token/Token22 token account
|
|
616
|
+
["value", "data", "parsed", "info", "tokenAmount", "decimals"],
|
|
617
|
+
["value", "data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
618
|
+
["value", "data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
619
|
+
["value", "data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
620
|
+
[
|
|
621
|
+
"value",
|
|
622
|
+
"data",
|
|
623
|
+
"parsed",
|
|
624
|
+
"info",
|
|
625
|
+
"extensions",
|
|
626
|
+
KEYPATH_WILDCARD,
|
|
627
|
+
"state",
|
|
628
|
+
"olderTransferFee",
|
|
629
|
+
"transferFeeBasisPoints"
|
|
630
|
+
],
|
|
631
|
+
[
|
|
632
|
+
"value",
|
|
633
|
+
"data",
|
|
634
|
+
"parsed",
|
|
635
|
+
"info",
|
|
636
|
+
"extensions",
|
|
637
|
+
KEYPATH_WILDCARD,
|
|
638
|
+
"state",
|
|
639
|
+
"newerTransferFee",
|
|
640
|
+
"transferFeeBasisPoints"
|
|
641
|
+
],
|
|
642
|
+
["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
643
|
+
["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"],
|
|
644
|
+
// parsed Token/Token22 mint account
|
|
645
|
+
["value", "data", "parsed", "info", "decimals"],
|
|
646
|
+
// parsed Token/Token22 multisig account
|
|
647
|
+
["value", "data", "parsed", "info", "numRequiredSigners"],
|
|
648
|
+
["value", "data", "parsed", "info", "numValidSigners"],
|
|
649
|
+
// parsed Stake account
|
|
650
|
+
["value", "data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
651
|
+
// parsed Sysvar rent account
|
|
652
|
+
["value", "data", "parsed", "info", "exemptionThreshold"],
|
|
653
|
+
["value", "data", "parsed", "info", "burnPercent"],
|
|
654
|
+
// parsed Vote account
|
|
655
|
+
["value", "data", "parsed", "info", "commission"],
|
|
656
|
+
["value", "data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
657
|
+
],
|
|
658
|
+
getBlockTime: [[]],
|
|
659
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
660
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
661
|
+
getTokenLargestAccounts: [
|
|
662
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
663
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
664
|
+
],
|
|
665
|
+
getTransaction: [
|
|
666
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
667
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
668
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
669
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
670
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
671
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
672
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
673
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
674
|
+
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
|
|
675
|
+
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
|
|
676
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
677
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
678
|
+
["transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
679
|
+
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
680
|
+
["transaction", "message", "header", "numRequiredSignatures"]
|
|
681
|
+
],
|
|
682
|
+
getVoteAccounts: [
|
|
683
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
684
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
685
|
+
]
|
|
241
686
|
};
|
|
242
687
|
function getNextAllowedKeypaths(keyPaths, property) {
|
|
243
688
|
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
@@ -257,7 +702,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
257
702
|
return out;
|
|
258
703
|
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
|
|
259
704
|
// Upcast the value to `bigint` unless an allowed keypath is present.
|
|
260
|
-
allowedKeypaths.length === 0
|
|
705
|
+
allowedKeypaths.length === 0 && // Only try to upcast an Integer to `bigint`
|
|
706
|
+
Number.isInteger(value)) {
|
|
261
707
|
return BigInt(value);
|
|
262
708
|
} else {
|
|
263
709
|
return value;
|
|
@@ -294,46 +740,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
294
740
|
});
|
|
295
741
|
}
|
|
296
742
|
|
|
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
743
|
// ../rpc-transport/dist/index.browser.js
|
|
338
744
|
init_env_shim();
|
|
339
745
|
var SolanaJsonRpcError = class extends Error {
|
|
@@ -399,6 +805,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
399
805
|
function createJsonRpc(rpcConfig) {
|
|
400
806
|
return makeProxy(rpcConfig);
|
|
401
807
|
}
|
|
808
|
+
var e = globalThis.fetch;
|
|
402
809
|
var SolanaHttpError = class extends Error {
|
|
403
810
|
constructor(details) {
|
|
404
811
|
super(`HTTP error (${details.statusCode}): ${details.message}`);
|
|
@@ -457,7 +864,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
457
864
|
}
|
|
458
865
|
return out;
|
|
459
866
|
}
|
|
460
|
-
var e = globalThis.fetch;
|
|
461
867
|
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
|
|
462
868
|
if (headers) {
|
|
463
869
|
assertIsAllowedHttpRequestHeaders(headers);
|
|
@@ -498,6 +904,46 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
498
904
|
};
|
|
499
905
|
}
|
|
500
906
|
|
|
907
|
+
// src/rpc-default-config.ts
|
|
908
|
+
init_env_shim();
|
|
909
|
+
|
|
910
|
+
// src/rpc-integer-overflow-error.ts
|
|
911
|
+
init_env_shim();
|
|
912
|
+
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
913
|
+
constructor(methodName, keyPath, value) {
|
|
914
|
+
const argPosition = (typeof keyPath[0] === "number" ? keyPath[0] : parseInt(keyPath[0], 10)) + 1;
|
|
915
|
+
let ordinal = "";
|
|
916
|
+
const lastDigit = argPosition % 10;
|
|
917
|
+
const lastTwoDigits = argPosition % 100;
|
|
918
|
+
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
919
|
+
ordinal = argPosition + "st";
|
|
920
|
+
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
921
|
+
ordinal = argPosition + "nd";
|
|
922
|
+
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
923
|
+
ordinal = argPosition + "rd";
|
|
924
|
+
} else {
|
|
925
|
+
ordinal = argPosition + "th";
|
|
926
|
+
}
|
|
927
|
+
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
|
|
928
|
+
super(
|
|
929
|
+
`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\`.`
|
|
930
|
+
);
|
|
931
|
+
this.keyPath = keyPath;
|
|
932
|
+
this.methodName = methodName;
|
|
933
|
+
this.value = value;
|
|
934
|
+
}
|
|
935
|
+
get name() {
|
|
936
|
+
return "SolanaJsonRpcIntegerOverflowError";
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
// src/rpc-default-config.ts
|
|
941
|
+
var DEFAULT_RPC_CONFIG = {
|
|
942
|
+
onIntegerOverflow(methodName, keyPath, value) {
|
|
943
|
+
throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
|
|
501
947
|
// src/rpc.ts
|
|
502
948
|
function createSolanaRpc(config) {
|
|
503
949
|
return createJsonRpc({
|
|
@@ -508,6 +954,73 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
508
954
|
|
|
509
955
|
// src/rpc-transport.ts
|
|
510
956
|
init_env_shim();
|
|
957
|
+
|
|
958
|
+
// src/rpc-request-coalescer.ts
|
|
959
|
+
init_env_shim();
|
|
960
|
+
function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
961
|
+
let coalescedRequestsByDeduplicationKey;
|
|
962
|
+
return async function makeCoalescedHttpRequest(config) {
|
|
963
|
+
const { payload, signal } = config;
|
|
964
|
+
const deduplicationKey = getDeduplicationKey(payload);
|
|
965
|
+
if (deduplicationKey === void 0) {
|
|
966
|
+
return await transport(config);
|
|
967
|
+
}
|
|
968
|
+
if (!coalescedRequestsByDeduplicationKey) {
|
|
969
|
+
Promise.resolve().then(() => {
|
|
970
|
+
coalescedRequestsByDeduplicationKey = void 0;
|
|
971
|
+
});
|
|
972
|
+
coalescedRequestsByDeduplicationKey = {};
|
|
973
|
+
}
|
|
974
|
+
if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
|
|
975
|
+
const abortController = new AbortController();
|
|
976
|
+
coalescedRequestsByDeduplicationKey[deduplicationKey] = {
|
|
977
|
+
abortController,
|
|
978
|
+
numConsumers: 0,
|
|
979
|
+
responsePromise: transport({
|
|
980
|
+
...config,
|
|
981
|
+
signal: abortController.signal
|
|
982
|
+
})
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
986
|
+
coalescedRequest.numConsumers++;
|
|
987
|
+
if (signal) {
|
|
988
|
+
const responsePromise = coalescedRequest.responsePromise;
|
|
989
|
+
return await new Promise((resolve, reject) => {
|
|
990
|
+
const handleAbort = (e2) => {
|
|
991
|
+
signal.removeEventListener("abort", handleAbort);
|
|
992
|
+
coalescedRequest.numConsumers -= 1;
|
|
993
|
+
if (coalescedRequest.numConsumers === 0) {
|
|
994
|
+
const abortController = coalescedRequest.abortController;
|
|
995
|
+
abortController.abort();
|
|
996
|
+
}
|
|
997
|
+
const abortError = new DOMException(e2.target.reason, "AbortError");
|
|
998
|
+
reject(abortError);
|
|
999
|
+
};
|
|
1000
|
+
signal.addEventListener("abort", handleAbort);
|
|
1001
|
+
responsePromise.then(resolve).finally(() => {
|
|
1002
|
+
signal.removeEventListener("abort", handleAbort);
|
|
1003
|
+
});
|
|
1004
|
+
});
|
|
1005
|
+
} else {
|
|
1006
|
+
return await coalescedRequest.responsePromise;
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// src/rpc-request-deduplication.ts
|
|
1012
|
+
init_env_shim();
|
|
1013
|
+
var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
|
|
1014
|
+
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
|
1015
|
+
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
|
|
1019
|
+
return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// src/rpc-transport.ts
|
|
511
1024
|
function normalizeHeaders2(headers) {
|
|
512
1025
|
const out = {};
|
|
513
1026
|
for (const headerName in headers) {
|
|
@@ -516,21 +1029,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
516
1029
|
return out;
|
|
517
1030
|
}
|
|
518
1031
|
function createDefaultRpcTransport(config) {
|
|
519
|
-
return
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
1032
|
+
return getRpcTransportWithRequestCoalescing(
|
|
1033
|
+
createHttpTransport({
|
|
1034
|
+
...config,
|
|
1035
|
+
headers: {
|
|
1036
|
+
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
|
1037
|
+
...{
|
|
1038
|
+
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
1039
|
+
"solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
|
|
1040
|
+
}
|
|
526
1041
|
}
|
|
527
|
-
}
|
|
528
|
-
|
|
1042
|
+
}),
|
|
1043
|
+
getSolanaRpcPayloadDeduplicationKey
|
|
1044
|
+
);
|
|
529
1045
|
}
|
|
530
1046
|
|
|
1047
|
+
exports.AccountRole = AccountRole;
|
|
531
1048
|
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
532
1049
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
533
1050
|
exports.createSolanaRpc = createSolanaRpc;
|
|
1051
|
+
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
1052
|
+
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
1053
|
+
exports.generateKeyPair = generateKeyPair;
|
|
1054
|
+
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
1055
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
1056
|
+
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
|
|
1057
|
+
exports.isSignerRole = isSignerRole;
|
|
1058
|
+
exports.isWritableRole = isWritableRole;
|
|
1059
|
+
exports.mergeRoles = mergeRoles;
|
|
1060
|
+
exports.signBytes = signBytes;
|
|
1061
|
+
exports.upgradeRoleToSigner = upgradeRoleToSigner;
|
|
1062
|
+
exports.upgradeRoleToWritable = upgradeRoleToWritable;
|
|
1063
|
+
exports.verifySignature = verifySignature;
|
|
534
1064
|
|
|
535
1065
|
return exports;
|
|
536
1066
|
|