@solana/web3.js 1.77.3 → 2.0.0-development
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 +56 -112
- package/dist/index.browser.cjs +158 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.js +137 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.development.js +1044 -0
- package/dist/index.development.js.map +1 -0
- package/dist/index.native.js +139 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.node.cjs +158 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.js +139 -0
- package/dist/index.node.js.map +1 -0
- package/dist/index.production.min.js +25 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/rpc-default-config.d.ts +3 -0
- package/dist/types/rpc-integer-overflow-error.d.ts +8 -0
- package/dist/types/rpc-request-coalescer.d.ts +5 -0
- package/dist/types/rpc-request-deduplication.d.ts +2 -0
- package/dist/types/rpc-transport.d.ts +4 -0
- package/dist/types/rpc.d.ts +5 -0
- package/package.json +86 -110
- package/lib/index.browser.cjs.js +0 -9534
- package/lib/index.browser.cjs.js.map +0 -1
- package/lib/index.browser.esm.js +0 -9432
- package/lib/index.browser.esm.js.map +0 -1
- package/lib/index.cjs.js +0 -12058
- package/lib/index.cjs.js.map +0 -1
- package/lib/index.d.ts +0 -3891
- package/lib/index.esm.js +0 -11949
- package/lib/index.esm.js.map +0 -1
- package/lib/index.iife.js +0 -25985
- package/lib/index.iife.js.map +0 -1
- package/lib/index.iife.min.js +0 -20
- package/lib/index.iife.min.js.map +0 -1
- package/lib/index.native.js +0 -9534
- package/lib/index.native.js.map +0 -1
- package/src/__forks__/browser/fetch-impl.ts +0 -4
- package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
- package/src/__forks__/react-native/fetch-impl.ts +0 -4
- package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
- package/src/account-data.ts +0 -39
- package/src/account.ts +0 -55
- package/src/blockhash.ts +0 -4
- package/src/bpf-loader-deprecated.ts +0 -5
- package/src/bpf-loader.ts +0 -45
- package/src/connection.ts +0 -6756
- package/src/epoch-schedule.ts +0 -102
- package/src/errors.ts +0 -50
- package/src/fee-calculator.ts +0 -18
- package/src/fetch-impl.ts +0 -13
- package/src/index.ts +0 -24
- package/src/instruction.ts +0 -58
- package/src/keypair.ts +0 -93
- package/src/layout.ts +0 -188
- package/src/loader.ts +0 -267
- package/src/message/account-keys.ts +0 -79
- package/src/message/compiled-keys.ts +0 -165
- package/src/message/index.ts +0 -47
- package/src/message/legacy.ts +0 -326
- package/src/message/v0.ts +0 -496
- package/src/message/versioned.ts +0 -36
- package/src/nonce-account.ts +0 -82
- package/src/programs/address-lookup-table/index.ts +0 -435
- package/src/programs/address-lookup-table/state.ts +0 -84
- package/src/programs/compute-budget.ts +0 -281
- package/src/programs/ed25519.ts +0 -157
- package/src/programs/index.ts +0 -7
- package/src/programs/secp256k1.ts +0 -228
- package/src/programs/stake.ts +0 -935
- package/src/programs/system.ts +0 -1048
- package/src/programs/vote.ts +0 -543
- package/src/publickey.ts +0 -259
- package/src/rpc-websocket-factory.ts +0 -4
- package/src/rpc-websocket.ts +0 -79
- package/src/sysvar.ts +0 -37
- package/src/timing.ts +0 -23
- package/src/transaction/constants.ts +0 -12
- package/src/transaction/expiry-custom-errors.ts +0 -48
- package/src/transaction/index.ts +0 -5
- package/src/transaction/legacy.ts +0 -918
- package/src/transaction/message.ts +0 -140
- package/src/transaction/versioned.ts +0 -126
- package/src/utils/assert.ts +0 -8
- package/src/utils/bigint.ts +0 -43
- package/src/utils/borsh-schema.ts +0 -38
- package/src/utils/cluster.ts +0 -31
- package/src/utils/ed25519.ts +0 -43
- package/src/utils/index.ts +0 -5
- package/src/utils/makeWebsocketUrl.ts +0 -26
- package/src/utils/promise-timeout.ts +0 -14
- package/src/utils/secp256k1.ts +0 -11
- package/src/utils/send-and-confirm-raw-transaction.ts +0 -102
- package/src/utils/send-and-confirm-transaction.ts +0 -98
- package/src/utils/shortvec-encoding.ts +0 -28
- package/src/utils/sleep.ts +0 -4
- package/src/utils/to-buffer.ts +0 -11
- package/src/validator-info.ts +0 -104
- package/src/vote-account.ts +0 -236
|
@@ -0,0 +1,1044 @@
|
|
|
1
|
+
this.globalThis = this.globalThis || {};
|
|
2
|
+
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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;
|
|
12
|
+
var __esm = (fn, res) => function __init() {
|
|
13
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
|
+
};
|
|
15
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __publicField = (obj, key, value) => {
|
|
35
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// ../build-scripts/env-shim.ts
|
|
40
|
+
var init_env_shim = __esm({
|
|
41
|
+
"../build-scripts/env-shim.ts"() {
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
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) {
|
|
48
|
+
init_env_shim();
|
|
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);
|
|
54
|
+
}
|
|
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";
|
|
61
|
+
}
|
|
62
|
+
if (val === false) {
|
|
63
|
+
return "false";
|
|
64
|
+
}
|
|
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
|
+
}
|
|
103
|
+
}
|
|
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;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
module.exports = function(val) {
|
|
114
|
+
var returnVal = stringify(val, false);
|
|
115
|
+
if (returnVal !== void 0) {
|
|
116
|
+
return "" + returnVal;
|
|
117
|
+
}
|
|
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);
|
|
219
|
+
}
|
|
220
|
+
if (serializer.fixedSize !== null) {
|
|
221
|
+
buffer = fixBytes(buffer, serializer.fixedSize);
|
|
222
|
+
}
|
|
223
|
+
const [value] = serializer.deserialize(buffer, 0);
|
|
224
|
+
return [value, offset + fixedBytes];
|
|
225
|
+
}
|
|
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;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
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)";
|
|
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
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
403
|
+
init_env_shim();
|
|
404
|
+
function getSizeDescription(size) {
|
|
405
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
409
|
+
init_env_shim();
|
|
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
|
+
}
|
|
449
|
+
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
450
|
+
try {
|
|
451
|
+
if (
|
|
452
|
+
// Lowest address (32 bytes of zeroes)
|
|
453
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
454
|
+
putativeBase58EncodedAddress.length > 44
|
|
455
|
+
) {
|
|
456
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
457
|
+
}
|
|
458
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
459
|
+
const numBytes = bytes.byteLength;
|
|
460
|
+
if (numBytes !== 32) {
|
|
461
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
462
|
+
}
|
|
463
|
+
} catch (e2) {
|
|
464
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
465
|
+
cause: e2
|
|
466
|
+
});
|
|
467
|
+
}
|
|
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("This runtime does not support the generation of Ed25519 keypairs");
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
async function assertKeyExporterIsAvailable() {
|
|
525
|
+
assertIsSecureContext();
|
|
526
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") {
|
|
527
|
+
throw new Error("No key export implementation could be found");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
async function generateKeyPair() {
|
|
531
|
+
await assertKeyGenerationIsAvailable();
|
|
532
|
+
const keyPair = await crypto.subtle.generateKey(
|
|
533
|
+
/* algorithm */
|
|
534
|
+
"Ed25519",
|
|
535
|
+
// Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20
|
|
536
|
+
/* extractable */
|
|
537
|
+
false,
|
|
538
|
+
// Prevents the bytes of the private key from being visible to JS.
|
|
539
|
+
/* allowed uses */
|
|
540
|
+
["sign", "verify"]
|
|
541
|
+
);
|
|
542
|
+
return keyPair;
|
|
543
|
+
}
|
|
544
|
+
async function getBase58EncodedAddressFromPublicKey(publicKey) {
|
|
545
|
+
await assertKeyExporterIsAvailable();
|
|
546
|
+
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
547
|
+
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
548
|
+
}
|
|
549
|
+
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
550
|
+
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
551
|
+
return base58EncodedAddress;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/rpc.ts
|
|
555
|
+
init_env_shim();
|
|
556
|
+
|
|
557
|
+
// ../rpc-core/dist/index.browser.js
|
|
558
|
+
init_env_shim();
|
|
559
|
+
function visitNode(value, keyPath, onIntegerOverflow) {
|
|
560
|
+
if (Array.isArray(value)) {
|
|
561
|
+
return value.map(
|
|
562
|
+
(element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow)
|
|
563
|
+
);
|
|
564
|
+
} else if (typeof value === "object" && value !== null) {
|
|
565
|
+
const out = {};
|
|
566
|
+
for (const propName in value) {
|
|
567
|
+
if (Object.prototype.hasOwnProperty.call(value, propName)) {
|
|
568
|
+
out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return out;
|
|
572
|
+
} else if (typeof value === "bigint") {
|
|
573
|
+
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
|
|
574
|
+
onIntegerOverflow(keyPath, value);
|
|
575
|
+
}
|
|
576
|
+
return Number(value);
|
|
577
|
+
} else {
|
|
578
|
+
return value;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) {
|
|
582
|
+
return visitNode(params, [], onIntegerOverflow);
|
|
583
|
+
}
|
|
584
|
+
var KEYPATH_WILDCARD = {};
|
|
585
|
+
var ALLOWED_NUMERIC_KEYPATHS = {
|
|
586
|
+
getAccountInfo: [
|
|
587
|
+
// parsed AddressTableLookup account
|
|
588
|
+
["value", "data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
589
|
+
// parsed Config account
|
|
590
|
+
["value", "data", "parsed", "info", "slashPenalty"],
|
|
591
|
+
["value", "data", "parsed", "info", "warmupCooldownRate"],
|
|
592
|
+
// parsed Token/Token22 token account
|
|
593
|
+
["value", "data", "parsed", "info", "tokenAmount", "decimals"],
|
|
594
|
+
["value", "data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
595
|
+
["value", "data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
596
|
+
["value", "data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
597
|
+
[
|
|
598
|
+
"value",
|
|
599
|
+
"data",
|
|
600
|
+
"parsed",
|
|
601
|
+
"info",
|
|
602
|
+
"extensions",
|
|
603
|
+
KEYPATH_WILDCARD,
|
|
604
|
+
"state",
|
|
605
|
+
"olderTransferFee",
|
|
606
|
+
"transferFeeBasisPoints"
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
"value",
|
|
610
|
+
"data",
|
|
611
|
+
"parsed",
|
|
612
|
+
"info",
|
|
613
|
+
"extensions",
|
|
614
|
+
KEYPATH_WILDCARD,
|
|
615
|
+
"state",
|
|
616
|
+
"newerTransferFee",
|
|
617
|
+
"transferFeeBasisPoints"
|
|
618
|
+
],
|
|
619
|
+
["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
620
|
+
["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"],
|
|
621
|
+
// parsed Token/Token22 mint account
|
|
622
|
+
["value", "data", "parsed", "info", "decimals"],
|
|
623
|
+
// parsed Token/Token22 multisig account
|
|
624
|
+
["value", "data", "parsed", "info", "numRequiredSigners"],
|
|
625
|
+
["value", "data", "parsed", "info", "numValidSigners"],
|
|
626
|
+
// parsed Stake account
|
|
627
|
+
["value", "data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
628
|
+
// parsed Sysvar rent account
|
|
629
|
+
["value", "data", "parsed", "info", "exemptionThreshold"],
|
|
630
|
+
["value", "data", "parsed", "info", "burnPercent"],
|
|
631
|
+
// parsed Vote account
|
|
632
|
+
["value", "data", "parsed", "info", "commission"],
|
|
633
|
+
["value", "data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
634
|
+
],
|
|
635
|
+
getBlockTime: [[]],
|
|
636
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
637
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
638
|
+
getTokenLargestAccounts: [
|
|
639
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
640
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
641
|
+
],
|
|
642
|
+
getTransaction: [
|
|
643
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
644
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
645
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
646
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
647
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
648
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
649
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
650
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
651
|
+
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
|
|
652
|
+
["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
|
|
653
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
654
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
655
|
+
["transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
656
|
+
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
657
|
+
["transaction", "message", "header", "numRequiredSignatures"]
|
|
658
|
+
],
|
|
659
|
+
getVoteAccounts: [
|
|
660
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
661
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
662
|
+
]
|
|
663
|
+
};
|
|
664
|
+
function getNextAllowedKeypaths(keyPaths, property) {
|
|
665
|
+
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
666
|
+
}
|
|
667
|
+
function visitNode2(value, allowedKeypaths) {
|
|
668
|
+
if (Array.isArray(value)) {
|
|
669
|
+
return value.map((element, ii) => {
|
|
670
|
+
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, ii);
|
|
671
|
+
return visitNode2(element, nextAllowedKeypaths);
|
|
672
|
+
});
|
|
673
|
+
} else if (typeof value === "object" && value !== null) {
|
|
674
|
+
const out = {};
|
|
675
|
+
for (const [propName, innerValue] of Object.entries(value)) {
|
|
676
|
+
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
|
|
677
|
+
out[propName] = visitNode2(innerValue, nextAllowedKeypaths);
|
|
678
|
+
}
|
|
679
|
+
return out;
|
|
680
|
+
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
|
|
681
|
+
// Upcast the value to `bigint` unless an allowed keypath is present.
|
|
682
|
+
allowedKeypaths.length === 0 && // Only try to upcast an Integer to `bigint`
|
|
683
|
+
Number.isInteger(value)) {
|
|
684
|
+
return BigInt(value);
|
|
685
|
+
} else {
|
|
686
|
+
return value;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
690
|
+
const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
|
|
691
|
+
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
692
|
+
}
|
|
693
|
+
function createSolanaRpcApi(config) {
|
|
694
|
+
return new Proxy({}, {
|
|
695
|
+
defineProperty() {
|
|
696
|
+
return false;
|
|
697
|
+
},
|
|
698
|
+
deleteProperty() {
|
|
699
|
+
return false;
|
|
700
|
+
},
|
|
701
|
+
get(...args) {
|
|
702
|
+
const [_, p] = args;
|
|
703
|
+
const methodName = p.toString();
|
|
704
|
+
return function(...rawParams) {
|
|
705
|
+
const handleIntegerOverflow = config?.onIntegerOverflow;
|
|
706
|
+
const params = patchParamsForSolanaLabsRpc(
|
|
707
|
+
rawParams,
|
|
708
|
+
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
|
|
709
|
+
);
|
|
710
|
+
return {
|
|
711
|
+
methodName,
|
|
712
|
+
params,
|
|
713
|
+
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
|
|
714
|
+
};
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// ../rpc-transport/dist/index.browser.js
|
|
721
|
+
init_env_shim();
|
|
722
|
+
var SolanaJsonRpcError = class extends Error {
|
|
723
|
+
constructor(details) {
|
|
724
|
+
super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);
|
|
725
|
+
Error.captureStackTrace(this, this.constructor);
|
|
726
|
+
this.code = details.code;
|
|
727
|
+
this.data = details.data;
|
|
728
|
+
}
|
|
729
|
+
get name() {
|
|
730
|
+
return "SolanaJsonRpcError";
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
var _nextMessageId = 0;
|
|
734
|
+
function getNextMessageId() {
|
|
735
|
+
const id = _nextMessageId;
|
|
736
|
+
_nextMessageId = (_nextMessageId + 1) % Number.MAX_SAFE_INTEGER;
|
|
737
|
+
return id;
|
|
738
|
+
}
|
|
739
|
+
function createJsonRpcMessage(method, params) {
|
|
740
|
+
return {
|
|
741
|
+
id: getNextMessageId(),
|
|
742
|
+
jsonrpc: "2.0",
|
|
743
|
+
method,
|
|
744
|
+
params
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function createPendingRpcRequest(rpcConfig, pendingRequest) {
|
|
748
|
+
return {
|
|
749
|
+
async send(options) {
|
|
750
|
+
const { methodName, params, responseProcessor } = pendingRequest;
|
|
751
|
+
const payload = createJsonRpcMessage(methodName, params);
|
|
752
|
+
const response = await rpcConfig.transport({
|
|
753
|
+
payload,
|
|
754
|
+
signal: options?.abortSignal
|
|
755
|
+
});
|
|
756
|
+
if ("error" in response) {
|
|
757
|
+
throw new SolanaJsonRpcError(response.error);
|
|
758
|
+
} else {
|
|
759
|
+
return responseProcessor ? responseProcessor(response.result) : response.result;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function makeProxy(rpcConfig) {
|
|
765
|
+
return new Proxy(rpcConfig.api, {
|
|
766
|
+
defineProperty() {
|
|
767
|
+
return false;
|
|
768
|
+
},
|
|
769
|
+
deleteProperty() {
|
|
770
|
+
return false;
|
|
771
|
+
},
|
|
772
|
+
get(target, p, receiver) {
|
|
773
|
+
return function(...rawParams) {
|
|
774
|
+
const methodName = p.toString();
|
|
775
|
+
const createRpcRequest = Reflect.get(target, methodName, receiver);
|
|
776
|
+
const newRequest = createRpcRequest ? createRpcRequest(...rawParams) : { methodName, params: rawParams };
|
|
777
|
+
return createPendingRpcRequest(rpcConfig, newRequest);
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
function createJsonRpc(rpcConfig) {
|
|
783
|
+
return makeProxy(rpcConfig);
|
|
784
|
+
}
|
|
785
|
+
var e = globalThis.fetch;
|
|
786
|
+
var SolanaHttpError = class extends Error {
|
|
787
|
+
constructor(details) {
|
|
788
|
+
super(`HTTP error (${details.statusCode}): ${details.message}`);
|
|
789
|
+
Error.captureStackTrace(this, this.constructor);
|
|
790
|
+
this.statusCode = details.statusCode;
|
|
791
|
+
}
|
|
792
|
+
get name() {
|
|
793
|
+
return "SolanaHttpError";
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
var DISALLOWED_HEADERS = {
|
|
797
|
+
accept: true,
|
|
798
|
+
"content-length": true,
|
|
799
|
+
"content-type": true
|
|
800
|
+
};
|
|
801
|
+
var FORBIDDEN_HEADERS = {
|
|
802
|
+
"accept-charset": true,
|
|
803
|
+
"accept-encoding": true,
|
|
804
|
+
"access-control-request-headers": true,
|
|
805
|
+
"access-control-request-method": true,
|
|
806
|
+
connection: true,
|
|
807
|
+
"content-length": true,
|
|
808
|
+
cookie: true,
|
|
809
|
+
date: true,
|
|
810
|
+
dnt: true,
|
|
811
|
+
expect: true,
|
|
812
|
+
host: true,
|
|
813
|
+
"keep-alive": true,
|
|
814
|
+
origin: true,
|
|
815
|
+
"permissions-policy": true,
|
|
816
|
+
// No currently available Typescript technique allows you to match on a prefix.
|
|
817
|
+
// 'proxy-':true,
|
|
818
|
+
// 'sec-':true,
|
|
819
|
+
referer: true,
|
|
820
|
+
te: true,
|
|
821
|
+
trailer: true,
|
|
822
|
+
"transfer-encoding": true,
|
|
823
|
+
upgrade: true,
|
|
824
|
+
via: true
|
|
825
|
+
};
|
|
826
|
+
function assertIsAllowedHttpRequestHeaders(headers) {
|
|
827
|
+
const badHeaders = Object.keys(headers).filter((headerName) => {
|
|
828
|
+
const lowercaseHeaderName = headerName.toLowerCase();
|
|
829
|
+
return DISALLOWED_HEADERS[headerName.toLowerCase()] === true || FORBIDDEN_HEADERS[headerName.toLowerCase()] === true || lowercaseHeaderName.startsWith("proxy-") || lowercaseHeaderName.startsWith("sec-");
|
|
830
|
+
});
|
|
831
|
+
if (badHeaders.length > 0) {
|
|
832
|
+
throw new Error(
|
|
833
|
+
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
function normalizeHeaders(headers) {
|
|
838
|
+
const out = {};
|
|
839
|
+
for (const headerName in headers) {
|
|
840
|
+
out[headerName.toLowerCase()] = headers[headerName];
|
|
841
|
+
}
|
|
842
|
+
return out;
|
|
843
|
+
}
|
|
844
|
+
function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
|
|
845
|
+
if (headers) {
|
|
846
|
+
assertIsAllowedHttpRequestHeaders(headers);
|
|
847
|
+
}
|
|
848
|
+
const agent = void 0;
|
|
849
|
+
if (httpAgentNodeOnly != null) {
|
|
850
|
+
console.warn(
|
|
851
|
+
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
const customHeaders = headers && normalizeHeaders(headers);
|
|
855
|
+
return async function makeHttpRequest({
|
|
856
|
+
payload,
|
|
857
|
+
signal
|
|
858
|
+
}) {
|
|
859
|
+
const body = JSON.stringify(payload);
|
|
860
|
+
const requestInfo = {
|
|
861
|
+
agent,
|
|
862
|
+
body,
|
|
863
|
+
headers: {
|
|
864
|
+
...customHeaders,
|
|
865
|
+
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
866
|
+
accept: "application/json",
|
|
867
|
+
"content-length": body.length.toString(),
|
|
868
|
+
"content-type": "application/json; charset=utf-8"
|
|
869
|
+
},
|
|
870
|
+
method: "POST",
|
|
871
|
+
signal
|
|
872
|
+
};
|
|
873
|
+
const response = await e(url, requestInfo);
|
|
874
|
+
if (!response.ok) {
|
|
875
|
+
throw new SolanaHttpError({
|
|
876
|
+
message: response.statusText,
|
|
877
|
+
statusCode: response.status
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
return await response.json();
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// src/rpc-default-config.ts
|
|
885
|
+
init_env_shim();
|
|
886
|
+
|
|
887
|
+
// src/rpc-integer-overflow-error.ts
|
|
888
|
+
init_env_shim();
|
|
889
|
+
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
890
|
+
constructor(methodName, keyPath, value) {
|
|
891
|
+
const argPosition = (typeof keyPath[0] === "number" ? keyPath[0] : parseInt(keyPath[0], 10)) + 1;
|
|
892
|
+
let ordinal = "";
|
|
893
|
+
const lastDigit = argPosition % 10;
|
|
894
|
+
const lastTwoDigits = argPosition % 100;
|
|
895
|
+
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
896
|
+
ordinal = argPosition + "st";
|
|
897
|
+
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
898
|
+
ordinal = argPosition + "nd";
|
|
899
|
+
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
900
|
+
ordinal = argPosition + "rd";
|
|
901
|
+
} else {
|
|
902
|
+
ordinal = argPosition + "th";
|
|
903
|
+
}
|
|
904
|
+
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
|
|
905
|
+
super(
|
|
906
|
+
`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\`.`
|
|
907
|
+
);
|
|
908
|
+
this.keyPath = keyPath;
|
|
909
|
+
this.methodName = methodName;
|
|
910
|
+
this.value = value;
|
|
911
|
+
}
|
|
912
|
+
get name() {
|
|
913
|
+
return "SolanaJsonRpcIntegerOverflowError";
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
// src/rpc-default-config.ts
|
|
918
|
+
var DEFAULT_RPC_CONFIG = {
|
|
919
|
+
onIntegerOverflow(methodName, keyPath, value) {
|
|
920
|
+
throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
// src/rpc.ts
|
|
925
|
+
function createSolanaRpc(config) {
|
|
926
|
+
return createJsonRpc({
|
|
927
|
+
...config,
|
|
928
|
+
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// src/rpc-transport.ts
|
|
933
|
+
init_env_shim();
|
|
934
|
+
|
|
935
|
+
// src/rpc-request-coalescer.ts
|
|
936
|
+
init_env_shim();
|
|
937
|
+
function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
|
|
938
|
+
let coalescedRequestsByDeduplicationKey;
|
|
939
|
+
return async function makeCoalescedHttpRequest(config) {
|
|
940
|
+
const { payload, signal } = config;
|
|
941
|
+
const deduplicationKey = getDeduplicationKey(payload);
|
|
942
|
+
if (deduplicationKey === void 0) {
|
|
943
|
+
return await transport(config);
|
|
944
|
+
}
|
|
945
|
+
if (!coalescedRequestsByDeduplicationKey) {
|
|
946
|
+
Promise.resolve().then(() => {
|
|
947
|
+
coalescedRequestsByDeduplicationKey = void 0;
|
|
948
|
+
});
|
|
949
|
+
coalescedRequestsByDeduplicationKey = {};
|
|
950
|
+
}
|
|
951
|
+
if (coalescedRequestsByDeduplicationKey[deduplicationKey] == null) {
|
|
952
|
+
const abortController = new AbortController();
|
|
953
|
+
coalescedRequestsByDeduplicationKey[deduplicationKey] = {
|
|
954
|
+
abortController,
|
|
955
|
+
numConsumers: 0,
|
|
956
|
+
responsePromise: transport({
|
|
957
|
+
...config,
|
|
958
|
+
signal: abortController.signal
|
|
959
|
+
})
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
const coalescedRequest = coalescedRequestsByDeduplicationKey[deduplicationKey];
|
|
963
|
+
coalescedRequest.numConsumers++;
|
|
964
|
+
if (signal) {
|
|
965
|
+
const responsePromise = coalescedRequest.responsePromise;
|
|
966
|
+
return await new Promise((resolve, reject) => {
|
|
967
|
+
const handleAbort = (e2) => {
|
|
968
|
+
signal.removeEventListener("abort", handleAbort);
|
|
969
|
+
coalescedRequest.numConsumers -= 1;
|
|
970
|
+
if (coalescedRequest.numConsumers === 0) {
|
|
971
|
+
const abortController = coalescedRequest.abortController;
|
|
972
|
+
abortController.abort();
|
|
973
|
+
}
|
|
974
|
+
const abortError = new DOMException(e2.target.reason, "AbortError");
|
|
975
|
+
reject(abortError);
|
|
976
|
+
};
|
|
977
|
+
signal.addEventListener("abort", handleAbort);
|
|
978
|
+
responsePromise.then(resolve).finally(() => {
|
|
979
|
+
signal.removeEventListener("abort", handleAbort);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
} else {
|
|
983
|
+
return await coalescedRequest.responsePromise;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/rpc-request-deduplication.ts
|
|
989
|
+
init_env_shim();
|
|
990
|
+
var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
|
|
991
|
+
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
|
992
|
+
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
|
|
996
|
+
return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// src/rpc-transport.ts
|
|
1001
|
+
function normalizeHeaders2(headers) {
|
|
1002
|
+
const out = {};
|
|
1003
|
+
for (const headerName in headers) {
|
|
1004
|
+
out[headerName.toLowerCase()] = headers[headerName];
|
|
1005
|
+
}
|
|
1006
|
+
return out;
|
|
1007
|
+
}
|
|
1008
|
+
function createDefaultRpcTransport(config) {
|
|
1009
|
+
return getRpcTransportWithRequestCoalescing(
|
|
1010
|
+
createHttpTransport({
|
|
1011
|
+
...config,
|
|
1012
|
+
headers: {
|
|
1013
|
+
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
|
1014
|
+
...{
|
|
1015
|
+
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
1016
|
+
"solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}),
|
|
1020
|
+
getSolanaRpcPayloadDeduplicationKey
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
exports.AccountRole = AccountRole;
|
|
1025
|
+
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
|
|
1026
|
+
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
1027
|
+
exports.createSolanaRpc = createSolanaRpc;
|
|
1028
|
+
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
1029
|
+
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
1030
|
+
exports.generateKeyPair = generateKeyPair;
|
|
1031
|
+
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
1032
|
+
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
1033
|
+
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
|
|
1034
|
+
exports.isSignerRole = isSignerRole;
|
|
1035
|
+
exports.isWritableRole = isWritableRole;
|
|
1036
|
+
exports.mergeRoles = mergeRoles;
|
|
1037
|
+
exports.upgradeRoleToSigner = upgradeRoleToSigner;
|
|
1038
|
+
exports.upgradeRoleToWritable = upgradeRoleToWritable;
|
|
1039
|
+
|
|
1040
|
+
return exports;
|
|
1041
|
+
|
|
1042
|
+
})({});
|
|
1043
|
+
//# sourceMappingURL=out.js.map
|
|
1044
|
+
//# sourceMappingURL=index.development.js.map
|