@solana/transactions 2.0.0-experimental.7000add → 2.0.0-experimental.70ec746
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/dist/index.browser.cjs +297 -185
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +292 -188
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +958 -239
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +292 -188
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +295 -187
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +292 -188
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +17 -11
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/blockhash.d.ts +1 -1
- package/dist/types/compile-address-table-lookups.d.ts +1 -1
- package/dist/types/compile-instructions.d.ts +1 -1
- package/dist/types/compile-static-accounts.d.ts +1 -1
- package/dist/types/durable-nonce.d.ts +6 -4
- package/dist/types/fee-payer.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts +5 -3
- package/dist/types/serializers/header.d.ts +4 -2
- package/dist/types/serializers/index.d.ts +2 -0
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/transaction-version.d.ts +4 -4
- package/dist/types/signatures.d.ts +12 -3
- package/dist/types/types.d.ts +7 -0
- package/dist/types/wire-transaction.d.ts +1 -1
- package/package.json +21 -18
- package/dist/types/accounts.d.ts.map +0 -1
- package/dist/types/blockhash.d.ts.map +0 -1
- package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
- package/dist/types/compile-header.d.ts.map +0 -1
- package/dist/types/compile-instructions.d.ts.map +0 -1
- package/dist/types/compile-lifetime-token.d.ts.map +0 -1
- package/dist/types/compile-static-accounts.d.ts.map +0 -1
- package/dist/types/compile-transaction.d.ts.map +0 -1
- package/dist/types/create-transaction.d.ts.map +0 -1
- package/dist/types/durable-nonce.d.ts.map +0 -1
- package/dist/types/fee-payer.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/instructions.d.ts.map +0 -1
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
- package/dist/types/serializers/header.d.ts.map +0 -1
- package/dist/types/serializers/instruction.d.ts.map +0 -1
- package/dist/types/serializers/message.d.ts.map +0 -1
- package/dist/types/serializers/transaction-version.d.ts.map +0 -1
- package/dist/types/serializers/transaction.d.ts.map +0 -1
- package/dist/types/serializers/unimplemented.d.ts.map +0 -1
- package/dist/types/signatures.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/unsigned-transaction.d.ts.map +0 -1
- package/dist/types/wire-transaction.d.ts.map +0 -1
|
@@ -9,7 +9,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
12
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
13
13
|
var mergeBytes = (bytesArr) => {
|
|
14
14
|
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
15
15
|
const result = new Uint8Array(totalLength);
|
|
@@ -29,7 +29,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
29
29
|
};
|
|
30
30
|
var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
|
|
31
31
|
|
|
32
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
32
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
|
|
33
33
|
var DeserializingEmptyBufferError = class extends Error {
|
|
34
34
|
constructor(serializer) {
|
|
35
35
|
super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
|
|
@@ -50,7 +50,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
53
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
54
54
|
function fixSerializer(serializer, fixedBytes, description) {
|
|
55
55
|
return {
|
|
56
56
|
description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
|
|
@@ -71,7 +71,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
74
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
|
|
75
75
|
function mapSerializer(serializer, unmap, map) {
|
|
76
76
|
return {
|
|
77
77
|
description: serializer.description,
|
|
@@ -85,7 +85,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
88
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
89
89
|
var InvalidBaseStringError = class extends Error {
|
|
90
90
|
constructor(value, base, cause) {
|
|
91
91
|
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
@@ -95,7 +95,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
98
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
99
99
|
var baseX = (alphabet) => {
|
|
100
100
|
const base = alphabet.length;
|
|
101
101
|
const baseBigInt = BigInt(base);
|
|
@@ -149,16 +149,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
152
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
153
153
|
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
154
154
|
|
|
155
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
155
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
|
|
156
156
|
var removeNullCharacters = (value) => (
|
|
157
157
|
// eslint-disable-next-line no-control-regex
|
|
158
158
|
value.replace(/\u0000/g, "")
|
|
159
159
|
);
|
|
160
160
|
|
|
161
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
161
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
|
|
162
162
|
var utf8 = {
|
|
163
163
|
description: "utf8",
|
|
164
164
|
fixedSize: null,
|
|
@@ -172,14 +172,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
175
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
|
|
176
176
|
var Endian;
|
|
177
177
|
(function(Endian2) {
|
|
178
178
|
Endian2["Little"] = "le";
|
|
179
179
|
Endian2["Big"] = "be";
|
|
180
180
|
})(Endian || (Endian = {}));
|
|
181
181
|
|
|
182
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
182
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
|
|
183
183
|
var NumberOutOfRangeError = class extends RangeError {
|
|
184
184
|
constructor(serializer, min, max, actual) {
|
|
185
185
|
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
|
|
@@ -187,7 +187,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
190
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
|
|
191
191
|
function numberFactory(input) {
|
|
192
192
|
let littleEndian;
|
|
193
193
|
let defaultDescription = input.name;
|
|
@@ -231,17 +231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
235
|
-
var u8 = (options = {}) => numberFactory({
|
|
236
|
-
name: "u8",
|
|
237
|
-
size: 1,
|
|
238
|
-
range: [0, Number("0xff")],
|
|
239
|
-
set: (view, value) => view.setUint8(0, Number(value)),
|
|
240
|
-
get: (view) => view.getUint8(0),
|
|
241
|
-
options
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
234
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
245
235
|
var u32 = (options = {}) => numberFactory({
|
|
246
236
|
name: "u32",
|
|
247
237
|
size: 4,
|
|
@@ -251,7 +241,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
251
241
|
options
|
|
252
242
|
});
|
|
253
243
|
|
|
254
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
244
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
255
245
|
var shortU16 = (options = {}) => ({
|
|
256
246
|
description: options.description ?? "shortU16",
|
|
257
247
|
fixedSize: null,
|
|
@@ -288,7 +278,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
288
278
|
}
|
|
289
279
|
});
|
|
290
280
|
|
|
291
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
281
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
|
|
292
282
|
var InvalidNumberOfItemsError = class extends Error {
|
|
293
283
|
constructor(serializer, expected, actual) {
|
|
294
284
|
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
@@ -308,12 +298,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
308
298
|
}
|
|
309
299
|
};
|
|
310
300
|
|
|
311
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
301
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
312
302
|
function sumSerializerSizes(sizes) {
|
|
313
303
|
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
314
304
|
}
|
|
315
305
|
|
|
316
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
306
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
317
307
|
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
318
308
|
if (typeof size === "number") {
|
|
319
309
|
return [size, offset];
|
|
@@ -349,7 +339,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
349
339
|
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
350
340
|
}
|
|
351
341
|
|
|
352
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
342
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
353
343
|
function array(item, options = {}) {
|
|
354
344
|
const size = options.size ?? u32();
|
|
355
345
|
if (size === "remainder" && item.fixedSize === null) {
|
|
@@ -382,7 +372,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
382
372
|
};
|
|
383
373
|
}
|
|
384
374
|
|
|
385
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
375
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
386
376
|
function bytes(options = {}) {
|
|
387
377
|
const size = options.size ?? "variable";
|
|
388
378
|
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
@@ -429,7 +419,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
429
419
|
};
|
|
430
420
|
}
|
|
431
421
|
|
|
432
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
422
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
433
423
|
function string(options = {}) {
|
|
434
424
|
const size = options.size ?? u32();
|
|
435
425
|
const encoding = options.encoding ?? utf8;
|
|
@@ -470,7 +460,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
470
460
|
};
|
|
471
461
|
}
|
|
472
462
|
|
|
473
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
463
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
474
464
|
function struct(fields, options = {}) {
|
|
475
465
|
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
476
466
|
return {
|
|
@@ -522,9 +512,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
522
512
|
if (numBytes !== 32) {
|
|
523
513
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
524
514
|
}
|
|
525
|
-
} catch (
|
|
515
|
+
} catch (e2) {
|
|
526
516
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
527
|
-
cause:
|
|
517
|
+
cause: e2
|
|
528
518
|
});
|
|
529
519
|
}
|
|
530
520
|
}
|
|
@@ -664,23 +654,390 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
664
654
|
Object.freeze(out);
|
|
665
655
|
return out;
|
|
666
656
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
657
|
+
|
|
658
|
+
// ../codecs-core/dist/index.browser.js
|
|
659
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes2, offset = 0) {
|
|
660
|
+
if (bytes2.length - offset <= 0) {
|
|
661
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
|
|
665
|
+
const bytesLength = bytes2.length - offset;
|
|
666
|
+
if (bytesLength < expected) {
|
|
667
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
var mergeBytes2 = (byteArrays) => {
|
|
671
|
+
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
672
|
+
if (nonEmptyByteArrays.length === 0) {
|
|
673
|
+
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
674
|
+
}
|
|
675
|
+
if (nonEmptyByteArrays.length === 1) {
|
|
676
|
+
return nonEmptyByteArrays[0];
|
|
677
|
+
}
|
|
678
|
+
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
679
|
+
const result = new Uint8Array(totalLength);
|
|
680
|
+
let offset = 0;
|
|
681
|
+
nonEmptyByteArrays.forEach((arr) => {
|
|
682
|
+
result.set(arr, offset);
|
|
683
|
+
offset += arr.length;
|
|
672
684
|
});
|
|
685
|
+
return result;
|
|
686
|
+
};
|
|
687
|
+
var padBytes2 = (bytes2, length) => {
|
|
688
|
+
if (bytes2.length >= length)
|
|
689
|
+
return bytes2;
|
|
690
|
+
const paddedBytes = new Uint8Array(length).fill(0);
|
|
691
|
+
paddedBytes.set(bytes2);
|
|
692
|
+
return paddedBytes;
|
|
693
|
+
};
|
|
694
|
+
var fixBytes2 = (bytes2, length) => padBytes2(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
|
|
695
|
+
function combineCodec(encoder, decoder, description) {
|
|
696
|
+
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
697
|
+
throw new Error(
|
|
698
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
if (encoder.maxSize !== decoder.maxSize) {
|
|
702
|
+
throw new Error(
|
|
703
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
if (description === void 0 && encoder.description !== decoder.description) {
|
|
707
|
+
throw new Error(
|
|
708
|
+
`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.`
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
decode: decoder.decode,
|
|
713
|
+
description: description ?? encoder.description,
|
|
714
|
+
encode: encoder.encode,
|
|
715
|
+
fixedSize: encoder.fixedSize,
|
|
716
|
+
maxSize: encoder.maxSize
|
|
717
|
+
};
|
|
673
718
|
}
|
|
674
|
-
function
|
|
675
|
-
return
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
719
|
+
function fixCodecHelper(data, fixedBytes, description) {
|
|
720
|
+
return {
|
|
721
|
+
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
722
|
+
fixedSize: fixedBytes,
|
|
723
|
+
maxSize: fixedBytes
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function fixEncoder(encoder, fixedBytes, description) {
|
|
727
|
+
return {
|
|
728
|
+
...fixCodecHelper(encoder, fixedBytes, description),
|
|
729
|
+
encode: (value) => fixBytes2(encoder.encode(value), fixedBytes)
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function fixDecoder(decoder, fixedBytes, description) {
|
|
733
|
+
return {
|
|
734
|
+
...fixCodecHelper(decoder, fixedBytes, description),
|
|
735
|
+
decode: (bytes2, offset = 0) => {
|
|
736
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes2, offset);
|
|
737
|
+
if (offset > 0 || bytes2.length > fixedBytes) {
|
|
738
|
+
bytes2 = bytes2.slice(offset, offset + fixedBytes);
|
|
739
|
+
}
|
|
740
|
+
if (decoder.fixedSize !== null) {
|
|
741
|
+
bytes2 = fixBytes2(bytes2, decoder.fixedSize);
|
|
742
|
+
}
|
|
743
|
+
const [value] = decoder.decode(bytes2, 0);
|
|
744
|
+
return [value, offset + fixedBytes];
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
function mapEncoder(encoder, unmap) {
|
|
749
|
+
return {
|
|
750
|
+
description: encoder.description,
|
|
751
|
+
encode: (value) => encoder.encode(unmap(value)),
|
|
752
|
+
fixedSize: encoder.fixedSize,
|
|
753
|
+
maxSize: encoder.maxSize
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
function mapDecoder(decoder, map) {
|
|
757
|
+
return {
|
|
758
|
+
decode: (bytes2, offset = 0) => {
|
|
759
|
+
const [value, length] = decoder.decode(bytes2, offset);
|
|
760
|
+
return [map(value, bytes2, offset), length];
|
|
761
|
+
},
|
|
762
|
+
description: decoder.description,
|
|
763
|
+
fixedSize: decoder.fixedSize,
|
|
764
|
+
maxSize: decoder.maxSize
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
769
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
770
|
+
if (value < min || value > max) {
|
|
771
|
+
throw new Error(
|
|
772
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function sharedNumberFactory(input) {
|
|
777
|
+
let littleEndian;
|
|
778
|
+
let defaultDescription = input.name;
|
|
779
|
+
if (input.size > 1) {
|
|
780
|
+
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
781
|
+
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
description: input.options.description ?? defaultDescription,
|
|
785
|
+
fixedSize: input.size,
|
|
786
|
+
littleEndian,
|
|
787
|
+
maxSize: input.size
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
function numberEncoderFactory(input) {
|
|
791
|
+
const codecData = sharedNumberFactory(input);
|
|
792
|
+
return {
|
|
793
|
+
description: codecData.description,
|
|
794
|
+
encode(value) {
|
|
795
|
+
if (input.range) {
|
|
796
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
797
|
+
}
|
|
798
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
799
|
+
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
|
|
800
|
+
return new Uint8Array(arrayBuffer);
|
|
801
|
+
},
|
|
802
|
+
fixedSize: codecData.fixedSize,
|
|
803
|
+
maxSize: codecData.maxSize
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
function numberDecoderFactory(input) {
|
|
807
|
+
const codecData = sharedNumberFactory(input);
|
|
808
|
+
return {
|
|
809
|
+
decode(bytes2, offset = 0) {
|
|
810
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
|
|
811
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
|
|
812
|
+
const view = new DataView(toArrayBuffer2(bytes2, offset, input.size));
|
|
813
|
+
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
814
|
+
},
|
|
815
|
+
description: codecData.description,
|
|
816
|
+
fixedSize: codecData.fixedSize,
|
|
817
|
+
maxSize: codecData.maxSize
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function toArrayBuffer2(bytes2, offset, length) {
|
|
821
|
+
const bytesOffset = bytes2.byteOffset + (offset ?? 0);
|
|
822
|
+
const bytesLength = length ?? bytes2.byteLength;
|
|
823
|
+
return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
824
|
+
}
|
|
825
|
+
var getShortU16Encoder = (options = {}) => ({
|
|
826
|
+
description: options.description ?? "shortU16",
|
|
827
|
+
encode: (value) => {
|
|
828
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
829
|
+
const bytes2 = [0];
|
|
830
|
+
for (let ii = 0; ; ii += 1) {
|
|
831
|
+
const alignedValue = value >> ii * 7;
|
|
832
|
+
if (alignedValue === 0) {
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
const nextSevenBits = 127 & alignedValue;
|
|
836
|
+
bytes2[ii] = nextSevenBits;
|
|
837
|
+
if (ii > 0) {
|
|
838
|
+
bytes2[ii - 1] |= 128;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return new Uint8Array(bytes2);
|
|
842
|
+
},
|
|
843
|
+
fixedSize: null,
|
|
844
|
+
maxSize: 3
|
|
845
|
+
});
|
|
846
|
+
var getShortU16Decoder = (options = {}) => ({
|
|
847
|
+
decode: (bytes2, offset = 0) => {
|
|
848
|
+
let value = 0;
|
|
849
|
+
let byteCount = 0;
|
|
850
|
+
while (++byteCount) {
|
|
851
|
+
const byteIndex = byteCount - 1;
|
|
852
|
+
const currentByte = bytes2[offset + byteIndex];
|
|
853
|
+
const nextSevenBits = 127 & currentByte;
|
|
854
|
+
value |= nextSevenBits << byteIndex * 7;
|
|
855
|
+
if ((currentByte & 128) === 0) {
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return [value, offset + byteCount];
|
|
860
|
+
},
|
|
861
|
+
description: options.description ?? "shortU16",
|
|
862
|
+
fixedSize: null,
|
|
863
|
+
maxSize: 3
|
|
864
|
+
});
|
|
865
|
+
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
866
|
+
name: "u32",
|
|
867
|
+
options,
|
|
868
|
+
range: [0, Number("0xffffffff")],
|
|
869
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
870
|
+
size: 4
|
|
871
|
+
});
|
|
872
|
+
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
873
|
+
get: (view, le) => view.getUint32(0, le),
|
|
874
|
+
name: "u32",
|
|
875
|
+
options,
|
|
876
|
+
size: 4
|
|
877
|
+
});
|
|
878
|
+
var getU8Encoder = (options = {}) => numberEncoderFactory({
|
|
879
|
+
name: "u8",
|
|
880
|
+
options,
|
|
881
|
+
range: [0, Number("0xff")],
|
|
882
|
+
set: (view, value) => view.setUint8(0, value),
|
|
883
|
+
size: 1
|
|
884
|
+
});
|
|
885
|
+
var getU8Decoder = (options = {}) => numberDecoderFactory({
|
|
886
|
+
get: (view) => view.getUint8(0),
|
|
887
|
+
name: "u8",
|
|
888
|
+
options,
|
|
889
|
+
size: 1
|
|
890
|
+
});
|
|
891
|
+
var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
|
|
892
|
+
|
|
893
|
+
// ../codecs-strings/dist/index.browser.js
|
|
894
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
895
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
896
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
900
|
+
const base = alphabet4.length;
|
|
901
|
+
const baseBigInt = BigInt(base);
|
|
902
|
+
return {
|
|
903
|
+
description: `base${base}`,
|
|
904
|
+
encode(value) {
|
|
905
|
+
assertValidBaseString(alphabet4, value);
|
|
906
|
+
if (value === "")
|
|
907
|
+
return new Uint8Array();
|
|
908
|
+
const chars = [...value];
|
|
909
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
910
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
911
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
912
|
+
if (trailIndex === chars.length)
|
|
913
|
+
return Uint8Array.from(leadingZeroes);
|
|
914
|
+
const tailChars = chars.slice(trailIndex);
|
|
915
|
+
let base10Number = 0n;
|
|
916
|
+
let baseXPower = 1n;
|
|
917
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
918
|
+
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
919
|
+
baseXPower *= baseBigInt;
|
|
920
|
+
}
|
|
921
|
+
const tailBytes = [];
|
|
922
|
+
while (base10Number > 0n) {
|
|
923
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
924
|
+
base10Number /= 256n;
|
|
925
|
+
}
|
|
926
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
927
|
+
},
|
|
928
|
+
fixedSize: null,
|
|
929
|
+
maxSize: null
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
933
|
+
const base = alphabet4.length;
|
|
934
|
+
const baseBigInt = BigInt(base);
|
|
935
|
+
return {
|
|
936
|
+
decode(rawBytes, offset = 0) {
|
|
937
|
+
const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
938
|
+
if (bytes2.length === 0)
|
|
939
|
+
return ["", 0];
|
|
940
|
+
let trailIndex = bytes2.findIndex((n) => n !== 0);
|
|
941
|
+
trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
|
|
942
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
943
|
+
if (trailIndex === bytes2.length)
|
|
944
|
+
return [leadingZeroes, rawBytes.length];
|
|
945
|
+
let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
946
|
+
const tailChars = [];
|
|
947
|
+
while (base10Number > 0n) {
|
|
948
|
+
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
949
|
+
base10Number /= baseBigInt;
|
|
950
|
+
}
|
|
951
|
+
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
952
|
+
},
|
|
953
|
+
description: `base${base}`,
|
|
954
|
+
fixedSize: null,
|
|
955
|
+
maxSize: null
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
959
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
960
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
961
|
+
var removeNullCharacters2 = (value) => (
|
|
962
|
+
// eslint-disable-next-line no-control-regex
|
|
963
|
+
value.replace(/\u0000/g, "")
|
|
964
|
+
);
|
|
965
|
+
var e = globalThis.TextDecoder;
|
|
966
|
+
var o = globalThis.TextEncoder;
|
|
967
|
+
var getUtf8Encoder = () => {
|
|
968
|
+
let textEncoder;
|
|
969
|
+
return {
|
|
970
|
+
description: "utf8",
|
|
971
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
972
|
+
fixedSize: null,
|
|
973
|
+
maxSize: null
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
var getUtf8Decoder = () => {
|
|
977
|
+
let textDecoder;
|
|
978
|
+
return {
|
|
979
|
+
decode(bytes2, offset = 0) {
|
|
980
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes2.slice(offset));
|
|
981
|
+
return [removeNullCharacters2(value), bytes2.length];
|
|
982
|
+
},
|
|
983
|
+
description: "utf8",
|
|
984
|
+
fixedSize: null,
|
|
985
|
+
maxSize: null
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
var getStringEncoder = (options = {}) => {
|
|
989
|
+
const size = options.size ?? getU32Encoder();
|
|
990
|
+
const encoding = options.encoding ?? getUtf8Encoder();
|
|
991
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
992
|
+
if (size === "variable") {
|
|
993
|
+
return { ...encoding, description };
|
|
994
|
+
}
|
|
995
|
+
if (typeof size === "number") {
|
|
996
|
+
return fixEncoder(encoding, size, description);
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
description,
|
|
1000
|
+
encode: (value) => {
|
|
1001
|
+
const contentBytes = encoding.encode(value);
|
|
1002
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
1003
|
+
return mergeBytes2([lengthBytes, contentBytes]);
|
|
1004
|
+
},
|
|
1005
|
+
fixedSize: null,
|
|
1006
|
+
maxSize: null
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
var getStringDecoder = (options = {}) => {
|
|
1010
|
+
const size = options.size ?? getU32Decoder();
|
|
1011
|
+
const encoding = options.encoding ?? getUtf8Decoder();
|
|
1012
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
1013
|
+
if (size === "variable") {
|
|
1014
|
+
return { ...encoding, description };
|
|
1015
|
+
}
|
|
1016
|
+
if (typeof size === "number") {
|
|
1017
|
+
return fixDecoder(encoding, size, description);
|
|
1018
|
+
}
|
|
1019
|
+
return {
|
|
1020
|
+
decode: (bytes2, offset = 0) => {
|
|
1021
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes2, offset);
|
|
1022
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
|
|
1023
|
+
const length = Number(lengthBigInt);
|
|
1024
|
+
offset = lengthOffset;
|
|
1025
|
+
const contentBytes = bytes2.slice(offset, offset + length);
|
|
1026
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
1027
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
1028
|
+
offset += contentOffset;
|
|
1029
|
+
return [value, offset];
|
|
1030
|
+
},
|
|
1031
|
+
description,
|
|
1032
|
+
fixedSize: null,
|
|
1033
|
+
maxSize: null
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1036
|
+
function getSizeDescription2(size) {
|
|
1037
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
683
1038
|
}
|
|
1039
|
+
|
|
1040
|
+
// ../assertions/dist/index.browser.js
|
|
684
1041
|
function assertIsSecureContext() {
|
|
685
1042
|
if (!globalThis.isSecureContext) {
|
|
686
1043
|
throw new Error(
|
|
@@ -700,24 +1057,88 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
700
1057
|
throw new Error("No signing implementation could be found");
|
|
701
1058
|
}
|
|
702
1059
|
}
|
|
703
|
-
|
|
1060
|
+
|
|
1061
|
+
// ../addresses/dist/index.browser.js
|
|
1062
|
+
var memoizedBase58Encoder;
|
|
1063
|
+
var memoizedBase58Decoder;
|
|
1064
|
+
function getMemoizedBase58Encoder() {
|
|
1065
|
+
if (!memoizedBase58Encoder)
|
|
1066
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
1067
|
+
return memoizedBase58Encoder;
|
|
1068
|
+
}
|
|
1069
|
+
function getMemoizedBase58Decoder() {
|
|
1070
|
+
if (!memoizedBase58Decoder)
|
|
1071
|
+
memoizedBase58Decoder = getBase58Decoder();
|
|
1072
|
+
return memoizedBase58Decoder;
|
|
1073
|
+
}
|
|
1074
|
+
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
1075
|
+
try {
|
|
1076
|
+
if (
|
|
1077
|
+
// Lowest address (32 bytes of zeroes)
|
|
1078
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
1079
|
+
putativeBase58EncodedAddress.length > 44
|
|
1080
|
+
) {
|
|
1081
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1082
|
+
}
|
|
1083
|
+
const base58Encoder = getMemoizedBase58Encoder();
|
|
1084
|
+
const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
1085
|
+
const numBytes = bytes2.byteLength;
|
|
1086
|
+
if (numBytes !== 32) {
|
|
1087
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1088
|
+
}
|
|
1089
|
+
} catch (e2) {
|
|
1090
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
1091
|
+
cause: e2
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
function address(putativeBase58EncodedAddress) {
|
|
1096
|
+
assertIsAddress(putativeBase58EncodedAddress);
|
|
1097
|
+
return putativeBase58EncodedAddress;
|
|
1098
|
+
}
|
|
1099
|
+
function getAddressEncoder(config) {
|
|
1100
|
+
return mapEncoder(
|
|
1101
|
+
getStringEncoder({
|
|
1102
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
1103
|
+
encoding: getMemoizedBase58Encoder(),
|
|
1104
|
+
size: 32
|
|
1105
|
+
}),
|
|
1106
|
+
(putativeAddress) => address(putativeAddress)
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
function getAddressDecoder(config) {
|
|
1110
|
+
return getStringDecoder({
|
|
1111
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
1112
|
+
encoding: getMemoizedBase58Decoder(),
|
|
1113
|
+
size: 32
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
function getAddressCodec(config) {
|
|
1117
|
+
return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
|
|
1118
|
+
}
|
|
1119
|
+
function getAddressComparator() {
|
|
1120
|
+
return new Intl.Collator("en", {
|
|
1121
|
+
caseFirst: "lower",
|
|
1122
|
+
ignorePunctuation: false,
|
|
1123
|
+
localeMatcher: "best fit",
|
|
1124
|
+
numeric: false,
|
|
1125
|
+
sensitivity: "variant",
|
|
1126
|
+
usage: "sort"
|
|
1127
|
+
}).compare;
|
|
1128
|
+
}
|
|
1129
|
+
async function getAddressFromPublicKey(publicKey) {
|
|
704
1130
|
await assertKeyExporterIsAvailable();
|
|
705
1131
|
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
706
1132
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
707
1133
|
}
|
|
708
1134
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
709
|
-
const [base58EncodedAddress] =
|
|
1135
|
+
const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
710
1136
|
return base58EncodedAddress;
|
|
711
1137
|
}
|
|
712
|
-
async function signBytes(key, data) {
|
|
713
|
-
await assertSigningCapabilityIsAvailable();
|
|
714
|
-
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
715
|
-
return new Uint8Array(signedData);
|
|
716
|
-
}
|
|
717
1138
|
|
|
718
1139
|
// src/accounts.ts
|
|
719
|
-
function upsert(addressMap,
|
|
720
|
-
addressMap[
|
|
1140
|
+
function upsert(addressMap, address2, update) {
|
|
1141
|
+
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
|
|
721
1142
|
}
|
|
722
1143
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
723
1144
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -768,7 +1189,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
768
1189
|
const shouldReplaceEntry = (
|
|
769
1190
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
770
1191
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
771
|
-
(addressComparator || (addressComparator =
|
|
1192
|
+
(addressComparator || (addressComparator = getAddressComparator()))(
|
|
772
1193
|
accountMeta.lookupTableAddress,
|
|
773
1194
|
entry.lookupTableAddress
|
|
774
1195
|
) < 0
|
|
@@ -874,14 +1295,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
874
1295
|
if (leftIsWritable !== isWritableRole(rightEntry.role)) {
|
|
875
1296
|
return leftIsWritable ? -1 : 1;
|
|
876
1297
|
}
|
|
877
|
-
addressComparator || (addressComparator =
|
|
1298
|
+
addressComparator || (addressComparator = getAddressComparator());
|
|
878
1299
|
if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
879
1300
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
880
1301
|
} else {
|
|
881
1302
|
return addressComparator(leftAddress, rightAddress);
|
|
882
1303
|
}
|
|
883
|
-
}).map(([
|
|
884
|
-
address,
|
|
1304
|
+
}).map(([address2, addressMeta]) => ({
|
|
1305
|
+
address: address2,
|
|
885
1306
|
...addressMeta
|
|
886
1307
|
}));
|
|
887
1308
|
return orderedAccounts;
|
|
@@ -905,7 +1326,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
905
1326
|
entry.readableIndices.push(account.addressIndex);
|
|
906
1327
|
}
|
|
907
1328
|
}
|
|
908
|
-
return Object.keys(index).sort(
|
|
1329
|
+
return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
|
|
909
1330
|
lookupTableAddress,
|
|
910
1331
|
...index[lookupTableAddress]
|
|
911
1332
|
}));
|
|
@@ -950,7 +1371,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
950
1371
|
return instructions.map(({ accounts, data, programAddress }) => {
|
|
951
1372
|
return {
|
|
952
1373
|
programAddressIndex: accountIndex[programAddress],
|
|
953
|
-
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[
|
|
1374
|
+
...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
|
|
954
1375
|
...data ? { data } : null
|
|
955
1376
|
};
|
|
956
1377
|
});
|
|
@@ -968,7 +1389,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
968
1389
|
function getCompiledStaticAccounts(orderedAccounts) {
|
|
969
1390
|
const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
|
|
970
1391
|
const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
|
|
971
|
-
return orderedStaticAccounts.map(({ address }) =>
|
|
1392
|
+
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
|
972
1393
|
}
|
|
973
1394
|
|
|
974
1395
|
// src/message.ts
|
|
@@ -985,145 +1406,365 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
985
1406
|
};
|
|
986
1407
|
}
|
|
987
1408
|
|
|
1409
|
+
// src/compile-transaction.ts
|
|
1410
|
+
function getCompiledTransaction(transaction) {
|
|
1411
|
+
const compiledMessage = compileMessage(transaction);
|
|
1412
|
+
let signatures;
|
|
1413
|
+
if ("signatures" in transaction) {
|
|
1414
|
+
signatures = [];
|
|
1415
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1416
|
+
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1417
|
+
}
|
|
1418
|
+
} else {
|
|
1419
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1420
|
+
}
|
|
1421
|
+
return {
|
|
1422
|
+
compiledMessage,
|
|
1423
|
+
signatures
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
1428
|
+
function sumCodecSizes(sizes) {
|
|
1429
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
1430
|
+
}
|
|
1431
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes2, offset) {
|
|
1432
|
+
if (typeof size === "number") {
|
|
1433
|
+
return [size, offset];
|
|
1434
|
+
}
|
|
1435
|
+
if (typeof size === "object") {
|
|
1436
|
+
return size.decode(bytes2, offset);
|
|
1437
|
+
}
|
|
1438
|
+
if (size === "remainder") {
|
|
1439
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1440
|
+
if (childrenSize === null) {
|
|
1441
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1442
|
+
}
|
|
1443
|
+
const remainder = bytes2.slice(offset).length;
|
|
1444
|
+
if (remainder % childrenSize !== 0) {
|
|
1445
|
+
throw new Error(
|
|
1446
|
+
`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.`
|
|
1447
|
+
);
|
|
1448
|
+
}
|
|
1449
|
+
return [remainder / childrenSize, offset];
|
|
1450
|
+
}
|
|
1451
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1452
|
+
}
|
|
1453
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
1454
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
1455
|
+
}
|
|
1456
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
1457
|
+
if (typeof size !== "number")
|
|
1458
|
+
return null;
|
|
1459
|
+
if (size === 0)
|
|
1460
|
+
return 0;
|
|
1461
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1462
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
1463
|
+
}
|
|
1464
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
1465
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
1466
|
+
}
|
|
1467
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1468
|
+
if (expected !== actual) {
|
|
1469
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
function arrayCodecHelper(item, size, description) {
|
|
1473
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
1474
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1475
|
+
}
|
|
1476
|
+
return {
|
|
1477
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1478
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1479
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
function getArrayEncoder(item, options = {}) {
|
|
1483
|
+
const size = options.size ?? getU32Encoder();
|
|
1484
|
+
return {
|
|
1485
|
+
...arrayCodecHelper(item, size, options.description),
|
|
1486
|
+
encode: (value) => {
|
|
1487
|
+
if (typeof size === "number") {
|
|
1488
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
1489
|
+
}
|
|
1490
|
+
return mergeBytes2([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
function getArrayDecoder(item, options = {}) {
|
|
1495
|
+
const size = options.size ?? getU32Decoder();
|
|
1496
|
+
return {
|
|
1497
|
+
...arrayCodecHelper(item, size, options.description),
|
|
1498
|
+
decode: (bytes2, offset = 0) => {
|
|
1499
|
+
if (typeof size === "object" && bytes2.slice(offset).length === 0) {
|
|
1500
|
+
return [[], offset];
|
|
1501
|
+
}
|
|
1502
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes2, offset);
|
|
1503
|
+
offset = newOffset;
|
|
1504
|
+
const values = [];
|
|
1505
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1506
|
+
const [value, newOffset2] = item.decode(bytes2, offset);
|
|
1507
|
+
values.push(value);
|
|
1508
|
+
offset = newOffset2;
|
|
1509
|
+
}
|
|
1510
|
+
return [values, offset];
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
function getBytesEncoder(options = {}) {
|
|
1515
|
+
const size = options.size ?? "variable";
|
|
1516
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1517
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
1518
|
+
const byteEncoder = {
|
|
1519
|
+
description,
|
|
1520
|
+
encode: (value) => value,
|
|
1521
|
+
fixedSize: null,
|
|
1522
|
+
maxSize: null
|
|
1523
|
+
};
|
|
1524
|
+
if (size === "variable") {
|
|
1525
|
+
return byteEncoder;
|
|
1526
|
+
}
|
|
1527
|
+
if (typeof size === "number") {
|
|
1528
|
+
return fixEncoder(byteEncoder, size, description);
|
|
1529
|
+
}
|
|
1530
|
+
return {
|
|
1531
|
+
...byteEncoder,
|
|
1532
|
+
encode: (value) => {
|
|
1533
|
+
const contentBytes = byteEncoder.encode(value);
|
|
1534
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
1535
|
+
return mergeBytes2([lengthBytes, contentBytes]);
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
function getBytesDecoder(options = {}) {
|
|
1540
|
+
const size = options.size ?? "variable";
|
|
1541
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1542
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
1543
|
+
const byteDecoder = {
|
|
1544
|
+
decode: (bytes2, offset = 0) => {
|
|
1545
|
+
const slice = bytes2.slice(offset);
|
|
1546
|
+
return [slice, offset + slice.length];
|
|
1547
|
+
},
|
|
1548
|
+
description,
|
|
1549
|
+
fixedSize: null,
|
|
1550
|
+
maxSize: null
|
|
1551
|
+
};
|
|
1552
|
+
if (size === "variable") {
|
|
1553
|
+
return byteDecoder;
|
|
1554
|
+
}
|
|
1555
|
+
if (typeof size === "number") {
|
|
1556
|
+
return fixDecoder(byteDecoder, size, description);
|
|
1557
|
+
}
|
|
1558
|
+
return {
|
|
1559
|
+
...byteDecoder,
|
|
1560
|
+
decode: (bytes2, offset = 0) => {
|
|
1561
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes2, offset);
|
|
1562
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
|
|
1563
|
+
const length = Number(lengthBigInt);
|
|
1564
|
+
offset = lengthOffset;
|
|
1565
|
+
const contentBytes = bytes2.slice(offset, offset + length);
|
|
1566
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1567
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
1568
|
+
offset += contentOffset;
|
|
1569
|
+
return [value, offset];
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
function structCodecHelper(fields, description) {
|
|
1574
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
1575
|
+
return {
|
|
1576
|
+
description: description ?? `struct(${fieldDescriptions})`,
|
|
1577
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
1578
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
function getStructEncoder(fields, options = {}) {
|
|
1582
|
+
return {
|
|
1583
|
+
...structCodecHelper(fields, options.description),
|
|
1584
|
+
encode: (struct2) => {
|
|
1585
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
|
|
1586
|
+
return mergeBytes2(fieldBytes);
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
function getStructDecoder(fields, options = {}) {
|
|
1591
|
+
return {
|
|
1592
|
+
...structCodecHelper(fields, options.description),
|
|
1593
|
+
decode: (bytes2, offset = 0) => {
|
|
1594
|
+
const struct2 = {};
|
|
1595
|
+
fields.forEach(([key, codec]) => {
|
|
1596
|
+
const [value, newOffset] = codec.decode(bytes2, offset);
|
|
1597
|
+
offset = newOffset;
|
|
1598
|
+
struct2[key] = value;
|
|
1599
|
+
});
|
|
1600
|
+
return [struct2, offset];
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
function getStructCodec(fields, options = {}) {
|
|
1605
|
+
return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
|
|
1606
|
+
}
|
|
1607
|
+
|
|
988
1608
|
// src/serializers/address-table-lookup.ts
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1609
|
+
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
1610
|
+
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
1611
|
+
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
1612
|
+
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" ;
|
|
1613
|
+
var memoizedAddressTableLookupEncoder;
|
|
1614
|
+
function getAddressTableLookupEncoder() {
|
|
1615
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
1616
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
992
1617
|
[
|
|
993
|
-
"lookupTableAddress",
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1618
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
1619
|
+
[
|
|
1620
|
+
"writableIndices",
|
|
1621
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1622
|
+
description: writableIndicesDescription,
|
|
1623
|
+
size: getShortU16Encoder()
|
|
1624
|
+
})
|
|
1625
|
+
],
|
|
1626
|
+
[
|
|
1627
|
+
"readableIndices",
|
|
1628
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1629
|
+
description: readableIndicesDescription,
|
|
1630
|
+
size: getShortU16Encoder()
|
|
1631
|
+
})
|
|
1632
|
+
]
|
|
999
1633
|
],
|
|
1634
|
+
{ description: addressTableLookupDescription }
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
return memoizedAddressTableLookupEncoder;
|
|
1638
|
+
}
|
|
1639
|
+
var memoizedAddressTableLookupDecoder;
|
|
1640
|
+
function getAddressTableLookupDecoder() {
|
|
1641
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
1642
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1000
1643
|
[
|
|
1001
|
-
"
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1644
|
+
["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
|
|
1645
|
+
[
|
|
1646
|
+
"writableIndices",
|
|
1647
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1648
|
+
description: writableIndicesDescription,
|
|
1649
|
+
size: getShortU16Decoder()
|
|
1650
|
+
})
|
|
1651
|
+
],
|
|
1652
|
+
[
|
|
1653
|
+
"readableIndices",
|
|
1654
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1655
|
+
description: readableIndicesDescription,
|
|
1656
|
+
size: getShortU16Decoder()
|
|
1657
|
+
})
|
|
1658
|
+
]
|
|
1008
1659
|
],
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
})
|
|
1017
|
-
]
|
|
1018
|
-
],
|
|
1019
|
-
{
|
|
1020
|
-
description: "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"
|
|
1021
|
-
}
|
|
1022
|
-
);
|
|
1660
|
+
{ description: addressTableLookupDescription }
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
return memoizedAddressTableLookupDecoder;
|
|
1664
|
+
}
|
|
1665
|
+
function getAddressTableLookupCodec() {
|
|
1666
|
+
return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
|
|
1023
1667
|
}
|
|
1024
1668
|
|
|
1025
1669
|
// src/serializers/header.ts
|
|
1670
|
+
var memoizedU8Codec;
|
|
1671
|
+
function getMemoizedU8Codec() {
|
|
1672
|
+
if (!memoizedU8Codec)
|
|
1673
|
+
memoizedU8Codec = getU8Codec();
|
|
1674
|
+
return memoizedU8Codec;
|
|
1675
|
+
}
|
|
1676
|
+
function getMemoizedU8CodecDescription(description) {
|
|
1677
|
+
const codec = getMemoizedU8Codec();
|
|
1678
|
+
return {
|
|
1679
|
+
...codec,
|
|
1680
|
+
description: description ?? codec.description
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
1684
|
+
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" ;
|
|
1685
|
+
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
1686
|
+
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1026
1687
|
function getMessageHeaderCodec() {
|
|
1027
|
-
return
|
|
1688
|
+
return getStructCodec(
|
|
1028
1689
|
[
|
|
1029
|
-
[
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
{
|
|
1033
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
|
|
1034
|
-
}
|
|
1035
|
-
)
|
|
1036
|
-
],
|
|
1037
|
-
[
|
|
1038
|
-
"numReadonlySignerAccounts",
|
|
1039
|
-
u8(
|
|
1040
|
-
{
|
|
1041
|
-
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"
|
|
1042
|
-
}
|
|
1043
|
-
)
|
|
1044
|
-
],
|
|
1045
|
-
[
|
|
1046
|
-
"numReadonlyNonSignerAccounts",
|
|
1047
|
-
u8(
|
|
1048
|
-
{
|
|
1049
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
1050
|
-
}
|
|
1051
|
-
)
|
|
1052
|
-
]
|
|
1690
|
+
["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
|
|
1691
|
+
["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
|
|
1692
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1053
1693
|
],
|
|
1054
1694
|
{
|
|
1055
|
-
description:
|
|
1056
|
-
}
|
|
1695
|
+
description: messageHeaderDescription
|
|
1696
|
+
}
|
|
1057
1697
|
);
|
|
1058
1698
|
}
|
|
1059
1699
|
|
|
1060
1700
|
// src/serializers/instruction.ts
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
)
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
)
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
]
|
|
1091
|
-
]),
|
|
1092
|
-
(value) => {
|
|
1093
|
-
if (value.addressIndices !== void 0 && value.data !== void 0) {
|
|
1094
|
-
return value;
|
|
1095
|
-
}
|
|
1096
|
-
return {
|
|
1097
|
-
...value,
|
|
1098
|
-
addressIndices: value.addressIndices ?? [],
|
|
1099
|
-
data: value.data ?? new Uint8Array(0)
|
|
1100
|
-
};
|
|
1101
|
-
},
|
|
1102
|
-
(value) => {
|
|
1103
|
-
if (value.addressIndices.length && value.data.byteLength) {
|
|
1104
|
-
return value;
|
|
1701
|
+
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
1702
|
+
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
1703
|
+
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" ;
|
|
1704
|
+
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
1705
|
+
var memoizedGetInstructionEncoder;
|
|
1706
|
+
function getInstructionEncoder() {
|
|
1707
|
+
if (!memoizedGetInstructionEncoder) {
|
|
1708
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
1709
|
+
getStructEncoder([
|
|
1710
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
1711
|
+
[
|
|
1712
|
+
"accountIndices",
|
|
1713
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
1714
|
+
description: accountIndicesDescription,
|
|
1715
|
+
size: getShortU16Encoder()
|
|
1716
|
+
})
|
|
1717
|
+
],
|
|
1718
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
1719
|
+
]),
|
|
1720
|
+
// Convert an instruction to have all fields defined
|
|
1721
|
+
(instruction) => {
|
|
1722
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1723
|
+
return instruction;
|
|
1724
|
+
}
|
|
1725
|
+
return {
|
|
1726
|
+
...instruction,
|
|
1727
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
1728
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
1729
|
+
};
|
|
1105
1730
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
...addressIndices.length ? { addressIndices } : null,
|
|
1110
|
-
...data.byteLength ? { data } : null
|
|
1111
|
-
};
|
|
1112
|
-
}
|
|
1113
|
-
);
|
|
1731
|
+
);
|
|
1732
|
+
}
|
|
1733
|
+
return memoizedGetInstructionEncoder;
|
|
1114
1734
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1735
|
+
var memoizedGetInstructionDecoder;
|
|
1736
|
+
function getInstructionDecoder() {
|
|
1737
|
+
if (!memoizedGetInstructionDecoder) {
|
|
1738
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
1739
|
+
getStructDecoder([
|
|
1740
|
+
["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
|
|
1741
|
+
[
|
|
1742
|
+
"accountIndices",
|
|
1743
|
+
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
1744
|
+
description: accountIndicesDescription,
|
|
1745
|
+
size: getShortU16Decoder()
|
|
1746
|
+
})
|
|
1747
|
+
],
|
|
1748
|
+
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
1749
|
+
]),
|
|
1750
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
1751
|
+
(instruction) => {
|
|
1752
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
1753
|
+
return instruction;
|
|
1754
|
+
}
|
|
1755
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
1756
|
+
return {
|
|
1757
|
+
...rest,
|
|
1758
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1759
|
+
...data.byteLength ? { data } : null
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
return memoizedGetInstructionDecoder;
|
|
1122
1765
|
}
|
|
1123
|
-
function
|
|
1124
|
-
return ()
|
|
1125
|
-
throw getError("decoder", name);
|
|
1126
|
-
};
|
|
1766
|
+
function getInstructionCodec() {
|
|
1767
|
+
return combineCodec(getInstructionEncoder(), getInstructionDecoder());
|
|
1127
1768
|
}
|
|
1128
1769
|
|
|
1129
1770
|
// src/serializers/transaction-version.ts
|
|
@@ -1133,7 +1774,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1133
1774
|
fixedSize: null,
|
|
1134
1775
|
maxSize: 1
|
|
1135
1776
|
};
|
|
1136
|
-
function
|
|
1777
|
+
function decode(bytes2, offset = 0) {
|
|
1137
1778
|
const firstByte = bytes2[offset];
|
|
1138
1779
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1139
1780
|
return ["legacy", offset];
|
|
@@ -1142,7 +1783,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1142
1783
|
return [version, offset + 1];
|
|
1143
1784
|
}
|
|
1144
1785
|
}
|
|
1145
|
-
function
|
|
1786
|
+
function encode(value) {
|
|
1146
1787
|
if (value === "legacy") {
|
|
1147
1788
|
return new Uint8Array();
|
|
1148
1789
|
}
|
|
@@ -1151,11 +1792,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1151
1792
|
}
|
|
1152
1793
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1153
1794
|
}
|
|
1154
|
-
function
|
|
1795
|
+
function getTransactionVersionDecoder() {
|
|
1155
1796
|
return {
|
|
1156
1797
|
...BASE_CONFIG,
|
|
1157
|
-
|
|
1158
|
-
|
|
1798
|
+
decode
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
function getTransactionVersionEncoder() {
|
|
1802
|
+
return {
|
|
1803
|
+
...BASE_CONFIG,
|
|
1804
|
+
encode
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
function getTransactionVersionCodec() {
|
|
1808
|
+
return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// src/serializers/unimplemented.ts
|
|
1812
|
+
function getError(type, name) {
|
|
1813
|
+
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
1814
|
+
return new Error(
|
|
1815
|
+
`No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
function getUnimplementedDecoder(name) {
|
|
1819
|
+
return () => {
|
|
1820
|
+
throw getError("decoder", name);
|
|
1159
1821
|
};
|
|
1160
1822
|
}
|
|
1161
1823
|
|
|
@@ -1165,7 +1827,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1165
1827
|
fixedSize: null,
|
|
1166
1828
|
maxSize: null
|
|
1167
1829
|
};
|
|
1168
|
-
function
|
|
1830
|
+
function serialize(compiledMessage) {
|
|
1169
1831
|
if (compiledMessage.version === "legacy") {
|
|
1170
1832
|
return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
|
|
1171
1833
|
} else {
|
|
@@ -1186,13 +1848,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1186
1848
|
).serialize(compiledMessage);
|
|
1187
1849
|
}
|
|
1188
1850
|
}
|
|
1851
|
+
function toSerializer(codec) {
|
|
1852
|
+
return {
|
|
1853
|
+
description: codec.description,
|
|
1854
|
+
deserialize: codec.decode,
|
|
1855
|
+
fixedSize: codec.fixedSize,
|
|
1856
|
+
maxSize: codec.maxSize,
|
|
1857
|
+
serialize: codec.encode
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1189
1860
|
function getPreludeStructSerializerTuple() {
|
|
1190
1861
|
return [
|
|
1191
|
-
["version", getTransactionVersionCodec()],
|
|
1192
|
-
["header", getMessageHeaderCodec()],
|
|
1862
|
+
["version", toSerializer(getTransactionVersionCodec())],
|
|
1863
|
+
["header", toSerializer(getMessageHeaderCodec())],
|
|
1193
1864
|
[
|
|
1194
1865
|
"staticAccounts",
|
|
1195
|
-
array(
|
|
1866
|
+
array(toSerializer(getAddressCodec()), {
|
|
1196
1867
|
description: "A compact-array of static account addresses belonging to this transaction" ,
|
|
1197
1868
|
size: shortU16()
|
|
1198
1869
|
})
|
|
@@ -1207,7 +1878,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1207
1878
|
],
|
|
1208
1879
|
[
|
|
1209
1880
|
"instructions",
|
|
1210
|
-
array(getInstructionCodec(), {
|
|
1881
|
+
array(toSerializer(getInstructionCodec()), {
|
|
1211
1882
|
description: "A compact-array of instructions belonging to this transaction" ,
|
|
1212
1883
|
size: shortU16()
|
|
1213
1884
|
})
|
|
@@ -1215,7 +1886,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1215
1886
|
];
|
|
1216
1887
|
}
|
|
1217
1888
|
function getAddressTableLookupsSerializer() {
|
|
1218
|
-
return array(getAddressTableLookupCodec(), {
|
|
1889
|
+
return array(toSerializer(getAddressTableLookupCodec()), {
|
|
1219
1890
|
...{ description: "A compact array of address table lookups belonging to this transaction" } ,
|
|
1220
1891
|
size: shortU16()
|
|
1221
1892
|
});
|
|
@@ -1224,49 +1895,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1224
1895
|
return {
|
|
1225
1896
|
...BASE_CONFIG2,
|
|
1226
1897
|
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1227
|
-
serialize
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
// src/signatures.ts
|
|
1232
|
-
async function getCompiledMessageSignature(message, secretKey) {
|
|
1233
|
-
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1234
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1235
|
-
return signature;
|
|
1236
|
-
}
|
|
1237
|
-
async function signTransaction(keyPair, transaction) {
|
|
1238
|
-
const compiledMessage = compileMessage(transaction);
|
|
1239
|
-
const [signerPublicKey, signature] = await Promise.all([
|
|
1240
|
-
getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
|
|
1241
|
-
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1242
|
-
]);
|
|
1243
|
-
const nextSignatures = {
|
|
1244
|
-
..."signatures" in transaction ? transaction.signatures : null,
|
|
1245
|
-
...{ [signerPublicKey]: signature }
|
|
1246
|
-
};
|
|
1247
|
-
const out = {
|
|
1248
|
-
...transaction,
|
|
1249
|
-
signatures: nextSignatures
|
|
1250
|
-
};
|
|
1251
|
-
Object.freeze(out);
|
|
1252
|
-
return out;
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
// src/compile-transaction.ts
|
|
1256
|
-
function getCompiledTransaction(transaction) {
|
|
1257
|
-
const compiledMessage = compileMessage(transaction);
|
|
1258
|
-
let signatures;
|
|
1259
|
-
if ("signatures" in transaction) {
|
|
1260
|
-
signatures = [];
|
|
1261
|
-
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1262
|
-
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1263
|
-
}
|
|
1264
|
-
} else {
|
|
1265
|
-
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1266
|
-
}
|
|
1267
|
-
return {
|
|
1268
|
-
compiledMessage,
|
|
1269
|
-
signatures
|
|
1898
|
+
serialize
|
|
1270
1899
|
};
|
|
1271
1900
|
}
|
|
1272
1901
|
|
|
@@ -1276,7 +1905,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1276
1905
|
fixedSize: null,
|
|
1277
1906
|
maxSize: null
|
|
1278
1907
|
};
|
|
1279
|
-
function
|
|
1908
|
+
function serialize2(transaction) {
|
|
1280
1909
|
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1281
1910
|
return struct([
|
|
1282
1911
|
[
|
|
@@ -1293,10 +1922,94 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1293
1922
|
return {
|
|
1294
1923
|
...BASE_CONFIG3,
|
|
1295
1924
|
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1296
|
-
serialize:
|
|
1925
|
+
serialize: serialize2
|
|
1297
1926
|
};
|
|
1298
1927
|
}
|
|
1299
1928
|
|
|
1929
|
+
// ../keys/dist/index.browser.js
|
|
1930
|
+
async function signBytes(key, data) {
|
|
1931
|
+
await assertSigningCapabilityIsAvailable();
|
|
1932
|
+
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
1933
|
+
return new Uint8Array(signedData);
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
// src/signatures.ts
|
|
1937
|
+
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
1938
|
+
try {
|
|
1939
|
+
if (
|
|
1940
|
+
// Lowest value (64 bytes of zeroes)
|
|
1941
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1942
|
+
putativeTransactionSignature.length > 88
|
|
1943
|
+
) {
|
|
1944
|
+
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1945
|
+
}
|
|
1946
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1947
|
+
const numBytes = bytes2.byteLength;
|
|
1948
|
+
if (numBytes !== 64) {
|
|
1949
|
+
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1950
|
+
}
|
|
1951
|
+
} catch (e2) {
|
|
1952
|
+
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1953
|
+
cause: e2
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
function isTransactionSignature(putativeTransactionSignature) {
|
|
1958
|
+
if (
|
|
1959
|
+
// Lowest value (64 bytes of zeroes)
|
|
1960
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1961
|
+
putativeTransactionSignature.length > 88
|
|
1962
|
+
) {
|
|
1963
|
+
return false;
|
|
1964
|
+
}
|
|
1965
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1966
|
+
const numBytes = bytes2.byteLength;
|
|
1967
|
+
if (numBytes !== 64) {
|
|
1968
|
+
return false;
|
|
1969
|
+
}
|
|
1970
|
+
return true;
|
|
1971
|
+
}
|
|
1972
|
+
async function getCompiledMessageSignature(message, secretKey) {
|
|
1973
|
+
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1974
|
+
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1975
|
+
return signature;
|
|
1976
|
+
}
|
|
1977
|
+
function getSignatureFromTransaction(transaction) {
|
|
1978
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
1979
|
+
if (!signatureBytes) {
|
|
1980
|
+
throw new Error(
|
|
1981
|
+
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1982
|
+
);
|
|
1983
|
+
}
|
|
1984
|
+
const transactionSignature2 = base58.deserialize(signatureBytes)[0];
|
|
1985
|
+
return transactionSignature2;
|
|
1986
|
+
}
|
|
1987
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1988
|
+
const compiledMessage = compileMessage(transaction);
|
|
1989
|
+
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1990
|
+
const publicKeySignaturePairs = await Promise.all(
|
|
1991
|
+
keyPairs.map(
|
|
1992
|
+
(keyPair) => Promise.all([
|
|
1993
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1994
|
+
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1995
|
+
])
|
|
1996
|
+
)
|
|
1997
|
+
);
|
|
1998
|
+
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
1999
|
+
nextSignatures[signerPublicKey] = signature;
|
|
2000
|
+
}
|
|
2001
|
+
const out = {
|
|
2002
|
+
...transaction,
|
|
2003
|
+
signatures: nextSignatures
|
|
2004
|
+
};
|
|
2005
|
+
Object.freeze(out);
|
|
2006
|
+
return out;
|
|
2007
|
+
}
|
|
2008
|
+
function transactionSignature(putativeTransactionSignature) {
|
|
2009
|
+
assertIsTransactionSignature(putativeTransactionSignature);
|
|
2010
|
+
return putativeTransactionSignature;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1300
2013
|
// src/wire-transaction.ts
|
|
1301
2014
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1302
2015
|
const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
|
|
@@ -1308,13 +2021,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1308
2021
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1309
2022
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1310
2023
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
2024
|
+
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
1311
2025
|
exports.createTransaction = createTransaction;
|
|
1312
2026
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2027
|
+
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
2028
|
+
exports.getTransactionEncoder = getTransactionEncoder;
|
|
2029
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
2030
|
+
exports.isTransactionSignature = isTransactionSignature;
|
|
1313
2031
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1314
2032
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1315
2033
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1316
2034
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1317
2035
|
exports.signTransaction = signTransaction;
|
|
2036
|
+
exports.transactionSignature = transactionSignature;
|
|
1318
2037
|
|
|
1319
2038
|
return exports;
|
|
1320
2039
|
|