@solana/web3.js 2.0.0-experimental.89b2a1e → 2.0.0-experimental.8c5ac55
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 +4 -4
- package/dist/index.browser.cjs +765 -8
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +746 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +2784 -815
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +735 -11
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +752 -8
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +735 -11
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +75 -30
- package/dist/types/airdrop-confirmer.d.ts +20 -0
- package/dist/types/airdrop.d.ts +23 -0
- package/dist/types/cached-abortable-iterable.d.ts +11 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/rpc-subscription-coalescer.d.ts +10 -0
- package/dist/types/rpc-websocket-autopinger.d.ts +8 -0
- package/dist/types/rpc-websocket-connection-sharding.d.ts +13 -0
- package/dist/types/rpc-websocket-transport.d.ts +13 -0
- package/dist/types/rpc.d.ts +5 -3
- package/dist/types/send-transaction.d.ts +37 -0
- package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +10 -0
- package/dist/types/transaction-confirmation-strategy-nonce.d.ts +15 -0
- package/dist/types/transaction-confirmation-strategy-racer.d.ts +14 -0
- package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +13 -0
- package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
- package/dist/types/transaction-confirmation.d.ts +37 -0
- package/package.json +24 -20
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/rpc-default-config.d.ts.map +0 -1
- package/dist/types/rpc-integer-overflow-error.d.ts.map +0 -1
- package/dist/types/rpc-request-coalescer.d.ts.map +0 -1
- package/dist/types/rpc-request-deduplication.d.ts.map +0 -1
- package/dist/types/rpc-transport.d.ts.map +0 -1
- package/dist/types/rpc.d.ts.map +0 -1
|
@@ -8,7 +8,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8
8
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
11
|
var __esm = (fn, res) => function __init() {
|
|
13
12
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
13
|
};
|
|
@@ -31,10 +30,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
31
30
|
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
32
31
|
mod2
|
|
33
32
|
));
|
|
34
|
-
var __publicField = (obj, key, value) => {
|
|
35
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
|
-
return value;
|
|
37
|
-
};
|
|
38
33
|
|
|
39
34
|
// ../build-scripts/env-shim.ts
|
|
40
35
|
var init_env_shim = __esm({
|
|
@@ -125,304 +120,206 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
125
120
|
// ../addresses/dist/index.browser.js
|
|
126
121
|
init_env_shim();
|
|
127
122
|
|
|
128
|
-
//
|
|
129
|
-
init_env_shim();
|
|
130
|
-
|
|
131
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
|
|
132
|
-
init_env_shim();
|
|
133
|
-
|
|
134
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
123
|
+
// ../codecs-core/dist/index.browser.js
|
|
135
124
|
init_env_shim();
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
126
|
+
if (bytes.length - offset <= 0) {
|
|
127
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
|
|
131
|
+
const bytesLength = bytes.length - offset;
|
|
132
|
+
if (bytesLength < expected) {
|
|
133
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
var mergeBytes = (byteArrays) => {
|
|
137
|
+
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
138
|
+
if (nonEmptyByteArrays.length === 0) {
|
|
139
|
+
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
140
|
+
}
|
|
141
|
+
if (nonEmptyByteArrays.length === 1) {
|
|
142
|
+
return nonEmptyByteArrays[0];
|
|
143
|
+
}
|
|
144
|
+
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
138
145
|
const result = new Uint8Array(totalLength);
|
|
139
146
|
let offset = 0;
|
|
140
|
-
|
|
147
|
+
nonEmptyByteArrays.forEach((arr) => {
|
|
141
148
|
result.set(arr, offset);
|
|
142
149
|
offset += arr.length;
|
|
143
150
|
});
|
|
144
151
|
return result;
|
|
145
152
|
};
|
|
146
|
-
var padBytes = (
|
|
147
|
-
if (
|
|
148
|
-
return
|
|
153
|
+
var padBytes = (bytes, length) => {
|
|
154
|
+
if (bytes.length >= length)
|
|
155
|
+
return bytes;
|
|
149
156
|
const paddedBytes = new Uint8Array(length).fill(0);
|
|
150
|
-
paddedBytes.set(
|
|
157
|
+
paddedBytes.set(bytes);
|
|
151
158
|
return paddedBytes;
|
|
152
159
|
};
|
|
153
|
-
var fixBytes = (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
|
|
160
|
-
__publicField(this, "name", "DeserializingEmptyBufferError");
|
|
160
|
+
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
161
|
+
function combineCodec(encoder, decoder, description) {
|
|
162
|
+
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
165
|
+
);
|
|
161
166
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
__publicField(this, "name", "NotEnoughBytesError");
|
|
167
|
+
if (encoder.maxSize !== decoder.maxSize) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
170
|
+
);
|
|
167
171
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
super(message);
|
|
173
|
-
__publicField(this, "name", "ExpectedFixedSizeSerializerError");
|
|
172
|
+
if (description === void 0 && encoder.description !== decoder.description) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
`Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
|
|
175
|
+
);
|
|
174
176
|
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
178
|
-
init_env_shim();
|
|
179
|
-
function fixSerializer(serializer, fixedBytes, description) {
|
|
180
177
|
return {
|
|
181
|
-
|
|
178
|
+
decode: decoder.decode,
|
|
179
|
+
description: description ?? encoder.description,
|
|
180
|
+
encode: encoder.encode,
|
|
181
|
+
fixedSize: encoder.fixedSize,
|
|
182
|
+
maxSize: encoder.maxSize
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function fixCodecHelper(data, fixedBytes, description) {
|
|
186
|
+
return {
|
|
187
|
+
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
182
188
|
fixedSize: fixedBytes,
|
|
183
|
-
maxSize: fixedBytes
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
maxSize: fixedBytes
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function fixEncoder(encoder, fixedBytes, description) {
|
|
193
|
+
return {
|
|
194
|
+
...fixCodecHelper(encoder, fixedBytes, description),
|
|
195
|
+
encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function fixDecoder(decoder, fixedBytes, description) {
|
|
199
|
+
return {
|
|
200
|
+
...fixCodecHelper(decoder, fixedBytes, description),
|
|
201
|
+
decode: (bytes, offset = 0) => {
|
|
202
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
203
|
+
if (offset > 0 || bytes.length > fixedBytes) {
|
|
204
|
+
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
189
205
|
}
|
|
190
|
-
if (
|
|
191
|
-
|
|
206
|
+
if (decoder.fixedSize !== null) {
|
|
207
|
+
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
192
208
|
}
|
|
193
|
-
const [value] =
|
|
209
|
+
const [value] = decoder.decode(bytes, 0);
|
|
194
210
|
return [value, offset + fixedBytes];
|
|
195
211
|
}
|
|
196
212
|
};
|
|
197
213
|
}
|
|
198
|
-
|
|
199
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
|
|
200
|
-
init_env_shim();
|
|
201
|
-
function mapSerializer(serializer, unmap, map) {
|
|
214
|
+
function mapEncoder(encoder, unmap) {
|
|
202
215
|
return {
|
|
203
|
-
description:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
deserialize: (buffer, offset = 0) => {
|
|
208
|
-
const [value, length] = serializer.deserialize(buffer, offset);
|
|
209
|
-
return map ? [map(value, buffer, offset), length] : [value, length];
|
|
210
|
-
}
|
|
216
|
+
description: encoder.description,
|
|
217
|
+
encode: (value) => encoder.encode(unmap(value)),
|
|
218
|
+
fixedSize: encoder.fixedSize,
|
|
219
|
+
maxSize: encoder.maxSize
|
|
211
220
|
};
|
|
212
221
|
}
|
|
213
|
-
|
|
214
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
|
|
215
|
-
init_env_shim();
|
|
216
|
-
|
|
217
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
218
|
-
init_env_shim();
|
|
219
|
-
|
|
220
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/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.2/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);
|
|
222
|
+
function mapDecoder(decoder, map) {
|
|
235
223
|
return {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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));
|
|
224
|
+
decode: (bytes, offset = 0) => {
|
|
225
|
+
const [value, length] = decoder.decode(bytes, offset);
|
|
226
|
+
return [map(value, bytes, offset), length];
|
|
264
227
|
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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];
|
|
281
|
-
}
|
|
228
|
+
description: decoder.description,
|
|
229
|
+
fixedSize: decoder.fixedSize,
|
|
230
|
+
maxSize: decoder.maxSize
|
|
282
231
|
};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/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.2/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.2/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.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
|
|
312
|
-
init_env_shim();
|
|
232
|
+
}
|
|
313
233
|
|
|
314
|
-
//
|
|
234
|
+
// ../codecs-strings/dist/index.browser.js
|
|
315
235
|
init_env_shim();
|
|
316
|
-
var Endian;
|
|
317
|
-
(function(Endian2) {
|
|
318
|
-
Endian2["Little"] = "le";
|
|
319
|
-
Endian2["Big"] = "be";
|
|
320
|
-
})(Endian || (Endian = {}));
|
|
321
236
|
|
|
322
|
-
//
|
|
237
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
323
238
|
init_env_shim();
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
239
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
240
|
+
if (value < min || value > max) {
|
|
241
|
+
throw new Error(
|
|
242
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
243
|
+
);
|
|
328
244
|
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
|
|
332
|
-
init_env_shim();
|
|
333
|
-
function numberFactory(input) {
|
|
245
|
+
}
|
|
246
|
+
function sharedNumberFactory(input) {
|
|
334
247
|
let littleEndian;
|
|
335
248
|
let defaultDescription = input.name;
|
|
336
249
|
if (input.size > 1) {
|
|
337
|
-
littleEndian = !("endian" in input.options) || input.options.endian ===
|
|
250
|
+
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
338
251
|
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
339
252
|
}
|
|
340
253
|
return {
|
|
341
254
|
description: input.options.description ?? defaultDescription,
|
|
342
255
|
fixedSize: input.size,
|
|
343
|
-
|
|
344
|
-
|
|
256
|
+
littleEndian,
|
|
257
|
+
maxSize: input.size
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function numberEncoderFactory(input) {
|
|
261
|
+
const codecData = sharedNumberFactory(input);
|
|
262
|
+
return {
|
|
263
|
+
description: codecData.description,
|
|
264
|
+
encode(value) {
|
|
345
265
|
if (input.range) {
|
|
346
|
-
|
|
266
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
347
267
|
}
|
|
348
|
-
const
|
|
349
|
-
input.set(new DataView(
|
|
350
|
-
return new Uint8Array(
|
|
268
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
269
|
+
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
|
|
270
|
+
return new Uint8Array(arrayBuffer);
|
|
351
271
|
},
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
assertEnoughBytes("i8", slice, input.size);
|
|
355
|
-
const view = toDataView(slice);
|
|
356
|
-
return [input.get(view, littleEndian), offset + input.size];
|
|
357
|
-
}
|
|
272
|
+
fixedSize: codecData.fixedSize,
|
|
273
|
+
maxSize: codecData.maxSize
|
|
358
274
|
};
|
|
359
275
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
size: 1,
|
|
381
|
-
range: [0, Number("0xff")],
|
|
382
|
-
set: (view, value) => view.setUint8(0, Number(value)),
|
|
383
|
-
get: (view) => view.getUint8(0),
|
|
384
|
-
options
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/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.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
399
|
-
init_env_shim();
|
|
400
|
-
var shortU16 = (options = {}) => ({
|
|
276
|
+
function numberDecoderFactory(input) {
|
|
277
|
+
const codecData = sharedNumberFactory(input);
|
|
278
|
+
return {
|
|
279
|
+
decode(bytes, offset = 0) {
|
|
280
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
|
|
281
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
|
|
282
|
+
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
283
|
+
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
284
|
+
},
|
|
285
|
+
description: codecData.description,
|
|
286
|
+
fixedSize: codecData.fixedSize,
|
|
287
|
+
maxSize: codecData.maxSize
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function toArrayBuffer(bytes, offset, length) {
|
|
291
|
+
const bytesOffset = bytes.byteOffset + (offset ?? 0);
|
|
292
|
+
const bytesLength = length ?? bytes.byteLength;
|
|
293
|
+
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
294
|
+
}
|
|
295
|
+
var getShortU16Encoder = (options = {}) => ({
|
|
401
296
|
description: options.description ?? "shortU16",
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
assertRange("shortU16", 0, 65535, value);
|
|
406
|
-
const bytes2 = [0];
|
|
297
|
+
encode: (value) => {
|
|
298
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
299
|
+
const bytes = [0];
|
|
407
300
|
for (let ii = 0; ; ii += 1) {
|
|
408
301
|
const alignedValue = value >> ii * 7;
|
|
409
302
|
if (alignedValue === 0) {
|
|
410
303
|
break;
|
|
411
304
|
}
|
|
412
305
|
const nextSevenBits = 127 & alignedValue;
|
|
413
|
-
|
|
306
|
+
bytes[ii] = nextSevenBits;
|
|
414
307
|
if (ii > 0) {
|
|
415
|
-
|
|
308
|
+
bytes[ii - 1] |= 128;
|
|
416
309
|
}
|
|
417
310
|
}
|
|
418
|
-
return new Uint8Array(
|
|
311
|
+
return new Uint8Array(bytes);
|
|
419
312
|
},
|
|
420
|
-
|
|
313
|
+
fixedSize: null,
|
|
314
|
+
maxSize: 3
|
|
315
|
+
});
|
|
316
|
+
var getShortU16Decoder = (options = {}) => ({
|
|
317
|
+
decode: (bytes, offset = 0) => {
|
|
421
318
|
let value = 0;
|
|
422
319
|
let byteCount = 0;
|
|
423
320
|
while (++byteCount) {
|
|
424
321
|
const byteIndex = byteCount - 1;
|
|
425
|
-
const currentByte =
|
|
322
|
+
const currentByte = bytes[offset + byteIndex];
|
|
426
323
|
const nextSevenBits = 127 & currentByte;
|
|
427
324
|
value |= nextSevenBits << byteIndex * 7;
|
|
428
325
|
if ((currentByte & 128) === 0) {
|
|
@@ -430,223 +327,200 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
430
327
|
}
|
|
431
328
|
}
|
|
432
329
|
return [value, offset + byteCount];
|
|
433
|
-
}
|
|
330
|
+
},
|
|
331
|
+
description: options.description ?? "shortU16",
|
|
332
|
+
fixedSize: null,
|
|
333
|
+
maxSize: 3
|
|
334
|
+
});
|
|
335
|
+
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
336
|
+
name: "u32",
|
|
337
|
+
options,
|
|
338
|
+
range: [0, Number("0xffffffff")],
|
|
339
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
340
|
+
size: 4
|
|
341
|
+
});
|
|
342
|
+
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
343
|
+
get: (view, le) => view.getUint32(0, le),
|
|
344
|
+
name: "u32",
|
|
345
|
+
options,
|
|
346
|
+
size: 4
|
|
347
|
+
});
|
|
348
|
+
var getU8Encoder = (options = {}) => numberEncoderFactory({
|
|
349
|
+
name: "u8",
|
|
350
|
+
options,
|
|
351
|
+
range: [0, Number("0xff")],
|
|
352
|
+
set: (view, value) => view.setUint8(0, value),
|
|
353
|
+
size: 1
|
|
354
|
+
});
|
|
355
|
+
var getU8Decoder = (options = {}) => numberDecoderFactory({
|
|
356
|
+
get: (view) => view.getUint8(0),
|
|
357
|
+
name: "u8",
|
|
358
|
+
options,
|
|
359
|
+
size: 1
|
|
434
360
|
});
|
|
435
361
|
|
|
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");
|
|
451
|
-
}
|
|
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.5/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.5/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
|
-
}
|
|
468
|
-
|
|
469
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
470
|
-
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
471
|
-
if (typeof size === "number") {
|
|
472
|
-
return [size, offset];
|
|
473
|
-
}
|
|
474
|
-
if (typeof size === "object") {
|
|
475
|
-
return size.deserialize(bytes2, offset);
|
|
476
|
-
}
|
|
477
|
-
if (size === "remainder") {
|
|
478
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
479
|
-
if (childrenSize === null) {
|
|
480
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
481
|
-
}
|
|
482
|
-
const remainder = bytes2.slice(offset).length;
|
|
483
|
-
if (remainder % childrenSize !== 0) {
|
|
484
|
-
throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
|
|
485
|
-
}
|
|
486
|
-
return [remainder / childrenSize, offset];
|
|
362
|
+
// ../codecs-strings/dist/index.browser.js
|
|
363
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
364
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
365
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
487
366
|
}
|
|
488
|
-
throw new UnrecognizedArrayLikeSerializerSizeError(size);
|
|
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;
|
|
500
|
-
}
|
|
501
|
-
function getSizePrefix(size, realSize) {
|
|
502
|
-
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
503
367
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const size = options.size ?? u32();
|
|
508
|
-
if (size === "remainder" && item.fixedSize === null) {
|
|
509
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
510
|
-
}
|
|
368
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
369
|
+
const base = alphabet4.length;
|
|
370
|
+
const baseBigInt = BigInt(base);
|
|
511
371
|
return {
|
|
512
|
-
description:
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
372
|
+
description: `base${base}`,
|
|
373
|
+
encode(value) {
|
|
374
|
+
assertValidBaseString(alphabet4, value);
|
|
375
|
+
if (value === "")
|
|
376
|
+
return new Uint8Array();
|
|
377
|
+
const chars = [...value];
|
|
378
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
379
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
380
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
381
|
+
if (trailIndex === chars.length)
|
|
382
|
+
return Uint8Array.from(leadingZeroes);
|
|
383
|
+
const tailChars = chars.slice(trailIndex);
|
|
384
|
+
let base10Number = 0n;
|
|
385
|
+
let baseXPower = 1n;
|
|
386
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
387
|
+
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
388
|
+
baseXPower *= baseBigInt;
|
|
518
389
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
return [[], offset];
|
|
390
|
+
const tailBytes = [];
|
|
391
|
+
while (base10Number > 0n) {
|
|
392
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
393
|
+
base10Number /= 256n;
|
|
524
394
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
395
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
396
|
+
},
|
|
397
|
+
fixedSize: null,
|
|
398
|
+
maxSize: null
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
402
|
+
const base = alphabet4.length;
|
|
403
|
+
const baseBigInt = BigInt(base);
|
|
404
|
+
return {
|
|
405
|
+
decode(rawBytes, offset = 0) {
|
|
406
|
+
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
407
|
+
if (bytes.length === 0)
|
|
408
|
+
return ["", 0];
|
|
409
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
410
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
411
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
412
|
+
if (trailIndex === bytes.length)
|
|
413
|
+
return [leadingZeroes, rawBytes.length];
|
|
414
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
415
|
+
const tailChars = [];
|
|
416
|
+
while (base10Number > 0n) {
|
|
417
|
+
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
418
|
+
base10Number /= baseBigInt;
|
|
532
419
|
}
|
|
533
|
-
return [
|
|
534
|
-
}
|
|
420
|
+
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
421
|
+
},
|
|
422
|
+
description: `base${base}`,
|
|
423
|
+
fixedSize: null,
|
|
424
|
+
maxSize: null
|
|
535
425
|
};
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
426
|
+
};
|
|
427
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
428
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
429
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
430
|
+
var getBase64Encoder = () => {
|
|
431
|
+
{
|
|
432
|
+
return {
|
|
433
|
+
description: `base64`,
|
|
434
|
+
encode(value) {
|
|
435
|
+
try {
|
|
436
|
+
const bytes = atob(value).split("").map((c) => c.charCodeAt(0));
|
|
437
|
+
return new Uint8Array(bytes);
|
|
438
|
+
} catch (e23) {
|
|
439
|
+
throw new Error(`Expected a string of base 64, got [${value}].`);
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
fixedSize: null,
|
|
443
|
+
maxSize: null
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
var removeNullCharacters = (value) => (
|
|
448
|
+
// eslint-disable-next-line no-control-regex
|
|
449
|
+
value.replace(/\u0000/g, "")
|
|
450
|
+
);
|
|
451
|
+
var e = globalThis.TextDecoder;
|
|
452
|
+
var o = globalThis.TextEncoder;
|
|
453
|
+
var getUtf8Encoder = () => {
|
|
454
|
+
let textEncoder;
|
|
455
|
+
return {
|
|
456
|
+
description: "utf8",
|
|
457
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
545
458
|
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];
|
|
551
|
-
}
|
|
459
|
+
maxSize: null
|
|
552
460
|
};
|
|
461
|
+
};
|
|
462
|
+
var getUtf8Decoder = () => {
|
|
463
|
+
let textDecoder;
|
|
464
|
+
return {
|
|
465
|
+
decode(bytes, offset = 0) {
|
|
466
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
467
|
+
return [removeNullCharacters(value), bytes.length];
|
|
468
|
+
},
|
|
469
|
+
description: "utf8",
|
|
470
|
+
fixedSize: null,
|
|
471
|
+
maxSize: null
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
var getStringEncoder = (options = {}) => {
|
|
475
|
+
const size = options.size ?? getU32Encoder();
|
|
476
|
+
const encoding = options.encoding ?? getUtf8Encoder();
|
|
477
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
553
478
|
if (size === "variable") {
|
|
554
|
-
return
|
|
479
|
+
return { ...encoding, description };
|
|
555
480
|
}
|
|
556
481
|
if (typeof size === "number") {
|
|
557
|
-
return
|
|
482
|
+
return fixEncoder(encoding, size, description);
|
|
558
483
|
}
|
|
559
484
|
return {
|
|
560
485
|
description,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const contentBytes = byteSerializer.serialize(value);
|
|
565
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
486
|
+
encode: (value) => {
|
|
487
|
+
const contentBytes = encoding.encode(value);
|
|
488
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
566
489
|
return mergeBytes([lengthBytes, contentBytes]);
|
|
567
490
|
},
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
throw new DeserializingEmptyBufferError("bytes");
|
|
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];
|
|
582
|
-
}
|
|
491
|
+
fixedSize: null,
|
|
492
|
+
maxSize: null
|
|
583
493
|
};
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
function string(options = {}) {
|
|
589
|
-
const size = options.size ?? u32();
|
|
590
|
-
const encoding = options.encoding ?? utf8;
|
|
494
|
+
};
|
|
495
|
+
var getStringDecoder = (options = {}) => {
|
|
496
|
+
const size = options.size ?? getU32Decoder();
|
|
497
|
+
const encoding = options.encoding ?? getUtf8Decoder();
|
|
591
498
|
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
592
499
|
if (size === "variable") {
|
|
593
|
-
return {
|
|
594
|
-
...encoding,
|
|
595
|
-
description
|
|
596
|
-
};
|
|
500
|
+
return { ...encoding, description };
|
|
597
501
|
}
|
|
598
502
|
if (typeof size === "number") {
|
|
599
|
-
return
|
|
503
|
+
return fixDecoder(encoding, size, description);
|
|
600
504
|
}
|
|
601
505
|
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);
|
|
506
|
+
decode: (bytes, offset = 0) => {
|
|
507
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
508
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
615
509
|
const length = Number(lengthBigInt);
|
|
616
510
|
offset = lengthOffset;
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
const [value, contentOffset] = encoding.deserialize(contentBuffer);
|
|
511
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
512
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
513
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
622
514
|
offset += contentOffset;
|
|
623
515
|
return [value, offset];
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/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
516
|
},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const [value, newOffset] = serializer.deserialize(bytes2, offset);
|
|
644
|
-
offset = newOffset;
|
|
645
|
-
struct2[key] = value;
|
|
646
|
-
});
|
|
647
|
-
return [struct2, offset];
|
|
648
|
-
}
|
|
517
|
+
description,
|
|
518
|
+
fixedSize: null,
|
|
519
|
+
maxSize: null
|
|
649
520
|
};
|
|
521
|
+
};
|
|
522
|
+
function getSizeDescription(size) {
|
|
523
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
650
524
|
}
|
|
651
525
|
|
|
652
526
|
// ../assertions/dist/index.browser.js
|
|
@@ -715,7 +589,37 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
715
589
|
throw new Error("No signature verification implementation could be found");
|
|
716
590
|
}
|
|
717
591
|
}
|
|
718
|
-
|
|
592
|
+
|
|
593
|
+
// ../addresses/dist/index.browser.js
|
|
594
|
+
var memoizedBase58Encoder;
|
|
595
|
+
var memoizedBase58Decoder;
|
|
596
|
+
function getMemoizedBase58Encoder() {
|
|
597
|
+
if (!memoizedBase58Encoder)
|
|
598
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
599
|
+
return memoizedBase58Encoder;
|
|
600
|
+
}
|
|
601
|
+
function getMemoizedBase58Decoder() {
|
|
602
|
+
if (!memoizedBase58Decoder)
|
|
603
|
+
memoizedBase58Decoder = getBase58Decoder();
|
|
604
|
+
return memoizedBase58Decoder;
|
|
605
|
+
}
|
|
606
|
+
function isAddress(putativeBase58EncodedAddress) {
|
|
607
|
+
if (
|
|
608
|
+
// Lowest address (32 bytes of zeroes)
|
|
609
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
610
|
+
putativeBase58EncodedAddress.length > 44
|
|
611
|
+
) {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
const base58Encoder3 = getMemoizedBase58Encoder();
|
|
615
|
+
const bytes = base58Encoder3.encode(putativeBase58EncodedAddress);
|
|
616
|
+
const numBytes = bytes.byteLength;
|
|
617
|
+
if (numBytes !== 32) {
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
719
623
|
try {
|
|
720
624
|
if (
|
|
721
625
|
// Lowest address (32 bytes of zeroes)
|
|
@@ -724,25 +628,43 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
724
628
|
) {
|
|
725
629
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
726
630
|
}
|
|
727
|
-
const
|
|
728
|
-
const
|
|
631
|
+
const base58Encoder3 = getMemoizedBase58Encoder();
|
|
632
|
+
const bytes = base58Encoder3.encode(putativeBase58EncodedAddress);
|
|
633
|
+
const numBytes = bytes.byteLength;
|
|
729
634
|
if (numBytes !== 32) {
|
|
730
635
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
731
636
|
}
|
|
732
|
-
} catch (
|
|
637
|
+
} catch (e3) {
|
|
733
638
|
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
734
|
-
cause:
|
|
639
|
+
cause: e3
|
|
735
640
|
});
|
|
736
641
|
}
|
|
737
642
|
}
|
|
738
|
-
function
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
643
|
+
function address(putativeBase58EncodedAddress) {
|
|
644
|
+
assertIsAddress(putativeBase58EncodedAddress);
|
|
645
|
+
return putativeBase58EncodedAddress;
|
|
646
|
+
}
|
|
647
|
+
function getAddressEncoder(config) {
|
|
648
|
+
return mapEncoder(
|
|
649
|
+
getStringEncoder({
|
|
650
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
651
|
+
encoding: getMemoizedBase58Encoder(),
|
|
652
|
+
size: 32
|
|
653
|
+
}),
|
|
654
|
+
(putativeAddress) => address(putativeAddress)
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
function getAddressDecoder(config) {
|
|
658
|
+
return getStringDecoder({
|
|
659
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
660
|
+
encoding: getMemoizedBase58Decoder(),
|
|
742
661
|
size: 32
|
|
743
662
|
});
|
|
744
663
|
}
|
|
745
|
-
function
|
|
664
|
+
function getAddressCodec(config) {
|
|
665
|
+
return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
|
|
666
|
+
}
|
|
667
|
+
function getAddressComparator() {
|
|
746
668
|
return new Intl.Collator("en", {
|
|
747
669
|
caseFirst: "lower",
|
|
748
670
|
ignorePunctuation: false,
|
|
@@ -826,17 +748,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
826
748
|
return hexString;
|
|
827
749
|
}
|
|
828
750
|
}
|
|
829
|
-
function decompressPointBytes(
|
|
830
|
-
const hexString =
|
|
751
|
+
function decompressPointBytes(bytes) {
|
|
752
|
+
const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
|
|
831
753
|
const integerLiteralString = `0x${hexString}`;
|
|
832
754
|
return BigInt(integerLiteralString);
|
|
833
755
|
}
|
|
834
|
-
async function compressedPointBytesAreOnCurve(
|
|
835
|
-
if (
|
|
756
|
+
async function compressedPointBytesAreOnCurve(bytes) {
|
|
757
|
+
if (bytes.byteLength !== 32) {
|
|
836
758
|
return false;
|
|
837
759
|
}
|
|
838
|
-
const y = decompressPointBytes(
|
|
839
|
-
return pointIsOnCurve(y,
|
|
760
|
+
const y = decompressPointBytes(bytes);
|
|
761
|
+
return pointIsOnCurve(y, bytes[31]);
|
|
762
|
+
}
|
|
763
|
+
function isProgramDerivedAddress(value) {
|
|
764
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number" && value[1] >= 0 && value[1] <= 255 && isAddress(value[0]);
|
|
765
|
+
}
|
|
766
|
+
function assertIsProgramDerivedAddress(value) {
|
|
767
|
+
const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number";
|
|
768
|
+
if (!validFormat) {
|
|
769
|
+
throw new Error(
|
|
770
|
+
`Expected given program derived address to have the following format: [Base58EncodedAddress, ProgramDerivedAddressBump].`
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
if (value[1] < 0 || value[1] > 255) {
|
|
774
|
+
throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);
|
|
775
|
+
}
|
|
776
|
+
assertIsAddress(value[0]);
|
|
840
777
|
}
|
|
841
778
|
var MAX_SEED_LENGTH = 32;
|
|
842
779
|
var MAX_SEEDS = 16;
|
|
@@ -866,22 +803,25 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
866
803
|
];
|
|
867
804
|
var PointOnCurveError = class extends Error {
|
|
868
805
|
};
|
|
869
|
-
async function createProgramDerivedAddress({
|
|
806
|
+
async function createProgramDerivedAddress({
|
|
807
|
+
programAddress,
|
|
808
|
+
seeds
|
|
809
|
+
}) {
|
|
870
810
|
await assertDigestCapabilityIsAvailable();
|
|
871
811
|
if (seeds.length > MAX_SEEDS) {
|
|
872
812
|
throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
|
|
873
813
|
}
|
|
874
814
|
let textEncoder;
|
|
875
815
|
const seedBytes = seeds.reduce((acc, seed, ii) => {
|
|
876
|
-
const
|
|
877
|
-
if (
|
|
816
|
+
const bytes = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
|
|
817
|
+
if (bytes.byteLength > MAX_SEED_LENGTH) {
|
|
878
818
|
throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
|
|
879
819
|
}
|
|
880
|
-
acc.push(...
|
|
820
|
+
acc.push(...bytes);
|
|
881
821
|
return acc;
|
|
882
822
|
}, []);
|
|
883
|
-
const base58EncodedAddressCodec =
|
|
884
|
-
const programAddressBytes = base58EncodedAddressCodec.
|
|
823
|
+
const base58EncodedAddressCodec = getAddressCodec();
|
|
824
|
+
const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);
|
|
885
825
|
const addressBytesBuffer = await crypto.subtle.digest(
|
|
886
826
|
"SHA-256",
|
|
887
827
|
new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
|
|
@@ -890,36 +830,58 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
890
830
|
if (await compressedPointBytesAreOnCurve(addressBytes)) {
|
|
891
831
|
throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
|
|
892
832
|
}
|
|
893
|
-
return base58EncodedAddressCodec.
|
|
833
|
+
return base58EncodedAddressCodec.decode(addressBytes)[0];
|
|
894
834
|
}
|
|
895
|
-
async function getProgramDerivedAddress({
|
|
835
|
+
async function getProgramDerivedAddress({
|
|
836
|
+
programAddress,
|
|
837
|
+
seeds
|
|
838
|
+
}) {
|
|
896
839
|
let bumpSeed = 255;
|
|
897
840
|
while (bumpSeed > 0) {
|
|
898
841
|
try {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
} catch (e2) {
|
|
907
|
-
if (e2 instanceof PointOnCurveError) {
|
|
842
|
+
const address2 = await createProgramDerivedAddress({
|
|
843
|
+
programAddress,
|
|
844
|
+
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
845
|
+
});
|
|
846
|
+
return [address2, bumpSeed];
|
|
847
|
+
} catch (e3) {
|
|
848
|
+
if (e3 instanceof PointOnCurveError) {
|
|
908
849
|
bumpSeed--;
|
|
909
850
|
} else {
|
|
910
|
-
throw
|
|
851
|
+
throw e3;
|
|
911
852
|
}
|
|
912
853
|
}
|
|
913
854
|
}
|
|
914
855
|
throw new Error("Unable to find a viable program address bump seed");
|
|
915
856
|
}
|
|
916
|
-
async function
|
|
857
|
+
async function createAddressWithSeed({
|
|
858
|
+
baseAddress,
|
|
859
|
+
programAddress,
|
|
860
|
+
seed
|
|
861
|
+
}) {
|
|
862
|
+
const { encode: encode2, decode: decode2 } = getAddressCodec();
|
|
863
|
+
const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
|
|
864
|
+
if (seedBytes.byteLength > MAX_SEED_LENGTH) {
|
|
865
|
+
throw new Error(`The seed exceeds the maximum length of 32 bytes`);
|
|
866
|
+
}
|
|
867
|
+
const programAddressBytes = encode2(programAddress);
|
|
868
|
+
if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
|
|
869
|
+
throw new Error(`programAddress cannot end with the PDA marker`);
|
|
870
|
+
}
|
|
871
|
+
const addressBytesBuffer = await crypto.subtle.digest(
|
|
872
|
+
"SHA-256",
|
|
873
|
+
new Uint8Array([...encode2(baseAddress), ...seedBytes, ...programAddressBytes])
|
|
874
|
+
);
|
|
875
|
+
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
876
|
+
return decode2(addressBytes)[0];
|
|
877
|
+
}
|
|
878
|
+
async function getAddressFromPublicKey(publicKey) {
|
|
917
879
|
await assertKeyExporterIsAvailable();
|
|
918
880
|
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
919
881
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
920
882
|
}
|
|
921
883
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
922
|
-
const [base58EncodedAddress] =
|
|
884
|
+
const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
923
885
|
return base58EncodedAddress;
|
|
924
886
|
}
|
|
925
887
|
|
|
@@ -986,8 +948,286 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
986
948
|
return await crypto.subtle.verify("Ed25519", key, signature, data);
|
|
987
949
|
}
|
|
988
950
|
|
|
951
|
+
// ../rpc-types/dist/index.browser.js
|
|
952
|
+
init_env_shim();
|
|
953
|
+
function getCommitmentScore(commitment) {
|
|
954
|
+
switch (commitment) {
|
|
955
|
+
case "finalized":
|
|
956
|
+
return 2;
|
|
957
|
+
case "confirmed":
|
|
958
|
+
return 1;
|
|
959
|
+
case "processed":
|
|
960
|
+
return 0;
|
|
961
|
+
default:
|
|
962
|
+
return ((_) => {
|
|
963
|
+
throw new Error(`Unrecognized commitment \`${commitment}\`.`);
|
|
964
|
+
})();
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
function commitmentComparator(a, b) {
|
|
968
|
+
if (a === b) {
|
|
969
|
+
return 0;
|
|
970
|
+
}
|
|
971
|
+
return getCommitmentScore(a) < getCommitmentScore(b) ? -1 : 1;
|
|
972
|
+
}
|
|
973
|
+
var maxU64Value = 18446744073709551615n;
|
|
974
|
+
function isLamports(putativeLamports) {
|
|
975
|
+
return putativeLamports >= 0 && putativeLamports <= maxU64Value;
|
|
976
|
+
}
|
|
977
|
+
function assertIsLamports(putativeLamports) {
|
|
978
|
+
if (putativeLamports < 0) {
|
|
979
|
+
throw new Error("Input for 64-bit unsigned integer cannot be negative");
|
|
980
|
+
}
|
|
981
|
+
if (putativeLamports > maxU64Value) {
|
|
982
|
+
throw new Error("Input number is too large to be represented as a 64-bit unsigned integer");
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
function lamports(putativeLamports) {
|
|
986
|
+
assertIsLamports(putativeLamports);
|
|
987
|
+
return putativeLamports;
|
|
988
|
+
}
|
|
989
|
+
function isStringifiedBigInt(putativeBigInt) {
|
|
990
|
+
try {
|
|
991
|
+
BigInt(putativeBigInt);
|
|
992
|
+
return true;
|
|
993
|
+
} catch (_) {
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function assertIsStringifiedBigInt(putativeBigInt) {
|
|
998
|
+
try {
|
|
999
|
+
BigInt(putativeBigInt);
|
|
1000
|
+
} catch (e3) {
|
|
1001
|
+
throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, {
|
|
1002
|
+
cause: e3
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
function stringifiedBigInt(putativeBigInt) {
|
|
1007
|
+
assertIsStringifiedBigInt(putativeBigInt);
|
|
1008
|
+
return putativeBigInt;
|
|
1009
|
+
}
|
|
1010
|
+
function isStringifiedNumber(putativeNumber) {
|
|
1011
|
+
return !Number.isNaN(Number(putativeNumber));
|
|
1012
|
+
}
|
|
1013
|
+
function assertIsStringifiedNumber(putativeNumber) {
|
|
1014
|
+
if (Number.isNaN(Number(putativeNumber))) {
|
|
1015
|
+
throw new Error(`\`${putativeNumber}\` cannot be parsed as a Number`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
function stringifiedNumber(putativeNumber) {
|
|
1019
|
+
assertIsStringifiedNumber(putativeNumber);
|
|
1020
|
+
return putativeNumber;
|
|
1021
|
+
}
|
|
1022
|
+
function isUnixTimestamp(putativeTimestamp) {
|
|
1023
|
+
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
|
|
1024
|
+
return false;
|
|
1025
|
+
}
|
|
1026
|
+
return true;
|
|
1027
|
+
}
|
|
1028
|
+
function assertIsUnixTimestamp(putativeTimestamp) {
|
|
1029
|
+
try {
|
|
1030
|
+
if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
|
|
1031
|
+
throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]");
|
|
1032
|
+
}
|
|
1033
|
+
} catch (e3) {
|
|
1034
|
+
throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, {
|
|
1035
|
+
cause: e3
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function unixTimestamp(putativeTimestamp) {
|
|
1040
|
+
assertIsUnixTimestamp(putativeTimestamp);
|
|
1041
|
+
return putativeTimestamp;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
989
1044
|
// ../transactions/dist/index.browser.js
|
|
990
1045
|
init_env_shim();
|
|
1046
|
+
|
|
1047
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
1048
|
+
init_env_shim();
|
|
1049
|
+
function sumCodecSizes(sizes) {
|
|
1050
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
1051
|
+
}
|
|
1052
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
1053
|
+
if (typeof size === "number") {
|
|
1054
|
+
return [size, offset];
|
|
1055
|
+
}
|
|
1056
|
+
if (typeof size === "object") {
|
|
1057
|
+
return size.decode(bytes, offset);
|
|
1058
|
+
}
|
|
1059
|
+
if (size === "remainder") {
|
|
1060
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1061
|
+
if (childrenSize === null) {
|
|
1062
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1063
|
+
}
|
|
1064
|
+
const remainder = bytes.slice(offset).length;
|
|
1065
|
+
if (remainder % childrenSize !== 0) {
|
|
1066
|
+
throw new Error(
|
|
1067
|
+
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
return [remainder / childrenSize, offset];
|
|
1071
|
+
}
|
|
1072
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1073
|
+
}
|
|
1074
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
1075
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
1076
|
+
}
|
|
1077
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
1078
|
+
if (typeof size !== "number")
|
|
1079
|
+
return null;
|
|
1080
|
+
if (size === 0)
|
|
1081
|
+
return 0;
|
|
1082
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1083
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
1084
|
+
}
|
|
1085
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
1086
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
1087
|
+
}
|
|
1088
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1089
|
+
if (expected !== actual) {
|
|
1090
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
function arrayCodecHelper(item, size, description) {
|
|
1094
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
1095
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1096
|
+
}
|
|
1097
|
+
return {
|
|
1098
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1099
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1100
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
function getArrayEncoder(item, options = {}) {
|
|
1104
|
+
const size = options.size ?? getU32Encoder();
|
|
1105
|
+
return {
|
|
1106
|
+
...arrayCodecHelper(item, size, options.description),
|
|
1107
|
+
encode: (value) => {
|
|
1108
|
+
if (typeof size === "number") {
|
|
1109
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
1110
|
+
}
|
|
1111
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
function getArrayDecoder(item, options = {}) {
|
|
1116
|
+
const size = options.size ?? getU32Decoder();
|
|
1117
|
+
return {
|
|
1118
|
+
...arrayCodecHelper(item, size, options.description),
|
|
1119
|
+
decode: (bytes, offset = 0) => {
|
|
1120
|
+
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
1121
|
+
return [[], offset];
|
|
1122
|
+
}
|
|
1123
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
|
|
1124
|
+
offset = newOffset;
|
|
1125
|
+
const values = [];
|
|
1126
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1127
|
+
const [value, newOffset2] = item.decode(bytes, offset);
|
|
1128
|
+
values.push(value);
|
|
1129
|
+
offset = newOffset2;
|
|
1130
|
+
}
|
|
1131
|
+
return [values, offset];
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
function getBytesEncoder(options = {}) {
|
|
1136
|
+
const size = options.size ?? "variable";
|
|
1137
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1138
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
1139
|
+
const byteEncoder = {
|
|
1140
|
+
description,
|
|
1141
|
+
encode: (value) => value,
|
|
1142
|
+
fixedSize: null,
|
|
1143
|
+
maxSize: null
|
|
1144
|
+
};
|
|
1145
|
+
if (size === "variable") {
|
|
1146
|
+
return byteEncoder;
|
|
1147
|
+
}
|
|
1148
|
+
if (typeof size === "number") {
|
|
1149
|
+
return fixEncoder(byteEncoder, size, description);
|
|
1150
|
+
}
|
|
1151
|
+
return {
|
|
1152
|
+
...byteEncoder,
|
|
1153
|
+
encode: (value) => {
|
|
1154
|
+
const contentBytes = byteEncoder.encode(value);
|
|
1155
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
1156
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
function getBytesDecoder(options = {}) {
|
|
1161
|
+
const size = options.size ?? "variable";
|
|
1162
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1163
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
1164
|
+
const byteDecoder = {
|
|
1165
|
+
decode: (bytes, offset = 0) => {
|
|
1166
|
+
const slice = bytes.slice(offset);
|
|
1167
|
+
return [slice, offset + slice.length];
|
|
1168
|
+
},
|
|
1169
|
+
description,
|
|
1170
|
+
fixedSize: null,
|
|
1171
|
+
maxSize: null
|
|
1172
|
+
};
|
|
1173
|
+
if (size === "variable") {
|
|
1174
|
+
return byteDecoder;
|
|
1175
|
+
}
|
|
1176
|
+
if (typeof size === "number") {
|
|
1177
|
+
return fixDecoder(byteDecoder, size, description);
|
|
1178
|
+
}
|
|
1179
|
+
return {
|
|
1180
|
+
...byteDecoder,
|
|
1181
|
+
decode: (bytes, offset = 0) => {
|
|
1182
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
1183
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
1184
|
+
const length = Number(lengthBigInt);
|
|
1185
|
+
offset = lengthOffset;
|
|
1186
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
1187
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1188
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
1189
|
+
offset += contentOffset;
|
|
1190
|
+
return [value, offset];
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
function structCodecHelper(fields, description) {
|
|
1195
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
1196
|
+
return {
|
|
1197
|
+
description: description ?? `struct(${fieldDescriptions})`,
|
|
1198
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
1199
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
function getStructEncoder(fields, options = {}) {
|
|
1203
|
+
return {
|
|
1204
|
+
...structCodecHelper(fields, options.description),
|
|
1205
|
+
encode: (struct) => {
|
|
1206
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
1207
|
+
return mergeBytes(fieldBytes);
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
function getStructDecoder(fields, options = {}) {
|
|
1212
|
+
return {
|
|
1213
|
+
...structCodecHelper(fields, options.description),
|
|
1214
|
+
decode: (bytes, offset = 0) => {
|
|
1215
|
+
const struct = {};
|
|
1216
|
+
fields.forEach(([key, codec]) => {
|
|
1217
|
+
const [value, newOffset] = codec.decode(bytes, offset);
|
|
1218
|
+
offset = newOffset;
|
|
1219
|
+
struct[key] = value;
|
|
1220
|
+
});
|
|
1221
|
+
return [struct, offset];
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// ../functional/dist/index.browser.js
|
|
1227
|
+
init_env_shim();
|
|
1228
|
+
function pipe(init, ...fns) {
|
|
1229
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1230
|
+
}
|
|
991
1231
|
function getUnsignedTransaction(transaction) {
|
|
992
1232
|
if ("signatures" in transaction) {
|
|
993
1233
|
const {
|
|
@@ -1000,7 +1240,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1000
1240
|
return transaction;
|
|
1001
1241
|
}
|
|
1002
1242
|
}
|
|
1243
|
+
var base58Encoder;
|
|
1003
1244
|
function assertIsBlockhash(putativeBlockhash) {
|
|
1245
|
+
if (!base58Encoder)
|
|
1246
|
+
base58Encoder = getBase58Encoder();
|
|
1004
1247
|
try {
|
|
1005
1248
|
if (
|
|
1006
1249
|
// Lowest value (32 bytes of zeroes)
|
|
@@ -1009,14 +1252,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1009
1252
|
) {
|
|
1010
1253
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1011
1254
|
}
|
|
1012
|
-
const
|
|
1013
|
-
const numBytes =
|
|
1255
|
+
const bytes = base58Encoder.encode(putativeBlockhash);
|
|
1256
|
+
const numBytes = bytes.byteLength;
|
|
1014
1257
|
if (numBytes !== 32) {
|
|
1015
1258
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1016
1259
|
}
|
|
1017
|
-
} catch (
|
|
1260
|
+
} catch (e3) {
|
|
1018
1261
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
1019
|
-
cause:
|
|
1262
|
+
cause: e3
|
|
1020
1263
|
});
|
|
1021
1264
|
}
|
|
1022
1265
|
}
|
|
@@ -1089,7 +1332,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1089
1332
|
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
1090
1333
|
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
|
|
1091
1334
|
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
|
|
1092
|
-
instruction.accounts[2].address != null && instruction.accounts[2].role
|
|
1335
|
+
instruction.accounts[2].address != null && isSignerRole2(instruction.accounts[2].role);
|
|
1093
1336
|
}
|
|
1094
1337
|
function isAdvanceNonceAccountInstructionData(data) {
|
|
1095
1338
|
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
@@ -1097,21 +1340,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1097
1340
|
function isDurableNonceTransaction(transaction) {
|
|
1098
1341
|
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
1099
1342
|
}
|
|
1343
|
+
function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
|
|
1344
|
+
return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
|
|
1345
|
+
}
|
|
1100
1346
|
function setTransactionLifetimeUsingDurableNonce({
|
|
1101
1347
|
nonce,
|
|
1102
1348
|
nonceAccountAddress,
|
|
1103
1349
|
nonceAuthorityAddress
|
|
1104
1350
|
}, transaction) {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1351
|
+
let newInstructions;
|
|
1352
|
+
const firstInstruction = transaction.instructions[0];
|
|
1353
|
+
if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1354
|
+
if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
|
|
1355
|
+
if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
|
|
1356
|
+
return transaction;
|
|
1357
|
+
} else {
|
|
1358
|
+
newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
|
|
1359
|
+
}
|
|
1360
|
+
} else {
|
|
1361
|
+
newInstructions = [
|
|
1362
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
1363
|
+
...transaction.instructions.slice(1)
|
|
1364
|
+
];
|
|
1365
|
+
}
|
|
1366
|
+
} else {
|
|
1367
|
+
newInstructions = [
|
|
1368
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
1369
|
+
...transaction.instructions
|
|
1370
|
+
];
|
|
1108
1371
|
}
|
|
1109
1372
|
const out = {
|
|
1110
1373
|
...getUnsignedTransaction(transaction),
|
|
1111
|
-
instructions:
|
|
1112
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
1113
|
-
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
1114
|
-
],
|
|
1374
|
+
instructions: newInstructions,
|
|
1115
1375
|
lifetimeConstraint: {
|
|
1116
1376
|
nonce
|
|
1117
1377
|
}
|
|
@@ -1146,8 +1406,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1146
1406
|
Object.freeze(out);
|
|
1147
1407
|
return out;
|
|
1148
1408
|
}
|
|
1149
|
-
function upsert(addressMap,
|
|
1150
|
-
addressMap[
|
|
1409
|
+
function upsert(addressMap, address2, update) {
|
|
1410
|
+
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole2.READONLY });
|
|
1151
1411
|
}
|
|
1152
1412
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
1153
1413
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -1198,7 +1458,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1198
1458
|
const shouldReplaceEntry = (
|
|
1199
1459
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
1200
1460
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
1201
|
-
(addressComparator || (addressComparator =
|
|
1461
|
+
(addressComparator || (addressComparator = getAddressComparator()))(
|
|
1202
1462
|
accountMeta.lookupTableAddress,
|
|
1203
1463
|
entry.lookupTableAddress
|
|
1204
1464
|
) < 0
|
|
@@ -1306,14 +1566,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1306
1566
|
if (leftIsWritable !== isWritableRole2(rightEntry.role)) {
|
|
1307
1567
|
return leftIsWritable ? -1 : 1;
|
|
1308
1568
|
}
|
|
1309
|
-
addressComparator || (addressComparator =
|
|
1569
|
+
addressComparator || (addressComparator = getAddressComparator());
|
|
1310
1570
|
if (leftEntry[TYPE] === 1 && rightEntry[TYPE] === 1 && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
1311
1571
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
1312
1572
|
} else {
|
|
1313
1573
|
return addressComparator(leftAddress, rightAddress);
|
|
1314
1574
|
}
|
|
1315
|
-
}).map(([
|
|
1316
|
-
address,
|
|
1575
|
+
}).map(([address2, addressMeta]) => ({
|
|
1576
|
+
address: address2,
|
|
1317
1577
|
...addressMeta
|
|
1318
1578
|
}));
|
|
1319
1579
|
return orderedAccounts;
|
|
@@ -1335,7 +1595,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1335
1595
|
entry.readableIndices.push(account.addressIndex);
|
|
1336
1596
|
}
|
|
1337
1597
|
}
|
|
1338
|
-
return Object.keys(index).sort(
|
|
1598
|
+
return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
|
|
1339
1599
|
lookupTableAddress,
|
|
1340
1600
|
...index[lookupTableAddress]
|
|
1341
1601
|
}));
|
|
@@ -1376,7 +1636,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1376
1636
|
return instructions.map(({ accounts, data, programAddress }) => {
|
|
1377
1637
|
return {
|
|
1378
1638
|
programAddressIndex: accountIndex[programAddress],
|
|
1379
|
-
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[
|
|
1639
|
+
...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
|
|
1380
1640
|
...data ? { data } : null
|
|
1381
1641
|
};
|
|
1382
1642
|
});
|
|
@@ -1390,7 +1650,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1390
1650
|
function getCompiledStaticAccounts(orderedAccounts) {
|
|
1391
1651
|
const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
|
|
1392
1652
|
const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
|
|
1393
|
-
return orderedStaticAccounts.map(({ address }) =>
|
|
1653
|
+
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
|
1394
1654
|
}
|
|
1395
1655
|
function compileMessage(transaction) {
|
|
1396
1656
|
const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
|
|
@@ -1404,138 +1664,306 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1404
1664
|
version: transaction.version
|
|
1405
1665
|
};
|
|
1406
1666
|
}
|
|
1407
|
-
function
|
|
1408
|
-
|
|
1409
|
-
|
|
1667
|
+
function getCompiledTransaction(transaction) {
|
|
1668
|
+
const compiledMessage = compileMessage(transaction);
|
|
1669
|
+
let signatures;
|
|
1670
|
+
if ("signatures" in transaction) {
|
|
1671
|
+
signatures = [];
|
|
1672
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1673
|
+
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1674
|
+
}
|
|
1675
|
+
} else {
|
|
1676
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1677
|
+
}
|
|
1678
|
+
return {
|
|
1679
|
+
compiledMessage,
|
|
1680
|
+
signatures
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
function getAccountMetas(message) {
|
|
1684
|
+
const { header } = message;
|
|
1685
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
1686
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
1687
|
+
const accountMetas = [];
|
|
1688
|
+
let accountIndex = 0;
|
|
1689
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
1690
|
+
accountMetas.push({
|
|
1691
|
+
address: message.staticAccounts[accountIndex],
|
|
1692
|
+
role: AccountRole2.WRITABLE_SIGNER
|
|
1693
|
+
});
|
|
1694
|
+
accountIndex++;
|
|
1695
|
+
}
|
|
1696
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
1697
|
+
accountMetas.push({
|
|
1698
|
+
address: message.staticAccounts[accountIndex],
|
|
1699
|
+
role: AccountRole2.READONLY_SIGNER
|
|
1700
|
+
});
|
|
1701
|
+
accountIndex++;
|
|
1702
|
+
}
|
|
1703
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
1704
|
+
accountMetas.push({
|
|
1705
|
+
address: message.staticAccounts[accountIndex],
|
|
1706
|
+
role: AccountRole2.WRITABLE
|
|
1707
|
+
});
|
|
1708
|
+
accountIndex++;
|
|
1709
|
+
}
|
|
1710
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
1711
|
+
accountMetas.push({
|
|
1712
|
+
address: message.staticAccounts[accountIndex],
|
|
1713
|
+
role: AccountRole2.READONLY
|
|
1714
|
+
});
|
|
1715
|
+
accountIndex++;
|
|
1716
|
+
}
|
|
1717
|
+
return accountMetas;
|
|
1718
|
+
}
|
|
1719
|
+
function convertInstruction(instruction, accountMetas) {
|
|
1720
|
+
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
1721
|
+
if (!programAddress) {
|
|
1722
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
1723
|
+
}
|
|
1724
|
+
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
1725
|
+
const { data } = instruction;
|
|
1726
|
+
return {
|
|
1727
|
+
programAddress,
|
|
1728
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
1729
|
+
...data && data.length ? { data } : {}
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
1733
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1734
|
+
return {
|
|
1735
|
+
blockhash: messageLifetimeToken,
|
|
1736
|
+
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
1737
|
+
// U64 MAX
|
|
1738
|
+
};
|
|
1739
|
+
} else {
|
|
1740
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
1741
|
+
assertIsAddress(nonceAccountAddress);
|
|
1742
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
1743
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
1744
|
+
return {
|
|
1745
|
+
nonce: messageLifetimeToken,
|
|
1746
|
+
nonceAccountAddress,
|
|
1747
|
+
nonceAuthorityAddress
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
function convertSignatures(compiledTransaction) {
|
|
1752
|
+
const {
|
|
1753
|
+
compiledMessage: { staticAccounts },
|
|
1754
|
+
signatures
|
|
1755
|
+
} = compiledTransaction;
|
|
1756
|
+
return signatures.reduce((acc, sig, index) => {
|
|
1757
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
1758
|
+
if (allZeros)
|
|
1759
|
+
return acc;
|
|
1760
|
+
const address2 = staticAccounts[index];
|
|
1761
|
+
return { ...acc, [address2]: sig };
|
|
1762
|
+
}, {});
|
|
1763
|
+
}
|
|
1764
|
+
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
1765
|
+
const { compiledMessage } = compiledTransaction;
|
|
1766
|
+
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
1767
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
1768
|
+
}
|
|
1769
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
1770
|
+
if (!feePayer)
|
|
1771
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
1772
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
1773
|
+
const instructions = compiledMessage.instructions.map(
|
|
1774
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
1775
|
+
);
|
|
1776
|
+
const firstInstruction = instructions[0];
|
|
1777
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
1778
|
+
compiledMessage.lifetimeToken,
|
|
1779
|
+
firstInstruction,
|
|
1780
|
+
lastValidBlockHeight
|
|
1781
|
+
);
|
|
1782
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
1783
|
+
return pipe(
|
|
1784
|
+
createTransaction({ version: compiledMessage.version }),
|
|
1785
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
1786
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
1787
|
+
return appendTransactionInstruction(instruction, acc);
|
|
1788
|
+
}, tx),
|
|
1789
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
1790
|
+
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
1791
|
+
);
|
|
1792
|
+
}
|
|
1793
|
+
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
1794
|
+
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
1795
|
+
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
1796
|
+
var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
|
|
1797
|
+
var memoizedAddressTableLookupEncoder;
|
|
1798
|
+
function getAddressTableLookupEncoder() {
|
|
1799
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
1800
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
1410
1801
|
[
|
|
1411
|
-
"lookupTableAddress",
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1802
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
1803
|
+
[
|
|
1804
|
+
"writableIndices",
|
|
1805
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1806
|
+
description: writableIndicesDescription,
|
|
1807
|
+
size: getShortU16Encoder()
|
|
1808
|
+
})
|
|
1809
|
+
],
|
|
1810
|
+
[
|
|
1811
|
+
"readableIndices",
|
|
1812
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1813
|
+
description: readableIndicesDescription,
|
|
1814
|
+
size: getShortU16Encoder()
|
|
1815
|
+
})
|
|
1816
|
+
]
|
|
1417
1817
|
],
|
|
1818
|
+
{ description: addressTableLookupDescription }
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
return memoizedAddressTableLookupEncoder;
|
|
1822
|
+
}
|
|
1823
|
+
var memoizedAddressTableLookupDecoder;
|
|
1824
|
+
function getAddressTableLookupDecoder() {
|
|
1825
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
1826
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1418
1827
|
[
|
|
1419
|
-
"
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1828
|
+
["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
|
|
1829
|
+
[
|
|
1830
|
+
"writableIndices",
|
|
1831
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1832
|
+
description: writableIndicesDescription,
|
|
1833
|
+
size: getShortU16Decoder()
|
|
1834
|
+
})
|
|
1835
|
+
],
|
|
1836
|
+
[
|
|
1837
|
+
"readableIndices",
|
|
1838
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1839
|
+
description: readableIndicesDescription,
|
|
1840
|
+
size: getShortU16Decoder()
|
|
1841
|
+
})
|
|
1842
|
+
]
|
|
1426
1843
|
],
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1844
|
+
{ description: addressTableLookupDescription }
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
return memoizedAddressTableLookupDecoder;
|
|
1848
|
+
}
|
|
1849
|
+
var memoizedU8Encoder;
|
|
1850
|
+
function getMemoizedU8Encoder() {
|
|
1851
|
+
if (!memoizedU8Encoder)
|
|
1852
|
+
memoizedU8Encoder = getU8Encoder();
|
|
1853
|
+
return memoizedU8Encoder;
|
|
1854
|
+
}
|
|
1855
|
+
function getMemoizedU8EncoderDescription(description) {
|
|
1856
|
+
const encoder = getMemoizedU8Encoder();
|
|
1857
|
+
return {
|
|
1858
|
+
...encoder,
|
|
1859
|
+
description: description ?? encoder.description
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
var memoizedU8Decoder;
|
|
1863
|
+
function getMemoizedU8Decoder() {
|
|
1864
|
+
if (!memoizedU8Decoder)
|
|
1865
|
+
memoizedU8Decoder = getU8Decoder();
|
|
1866
|
+
return memoizedU8Decoder;
|
|
1867
|
+
}
|
|
1868
|
+
function getMemoizedU8DecoderDescription(description) {
|
|
1869
|
+
const decoder = getMemoizedU8Decoder();
|
|
1870
|
+
return {
|
|
1871
|
+
...decoder,
|
|
1872
|
+
description: description ?? decoder.description
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
1876
|
+
var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ;
|
|
1877
|
+
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
1878
|
+
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1879
|
+
function getMessageHeaderEncoder() {
|
|
1880
|
+
return getStructEncoder(
|
|
1881
|
+
[
|
|
1882
|
+
["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
|
|
1883
|
+
["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
|
|
1884
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1436
1885
|
],
|
|
1437
1886
|
{
|
|
1438
|
-
description:
|
|
1439
|
-
}
|
|
1887
|
+
description: messageHeaderDescription
|
|
1888
|
+
}
|
|
1440
1889
|
);
|
|
1441
1890
|
}
|
|
1442
|
-
function
|
|
1443
|
-
return
|
|
1891
|
+
function getMessageHeaderDecoder() {
|
|
1892
|
+
return getStructDecoder(
|
|
1444
1893
|
[
|
|
1445
|
-
[
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
{
|
|
1449
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
|
|
1450
|
-
}
|
|
1451
|
-
)
|
|
1452
|
-
],
|
|
1453
|
-
[
|
|
1454
|
-
"numReadonlySignerAccounts",
|
|
1455
|
-
u8(
|
|
1456
|
-
{
|
|
1457
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
|
|
1458
|
-
}
|
|
1459
|
-
)
|
|
1460
|
-
],
|
|
1461
|
-
[
|
|
1462
|
-
"numReadonlyNonSignerAccounts",
|
|
1463
|
-
u8(
|
|
1464
|
-
{
|
|
1465
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
1466
|
-
}
|
|
1467
|
-
)
|
|
1468
|
-
]
|
|
1894
|
+
["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
|
|
1895
|
+
["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
|
|
1896
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1469
1897
|
],
|
|
1470
1898
|
{
|
|
1471
|
-
description:
|
|
1472
|
-
}
|
|
1473
|
-
);
|
|
1474
|
-
}
|
|
1475
|
-
function getInstructionCodec() {
|
|
1476
|
-
return mapSerializer(
|
|
1477
|
-
struct([
|
|
1478
|
-
[
|
|
1479
|
-
"programAddressIndex",
|
|
1480
|
-
u8(
|
|
1481
|
-
{
|
|
1482
|
-
description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
|
|
1483
|
-
}
|
|
1484
|
-
)
|
|
1485
|
-
],
|
|
1486
|
-
[
|
|
1487
|
-
"addressIndices",
|
|
1488
|
-
array(
|
|
1489
|
-
u8({
|
|
1490
|
-
description: "The index of an account, according to the well-ordered accounts list for this transaction"
|
|
1491
|
-
}),
|
|
1492
|
-
{
|
|
1493
|
-
description: "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ,
|
|
1494
|
-
size: shortU16()
|
|
1495
|
-
}
|
|
1496
|
-
)
|
|
1497
|
-
],
|
|
1498
|
-
[
|
|
1499
|
-
"data",
|
|
1500
|
-
bytes({
|
|
1501
|
-
description: "An optional buffer of data passed to the instruction" ,
|
|
1502
|
-
size: shortU16()
|
|
1503
|
-
})
|
|
1504
|
-
]
|
|
1505
|
-
]),
|
|
1506
|
-
(value) => {
|
|
1507
|
-
if (value.addressIndices !== void 0 && value.data !== void 0) {
|
|
1508
|
-
return value;
|
|
1509
|
-
}
|
|
1510
|
-
return {
|
|
1511
|
-
...value,
|
|
1512
|
-
addressIndices: value.addressIndices ?? [],
|
|
1513
|
-
data: value.data ?? new Uint8Array(0)
|
|
1514
|
-
};
|
|
1515
|
-
},
|
|
1516
|
-
(value) => {
|
|
1517
|
-
if (value.addressIndices.length && value.data.byteLength) {
|
|
1518
|
-
return value;
|
|
1519
|
-
}
|
|
1520
|
-
const { addressIndices, data, ...rest } = value;
|
|
1521
|
-
return {
|
|
1522
|
-
...rest,
|
|
1523
|
-
...addressIndices.length ? { addressIndices } : null,
|
|
1524
|
-
...data.byteLength ? { data } : null
|
|
1525
|
-
};
|
|
1899
|
+
description: messageHeaderDescription
|
|
1526
1900
|
}
|
|
1527
1901
|
);
|
|
1528
1902
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1903
|
+
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
1904
|
+
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
1905
|
+
var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
|
|
1906
|
+
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
1907
|
+
var memoizedGetInstructionEncoder;
|
|
1908
|
+
function getInstructionEncoder() {
|
|
1909
|
+
if (!memoizedGetInstructionEncoder) {
|
|
1910
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
1911
|
+
getStructEncoder([
|
|
1912
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
1913
|
+
[
|
|
1914
|
+
"accountIndices",
|
|
1915
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
1916
|
+
description: accountIndicesDescription,
|
|
1917
|
+
size: getShortU16Encoder()
|
|
1918
|
+
})
|
|
1919
|
+
],
|
|
1920
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
1921
|
+
]),
|
|
1922
|
+
// Convert an instruction to have all fields defined
|
|
1923
|
+
(instruction) => {
|
|
1924
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1925
|
+
return instruction;
|
|
1926
|
+
}
|
|
1927
|
+
return {
|
|
1928
|
+
...instruction,
|
|
1929
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
1930
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
);
|
|
1934
|
+
}
|
|
1935
|
+
return memoizedGetInstructionEncoder;
|
|
1534
1936
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1937
|
+
var memoizedGetInstructionDecoder;
|
|
1938
|
+
function getInstructionDecoder() {
|
|
1939
|
+
if (!memoizedGetInstructionDecoder) {
|
|
1940
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
1941
|
+
getStructDecoder([
|
|
1942
|
+
["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
|
|
1943
|
+
[
|
|
1944
|
+
"accountIndices",
|
|
1945
|
+
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
1946
|
+
description: accountIndicesDescription,
|
|
1947
|
+
size: getShortU16Decoder()
|
|
1948
|
+
})
|
|
1949
|
+
],
|
|
1950
|
+
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
1951
|
+
]),
|
|
1952
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
1953
|
+
(instruction) => {
|
|
1954
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
1955
|
+
return instruction;
|
|
1956
|
+
}
|
|
1957
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
1958
|
+
return {
|
|
1959
|
+
...rest,
|
|
1960
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1961
|
+
...data.byteLength ? { data } : null
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
return memoizedGetInstructionDecoder;
|
|
1539
1967
|
}
|
|
1540
1968
|
var VERSION_FLAG_MASK = 128;
|
|
1541
1969
|
var BASE_CONFIG = {
|
|
@@ -1543,8 +1971,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1543
1971
|
fixedSize: null,
|
|
1544
1972
|
maxSize: 1
|
|
1545
1973
|
};
|
|
1546
|
-
function
|
|
1547
|
-
const firstByte =
|
|
1974
|
+
function decode(bytes, offset = 0) {
|
|
1975
|
+
const firstByte = bytes[offset];
|
|
1548
1976
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1549
1977
|
return ["legacy", offset];
|
|
1550
1978
|
} else {
|
|
@@ -1552,7 +1980,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1552
1980
|
return [version, offset + 1];
|
|
1553
1981
|
}
|
|
1554
1982
|
}
|
|
1555
|
-
function
|
|
1983
|
+
function encode(value) {
|
|
1556
1984
|
if (value === "legacy") {
|
|
1557
1985
|
return new Uint8Array();
|
|
1558
1986
|
}
|
|
@@ -1561,95 +1989,255 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1561
1989
|
}
|
|
1562
1990
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1563
1991
|
}
|
|
1564
|
-
function
|
|
1992
|
+
function getTransactionVersionDecoder() {
|
|
1565
1993
|
return {
|
|
1566
1994
|
...BASE_CONFIG,
|
|
1567
|
-
|
|
1568
|
-
serialize
|
|
1995
|
+
decode
|
|
1569
1996
|
};
|
|
1570
1997
|
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1998
|
+
function getTransactionVersionEncoder() {
|
|
1999
|
+
return {
|
|
2000
|
+
...BASE_CONFIG,
|
|
2001
|
+
encode
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
|
|
2005
|
+
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
|
|
2006
|
+
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
|
|
2007
|
+
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
|
|
2008
|
+
function getCompiledMessageLegacyEncoder() {
|
|
2009
|
+
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
2010
|
+
}
|
|
2011
|
+
function getCompiledMessageVersionedEncoder() {
|
|
2012
|
+
return mapEncoder(
|
|
2013
|
+
getStructEncoder([
|
|
2014
|
+
...getPreludeStructEncoderTuple(),
|
|
2015
|
+
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
2016
|
+
]),
|
|
2017
|
+
(value) => {
|
|
2018
|
+
if (value.version === "legacy") {
|
|
2019
|
+
return value;
|
|
1593
2020
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
2021
|
+
return {
|
|
2022
|
+
...value,
|
|
2023
|
+
addressTableLookups: value.addressTableLookups ?? []
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
);
|
|
1596
2027
|
}
|
|
1597
|
-
function
|
|
2028
|
+
function getPreludeStructEncoderTuple() {
|
|
1598
2029
|
return [
|
|
1599
|
-
["version",
|
|
1600
|
-
["header",
|
|
2030
|
+
["version", getTransactionVersionEncoder()],
|
|
2031
|
+
["header", getMessageHeaderEncoder()],
|
|
1601
2032
|
[
|
|
1602
2033
|
"staticAccounts",
|
|
1603
|
-
|
|
1604
|
-
description:
|
|
1605
|
-
size:
|
|
2034
|
+
getArrayEncoder(getAddressEncoder(), {
|
|
2035
|
+
description: staticAccountsDescription,
|
|
2036
|
+
size: getShortU16Encoder()
|
|
1606
2037
|
})
|
|
1607
2038
|
],
|
|
1608
2039
|
[
|
|
1609
2040
|
"lifetimeToken",
|
|
1610
|
-
|
|
1611
|
-
description:
|
|
1612
|
-
encoding:
|
|
2041
|
+
getStringEncoder({
|
|
2042
|
+
description: lifetimeTokenDescription,
|
|
2043
|
+
encoding: getBase58Encoder(),
|
|
1613
2044
|
size: 32
|
|
1614
2045
|
})
|
|
1615
2046
|
],
|
|
1616
2047
|
[
|
|
1617
2048
|
"instructions",
|
|
1618
|
-
|
|
1619
|
-
description:
|
|
1620
|
-
size:
|
|
2049
|
+
getArrayEncoder(getInstructionEncoder(), {
|
|
2050
|
+
description: instructionsDescription,
|
|
2051
|
+
size: getShortU16Encoder()
|
|
1621
2052
|
})
|
|
1622
2053
|
]
|
|
1623
2054
|
];
|
|
1624
2055
|
}
|
|
1625
|
-
function
|
|
1626
|
-
return
|
|
1627
|
-
|
|
1628
|
-
|
|
2056
|
+
function getPreludeStructDecoderTuple() {
|
|
2057
|
+
return [
|
|
2058
|
+
["version", getTransactionVersionDecoder()],
|
|
2059
|
+
["header", getMessageHeaderDecoder()],
|
|
2060
|
+
[
|
|
2061
|
+
"staticAccounts",
|
|
2062
|
+
getArrayDecoder(getAddressDecoder(), {
|
|
2063
|
+
description: staticAccountsDescription,
|
|
2064
|
+
size: getShortU16Decoder()
|
|
2065
|
+
})
|
|
2066
|
+
],
|
|
2067
|
+
[
|
|
2068
|
+
"lifetimeToken",
|
|
2069
|
+
getStringDecoder({
|
|
2070
|
+
description: lifetimeTokenDescription,
|
|
2071
|
+
encoding: getBase58Decoder(),
|
|
2072
|
+
size: 32
|
|
2073
|
+
})
|
|
2074
|
+
],
|
|
2075
|
+
[
|
|
2076
|
+
"instructions",
|
|
2077
|
+
getArrayDecoder(getInstructionDecoder(), {
|
|
2078
|
+
description: instructionsDescription,
|
|
2079
|
+
size: getShortU16Decoder()
|
|
2080
|
+
})
|
|
2081
|
+
],
|
|
2082
|
+
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
2083
|
+
];
|
|
2084
|
+
}
|
|
2085
|
+
function getAddressTableLookupArrayEncoder() {
|
|
2086
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
2087
|
+
description: addressTableLookupsDescription,
|
|
2088
|
+
size: getShortU16Encoder()
|
|
1629
2089
|
});
|
|
1630
2090
|
}
|
|
2091
|
+
function getAddressTableLookupArrayDecoder() {
|
|
2092
|
+
return getArrayDecoder(getAddressTableLookupDecoder(), {
|
|
2093
|
+
description: addressTableLookupsDescription,
|
|
2094
|
+
size: getShortU16Decoder()
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1631
2098
|
function getCompiledMessageEncoder() {
|
|
1632
2099
|
return {
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
2100
|
+
description: messageDescription,
|
|
2101
|
+
encode: (compiledMessage) => {
|
|
2102
|
+
if (compiledMessage.version === "legacy") {
|
|
2103
|
+
return getCompiledMessageLegacyEncoder().encode(compiledMessage);
|
|
2104
|
+
} else {
|
|
2105
|
+
return getCompiledMessageVersionedEncoder().encode(compiledMessage);
|
|
2106
|
+
}
|
|
2107
|
+
},
|
|
2108
|
+
fixedSize: null,
|
|
2109
|
+
maxSize: null
|
|
1636
2110
|
};
|
|
1637
2111
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
2112
|
+
function getCompiledMessageDecoder() {
|
|
2113
|
+
return mapDecoder(
|
|
2114
|
+
getStructDecoder(getPreludeStructDecoderTuple(), {
|
|
2115
|
+
description: messageDescription
|
|
2116
|
+
}),
|
|
2117
|
+
({ addressTableLookups, ...restOfMessage }) => {
|
|
2118
|
+
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
2119
|
+
return restOfMessage;
|
|
2120
|
+
}
|
|
2121
|
+
return { ...restOfMessage, addressTableLookups };
|
|
2122
|
+
}
|
|
2123
|
+
);
|
|
2124
|
+
}
|
|
2125
|
+
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
2126
|
+
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
2127
|
+
function getCompiledTransactionEncoder() {
|
|
2128
|
+
return getStructEncoder(
|
|
2129
|
+
[
|
|
2130
|
+
[
|
|
2131
|
+
"signatures",
|
|
2132
|
+
getArrayEncoder(getBytesEncoder({ size: 64 }), {
|
|
2133
|
+
description: signaturesDescription,
|
|
2134
|
+
size: getShortU16Encoder()
|
|
2135
|
+
})
|
|
2136
|
+
],
|
|
2137
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
2138
|
+
],
|
|
2139
|
+
{
|
|
2140
|
+
description: transactionDescription
|
|
2141
|
+
}
|
|
2142
|
+
);
|
|
2143
|
+
}
|
|
2144
|
+
function getSignatureDecoder() {
|
|
2145
|
+
return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
|
|
2146
|
+
}
|
|
2147
|
+
function getCompiledTransactionDecoder() {
|
|
2148
|
+
return getStructDecoder(
|
|
2149
|
+
[
|
|
2150
|
+
[
|
|
2151
|
+
"signatures",
|
|
2152
|
+
getArrayDecoder(getSignatureDecoder(), {
|
|
2153
|
+
description: signaturesDescription,
|
|
2154
|
+
size: getShortU16Decoder()
|
|
2155
|
+
})
|
|
2156
|
+
],
|
|
2157
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
2158
|
+
],
|
|
2159
|
+
{
|
|
2160
|
+
description: transactionDescription
|
|
2161
|
+
}
|
|
2162
|
+
);
|
|
2163
|
+
}
|
|
2164
|
+
function getTransactionEncoder() {
|
|
2165
|
+
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
2166
|
+
}
|
|
2167
|
+
function getTransactionDecoder(lastValidBlockHeight) {
|
|
2168
|
+
return mapDecoder(
|
|
2169
|
+
getCompiledTransactionDecoder(),
|
|
2170
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
|
|
2171
|
+
);
|
|
2172
|
+
}
|
|
2173
|
+
function getTransactionCodec(lastValidBlockHeight) {
|
|
2174
|
+
return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
2175
|
+
}
|
|
2176
|
+
var base58Encoder2;
|
|
2177
|
+
var base58Decoder;
|
|
2178
|
+
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
2179
|
+
if (!base58Encoder2)
|
|
2180
|
+
base58Encoder2 = getBase58Encoder();
|
|
2181
|
+
try {
|
|
2182
|
+
if (
|
|
2183
|
+
// Lowest value (64 bytes of zeroes)
|
|
2184
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
2185
|
+
putativeTransactionSignature.length > 88
|
|
2186
|
+
) {
|
|
2187
|
+
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
2188
|
+
}
|
|
2189
|
+
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
2190
|
+
const numBytes = bytes.byteLength;
|
|
2191
|
+
if (numBytes !== 64) {
|
|
2192
|
+
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
2193
|
+
}
|
|
2194
|
+
} catch (e3) {
|
|
2195
|
+
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
2196
|
+
cause: e3
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
function isTransactionSignature(putativeTransactionSignature) {
|
|
2201
|
+
if (!base58Encoder2)
|
|
2202
|
+
base58Encoder2 = getBase58Encoder();
|
|
2203
|
+
if (
|
|
2204
|
+
// Lowest value (64 bytes of zeroes)
|
|
2205
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
2206
|
+
putativeTransactionSignature.length > 88
|
|
2207
|
+
) {
|
|
2208
|
+
return false;
|
|
2209
|
+
}
|
|
2210
|
+
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
2211
|
+
const numBytes = bytes.byteLength;
|
|
2212
|
+
if (numBytes !== 64) {
|
|
2213
|
+
return false;
|
|
2214
|
+
}
|
|
2215
|
+
return true;
|
|
2216
|
+
}
|
|
2217
|
+
function getSignatureFromTransaction(transaction) {
|
|
2218
|
+
if (!base58Decoder)
|
|
2219
|
+
base58Decoder = getBase58Decoder();
|
|
2220
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
2221
|
+
if (!signatureBytes) {
|
|
2222
|
+
throw new Error(
|
|
2223
|
+
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
const transactionSignature2 = base58Decoder.decode(signatureBytes)[0];
|
|
2227
|
+
return transactionSignature2;
|
|
1642
2228
|
}
|
|
1643
|
-
async function signTransaction(
|
|
2229
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1644
2230
|
const compiledMessage = compileMessage(transaction);
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
2231
|
+
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
2232
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
2233
|
+
const publicKeySignaturePairs = await Promise.all(
|
|
2234
|
+
keyPairs.map(
|
|
2235
|
+
(keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
|
|
2236
|
+
)
|
|
2237
|
+
);
|
|
2238
|
+
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
2239
|
+
nextSignatures[signerPublicKey] = signature;
|
|
2240
|
+
}
|
|
1653
2241
|
const out = {
|
|
1654
2242
|
...transaction,
|
|
1655
2243
|
signatures: nextSignatures
|
|
@@ -1657,52 +2245,190 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1657
2245
|
Object.freeze(out);
|
|
1658
2246
|
return out;
|
|
1659
2247
|
}
|
|
1660
|
-
function
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
2248
|
+
function transactionSignature(putativeTransactionSignature) {
|
|
2249
|
+
assertIsTransactionSignature(putativeTransactionSignature);
|
|
2250
|
+
return putativeTransactionSignature;
|
|
2251
|
+
}
|
|
2252
|
+
function assertTransactionIsFullySigned(transaction) {
|
|
2253
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole2(a.role)) ?? []).map((a) => a.address);
|
|
2254
|
+
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
2255
|
+
requiredSigners.forEach((address2) => {
|
|
2256
|
+
if (!transaction.signatures[address2]) {
|
|
2257
|
+
throw new Error(`Transaction is missing signature for address \`${address2}\``);
|
|
1667
2258
|
}
|
|
1668
|
-
}
|
|
1669
|
-
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
function getBase64EncodedWireTransaction(transaction) {
|
|
2262
|
+
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
2263
|
+
{
|
|
2264
|
+
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1670
2265
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
// src/airdrop.ts
|
|
2269
|
+
init_env_shim();
|
|
2270
|
+
|
|
2271
|
+
// src/airdrop-confirmer.ts
|
|
2272
|
+
init_env_shim();
|
|
2273
|
+
|
|
2274
|
+
// src/transaction-confirmation-strategy-racer.ts
|
|
2275
|
+
init_env_shim();
|
|
2276
|
+
async function raceStrategies(signature, config, getSpecificStrategiesForRace) {
|
|
2277
|
+
const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
|
|
2278
|
+
callerAbortSignal?.throwIfAborted();
|
|
2279
|
+
const abortController = new AbortController();
|
|
2280
|
+
if (callerAbortSignal) {
|
|
2281
|
+
const handleAbort = () => {
|
|
2282
|
+
abortController.abort();
|
|
2283
|
+
};
|
|
2284
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
2285
|
+
}
|
|
2286
|
+
try {
|
|
2287
|
+
const specificStrategies = getSpecificStrategiesForRace({
|
|
2288
|
+
...config,
|
|
2289
|
+
abortSignal: abortController.signal
|
|
2290
|
+
});
|
|
2291
|
+
return await Promise.race([
|
|
2292
|
+
getRecentSignatureConfirmationPromise({
|
|
2293
|
+
abortSignal: abortController.signal,
|
|
2294
|
+
commitment,
|
|
2295
|
+
signature
|
|
2296
|
+
}),
|
|
2297
|
+
...specificStrategies
|
|
2298
|
+
]);
|
|
2299
|
+
} finally {
|
|
2300
|
+
abortController.abort();
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
// src/transaction-confirmation-strategy-recent-signature.ts
|
|
2305
|
+
init_env_shim();
|
|
2306
|
+
function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
|
|
2307
|
+
return async function getRecentSignatureConfirmationPromise({
|
|
2308
|
+
abortSignal: callerAbortSignal,
|
|
2309
|
+
commitment,
|
|
2310
|
+
signature
|
|
2311
|
+
}) {
|
|
2312
|
+
const abortController = new AbortController();
|
|
2313
|
+
function handleAbort() {
|
|
2314
|
+
abortController.abort();
|
|
2315
|
+
}
|
|
2316
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
2317
|
+
const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
|
|
2318
|
+
const signatureDidCommitPromise = (async () => {
|
|
2319
|
+
for await (const signatureStatusNotification of signatureStatusNotifications) {
|
|
2320
|
+
if (signatureStatusNotification.value.err) {
|
|
2321
|
+
throw new Error(`The transaction with signature \`${signature}\` failed.`, {
|
|
2322
|
+
cause: signatureStatusNotification.value.err
|
|
2323
|
+
});
|
|
2324
|
+
} else {
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
})();
|
|
2329
|
+
const signatureStatusLookupPromise = (async () => {
|
|
2330
|
+
const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
|
|
2331
|
+
const signatureStatus = signatureStatusResults[0];
|
|
2332
|
+
if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
|
|
2333
|
+
return;
|
|
2334
|
+
} else {
|
|
2335
|
+
await new Promise(() => {
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
})();
|
|
2339
|
+
try {
|
|
2340
|
+
return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
|
|
2341
|
+
} finally {
|
|
2342
|
+
abortController.abort();
|
|
2343
|
+
}
|
|
1674
2344
|
};
|
|
1675
2345
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
2346
|
+
|
|
2347
|
+
// src/transaction-confirmation-strategy-timeout.ts
|
|
2348
|
+
init_env_shim();
|
|
2349
|
+
async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
|
|
2350
|
+
return await new Promise((_, reject) => {
|
|
2351
|
+
const handleAbort = (e3) => {
|
|
2352
|
+
clearTimeout(timeoutId);
|
|
2353
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
2354
|
+
reject(abortError);
|
|
2355
|
+
};
|
|
2356
|
+
callerAbortSignal.addEventListener("abort", handleAbort);
|
|
2357
|
+
const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
|
|
2358
|
+
const startMs = performance.now();
|
|
2359
|
+
const timeoutId = (
|
|
2360
|
+
// We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
|
|
2361
|
+
// elapsed time instead of active time.
|
|
2362
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
|
|
2363
|
+
setTimeout(() => {
|
|
2364
|
+
const elapsedMs = performance.now() - startMs;
|
|
2365
|
+
reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
|
|
2366
|
+
}, timeoutMs)
|
|
2367
|
+
);
|
|
2368
|
+
});
|
|
1693
2369
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
2370
|
+
|
|
2371
|
+
// src/airdrop-confirmer.ts
|
|
2372
|
+
function createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
2373
|
+
rpc,
|
|
2374
|
+
rpcSubscriptions
|
|
2375
|
+
}) {
|
|
2376
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
2377
|
+
rpc,
|
|
2378
|
+
rpcSubscriptions
|
|
2379
|
+
);
|
|
2380
|
+
return async function confirmSignatureOnlyRecentTransaction(config) {
|
|
2381
|
+
await waitForRecentTransactionConfirmationUntilTimeout({
|
|
2382
|
+
...config,
|
|
2383
|
+
getRecentSignatureConfirmationPromise,
|
|
2384
|
+
getTimeoutPromise
|
|
2385
|
+
});
|
|
1699
2386
|
};
|
|
1700
2387
|
}
|
|
1701
|
-
function
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
2388
|
+
async function waitForRecentTransactionConfirmationUntilTimeout(config) {
|
|
2389
|
+
await raceStrategies(
|
|
2390
|
+
config.signature,
|
|
2391
|
+
config,
|
|
2392
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
|
|
2393
|
+
return [
|
|
2394
|
+
getTimeoutPromise2({
|
|
2395
|
+
abortSignal,
|
|
2396
|
+
commitment
|
|
2397
|
+
})
|
|
2398
|
+
];
|
|
2399
|
+
}
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
// src/airdrop.ts
|
|
2404
|
+
function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
|
|
2405
|
+
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
|
|
2406
|
+
rpc,
|
|
2407
|
+
rpcSubscriptions
|
|
2408
|
+
});
|
|
2409
|
+
return async function requestAirdrop(config) {
|
|
2410
|
+
return await requestAndConfirmAirdrop({
|
|
2411
|
+
...config,
|
|
2412
|
+
confirmSignatureOnlyTransaction,
|
|
2413
|
+
rpc
|
|
2414
|
+
});
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
async function requestAndConfirmAirdrop({
|
|
2418
|
+
abortSignal,
|
|
2419
|
+
commitment,
|
|
2420
|
+
confirmSignatureOnlyTransaction,
|
|
2421
|
+
lamports: lamports2,
|
|
2422
|
+
recipientAddress,
|
|
2423
|
+
rpc
|
|
2424
|
+
}) {
|
|
2425
|
+
const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports2, { commitment }).send({ abortSignal });
|
|
2426
|
+
await confirmSignatureOnlyTransaction({
|
|
2427
|
+
abortSignal,
|
|
2428
|
+
commitment,
|
|
2429
|
+
signature: airdropTransactionSignature
|
|
2430
|
+
});
|
|
2431
|
+
return airdropTransactionSignature;
|
|
1706
2432
|
}
|
|
1707
2433
|
|
|
1708
2434
|
// src/rpc.ts
|
|
@@ -1736,85 +2462,393 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1736
2462
|
return visitNode(params, [], onIntegerOverflow);
|
|
1737
2463
|
}
|
|
1738
2464
|
var KEYPATH_WILDCARD = {};
|
|
1739
|
-
var
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
2465
|
+
var jsonParsedTokenAccountsConfigs = [
|
|
2466
|
+
// parsed Token/Token22 token account
|
|
2467
|
+
["data", "parsed", "info", "tokenAmount", "decimals"],
|
|
2468
|
+
["data", "parsed", "info", "tokenAmount", "uiAmount"],
|
|
2469
|
+
["data", "parsed", "info", "rentExemptReserve", "decimals"],
|
|
2470
|
+
["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
|
|
2471
|
+
["data", "parsed", "info", "delegatedAmount", "decimals"],
|
|
2472
|
+
["data", "parsed", "info", "delegatedAmount", "uiAmount"],
|
|
2473
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
|
|
2474
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
|
|
2475
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
|
|
2476
|
+
["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
|
|
2477
|
+
];
|
|
2478
|
+
var jsonParsedAccountsConfigs = [
|
|
2479
|
+
...jsonParsedTokenAccountsConfigs,
|
|
2480
|
+
// parsed AddressTableLookup account
|
|
2481
|
+
["data", "parsed", "info", "lastExtendedSlotStartIndex"],
|
|
2482
|
+
// parsed Config account
|
|
2483
|
+
["data", "parsed", "info", "slashPenalty"],
|
|
2484
|
+
["data", "parsed", "info", "warmupCooldownRate"],
|
|
2485
|
+
// parsed Token/Token22 mint account
|
|
2486
|
+
["data", "parsed", "info", "decimals"],
|
|
2487
|
+
// parsed Token/Token22 multisig account
|
|
2488
|
+
["data", "parsed", "info", "numRequiredSigners"],
|
|
2489
|
+
["data", "parsed", "info", "numValidSigners"],
|
|
2490
|
+
// parsed Stake account
|
|
2491
|
+
["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
|
|
2492
|
+
// parsed Sysvar rent account
|
|
2493
|
+
["data", "parsed", "info", "exemptionThreshold"],
|
|
2494
|
+
["data", "parsed", "info", "burnPercent"],
|
|
2495
|
+
// parsed Vote account
|
|
2496
|
+
["data", "parsed", "info", "commission"],
|
|
2497
|
+
["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
|
|
2498
|
+
];
|
|
2499
|
+
var memoizedNotificationKeypaths;
|
|
2500
|
+
var memoizedResponseKeypaths;
|
|
2501
|
+
function getAllowedNumericKeypathsForNotification() {
|
|
2502
|
+
if (!memoizedNotificationKeypaths) {
|
|
2503
|
+
memoizedNotificationKeypaths = {
|
|
2504
|
+
accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
2505
|
+
blockNotifications: [
|
|
2506
|
+
["value", "block", "blockTime"],
|
|
2507
|
+
[
|
|
2508
|
+
"value",
|
|
2509
|
+
"block",
|
|
2510
|
+
"transactions",
|
|
2511
|
+
KEYPATH_WILDCARD,
|
|
2512
|
+
"meta",
|
|
2513
|
+
"preTokenBalances",
|
|
2514
|
+
KEYPATH_WILDCARD,
|
|
2515
|
+
"accountIndex"
|
|
2516
|
+
],
|
|
2517
|
+
[
|
|
2518
|
+
"value",
|
|
2519
|
+
"block",
|
|
2520
|
+
"transactions",
|
|
2521
|
+
KEYPATH_WILDCARD,
|
|
2522
|
+
"meta",
|
|
2523
|
+
"preTokenBalances",
|
|
2524
|
+
KEYPATH_WILDCARD,
|
|
2525
|
+
"uiTokenAmount",
|
|
2526
|
+
"decimals"
|
|
2527
|
+
],
|
|
2528
|
+
[
|
|
2529
|
+
"value",
|
|
2530
|
+
"block",
|
|
2531
|
+
"transactions",
|
|
2532
|
+
KEYPATH_WILDCARD,
|
|
2533
|
+
"meta",
|
|
2534
|
+
"postTokenBalances",
|
|
2535
|
+
KEYPATH_WILDCARD,
|
|
2536
|
+
"accountIndex"
|
|
2537
|
+
],
|
|
2538
|
+
[
|
|
2539
|
+
"value",
|
|
2540
|
+
"block",
|
|
2541
|
+
"transactions",
|
|
2542
|
+
KEYPATH_WILDCARD,
|
|
2543
|
+
"meta",
|
|
2544
|
+
"postTokenBalances",
|
|
2545
|
+
KEYPATH_WILDCARD,
|
|
2546
|
+
"uiTokenAmount",
|
|
2547
|
+
"decimals"
|
|
2548
|
+
],
|
|
2549
|
+
["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
2550
|
+
[
|
|
2551
|
+
"value",
|
|
2552
|
+
"block",
|
|
2553
|
+
"transactions",
|
|
2554
|
+
KEYPATH_WILDCARD,
|
|
2555
|
+
"meta",
|
|
2556
|
+
"innerInstructions",
|
|
2557
|
+
KEYPATH_WILDCARD,
|
|
2558
|
+
"index"
|
|
2559
|
+
],
|
|
2560
|
+
[
|
|
2561
|
+
"value",
|
|
2562
|
+
"block",
|
|
2563
|
+
"transactions",
|
|
2564
|
+
KEYPATH_WILDCARD,
|
|
2565
|
+
"meta",
|
|
2566
|
+
"innerInstructions",
|
|
2567
|
+
KEYPATH_WILDCARD,
|
|
2568
|
+
"instructions",
|
|
2569
|
+
KEYPATH_WILDCARD,
|
|
2570
|
+
"programIdIndex"
|
|
2571
|
+
],
|
|
2572
|
+
[
|
|
2573
|
+
"value",
|
|
2574
|
+
"block",
|
|
2575
|
+
"transactions",
|
|
2576
|
+
KEYPATH_WILDCARD,
|
|
2577
|
+
"meta",
|
|
2578
|
+
"innerInstructions",
|
|
2579
|
+
KEYPATH_WILDCARD,
|
|
2580
|
+
"instructions",
|
|
2581
|
+
KEYPATH_WILDCARD,
|
|
2582
|
+
"accounts",
|
|
2583
|
+
KEYPATH_WILDCARD
|
|
2584
|
+
],
|
|
2585
|
+
[
|
|
2586
|
+
"value",
|
|
2587
|
+
"block",
|
|
2588
|
+
"transactions",
|
|
2589
|
+
KEYPATH_WILDCARD,
|
|
2590
|
+
"transaction",
|
|
2591
|
+
"message",
|
|
2592
|
+
"addressTableLookups",
|
|
2593
|
+
KEYPATH_WILDCARD,
|
|
2594
|
+
"writableIndexes",
|
|
2595
|
+
KEYPATH_WILDCARD
|
|
2596
|
+
],
|
|
2597
|
+
[
|
|
2598
|
+
"value",
|
|
2599
|
+
"block",
|
|
2600
|
+
"transactions",
|
|
2601
|
+
KEYPATH_WILDCARD,
|
|
2602
|
+
"transaction",
|
|
2603
|
+
"message",
|
|
2604
|
+
"addressTableLookups",
|
|
2605
|
+
KEYPATH_WILDCARD,
|
|
2606
|
+
"readonlyIndexes",
|
|
2607
|
+
KEYPATH_WILDCARD
|
|
2608
|
+
],
|
|
2609
|
+
[
|
|
2610
|
+
"value",
|
|
2611
|
+
"block",
|
|
2612
|
+
"transactions",
|
|
2613
|
+
KEYPATH_WILDCARD,
|
|
2614
|
+
"transaction",
|
|
2615
|
+
"message",
|
|
2616
|
+
"instructions",
|
|
2617
|
+
KEYPATH_WILDCARD,
|
|
2618
|
+
"programIdIndex"
|
|
2619
|
+
],
|
|
2620
|
+
[
|
|
2621
|
+
"value",
|
|
2622
|
+
"block",
|
|
2623
|
+
"transactions",
|
|
2624
|
+
KEYPATH_WILDCARD,
|
|
2625
|
+
"transaction",
|
|
2626
|
+
"message",
|
|
2627
|
+
"instructions",
|
|
2628
|
+
KEYPATH_WILDCARD,
|
|
2629
|
+
"accounts",
|
|
2630
|
+
KEYPATH_WILDCARD
|
|
2631
|
+
],
|
|
2632
|
+
[
|
|
2633
|
+
"value",
|
|
2634
|
+
"block",
|
|
2635
|
+
"transactions",
|
|
2636
|
+
KEYPATH_WILDCARD,
|
|
2637
|
+
"transaction",
|
|
2638
|
+
"message",
|
|
2639
|
+
"header",
|
|
2640
|
+
"numReadonlySignedAccounts"
|
|
2641
|
+
],
|
|
2642
|
+
[
|
|
2643
|
+
"value",
|
|
2644
|
+
"block",
|
|
2645
|
+
"transactions",
|
|
2646
|
+
KEYPATH_WILDCARD,
|
|
2647
|
+
"transaction",
|
|
2648
|
+
"message",
|
|
2649
|
+
"header",
|
|
2650
|
+
"numReadonlyUnsignedAccounts"
|
|
2651
|
+
],
|
|
2652
|
+
[
|
|
2653
|
+
"value",
|
|
2654
|
+
"block",
|
|
2655
|
+
"transactions",
|
|
2656
|
+
KEYPATH_WILDCARD,
|
|
2657
|
+
"transaction",
|
|
2658
|
+
"message",
|
|
2659
|
+
"header",
|
|
2660
|
+
"numRequiredSignatures"
|
|
2661
|
+
],
|
|
2662
|
+
["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
|
|
2663
|
+
],
|
|
2664
|
+
programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
2665
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
2666
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
2667
|
+
])
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
return memoizedNotificationKeypaths;
|
|
2671
|
+
}
|
|
2672
|
+
function getAllowedNumericKeypathsForResponse() {
|
|
2673
|
+
if (!memoizedResponseKeypaths) {
|
|
2674
|
+
memoizedResponseKeypaths = {
|
|
2675
|
+
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
2676
|
+
getBlock: [
|
|
2677
|
+
["blockTime"],
|
|
2678
|
+
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
2679
|
+
[
|
|
2680
|
+
"transactions",
|
|
2681
|
+
KEYPATH_WILDCARD,
|
|
2682
|
+
"meta",
|
|
2683
|
+
"preTokenBalances",
|
|
2684
|
+
KEYPATH_WILDCARD,
|
|
2685
|
+
"uiTokenAmount",
|
|
2686
|
+
"decimals"
|
|
2687
|
+
],
|
|
2688
|
+
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
2689
|
+
[
|
|
2690
|
+
"transactions",
|
|
2691
|
+
KEYPATH_WILDCARD,
|
|
2692
|
+
"meta",
|
|
2693
|
+
"postTokenBalances",
|
|
2694
|
+
KEYPATH_WILDCARD,
|
|
2695
|
+
"uiTokenAmount",
|
|
2696
|
+
"decimals"
|
|
2697
|
+
],
|
|
2698
|
+
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
2699
|
+
["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
2700
|
+
[
|
|
2701
|
+
"transactions",
|
|
2702
|
+
KEYPATH_WILDCARD,
|
|
2703
|
+
"meta",
|
|
2704
|
+
"innerInstructions",
|
|
2705
|
+
KEYPATH_WILDCARD,
|
|
2706
|
+
"instructions",
|
|
2707
|
+
KEYPATH_WILDCARD,
|
|
2708
|
+
"programIdIndex"
|
|
2709
|
+
],
|
|
2710
|
+
[
|
|
2711
|
+
"transactions",
|
|
2712
|
+
KEYPATH_WILDCARD,
|
|
2713
|
+
"meta",
|
|
2714
|
+
"innerInstructions",
|
|
2715
|
+
KEYPATH_WILDCARD,
|
|
2716
|
+
"instructions",
|
|
2717
|
+
KEYPATH_WILDCARD,
|
|
2718
|
+
"accounts",
|
|
2719
|
+
KEYPATH_WILDCARD
|
|
2720
|
+
],
|
|
2721
|
+
[
|
|
2722
|
+
"transactions",
|
|
2723
|
+
KEYPATH_WILDCARD,
|
|
2724
|
+
"transaction",
|
|
2725
|
+
"message",
|
|
2726
|
+
"addressTableLookups",
|
|
2727
|
+
KEYPATH_WILDCARD,
|
|
2728
|
+
"writableIndexes",
|
|
2729
|
+
KEYPATH_WILDCARD
|
|
2730
|
+
],
|
|
2731
|
+
[
|
|
2732
|
+
"transactions",
|
|
2733
|
+
KEYPATH_WILDCARD,
|
|
2734
|
+
"transaction",
|
|
2735
|
+
"message",
|
|
2736
|
+
"addressTableLookups",
|
|
2737
|
+
KEYPATH_WILDCARD,
|
|
2738
|
+
"readonlyIndexes",
|
|
2739
|
+
KEYPATH_WILDCARD
|
|
2740
|
+
],
|
|
2741
|
+
[
|
|
2742
|
+
"transactions",
|
|
2743
|
+
KEYPATH_WILDCARD,
|
|
2744
|
+
"transaction",
|
|
2745
|
+
"message",
|
|
2746
|
+
"instructions",
|
|
2747
|
+
KEYPATH_WILDCARD,
|
|
2748
|
+
"programIdIndex"
|
|
2749
|
+
],
|
|
2750
|
+
[
|
|
2751
|
+
"transactions",
|
|
2752
|
+
KEYPATH_WILDCARD,
|
|
2753
|
+
"transaction",
|
|
2754
|
+
"message",
|
|
2755
|
+
"instructions",
|
|
2756
|
+
KEYPATH_WILDCARD,
|
|
2757
|
+
"accounts",
|
|
2758
|
+
KEYPATH_WILDCARD
|
|
2759
|
+
],
|
|
2760
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
2761
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
2762
|
+
["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
|
|
2763
|
+
["rewards", KEYPATH_WILDCARD, "commission"]
|
|
2764
|
+
],
|
|
2765
|
+
getBlockTime: [[]],
|
|
2766
|
+
getClusterNodes: [
|
|
2767
|
+
[KEYPATH_WILDCARD, "featureSet"],
|
|
2768
|
+
[KEYPATH_WILDCARD, "shredVersion"]
|
|
2769
|
+
],
|
|
2770
|
+
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
|
|
2771
|
+
getInflationRate: [["foundation"], ["total"], ["validator"]],
|
|
2772
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
2773
|
+
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
|
|
2774
|
+
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
2775
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
2776
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
2777
|
+
]),
|
|
2778
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
2779
|
+
getTokenAccountBalance: [
|
|
2780
|
+
["value", "decimals"],
|
|
2781
|
+
["value", "uiAmount"]
|
|
2782
|
+
],
|
|
2783
|
+
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
2784
|
+
"value",
|
|
2785
|
+
KEYPATH_WILDCARD,
|
|
2786
|
+
"account",
|
|
2787
|
+
...c
|
|
2788
|
+
]),
|
|
2789
|
+
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
2790
|
+
"value",
|
|
2791
|
+
KEYPATH_WILDCARD,
|
|
2792
|
+
"account",
|
|
2793
|
+
...c
|
|
2794
|
+
]),
|
|
2795
|
+
getTokenLargestAccounts: [
|
|
2796
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
2797
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
2798
|
+
],
|
|
2799
|
+
getTokenSupply: [
|
|
2800
|
+
["value", "decimals"],
|
|
2801
|
+
["value", "uiAmount"]
|
|
2802
|
+
],
|
|
2803
|
+
getTransaction: [
|
|
2804
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
2805
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
2806
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
2807
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
2808
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
2809
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
|
|
2810
|
+
["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
2811
|
+
[
|
|
2812
|
+
"meta",
|
|
2813
|
+
"innerInstructions",
|
|
2814
|
+
KEYPATH_WILDCARD,
|
|
2815
|
+
"instructions",
|
|
2816
|
+
KEYPATH_WILDCARD,
|
|
2817
|
+
"accounts",
|
|
2818
|
+
KEYPATH_WILDCARD
|
|
2819
|
+
],
|
|
2820
|
+
[
|
|
2821
|
+
"transaction",
|
|
2822
|
+
"message",
|
|
2823
|
+
"addressTableLookups",
|
|
2824
|
+
KEYPATH_WILDCARD,
|
|
2825
|
+
"writableIndexes",
|
|
2826
|
+
KEYPATH_WILDCARD
|
|
2827
|
+
],
|
|
2828
|
+
[
|
|
2829
|
+
"transaction",
|
|
2830
|
+
"message",
|
|
2831
|
+
"addressTableLookups",
|
|
2832
|
+
KEYPATH_WILDCARD,
|
|
2833
|
+
"readonlyIndexes",
|
|
2834
|
+
KEYPATH_WILDCARD
|
|
2835
|
+
],
|
|
2836
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
|
|
2837
|
+
["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
|
|
2838
|
+
["transaction", "message", "header", "numReadonlySignedAccounts"],
|
|
2839
|
+
["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
|
|
2840
|
+
["transaction", "message", "header", "numRequiredSignatures"]
|
|
2841
|
+
],
|
|
2842
|
+
getVersion: [["feature-set"]],
|
|
2843
|
+
getVoteAccounts: [
|
|
2844
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
2845
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
2846
|
+
],
|
|
2847
|
+
simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
|
|
2848
|
+
};
|
|
2849
|
+
}
|
|
2850
|
+
return memoizedResponseKeypaths;
|
|
2851
|
+
}
|
|
1818
2852
|
function getNextAllowedKeypaths(keyPaths, property) {
|
|
1819
2853
|
return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
|
|
1820
2854
|
}
|
|
@@ -1841,7 +2875,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1841
2875
|
}
|
|
1842
2876
|
}
|
|
1843
2877
|
function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
|
|
1844
|
-
const allowedKeypaths = methodName ?
|
|
2878
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
|
|
2879
|
+
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
2880
|
+
}
|
|
2881
|
+
function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
|
|
2882
|
+
const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
|
|
1845
2883
|
return visitNode2(rawResponse, allowedKeypaths ?? []);
|
|
1846
2884
|
}
|
|
1847
2885
|
function createSolanaRpcApi(config) {
|
|
@@ -1870,6 +2908,36 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1870
2908
|
}
|
|
1871
2909
|
});
|
|
1872
2910
|
}
|
|
2911
|
+
function createSolanaRpcSubscriptionsApi(config) {
|
|
2912
|
+
return new Proxy({}, {
|
|
2913
|
+
defineProperty() {
|
|
2914
|
+
return false;
|
|
2915
|
+
},
|
|
2916
|
+
deleteProperty() {
|
|
2917
|
+
return false;
|
|
2918
|
+
},
|
|
2919
|
+
get(...args) {
|
|
2920
|
+
const [_, p] = args;
|
|
2921
|
+
const notificationName = p.toString();
|
|
2922
|
+
return function(...rawParams) {
|
|
2923
|
+
const handleIntegerOverflow = config?.onIntegerOverflow;
|
|
2924
|
+
const params = patchParamsForSolanaLabsRpc(
|
|
2925
|
+
rawParams,
|
|
2926
|
+
handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
|
|
2927
|
+
);
|
|
2928
|
+
return {
|
|
2929
|
+
params,
|
|
2930
|
+
responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
|
|
2931
|
+
subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
|
|
2932
|
+
unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
|
|
2933
|
+
};
|
|
2934
|
+
};
|
|
2935
|
+
}
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
2938
|
+
function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
|
|
2939
|
+
return createSolanaRpcSubscriptionsApi(config);
|
|
2940
|
+
}
|
|
1873
2941
|
|
|
1874
2942
|
// ../rpc-transport/dist/index.browser.js
|
|
1875
2943
|
init_env_shim();
|
|
@@ -1898,24 +2966,109 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1898
2966
|
params
|
|
1899
2967
|
};
|
|
1900
2968
|
}
|
|
1901
|
-
function createPendingRpcRequest(rpcConfig, pendingRequest) {
|
|
2969
|
+
function createPendingRpcRequest(rpcConfig, pendingRequest) {
|
|
2970
|
+
return {
|
|
2971
|
+
async send(options) {
|
|
2972
|
+
const { methodName, params, responseProcessor } = pendingRequest;
|
|
2973
|
+
const payload = createJsonRpcMessage(methodName, params);
|
|
2974
|
+
const response = await rpcConfig.transport({
|
|
2975
|
+
payload,
|
|
2976
|
+
signal: options?.abortSignal
|
|
2977
|
+
});
|
|
2978
|
+
if ("error" in response) {
|
|
2979
|
+
throw new SolanaJsonRpcError(response.error);
|
|
2980
|
+
} else {
|
|
2981
|
+
return responseProcessor ? responseProcessor(response.result) : response.result;
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
function makeProxy(rpcConfig) {
|
|
2987
|
+
return new Proxy(rpcConfig.api, {
|
|
2988
|
+
defineProperty() {
|
|
2989
|
+
return false;
|
|
2990
|
+
},
|
|
2991
|
+
deleteProperty() {
|
|
2992
|
+
return false;
|
|
2993
|
+
},
|
|
2994
|
+
get(target, p, receiver) {
|
|
2995
|
+
return function(...rawParams) {
|
|
2996
|
+
const methodName = p.toString();
|
|
2997
|
+
const createRpcRequest = Reflect.get(target, methodName, receiver);
|
|
2998
|
+
const newRequest = createRpcRequest ? createRpcRequest(...rawParams) : { methodName, params: rawParams };
|
|
2999
|
+
return createPendingRpcRequest(rpcConfig, newRequest);
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
function createJsonRpc(rpcConfig) {
|
|
3005
|
+
return makeProxy(rpcConfig);
|
|
3006
|
+
}
|
|
3007
|
+
function registerIterableCleanup(iterable, cleanupFn) {
|
|
3008
|
+
(async () => {
|
|
3009
|
+
try {
|
|
3010
|
+
for await (const _ of iterable)
|
|
3011
|
+
;
|
|
3012
|
+
} catch {
|
|
3013
|
+
} finally {
|
|
3014
|
+
cleanupFn();
|
|
3015
|
+
}
|
|
3016
|
+
})();
|
|
3017
|
+
}
|
|
3018
|
+
function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
|
|
1902
3019
|
return {
|
|
1903
|
-
async
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
3020
|
+
async subscribe({ abortSignal }) {
|
|
3021
|
+
abortSignal.throwIfAborted();
|
|
3022
|
+
let subscriptionId;
|
|
3023
|
+
function handleCleanup() {
|
|
3024
|
+
if (subscriptionId !== void 0) {
|
|
3025
|
+
const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
|
|
3026
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
|
|
3027
|
+
connectionAbortController.abort();
|
|
3028
|
+
});
|
|
3029
|
+
} else {
|
|
3030
|
+
connectionAbortController.abort();
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
abortSignal.addEventListener("abort", handleCleanup);
|
|
3034
|
+
const connectionAbortController = new AbortController();
|
|
3035
|
+
const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
|
|
3036
|
+
const connection = await rpcConfig.transport({
|
|
3037
|
+
payload: subscribeMessage,
|
|
3038
|
+
signal: connectionAbortController.signal
|
|
1909
3039
|
});
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
}
|
|
1913
|
-
|
|
3040
|
+
function handleConnectionCleanup() {
|
|
3041
|
+
abortSignal.removeEventListener("abort", handleCleanup);
|
|
3042
|
+
}
|
|
3043
|
+
registerIterableCleanup(connection, handleConnectionCleanup);
|
|
3044
|
+
for await (const message of connection) {
|
|
3045
|
+
if ("id" in message && message.id === subscribeMessage.id) {
|
|
3046
|
+
if ("error" in message) {
|
|
3047
|
+
throw new SolanaJsonRpcError(message.error);
|
|
3048
|
+
} else {
|
|
3049
|
+
subscriptionId = message.result;
|
|
3050
|
+
break;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
if (subscriptionId == null) {
|
|
3055
|
+
throw new Error("Failed to obtain a subscription id from the server");
|
|
1914
3056
|
}
|
|
3057
|
+
return {
|
|
3058
|
+
async *[Symbol.asyncIterator]() {
|
|
3059
|
+
for await (const message of connection) {
|
|
3060
|
+
if (!("params" in message) || message.params.subscription !== subscriptionId) {
|
|
3061
|
+
continue;
|
|
3062
|
+
}
|
|
3063
|
+
const notification = message.params.result;
|
|
3064
|
+
yield responseProcessor ? responseProcessor(notification) : notification;
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
1915
3068
|
}
|
|
1916
3069
|
};
|
|
1917
3070
|
}
|
|
1918
|
-
function
|
|
3071
|
+
function makeProxy2(rpcConfig) {
|
|
1919
3072
|
return new Proxy(rpcConfig.api, {
|
|
1920
3073
|
defineProperty() {
|
|
1921
3074
|
return false;
|
|
@@ -1926,17 +3079,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1926
3079
|
get(target, p, receiver) {
|
|
1927
3080
|
return function(...rawParams) {
|
|
1928
3081
|
const methodName = p.toString();
|
|
1929
|
-
const
|
|
1930
|
-
|
|
1931
|
-
|
|
3082
|
+
const createRpcSubscription = Reflect.get(target, methodName, receiver);
|
|
3083
|
+
if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
|
|
3084
|
+
throw new Error(
|
|
3085
|
+
"Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
|
|
3086
|
+
);
|
|
3087
|
+
}
|
|
3088
|
+
const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
|
|
3089
|
+
params: rawParams,
|
|
3090
|
+
subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
|
|
3091
|
+
unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
|
|
3092
|
+
};
|
|
3093
|
+
return createPendingRpcSubscription(rpcConfig, newRequest);
|
|
1932
3094
|
};
|
|
1933
3095
|
}
|
|
1934
3096
|
});
|
|
1935
3097
|
}
|
|
1936
|
-
function
|
|
1937
|
-
return
|
|
3098
|
+
function createJsonSubscriptionRpc(rpcConfig) {
|
|
3099
|
+
return makeProxy2(rpcConfig);
|
|
1938
3100
|
}
|
|
1939
|
-
var
|
|
3101
|
+
var e2 = globalThis.fetch;
|
|
1940
3102
|
var SolanaHttpError = class extends Error {
|
|
1941
3103
|
constructor(details) {
|
|
1942
3104
|
super(`HTTP error (${details.statusCode}): ${details.message}`);
|
|
@@ -2024,7 +3186,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2024
3186
|
method: "POST",
|
|
2025
3187
|
signal
|
|
2026
3188
|
};
|
|
2027
|
-
const response = await
|
|
3189
|
+
const response = await e2(url, requestInfo);
|
|
2028
3190
|
if (!response.ok) {
|
|
2029
3191
|
throw new SolanaHttpError({
|
|
2030
3192
|
message: response.statusText,
|
|
@@ -2034,6 +3196,175 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2034
3196
|
return await response.json();
|
|
2035
3197
|
};
|
|
2036
3198
|
}
|
|
3199
|
+
var e22 = globalThis.WebSocket;
|
|
3200
|
+
var EXPLICIT_ABORT_TOKEN = Symbol(
|
|
3201
|
+
"This symbol is thrown from a socket's iterator when the connection is explicity aborted by the user"
|
|
3202
|
+
);
|
|
3203
|
+
async function createWebSocketConnection({
|
|
3204
|
+
sendBufferHighWatermark,
|
|
3205
|
+
signal,
|
|
3206
|
+
url
|
|
3207
|
+
}) {
|
|
3208
|
+
return new Promise((resolve, reject) => {
|
|
3209
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
3210
|
+
const iteratorState = /* @__PURE__ */ new Map();
|
|
3211
|
+
function errorAndClearAllIteratorStates(reason) {
|
|
3212
|
+
const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
|
|
3213
|
+
iteratorState.clear();
|
|
3214
|
+
errorCallbacks.forEach((cb) => {
|
|
3215
|
+
try {
|
|
3216
|
+
cb(reason);
|
|
3217
|
+
} catch {
|
|
3218
|
+
}
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
3221
|
+
function handleAbort() {
|
|
3222
|
+
errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
|
|
3223
|
+
if (webSocket.readyState !== e22.CLOSED && webSocket.readyState !== e22.CLOSING) {
|
|
3224
|
+
webSocket.close(1e3);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
function handleClose(ev) {
|
|
3228
|
+
bufferDrainWatcher?.onCancel();
|
|
3229
|
+
signal.removeEventListener("abort", handleAbort);
|
|
3230
|
+
webSocket.removeEventListener("close", handleClose);
|
|
3231
|
+
webSocket.removeEventListener("error", handleError);
|
|
3232
|
+
webSocket.removeEventListener("open", handleOpen);
|
|
3233
|
+
webSocket.removeEventListener("message", handleMessage);
|
|
3234
|
+
errorAndClearAllIteratorStates(ev);
|
|
3235
|
+
}
|
|
3236
|
+
function handleError(ev) {
|
|
3237
|
+
if (!hasConnected) {
|
|
3238
|
+
reject(
|
|
3239
|
+
// TODO: Coded error
|
|
3240
|
+
new Error("WebSocket failed to connect", { cause: ev })
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
let hasConnected = false;
|
|
3245
|
+
let bufferDrainWatcher;
|
|
3246
|
+
function handleOpen() {
|
|
3247
|
+
hasConnected = true;
|
|
3248
|
+
resolve({
|
|
3249
|
+
async send(payload) {
|
|
3250
|
+
const message = JSON.stringify(payload);
|
|
3251
|
+
if (!bufferDrainWatcher && webSocket.readyState === e22.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
|
|
3252
|
+
let onCancel;
|
|
3253
|
+
const promise = new Promise((resolve2, reject2) => {
|
|
3254
|
+
const intervalId = setInterval(() => {
|
|
3255
|
+
if (webSocket.readyState !== e22.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
|
|
3256
|
+
clearInterval(intervalId);
|
|
3257
|
+
bufferDrainWatcher = void 0;
|
|
3258
|
+
resolve2();
|
|
3259
|
+
}
|
|
3260
|
+
}, 16);
|
|
3261
|
+
onCancel = () => {
|
|
3262
|
+
bufferDrainWatcher = void 0;
|
|
3263
|
+
clearInterval(intervalId);
|
|
3264
|
+
reject2(
|
|
3265
|
+
// TODO: Coded error
|
|
3266
|
+
new Error("WebSocket was closed before payload could be sent")
|
|
3267
|
+
);
|
|
3268
|
+
};
|
|
3269
|
+
});
|
|
3270
|
+
bufferDrainWatcher = {
|
|
3271
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3272
|
+
// @ts-ignore
|
|
3273
|
+
onCancel,
|
|
3274
|
+
promise
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
if (bufferDrainWatcher) {
|
|
3278
|
+
await bufferDrainWatcher.promise;
|
|
3279
|
+
}
|
|
3280
|
+
webSocket.send(message);
|
|
3281
|
+
},
|
|
3282
|
+
async *[Symbol.asyncIterator]() {
|
|
3283
|
+
const iteratorKey = Symbol();
|
|
3284
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
3285
|
+
try {
|
|
3286
|
+
while (true) {
|
|
3287
|
+
const state = iteratorState.get(iteratorKey);
|
|
3288
|
+
if (!state) {
|
|
3289
|
+
throw new Error("Invariant: WebSocket message iterator is missing state storage");
|
|
3290
|
+
}
|
|
3291
|
+
if (state.__hasPolled) {
|
|
3292
|
+
throw new Error(
|
|
3293
|
+
"Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
|
|
3294
|
+
);
|
|
3295
|
+
}
|
|
3296
|
+
const queuedMessages = state.queuedMessages;
|
|
3297
|
+
if (queuedMessages.length) {
|
|
3298
|
+
state.queuedMessages = [];
|
|
3299
|
+
yield* queuedMessages;
|
|
3300
|
+
} else {
|
|
3301
|
+
try {
|
|
3302
|
+
yield await new Promise((resolve2, reject2) => {
|
|
3303
|
+
iteratorState.set(iteratorKey, {
|
|
3304
|
+
__hasPolled: true,
|
|
3305
|
+
onError: reject2,
|
|
3306
|
+
onMessage: resolve2
|
|
3307
|
+
});
|
|
3308
|
+
});
|
|
3309
|
+
} catch (e3) {
|
|
3310
|
+
if (e3 === EXPLICIT_ABORT_TOKEN) {
|
|
3311
|
+
return;
|
|
3312
|
+
} else {
|
|
3313
|
+
throw new Error("WebSocket connection closed", { cause: e3 });
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
} finally {
|
|
3319
|
+
iteratorState.delete(iteratorKey);
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
function handleMessage({ data }) {
|
|
3325
|
+
const message = JSON.parse(data);
|
|
3326
|
+
iteratorState.forEach((state, iteratorKey) => {
|
|
3327
|
+
if (state.__hasPolled) {
|
|
3328
|
+
const { onMessage } = state;
|
|
3329
|
+
iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
|
|
3330
|
+
onMessage(message);
|
|
3331
|
+
} else {
|
|
3332
|
+
state.queuedMessages.push(message);
|
|
3333
|
+
}
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
const webSocket = new e22(url);
|
|
3337
|
+
webSocket.addEventListener("close", handleClose);
|
|
3338
|
+
webSocket.addEventListener("error", handleError);
|
|
3339
|
+
webSocket.addEventListener("open", handleOpen);
|
|
3340
|
+
webSocket.addEventListener("message", handleMessage);
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
function createWebSocketTransport({ sendBufferHighWatermark, url }) {
|
|
3344
|
+
if (/^wss?:/i.test(url) === false) {
|
|
3345
|
+
const protocolMatch = url.match(/^([^:]+):/);
|
|
3346
|
+
throw new DOMException(
|
|
3347
|
+
protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
|
|
3348
|
+
);
|
|
3349
|
+
}
|
|
3350
|
+
return async function sendWebSocketMessage({ payload, signal }) {
|
|
3351
|
+
signal?.throwIfAborted();
|
|
3352
|
+
const connection = await createWebSocketConnection({
|
|
3353
|
+
sendBufferHighWatermark,
|
|
3354
|
+
signal,
|
|
3355
|
+
url
|
|
3356
|
+
});
|
|
3357
|
+
signal?.throwIfAborted();
|
|
3358
|
+
await connection.send(payload);
|
|
3359
|
+
return {
|
|
3360
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
3361
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
|
|
3362
|
+
};
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
// src/rpc.ts
|
|
3367
|
+
var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
|
|
2037
3368
|
|
|
2038
3369
|
// src/rpc-default-config.ts
|
|
2039
3370
|
init_env_shim();
|
|
@@ -2075,6 +3406,197 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2075
3406
|
}
|
|
2076
3407
|
};
|
|
2077
3408
|
|
|
3409
|
+
// src/rpc-subscription-coalescer.ts
|
|
3410
|
+
init_env_shim();
|
|
3411
|
+
|
|
3412
|
+
// src/cached-abortable-iterable.ts
|
|
3413
|
+
init_env_shim();
|
|
3414
|
+
function registerIterableCleanup2(iterable, cleanupFn) {
|
|
3415
|
+
(async () => {
|
|
3416
|
+
try {
|
|
3417
|
+
for await (const _ of iterable)
|
|
3418
|
+
;
|
|
3419
|
+
} catch {
|
|
3420
|
+
} finally {
|
|
3421
|
+
cleanupFn();
|
|
3422
|
+
}
|
|
3423
|
+
})();
|
|
3424
|
+
}
|
|
3425
|
+
function getCachedAbortableIterableFactory({
|
|
3426
|
+
getAbortSignalFromInputArgs,
|
|
3427
|
+
getCacheEntryMissingError,
|
|
3428
|
+
getCacheKeyFromInputArgs,
|
|
3429
|
+
onCacheHit,
|
|
3430
|
+
onCreateIterable
|
|
3431
|
+
}) {
|
|
3432
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3433
|
+
function getCacheEntryOrThrow(cacheKey) {
|
|
3434
|
+
const currentCacheEntry = cache.get(cacheKey);
|
|
3435
|
+
if (!currentCacheEntry) {
|
|
3436
|
+
throw getCacheEntryMissingError(cacheKey);
|
|
3437
|
+
}
|
|
3438
|
+
return currentCacheEntry;
|
|
3439
|
+
}
|
|
3440
|
+
return async (...args) => {
|
|
3441
|
+
const cacheKey = getCacheKeyFromInputArgs(...args);
|
|
3442
|
+
const signal = getAbortSignalFromInputArgs(...args);
|
|
3443
|
+
if (cacheKey === void 0) {
|
|
3444
|
+
return await onCreateIterable(signal, ...args);
|
|
3445
|
+
}
|
|
3446
|
+
const cleanup = () => {
|
|
3447
|
+
cache.delete(cacheKey);
|
|
3448
|
+
signal.removeEventListener("abort", handleAbort);
|
|
3449
|
+
};
|
|
3450
|
+
const handleAbort = () => {
|
|
3451
|
+
const cacheEntry = getCacheEntryOrThrow(cacheKey);
|
|
3452
|
+
if (cacheEntry.purgeScheduled !== true) {
|
|
3453
|
+
cacheEntry.purgeScheduled = true;
|
|
3454
|
+
globalThis.queueMicrotask(() => {
|
|
3455
|
+
cacheEntry.purgeScheduled = false;
|
|
3456
|
+
if (cacheEntry.referenceCount === 0) {
|
|
3457
|
+
cacheEntry.abortController.abort();
|
|
3458
|
+
cleanup();
|
|
3459
|
+
}
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
cacheEntry.referenceCount--;
|
|
3463
|
+
};
|
|
3464
|
+
signal.addEventListener("abort", handleAbort);
|
|
3465
|
+
try {
|
|
3466
|
+
const cacheEntry = cache.get(cacheKey);
|
|
3467
|
+
if (!cacheEntry) {
|
|
3468
|
+
const singletonAbortController = new AbortController();
|
|
3469
|
+
const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
|
|
3470
|
+
const newCacheEntry = {
|
|
3471
|
+
abortController: singletonAbortController,
|
|
3472
|
+
iterable: newIterablePromise,
|
|
3473
|
+
purgeScheduled: false,
|
|
3474
|
+
referenceCount: 1
|
|
3475
|
+
};
|
|
3476
|
+
cache.set(cacheKey, newCacheEntry);
|
|
3477
|
+
const newIterable = await newIterablePromise;
|
|
3478
|
+
registerIterableCleanup2(newIterable, cleanup);
|
|
3479
|
+
newCacheEntry.iterable = newIterable;
|
|
3480
|
+
return newIterable;
|
|
3481
|
+
} else {
|
|
3482
|
+
cacheEntry.referenceCount++;
|
|
3483
|
+
const iterableOrIterablePromise = cacheEntry.iterable;
|
|
3484
|
+
const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
|
|
3485
|
+
await onCacheHit(cachedIterable, ...args);
|
|
3486
|
+
return cachedIterable;
|
|
3487
|
+
}
|
|
3488
|
+
} catch (e3) {
|
|
3489
|
+
cleanup();
|
|
3490
|
+
throw e3;
|
|
3491
|
+
}
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
// src/rpc-subscription-coalescer.ts
|
|
3496
|
+
var EXPLICIT_ABORT_TOKEN2 = Symbol(
|
|
3497
|
+
"This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
|
|
3498
|
+
);
|
|
3499
|
+
function registerIterableCleanup3(iterable, cleanupFn) {
|
|
3500
|
+
(async () => {
|
|
3501
|
+
try {
|
|
3502
|
+
for await (const _ of iterable)
|
|
3503
|
+
;
|
|
3504
|
+
} catch {
|
|
3505
|
+
} finally {
|
|
3506
|
+
cleanupFn();
|
|
3507
|
+
}
|
|
3508
|
+
})();
|
|
3509
|
+
}
|
|
3510
|
+
function getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
3511
|
+
getDeduplicationKey,
|
|
3512
|
+
rpcSubscriptions
|
|
3513
|
+
}) {
|
|
3514
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3515
|
+
return new Proxy(rpcSubscriptions, {
|
|
3516
|
+
defineProperty() {
|
|
3517
|
+
return false;
|
|
3518
|
+
},
|
|
3519
|
+
deleteProperty() {
|
|
3520
|
+
return false;
|
|
3521
|
+
},
|
|
3522
|
+
get(target, p, receiver) {
|
|
3523
|
+
const subscriptionMethod = Reflect.get(target, p, receiver);
|
|
3524
|
+
if (typeof subscriptionMethod !== "function") {
|
|
3525
|
+
return subscriptionMethod;
|
|
3526
|
+
}
|
|
3527
|
+
return function(...rawParams) {
|
|
3528
|
+
const deduplicationKey = getDeduplicationKey(p, rawParams);
|
|
3529
|
+
if (deduplicationKey === void 0) {
|
|
3530
|
+
return subscriptionMethod(...rawParams);
|
|
3531
|
+
}
|
|
3532
|
+
if (cache.has(deduplicationKey)) {
|
|
3533
|
+
return cache.get(deduplicationKey);
|
|
3534
|
+
}
|
|
3535
|
+
const iterableFactory = getCachedAbortableIterableFactory({
|
|
3536
|
+
getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
|
|
3537
|
+
getCacheEntryMissingError(deduplicationKey2) {
|
|
3538
|
+
return new Error(
|
|
3539
|
+
`Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
|
|
3540
|
+
);
|
|
3541
|
+
},
|
|
3542
|
+
getCacheKeyFromInputArgs: () => deduplicationKey,
|
|
3543
|
+
async onCacheHit(_iterable, _config) {
|
|
3544
|
+
},
|
|
3545
|
+
async onCreateIterable(abortSignal, config) {
|
|
3546
|
+
const pendingSubscription2 = subscriptionMethod(
|
|
3547
|
+
...rawParams
|
|
3548
|
+
);
|
|
3549
|
+
const iterable = await pendingSubscription2.subscribe({
|
|
3550
|
+
...config,
|
|
3551
|
+
abortSignal
|
|
3552
|
+
});
|
|
3553
|
+
registerIterableCleanup3(iterable, () => {
|
|
3554
|
+
cache.delete(deduplicationKey);
|
|
3555
|
+
});
|
|
3556
|
+
return iterable;
|
|
3557
|
+
}
|
|
3558
|
+
});
|
|
3559
|
+
const pendingSubscription = {
|
|
3560
|
+
async subscribe(...args) {
|
|
3561
|
+
const iterable = await iterableFactory(...args);
|
|
3562
|
+
const { abortSignal } = args[0];
|
|
3563
|
+
let abortPromise;
|
|
3564
|
+
return {
|
|
3565
|
+
...iterable,
|
|
3566
|
+
async *[Symbol.asyncIterator]() {
|
|
3567
|
+
abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN2) : new Promise((_, reject) => {
|
|
3568
|
+
abortSignal.addEventListener("abort", () => {
|
|
3569
|
+
reject(EXPLICIT_ABORT_TOKEN2);
|
|
3570
|
+
});
|
|
3571
|
+
}));
|
|
3572
|
+
try {
|
|
3573
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
3574
|
+
while (true) {
|
|
3575
|
+
const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
|
|
3576
|
+
if (iteratorResult.done) {
|
|
3577
|
+
return;
|
|
3578
|
+
} else {
|
|
3579
|
+
yield iteratorResult.value;
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
} catch (e3) {
|
|
3583
|
+
if (e3 === EXPLICIT_ABORT_TOKEN2) {
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
cache.delete(deduplicationKey);
|
|
3587
|
+
throw e3;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3592
|
+
};
|
|
3593
|
+
cache.set(deduplicationKey, pendingSubscription);
|
|
3594
|
+
return pendingSubscription;
|
|
3595
|
+
};
|
|
3596
|
+
}
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
|
|
2078
3600
|
// src/rpc.ts
|
|
2079
3601
|
function createSolanaRpc(config) {
|
|
2080
3602
|
return createJsonRpc({
|
|
@@ -2082,6 +3604,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2082
3604
|
api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
|
|
2083
3605
|
});
|
|
2084
3606
|
}
|
|
3607
|
+
function createSolanaRpcSubscriptions(config) {
|
|
3608
|
+
return pipe(
|
|
3609
|
+
createJsonSubscriptionRpc({
|
|
3610
|
+
...config,
|
|
3611
|
+
api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
|
|
3612
|
+
}),
|
|
3613
|
+
(rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
|
|
3614
|
+
getDeduplicationKey: (...args) => (0, import_fast_stable_stringify.default)(args),
|
|
3615
|
+
rpcSubscriptions
|
|
3616
|
+
})
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3619
|
+
function createSolanaRpcSubscriptions_UNSTABLE(config) {
|
|
3620
|
+
return createJsonSubscriptionRpc({
|
|
3621
|
+
...config,
|
|
3622
|
+
api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
2085
3625
|
|
|
2086
3626
|
// src/rpc-transport.ts
|
|
2087
3627
|
init_env_shim();
|
|
@@ -2118,14 +3658,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2118
3658
|
if (signal) {
|
|
2119
3659
|
const responsePromise = coalescedRequest.responsePromise;
|
|
2120
3660
|
return await new Promise((resolve, reject) => {
|
|
2121
|
-
const handleAbort = (
|
|
3661
|
+
const handleAbort = (e3) => {
|
|
2122
3662
|
signal.removeEventListener("abort", handleAbort);
|
|
2123
3663
|
coalescedRequest.numConsumers -= 1;
|
|
2124
3664
|
if (coalescedRequest.numConsumers === 0) {
|
|
2125
3665
|
const abortController = coalescedRequest.abortController;
|
|
2126
3666
|
abortController.abort();
|
|
2127
3667
|
}
|
|
2128
|
-
const abortError = new DOMException(
|
|
3668
|
+
const abortError = new DOMException(e3.target.reason, "AbortError");
|
|
2129
3669
|
reject(abortError);
|
|
2130
3670
|
};
|
|
2131
3671
|
signal.addEventListener("abort", handleAbort);
|
|
@@ -2141,14 +3681,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2141
3681
|
|
|
2142
3682
|
// src/rpc-request-deduplication.ts
|
|
2143
3683
|
init_env_shim();
|
|
2144
|
-
var
|
|
2145
|
-
function
|
|
3684
|
+
var import_fast_stable_stringify2 = __toESM(require_fast_stable_stringify(), 1);
|
|
3685
|
+
function isJsonRpcPayload(payload) {
|
|
2146
3686
|
if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
2147
|
-
return;
|
|
2148
|
-
}
|
|
2149
|
-
if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
|
|
2150
|
-
return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
|
|
3687
|
+
return false;
|
|
2151
3688
|
}
|
|
3689
|
+
return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
|
|
3690
|
+
}
|
|
3691
|
+
function getSolanaRpcPayloadDeduplicationKey(payload) {
|
|
3692
|
+
return isJsonRpcPayload(payload) ? (0, import_fast_stable_stringify2.default)([payload.method, payload.params]) : void 0;
|
|
2152
3693
|
}
|
|
2153
3694
|
|
|
2154
3695
|
// src/rpc-transport.ts
|
|
@@ -2160,7 +3701,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2160
3701
|
return out;
|
|
2161
3702
|
}
|
|
2162
3703
|
function createDefaultRpcTransport(config) {
|
|
2163
|
-
return
|
|
3704
|
+
return pipe(
|
|
2164
3705
|
createHttpTransport({
|
|
2165
3706
|
...config,
|
|
2166
3707
|
headers: {
|
|
@@ -2171,38 +3712,466 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2171
3712
|
}
|
|
2172
3713
|
}
|
|
2173
3714
|
}),
|
|
2174
|
-
getSolanaRpcPayloadDeduplicationKey
|
|
3715
|
+
(transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
|
|
3716
|
+
);
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
// src/rpc-websocket-transport.ts
|
|
3720
|
+
init_env_shim();
|
|
3721
|
+
|
|
3722
|
+
// src/rpc-websocket-autopinger.ts
|
|
3723
|
+
init_env_shim();
|
|
3724
|
+
var PING_PAYLOAD = {
|
|
3725
|
+
jsonrpc: "2.0",
|
|
3726
|
+
method: "ping"
|
|
3727
|
+
};
|
|
3728
|
+
function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
|
|
3729
|
+
const pingableConnections = /* @__PURE__ */ new Map();
|
|
3730
|
+
return async (...args) => {
|
|
3731
|
+
const connection = await transport(...args);
|
|
3732
|
+
let intervalId;
|
|
3733
|
+
function sendPing() {
|
|
3734
|
+
connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
|
|
3735
|
+
}
|
|
3736
|
+
function restartPingTimer() {
|
|
3737
|
+
clearInterval(intervalId);
|
|
3738
|
+
intervalId = setInterval(sendPing, intervalMs);
|
|
3739
|
+
}
|
|
3740
|
+
if (pingableConnections.has(connection) === false) {
|
|
3741
|
+
pingableConnections.set(connection, {
|
|
3742
|
+
[Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
|
|
3743
|
+
send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
|
|
3744
|
+
restartPingTimer();
|
|
3745
|
+
return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
|
|
3746
|
+
}
|
|
3747
|
+
});
|
|
3748
|
+
(async () => {
|
|
3749
|
+
try {
|
|
3750
|
+
for await (const _ of connection) {
|
|
3751
|
+
restartPingTimer();
|
|
3752
|
+
}
|
|
3753
|
+
} catch {
|
|
3754
|
+
} finally {
|
|
3755
|
+
pingableConnections.delete(connection);
|
|
3756
|
+
clearInterval(intervalId);
|
|
3757
|
+
if (handleOffline) {
|
|
3758
|
+
globalThis.window.removeEventListener("offline", handleOffline);
|
|
3759
|
+
}
|
|
3760
|
+
if (handleOnline) {
|
|
3761
|
+
globalThis.window.removeEventListener("online", handleOnline);
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
})();
|
|
3765
|
+
if (globalThis.navigator.onLine) {
|
|
3766
|
+
restartPingTimer();
|
|
3767
|
+
}
|
|
3768
|
+
let handleOffline;
|
|
3769
|
+
let handleOnline;
|
|
3770
|
+
{
|
|
3771
|
+
handleOffline = () => {
|
|
3772
|
+
clearInterval(intervalId);
|
|
3773
|
+
};
|
|
3774
|
+
handleOnline = () => {
|
|
3775
|
+
sendPing();
|
|
3776
|
+
restartPingTimer();
|
|
3777
|
+
};
|
|
3778
|
+
globalThis.window.addEventListener("offline", handleOffline);
|
|
3779
|
+
globalThis.window.addEventListener("online", handleOnline);
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
return pingableConnections.get(connection);
|
|
3783
|
+
};
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
// src/rpc-websocket-connection-sharding.ts
|
|
3787
|
+
init_env_shim();
|
|
3788
|
+
var NULL_SHARD_CACHE_KEY = Symbol(
|
|
3789
|
+
"Cache key to use when there is no connection sharding strategy"
|
|
3790
|
+
);
|
|
3791
|
+
function getWebSocketTransportWithConnectionSharding({ getShard, transport }) {
|
|
3792
|
+
return getCachedAbortableIterableFactory({
|
|
3793
|
+
getAbortSignalFromInputArgs: ({ signal }) => signal,
|
|
3794
|
+
getCacheEntryMissingError(shardKey) {
|
|
3795
|
+
return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
|
|
3796
|
+
},
|
|
3797
|
+
getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
|
|
3798
|
+
onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
|
|
3799
|
+
onCreateIterable: (abortSignal, config) => transport({
|
|
3800
|
+
...config,
|
|
3801
|
+
signal: abortSignal
|
|
3802
|
+
})
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3806
|
+
// src/rpc-websocket-transport.ts
|
|
3807
|
+
function createDefaultRpcSubscriptionsTransport(config) {
|
|
3808
|
+
const { getShard, intervalMs, ...rest } = config;
|
|
3809
|
+
return pipe(
|
|
3810
|
+
createWebSocketTransport({
|
|
3811
|
+
...rest,
|
|
3812
|
+
sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
|
|
3813
|
+
131072
|
|
3814
|
+
}),
|
|
3815
|
+
(transport) => getWebSocketTransportWithAutoping({
|
|
3816
|
+
intervalMs: intervalMs ?? 5e3,
|
|
3817
|
+
transport
|
|
3818
|
+
}),
|
|
3819
|
+
(transport) => getWebSocketTransportWithConnectionSharding({
|
|
3820
|
+
getShard,
|
|
3821
|
+
transport
|
|
3822
|
+
})
|
|
3823
|
+
);
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
// src/send-transaction.ts
|
|
3827
|
+
init_env_shim();
|
|
3828
|
+
|
|
3829
|
+
// src/transaction-confirmation.ts
|
|
3830
|
+
init_env_shim();
|
|
3831
|
+
|
|
3832
|
+
// src/transaction-confirmation-strategy-blockheight.ts
|
|
3833
|
+
init_env_shim();
|
|
3834
|
+
function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
|
|
3835
|
+
return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
|
|
3836
|
+
const abortController = new AbortController();
|
|
3837
|
+
function handleAbort() {
|
|
3838
|
+
abortController.abort();
|
|
3839
|
+
}
|
|
3840
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3841
|
+
const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
|
|
3842
|
+
try {
|
|
3843
|
+
for await (const slotNotification of slotNotifications) {
|
|
3844
|
+
if (slotNotification.slot > lastValidBlockHeight) {
|
|
3845
|
+
throw new Error(
|
|
3846
|
+
"The network has progressed past the last block for which this transaction could have committed."
|
|
3847
|
+
);
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
} finally {
|
|
3851
|
+
abortController.abort();
|
|
3852
|
+
}
|
|
3853
|
+
};
|
|
3854
|
+
}
|
|
3855
|
+
|
|
3856
|
+
// src/transaction-confirmation-strategy-nonce.ts
|
|
3857
|
+
init_env_shim();
|
|
3858
|
+
var NONCE_VALUE_OFFSET = 4 + // version(u32)
|
|
3859
|
+
4 + // state(u32)
|
|
3860
|
+
32;
|
|
3861
|
+
function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
|
|
3862
|
+
return async function getNonceInvalidationPromise({
|
|
3863
|
+
abortSignal: callerAbortSignal,
|
|
3864
|
+
commitment,
|
|
3865
|
+
currentNonceValue,
|
|
3866
|
+
nonceAccountAddress
|
|
3867
|
+
}) {
|
|
3868
|
+
const abortController = new AbortController();
|
|
3869
|
+
function handleAbort() {
|
|
3870
|
+
abortController.abort();
|
|
3871
|
+
}
|
|
3872
|
+
callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
|
|
3873
|
+
const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
|
|
3874
|
+
const base58Decoder2 = getBase58Decoder();
|
|
3875
|
+
const base64Encoder = getBase64Encoder();
|
|
3876
|
+
function getNonceFromAccountData([base64EncodedBytes]) {
|
|
3877
|
+
const data = base64Encoder.encode(base64EncodedBytes);
|
|
3878
|
+
const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
|
|
3879
|
+
return base58Decoder2.decode(nonceValueBytes)[0];
|
|
3880
|
+
}
|
|
3881
|
+
const nonceAccountDidAdvancePromise = (async () => {
|
|
3882
|
+
for await (const accountNotification of accountNotifications) {
|
|
3883
|
+
const nonceValue = getNonceFromAccountData(accountNotification.value.data);
|
|
3884
|
+
if (nonceValue !== currentNonceValue) {
|
|
3885
|
+
throw new Error(
|
|
3886
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
3887
|
+
);
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
})();
|
|
3891
|
+
const nonceIsAlreadyInvalidPromise = (async () => {
|
|
3892
|
+
const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
|
|
3893
|
+
commitment,
|
|
3894
|
+
dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
|
|
3895
|
+
encoding: "base58"
|
|
3896
|
+
}).send({ abortSignal: abortController.signal });
|
|
3897
|
+
if (!nonceAccount) {
|
|
3898
|
+
throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
|
|
3899
|
+
}
|
|
3900
|
+
const nonceValue = (
|
|
3901
|
+
// This works because we asked for the exact slice of data representing the nonce
|
|
3902
|
+
// value, and furthermore asked for it in `base58` encoding.
|
|
3903
|
+
nonceAccount.data[0]
|
|
3904
|
+
);
|
|
3905
|
+
if (nonceValue !== currentNonceValue) {
|
|
3906
|
+
throw new Error(
|
|
3907
|
+
`The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
|
|
3908
|
+
);
|
|
3909
|
+
} else {
|
|
3910
|
+
await new Promise(() => {
|
|
3911
|
+
});
|
|
3912
|
+
}
|
|
3913
|
+
})();
|
|
3914
|
+
try {
|
|
3915
|
+
return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
|
|
3916
|
+
} finally {
|
|
3917
|
+
abortController.abort();
|
|
3918
|
+
}
|
|
3919
|
+
};
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
// src/transaction-confirmation.ts
|
|
3923
|
+
function createDefaultDurableNonceTransactionConfirmer({
|
|
3924
|
+
rpc,
|
|
3925
|
+
rpcSubscriptions
|
|
3926
|
+
}) {
|
|
3927
|
+
const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
|
|
3928
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
3929
|
+
rpc,
|
|
3930
|
+
rpcSubscriptions
|
|
3931
|
+
);
|
|
3932
|
+
return async function confirmDurableNonceTransaction(config) {
|
|
3933
|
+
await waitForDurableNonceTransactionConfirmation({
|
|
3934
|
+
...config,
|
|
3935
|
+
getNonceInvalidationPromise,
|
|
3936
|
+
getRecentSignatureConfirmationPromise
|
|
3937
|
+
});
|
|
3938
|
+
};
|
|
3939
|
+
}
|
|
3940
|
+
function createDefaultRecentTransactionConfirmer({
|
|
3941
|
+
rpc,
|
|
3942
|
+
rpcSubscriptions
|
|
3943
|
+
}) {
|
|
3944
|
+
const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
|
|
3945
|
+
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
|
|
3946
|
+
rpc,
|
|
3947
|
+
rpcSubscriptions
|
|
3948
|
+
);
|
|
3949
|
+
return async function confirmRecentTransaction(config) {
|
|
3950
|
+
await waitForRecentTransactionConfirmation({
|
|
3951
|
+
...config,
|
|
3952
|
+
getBlockHeightExceedencePromise,
|
|
3953
|
+
getRecentSignatureConfirmationPromise
|
|
3954
|
+
});
|
|
3955
|
+
};
|
|
3956
|
+
}
|
|
3957
|
+
async function waitForDurableNonceTransactionConfirmation(config) {
|
|
3958
|
+
await raceStrategies(
|
|
3959
|
+
getSignatureFromTransaction(config.transaction),
|
|
3960
|
+
config,
|
|
3961
|
+
function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
|
|
3962
|
+
return [
|
|
3963
|
+
getNonceInvalidationPromise({
|
|
3964
|
+
abortSignal,
|
|
3965
|
+
commitment,
|
|
3966
|
+
currentNonceValue: transaction.lifetimeConstraint.nonce,
|
|
3967
|
+
nonceAccountAddress: transaction.instructions[0].accounts[0].address
|
|
3968
|
+
})
|
|
3969
|
+
];
|
|
3970
|
+
}
|
|
2175
3971
|
);
|
|
2176
3972
|
}
|
|
3973
|
+
async function waitForRecentTransactionConfirmation(config) {
|
|
3974
|
+
await raceStrategies(
|
|
3975
|
+
getSignatureFromTransaction(config.transaction),
|
|
3976
|
+
config,
|
|
3977
|
+
function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
|
|
3978
|
+
return [
|
|
3979
|
+
getBlockHeightExceedencePromise({
|
|
3980
|
+
abortSignal,
|
|
3981
|
+
lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
|
|
3982
|
+
})
|
|
3983
|
+
];
|
|
3984
|
+
}
|
|
3985
|
+
);
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
// src/send-transaction.ts
|
|
3989
|
+
function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
|
|
3990
|
+
if (
|
|
3991
|
+
// The developer has supplied no value for `preflightCommitment`.
|
|
3992
|
+
!config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
|
|
3993
|
+
commitmentComparator(
|
|
3994
|
+
commitment,
|
|
3995
|
+
"finalized"
|
|
3996
|
+
/* default value of `preflightCommitment` */
|
|
3997
|
+
) < 0
|
|
3998
|
+
) {
|
|
3999
|
+
return {
|
|
4000
|
+
...config,
|
|
4001
|
+
// In the common case, it is unlikely that you want to simulate a transaction at
|
|
4002
|
+
// `finalized` commitment when your standard of commitment for confirming the
|
|
4003
|
+
// transaction is lower. Cap the simulation commitment level to the level of the
|
|
4004
|
+
// confirmation commitment.
|
|
4005
|
+
preflightCommitment: commitment
|
|
4006
|
+
};
|
|
4007
|
+
}
|
|
4008
|
+
return config;
|
|
4009
|
+
}
|
|
4010
|
+
async function sendTransaction_INTERNAL({
|
|
4011
|
+
abortSignal,
|
|
4012
|
+
commitment,
|
|
4013
|
+
rpc,
|
|
4014
|
+
transaction,
|
|
4015
|
+
...sendTransactionConfig
|
|
4016
|
+
}) {
|
|
4017
|
+
const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
|
|
4018
|
+
return await rpc.sendTransaction(base64EncodedWireTransaction, {
|
|
4019
|
+
...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
|
|
4020
|
+
encoding: "base64"
|
|
4021
|
+
}).send({ abortSignal });
|
|
4022
|
+
}
|
|
4023
|
+
function createDefaultDurableNonceTransactionSender({
|
|
4024
|
+
rpc,
|
|
4025
|
+
rpcSubscriptions
|
|
4026
|
+
}) {
|
|
4027
|
+
const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
|
|
4028
|
+
rpc,
|
|
4029
|
+
rpcSubscriptions
|
|
4030
|
+
});
|
|
4031
|
+
return async function sendDurableNonceTransaction(transaction, config) {
|
|
4032
|
+
await sendAndConfirmDurableNonceTransaction({
|
|
4033
|
+
...config,
|
|
4034
|
+
confirmDurableNonceTransaction,
|
|
4035
|
+
rpc,
|
|
4036
|
+
transaction
|
|
4037
|
+
});
|
|
4038
|
+
};
|
|
4039
|
+
}
|
|
4040
|
+
function createDefaultTransactionSender({
|
|
4041
|
+
rpc,
|
|
4042
|
+
rpcSubscriptions
|
|
4043
|
+
}) {
|
|
4044
|
+
const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
|
|
4045
|
+
rpc,
|
|
4046
|
+
rpcSubscriptions
|
|
4047
|
+
});
|
|
4048
|
+
return async function sendTransaction(transaction, config) {
|
|
4049
|
+
await sendAndConfirmTransaction({
|
|
4050
|
+
...config,
|
|
4051
|
+
confirmRecentTransaction,
|
|
4052
|
+
rpc,
|
|
4053
|
+
transaction
|
|
4054
|
+
});
|
|
4055
|
+
};
|
|
4056
|
+
}
|
|
4057
|
+
async function sendAndConfirmDurableNonceTransaction({
|
|
4058
|
+
abortSignal,
|
|
4059
|
+
commitment,
|
|
4060
|
+
confirmDurableNonceTransaction,
|
|
4061
|
+
rpc,
|
|
4062
|
+
transaction,
|
|
4063
|
+
...sendTransactionConfig
|
|
4064
|
+
}) {
|
|
4065
|
+
const transactionSignature2 = await sendTransaction_INTERNAL({
|
|
4066
|
+
...sendTransactionConfig,
|
|
4067
|
+
abortSignal,
|
|
4068
|
+
commitment,
|
|
4069
|
+
rpc,
|
|
4070
|
+
transaction
|
|
4071
|
+
});
|
|
4072
|
+
await confirmDurableNonceTransaction({
|
|
4073
|
+
abortSignal,
|
|
4074
|
+
commitment,
|
|
4075
|
+
transaction
|
|
4076
|
+
});
|
|
4077
|
+
return transactionSignature2;
|
|
4078
|
+
}
|
|
4079
|
+
async function sendAndConfirmTransaction({
|
|
4080
|
+
abortSignal,
|
|
4081
|
+
commitment,
|
|
4082
|
+
confirmRecentTransaction,
|
|
4083
|
+
rpc,
|
|
4084
|
+
transaction,
|
|
4085
|
+
...sendTransactionConfig
|
|
4086
|
+
}) {
|
|
4087
|
+
const transactionSignature2 = await sendTransaction_INTERNAL({
|
|
4088
|
+
...sendTransactionConfig,
|
|
4089
|
+
abortSignal,
|
|
4090
|
+
commitment,
|
|
4091
|
+
rpc,
|
|
4092
|
+
transaction
|
|
4093
|
+
});
|
|
4094
|
+
await confirmRecentTransaction({
|
|
4095
|
+
abortSignal,
|
|
4096
|
+
commitment,
|
|
4097
|
+
transaction
|
|
4098
|
+
});
|
|
4099
|
+
return transactionSignature2;
|
|
4100
|
+
}
|
|
2177
4101
|
|
|
2178
4102
|
exports.AccountRole = AccountRole;
|
|
4103
|
+
exports.address = address;
|
|
2179
4104
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
2180
|
-
exports.
|
|
4105
|
+
exports.assertIsAddress = assertIsAddress;
|
|
2181
4106
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
2182
4107
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
4108
|
+
exports.assertIsLamports = assertIsLamports;
|
|
4109
|
+
exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
|
|
4110
|
+
exports.assertIsStringifiedBigInt = assertIsStringifiedBigInt;
|
|
4111
|
+
exports.assertIsStringifiedNumber = assertIsStringifiedNumber;
|
|
4112
|
+
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
4113
|
+
exports.assertIsUnixTimestamp = assertIsUnixTimestamp;
|
|
4114
|
+
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
4115
|
+
exports.commitmentComparator = commitmentComparator;
|
|
4116
|
+
exports.createAddressWithSeed = createAddressWithSeed;
|
|
4117
|
+
exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
|
|
4118
|
+
exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
|
|
4119
|
+
exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
|
|
4120
|
+
exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
|
|
4121
|
+
exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
|
|
4122
|
+
exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
|
|
2183
4123
|
exports.createDefaultRpcTransport = createDefaultRpcTransport;
|
|
4124
|
+
exports.createDefaultTransactionSender = createDefaultTransactionSender;
|
|
4125
|
+
exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
|
|
4126
|
+
exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
|
|
2184
4127
|
exports.createSolanaRpc = createSolanaRpc;
|
|
4128
|
+
exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
|
|
4129
|
+
exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
|
|
2185
4130
|
exports.createTransaction = createTransaction;
|
|
2186
4131
|
exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
|
|
2187
4132
|
exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
|
|
2188
4133
|
exports.generateKeyPair = generateKeyPair;
|
|
2189
|
-
exports.
|
|
2190
|
-
exports.
|
|
2191
|
-
exports.
|
|
4134
|
+
exports.getAddressCodec = getAddressCodec;
|
|
4135
|
+
exports.getAddressComparator = getAddressComparator;
|
|
4136
|
+
exports.getAddressDecoder = getAddressDecoder;
|
|
4137
|
+
exports.getAddressEncoder = getAddressEncoder;
|
|
4138
|
+
exports.getAddressFromPublicKey = getAddressFromPublicKey;
|
|
2192
4139
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2193
4140
|
exports.getProgramDerivedAddress = getProgramDerivedAddress;
|
|
4141
|
+
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
4142
|
+
exports.getTransactionCodec = getTransactionCodec;
|
|
4143
|
+
exports.getTransactionDecoder = getTransactionDecoder;
|
|
4144
|
+
exports.getTransactionEncoder = getTransactionEncoder;
|
|
4145
|
+
exports.isAddress = isAddress;
|
|
4146
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
4147
|
+
exports.isLamports = isLamports;
|
|
4148
|
+
exports.isProgramDerivedAddress = isProgramDerivedAddress;
|
|
2194
4149
|
exports.isSignerRole = isSignerRole;
|
|
4150
|
+
exports.isStringifiedBigInt = isStringifiedBigInt;
|
|
4151
|
+
exports.isStringifiedNumber = isStringifiedNumber;
|
|
4152
|
+
exports.isTransactionSignature = isTransactionSignature;
|
|
4153
|
+
exports.isUnixTimestamp = isUnixTimestamp;
|
|
2195
4154
|
exports.isWritableRole = isWritableRole;
|
|
4155
|
+
exports.lamports = lamports;
|
|
2196
4156
|
exports.mergeRoles = mergeRoles;
|
|
2197
4157
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
4158
|
+
exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
|
|
4159
|
+
exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
|
|
4160
|
+
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
2198
4161
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
2199
4162
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
2200
4163
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
2201
4164
|
exports.signBytes = signBytes;
|
|
2202
4165
|
exports.signTransaction = signTransaction;
|
|
4166
|
+
exports.stringifiedBigInt = stringifiedBigInt;
|
|
4167
|
+
exports.stringifiedNumber = stringifiedNumber;
|
|
4168
|
+
exports.transactionSignature = transactionSignature;
|
|
4169
|
+
exports.unixTimestamp = unixTimestamp;
|
|
2203
4170
|
exports.upgradeRoleToSigner = upgradeRoleToSigner;
|
|
2204
4171
|
exports.upgradeRoleToWritable = upgradeRoleToWritable;
|
|
2205
4172
|
exports.verifySignature = verifySignature;
|
|
4173
|
+
exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
|
|
4174
|
+
exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
|
|
2206
4175
|
|
|
2207
4176
|
return exports;
|
|
2208
4177
|
|