@solana/web3.js 2.0.0-experimental.e0b865d → 2.0.0-experimental.e1b2277
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/LICENSE +1 -1
- package/README.md +1151 -43
- package/dist/index.browser.cjs +464 -14
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +448 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +2274 -1006
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +448 -15
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +464 -14
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +448 -15
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +82 -36
- package/dist/types/airdrop-confirmer.d.ts +19 -0
- package/dist/types/airdrop-confirmer.d.ts.map +1 -0
- package/dist/types/airdrop.d.ts +21 -0
- package/dist/types/airdrop.d.ts.map +1 -0
- package/dist/types/cached-abortable-iterable.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -3
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rpc-default-config.d.ts.map +1 -0
- package/dist/types/rpc-integer-overflow-error.d.ts +3 -2
- package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -0
- package/dist/types/rpc-request-coalescer.d.ts +1 -1
- package/dist/types/rpc-request-coalescer.d.ts.map +1 -0
- package/dist/types/rpc-request-deduplication.d.ts.map +1 -0
- package/dist/types/rpc-subscription-coalescer.d.ts +1 -1
- package/dist/types/rpc-subscription-coalescer.d.ts.map +1 -0
- package/dist/types/rpc-transport.d.ts +1 -2
- package/dist/types/rpc-transport.d.ts.map +1 -0
- package/dist/types/rpc-websocket-autopinger.d.ts +1 -1
- package/dist/types/rpc-websocket-autopinger.d.ts.map +1 -0
- package/dist/types/rpc-websocket-connection-sharding.d.ts +1 -1
- package/dist/types/rpc-websocket-connection-sharding.d.ts.map +1 -0
- package/dist/types/rpc-websocket-transport.d.ts +1 -2
- package/dist/types/rpc-websocket-transport.d.ts.map +1 -0
- package/dist/types/rpc.d.ts +1 -2
- package/dist/types/rpc.d.ts.map +1 -0
- package/dist/types/send-transaction.d.ts +38 -0
- package/dist/types/send-transaction.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +9 -0
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts +14 -0
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +14 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +12 -0
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts.map +1 -0
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts.map +1 -0
- package/dist/types/transaction-confirmation.d.ts +32 -0
- package/dist/types/transaction-confirmation.d.ts.map +1 -0
- package/package.json +22 -20
|
@@ -125,304 +125,203 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
125
125
|
// ../addresses/dist/index.browser.js
|
|
126
126
|
init_env_shim();
|
|
127
127
|
|
|
128
|
-
//
|
|
128
|
+
// ../codecs-core/dist/index.browser.js
|
|
129
129
|
init_env_shim();
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return result;
|
|
145
|
-
};
|
|
146
|
-
var padBytes = (bytes2, length) => {
|
|
147
|
-
if (bytes2.length >= length)
|
|
148
|
-
return bytes2;
|
|
130
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
131
|
+
if (bytes.length - offset <= 0) {
|
|
132
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
|
|
136
|
+
const bytesLength = bytes.length - offset;
|
|
137
|
+
if (bytesLength < expected) {
|
|
138
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
var padBytes = (bytes, length) => {
|
|
142
|
+
if (bytes.length >= length)
|
|
143
|
+
return bytes;
|
|
149
144
|
const paddedBytes = new Uint8Array(length).fill(0);
|
|
150
|
-
paddedBytes.set(
|
|
145
|
+
paddedBytes.set(bytes);
|
|
151
146
|
return paddedBytes;
|
|
152
147
|
};
|
|
153
|
-
var fixBytes = (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
149
|
+
function getEncodedSize(value, encoder) {
|
|
150
|
+
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
151
|
+
}
|
|
152
|
+
function createEncoder(encoder) {
|
|
153
|
+
return Object.freeze({
|
|
154
|
+
...encoder,
|
|
155
|
+
encode: (value) => {
|
|
156
|
+
const bytes = new Uint8Array(getEncodedSize(value, encoder));
|
|
157
|
+
encoder.write(value, bytes, 0);
|
|
158
|
+
return bytes;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function createDecoder(decoder) {
|
|
163
|
+
return Object.freeze({
|
|
164
|
+
...decoder,
|
|
165
|
+
decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function isFixedSize(codec) {
|
|
169
|
+
return "fixedSize" in codec && typeof codec.fixedSize === "number";
|
|
170
|
+
}
|
|
171
|
+
function assertIsFixedSize(codec, message) {
|
|
172
|
+
if (!isFixedSize(codec)) {
|
|
173
|
+
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
|
|
161
174
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
175
|
+
}
|
|
176
|
+
function isVariableSize(codec) {
|
|
177
|
+
return !isFixedSize(codec);
|
|
178
|
+
}
|
|
179
|
+
function combineCodec(encoder, decoder) {
|
|
180
|
+
if (isFixedSize(encoder) !== isFixedSize(decoder)) {
|
|
181
|
+
throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);
|
|
167
182
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
191
|
+
);
|
|
174
192
|
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
178
|
-
init_env_shim();
|
|
179
|
-
function fixSerializer(serializer, fixedBytes, description) {
|
|
180
193
|
return {
|
|
181
|
-
|
|
194
|
+
...decoder,
|
|
195
|
+
...encoder,
|
|
196
|
+
decode: decoder.decode,
|
|
197
|
+
encode: encoder.encode,
|
|
198
|
+
read: decoder.read,
|
|
199
|
+
write: encoder.write
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function fixEncoder(encoder, fixedBytes) {
|
|
203
|
+
return createEncoder({
|
|
182
204
|
fixedSize: fixedBytes,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
205
|
+
write: (value, bytes, offset) => {
|
|
206
|
+
const variableByteArray = encoder.encode(value);
|
|
207
|
+
const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray;
|
|
208
|
+
bytes.set(fixedByteArray, offset);
|
|
209
|
+
return offset + fixedBytes;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function fixDecoder(decoder, fixedBytes) {
|
|
214
|
+
return createDecoder({
|
|
215
|
+
fixedSize: fixedBytes,
|
|
216
|
+
read: (bytes, offset) => {
|
|
217
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
218
|
+
if (offset > 0 || bytes.length > fixedBytes) {
|
|
219
|
+
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
189
220
|
}
|
|
190
|
-
if (
|
|
191
|
-
|
|
221
|
+
if (isFixedSize(decoder)) {
|
|
222
|
+
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
192
223
|
}
|
|
193
|
-
const [value] =
|
|
224
|
+
const [value] = decoder.read(bytes, 0);
|
|
194
225
|
return [value, offset + fixedBytes];
|
|
195
226
|
}
|
|
196
|
-
};
|
|
227
|
+
});
|
|
197
228
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
description: serializer.description,
|
|
204
|
-
fixedSize: serializer.fixedSize,
|
|
205
|
-
maxSize: serializer.maxSize,
|
|
206
|
-
serialize: (value) => serializer.serialize(unmap(value)),
|
|
207
|
-
deserialize: (buffer, offset = 0) => {
|
|
208
|
-
const [value, length] = serializer.deserialize(buffer, offset);
|
|
209
|
-
return map ? [map(value, buffer, offset), length] : [value, length];
|
|
210
|
-
}
|
|
211
|
-
};
|
|
229
|
+
function mapEncoder(encoder, unmap) {
|
|
230
|
+
return createEncoder({
|
|
231
|
+
...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder,
|
|
232
|
+
write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset)
|
|
233
|
+
});
|
|
212
234
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
221
|
-
init_env_shim();
|
|
222
|
-
var InvalidBaseStringError = class extends Error {
|
|
223
|
-
constructor(value, base, cause) {
|
|
224
|
-
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
225
|
-
super(message);
|
|
226
|
-
__publicField(this, "name", "InvalidBaseStringError");
|
|
227
|
-
this.cause = cause;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
232
|
-
var baseX = (alphabet) => {
|
|
233
|
-
const base = alphabet.length;
|
|
234
|
-
const baseBigInt = BigInt(base);
|
|
235
|
-
return {
|
|
236
|
-
description: `base${base}`,
|
|
237
|
-
fixedSize: null,
|
|
238
|
-
maxSize: null,
|
|
239
|
-
serialize(value) {
|
|
240
|
-
if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
|
|
241
|
-
throw new InvalidBaseStringError(value, base);
|
|
242
|
-
}
|
|
243
|
-
if (value === "")
|
|
244
|
-
return new Uint8Array();
|
|
245
|
-
const chars = [...value];
|
|
246
|
-
let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
|
|
247
|
-
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
248
|
-
const leadingZeroes = Array(trailIndex).fill(0);
|
|
249
|
-
if (trailIndex === chars.length)
|
|
250
|
-
return Uint8Array.from(leadingZeroes);
|
|
251
|
-
const tailChars = chars.slice(trailIndex);
|
|
252
|
-
let base10Number = 0n;
|
|
253
|
-
let baseXPower = 1n;
|
|
254
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
255
|
-
base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
|
|
256
|
-
baseXPower *= baseBigInt;
|
|
257
|
-
}
|
|
258
|
-
const tailBytes = [];
|
|
259
|
-
while (base10Number > 0n) {
|
|
260
|
-
tailBytes.unshift(Number(base10Number % 256n));
|
|
261
|
-
base10Number /= 256n;
|
|
262
|
-
}
|
|
263
|
-
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
264
|
-
},
|
|
265
|
-
deserialize(buffer, offset = 0) {
|
|
266
|
-
if (buffer.length === 0)
|
|
267
|
-
return ["", 0];
|
|
268
|
-
const bytes2 = buffer.slice(offset);
|
|
269
|
-
let trailIndex = bytes2.findIndex((n) => n !== 0);
|
|
270
|
-
trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
|
|
271
|
-
const leadingZeroes = alphabet[0].repeat(trailIndex);
|
|
272
|
-
if (trailIndex === bytes2.length)
|
|
273
|
-
return [leadingZeroes, buffer.length];
|
|
274
|
-
let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
275
|
-
const tailChars = [];
|
|
276
|
-
while (base10Number > 0n) {
|
|
277
|
-
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
|
|
278
|
-
base10Number /= baseBigInt;
|
|
279
|
-
}
|
|
280
|
-
return [leadingZeroes + tailChars.join(""), buffer.length];
|
|
235
|
+
function mapDecoder(decoder, map) {
|
|
236
|
+
return createDecoder({
|
|
237
|
+
...decoder,
|
|
238
|
+
read: (bytes, offset) => {
|
|
239
|
+
const [value, newOffset] = decoder.read(bytes, offset);
|
|
240
|
+
return [map(value, bytes, offset), newOffset];
|
|
281
241
|
}
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
286
|
-
init_env_shim();
|
|
287
|
-
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
288
|
-
|
|
289
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
|
|
290
|
-
init_env_shim();
|
|
291
|
-
var removeNullCharacters = (value) => (
|
|
292
|
-
// eslint-disable-next-line no-control-regex
|
|
293
|
-
value.replace(/\u0000/g, "")
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
|
|
297
|
-
init_env_shim();
|
|
298
|
-
var utf8 = {
|
|
299
|
-
description: "utf8",
|
|
300
|
-
fixedSize: null,
|
|
301
|
-
maxSize: null,
|
|
302
|
-
serialize(value) {
|
|
303
|
-
return new TextEncoder().encode(value);
|
|
304
|
-
},
|
|
305
|
-
deserialize(buffer, offset = 0) {
|
|
306
|
-
const value = new TextDecoder().decode(buffer.slice(offset));
|
|
307
|
-
return [removeNullCharacters(value), buffer.length];
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
|
|
312
|
-
init_env_shim();
|
|
313
|
-
|
|
314
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
|
|
315
|
-
init_env_shim();
|
|
316
|
-
var Endian;
|
|
317
|
-
(function(Endian2) {
|
|
318
|
-
Endian2["Little"] = "le";
|
|
319
|
-
Endian2["Big"] = "be";
|
|
320
|
-
})(Endian || (Endian = {}));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
321
244
|
|
|
322
|
-
//
|
|
245
|
+
// ../codecs-strings/dist/index.browser.js
|
|
323
246
|
init_env_shim();
|
|
324
|
-
var NumberOutOfRangeError = class extends RangeError {
|
|
325
|
-
constructor(serializer, min, max, actual) {
|
|
326
|
-
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
|
|
327
|
-
__publicField(this, "name", "NumberOutOfRangeError");
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
247
|
|
|
331
|
-
//
|
|
248
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
332
249
|
init_env_shim();
|
|
333
|
-
function
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
250
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
251
|
+
if (value < min || value > max) {
|
|
252
|
+
throw new Error(
|
|
253
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
254
|
+
);
|
|
339
255
|
}
|
|
340
|
-
|
|
341
|
-
|
|
256
|
+
}
|
|
257
|
+
function isLittleEndian(config) {
|
|
258
|
+
return (config == null ? void 0 : config.endian) === 1 ? false : true;
|
|
259
|
+
}
|
|
260
|
+
function numberEncoderFactory(input) {
|
|
261
|
+
return createEncoder({
|
|
342
262
|
fixedSize: input.size,
|
|
343
|
-
|
|
344
|
-
serialize(value) {
|
|
263
|
+
write(value, bytes, offset) {
|
|
345
264
|
if (input.range) {
|
|
346
|
-
|
|
265
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
347
266
|
}
|
|
348
|
-
const
|
|
349
|
-
input.set(new DataView(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
deserialize(bytes2, offset = 0) {
|
|
353
|
-
const slice = bytes2.slice(offset, offset + input.size);
|
|
354
|
-
assertEnoughBytes("i8", slice, input.size);
|
|
355
|
-
const view = toDataView(slice);
|
|
356
|
-
return [input.get(view, littleEndian), offset + input.size];
|
|
267
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
268
|
+
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
|
|
269
|
+
bytes.set(new Uint8Array(arrayBuffer), offset);
|
|
270
|
+
return offset + input.size;
|
|
357
271
|
}
|
|
358
|
-
};
|
|
272
|
+
});
|
|
359
273
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
options
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
388
|
-
init_env_shim();
|
|
389
|
-
var u32 = (options = {}) => numberFactory({
|
|
390
|
-
name: "u32",
|
|
391
|
-
size: 4,
|
|
392
|
-
range: [0, Number("0xffffffff")],
|
|
393
|
-
set: (view, value, le) => view.setUint32(0, Number(value), le),
|
|
394
|
-
get: (view, le) => view.getUint32(0, le),
|
|
395
|
-
options
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
399
|
-
init_env_shim();
|
|
400
|
-
var shortU16 = (options = {}) => ({
|
|
401
|
-
description: options.description ?? "shortU16",
|
|
402
|
-
fixedSize: null,
|
|
274
|
+
function numberDecoderFactory(input) {
|
|
275
|
+
return createDecoder({
|
|
276
|
+
fixedSize: input.size,
|
|
277
|
+
read(bytes, offset = 0) {
|
|
278
|
+
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
|
|
279
|
+
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
|
|
280
|
+
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
281
|
+
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function toArrayBuffer(bytes, offset, length) {
|
|
286
|
+
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
287
|
+
const bytesLength = length != null ? length : bytes.byteLength;
|
|
288
|
+
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
289
|
+
}
|
|
290
|
+
var getShortU16Encoder = () => createEncoder({
|
|
291
|
+
getSizeFromValue: (value) => {
|
|
292
|
+
if (value <= 127)
|
|
293
|
+
return 1;
|
|
294
|
+
if (value <= 16383)
|
|
295
|
+
return 2;
|
|
296
|
+
return 3;
|
|
297
|
+
},
|
|
403
298
|
maxSize: 3,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
const
|
|
299
|
+
write: (value, bytes, offset) => {
|
|
300
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
301
|
+
const shortU16Bytes = [0];
|
|
407
302
|
for (let ii = 0; ; ii += 1) {
|
|
408
303
|
const alignedValue = value >> ii * 7;
|
|
409
304
|
if (alignedValue === 0) {
|
|
410
305
|
break;
|
|
411
306
|
}
|
|
412
307
|
const nextSevenBits = 127 & alignedValue;
|
|
413
|
-
|
|
308
|
+
shortU16Bytes[ii] = nextSevenBits;
|
|
414
309
|
if (ii > 0) {
|
|
415
|
-
|
|
310
|
+
shortU16Bytes[ii - 1] |= 128;
|
|
416
311
|
}
|
|
417
312
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
313
|
+
bytes.set(shortU16Bytes, offset);
|
|
314
|
+
return offset + shortU16Bytes.length;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
var getShortU16Decoder = () => createDecoder({
|
|
318
|
+
maxSize: 3,
|
|
319
|
+
read: (bytes, offset) => {
|
|
421
320
|
let value = 0;
|
|
422
321
|
let byteCount = 0;
|
|
423
322
|
while (++byteCount) {
|
|
424
323
|
const byteIndex = byteCount - 1;
|
|
425
|
-
const currentByte =
|
|
324
|
+
const currentByte = bytes[offset + byteIndex];
|
|
426
325
|
const nextSevenBits = 127 & currentByte;
|
|
427
326
|
value |= nextSevenBits << byteIndex * 7;
|
|
428
327
|
if ((currentByte & 128) === 0) {
|
|
@@ -432,221 +331,208 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
432
331
|
return [value, offset + byteCount];
|
|
433
332
|
}
|
|
434
333
|
});
|
|
334
|
+
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
335
|
+
config,
|
|
336
|
+
name: "u32",
|
|
337
|
+
range: [0, Number("0xffffffff")],
|
|
338
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
339
|
+
size: 4
|
|
340
|
+
});
|
|
341
|
+
var getU32Decoder = (config = {}) => numberDecoderFactory({
|
|
342
|
+
config,
|
|
343
|
+
get: (view, le) => view.getUint32(0, le),
|
|
344
|
+
name: "u32",
|
|
345
|
+
size: 4
|
|
346
|
+
});
|
|
347
|
+
var getU8Encoder = () => numberEncoderFactory({
|
|
348
|
+
name: "u8",
|
|
349
|
+
range: [0, Number("0xff")],
|
|
350
|
+
set: (view, value) => view.setUint8(0, value),
|
|
351
|
+
size: 1
|
|
352
|
+
});
|
|
353
|
+
var getU8Decoder = () => numberDecoderFactory({
|
|
354
|
+
get: (view) => view.getUint8(0),
|
|
355
|
+
name: "u8",
|
|
356
|
+
size: 1
|
|
357
|
+
});
|
|
435
358
|
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
init_env_shim();
|
|
441
|
-
var InvalidNumberOfItemsError = class extends Error {
|
|
442
|
-
constructor(serializer, expected, actual) {
|
|
443
|
-
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
444
|
-
__publicField(this, "name", "InvalidNumberOfItemsError");
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
var InvalidArrayLikeRemainderSizeError = class extends Error {
|
|
448
|
-
constructor(remainderSize, itemSize) {
|
|
449
|
-
super(`The remainder of the buffer (${remainderSize} bytes) cannot be split into chunks of ${itemSize} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainderSize} modulo ${itemSize} should be equal to zero.`);
|
|
450
|
-
__publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
|
|
359
|
+
// ../codecs-strings/dist/index.browser.js
|
|
360
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
361
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
362
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
451
363
|
}
|
|
452
|
-
};
|
|
453
|
-
var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
|
|
454
|
-
constructor(size) {
|
|
455
|
-
super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
|
|
456
|
-
__publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
461
|
-
init_env_shim();
|
|
462
|
-
|
|
463
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
464
|
-
init_env_shim();
|
|
465
|
-
function sumSerializerSizes(sizes) {
|
|
466
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
467
364
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
365
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
366
|
+
return createEncoder({
|
|
367
|
+
getSizeFromValue: (value) => {
|
|
368
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
369
|
+
if (tailChars === "")
|
|
370
|
+
return value.length;
|
|
371
|
+
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
372
|
+
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
|
|
373
|
+
},
|
|
374
|
+
write(value, bytes, offset) {
|
|
375
|
+
assertValidBaseString(alphabet4, value);
|
|
376
|
+
if (value === "")
|
|
377
|
+
return offset;
|
|
378
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
379
|
+
if (tailChars === "") {
|
|
380
|
+
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
|
|
381
|
+
return offset + leadingZeroes.length;
|
|
382
|
+
}
|
|
383
|
+
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
384
|
+
const tailBytes = [];
|
|
385
|
+
while (base10Number > 0n) {
|
|
386
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
387
|
+
base10Number /= 256n;
|
|
388
|
+
}
|
|
389
|
+
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
|
|
390
|
+
bytes.set(bytesToAdd, offset);
|
|
391
|
+
return offset + bytesToAdd.length;
|
|
481
392
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
396
|
+
return createDecoder({
|
|
397
|
+
read(rawBytes, offset) {
|
|
398
|
+
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
399
|
+
if (bytes.length === 0)
|
|
400
|
+
return ["", 0];
|
|
401
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
402
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
403
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
404
|
+
if (trailIndex === bytes.length)
|
|
405
|
+
return [leadingZeroes, rawBytes.length];
|
|
406
|
+
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
407
|
+
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
|
|
408
|
+
return [leadingZeroes + tailChars, rawBytes.length];
|
|
485
409
|
}
|
|
486
|
-
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
function partitionLeadingZeroes(value, zeroCharacter) {
|
|
413
|
+
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
|
|
414
|
+
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
|
|
415
|
+
}
|
|
416
|
+
function getBigIntFromBaseX(value, alphabet4) {
|
|
417
|
+
const base = BigInt(alphabet4.length);
|
|
418
|
+
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
|
|
419
|
+
}
|
|
420
|
+
function getBaseXFromBigInt(value, alphabet4) {
|
|
421
|
+
const base = BigInt(alphabet4.length);
|
|
422
|
+
const tailChars = [];
|
|
423
|
+
while (value > 0n) {
|
|
424
|
+
tailChars.unshift(alphabet4[Number(value % base)]);
|
|
425
|
+
value /= base;
|
|
487
426
|
}
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
function getSizeDescription(size) {
|
|
491
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
492
|
-
}
|
|
493
|
-
function getSizeFromChildren(size, childrenSizes) {
|
|
494
|
-
if (typeof size !== "number")
|
|
495
|
-
return null;
|
|
496
|
-
if (size === 0)
|
|
497
|
-
return 0;
|
|
498
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
499
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
427
|
+
return tailChars.join("");
|
|
500
428
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
if (typeof size === "object" && bytes2.slice(offset).length === 0) {
|
|
523
|
-
return [[], offset];
|
|
429
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
430
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
431
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
432
|
+
var getBase64Encoder = () => {
|
|
433
|
+
{
|
|
434
|
+
return createEncoder({
|
|
435
|
+
getSizeFromValue: (value) => {
|
|
436
|
+
try {
|
|
437
|
+
return atob(value).length;
|
|
438
|
+
} catch (e23) {
|
|
439
|
+
throw new Error(`Expected a string of base 64, got [${value}].`);
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
write(value, bytes, offset) {
|
|
443
|
+
try {
|
|
444
|
+
const bytesToAdd = atob(value).split("").map((c) => c.charCodeAt(0));
|
|
445
|
+
bytes.set(bytesToAdd, offset);
|
|
446
|
+
return bytesToAdd.length + offset;
|
|
447
|
+
} catch (e23) {
|
|
448
|
+
throw new Error(`Expected a string of base 64, got [${value}].`);
|
|
449
|
+
}
|
|
524
450
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
var getBase64Decoder = () => {
|
|
455
|
+
{
|
|
456
|
+
return createDecoder({
|
|
457
|
+
read(bytes, offset = 0) {
|
|
458
|
+
const slice = bytes.slice(offset);
|
|
459
|
+
const value = btoa(String.fromCharCode(...slice));
|
|
460
|
+
return [value, bytes.length];
|
|
532
461
|
}
|
|
533
|
-
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
var removeNullCharacters = (value) => (
|
|
466
|
+
// eslint-disable-next-line no-control-regex
|
|
467
|
+
value.replace(/\u0000/g, "")
|
|
468
|
+
);
|
|
469
|
+
var e = globalThis.TextDecoder;
|
|
470
|
+
var o = globalThis.TextEncoder;
|
|
471
|
+
var getUtf8Encoder = () => {
|
|
472
|
+
let textEncoder;
|
|
473
|
+
return createEncoder({
|
|
474
|
+
getSizeFromValue: (value) => (textEncoder || (textEncoder = new o())).encode(value).length,
|
|
475
|
+
write: (value, bytes, offset) => {
|
|
476
|
+
const bytesToAdd = (textEncoder || (textEncoder = new o())).encode(value);
|
|
477
|
+
bytes.set(bytesToAdd, offset);
|
|
478
|
+
return offset + bytesToAdd.length;
|
|
534
479
|
}
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const byteSerializer = {
|
|
544
|
-
description,
|
|
545
|
-
fixedSize: null,
|
|
546
|
-
maxSize: null,
|
|
547
|
-
serialize: (value) => new Uint8Array(value),
|
|
548
|
-
deserialize: (bytes2, offset = 0) => {
|
|
549
|
-
const slice = bytes2.slice(offset);
|
|
550
|
-
return [slice, offset + slice.length];
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
var getUtf8Decoder = () => {
|
|
483
|
+
let textDecoder;
|
|
484
|
+
return createDecoder({
|
|
485
|
+
read(bytes, offset) {
|
|
486
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
487
|
+
return [removeNullCharacters(value), bytes.length];
|
|
551
488
|
}
|
|
552
|
-
};
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
function getStringEncoder(config = {}) {
|
|
492
|
+
var _a, _b;
|
|
493
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
494
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
|
|
553
495
|
if (size === "variable") {
|
|
554
|
-
return
|
|
496
|
+
return encoding;
|
|
555
497
|
}
|
|
556
498
|
if (typeof size === "number") {
|
|
557
|
-
return
|
|
499
|
+
return fixEncoder(encoding, size);
|
|
558
500
|
}
|
|
559
|
-
return {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
serialize: (value) => {
|
|
564
|
-
const contentBytes = byteSerializer.serialize(value);
|
|
565
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
566
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
501
|
+
return createEncoder({
|
|
502
|
+
getSizeFromValue: (value) => {
|
|
503
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
504
|
+
return getEncodedSize(contentSize, size) + contentSize;
|
|
567
505
|
},
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
573
|
-
const length = Number(lengthBigInt);
|
|
574
|
-
offset = lengthOffset;
|
|
575
|
-
const contentBuffer = buffer.slice(offset, offset + length);
|
|
576
|
-
if (contentBuffer.length < length) {
|
|
577
|
-
throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
|
|
578
|
-
}
|
|
579
|
-
const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
|
|
580
|
-
offset += contentOffset;
|
|
581
|
-
return [value, offset];
|
|
506
|
+
write: (value, bytes, offset) => {
|
|
507
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
508
|
+
offset = size.write(contentSize, bytes, offset);
|
|
509
|
+
return encoding.write(value, bytes, offset);
|
|
582
510
|
}
|
|
583
|
-
};
|
|
511
|
+
});
|
|
584
512
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
const size = options.size ?? u32();
|
|
590
|
-
const encoding = options.encoding ?? utf8;
|
|
591
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
513
|
+
function getStringDecoder(config = {}) {
|
|
514
|
+
var _a, _b;
|
|
515
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
516
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
|
|
592
517
|
if (size === "variable") {
|
|
593
|
-
return
|
|
594
|
-
...encoding,
|
|
595
|
-
description
|
|
596
|
-
};
|
|
518
|
+
return encoding;
|
|
597
519
|
}
|
|
598
520
|
if (typeof size === "number") {
|
|
599
|
-
return
|
|
521
|
+
return fixDecoder(encoding, size);
|
|
600
522
|
}
|
|
601
|
-
return {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
serialize: (value) => {
|
|
606
|
-
const contentBytes = encoding.serialize(value);
|
|
607
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
608
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
609
|
-
},
|
|
610
|
-
deserialize: (buffer, offset = 0) => {
|
|
611
|
-
if (buffer.slice(offset).length === 0) {
|
|
612
|
-
throw new DeserializingEmptyBufferError("string");
|
|
613
|
-
}
|
|
614
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
523
|
+
return createDecoder({
|
|
524
|
+
read: (bytes, offset = 0) => {
|
|
525
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
526
|
+
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
|
|
615
527
|
const length = Number(lengthBigInt);
|
|
616
528
|
offset = lengthOffset;
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
const [value, contentOffset] = encoding.deserialize(contentBuffer);
|
|
529
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
530
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
531
|
+
const [value, contentOffset] = encoding.read(contentBytes, 0);
|
|
622
532
|
offset += contentOffset;
|
|
623
533
|
return [value, offset];
|
|
624
534
|
}
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
629
|
-
init_env_shim();
|
|
630
|
-
function struct(fields, options = {}) {
|
|
631
|
-
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
632
|
-
return {
|
|
633
|
-
description: options.description ?? `struct(${fieldDescriptions})`,
|
|
634
|
-
fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
|
|
635
|
-
maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
|
|
636
|
-
serialize: (struct2) => {
|
|
637
|
-
const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
|
|
638
|
-
return mergeBytes(fieldBytes);
|
|
639
|
-
},
|
|
640
|
-
deserialize: (bytes2, offset = 0) => {
|
|
641
|
-
const struct2 = {};
|
|
642
|
-
fields.forEach(([key, serializer]) => {
|
|
643
|
-
const [value, newOffset] = serializer.deserialize(bytes2, offset);
|
|
644
|
-
offset = newOffset;
|
|
645
|
-
struct2[key] = value;
|
|
646
|
-
});
|
|
647
|
-
return [struct2, offset];
|
|
648
|
-
}
|
|
649
|
-
};
|
|
535
|
+
});
|
|
650
536
|
}
|
|
651
537
|
|
|
652
538
|
// ../assertions/dist/index.browser.js
|
|
@@ -681,14 +567,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
681
567
|
}
|
|
682
568
|
}
|
|
683
569
|
async function assertDigestCapabilityIsAvailable() {
|
|
570
|
+
var _a;
|
|
684
571
|
assertIsSecureContext();
|
|
685
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
572
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.digest) !== "function") {
|
|
686
573
|
throw new Error("No digest implementation could be found");
|
|
687
574
|
}
|
|
688
575
|
}
|
|
689
576
|
async function assertKeyGenerationIsAvailable() {
|
|
577
|
+
var _a;
|
|
690
578
|
assertIsSecureContext();
|
|
691
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
579
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.generateKey) !== "function") {
|
|
692
580
|
throw new Error("No key generation implementation could be found");
|
|
693
581
|
}
|
|
694
582
|
if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
|
|
@@ -698,70 +586,94 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
698
586
|
}
|
|
699
587
|
}
|
|
700
588
|
async function assertKeyExporterIsAvailable() {
|
|
589
|
+
var _a;
|
|
701
590
|
assertIsSecureContext();
|
|
702
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
591
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
|
|
703
592
|
throw new Error("No key export implementation could be found");
|
|
704
593
|
}
|
|
705
594
|
}
|
|
706
595
|
async function assertSigningCapabilityIsAvailable() {
|
|
596
|
+
var _a;
|
|
707
597
|
assertIsSecureContext();
|
|
708
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
598
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
|
|
709
599
|
throw new Error("No signing implementation could be found");
|
|
710
600
|
}
|
|
711
601
|
}
|
|
712
602
|
async function assertVerificationCapabilityIsAvailable() {
|
|
603
|
+
var _a;
|
|
713
604
|
assertIsSecureContext();
|
|
714
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
605
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.verify) !== "function") {
|
|
715
606
|
throw new Error("No signature verification implementation could be found");
|
|
716
607
|
}
|
|
717
608
|
}
|
|
718
|
-
|
|
609
|
+
|
|
610
|
+
// ../addresses/dist/index.browser.js
|
|
611
|
+
var memoizedBase58Encoder;
|
|
612
|
+
var memoizedBase58Decoder;
|
|
613
|
+
function getMemoizedBase58Encoder() {
|
|
614
|
+
if (!memoizedBase58Encoder)
|
|
615
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
616
|
+
return memoizedBase58Encoder;
|
|
617
|
+
}
|
|
618
|
+
function getMemoizedBase58Decoder() {
|
|
619
|
+
if (!memoizedBase58Decoder)
|
|
620
|
+
memoizedBase58Decoder = getBase58Decoder();
|
|
621
|
+
return memoizedBase58Decoder;
|
|
622
|
+
}
|
|
623
|
+
function isAddress(putativeAddress) {
|
|
719
624
|
if (
|
|
720
625
|
// Lowest address (32 bytes of zeroes)
|
|
721
|
-
|
|
722
|
-
|
|
626
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
627
|
+
putativeAddress.length > 44
|
|
723
628
|
) {
|
|
724
629
|
return false;
|
|
725
630
|
}
|
|
726
|
-
const
|
|
727
|
-
const
|
|
631
|
+
const base58Encoder3 = getMemoizedBase58Encoder();
|
|
632
|
+
const bytes = base58Encoder3.encode(putativeAddress);
|
|
633
|
+
const numBytes = bytes.byteLength;
|
|
728
634
|
if (numBytes !== 32) {
|
|
729
635
|
return false;
|
|
730
636
|
}
|
|
731
637
|
return true;
|
|
732
638
|
}
|
|
733
|
-
function
|
|
639
|
+
function assertIsAddress(putativeAddress) {
|
|
734
640
|
try {
|
|
735
641
|
if (
|
|
736
642
|
// Lowest address (32 bytes of zeroes)
|
|
737
|
-
|
|
738
|
-
|
|
643
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
644
|
+
putativeAddress.length > 44
|
|
739
645
|
) {
|
|
740
646
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
741
647
|
}
|
|
742
|
-
const
|
|
743
|
-
const
|
|
648
|
+
const base58Encoder3 = getMemoizedBase58Encoder();
|
|
649
|
+
const bytes = base58Encoder3.encode(putativeAddress);
|
|
650
|
+
const numBytes = bytes.byteLength;
|
|
744
651
|
if (numBytes !== 32) {
|
|
745
652
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
746
653
|
}
|
|
747
654
|
} catch (e3) {
|
|
748
|
-
throw new Error(`\`${
|
|
655
|
+
throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
|
|
749
656
|
cause: e3
|
|
750
657
|
});
|
|
751
658
|
}
|
|
752
659
|
}
|
|
753
|
-
function address(
|
|
754
|
-
|
|
755
|
-
return
|
|
660
|
+
function address(putativeAddress) {
|
|
661
|
+
assertIsAddress(putativeAddress);
|
|
662
|
+
return putativeAddress;
|
|
756
663
|
}
|
|
757
|
-
function
|
|
758
|
-
return
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
});
|
|
664
|
+
function getAddressEncoder() {
|
|
665
|
+
return mapEncoder(
|
|
666
|
+
getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }),
|
|
667
|
+
(putativeAddress) => address(putativeAddress)
|
|
668
|
+
);
|
|
763
669
|
}
|
|
764
|
-
function
|
|
670
|
+
function getAddressDecoder() {
|
|
671
|
+
return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 });
|
|
672
|
+
}
|
|
673
|
+
function getAddressCodec() {
|
|
674
|
+
return combineCodec(getAddressEncoder(), getAddressDecoder());
|
|
675
|
+
}
|
|
676
|
+
function getAddressComparator() {
|
|
765
677
|
return new Intl.Collator("en", {
|
|
766
678
|
caseFirst: "lower",
|
|
767
679
|
ignorePunctuation: false,
|
|
@@ -845,20 +757,35 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
845
757
|
return hexString;
|
|
846
758
|
}
|
|
847
759
|
}
|
|
848
|
-
function decompressPointBytes(
|
|
849
|
-
const hexString =
|
|
760
|
+
function decompressPointBytes(bytes) {
|
|
761
|
+
const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
|
|
850
762
|
const integerLiteralString = `0x${hexString}`;
|
|
851
763
|
return BigInt(integerLiteralString);
|
|
852
764
|
}
|
|
853
|
-
async function compressedPointBytesAreOnCurve(
|
|
854
|
-
if (
|
|
765
|
+
async function compressedPointBytesAreOnCurve(bytes) {
|
|
766
|
+
if (bytes.byteLength !== 32) {
|
|
855
767
|
return false;
|
|
856
768
|
}
|
|
857
|
-
const y = decompressPointBytes(
|
|
858
|
-
return pointIsOnCurve(y,
|
|
769
|
+
const y = decompressPointBytes(bytes);
|
|
770
|
+
return pointIsOnCurve(y, bytes[31]);
|
|
859
771
|
}
|
|
860
|
-
|
|
861
|
-
|
|
772
|
+
function isProgramDerivedAddress(value) {
|
|
773
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number" && value[1] >= 0 && value[1] <= 255 && isAddress(value[0]);
|
|
774
|
+
}
|
|
775
|
+
function assertIsProgramDerivedAddress(value) {
|
|
776
|
+
const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number";
|
|
777
|
+
if (!validFormat) {
|
|
778
|
+
throw new Error(
|
|
779
|
+
`Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].`
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
if (value[1] < 0 || value[1] > 255) {
|
|
783
|
+
throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);
|
|
784
|
+
}
|
|
785
|
+
assertIsAddress(value[0]);
|
|
786
|
+
}
|
|
787
|
+
var MAX_SEED_LENGTH = 32;
|
|
788
|
+
var MAX_SEEDS = 16;
|
|
862
789
|
var PDA_MARKER_BYTES = [
|
|
863
790
|
// The string 'ProgramDerivedAddress'
|
|
864
791
|
80,
|
|
@@ -892,15 +819,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
892
819
|
}
|
|
893
820
|
let textEncoder;
|
|
894
821
|
const seedBytes = seeds.reduce((acc, seed, ii) => {
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
822
|
+
const bytes = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
|
|
823
|
+
if (bytes.byteLength > MAX_SEED_LENGTH) {
|
|
897
824
|
throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
|
|
898
825
|
}
|
|
899
|
-
acc.push(...
|
|
826
|
+
acc.push(...bytes);
|
|
900
827
|
return acc;
|
|
901
828
|
}, []);
|
|
902
|
-
const base58EncodedAddressCodec =
|
|
903
|
-
const programAddressBytes = base58EncodedAddressCodec.
|
|
829
|
+
const base58EncodedAddressCodec = getAddressCodec();
|
|
830
|
+
const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);
|
|
904
831
|
const addressBytesBuffer = await crypto.subtle.digest(
|
|
905
832
|
"SHA-256",
|
|
906
833
|
new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
|
|
@@ -909,19 +836,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
909
836
|
if (await compressedPointBytesAreOnCurve(addressBytes)) {
|
|
910
837
|
throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
|
|
911
838
|
}
|
|
912
|
-
return base58EncodedAddressCodec.
|
|
839
|
+
return base58EncodedAddressCodec.decode(addressBytes);
|
|
913
840
|
}
|
|
914
|
-
async function getProgramDerivedAddress({
|
|
841
|
+
async function getProgramDerivedAddress({
|
|
842
|
+
programAddress,
|
|
843
|
+
seeds
|
|
844
|
+
}) {
|
|
915
845
|
let bumpSeed = 255;
|
|
916
846
|
while (bumpSeed > 0) {
|
|
917
847
|
try {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
})
|
|
924
|
-
};
|
|
848
|
+
const address2 = await createProgramDerivedAddress({
|
|
849
|
+
programAddress,
|
|
850
|
+
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
851
|
+
});
|
|
852
|
+
return [address2, bumpSeed];
|
|
925
853
|
} catch (e3) {
|
|
926
854
|
if (e3 instanceof PointOnCurveError) {
|
|
927
855
|
bumpSeed--;
|
|
@@ -932,26 +860,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
932
860
|
}
|
|
933
861
|
throw new Error("Unable to find a viable program address bump seed");
|
|
934
862
|
}
|
|
935
|
-
async function createAddressWithSeed({
|
|
936
|
-
|
|
937
|
-
programAddress,
|
|
938
|
-
seed
|
|
939
|
-
}) {
|
|
940
|
-
const { serialize: serialize4, deserialize: deserialize2 } = getBase58EncodedAddressCodec();
|
|
863
|
+
async function createAddressWithSeed({ baseAddress, programAddress, seed }) {
|
|
864
|
+
const { encode, decode } = getAddressCodec();
|
|
941
865
|
const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
|
|
942
866
|
if (seedBytes.byteLength > MAX_SEED_LENGTH) {
|
|
943
867
|
throw new Error(`The seed exceeds the maximum length of 32 bytes`);
|
|
944
868
|
}
|
|
945
|
-
const programAddressBytes =
|
|
869
|
+
const programAddressBytes = encode(programAddress);
|
|
946
870
|
if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
|
|
947
871
|
throw new Error(`programAddress cannot end with the PDA marker`);
|
|
948
872
|
}
|
|
949
873
|
const addressBytesBuffer = await crypto.subtle.digest(
|
|
950
874
|
"SHA-256",
|
|
951
|
-
new Uint8Array([...
|
|
875
|
+
new Uint8Array([...encode(baseAddress), ...seedBytes, ...programAddressBytes])
|
|
952
876
|
);
|
|
953
877
|
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
954
|
-
return
|
|
878
|
+
return decode(addressBytes);
|
|
955
879
|
}
|
|
956
880
|
async function getAddressFromPublicKey(publicKey) {
|
|
957
881
|
await assertKeyExporterIsAvailable();
|
|
@@ -959,8 +883,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
959
883
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
960
884
|
}
|
|
961
885
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
962
|
-
|
|
963
|
-
return base58EncodedAddress;
|
|
886
|
+
return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
964
887
|
}
|
|
965
888
|
|
|
966
889
|
// ../instructions/dist/index.browser.js
|
|
@@ -1016,18 +939,408 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1016
939
|
);
|
|
1017
940
|
return keyPair;
|
|
1018
941
|
}
|
|
942
|
+
function addPkcs8Header(bytes) {
|
|
943
|
+
return new Uint8Array([
|
|
944
|
+
/**
|
|
945
|
+
* PKCS#8 header
|
|
946
|
+
*/
|
|
947
|
+
48,
|
|
948
|
+
// ASN.1 sequence tag
|
|
949
|
+
46,
|
|
950
|
+
// Length of sequence (46 more bytes)
|
|
951
|
+
2,
|
|
952
|
+
// ASN.1 integer tag
|
|
953
|
+
1,
|
|
954
|
+
// Length of integer
|
|
955
|
+
0,
|
|
956
|
+
// Version number
|
|
957
|
+
48,
|
|
958
|
+
// ASN.1 sequence tag
|
|
959
|
+
5,
|
|
960
|
+
// Length of sequence
|
|
961
|
+
6,
|
|
962
|
+
// ASN.1 object identifier tag
|
|
963
|
+
3,
|
|
964
|
+
// Length of object identifier
|
|
965
|
+
// Edwards curve algorithms identifier https://oid-rep.orange-labs.fr/get/1.3.101.112
|
|
966
|
+
43,
|
|
967
|
+
// iso(1) / identified-organization(3) (The first node is multiplied by the decimal 40 and the result is added to the value of the second node)
|
|
968
|
+
101,
|
|
969
|
+
// thawte(101)
|
|
970
|
+
// Ed25519 identifier
|
|
971
|
+
112,
|
|
972
|
+
// id-Ed25519(112)
|
|
973
|
+
/**
|
|
974
|
+
* Private key payload
|
|
975
|
+
*/
|
|
976
|
+
4,
|
|
977
|
+
// ASN.1 octet string tag
|
|
978
|
+
34,
|
|
979
|
+
// String length (34 more bytes)
|
|
980
|
+
// Private key bytes as octet string
|
|
981
|
+
4,
|
|
982
|
+
// ASN.1 octet string tag
|
|
983
|
+
32,
|
|
984
|
+
// String length (32 bytes)
|
|
985
|
+
...bytes
|
|
986
|
+
]);
|
|
987
|
+
}
|
|
988
|
+
async function createPrivateKeyFromBytes(bytes, extractable) {
|
|
989
|
+
if (bytes.byteLength !== 32) {
|
|
990
|
+
throw new Error("Private key bytes must be of length 32");
|
|
991
|
+
}
|
|
992
|
+
const privateKeyBytesPkcs8 = addPkcs8Header(bytes);
|
|
993
|
+
return await crypto.subtle.importKey("pkcs8", privateKeyBytesPkcs8, "Ed25519", extractable != null ? extractable : false, ["sign"]);
|
|
994
|
+
}
|
|
995
|
+
var base58Encoder;
|
|
996
|
+
function assertIsSignature(putativeSignature) {
|
|
997
|
+
if (!base58Encoder)
|
|
998
|
+
base58Encoder = getBase58Encoder();
|
|
999
|
+
try {
|
|
1000
|
+
if (
|
|
1001
|
+
// Lowest value (64 bytes of zeroes)
|
|
1002
|
+
putativeSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1003
|
+
putativeSignature.length > 88
|
|
1004
|
+
) {
|
|
1005
|
+
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1006
|
+
}
|
|
1007
|
+
const bytes = base58Encoder.encode(putativeSignature);
|
|
1008
|
+
const numBytes = bytes.byteLength;
|
|
1009
|
+
if (numBytes !== 64) {
|
|
1010
|
+
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1011
|
+
}
|
|
1012
|
+
} catch (e3) {
|
|
1013
|
+
throw new Error(`\`${putativeSignature}\` is not a signature`, {
|
|
1014
|
+
cause: e3
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
function isSignature(putativeSignature) {
|
|
1019
|
+
if (!base58Encoder)
|
|
1020
|
+
base58Encoder = getBase58Encoder();
|
|
1021
|
+
if (
|
|
1022
|
+
// Lowest value (64 bytes of zeroes)
|
|
1023
|
+
putativeSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1024
|
+
putativeSignature.length > 88
|
|
1025
|
+
) {
|
|
1026
|
+
return false;
|
|
1027
|
+
}
|
|
1028
|
+
const bytes = base58Encoder.encode(putativeSignature);
|
|
1029
|
+
const numBytes = bytes.byteLength;
|
|
1030
|
+
if (numBytes !== 64) {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
1019
1035
|
async function signBytes(key, data) {
|
|
1020
1036
|
await assertSigningCapabilityIsAvailable();
|
|
1021
1037
|
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
1022
1038
|
return new Uint8Array(signedData);
|
|
1023
1039
|
}
|
|
1024
|
-
|
|
1040
|
+
function signature(putativeSignature) {
|
|
1041
|
+
assertIsSignature(putativeSignature);
|
|
1042
|
+
return putativeSignature;
|
|
1043
|
+
}
|
|
1044
|
+
async function verifySignature(key, signature2, data) {
|
|
1025
1045
|
await assertVerificationCapabilityIsAvailable();
|
|
1026
|
-
return await crypto.subtle.verify("Ed25519", key,
|
|
1046
|
+
return await crypto.subtle.verify("Ed25519", key, signature2, data);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// ../rpc-types/dist/index.browser.js
|
|
1050
|
+
init_env_shim();
|
|
1051
|
+
function getCommitmentScore(commitment) {
|
|
1052
|
+
switch (commitment) {
|
|
1053
|
+
case "finalized":
|
|
1054
|
+
return 2;
|
|
1055
|
+
case "confirmed":
|
|
1056
|
+
return 1;
|
|
1057
|
+
case "processed":
|
|
1058
|
+
return 0;
|
|
1059
|
+
default:
|
|
1060
|
+
return ((_) => {
|
|
1061
|
+
throw new Error(`Unrecognized commitment \`${commitment}\`.`);
|
|
1062
|
+
})();
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
function commitmentComparator(a, b) {
|
|
1066
|
+
if (a === b) {
|
|
1067
|
+
return 0;
|
|
1068
|
+
}
|
|
1069
|
+
return getCommitmentScore(a) < getCommitmentScore(b) ? -1 : 1;
|
|
1070
|
+
}
|
|
1071
|
+
var maxU64Value = 18446744073709551615n;
|
|
1072
|
+
function isLamports(putativeLamports) {
|
|
1073
|
+
return putativeLamports >= 0 && putativeLamports <= maxU64Value;
|
|
1074
|
+
}
|
|
1075
|
+
function assertIsLamports(putativeLamports) {
|
|
1076
|
+
if (putativeLamports < 0) {
|
|
1077
|
+
throw new Error("Input for 64-bit unsigned integer cannot be negative");
|
|
1078
|
+
}
|
|
1079
|
+
if (putativeLamports > maxU64Value) {
|
|
1080
|
+
throw new Error("Input number is too large to be represented as a 64-bit unsigned integer");
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
function lamports(putativeLamports) {
|
|
1084
|
+
assertIsLamports(putativeLamports);
|
|
1085
|
+
return putativeLamports;
|
|
1086
|
+
}
|
|
1087
|
+
function isStringifiedBigInt(putativeBigInt) {
|
|
1088
|
+
try {
|
|
1089
|
+
BigInt(putativeBigInt);
|
|
1090
|
+
return true;
|
|
1091
|
+
} catch (_) {
|
|
1092
|
+
return false;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
function assertIsStringifiedBigInt(putativeBigInt) {
|
|
1096
|
+
try {
|
|
1097
|
+
BigInt(putativeBigInt);
|
|
1098
|
+
} catch (e3) {
|
|
1099
|
+
throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, {
|
|
1100
|
+
cause: e3
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function stringifiedBigInt(putativeBigInt) {
|
|
1105
|
+
assertIsStringifiedBigInt(putativeBigInt);
|
|
1106
|
+
return putativeBigInt;
|
|
1107
|
+
}
|
|
1108
|
+
function isStringifiedNumber(putativeNumber) {
|
|
1109
|
+
return !Number.isNaN(Number(putativeNumber));
|
|
1110
|
+
}
|
|
1111
|
+
function assertIsStringifiedNumber(putativeNumber) {
|
|
1112
|
+
if (Number.isNaN(Number(putativeNumber))) {
|
|
1113
|
+
throw new Error(`\`${putativeNumber}\` cannot be parsed as a Number`);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
function stringifiedNumber(putativeNumber) {
|
|
1117
|
+
assertIsStringifiedNumber(putativeNumber);
|
|
1118
|
+
return putativeNumber;
|
|
1119
|
+
}
|
|
1120
|
+
function isUnixTimestamp(putativeTimestamp) {
|
|
1121
|
+
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1124
|
+
return true;
|
|
1125
|
+
}
|
|
1126
|
+
function assertIsUnixTimestamp(putativeTimestamp) {
|
|
1127
|
+
try {
|
|
1128
|
+
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
|
|
1129
|
+
throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]");
|
|
1130
|
+
}
|
|
1131
|
+
} catch (e3) {
|
|
1132
|
+
throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, {
|
|
1133
|
+
cause: e3
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
function unixTimestamp(putativeTimestamp) {
|
|
1138
|
+
assertIsUnixTimestamp(putativeTimestamp);
|
|
1139
|
+
return putativeTimestamp;
|
|
1027
1140
|
}
|
|
1028
1141
|
|
|
1029
1142
|
// ../transactions/dist/index.browser.js
|
|
1030
1143
|
init_env_shim();
|
|
1144
|
+
|
|
1145
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
1146
|
+
init_env_shim();
|
|
1147
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1148
|
+
if (expected !== actual) {
|
|
1149
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
function sumCodecSizes(sizes) {
|
|
1153
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
1154
|
+
}
|
|
1155
|
+
function getFixedSize(codec) {
|
|
1156
|
+
return isFixedSize(codec) ? codec.fixedSize : null;
|
|
1157
|
+
}
|
|
1158
|
+
function getMaxSize(codec) {
|
|
1159
|
+
var _a;
|
|
1160
|
+
return isFixedSize(codec) ? codec.fixedSize : (_a = codec.maxSize) != null ? _a : null;
|
|
1161
|
+
}
|
|
1162
|
+
function getArrayEncoder(item, config = {}) {
|
|
1163
|
+
var _a, _b;
|
|
1164
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
1165
|
+
if (size === "remainder") {
|
|
1166
|
+
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
1167
|
+
}
|
|
1168
|
+
const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
|
|
1169
|
+
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
1170
|
+
return createEncoder({
|
|
1171
|
+
...fixedSize !== null ? { fixedSize } : {
|
|
1172
|
+
getSizeFromValue: (array) => {
|
|
1173
|
+
const prefixSize = typeof size === "object" ? getEncodedSize(array.length, size) : 0;
|
|
1174
|
+
return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);
|
|
1175
|
+
},
|
|
1176
|
+
maxSize
|
|
1177
|
+
},
|
|
1178
|
+
write: (array, bytes, offset) => {
|
|
1179
|
+
if (typeof size === "number") {
|
|
1180
|
+
assertValidNumberOfItemsForCodec("array", size, array.length);
|
|
1181
|
+
}
|
|
1182
|
+
if (typeof size === "object") {
|
|
1183
|
+
offset = size.write(array.length, bytes, offset);
|
|
1184
|
+
}
|
|
1185
|
+
array.forEach((value) => {
|
|
1186
|
+
offset = item.write(value, bytes, offset);
|
|
1187
|
+
});
|
|
1188
|
+
return offset;
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
function getArrayDecoder(item, config = {}) {
|
|
1193
|
+
var _a, _b;
|
|
1194
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
1195
|
+
if (size === "remainder") {
|
|
1196
|
+
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
1197
|
+
}
|
|
1198
|
+
const itemSize = getFixedSize(item);
|
|
1199
|
+
const fixedSize = computeArrayLikeCodecSize(size, itemSize);
|
|
1200
|
+
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
1201
|
+
return createDecoder({
|
|
1202
|
+
...fixedSize !== null ? { fixedSize } : { maxSize },
|
|
1203
|
+
read: (bytes, offset) => {
|
|
1204
|
+
const array = [];
|
|
1205
|
+
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
1206
|
+
return [array, offset];
|
|
1207
|
+
}
|
|
1208
|
+
const [resolvedSize, newOffset] = readArrayLikeCodecSize(size, itemSize, bytes, offset);
|
|
1209
|
+
offset = newOffset;
|
|
1210
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1211
|
+
const [value, newOffset2] = item.read(bytes, offset);
|
|
1212
|
+
offset = newOffset2;
|
|
1213
|
+
array.push(value);
|
|
1214
|
+
}
|
|
1215
|
+
return [array, offset];
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
function readArrayLikeCodecSize(size, itemSize, bytes, offset) {
|
|
1220
|
+
if (typeof size === "number") {
|
|
1221
|
+
return [size, offset];
|
|
1222
|
+
}
|
|
1223
|
+
if (typeof size === "object") {
|
|
1224
|
+
return size.read(bytes, offset);
|
|
1225
|
+
}
|
|
1226
|
+
if (size === "remainder") {
|
|
1227
|
+
if (itemSize === null) {
|
|
1228
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1229
|
+
}
|
|
1230
|
+
const remainder = Math.max(0, bytes.length - offset);
|
|
1231
|
+
if (remainder % itemSize !== 0) {
|
|
1232
|
+
throw new Error(
|
|
1233
|
+
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${itemSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${itemSize} should be equal to zero.`
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
return [remainder / itemSize, offset];
|
|
1237
|
+
}
|
|
1238
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1239
|
+
}
|
|
1240
|
+
function computeArrayLikeCodecSize(size, itemSize) {
|
|
1241
|
+
if (typeof size !== "number")
|
|
1242
|
+
return null;
|
|
1243
|
+
if (size === 0)
|
|
1244
|
+
return 0;
|
|
1245
|
+
return itemSize === null ? null : itemSize * size;
|
|
1246
|
+
}
|
|
1247
|
+
function getBytesEncoder(config = {}) {
|
|
1248
|
+
var _a;
|
|
1249
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
1250
|
+
const byteEncoder = createEncoder({
|
|
1251
|
+
getSizeFromValue: (value) => value.length,
|
|
1252
|
+
write: (value, bytes, offset) => {
|
|
1253
|
+
bytes.set(value, offset);
|
|
1254
|
+
return offset + value.length;
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
if (size === "variable") {
|
|
1258
|
+
return byteEncoder;
|
|
1259
|
+
}
|
|
1260
|
+
if (typeof size === "number") {
|
|
1261
|
+
return fixEncoder(byteEncoder, size);
|
|
1262
|
+
}
|
|
1263
|
+
return createEncoder({
|
|
1264
|
+
getSizeFromValue: (value) => getEncodedSize(value.length, size) + value.length,
|
|
1265
|
+
write: (value, bytes, offset) => {
|
|
1266
|
+
offset = size.write(value.length, bytes, offset);
|
|
1267
|
+
return byteEncoder.write(value, bytes, offset);
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
function getBytesDecoder(config = {}) {
|
|
1272
|
+
var _a;
|
|
1273
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
1274
|
+
const byteDecoder = createDecoder({
|
|
1275
|
+
read: (bytes, offset) => {
|
|
1276
|
+
const slice = bytes.slice(offset);
|
|
1277
|
+
return [slice, offset + slice.length];
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
if (size === "variable") {
|
|
1281
|
+
return byteDecoder;
|
|
1282
|
+
}
|
|
1283
|
+
if (typeof size === "number") {
|
|
1284
|
+
return fixDecoder(byteDecoder, size);
|
|
1285
|
+
}
|
|
1286
|
+
return createDecoder({
|
|
1287
|
+
read: (bytes, offset) => {
|
|
1288
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
1289
|
+
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
|
|
1290
|
+
const length = Number(lengthBigInt);
|
|
1291
|
+
offset = lengthOffset;
|
|
1292
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
1293
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1294
|
+
const [value, contentOffset] = byteDecoder.read(contentBytes, 0);
|
|
1295
|
+
offset += contentOffset;
|
|
1296
|
+
return [value, offset];
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
function getStructEncoder(fields) {
|
|
1301
|
+
var _a;
|
|
1302
|
+
const fieldCodecs = fields.map(([, codec]) => codec);
|
|
1303
|
+
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
|
|
1304
|
+
const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
|
|
1305
|
+
return createEncoder({
|
|
1306
|
+
...fixedSize === null ? {
|
|
1307
|
+
getSizeFromValue: (value) => fields.map(([key, codec]) => getEncodedSize(value[key], codec)).reduce((all, one) => all + one, 0),
|
|
1308
|
+
maxSize
|
|
1309
|
+
} : { fixedSize },
|
|
1310
|
+
write: (struct, bytes, offset) => {
|
|
1311
|
+
fields.forEach(([key, codec]) => {
|
|
1312
|
+
offset = codec.write(struct[key], bytes, offset);
|
|
1313
|
+
});
|
|
1314
|
+
return offset;
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
function getStructDecoder(fields) {
|
|
1319
|
+
var _a;
|
|
1320
|
+
const fieldCodecs = fields.map(([, codec]) => codec);
|
|
1321
|
+
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
|
|
1322
|
+
const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
|
|
1323
|
+
return createDecoder({
|
|
1324
|
+
...fixedSize === null ? { maxSize } : { fixedSize },
|
|
1325
|
+
read: (bytes, offset) => {
|
|
1326
|
+
const struct = {};
|
|
1327
|
+
fields.forEach(([key, codec]) => {
|
|
1328
|
+
const [value, newOffset] = codec.read(bytes, offset);
|
|
1329
|
+
offset = newOffset;
|
|
1330
|
+
struct[key] = value;
|
|
1331
|
+
});
|
|
1332
|
+
return [struct, offset];
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
// ../functional/dist/index.browser.js
|
|
1338
|
+
init_env_shim();
|
|
1339
|
+
function pipe(init, ...fns) {
|
|
1340
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// ../transactions/dist/index.browser.js
|
|
1031
1344
|
function getUnsignedTransaction(transaction) {
|
|
1032
1345
|
if ("signatures" in transaction) {
|
|
1033
1346
|
const {
|
|
@@ -1040,7 +1353,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1040
1353
|
return transaction;
|
|
1041
1354
|
}
|
|
1042
1355
|
}
|
|
1356
|
+
var base58Encoder2;
|
|
1043
1357
|
function assertIsBlockhash(putativeBlockhash) {
|
|
1358
|
+
if (!base58Encoder2)
|
|
1359
|
+
base58Encoder2 = getBase58Encoder();
|
|
1044
1360
|
try {
|
|
1045
1361
|
if (
|
|
1046
1362
|
// Lowest value (32 bytes of zeroes)
|
|
@@ -1049,8 +1365,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1049
1365
|
) {
|
|
1050
1366
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1051
1367
|
}
|
|
1052
|
-
const
|
|
1053
|
-
const numBytes =
|
|
1368
|
+
const bytes = base58Encoder2.encode(putativeBlockhash);
|
|
1369
|
+
const numBytes = bytes.byteLength;
|
|
1054
1370
|
if (numBytes !== 32) {
|
|
1055
1371
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1056
1372
|
}
|
|
@@ -1060,6 +1376,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1060
1376
|
});
|
|
1061
1377
|
}
|
|
1062
1378
|
}
|
|
1379
|
+
function isTransactionWithBlockhashLifetime(transaction) {
|
|
1380
|
+
const lifetimeConstraintShapeMatches = "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.blockhash === "string" && typeof transaction.lifetimeConstraint.lastValidBlockHeight === "bigint";
|
|
1381
|
+
if (!lifetimeConstraintShapeMatches)
|
|
1382
|
+
return false;
|
|
1383
|
+
try {
|
|
1384
|
+
assertIsBlockhash(transaction.lifetimeConstraint.blockhash);
|
|
1385
|
+
return true;
|
|
1386
|
+
} catch {
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
function assertIsTransactionWithBlockhashLifetime(transaction) {
|
|
1391
|
+
if (!isTransactionWithBlockhashLifetime(transaction)) {
|
|
1392
|
+
throw new Error("Transaction does not have a blockhash lifetime");
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1063
1395
|
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
1064
1396
|
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
1065
1397
|
return transaction;
|
|
@@ -1124,12 +1456,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1124
1456
|
};
|
|
1125
1457
|
}
|
|
1126
1458
|
function isAdvanceNonceAccountInstruction(instruction) {
|
|
1459
|
+
var _a;
|
|
1127
1460
|
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
1128
1461
|
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
1129
|
-
instruction.accounts
|
|
1462
|
+
((_a = instruction.accounts) == null ? void 0 : _a.length) === 3 && // First account is nonce account address
|
|
1130
1463
|
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
|
|
1131
1464
|
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
|
|
1132
|
-
instruction.accounts[2].address != null && instruction.accounts[2].role
|
|
1465
|
+
instruction.accounts[2].address != null && isSignerRole2(instruction.accounts[2].role);
|
|
1133
1466
|
}
|
|
1134
1467
|
function isAdvanceNonceAccountInstructionData(data) {
|
|
1135
1468
|
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
@@ -1137,21 +1470,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1137
1470
|
function isDurableNonceTransaction(transaction) {
|
|
1138
1471
|
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
1139
1472
|
}
|
|
1473
|
+
function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
|
|
1474
|
+
return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
|
|
1475
|
+
}
|
|
1140
1476
|
function setTransactionLifetimeUsingDurableNonce({
|
|
1141
1477
|
nonce,
|
|
1142
1478
|
nonceAccountAddress,
|
|
1143
1479
|
nonceAuthorityAddress
|
|
1144
1480
|
}, transaction) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1481
|
+
let newInstructions;
|
|
1482
|
+
const firstInstruction = transaction.instructions[0];
|
|
1483
|
+
if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1484
|
+
if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
|
|
1485
|
+
if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
|
|
1486
|
+
return transaction;
|
|
1487
|
+
} else {
|
|
1488
|
+
newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
|
|
1489
|
+
}
|
|
1490
|
+
} else {
|
|
1491
|
+
newInstructions = [
|
|
1492
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
1493
|
+
...transaction.instructions.slice(1)
|
|
1494
|
+
];
|
|
1495
|
+
}
|
|
1496
|
+
} else {
|
|
1497
|
+
newInstructions = [
|
|
1498
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
1499
|
+
...transaction.instructions
|
|
1500
|
+
];
|
|
1148
1501
|
}
|
|
1149
1502
|
const out = {
|
|
1150
1503
|
...getUnsignedTransaction(transaction),
|
|
1151
|
-
instructions:
|
|
1152
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
1153
|
-
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
1154
|
-
],
|
|
1504
|
+
instructions: newInstructions,
|
|
1155
1505
|
lifetimeConstraint: {
|
|
1156
1506
|
nonce
|
|
1157
1507
|
}
|
|
@@ -1187,7 +1537,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1187
1537
|
return out;
|
|
1188
1538
|
}
|
|
1189
1539
|
function upsert(addressMap, address2, update) {
|
|
1190
|
-
|
|
1540
|
+
var _a;
|
|
1541
|
+
addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole2.READONLY });
|
|
1191
1542
|
}
|
|
1192
1543
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
1193
1544
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -1238,7 +1589,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1238
1589
|
const shouldReplaceEntry = (
|
|
1239
1590
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
1240
1591
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
1241
|
-
(addressComparator || (addressComparator =
|
|
1592
|
+
(addressComparator || (addressComparator = getAddressComparator()))(
|
|
1242
1593
|
accountMeta.lookupTableAddress,
|
|
1243
1594
|
entry.lookupTableAddress
|
|
1244
1595
|
) < 0
|
|
@@ -1346,7 +1697,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1346
1697
|
if (leftIsWritable !== isWritableRole2(rightEntry.role)) {
|
|
1347
1698
|
return leftIsWritable ? -1 : 1;
|
|
1348
1699
|
}
|
|
1349
|
-
addressComparator || (addressComparator =
|
|
1700
|
+
addressComparator || (addressComparator = getAddressComparator());
|
|
1350
1701
|
if (leftEntry[TYPE] === 1 && rightEntry[TYPE] === 1 && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
1351
1702
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
1352
1703
|
} else {
|
|
@@ -1375,7 +1726,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1375
1726
|
entry.readableIndices.push(account.addressIndex);
|
|
1376
1727
|
}
|
|
1377
1728
|
}
|
|
1378
|
-
return Object.keys(index).sort(
|
|
1729
|
+
return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
|
|
1379
1730
|
lookupTableAddress,
|
|
1380
1731
|
...index[lookupTableAddress]
|
|
1381
1732
|
}));
|
|
@@ -1444,410 +1795,1026 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1444
1795
|
version: transaction.version
|
|
1445
1796
|
};
|
|
1446
1797
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
getBase58EncodedAddressCodec(
|
|
1453
|
-
{
|
|
1454
|
-
description: "The address of the address lookup table account from which instruction addresses should be looked up"
|
|
1455
|
-
}
|
|
1456
|
-
)
|
|
1457
|
-
],
|
|
1798
|
+
var memoizedAddressTableLookupEncoder;
|
|
1799
|
+
function getAddressTableLookupEncoder() {
|
|
1800
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
1801
|
+
memoizedAddressTableLookupEncoder = getStructEncoder([
|
|
1802
|
+
["lookupTableAddress", getAddressEncoder()],
|
|
1458
1803
|
[
|
|
1459
1804
|
"writableIndices",
|
|
1460
|
-
|
|
1461
|
-
...{
|
|
1462
|
-
description: "The indices of the accounts in the lookup table that should be loaded as writeable"
|
|
1463
|
-
} ,
|
|
1464
|
-
size: shortU16()
|
|
1465
|
-
})
|
|
1805
|
+
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
|
|
1466
1806
|
],
|
|
1467
1807
|
[
|
|
1468
1808
|
"readableIndices",
|
|
1469
|
-
|
|
1470
|
-
...{
|
|
1471
|
-
description: "The indices of the accounts in the lookup table that should be loaded as read-only"
|
|
1472
|
-
} ,
|
|
1473
|
-
size: shortU16()
|
|
1474
|
-
})
|
|
1809
|
+
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
|
|
1475
1810
|
]
|
|
1476
|
-
]
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1811
|
+
]);
|
|
1812
|
+
}
|
|
1813
|
+
return memoizedAddressTableLookupEncoder;
|
|
1814
|
+
}
|
|
1815
|
+
var memoizedAddressTableLookupDecoder;
|
|
1816
|
+
function getAddressTableLookupDecoder() {
|
|
1817
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
1818
|
+
memoizedAddressTableLookupDecoder = getStructDecoder([
|
|
1819
|
+
["lookupTableAddress", getAddressDecoder()],
|
|
1820
|
+
["writableIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
|
|
1821
|
+
["readableIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })]
|
|
1822
|
+
]);
|
|
1823
|
+
}
|
|
1824
|
+
return memoizedAddressTableLookupDecoder;
|
|
1825
|
+
}
|
|
1826
|
+
var memoizedU8Encoder;
|
|
1827
|
+
function getMemoizedU8Encoder() {
|
|
1828
|
+
if (!memoizedU8Encoder)
|
|
1829
|
+
memoizedU8Encoder = getU8Encoder();
|
|
1830
|
+
return memoizedU8Encoder;
|
|
1831
|
+
}
|
|
1832
|
+
var memoizedU8Decoder;
|
|
1833
|
+
function getMemoizedU8Decoder() {
|
|
1834
|
+
if (!memoizedU8Decoder)
|
|
1835
|
+
memoizedU8Decoder = getU8Decoder();
|
|
1836
|
+
return memoizedU8Decoder;
|
|
1837
|
+
}
|
|
1838
|
+
function getMessageHeaderEncoder() {
|
|
1839
|
+
return getStructEncoder([
|
|
1840
|
+
["numSignerAccounts", getMemoizedU8Encoder()],
|
|
1841
|
+
["numReadonlySignerAccounts", getMemoizedU8Encoder()],
|
|
1842
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
|
|
1843
|
+
]);
|
|
1844
|
+
}
|
|
1845
|
+
function getMessageHeaderDecoder() {
|
|
1846
|
+
return getStructDecoder([
|
|
1847
|
+
["numSignerAccounts", getMemoizedU8Decoder()],
|
|
1848
|
+
["numReadonlySignerAccounts", getMemoizedU8Decoder()],
|
|
1849
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()]
|
|
1850
|
+
]);
|
|
1851
|
+
}
|
|
1852
|
+
var memoizedGetInstructionEncoder;
|
|
1853
|
+
function getInstructionEncoder() {
|
|
1854
|
+
if (!memoizedGetInstructionEncoder) {
|
|
1855
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
1856
|
+
getStructEncoder([
|
|
1857
|
+
["programAddressIndex", getU8Encoder()],
|
|
1858
|
+
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],
|
|
1859
|
+
["data", getBytesEncoder({ size: getShortU16Encoder() })]
|
|
1860
|
+
]),
|
|
1861
|
+
// Convert an instruction to have all fields defined
|
|
1862
|
+
(instruction) => {
|
|
1863
|
+
var _a, _b;
|
|
1864
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1865
|
+
return instruction;
|
|
1866
|
+
}
|
|
1867
|
+
return {
|
|
1868
|
+
...instruction,
|
|
1869
|
+
accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
|
|
1870
|
+
data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
);
|
|
1874
|
+
}
|
|
1875
|
+
return memoizedGetInstructionEncoder;
|
|
1876
|
+
}
|
|
1877
|
+
var memoizedGetInstructionDecoder;
|
|
1878
|
+
function getInstructionDecoder() {
|
|
1879
|
+
if (!memoizedGetInstructionDecoder) {
|
|
1880
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
1881
|
+
getStructDecoder([
|
|
1882
|
+
["programAddressIndex", getU8Decoder()],
|
|
1883
|
+
["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
|
|
1884
|
+
["data", getBytesDecoder({ size: getShortU16Decoder() })]
|
|
1885
|
+
]),
|
|
1886
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
1887
|
+
(instruction) => {
|
|
1888
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
1889
|
+
return instruction;
|
|
1890
|
+
}
|
|
1891
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
1892
|
+
return {
|
|
1893
|
+
...rest,
|
|
1894
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1895
|
+
...data.byteLength ? { data } : null
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
);
|
|
1899
|
+
}
|
|
1900
|
+
return memoizedGetInstructionDecoder;
|
|
1481
1901
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
}
|
|
1499
|
-
)
|
|
1500
|
-
],
|
|
1501
|
-
[
|
|
1502
|
-
"numReadonlyNonSignerAccounts",
|
|
1503
|
-
u8(
|
|
1504
|
-
{
|
|
1505
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
1506
|
-
}
|
|
1507
|
-
)
|
|
1508
|
-
]
|
|
1509
|
-
],
|
|
1510
|
-
{
|
|
1511
|
-
description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
|
|
1512
|
-
}
|
|
1513
|
-
);
|
|
1902
|
+
var VERSION_FLAG_MASK = 128;
|
|
1903
|
+
function getTransactionVersionEncoder() {
|
|
1904
|
+
return createEncoder({
|
|
1905
|
+
getSizeFromValue: (value) => value === "legacy" ? 0 : 1,
|
|
1906
|
+
maxSize: 1,
|
|
1907
|
+
write: (value, bytes, offset) => {
|
|
1908
|
+
if (value === "legacy") {
|
|
1909
|
+
return offset;
|
|
1910
|
+
}
|
|
1911
|
+
if (value < 0 || value > 127) {
|
|
1912
|
+
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
1913
|
+
}
|
|
1914
|
+
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
1915
|
+
return offset + 1;
|
|
1916
|
+
}
|
|
1917
|
+
});
|
|
1514
1918
|
}
|
|
1515
|
-
function
|
|
1516
|
-
return
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
],
|
|
1538
|
-
[
|
|
1539
|
-
"data",
|
|
1540
|
-
bytes({
|
|
1541
|
-
description: "An optional buffer of data passed to the instruction" ,
|
|
1542
|
-
size: shortU16()
|
|
1543
|
-
})
|
|
1544
|
-
]
|
|
1919
|
+
function getTransactionVersionDecoder() {
|
|
1920
|
+
return createDecoder({
|
|
1921
|
+
maxSize: 1,
|
|
1922
|
+
read: (bytes, offset) => {
|
|
1923
|
+
const firstByte = bytes[offset];
|
|
1924
|
+
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1925
|
+
return ["legacy", offset];
|
|
1926
|
+
} else {
|
|
1927
|
+
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
1928
|
+
return [version, offset + 1];
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
function getCompiledMessageLegacyEncoder() {
|
|
1934
|
+
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
1935
|
+
}
|
|
1936
|
+
function getCompiledMessageVersionedEncoder() {
|
|
1937
|
+
return mapEncoder(
|
|
1938
|
+
getStructEncoder([
|
|
1939
|
+
...getPreludeStructEncoderTuple(),
|
|
1940
|
+
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1545
1941
|
]),
|
|
1546
1942
|
(value) => {
|
|
1547
|
-
|
|
1943
|
+
var _a;
|
|
1944
|
+
if (value.version === "legacy") {
|
|
1548
1945
|
return value;
|
|
1549
1946
|
}
|
|
1550
1947
|
return {
|
|
1551
1948
|
...value,
|
|
1552
|
-
|
|
1553
|
-
data: value.data ?? new Uint8Array(0)
|
|
1554
|
-
};
|
|
1555
|
-
},
|
|
1556
|
-
(value) => {
|
|
1557
|
-
if (value.accountIndices.length && value.data.byteLength) {
|
|
1558
|
-
return value;
|
|
1559
|
-
}
|
|
1560
|
-
const { accountIndices, data, ...rest } = value;
|
|
1561
|
-
return {
|
|
1562
|
-
...rest,
|
|
1563
|
-
...accountIndices.length ? { accountIndices } : null,
|
|
1564
|
-
...data.byteLength ? { data } : null
|
|
1949
|
+
addressTableLookups: (_a = value.addressTableLookups) != null ? _a : []
|
|
1565
1950
|
};
|
|
1566
1951
|
}
|
|
1567
1952
|
);
|
|
1568
1953
|
}
|
|
1569
|
-
function
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1954
|
+
function getPreludeStructEncoderTuple() {
|
|
1955
|
+
return [
|
|
1956
|
+
["version", getTransactionVersionEncoder()],
|
|
1957
|
+
["header", getMessageHeaderEncoder()],
|
|
1958
|
+
["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],
|
|
1959
|
+
["lifetimeToken", getStringEncoder({ encoding: getBase58Encoder(), size: 32 })],
|
|
1960
|
+
["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })]
|
|
1961
|
+
];
|
|
1574
1962
|
}
|
|
1575
|
-
function
|
|
1576
|
-
return
|
|
1577
|
-
|
|
1578
|
-
|
|
1963
|
+
function getPreludeStructDecoderTuple() {
|
|
1964
|
+
return [
|
|
1965
|
+
["version", getTransactionVersionDecoder()],
|
|
1966
|
+
["header", getMessageHeaderDecoder()],
|
|
1967
|
+
["staticAccounts", getArrayDecoder(getAddressDecoder(), { size: getShortU16Decoder() })],
|
|
1968
|
+
["lifetimeToken", getStringDecoder({ encoding: getBase58Decoder(), size: 32 })],
|
|
1969
|
+
["instructions", getArrayDecoder(getInstructionDecoder(), { size: getShortU16Decoder() })],
|
|
1970
|
+
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
1971
|
+
];
|
|
1579
1972
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
description: "A single byte that encodes the version of the transaction" ,
|
|
1583
|
-
fixedSize: null,
|
|
1584
|
-
maxSize: 1
|
|
1585
|
-
};
|
|
1586
|
-
function deserialize(bytes3, offset = 0) {
|
|
1587
|
-
const firstByte = bytes3[offset];
|
|
1588
|
-
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1589
|
-
return ["legacy", offset];
|
|
1590
|
-
} else {
|
|
1591
|
-
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
1592
|
-
return [version, offset + 1];
|
|
1593
|
-
}
|
|
1973
|
+
function getAddressTableLookupArrayEncoder() {
|
|
1974
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() });
|
|
1594
1975
|
}
|
|
1595
|
-
function
|
|
1596
|
-
|
|
1597
|
-
return new Uint8Array();
|
|
1598
|
-
}
|
|
1599
|
-
if (value < 0 || value > 127) {
|
|
1600
|
-
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
1601
|
-
}
|
|
1602
|
-
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1976
|
+
function getAddressTableLookupArrayDecoder() {
|
|
1977
|
+
return getArrayDecoder(getAddressTableLookupDecoder(), { size: getShortU16Decoder() });
|
|
1603
1978
|
}
|
|
1604
|
-
function
|
|
1605
|
-
return {
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1979
|
+
function getCompiledMessageEncoder() {
|
|
1980
|
+
return createEncoder({
|
|
1981
|
+
getSizeFromValue: (compiledMessage) => {
|
|
1982
|
+
if (compiledMessage.version === "legacy") {
|
|
1983
|
+
return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);
|
|
1984
|
+
} else {
|
|
1985
|
+
return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);
|
|
1986
|
+
}
|
|
1987
|
+
},
|
|
1988
|
+
write: (compiledMessage, bytes, offset) => {
|
|
1989
|
+
if (compiledMessage.version === "legacy") {
|
|
1990
|
+
return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);
|
|
1991
|
+
} else {
|
|
1992
|
+
return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1610
1996
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1997
|
+
function getCompiledMessageDecoder() {
|
|
1998
|
+
return mapDecoder(getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {
|
|
1999
|
+
if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
|
|
2000
|
+
return restOfMessage;
|
|
2001
|
+
}
|
|
2002
|
+
return { ...restOfMessage, addressTableLookups };
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
function getCompiledMessageCodec() {
|
|
2006
|
+
return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
|
|
2007
|
+
}
|
|
2008
|
+
function getCompiledTransaction(transaction) {
|
|
2009
|
+
var _a;
|
|
2010
|
+
const compiledMessage = compileMessage(transaction);
|
|
2011
|
+
let signatures;
|
|
2012
|
+
if ("signatures" in transaction) {
|
|
2013
|
+
signatures = [];
|
|
2014
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
2015
|
+
signatures[ii] = (_a = transaction.signatures[compiledMessage.staticAccounts[ii]]) != null ? _a : new Uint8Array(Array(64).fill(0));
|
|
2016
|
+
}
|
|
1619
2017
|
} else {
|
|
1620
|
-
|
|
1621
|
-
struct([
|
|
1622
|
-
...getPreludeStructSerializerTuple(),
|
|
1623
|
-
["addressTableLookups", getAddressTableLookupsSerializer()]
|
|
1624
|
-
]),
|
|
1625
|
-
(value) => {
|
|
1626
|
-
if (value.version === "legacy") {
|
|
1627
|
-
return value;
|
|
1628
|
-
}
|
|
1629
|
-
return {
|
|
1630
|
-
...value,
|
|
1631
|
-
addressTableLookups: value.addressTableLookups ?? []
|
|
1632
|
-
};
|
|
1633
|
-
}
|
|
1634
|
-
).serialize(compiledMessage);
|
|
2018
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1635
2019
|
}
|
|
2020
|
+
return {
|
|
2021
|
+
compiledMessage,
|
|
2022
|
+
signatures
|
|
2023
|
+
};
|
|
1636
2024
|
}
|
|
1637
|
-
function
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
2025
|
+
function getAccountMetas(message) {
|
|
2026
|
+
const { header } = message;
|
|
2027
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
2028
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
2029
|
+
const accountMetas = [];
|
|
2030
|
+
let accountIndex = 0;
|
|
2031
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
2032
|
+
accountMetas.push({
|
|
2033
|
+
address: message.staticAccounts[accountIndex],
|
|
2034
|
+
role: AccountRole2.WRITABLE_SIGNER
|
|
2035
|
+
});
|
|
2036
|
+
accountIndex++;
|
|
2037
|
+
}
|
|
2038
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
2039
|
+
accountMetas.push({
|
|
2040
|
+
address: message.staticAccounts[accountIndex],
|
|
2041
|
+
role: AccountRole2.READONLY_SIGNER
|
|
2042
|
+
});
|
|
2043
|
+
accountIndex++;
|
|
2044
|
+
}
|
|
2045
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
2046
|
+
accountMetas.push({
|
|
2047
|
+
address: message.staticAccounts[accountIndex],
|
|
2048
|
+
role: AccountRole2.WRITABLE
|
|
2049
|
+
});
|
|
2050
|
+
accountIndex++;
|
|
2051
|
+
}
|
|
2052
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
2053
|
+
accountMetas.push({
|
|
2054
|
+
address: message.staticAccounts[accountIndex],
|
|
2055
|
+
role: AccountRole2.READONLY
|
|
2056
|
+
});
|
|
2057
|
+
accountIndex++;
|
|
2058
|
+
}
|
|
2059
|
+
return accountMetas;
|
|
2060
|
+
}
|
|
2061
|
+
function convertInstruction(instruction, accountMetas) {
|
|
2062
|
+
var _a, _b;
|
|
2063
|
+
const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
|
|
2064
|
+
if (!programAddress) {
|
|
2065
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
2066
|
+
}
|
|
2067
|
+
const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
|
|
2068
|
+
const { data } = instruction;
|
|
2069
|
+
return {
|
|
2070
|
+
programAddress,
|
|
2071
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
2072
|
+
...data && data.length ? { data } : {}
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
2076
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
2077
|
+
return {
|
|
2078
|
+
blockhash: messageLifetimeToken,
|
|
2079
|
+
lastValidBlockHeight: lastValidBlockHeight != null ? lastValidBlockHeight : 2n ** 64n - 1n
|
|
2080
|
+
// U64 MAX
|
|
2081
|
+
};
|
|
2082
|
+
} else {
|
|
2083
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
2084
|
+
assertIsAddress(nonceAccountAddress);
|
|
2085
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
2086
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
2087
|
+
return {
|
|
2088
|
+
nonce: messageLifetimeToken,
|
|
2089
|
+
nonceAccountAddress,
|
|
2090
|
+
nonceAuthorityAddress
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
function convertSignatures(compiledTransaction) {
|
|
2095
|
+
const {
|
|
2096
|
+
compiledMessage: { staticAccounts },
|
|
2097
|
+
signatures
|
|
2098
|
+
} = compiledTransaction;
|
|
2099
|
+
return signatures.reduce((acc, sig, index) => {
|
|
2100
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
2101
|
+
if (allZeros)
|
|
2102
|
+
return acc;
|
|
2103
|
+
const address2 = staticAccounts[index];
|
|
2104
|
+
return { ...acc, [address2]: sig };
|
|
2105
|
+
}, {});
|
|
2106
|
+
}
|
|
2107
|
+
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
2108
|
+
const { compiledMessage } = compiledTransaction;
|
|
2109
|
+
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
2110
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
2111
|
+
}
|
|
2112
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
2113
|
+
if (!feePayer)
|
|
2114
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
2115
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
2116
|
+
const instructions = compiledMessage.instructions.map(
|
|
2117
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
2118
|
+
);
|
|
2119
|
+
const firstInstruction = instructions[0];
|
|
2120
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
2121
|
+
compiledMessage.lifetimeToken,
|
|
2122
|
+
firstInstruction,
|
|
2123
|
+
lastValidBlockHeight
|
|
2124
|
+
);
|
|
2125
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
2126
|
+
return pipe(
|
|
2127
|
+
createTransaction({ version: compiledMessage.version }),
|
|
2128
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
2129
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
2130
|
+
return appendTransactionInstruction(instruction, acc);
|
|
2131
|
+
}, tx),
|
|
2132
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
2133
|
+
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
2134
|
+
);
|
|
2135
|
+
}
|
|
2136
|
+
function getCompiledTransactionEncoder() {
|
|
2137
|
+
return getStructEncoder([
|
|
2138
|
+
["signatures", getArrayEncoder(getBytesEncoder({ size: 64 }), { size: getShortU16Encoder() })],
|
|
2139
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
2140
|
+
]);
|
|
2141
|
+
}
|
|
2142
|
+
function getCompiledTransactionDecoder() {
|
|
2143
|
+
return getStructDecoder([
|
|
1648
2144
|
[
|
|
1649
|
-
"
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
encoding: base58,
|
|
1653
|
-
size: 32
|
|
2145
|
+
"signatures",
|
|
2146
|
+
getArrayDecoder(getBytesDecoder({ size: 64 }), {
|
|
2147
|
+
size: getShortU16Decoder()
|
|
1654
2148
|
})
|
|
1655
2149
|
],
|
|
1656
|
-
[
|
|
1657
|
-
|
|
1658
|
-
array(getInstructionCodec(), {
|
|
1659
|
-
description: "A compact-array of instructions belonging to this transaction" ,
|
|
1660
|
-
size: shortU16()
|
|
1661
|
-
})
|
|
1662
|
-
]
|
|
1663
|
-
];
|
|
2150
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
2151
|
+
]);
|
|
1664
2152
|
}
|
|
1665
|
-
function
|
|
1666
|
-
return
|
|
1667
|
-
...{ description: "A compact array of address table lookups belonging to this transaction" } ,
|
|
1668
|
-
size: shortU16()
|
|
1669
|
-
});
|
|
2153
|
+
function getTransactionEncoder() {
|
|
2154
|
+
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
1670
2155
|
}
|
|
1671
|
-
function
|
|
1672
|
-
return
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
};
|
|
2156
|
+
function getTransactionDecoder(lastValidBlockHeight) {
|
|
2157
|
+
return mapDecoder(
|
|
2158
|
+
getCompiledTransactionDecoder(),
|
|
2159
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
|
|
2160
|
+
);
|
|
1677
2161
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1681
|
-
return signature;
|
|
2162
|
+
function getTransactionCodec(lastValidBlockHeight) {
|
|
2163
|
+
return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
1682
2164
|
}
|
|
1683
|
-
|
|
2165
|
+
var base58Decoder;
|
|
2166
|
+
function getSignatureFromTransaction(transaction) {
|
|
2167
|
+
if (!base58Decoder)
|
|
2168
|
+
base58Decoder = getBase58Decoder();
|
|
2169
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
2170
|
+
if (!signatureBytes) {
|
|
2171
|
+
throw new Error(
|
|
2172
|
+
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
const transactionSignature = base58Decoder.decode(signatureBytes);
|
|
2176
|
+
return transactionSignature;
|
|
2177
|
+
}
|
|
2178
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1684
2179
|
const compiledMessage = compileMessage(transaction);
|
|
1685
2180
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
2181
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
1686
2182
|
const publicKeySignaturePairs = await Promise.all(
|
|
1687
2183
|
keyPairs.map(
|
|
1688
|
-
(keyPair) => Promise.all([
|
|
1689
|
-
|
|
1690
|
-
|
|
2184
|
+
(keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
|
|
2185
|
+
)
|
|
2186
|
+
);
|
|
2187
|
+
for (const [signerPublicKey, signature2] of publicKeySignaturePairs) {
|
|
2188
|
+
nextSignatures[signerPublicKey] = signature2;
|
|
2189
|
+
}
|
|
2190
|
+
const out = {
|
|
2191
|
+
...transaction,
|
|
2192
|
+
signatures: nextSignatures
|
|
2193
|
+
};
|
|
2194
|
+
Object.freeze(out);
|
|
2195
|
+
return out;
|
|
2196
|
+
}
|
|
2197
|
+
async function signTransaction(keyPairs, transaction) {
|
|
2198
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
2199
|
+
assertTransactionIsFullySigned(out);
|
|
2200
|
+
Object.freeze(out);
|
|
2201
|
+
return out;
|
|
2202
|
+
}
|
|
2203
|
+
function assertTransactionIsFullySigned(transaction) {
|
|
2204
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
|
|
2205
|
+
var _a, _b;
|
|
2206
|
+
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : [];
|
|
2207
|
+
}).map((a) => a.address);
|
|
2208
|
+
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
2209
|
+
requiredSigners.forEach((address2) => {
|
|
2210
|
+
if (!transaction.signatures[address2]) {
|
|
2211
|
+
throw new Error(`Transaction is missing signature for address \`${address2}\``);
|
|
2212
|
+
}
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
function getBase64EncodedWireTransaction(transaction) {
|
|
2216
|
+
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
2217
|
+
return getBase64Decoder().decode(wireTransactionBytes);
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
// src/airdrop.ts
|
|
2221
|
+
init_env_shim();
|
|
2222
|
+
|
|
2223
|
+
// src/airdrop-confirmer.ts
|
|
2224
|
+
init_env_shim();
|
|
2225
|
+
|
|
2226
|
+
// src/transaction-confirmation-strategy-racer.ts
|
|
2227
|
+
init_env_shim();
|
|
2228
|
+
async function raceStrategies(signature2, config, getSpecificStrategiesForRace) {
|
|
2229
|
+
const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
|
|
2230
|
+
callerAbortSignal == null ? void 0 : callerAbortSignal.throwIfAborted();
|
|
2231
|
+
const abortController = new AbortController();
|
|
2232
|
+
if (callerAbortSignal) {
|
|
2233
|
+
const handleAbort = () => {
|
|
2234
|
+
abortController.abort();
|
|
2235
|
+
};
|
|
2236
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
2237
|
+
}
|
|
2238
|
+
try {
|
|
2239
|
+
const specificStrategies = getSpecificStrategiesForRace({
|
|
2240
|
+
...config,
|
|
2241
|
+
abortSignal: abortController.signal
|
|
2242
|
+
});
|
|
2243
|
+
return await Promise.race([
|
|
2244
|
+
getRecentSignatureConfirmationPromise({
|
|
2245
|
+
abortSignal: abortController.signal,
|
|
2246
|
+
commitment,
|
|
2247
|
+
signature: signature2
|
|
2248
|
+
}),
|
|
2249
|
+
...specificStrategies
|
|
2250
|
+
]);
|
|
2251
|
+
} finally {
|
|
2252
|
+
abortController.abort();
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
// src/transaction-confirmation-strategy-recent-signature.ts
|
|
2257
|
+
init_env_shim();
|
|
2258
|
+
function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
2259
|
+
return async function getRecentSignatureConfirmationPromise({
|
|
2260
|
+
abortSignal: callerAbortSignal,
|
|
2261
|
+
commitment,
|
|
2262
|
+
signature: signature2
|
|
2263
|
+
}) {
|
|
2264
|
+
const abortController = new AbortController();
|
|
2265
|
+
function handleAbort() {
|
|
2266
|
+
abortController.abort();
|
|
2267
|
+
}
|
|
2268
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
2269
|
+
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature2, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
2270
|
+
const signatureDidCommitPromise = (async () => {
|
|
2271
|
+
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
2272
|
+
if (signatureStatusNotification.value.err) {
|
|
2273
|
+
throw new Error(`The transaction with signature \`${signature2}\` failed.`, {
|
|
2274
|
+
cause: signatureStatusNotification.value.err
|
|
2275
|
+
});
|
|
2276
|
+
} else {
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
})();
|
|
2281
|
+
const signatureStatusLookupPromise = (async () => {
|
|
2282
|
+
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature2]).send({ abortSignal: abortController.signal });
|
|
2283
|
+
const signatureStatus = signatureStatusResults[0];
|
|
2284
|
+
if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
2285
|
+
return;
|
|
2286
|
+
} else {
|
|
2287
|
+
await new Promise(() => {
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
})();
|
|
2291
|
+
try {
|
|
2292
|
+
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
2293
|
+
} finally {
|
|
2294
|
+
abortController.abort();
|
|
2295
|
+
}
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
// src/transaction-confirmation-strategy-timeout.ts
|
|
2300
|
+
init_env_shim();
|
|
2301
|
+
async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
|
|
2302
|
+
return await new Promise((_, reject) => {
|
|
2303
|
+
const handleAbort = (e3) => {
|
|
2304
|
+
clearTimeout(timeoutId);
|
|
2305
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
2306
|
+
reject(abortError);
|
|
2307
|
+
};
|
|
2308
|
+
callerAbortSignal.addEventListener("abort", handleAbort);
|
|
2309
|
+
const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
|
|
2310
|
+
const startMs = performance.now();
|
|
2311
|
+
const timeoutId = (
|
|
2312
|
+
// We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
|
|
2313
|
+
// elapsed time instead of active time.
|
|
2314
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
|
|
2315
|
+
setTimeout(() => {
|
|
2316
|
+
const elapsedMs = performance.now() - startMs;
|
|
2317
|
+
reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
|
|
2318
|
+
}, timeoutMs)
|
|
2319
|
+
);
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
// src/airdrop-confirmer.ts
|
|
2324
|
+
function createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
2325
|
+
rpc,
|
|
2326
|
+
rpcSubscriptions
|
|
2327
|
+
}) {
|
|
2328
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
2329
|
+
rpc,
|
|
2330
|
+
rpcSubscriptions
|
|
2331
|
+
);
|
|
2332
|
+
return async function confirmSignatureOnlyRecentTransaction(config) {
|
|
2333
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
2334
|
+
...config,
|
|
2335
|
+
getRecentSignatureConfirmationPromise,
|
|
2336
|
+
getTimeoutPromise
|
|
2337
|
+
});
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
async function waitForRecentTransactionConfirmationUntilTimeout(config) {
|
|
2341
|
+
await raceStrategies(
|
|
2342
|
+
config.signature,
|
|
2343
|
+
config,
|
|
2344
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
|
|
2345
|
+
return [
|
|
2346
|
+
getTimeoutPromise2({
|
|
2347
|
+
abortSignal,
|
|
2348
|
+
commitment
|
|
2349
|
+
})
|
|
2350
|
+
];
|
|
2351
|
+
}
|
|
2352
|
+
);
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
// src/airdrop.ts
|
|
2356
|
+
function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
|
|
2357
|
+
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
2358
|
+
rpc,
|
|
2359
|
+
rpcSubscriptions
|
|
2360
|
+
});
|
|
2361
|
+
return async function requestAirdrop(config) {
|
|
2362
|
+
return await requestAndConfirmAirdrop({
|
|
2363
|
+
...config,
|
|
2364
|
+
confirmSignatureOnlyTransaction,
|
|
2365
|
+
rpc
|
|
2366
|
+
});
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
async function requestAndConfirmAirdrop({
|
|
2370
|
+
abortSignal,
|
|
2371
|
+
commitment,
|
|
2372
|
+
confirmSignatureOnlyTransaction,
|
|
2373
|
+
lamports: lamports2,
|
|
2374
|
+
recipientAddress,
|
|
2375
|
+
rpc
|
|
2376
|
+
}) {
|
|
2377
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports2, { commitment }).send({ abortSignal });
|
|
2378
|
+
await confirmSignatureOnlyTransaction({
|
|
2379
|
+
abortSignal,
|
|
2380
|
+
commitment,
|
|
2381
|
+
signature: airdropTransactionSignature
|
|
2382
|
+
});
|
|
2383
|
+
return airdropTransactionSignature;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
// src/rpc.ts
|
|
2387
|
+
init_env_shim();
|
|
2388
|
+
|
|
2389
|
+
// ../rpc-core/dist/index.browser.js
|
|
2390
|
+
init_env_shim();
|
|
2391
|
+
function createJsonRpcApi(config) {
|
|
2392
|
+
return new Proxy({}, {
|
|
2393
|
+
defineProperty() {
|
|
2394
|
+
return false;
|
|
2395
|
+
},
|
|
2396
|
+
deleteProperty() {
|
|
2397
|
+
return false;
|
|
2398
|
+
},
|
|
2399
|
+
get(...args) {
|
|
2400
|
+
const [_, p] = args;
|
|
2401
|
+
const methodName = p.toString();
|
|
2402
|
+
return function(...rawParams) {
|
|
2403
|
+
const params = (config == null ? void 0 : config.parametersTransformer) ? config == null ? void 0 : config.parametersTransformer(rawParams, methodName) : rawParams;
|
|
2404
|
+
const responseTransformer = (config == null ? void 0 : config.responseTransformer) ? config == null ? void 0 : config.responseTransformer : (rawResponse) => rawResponse;
|
|
2405
|
+
return {
|
|
2406
|
+
methodName,
|
|
2407
|
+
params,
|
|
2408
|
+
responseTransformer
|
|
2409
|
+
};
|
|
2410
|
+
};
|
|
2411
|
+
}
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
function createJsonRpcSubscriptionsApi(config) {
|
|
2415
|
+
return new Proxy({}, {
|
|
2416
|
+
defineProperty() {
|
|
2417
|
+
return false;
|
|
2418
|
+
},
|
|
2419
|
+
deleteProperty() {
|
|
2420
|
+
return false;
|
|
2421
|
+
},
|
|
2422
|
+
get(...args) {
|
|
2423
|
+
const [_, p] = args;
|
|
2424
|
+
const notificationName = p.toString();
|
|
2425
|
+
return function(...rawParams) {
|
|
2426
|
+
const params = (config == null ? void 0 : config.parametersTransformer) ? config == null ? void 0 : config.parametersTransformer(rawParams, notificationName) : rawParams;
|
|
2427
|
+
const responseTransformer = (config == null ? void 0 : config.responseTransformer) ? config == null ? void 0 : config.responseTransformer : (rawResponse) => rawResponse;
|
|
2428
|
+
const subscribeMethodName = (config == null ? void 0 : config.subscribeNotificationNameTransformer) ? config == null ? void 0 : config.subscribeNotificationNameTransformer(notificationName) : notificationName;
|
|
2429
|
+
const unsubscribeMethodName = (config == null ? void 0 : config.unsubscribeNotificationNameTransformer) ? config == null ? void 0 : config.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
|
|
2430
|
+
return {
|
|
2431
|
+
params,
|
|
2432
|
+
responseTransformer,
|
|
2433
|
+
subscribeMethodName,
|
|
2434
|
+
unsubscribeMethodName
|
|
2435
|
+
};
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
function applyDefaultCommitment({
|
|
2441
|
+
commitmentPropertyName,
|
|
2442
|
+
params,
|
|
2443
|
+
optionsObjectPositionInParams,
|
|
2444
|
+
overrideCommitment
|
|
2445
|
+
}) {
|
|
2446
|
+
const paramInTargetPosition = params[optionsObjectPositionInParams];
|
|
2447
|
+
if (
|
|
2448
|
+
// There's no config.
|
|
2449
|
+
paramInTargetPosition === void 0 || // There is a config object.
|
|
2450
|
+
paramInTargetPosition && typeof paramInTargetPosition === "object" && !Array.isArray(paramInTargetPosition)
|
|
2451
|
+
) {
|
|
2452
|
+
if (
|
|
2453
|
+
// The config object already has a commitment set.
|
|
2454
|
+
paramInTargetPosition && commitmentPropertyName in paramInTargetPosition
|
|
2455
|
+
) {
|
|
2456
|
+
if (!paramInTargetPosition[commitmentPropertyName] || paramInTargetPosition[commitmentPropertyName] === "finalized") {
|
|
2457
|
+
const nextParams = [...params];
|
|
2458
|
+
const {
|
|
2459
|
+
[commitmentPropertyName]: _,
|
|
2460
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2461
|
+
...rest
|
|
2462
|
+
} = paramInTargetPosition;
|
|
2463
|
+
if (Object.keys(rest).length > 0) {
|
|
2464
|
+
nextParams[optionsObjectPositionInParams] = rest;
|
|
2465
|
+
} else {
|
|
2466
|
+
if (optionsObjectPositionInParams === nextParams.length - 1) {
|
|
2467
|
+
nextParams.length--;
|
|
2468
|
+
} else {
|
|
2469
|
+
nextParams[optionsObjectPositionInParams] = void 0;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
return nextParams;
|
|
2473
|
+
}
|
|
2474
|
+
} else if (overrideCommitment !== "finalized") {
|
|
2475
|
+
const nextParams = [...params];
|
|
2476
|
+
nextParams[optionsObjectPositionInParams] = {
|
|
2477
|
+
...paramInTargetPosition,
|
|
2478
|
+
[commitmentPropertyName]: overrideCommitment
|
|
2479
|
+
};
|
|
2480
|
+
return nextParams;
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
return params;
|
|
2484
|
+
}
|
|
2485
|
+
function downcastNodeToNumberIfBigint(value) {
|
|
2486
|
+
return typeof value === "bigint" ? (
|
|
2487
|
+
// FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
|
|
2488
|
+
// JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
|
|
2489
|
+
// downcasting `bigints` to `numbers`.
|
|
2490
|
+
Number(value)
|
|
2491
|
+
) : value;
|
|
2492
|
+
}
|
|
2493
|
+
function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
|
|
2494
|
+
return (value, { keyPath }) => {
|
|
2495
|
+
if (typeof value === "bigint") {
|
|
2496
|
+
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
|
|
2497
|
+
onIntegerOverflow(keyPath, value);
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
return value;
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
var OPTIONS_OBJECT_POSITION_BY_METHOD = {
|
|
2504
|
+
accountNotifications: 1,
|
|
2505
|
+
blockNotifications: 1,
|
|
2506
|
+
getAccountInfo: 1,
|
|
2507
|
+
getBalance: 1,
|
|
2508
|
+
getBlock: 1,
|
|
2509
|
+
getBlockHeight: 0,
|
|
2510
|
+
getBlockProduction: 0,
|
|
2511
|
+
getBlocks: 2,
|
|
2512
|
+
getBlocksWithLimit: 2,
|
|
2513
|
+
getConfirmedBlock: 1,
|
|
2514
|
+
getConfirmedBlocks: 1,
|
|
2515
|
+
getConfirmedBlocksWithLimit: 2,
|
|
2516
|
+
getConfirmedSignaturesForAddress2: 1,
|
|
2517
|
+
getConfirmedTransaction: 1,
|
|
2518
|
+
getEpochInfo: 0,
|
|
2519
|
+
getFeeCalculatorForBlockhash: 1,
|
|
2520
|
+
getFeeForMessage: 1,
|
|
2521
|
+
getFees: 1,
|
|
2522
|
+
getInflationGovernor: 0,
|
|
2523
|
+
getInflationReward: 1,
|
|
2524
|
+
getLargestAccounts: 0,
|
|
2525
|
+
getLatestBlockhash: 0,
|
|
2526
|
+
getLeaderSchedule: 1,
|
|
2527
|
+
getMinimumBalanceForRentExemption: 1,
|
|
2528
|
+
getMultipleAccounts: 1,
|
|
2529
|
+
getProgramAccounts: 1,
|
|
2530
|
+
getRecentBlockhash: 1,
|
|
2531
|
+
getSignaturesForAddress: 1,
|
|
2532
|
+
getSlot: 0,
|
|
2533
|
+
getSlotLeader: 0,
|
|
2534
|
+
getStakeActivation: 1,
|
|
2535
|
+
getStakeMinimumDelegation: 0,
|
|
2536
|
+
getSupply: 0,
|
|
2537
|
+
getTokenAccountBalance: 1,
|
|
2538
|
+
getTokenAccountsByDelegate: 2,
|
|
2539
|
+
getTokenAccountsByOwner: 2,
|
|
2540
|
+
getTokenLargestAccounts: 1,
|
|
2541
|
+
getTokenSupply: 1,
|
|
2542
|
+
getTransaction: 1,
|
|
2543
|
+
getTransactionCount: 0,
|
|
2544
|
+
getVoteAccounts: 0,
|
|
2545
|
+
isBlockhashValid: 1,
|
|
2546
|
+
logsNotifications: 1,
|
|
2547
|
+
programNotifications: 1,
|
|
2548
|
+
requestAirdrop: 2,
|
|
2549
|
+
sendTransaction: 1,
|
|
2550
|
+
signatureNotifications: 1,
|
|
2551
|
+
simulateTransaction: 1
|
|
2552
|
+
};
|
|
2553
|
+
var KEYPATH_WILDCARD = {};
|
|
2554
|
+
function getTreeWalker(visitors) {
|
|
2555
|
+
return function traverse(node, state) {
|
|
2556
|
+
if (Array.isArray(node)) {
|
|
2557
|
+
return node.map((element, ii) => {
|
|
2558
|
+
const nextState = {
|
|
2559
|
+
...state,
|
|
2560
|
+
keyPath: [...state.keyPath, ii]
|
|
2561
|
+
};
|
|
2562
|
+
return traverse(element, nextState);
|
|
2563
|
+
});
|
|
2564
|
+
} else if (typeof node === "object" && node !== null) {
|
|
2565
|
+
const out = {};
|
|
2566
|
+
for (const propName in node) {
|
|
2567
|
+
if (!Object.prototype.hasOwnProperty.call(node, propName)) {
|
|
2568
|
+
continue;
|
|
2569
|
+
}
|
|
2570
|
+
const nextState = {
|
|
2571
|
+
...state,
|
|
2572
|
+
keyPath: [...state.keyPath, propName]
|
|
2573
|
+
};
|
|
2574
|
+
out[propName] = traverse(node[propName], nextState);
|
|
2575
|
+
}
|
|
2576
|
+
return out;
|
|
2577
|
+
} else {
|
|
2578
|
+
return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
function getParamsPatcherForSolanaLabsRpc(config) {
|
|
2583
|
+
const defaultCommitment = config == null ? void 0 : config.defaultCommitment;
|
|
2584
|
+
const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
|
|
2585
|
+
return (rawParams, methodName) => {
|
|
2586
|
+
const traverse = getTreeWalker([
|
|
2587
|
+
...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
|
|
2588
|
+
downcastNodeToNumberIfBigint
|
|
2589
|
+
]);
|
|
2590
|
+
const initialState = {
|
|
2591
|
+
keyPath: []
|
|
2592
|
+
};
|
|
2593
|
+
const patchedParams = traverse(rawParams, initialState);
|
|
2594
|
+
if (!Array.isArray(patchedParams)) {
|
|
2595
|
+
return patchedParams;
|
|
2596
|
+
}
|
|
2597
|
+
const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName];
|
|
2598
|
+
if (optionsObjectPositionInParams == null) {
|
|
2599
|
+
return patchedParams;
|
|
2600
|
+
}
|
|
2601
|
+
return applyDefaultCommitment({
|
|
2602
|
+
commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment",
|
|
2603
|
+
optionsObjectPositionInParams,
|
|
2604
|
+
overrideCommitment: defaultCommitment,
|
|
2605
|
+
params: patchedParams
|
|
2606
|
+
});
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
var jsonParsedTokenAccountsConfigs = [
|
|
2610
|
+
// parsed Token/Token22 token account
|
|
2611
|
+
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
2612
|
+
["data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
2613
|
+
["data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
2614
|
+
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
|
|
2615
|
+
["data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
2616
|
+
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
|
|
2617
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
|
|
2618
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
|
|
2619
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
2620
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
|
|
2621
|
+
];
|
|
2622
|
+
var jsonParsedAccountsConfigs = [
|
|
2623
|
+
...jsonParsedTokenAccountsConfigs,
|
|
2624
|
+
// parsed AddressTableLookup account
|
|
2625
|
+
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
2626
|
+
// parsed Config account
|
|
2627
|
+
["data", "parsed", "info", "slashPenalty"],
|
|
2628
|
+
["data", "parsed", "info", "warmupCooldownRate"],
|
|
2629
|
+
// parsed Token/Token22 mint account
|
|
2630
|
+
["data", "parsed", "info", "decimals"],
|
|
2631
|
+
// parsed Token/Token22 multisig account
|
|
2632
|
+
["data", "parsed", "info", "numRequiredSigners"],
|
|
2633
|
+
["data", "parsed", "info", "numValidSigners"],
|
|
2634
|
+
// parsed Stake account
|
|
2635
|
+
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
2636
|
+
// parsed Sysvar rent account
|
|
2637
|
+
["data", "parsed", "info", "exemptionThreshold"],
|
|
2638
|
+
["data", "parsed", "info", "burnPercent"],
|
|
2639
|
+
// parsed Vote account
|
|
2640
|
+
["data", "parsed", "info", "commission"],
|
|
2641
|
+
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
2642
|
+
];
|
|
2643
|
+
var memoizedNotificationKeypaths;
|
|
2644
|
+
var memoizedResponseKeypaths;
|
|
2645
|
+
function getAllowedNumericKeypathsForNotification() {
|
|
2646
|
+
if (!memoizedNotificationKeypaths) {
|
|
2647
|
+
memoizedNotificationKeypaths = {
|
|
2648
|
+
accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
2649
|
+
blockNotifications: [
|
|
2650
|
+
["value", "block", "blockTime"],
|
|
2651
|
+
[
|
|
2652
|
+
"value",
|
|
2653
|
+
"block",
|
|
2654
|
+
"transactions",
|
|
2655
|
+
KEYPATH_WILDCARD,
|
|
2656
|
+
"meta",
|
|
2657
|
+
"preTokenBalances",
|
|
2658
|
+
KEYPATH_WILDCARD,
|
|
2659
|
+
"accountIndex"
|
|
2660
|
+
],
|
|
2661
|
+
[
|
|
2662
|
+
"value",
|
|
2663
|
+
"block",
|
|
2664
|
+
"transactions",
|
|
2665
|
+
KEYPATH_WILDCARD,
|
|
2666
|
+
"meta",
|
|
2667
|
+
"preTokenBalances",
|
|
2668
|
+
KEYPATH_WILDCARD,
|
|
2669
|
+
"uiTokenAmount",
|
|
2670
|
+
"decimals"
|
|
2671
|
+
],
|
|
2672
|
+
[
|
|
2673
|
+
"value",
|
|
2674
|
+
"block",
|
|
2675
|
+
"transactions",
|
|
2676
|
+
KEYPATH_WILDCARD,
|
|
2677
|
+
"meta",
|
|
2678
|
+
"postTokenBalances",
|
|
2679
|
+
KEYPATH_WILDCARD,
|
|
2680
|
+
"accountIndex"
|
|
2681
|
+
],
|
|
2682
|
+
[
|
|
2683
|
+
"value",
|
|
2684
|
+
"block",
|
|
2685
|
+
"transactions",
|
|
2686
|
+
KEYPATH_WILDCARD,
|
|
2687
|
+
"meta",
|
|
2688
|
+
"postTokenBalances",
|
|
2689
|
+
KEYPATH_WILDCARD,
|
|
2690
|
+
"uiTokenAmount",
|
|
2691
|
+
"decimals"
|
|
2692
|
+
],
|
|
2693
|
+
["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
2694
|
+
[
|
|
2695
|
+
"value",
|
|
2696
|
+
"block",
|
|
2697
|
+
"transactions",
|
|
2698
|
+
KEYPATH_WILDCARD,
|
|
2699
|
+
"meta",
|
|
2700
|
+
"innerInstructions",
|
|
2701
|
+
KEYPATH_WILDCARD,
|
|
2702
|
+
"index"
|
|
2703
|
+
],
|
|
2704
|
+
[
|
|
2705
|
+
"value",
|
|
2706
|
+
"block",
|
|
2707
|
+
"transactions",
|
|
2708
|
+
KEYPATH_WILDCARD,
|
|
2709
|
+
"meta",
|
|
2710
|
+
"innerInstructions",
|
|
2711
|
+
KEYPATH_WILDCARD,
|
|
2712
|
+
"instructions",
|
|
2713
|
+
KEYPATH_WILDCARD,
|
|
2714
|
+
"programIdIndex"
|
|
2715
|
+
],
|
|
2716
|
+
[
|
|
2717
|
+
"value",
|
|
2718
|
+
"block",
|
|
2719
|
+
"transactions",
|
|
2720
|
+
KEYPATH_WILDCARD,
|
|
2721
|
+
"meta",
|
|
2722
|
+
"innerInstructions",
|
|
2723
|
+
KEYPATH_WILDCARD,
|
|
2724
|
+
"instructions",
|
|
2725
|
+
KEYPATH_WILDCARD,
|
|
2726
|
+
"accounts",
|
|
2727
|
+
KEYPATH_WILDCARD
|
|
2728
|
+
],
|
|
2729
|
+
[
|
|
2730
|
+
"value",
|
|
2731
|
+
"block",
|
|
2732
|
+
"transactions",
|
|
2733
|
+
KEYPATH_WILDCARD,
|
|
2734
|
+
"transaction",
|
|
2735
|
+
"message",
|
|
2736
|
+
"addressTableLookups",
|
|
2737
|
+
KEYPATH_WILDCARD,
|
|
2738
|
+
"writableIndexes",
|
|
2739
|
+
KEYPATH_WILDCARD
|
|
2740
|
+
],
|
|
2741
|
+
[
|
|
2742
|
+
"value",
|
|
2743
|
+
"block",
|
|
2744
|
+
"transactions",
|
|
2745
|
+
KEYPATH_WILDCARD,
|
|
2746
|
+
"transaction",
|
|
2747
|
+
"message",
|
|
2748
|
+
"addressTableLookups",
|
|
2749
|
+
KEYPATH_WILDCARD,
|
|
2750
|
+
"readonlyIndexes",
|
|
2751
|
+
KEYPATH_WILDCARD
|
|
2752
|
+
],
|
|
2753
|
+
[
|
|
2754
|
+
"value",
|
|
2755
|
+
"block",
|
|
2756
|
+
"transactions",
|
|
2757
|
+
KEYPATH_WILDCARD,
|
|
2758
|
+
"transaction",
|
|
2759
|
+
"message",
|
|
2760
|
+
"instructions",
|
|
2761
|
+
KEYPATH_WILDCARD,
|
|
2762
|
+
"programIdIndex"
|
|
2763
|
+
],
|
|
2764
|
+
[
|
|
2765
|
+
"value",
|
|
2766
|
+
"block",
|
|
2767
|
+
"transactions",
|
|
2768
|
+
KEYPATH_WILDCARD,
|
|
2769
|
+
"transaction",
|
|
2770
|
+
"message",
|
|
2771
|
+
"instructions",
|
|
2772
|
+
KEYPATH_WILDCARD,
|
|
2773
|
+
"accounts",
|
|
2774
|
+
KEYPATH_WILDCARD
|
|
2775
|
+
],
|
|
2776
|
+
[
|
|
2777
|
+
"value",
|
|
2778
|
+
"block",
|
|
2779
|
+
"transactions",
|
|
2780
|
+
KEYPATH_WILDCARD,
|
|
2781
|
+
"transaction",
|
|
2782
|
+
"message",
|
|
2783
|
+
"header",
|
|
2784
|
+
"numReadonlySignedAccounts"
|
|
2785
|
+
],
|
|
2786
|
+
[
|
|
2787
|
+
"value",
|
|
2788
|
+
"block",
|
|
2789
|
+
"transactions",
|
|
2790
|
+
KEYPATH_WILDCARD,
|
|
2791
|
+
"transaction",
|
|
2792
|
+
"message",
|
|
2793
|
+
"header",
|
|
2794
|
+
"numReadonlyUnsignedAccounts"
|
|
2795
|
+
],
|
|
2796
|
+
[
|
|
2797
|
+
"value",
|
|
2798
|
+
"block",
|
|
2799
|
+
"transactions",
|
|
2800
|
+
KEYPATH_WILDCARD,
|
|
2801
|
+
"transaction",
|
|
2802
|
+
"message",
|
|
2803
|
+
"header",
|
|
2804
|
+
"numRequiredSignatures"
|
|
2805
|
+
],
|
|
2806
|
+
["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
|
|
2807
|
+
],
|
|
2808
|
+
programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
2809
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
2810
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
1691
2811
|
])
|
|
1692
|
-
|
|
1693
|
-
);
|
|
1694
|
-
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
1695
|
-
nextSignatures[signerPublicKey] = signature;
|
|
1696
|
-
}
|
|
1697
|
-
const out = {
|
|
1698
|
-
...transaction,
|
|
1699
|
-
signatures: nextSignatures
|
|
1700
|
-
};
|
|
1701
|
-
Object.freeze(out);
|
|
1702
|
-
return out;
|
|
1703
|
-
}
|
|
1704
|
-
function getCompiledTransaction(transaction) {
|
|
1705
|
-
const compiledMessage = compileMessage(transaction);
|
|
1706
|
-
let signatures;
|
|
1707
|
-
if ("signatures" in transaction) {
|
|
1708
|
-
signatures = [];
|
|
1709
|
-
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1710
|
-
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1711
|
-
}
|
|
1712
|
-
} else {
|
|
1713
|
-
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1714
|
-
}
|
|
1715
|
-
return {
|
|
1716
|
-
compiledMessage,
|
|
1717
|
-
signatures
|
|
1718
|
-
};
|
|
1719
|
-
}
|
|
1720
|
-
var BASE_CONFIG3 = {
|
|
1721
|
-
description: "The wire format of a Solana transaction" ,
|
|
1722
|
-
fixedSize: null,
|
|
1723
|
-
maxSize: null
|
|
1724
|
-
};
|
|
1725
|
-
function serialize3(transaction) {
|
|
1726
|
-
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1727
|
-
return struct([
|
|
1728
|
-
[
|
|
1729
|
-
"signatures",
|
|
1730
|
-
array(bytes({ size: 64 }), {
|
|
1731
|
-
...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
|
|
1732
|
-
size: shortU16()
|
|
1733
|
-
})
|
|
1734
|
-
],
|
|
1735
|
-
["compiledMessage", getCompiledMessageEncoder()]
|
|
1736
|
-
]).serialize(compiledTransaction);
|
|
1737
|
-
}
|
|
1738
|
-
function getTransactionEncoder() {
|
|
1739
|
-
return {
|
|
1740
|
-
...BASE_CONFIG3,
|
|
1741
|
-
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1742
|
-
serialize: serialize3
|
|
1743
|
-
};
|
|
1744
|
-
}
|
|
1745
|
-
function getBase64EncodedWireTransaction(transaction) {
|
|
1746
|
-
const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
|
|
1747
|
-
{
|
|
1748
|
-
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
// src/rpc.ts
|
|
1753
|
-
init_env_shim();
|
|
1754
|
-
|
|
1755
|
-
// ../functional/dist/index.browser.js
|
|
1756
|
-
init_env_shim();
|
|
1757
|
-
function pipe(init, ...fns) {
|
|
1758
|
-
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
// ../rpc-core/dist/index.browser.js
|
|
1762
|
-
init_env_shim();
|
|
1763
|
-
function visitNode(value, keyPath, onIntegerOverflow) {
|
|
1764
|
-
if (Array.isArray(value)) {
|
|
1765
|
-
return value.map(
|
|
1766
|
-
(element, ii) => visitNode(element, [...keyPath, ii], onIntegerOverflow)
|
|
1767
|
-
);
|
|
1768
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1769
|
-
const out = {};
|
|
1770
|
-
for (const propName in value) {
|
|
1771
|
-
if (Object.prototype.hasOwnProperty.call(value, propName)) {
|
|
1772
|
-
out[propName] = visitNode(value[propName], [...keyPath, propName], onIntegerOverflow);
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
return out;
|
|
1776
|
-
} else if (typeof value === "bigint") {
|
|
1777
|
-
if (onIntegerOverflow && (value > Number.MAX_SAFE_INTEGER || value < -Number.MAX_SAFE_INTEGER)) {
|
|
1778
|
-
onIntegerOverflow(keyPath, value);
|
|
1779
|
-
}
|
|
1780
|
-
return Number(value);
|
|
1781
|
-
} else {
|
|
1782
|
-
return value;
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
function patchParamsForSolanaLabsRpc(params, onIntegerOverflow) {
|
|
1786
|
-
return visitNode(params, [], onIntegerOverflow);
|
|
1787
|
-
}
|
|
1788
|
-
var KEYPATH_WILDCARD = {};
|
|
1789
|
-
var memoizedNotificationKeypaths;
|
|
1790
|
-
var memoizedResponseKeypaths;
|
|
1791
|
-
function getAllowedNumericKeypathsForNotification() {
|
|
1792
|
-
if (!memoizedNotificationKeypaths) {
|
|
1793
|
-
memoizedNotificationKeypaths = {};
|
|
2812
|
+
};
|
|
1794
2813
|
}
|
|
1795
2814
|
return memoizedNotificationKeypaths;
|
|
1796
2815
|
}
|
|
1797
2816
|
function getAllowedNumericKeypathsForResponse() {
|
|
1798
2817
|
if (!memoizedResponseKeypaths) {
|
|
1799
|
-
const jsonParsedTokenAccountsConfigs = [
|
|
1800
|
-
// parsed Token/Token22 token account
|
|
1801
|
-
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
1802
|
-
["data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
1803
|
-
["data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
1804
|
-
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
|
|
1805
|
-
["data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
1806
|
-
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
|
|
1807
|
-
[
|
|
1808
|
-
"data",
|
|
1809
|
-
"parsed",
|
|
1810
|
-
"info",
|
|
1811
|
-
"extensions",
|
|
1812
|
-
KEYPATH_WILDCARD,
|
|
1813
|
-
"state",
|
|
1814
|
-
"olderTransferFee",
|
|
1815
|
-
"transferFeeBasisPoints"
|
|
1816
|
-
],
|
|
1817
|
-
[
|
|
1818
|
-
"data",
|
|
1819
|
-
"parsed",
|
|
1820
|
-
"info",
|
|
1821
|
-
"extensions",
|
|
1822
|
-
KEYPATH_WILDCARD,
|
|
1823
|
-
"state",
|
|
1824
|
-
"newerTransferFee",
|
|
1825
|
-
"transferFeeBasisPoints"
|
|
1826
|
-
],
|
|
1827
|
-
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
1828
|
-
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
|
|
1829
|
-
];
|
|
1830
|
-
const jsonParsedAccountsConfigs = [
|
|
1831
|
-
...jsonParsedTokenAccountsConfigs,
|
|
1832
|
-
// parsed AddressTableLookup account
|
|
1833
|
-
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
1834
|
-
// parsed Config account
|
|
1835
|
-
["data", "parsed", "info", "slashPenalty"],
|
|
1836
|
-
["data", "parsed", "info", "warmupCooldownRate"],
|
|
1837
|
-
// parsed Token/Token22 mint account
|
|
1838
|
-
["data", "parsed", "info", "decimals"],
|
|
1839
|
-
// parsed Token/Token22 multisig account
|
|
1840
|
-
["data", "parsed", "info", "numRequiredSigners"],
|
|
1841
|
-
["data", "parsed", "info", "numValidSigners"],
|
|
1842
|
-
// parsed Stake account
|
|
1843
|
-
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
1844
|
-
// parsed Sysvar rent account
|
|
1845
|
-
["data", "parsed", "info", "exemptionThreshold"],
|
|
1846
|
-
["data", "parsed", "info", "burnPercent"],
|
|
1847
|
-
// parsed Vote account
|
|
1848
|
-
["data", "parsed", "info", "commission"],
|
|
1849
|
-
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
1850
|
-
];
|
|
1851
2818
|
memoizedResponseKeypaths = {
|
|
1852
2819
|
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
1853
2820
|
getBlock: [
|
|
@@ -2026,94 +2993,65 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2026
2993
|
}
|
|
2027
2994
|
return memoizedResponseKeypaths;
|
|
2028
2995
|
}
|
|
2029
|
-
function
|
|
2030
|
-
return
|
|
2996
|
+
function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
|
|
2997
|
+
return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
|
|
2998
|
+
if (prohibitedKeyPath.length !== keyPath.length) {
|
|
2999
|
+
return false;
|
|
3000
|
+
}
|
|
3001
|
+
for (let ii = keyPath.length - 1; ii >= 0; ii--) {
|
|
3002
|
+
const keyPathPart = keyPath[ii];
|
|
3003
|
+
const prohibitedKeyPathPart = prohibitedKeyPath[ii];
|
|
3004
|
+
if (prohibitedKeyPathPart !== keyPathPart && (prohibitedKeyPathPart !== KEYPATH_WILDCARD || typeof keyPathPart !== "number")) {
|
|
3005
|
+
return false;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
return true;
|
|
3009
|
+
});
|
|
2031
3010
|
}
|
|
2032
|
-
function
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
for (const [propName, innerValue] of Object.entries(value)) {
|
|
2041
|
-
const nextAllowedKeypaths = getNextAllowedKeypaths(allowedKeypaths, propName);
|
|
2042
|
-
out[propName] = visitNode2(innerValue, nextAllowedKeypaths);
|
|
2043
|
-
}
|
|
2044
|
-
return out;
|
|
2045
|
-
} else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
|
|
2046
|
-
// Upcast the value to `bigint` unless an allowed keypath is present.
|
|
2047
|
-
allowedKeypaths.length === 0 && // Only try to upcast an Integer to `bigint`
|
|
2048
|
-
Number.isInteger(value)) {
|
|
2049
|
-
return BigInt(value);
|
|
2050
|
-
} else {
|
|
2051
|
-
return value;
|
|
2052
|
-
}
|
|
3011
|
+
function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
|
|
3012
|
+
return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
|
|
3013
|
+
if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
|
|
3014
|
+
return BigInt(value);
|
|
3015
|
+
} else {
|
|
3016
|
+
return value;
|
|
3017
|
+
}
|
|
3018
|
+
};
|
|
2053
3019
|
}
|
|
2054
3020
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
2055
|
-
const
|
|
2056
|
-
|
|
3021
|
+
const allowedNumericKeyPaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
|
|
3022
|
+
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths != null ? allowedNumericKeyPaths : [])]);
|
|
3023
|
+
const initialState = {
|
|
3024
|
+
keyPath: []
|
|
3025
|
+
};
|
|
3026
|
+
return traverse(rawResponse, initialState);
|
|
2057
3027
|
}
|
|
2058
|
-
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse,
|
|
2059
|
-
const
|
|
2060
|
-
|
|
3028
|
+
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName) {
|
|
3029
|
+
const allowedNumericKeyPaths = notificationName ? getAllowedNumericKeypathsForNotification()[notificationName] : void 0;
|
|
3030
|
+
const traverse = getTreeWalker([getBigIntUpcastVisitor(allowedNumericKeyPaths != null ? allowedNumericKeyPaths : [])]);
|
|
3031
|
+
const initialState = {
|
|
3032
|
+
keyPath: []
|
|
3033
|
+
};
|
|
3034
|
+
return traverse(rawResponse, initialState);
|
|
2061
3035
|
}
|
|
2062
3036
|
function createSolanaRpcApi(config) {
|
|
2063
|
-
return
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
},
|
|
2067
|
-
deleteProperty() {
|
|
2068
|
-
return false;
|
|
2069
|
-
},
|
|
2070
|
-
get(...args) {
|
|
2071
|
-
const [_, p] = args;
|
|
2072
|
-
const methodName = p.toString();
|
|
2073
|
-
return function(...rawParams) {
|
|
2074
|
-
const handleIntegerOverflow = config?.onIntegerOverflow;
|
|
2075
|
-
const params = patchParamsForSolanaLabsRpc(
|
|
2076
|
-
rawParams,
|
|
2077
|
-
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
|
|
2078
|
-
);
|
|
2079
|
-
return {
|
|
2080
|
-
methodName,
|
|
2081
|
-
params,
|
|
2082
|
-
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
|
|
2083
|
-
};
|
|
2084
|
-
};
|
|
2085
|
-
}
|
|
3037
|
+
return createJsonRpcApi({
|
|
3038
|
+
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
|
|
3039
|
+
responseTransformer: patchResponseForSolanaLabsRpc
|
|
2086
3040
|
});
|
|
2087
3041
|
}
|
|
2088
|
-
function
|
|
2089
|
-
return
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
return false;
|
|
2095
|
-
},
|
|
2096
|
-
get(...args) {
|
|
2097
|
-
const [_, p] = args;
|
|
2098
|
-
const notificationName = p.toString();
|
|
2099
|
-
return function(...rawParams) {
|
|
2100
|
-
const handleIntegerOverflow = config?.onIntegerOverflow;
|
|
2101
|
-
const params = patchParamsForSolanaLabsRpc(
|
|
2102
|
-
rawParams,
|
|
2103
|
-
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
|
|
2104
|
-
);
|
|
2105
|
-
return {
|
|
2106
|
-
params,
|
|
2107
|
-
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
|
|
2108
|
-
subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
|
|
2109
|
-
unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2110
|
-
};
|
|
2111
|
-
};
|
|
2112
|
-
}
|
|
3042
|
+
function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
|
|
3043
|
+
return createJsonRpcSubscriptionsApi({
|
|
3044
|
+
parametersTransformer: getParamsPatcherForSolanaLabsRpc(config),
|
|
3045
|
+
responseTransformer: patchResponseForSolanaLabsRpcSubscriptions,
|
|
3046
|
+
subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"),
|
|
3047
|
+
unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2113
3048
|
});
|
|
2114
3049
|
}
|
|
3050
|
+
function createSolanaRpcSubscriptionsApi(config) {
|
|
3051
|
+
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
|
|
3052
|
+
}
|
|
2115
3053
|
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
|
|
2116
|
-
return
|
|
3054
|
+
return createSolanaRpcSubscriptionsApi_INTERNAL(config);
|
|
2117
3055
|
}
|
|
2118
3056
|
|
|
2119
3057
|
// ../rpc-transport/dist/index.browser.js
|
|
@@ -2121,6 +3059,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2121
3059
|
var SolanaJsonRpcError = class extends Error {
|
|
2122
3060
|
constructor(details) {
|
|
2123
3061
|
super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);
|
|
3062
|
+
__publicField(this, "code");
|
|
3063
|
+
__publicField(this, "data");
|
|
2124
3064
|
Error.captureStackTrace(this, this.constructor);
|
|
2125
3065
|
this.code = details.code;
|
|
2126
3066
|
this.data = details.data;
|
|
@@ -2146,16 +3086,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2146
3086
|
function createPendingRpcRequest(rpcConfig, pendingRequest) {
|
|
2147
3087
|
return {
|
|
2148
3088
|
async send(options) {
|
|
2149
|
-
const { methodName, params,
|
|
3089
|
+
const { methodName, params, responseTransformer } = pendingRequest;
|
|
2150
3090
|
const payload = createJsonRpcMessage(methodName, params);
|
|
2151
3091
|
const response = await rpcConfig.transport({
|
|
2152
3092
|
payload,
|
|
2153
|
-
signal: options
|
|
3093
|
+
signal: options == null ? void 0 : options.abortSignal
|
|
2154
3094
|
});
|
|
2155
3095
|
if ("error" in response) {
|
|
2156
3096
|
throw new SolanaJsonRpcError(response.error);
|
|
2157
3097
|
} else {
|
|
2158
|
-
return
|
|
3098
|
+
return responseTransformer ? responseTransformer(response.result, methodName) : response.result;
|
|
2159
3099
|
}
|
|
2160
3100
|
}
|
|
2161
3101
|
};
|
|
@@ -2192,7 +3132,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2192
3132
|
}
|
|
2193
3133
|
})();
|
|
2194
3134
|
}
|
|
2195
|
-
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName,
|
|
3135
|
+
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) {
|
|
2196
3136
|
return {
|
|
2197
3137
|
async subscribe({ abortSignal }) {
|
|
2198
3138
|
abortSignal.throwIfAborted();
|
|
@@ -2238,7 +3178,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2238
3178
|
continue;
|
|
2239
3179
|
}
|
|
2240
3180
|
const notification = message.params.result;
|
|
2241
|
-
yield
|
|
3181
|
+
yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
|
|
2242
3182
|
}
|
|
2243
3183
|
}
|
|
2244
3184
|
};
|
|
@@ -2275,10 +3215,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2275
3215
|
function createJsonSubscriptionRpc(rpcConfig) {
|
|
2276
3216
|
return makeProxy2(rpcConfig);
|
|
2277
3217
|
}
|
|
2278
|
-
var
|
|
3218
|
+
var e2 = globalThis.fetch;
|
|
2279
3219
|
var SolanaHttpError = class extends Error {
|
|
2280
3220
|
constructor(details) {
|
|
2281
3221
|
super(`HTTP error (${details.statusCode}): ${details.message}`);
|
|
3222
|
+
__publicField(this, "statusCode");
|
|
2282
3223
|
Error.captureStackTrace(this, this.constructor);
|
|
2283
3224
|
this.statusCode = details.statusCode;
|
|
2284
3225
|
}
|
|
@@ -2334,16 +3275,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2334
3275
|
}
|
|
2335
3276
|
return out;
|
|
2336
3277
|
}
|
|
2337
|
-
function createHttpTransport({
|
|
3278
|
+
function createHttpTransport({ headers, url }) {
|
|
2338
3279
|
if (headers) {
|
|
2339
3280
|
assertIsAllowedHttpRequestHeaders(headers);
|
|
2340
3281
|
}
|
|
2341
|
-
const agent = void 0;
|
|
2342
|
-
if (httpAgentNodeOnly != null) {
|
|
2343
|
-
console.warn(
|
|
2344
|
-
"createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
|
|
2345
|
-
);
|
|
2346
|
-
}
|
|
2347
3282
|
const customHeaders = headers && normalizeHeaders(headers);
|
|
2348
3283
|
return async function makeHttpRequest({
|
|
2349
3284
|
payload,
|
|
@@ -2351,7 +3286,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2351
3286
|
}) {
|
|
2352
3287
|
const body = JSON.stringify(payload);
|
|
2353
3288
|
const requestInfo = {
|
|
2354
|
-
agent,
|
|
2355
3289
|
body,
|
|
2356
3290
|
headers: {
|
|
2357
3291
|
...customHeaders,
|
|
@@ -2363,7 +3297,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2363
3297
|
method: "POST",
|
|
2364
3298
|
signal
|
|
2365
3299
|
};
|
|
2366
|
-
const response = await
|
|
3300
|
+
const response = await e2(url, requestInfo);
|
|
2367
3301
|
if (!response.ok) {
|
|
2368
3302
|
throw new SolanaHttpError({
|
|
2369
3303
|
message: response.statusText,
|
|
@@ -2373,9 +3307,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2373
3307
|
return await response.json();
|
|
2374
3308
|
};
|
|
2375
3309
|
}
|
|
2376
|
-
var
|
|
3310
|
+
var e22 = globalThis.WebSocket;
|
|
2377
3311
|
var EXPLICIT_ABORT_TOKEN = Symbol(
|
|
2378
|
-
"This symbol is thrown from a socket's iterator when the connection is
|
|
3312
|
+
"This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
|
|
2379
3313
|
);
|
|
2380
3314
|
async function createWebSocketConnection({
|
|
2381
3315
|
sendBufferHighWatermark,
|
|
@@ -2397,12 +3331,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2397
3331
|
}
|
|
2398
3332
|
function handleAbort() {
|
|
2399
3333
|
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
|
|
2400
|
-
if (webSocket.readyState !==
|
|
3334
|
+
if (webSocket.readyState !== e22.CLOSED && webSocket.readyState !== e22.CLOSING) {
|
|
2401
3335
|
webSocket.close(1e3);
|
|
2402
3336
|
}
|
|
2403
3337
|
}
|
|
2404
3338
|
function handleClose(ev) {
|
|
2405
|
-
bufferDrainWatcher
|
|
3339
|
+
bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
|
|
2406
3340
|
signal.removeEventListener("abort", handleAbort);
|
|
2407
3341
|
webSocket.removeEventListener("close", handleClose);
|
|
2408
3342
|
webSocket.removeEventListener("error", handleError);
|
|
@@ -2425,11 +3359,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2425
3359
|
resolve({
|
|
2426
3360
|
async send(payload) {
|
|
2427
3361
|
const message = JSON.stringify(payload);
|
|
2428
|
-
if (!bufferDrainWatcher && webSocket.readyState ===
|
|
3362
|
+
if (!bufferDrainWatcher && webSocket.readyState === e22.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
|
2429
3363
|
let onCancel;
|
|
2430
3364
|
const promise = new Promise((resolve2, reject2) => {
|
|
2431
3365
|
const intervalId = setInterval(() => {
|
|
2432
|
-
if (webSocket.readyState !==
|
|
3366
|
+
if (webSocket.readyState !== e22.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
|
2433
3367
|
clearInterval(intervalId);
|
|
2434
3368
|
bufferDrainWatcher = void 0;
|
|
2435
3369
|
resolve2();
|
|
@@ -2510,7 +3444,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2510
3444
|
}
|
|
2511
3445
|
});
|
|
2512
3446
|
}
|
|
2513
|
-
const webSocket = new
|
|
3447
|
+
const webSocket = new e22(url);
|
|
2514
3448
|
webSocket.addEventListener("close", handleClose);
|
|
2515
3449
|
webSocket.addEventListener("error", handleError);
|
|
2516
3450
|
webSocket.addEventListener("open", handleOpen);
|
|
@@ -2525,13 +3459,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2525
3459
|
);
|
|
2526
3460
|
}
|
|
2527
3461
|
return async function sendWebSocketMessage({ payload, signal }) {
|
|
2528
|
-
signal
|
|
3462
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
2529
3463
|
const connection = await createWebSocketConnection({
|
|
2530
3464
|
sendBufferHighWatermark,
|
|
2531
3465
|
signal,
|
|
2532
3466
|
url
|
|
2533
3467
|
});
|
|
2534
|
-
signal
|
|
3468
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
2535
3469
|
await connection.send(payload);
|
|
2536
3470
|
return {
|
|
2537
3471
|
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
@@ -2550,23 +3484,30 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2550
3484
|
init_env_shim();
|
|
2551
3485
|
var SolanaJsonRpcIntegerOverflowError = class extends Error {
|
|
2552
3486
|
constructor(methodName, keyPath, value) {
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
3487
|
+
let argumentLabel = "";
|
|
3488
|
+
if (typeof keyPath[0] === "number") {
|
|
3489
|
+
const argPosition = keyPath[0] + 1;
|
|
3490
|
+
const lastDigit = argPosition % 10;
|
|
3491
|
+
const lastTwoDigits = argPosition % 100;
|
|
3492
|
+
if (lastDigit == 1 && lastTwoDigits != 11) {
|
|
3493
|
+
argumentLabel = argPosition + "st";
|
|
3494
|
+
} else if (lastDigit == 2 && lastTwoDigits != 12) {
|
|
3495
|
+
argumentLabel = argPosition + "nd";
|
|
3496
|
+
} else if (lastDigit == 3 && lastTwoDigits != 13) {
|
|
3497
|
+
argumentLabel = argPosition + "rd";
|
|
3498
|
+
} else {
|
|
3499
|
+
argumentLabel = argPosition + "th";
|
|
3500
|
+
}
|
|
2563
3501
|
} else {
|
|
2564
|
-
|
|
3502
|
+
argumentLabel = `\`${keyPath[0].toString()}\``;
|
|
2565
3503
|
}
|
|
2566
3504
|
const path = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : null;
|
|
2567
3505
|
super(
|
|
2568
|
-
`The ${
|
|
3506
|
+
`The ${argumentLabel} 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\`.`
|
|
2569
3507
|
);
|
|
3508
|
+
__publicField(this, "methodName");
|
|
3509
|
+
__publicField(this, "keyPath");
|
|
3510
|
+
__publicField(this, "value");
|
|
2570
3511
|
this.keyPath = keyPath;
|
|
2571
3512
|
this.methodName = methodName;
|
|
2572
3513
|
this.value = value;
|
|
@@ -2578,6 +3519,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2578
3519
|
|
|
2579
3520
|
// src/rpc-default-config.ts
|
|
2580
3521
|
var DEFAULT_RPC_CONFIG = {
|
|
3522
|
+
defaultCommitment: "confirmed",
|
|
2581
3523
|
onIntegerOverflow(methodName, keyPath, value) {
|
|
2582
3524
|
throw new SolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
|
|
2583
3525
|
}
|
|
@@ -2713,7 +3655,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2713
3655
|
getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
|
|
2714
3656
|
getCacheEntryMissingError(deduplicationKey2) {
|
|
2715
3657
|
return new Error(
|
|
2716
|
-
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2
|
|
3658
|
+
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2 == null ? void 0 : deduplicationKey2.toString()}\``
|
|
2717
3659
|
);
|
|
2718
3660
|
},
|
|
2719
3661
|
getCacheKeyFromInputArgs: () => deduplicationKey,
|
|
@@ -2878,6 +3820,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2878
3820
|
return out;
|
|
2879
3821
|
}
|
|
2880
3822
|
function createDefaultRpcTransport(config) {
|
|
3823
|
+
var _a;
|
|
2881
3824
|
return pipe(
|
|
2882
3825
|
createHttpTransport({
|
|
2883
3826
|
...config,
|
|
@@ -2885,7 +3828,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2885
3828
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
|
2886
3829
|
...{
|
|
2887
3830
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
2888
|
-
"solana-client": `js/${"2.0.0-development"}`
|
|
3831
|
+
"solana-client": (_a = `js/${"2.0.0-development"}`) != null ? _a : "UNKNOWN"
|
|
2889
3832
|
}
|
|
2890
3833
|
}
|
|
2891
3834
|
}),
|
|
@@ -2969,7 +3912,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2969
3912
|
return getCachedAbortableIterableFactory({
|
|
2970
3913
|
getAbortSignalFromInputArgs: ({ signal }) => signal,
|
|
2971
3914
|
getCacheEntryMissingError(shardKey) {
|
|
2972
|
-
return new Error(`Found no cache entry for connection with shard key \`${shardKey
|
|
3915
|
+
return new Error(`Found no cache entry for connection with shard key \`${shardKey == null ? void 0 : shardKey.toString()}\``);
|
|
2973
3916
|
},
|
|
2974
3917
|
getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
|
|
2975
3918
|
onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
|
|
@@ -2982,15 +3925,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2982
3925
|
|
|
2983
3926
|
// src/rpc-websocket-transport.ts
|
|
2984
3927
|
function createDefaultRpcSubscriptionsTransport(config) {
|
|
3928
|
+
var _a;
|
|
2985
3929
|
const { getShard, intervalMs, ...rest } = config;
|
|
2986
3930
|
return pipe(
|
|
2987
3931
|
createWebSocketTransport({
|
|
2988
3932
|
...rest,
|
|
2989
|
-
sendBufferHighWatermark: config.sendBufferHighWatermark
|
|
2990
|
-
|
|
3933
|
+
sendBufferHighWatermark: (_a = config.sendBufferHighWatermark) != null ? _a : (
|
|
3934
|
+
// Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
3935
|
+
131072
|
|
3936
|
+
)
|
|
2991
3937
|
}),
|
|
2992
3938
|
(transport) => getWebSocketTransportWithAutoping({
|
|
2993
|
-
intervalMs: intervalMs
|
|
3939
|
+
intervalMs: intervalMs != null ? intervalMs : 5e3,
|
|
2994
3940
|
transport
|
|
2995
3941
|
}),
|
|
2996
3942
|
(transport) => getWebSocketTransportWithConnectionSharding({
|
|
@@ -3000,15 +3946,310 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3000
3946
|
);
|
|
3001
3947
|
}
|
|
3002
3948
|
|
|
3949
|
+
// src/send-transaction.ts
|
|
3950
|
+
init_env_shim();
|
|
3951
|
+
|
|
3952
|
+
// src/transaction-confirmation.ts
|
|
3953
|
+
init_env_shim();
|
|
3954
|
+
|
|
3955
|
+
// src/transaction-confirmation-strategy-blockheight.ts
|
|
3956
|
+
init_env_shim();
|
|
3957
|
+
function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
|
|
3958
|
+
return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
|
|
3959
|
+
const abortController = new AbortController();
|
|
3960
|
+
function handleAbort() {
|
|
3961
|
+
abortController.abort();
|
|
3962
|
+
}
|
|
3963
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3964
|
+
const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
|
|
3965
|
+
try {
|
|
3966
|
+
for await (const slotNotification of slotNotifications) {
|
|
3967
|
+
if (slotNotification.slot > lastValidBlockHeight) {
|
|
3968
|
+
throw new Error(
|
|
3969
|
+
"The network has progressed past the last block for which this transaction could have committed."
|
|
3970
|
+
);
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
} finally {
|
|
3974
|
+
abortController.abort();
|
|
3975
|
+
}
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
|
|
3979
|
+
// src/transaction-confirmation-strategy-nonce.ts
|
|
3980
|
+
init_env_shim();
|
|
3981
|
+
var NONCE_VALUE_OFFSET = 4 + // version(u32)
|
|
3982
|
+
4 + // state(u32)
|
|
3983
|
+
32;
|
|
3984
|
+
function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
|
|
3985
|
+
return async function getNonceInvalidationPromise({
|
|
3986
|
+
abortSignal: callerAbortSignal,
|
|
3987
|
+
commitment,
|
|
3988
|
+
currentNonceValue,
|
|
3989
|
+
nonceAccountAddress
|
|
3990
|
+
}) {
|
|
3991
|
+
const abortController = new AbortController();
|
|
3992
|
+
function handleAbort() {
|
|
3993
|
+
abortController.abort();
|
|
3994
|
+
}
|
|
3995
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3996
|
+
const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
|
|
3997
|
+
const base58Decoder2 = getBase58Decoder();
|
|
3998
|
+
const base64Encoder = getBase64Encoder();
|
|
3999
|
+
function getNonceFromAccountData([base64EncodedBytes]) {
|
|
4000
|
+
const data = base64Encoder.encode(base64EncodedBytes);
|
|
4001
|
+
const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
|
|
4002
|
+
return base58Decoder2.decode(nonceValueBytes);
|
|
4003
|
+
}
|
|
4004
|
+
const nonceAccountDidAdvancePromise = (async () => {
|
|
4005
|
+
for await (const accountNotification of accountNotifications) {
|
|
4006
|
+
const nonceValue = getNonceFromAccountData(accountNotification.value.data);
|
|
4007
|
+
if (nonceValue !== currentNonceValue) {
|
|
4008
|
+
throw new Error(
|
|
4009
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
})();
|
|
4014
|
+
const nonceIsAlreadyInvalidPromise = (async () => {
|
|
4015
|
+
const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
|
|
4016
|
+
commitment,
|
|
4017
|
+
dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
|
|
4018
|
+
encoding: "base58"
|
|
4019
|
+
}).send({ abortSignal: abortController.signal });
|
|
4020
|
+
if (!nonceAccount) {
|
|
4021
|
+
throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
|
|
4022
|
+
}
|
|
4023
|
+
const nonceValue = (
|
|
4024
|
+
// This works because we asked for the exact slice of data representing the nonce
|
|
4025
|
+
// value, and furthermore asked for it in `base58` encoding.
|
|
4026
|
+
nonceAccount.data[0]
|
|
4027
|
+
);
|
|
4028
|
+
if (nonceValue !== currentNonceValue) {
|
|
4029
|
+
throw new Error(
|
|
4030
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
4031
|
+
);
|
|
4032
|
+
} else {
|
|
4033
|
+
await new Promise(() => {
|
|
4034
|
+
});
|
|
4035
|
+
}
|
|
4036
|
+
})();
|
|
4037
|
+
try {
|
|
4038
|
+
return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
|
|
4039
|
+
} finally {
|
|
4040
|
+
abortController.abort();
|
|
4041
|
+
}
|
|
4042
|
+
};
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
// src/transaction-confirmation.ts
|
|
4046
|
+
function createDefaultDurableNonceTransactionConfirmer({
|
|
4047
|
+
rpc,
|
|
4048
|
+
rpcSubscriptions
|
|
4049
|
+
}) {
|
|
4050
|
+
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
4051
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
4052
|
+
rpc,
|
|
4053
|
+
rpcSubscriptions
|
|
4054
|
+
);
|
|
4055
|
+
return async function confirmDurableNonceTransaction(config) {
|
|
4056
|
+
await waitForDurableNonceTransactionConfirmation({
|
|
4057
|
+
...config,
|
|
4058
|
+
getNonceInvalidationPromise,
|
|
4059
|
+
getRecentSignatureConfirmationPromise
|
|
4060
|
+
});
|
|
4061
|
+
};
|
|
4062
|
+
}
|
|
4063
|
+
function createDefaultRecentTransactionConfirmer({
|
|
4064
|
+
rpc,
|
|
4065
|
+
rpcSubscriptions
|
|
4066
|
+
}) {
|
|
4067
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
|
|
4068
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
4069
|
+
rpc,
|
|
4070
|
+
rpcSubscriptions
|
|
4071
|
+
);
|
|
4072
|
+
return async function confirmRecentTransaction(config) {
|
|
4073
|
+
await waitForRecentTransactionConfirmation({
|
|
4074
|
+
...config,
|
|
4075
|
+
getBlockHeightExceedencePromise,
|
|
4076
|
+
getRecentSignatureConfirmationPromise
|
|
4077
|
+
});
|
|
4078
|
+
};
|
|
4079
|
+
}
|
|
4080
|
+
async function waitForDurableNonceTransactionConfirmation(config) {
|
|
4081
|
+
await raceStrategies(
|
|
4082
|
+
getSignatureFromTransaction(config.transaction),
|
|
4083
|
+
config,
|
|
4084
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
|
|
4085
|
+
return [
|
|
4086
|
+
getNonceInvalidationPromise({
|
|
4087
|
+
abortSignal,
|
|
4088
|
+
commitment,
|
|
4089
|
+
currentNonceValue: transaction.lifetimeConstraint.nonce,
|
|
4090
|
+
nonceAccountAddress: transaction.instructions[0].accounts[0].address
|
|
4091
|
+
})
|
|
4092
|
+
];
|
|
4093
|
+
}
|
|
4094
|
+
);
|
|
4095
|
+
}
|
|
4096
|
+
async function waitForRecentTransactionConfirmation(config) {
|
|
4097
|
+
await raceStrategies(
|
|
4098
|
+
getSignatureFromTransaction(config.transaction),
|
|
4099
|
+
config,
|
|
4100
|
+
function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
|
|
4101
|
+
return [
|
|
4102
|
+
getBlockHeightExceedencePromise({
|
|
4103
|
+
abortSignal,
|
|
4104
|
+
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
4105
|
+
})
|
|
4106
|
+
];
|
|
4107
|
+
}
|
|
4108
|
+
);
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
// src/send-transaction.ts
|
|
4112
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
4113
|
+
if (
|
|
4114
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
4115
|
+
!(config == null ? void 0 : config.preflightCommitment) && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
4116
|
+
commitmentComparator(
|
|
4117
|
+
commitment,
|
|
4118
|
+
"finalized"
|
|
4119
|
+
/* default value of `preflightCommitment` */
|
|
4120
|
+
) < 0
|
|
4121
|
+
) {
|
|
4122
|
+
return {
|
|
4123
|
+
...config,
|
|
4124
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
4125
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
4126
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
4127
|
+
// confirmation commitment.
|
|
4128
|
+
preflightCommitment: commitment
|
|
4129
|
+
};
|
|
4130
|
+
}
|
|
4131
|
+
return config;
|
|
4132
|
+
}
|
|
4133
|
+
async function sendTransaction_INTERNAL({
|
|
4134
|
+
abortSignal,
|
|
4135
|
+
commitment,
|
|
4136
|
+
rpc,
|
|
4137
|
+
transaction,
|
|
4138
|
+
...sendTransactionConfig
|
|
4139
|
+
}) {
|
|
4140
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
|
|
4141
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
4142
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
4143
|
+
encoding: "base64"
|
|
4144
|
+
}).send({ abortSignal });
|
|
4145
|
+
}
|
|
4146
|
+
function createDefaultDurableNonceTransactionSender({
|
|
4147
|
+
rpc,
|
|
4148
|
+
rpcSubscriptions
|
|
4149
|
+
}) {
|
|
4150
|
+
const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
|
|
4151
|
+
rpc,
|
|
4152
|
+
rpcSubscriptions
|
|
4153
|
+
});
|
|
4154
|
+
return async function sendDurableNonceTransaction(transaction, config) {
|
|
4155
|
+
await sendAndConfirmDurableNonceTransaction({
|
|
4156
|
+
...config,
|
|
4157
|
+
confirmDurableNonceTransaction,
|
|
4158
|
+
rpc,
|
|
4159
|
+
transaction
|
|
4160
|
+
});
|
|
4161
|
+
};
|
|
4162
|
+
}
|
|
4163
|
+
function createDefaultTransactionSender({
|
|
4164
|
+
rpc,
|
|
4165
|
+
rpcSubscriptions
|
|
4166
|
+
}) {
|
|
4167
|
+
const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
|
|
4168
|
+
rpc,
|
|
4169
|
+
rpcSubscriptions
|
|
4170
|
+
});
|
|
4171
|
+
return async function sendTransaction(transaction, config) {
|
|
4172
|
+
await sendAndConfirmTransaction({
|
|
4173
|
+
...config,
|
|
4174
|
+
confirmRecentTransaction,
|
|
4175
|
+
rpc,
|
|
4176
|
+
transaction
|
|
4177
|
+
});
|
|
4178
|
+
};
|
|
4179
|
+
}
|
|
4180
|
+
async function sendAndConfirmDurableNonceTransaction({
|
|
4181
|
+
abortSignal,
|
|
4182
|
+
commitment,
|
|
4183
|
+
confirmDurableNonceTransaction,
|
|
4184
|
+
rpc,
|
|
4185
|
+
transaction,
|
|
4186
|
+
...sendTransactionConfig
|
|
4187
|
+
}) {
|
|
4188
|
+
const transactionSignature = await sendTransaction_INTERNAL({
|
|
4189
|
+
...sendTransactionConfig,
|
|
4190
|
+
abortSignal,
|
|
4191
|
+
commitment,
|
|
4192
|
+
rpc,
|
|
4193
|
+
transaction
|
|
4194
|
+
});
|
|
4195
|
+
await confirmDurableNonceTransaction({
|
|
4196
|
+
abortSignal,
|
|
4197
|
+
commitment,
|
|
4198
|
+
transaction
|
|
4199
|
+
});
|
|
4200
|
+
return transactionSignature;
|
|
4201
|
+
}
|
|
4202
|
+
async function sendAndConfirmTransaction({
|
|
4203
|
+
abortSignal,
|
|
4204
|
+
commitment,
|
|
4205
|
+
confirmRecentTransaction,
|
|
4206
|
+
rpc,
|
|
4207
|
+
transaction,
|
|
4208
|
+
...sendTransactionConfig
|
|
4209
|
+
}) {
|
|
4210
|
+
const transactionSignature = await sendTransaction_INTERNAL({
|
|
4211
|
+
...sendTransactionConfig,
|
|
4212
|
+
abortSignal,
|
|
4213
|
+
commitment,
|
|
4214
|
+
rpc,
|
|
4215
|
+
transaction
|
|
4216
|
+
});
|
|
4217
|
+
await confirmRecentTransaction({
|
|
4218
|
+
abortSignal,
|
|
4219
|
+
commitment,
|
|
4220
|
+
transaction
|
|
4221
|
+
});
|
|
4222
|
+
return transactionSignature;
|
|
4223
|
+
}
|
|
4224
|
+
|
|
3003
4225
|
exports.AccountRole = AccountRole;
|
|
3004
4226
|
exports.address = address;
|
|
3005
4227
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
3006
|
-
exports.
|
|
4228
|
+
exports.assertIsAddress = assertIsAddress;
|
|
3007
4229
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
3008
4230
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
4231
|
+
exports.assertIsLamports = assertIsLamports;
|
|
4232
|
+
exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
|
|
4233
|
+
exports.assertIsSignature = assertIsSignature;
|
|
4234
|
+
exports.assertIsStringifiedBigInt = assertIsStringifiedBigInt;
|
|
4235
|
+
exports.assertIsStringifiedNumber = assertIsStringifiedNumber;
|
|
4236
|
+
exports.assertIsTransactionWithBlockhashLifetime = assertIsTransactionWithBlockhashLifetime;
|
|
4237
|
+
exports.assertIsUnixTimestamp = assertIsUnixTimestamp;
|
|
4238
|
+
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
4239
|
+
exports.commitmentComparator = commitmentComparator;
|
|
4240
|
+
exports.compileMessage = compileMessage;
|
|
3009
4241
|
exports.createAddressWithSeed = createAddressWithSeed;
|
|
4242
|
+
exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
|
|
4243
|
+
exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
|
|
4244
|
+
exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
|
|
4245
|
+
exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
|
|
4246
|
+
exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
|
|
3010
4247
|
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
3011
4248
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
4249
|
+
exports.createDefaultTransactionSender = createDefaultTransactionSender;
|
|
4250
|
+
exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
|
|
4251
|
+
exports.createPrivateKeyFromBytes = createPrivateKeyFromBytes;
|
|
4252
|
+
exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
|
|
3012
4253
|
exports.createSolanaRpc = createSolanaRpc;
|
|
3013
4254
|
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
3014
4255
|
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
@@ -3016,24 +4257,51 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
3016
4257
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
3017
4258
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
3018
4259
|
exports.generateKeyPair = generateKeyPair;
|
|
4260
|
+
exports.getAddressCodec = getAddressCodec;
|
|
4261
|
+
exports.getAddressComparator = getAddressComparator;
|
|
4262
|
+
exports.getAddressDecoder = getAddressDecoder;
|
|
4263
|
+
exports.getAddressEncoder = getAddressEncoder;
|
|
3019
4264
|
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
3020
|
-
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
|
|
3021
|
-
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
|
|
3022
4265
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
4266
|
+
exports.getCompiledMessageCodec = getCompiledMessageCodec;
|
|
4267
|
+
exports.getCompiledMessageDecoder = getCompiledMessageDecoder;
|
|
4268
|
+
exports.getCompiledMessageEncoder = getCompiledMessageEncoder;
|
|
3023
4269
|
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
3024
|
-
exports.
|
|
4270
|
+
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
4271
|
+
exports.getTransactionCodec = getTransactionCodec;
|
|
4272
|
+
exports.getTransactionDecoder = getTransactionDecoder;
|
|
4273
|
+
exports.getTransactionEncoder = getTransactionEncoder;
|
|
4274
|
+
exports.isAddress = isAddress;
|
|
4275
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
4276
|
+
exports.isLamports = isLamports;
|
|
4277
|
+
exports.isProgramDerivedAddress = isProgramDerivedAddress;
|
|
4278
|
+
exports.isSignature = isSignature;
|
|
3025
4279
|
exports.isSignerRole = isSignerRole;
|
|
4280
|
+
exports.isStringifiedBigInt = isStringifiedBigInt;
|
|
4281
|
+
exports.isStringifiedNumber = isStringifiedNumber;
|
|
4282
|
+
exports.isUnixTimestamp = isUnixTimestamp;
|
|
3026
4283
|
exports.isWritableRole = isWritableRole;
|
|
4284
|
+
exports.lamports = lamports;
|
|
3027
4285
|
exports.mergeRoles = mergeRoles;
|
|
4286
|
+
exports.partiallySignTransaction = partiallySignTransaction;
|
|
3028
4287
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
4288
|
+
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
4289
|
+
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|
|
4290
|
+
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
3029
4291
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
3030
4292
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
3031
4293
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
3032
4294
|
exports.signBytes = signBytes;
|
|
3033
4295
|
exports.signTransaction = signTransaction;
|
|
4296
|
+
exports.signature = signature;
|
|
4297
|
+
exports.stringifiedBigInt = stringifiedBigInt;
|
|
4298
|
+
exports.stringifiedNumber = stringifiedNumber;
|
|
4299
|
+
exports.unixTimestamp = unixTimestamp;
|
|
3034
4300
|
exports.upgradeRoleToSigner = upgradeRoleToSigner;
|
|
3035
4301
|
exports.upgradeRoleToWritable = upgradeRoleToWritable;
|
|
3036
4302
|
exports.verifySignature = verifySignature;
|
|
4303
|
+
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
4304
|
+
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
3037
4305
|
|
|
3038
4306
|
return exports;
|
|
3039
4307
|
|