@solana/transactions 2.0.0-experimental.630f6d2 → 2.0.0-experimental.6556a8b
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 +124 -47
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +121 -49
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +536 -90
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +119 -49
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +122 -47
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +119 -51
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +16 -11
- package/dist/types/accounts.d.ts +1 -1
- package/dist/types/blockhash.d.ts +1 -1
- package/dist/types/durable-nonce.d.ts +4 -3
- package/dist/types/fee-payer.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/serializers/index.d.ts +2 -0
- package/dist/types/signatures.d.ts +10 -2
- package/dist/types/types.d.ts +7 -0
- package/dist/types/wire-transaction.d.ts +1 -1
- package/package.json +13 -11
- 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,7 +231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
234
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
|
|
235
235
|
var u8 = (options = {}) => numberFactory({
|
|
236
236
|
name: "u8",
|
|
237
237
|
size: 1,
|
|
@@ -241,7 +241,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
241
241
|
options
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
-
// ../../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/u32.mjs
|
|
245
245
|
var u32 = (options = {}) => numberFactory({
|
|
246
246
|
name: "u32",
|
|
247
247
|
size: 4,
|
|
@@ -251,7 +251,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
251
251
|
options
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
254
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
255
255
|
var shortU16 = (options = {}) => ({
|
|
256
256
|
description: options.description ?? "shortU16",
|
|
257
257
|
fixedSize: null,
|
|
@@ -288,7 +288,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
288
288
|
}
|
|
289
289
|
});
|
|
290
290
|
|
|
291
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
291
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
|
|
292
292
|
var InvalidNumberOfItemsError = class extends Error {
|
|
293
293
|
constructor(serializer, expected, actual) {
|
|
294
294
|
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
@@ -308,12 +308,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
311
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
312
312
|
function sumSerializerSizes(sizes) {
|
|
313
313
|
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
316
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
317
317
|
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
318
318
|
if (typeof size === "number") {
|
|
319
319
|
return [size, offset];
|
|
@@ -349,7 +349,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
349
349
|
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
352
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
353
353
|
function array(item, options = {}) {
|
|
354
354
|
const size = options.size ?? u32();
|
|
355
355
|
if (size === "remainder" && item.fixedSize === null) {
|
|
@@ -382,7 +382,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
385
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
386
386
|
function bytes(options = {}) {
|
|
387
387
|
const size = options.size ?? "variable";
|
|
388
388
|
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
@@ -429,7 +429,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
432
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
433
433
|
function string(options = {}) {
|
|
434
434
|
const size = options.size ?? u32();
|
|
435
435
|
const encoding = options.encoding ?? utf8;
|
|
@@ -470,7 +470,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
473
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
474
474
|
function struct(fields, options = {}) {
|
|
475
475
|
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
476
476
|
return {
|
|
@@ -522,9 +522,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
522
522
|
if (numBytes !== 32) {
|
|
523
523
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
524
524
|
}
|
|
525
|
-
} catch (
|
|
525
|
+
} catch (e2) {
|
|
526
526
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
527
|
-
cause:
|
|
527
|
+
cause: e2
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
}
|
|
@@ -665,6 +665,323 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
665
665
|
return out;
|
|
666
666
|
}
|
|
667
667
|
|
|
668
|
+
// ../codecs-core/dist/index.browser.js
|
|
669
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes2, offset = 0) {
|
|
670
|
+
if (bytes2.length - offset <= 0) {
|
|
671
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
|
|
675
|
+
const bytesLength = bytes2.length - offset;
|
|
676
|
+
if (bytesLength < expected) {
|
|
677
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
var mergeBytes2 = (byteArrays) => {
|
|
681
|
+
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
682
|
+
if (nonEmptyByteArrays.length === 0) {
|
|
683
|
+
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
684
|
+
}
|
|
685
|
+
if (nonEmptyByteArrays.length === 1) {
|
|
686
|
+
return nonEmptyByteArrays[0];
|
|
687
|
+
}
|
|
688
|
+
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
689
|
+
const result = new Uint8Array(totalLength);
|
|
690
|
+
let offset = 0;
|
|
691
|
+
nonEmptyByteArrays.forEach((arr) => {
|
|
692
|
+
result.set(arr, offset);
|
|
693
|
+
offset += arr.length;
|
|
694
|
+
});
|
|
695
|
+
return result;
|
|
696
|
+
};
|
|
697
|
+
var padBytes2 = (bytes2, length) => {
|
|
698
|
+
if (bytes2.length >= length)
|
|
699
|
+
return bytes2;
|
|
700
|
+
const paddedBytes = new Uint8Array(length).fill(0);
|
|
701
|
+
paddedBytes.set(bytes2);
|
|
702
|
+
return paddedBytes;
|
|
703
|
+
};
|
|
704
|
+
var fixBytes2 = (bytes2, length) => padBytes2(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
|
|
705
|
+
function combineCodec(encoder, decoder, description) {
|
|
706
|
+
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
707
|
+
throw new Error(
|
|
708
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
if (encoder.maxSize !== decoder.maxSize) {
|
|
712
|
+
throw new Error(
|
|
713
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
if (description === void 0 && encoder.description !== decoder.description) {
|
|
717
|
+
throw new Error(
|
|
718
|
+
`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.`
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
return {
|
|
722
|
+
decode: decoder.decode,
|
|
723
|
+
description: description ?? encoder.description,
|
|
724
|
+
encode: encoder.encode,
|
|
725
|
+
fixedSize: encoder.fixedSize,
|
|
726
|
+
maxSize: encoder.maxSize
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
function fixCodecHelper(data, fixedBytes, description) {
|
|
730
|
+
return {
|
|
731
|
+
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
732
|
+
fixedSize: fixedBytes,
|
|
733
|
+
maxSize: fixedBytes
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
function fixEncoder(encoder, fixedBytes, description) {
|
|
737
|
+
return {
|
|
738
|
+
...fixCodecHelper(encoder, fixedBytes, description),
|
|
739
|
+
encode: (value) => fixBytes2(encoder.encode(value), fixedBytes)
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function fixDecoder(decoder, fixedBytes, description) {
|
|
743
|
+
return {
|
|
744
|
+
...fixCodecHelper(decoder, fixedBytes, description),
|
|
745
|
+
decode: (bytes2, offset = 0) => {
|
|
746
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes2, offset);
|
|
747
|
+
if (offset > 0 || bytes2.length > fixedBytes) {
|
|
748
|
+
bytes2 = bytes2.slice(offset, offset + fixedBytes);
|
|
749
|
+
}
|
|
750
|
+
if (decoder.fixedSize !== null) {
|
|
751
|
+
bytes2 = fixBytes2(bytes2, decoder.fixedSize);
|
|
752
|
+
}
|
|
753
|
+
const [value] = decoder.decode(bytes2, 0);
|
|
754
|
+
return [value, offset + fixedBytes];
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function mapEncoder(encoder, unmap) {
|
|
759
|
+
return {
|
|
760
|
+
description: encoder.description,
|
|
761
|
+
encode: (value) => encoder.encode(unmap(value)),
|
|
762
|
+
fixedSize: encoder.fixedSize,
|
|
763
|
+
maxSize: encoder.maxSize
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
768
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
769
|
+
if (value < min || value > max) {
|
|
770
|
+
throw new Error(
|
|
771
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function sharedNumberFactory(input) {
|
|
776
|
+
let littleEndian;
|
|
777
|
+
let defaultDescription = input.name;
|
|
778
|
+
if (input.size > 1) {
|
|
779
|
+
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
780
|
+
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
781
|
+
}
|
|
782
|
+
return {
|
|
783
|
+
description: input.options.description ?? defaultDescription,
|
|
784
|
+
fixedSize: input.size,
|
|
785
|
+
littleEndian,
|
|
786
|
+
maxSize: input.size
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function numberEncoderFactory(input) {
|
|
790
|
+
const codecData = sharedNumberFactory(input);
|
|
791
|
+
return {
|
|
792
|
+
description: codecData.description,
|
|
793
|
+
encode(value) {
|
|
794
|
+
if (input.range) {
|
|
795
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
796
|
+
}
|
|
797
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
798
|
+
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
|
|
799
|
+
return new Uint8Array(arrayBuffer);
|
|
800
|
+
},
|
|
801
|
+
fixedSize: codecData.fixedSize,
|
|
802
|
+
maxSize: codecData.maxSize
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function numberDecoderFactory(input) {
|
|
806
|
+
const codecData = sharedNumberFactory(input);
|
|
807
|
+
return {
|
|
808
|
+
decode(bytes2, offset = 0) {
|
|
809
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
|
|
810
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
|
|
811
|
+
const view = new DataView(toArrayBuffer2(bytes2, offset, input.size));
|
|
812
|
+
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
813
|
+
},
|
|
814
|
+
description: codecData.description,
|
|
815
|
+
fixedSize: codecData.fixedSize,
|
|
816
|
+
maxSize: codecData.maxSize
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function toArrayBuffer2(bytes2, offset, length) {
|
|
820
|
+
const bytesOffset = bytes2.byteOffset + (offset ?? 0);
|
|
821
|
+
const bytesLength = length ?? bytes2.byteLength;
|
|
822
|
+
return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
823
|
+
}
|
|
824
|
+
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
825
|
+
name: "u32",
|
|
826
|
+
options,
|
|
827
|
+
range: [0, Number("0xffffffff")],
|
|
828
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
829
|
+
size: 4
|
|
830
|
+
});
|
|
831
|
+
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
832
|
+
get: (view, le) => view.getUint32(0, le),
|
|
833
|
+
name: "u32",
|
|
834
|
+
options,
|
|
835
|
+
size: 4
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// ../codecs-strings/dist/index.browser.js
|
|
839
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
840
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
841
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
845
|
+
const base = alphabet4.length;
|
|
846
|
+
const baseBigInt = BigInt(base);
|
|
847
|
+
return {
|
|
848
|
+
description: `base${base}`,
|
|
849
|
+
encode(value) {
|
|
850
|
+
assertValidBaseString(alphabet4, value);
|
|
851
|
+
if (value === "")
|
|
852
|
+
return new Uint8Array();
|
|
853
|
+
const chars = [...value];
|
|
854
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
855
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
856
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
857
|
+
if (trailIndex === chars.length)
|
|
858
|
+
return Uint8Array.from(leadingZeroes);
|
|
859
|
+
const tailChars = chars.slice(trailIndex);
|
|
860
|
+
let base10Number = 0n;
|
|
861
|
+
let baseXPower = 1n;
|
|
862
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
863
|
+
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
864
|
+
baseXPower *= baseBigInt;
|
|
865
|
+
}
|
|
866
|
+
const tailBytes = [];
|
|
867
|
+
while (base10Number > 0n) {
|
|
868
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
869
|
+
base10Number /= 256n;
|
|
870
|
+
}
|
|
871
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
872
|
+
},
|
|
873
|
+
fixedSize: null,
|
|
874
|
+
maxSize: null
|
|
875
|
+
};
|
|
876
|
+
};
|
|
877
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
878
|
+
const base = alphabet4.length;
|
|
879
|
+
const baseBigInt = BigInt(base);
|
|
880
|
+
return {
|
|
881
|
+
decode(rawBytes, offset = 0) {
|
|
882
|
+
const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
883
|
+
if (bytes2.length === 0)
|
|
884
|
+
return ["", 0];
|
|
885
|
+
let trailIndex = bytes2.findIndex((n) => n !== 0);
|
|
886
|
+
trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
|
|
887
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
888
|
+
if (trailIndex === bytes2.length)
|
|
889
|
+
return [leadingZeroes, rawBytes.length];
|
|
890
|
+
let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
891
|
+
const tailChars = [];
|
|
892
|
+
while (base10Number > 0n) {
|
|
893
|
+
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
894
|
+
base10Number /= baseBigInt;
|
|
895
|
+
}
|
|
896
|
+
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
897
|
+
},
|
|
898
|
+
description: `base${base}`,
|
|
899
|
+
fixedSize: null,
|
|
900
|
+
maxSize: null
|
|
901
|
+
};
|
|
902
|
+
};
|
|
903
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
904
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
905
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
906
|
+
var removeNullCharacters2 = (value) => (
|
|
907
|
+
// eslint-disable-next-line no-control-regex
|
|
908
|
+
value.replace(/\u0000/g, "")
|
|
909
|
+
);
|
|
910
|
+
var e = globalThis.TextDecoder;
|
|
911
|
+
var o = globalThis.TextEncoder;
|
|
912
|
+
var getUtf8Encoder = () => {
|
|
913
|
+
let textEncoder;
|
|
914
|
+
return {
|
|
915
|
+
description: "utf8",
|
|
916
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
917
|
+
fixedSize: null,
|
|
918
|
+
maxSize: null
|
|
919
|
+
};
|
|
920
|
+
};
|
|
921
|
+
var getUtf8Decoder = () => {
|
|
922
|
+
let textDecoder;
|
|
923
|
+
return {
|
|
924
|
+
decode(bytes2, offset = 0) {
|
|
925
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes2.slice(offset));
|
|
926
|
+
return [removeNullCharacters2(value), bytes2.length];
|
|
927
|
+
},
|
|
928
|
+
description: "utf8",
|
|
929
|
+
fixedSize: null,
|
|
930
|
+
maxSize: null
|
|
931
|
+
};
|
|
932
|
+
};
|
|
933
|
+
var getStringEncoder = (options = {}) => {
|
|
934
|
+
const size = options.size ?? getU32Encoder();
|
|
935
|
+
const encoding = options.encoding ?? getUtf8Encoder();
|
|
936
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
937
|
+
if (size === "variable") {
|
|
938
|
+
return { ...encoding, description };
|
|
939
|
+
}
|
|
940
|
+
if (typeof size === "number") {
|
|
941
|
+
return fixEncoder(encoding, size, description);
|
|
942
|
+
}
|
|
943
|
+
return {
|
|
944
|
+
description,
|
|
945
|
+
encode: (value) => {
|
|
946
|
+
const contentBytes = encoding.encode(value);
|
|
947
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
948
|
+
return mergeBytes2([lengthBytes, contentBytes]);
|
|
949
|
+
},
|
|
950
|
+
fixedSize: null,
|
|
951
|
+
maxSize: null
|
|
952
|
+
};
|
|
953
|
+
};
|
|
954
|
+
var getStringDecoder = (options = {}) => {
|
|
955
|
+
const size = options.size ?? getU32Decoder();
|
|
956
|
+
const encoding = options.encoding ?? getUtf8Decoder();
|
|
957
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
958
|
+
if (size === "variable") {
|
|
959
|
+
return { ...encoding, description };
|
|
960
|
+
}
|
|
961
|
+
if (typeof size === "number") {
|
|
962
|
+
return fixDecoder(encoding, size, description);
|
|
963
|
+
}
|
|
964
|
+
return {
|
|
965
|
+
decode: (bytes2, offset = 0) => {
|
|
966
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes2, offset);
|
|
967
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
|
|
968
|
+
const length = Number(lengthBigInt);
|
|
969
|
+
offset = lengthOffset;
|
|
970
|
+
const contentBytes = bytes2.slice(offset, offset + length);
|
|
971
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
972
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
973
|
+
offset += contentOffset;
|
|
974
|
+
return [value, offset];
|
|
975
|
+
},
|
|
976
|
+
description,
|
|
977
|
+
fixedSize: null,
|
|
978
|
+
maxSize: null
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
function getSizeDescription2(size) {
|
|
982
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
983
|
+
}
|
|
984
|
+
|
|
668
985
|
// ../assertions/dist/index.browser.js
|
|
669
986
|
function assertIsSecureContext() {
|
|
670
987
|
if (!globalThis.isSecureContext) {
|
|
@@ -685,14 +1002,66 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
685
1002
|
throw new Error("No signing implementation could be found");
|
|
686
1003
|
}
|
|
687
1004
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
1005
|
+
|
|
1006
|
+
// ../addresses/dist/index.browser.js
|
|
1007
|
+
var memoizedBase58Encoder;
|
|
1008
|
+
var memoizedBase58Decoder;
|
|
1009
|
+
function getMemoizedBase58Encoder() {
|
|
1010
|
+
if (!memoizedBase58Encoder)
|
|
1011
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
1012
|
+
return memoizedBase58Encoder;
|
|
1013
|
+
}
|
|
1014
|
+
function getMemoizedBase58Decoder() {
|
|
1015
|
+
if (!memoizedBase58Decoder)
|
|
1016
|
+
memoizedBase58Decoder = getBase58Decoder();
|
|
1017
|
+
return memoizedBase58Decoder;
|
|
1018
|
+
}
|
|
1019
|
+
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
1020
|
+
try {
|
|
1021
|
+
if (
|
|
1022
|
+
// Lowest address (32 bytes of zeroes)
|
|
1023
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
1024
|
+
putativeBase58EncodedAddress.length > 44
|
|
1025
|
+
) {
|
|
1026
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1027
|
+
}
|
|
1028
|
+
const base58Encoder = getMemoizedBase58Encoder();
|
|
1029
|
+
const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
1030
|
+
const numBytes = bytes2.byteLength;
|
|
1031
|
+
if (numBytes !== 32) {
|
|
1032
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1033
|
+
}
|
|
1034
|
+
} catch (e2) {
|
|
1035
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
1036
|
+
cause: e2
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
function address(putativeBase58EncodedAddress) {
|
|
1041
|
+
assertIsAddress(putativeBase58EncodedAddress);
|
|
1042
|
+
return putativeBase58EncodedAddress;
|
|
1043
|
+
}
|
|
1044
|
+
function getAddressEncoder(config) {
|
|
1045
|
+
return mapEncoder(
|
|
1046
|
+
getStringEncoder({
|
|
1047
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
1048
|
+
encoding: getMemoizedBase58Encoder(),
|
|
1049
|
+
size: 32
|
|
1050
|
+
}),
|
|
1051
|
+
(putativeAddress) => address(putativeAddress)
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
function getAddressDecoder(config) {
|
|
1055
|
+
return getStringDecoder({
|
|
1056
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
1057
|
+
encoding: getMemoizedBase58Decoder(),
|
|
692
1058
|
size: 32
|
|
693
1059
|
});
|
|
694
1060
|
}
|
|
695
|
-
function
|
|
1061
|
+
function getAddressCodec(config) {
|
|
1062
|
+
return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
|
|
1063
|
+
}
|
|
1064
|
+
function getAddressComparator() {
|
|
696
1065
|
return new Intl.Collator("en", {
|
|
697
1066
|
caseFirst: "lower",
|
|
698
1067
|
ignorePunctuation: false,
|
|
@@ -708,20 +1077,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
708
1077
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
709
1078
|
}
|
|
710
1079
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
711
|
-
const [base58EncodedAddress] =
|
|
1080
|
+
const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
712
1081
|
return base58EncodedAddress;
|
|
713
1082
|
}
|
|
714
1083
|
|
|
715
|
-
// ../keys/dist/index.browser.js
|
|
716
|
-
async function signBytes(key, data) {
|
|
717
|
-
await assertSigningCapabilityIsAvailable();
|
|
718
|
-
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
719
|
-
return new Uint8Array(signedData);
|
|
720
|
-
}
|
|
721
|
-
|
|
722
1084
|
// src/accounts.ts
|
|
723
|
-
function upsert(addressMap,
|
|
724
|
-
addressMap[
|
|
1085
|
+
function upsert(addressMap, address2, update) {
|
|
1086
|
+
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
|
|
725
1087
|
}
|
|
726
1088
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
727
1089
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -772,7 +1134,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
772
1134
|
const shouldReplaceEntry = (
|
|
773
1135
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
774
1136
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
775
|
-
(addressComparator || (addressComparator =
|
|
1137
|
+
(addressComparator || (addressComparator = getAddressComparator()))(
|
|
776
1138
|
accountMeta.lookupTableAddress,
|
|
777
1139
|
entry.lookupTableAddress
|
|
778
1140
|
) < 0
|
|
@@ -878,14 +1240,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
878
1240
|
if (leftIsWritable !== isWritableRole(rightEntry.role)) {
|
|
879
1241
|
return leftIsWritable ? -1 : 1;
|
|
880
1242
|
}
|
|
881
|
-
addressComparator || (addressComparator =
|
|
1243
|
+
addressComparator || (addressComparator = getAddressComparator());
|
|
882
1244
|
if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
883
1245
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
884
1246
|
} else {
|
|
885
1247
|
return addressComparator(leftAddress, rightAddress);
|
|
886
1248
|
}
|
|
887
|
-
}).map(([
|
|
888
|
-
address,
|
|
1249
|
+
}).map(([address2, addressMeta]) => ({
|
|
1250
|
+
address: address2,
|
|
889
1251
|
...addressMeta
|
|
890
1252
|
}));
|
|
891
1253
|
return orderedAccounts;
|
|
@@ -909,7 +1271,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
909
1271
|
entry.readableIndices.push(account.addressIndex);
|
|
910
1272
|
}
|
|
911
1273
|
}
|
|
912
|
-
return Object.keys(index).sort(
|
|
1274
|
+
return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
|
|
913
1275
|
lookupTableAddress,
|
|
914
1276
|
...index[lookupTableAddress]
|
|
915
1277
|
}));
|
|
@@ -954,7 +1316,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
954
1316
|
return instructions.map(({ accounts, data, programAddress }) => {
|
|
955
1317
|
return {
|
|
956
1318
|
programAddressIndex: accountIndex[programAddress],
|
|
957
|
-
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[
|
|
1319
|
+
...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
|
|
958
1320
|
...data ? { data } : null
|
|
959
1321
|
};
|
|
960
1322
|
});
|
|
@@ -972,7 +1334,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
972
1334
|
function getCompiledStaticAccounts(orderedAccounts) {
|
|
973
1335
|
const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
|
|
974
1336
|
const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
|
|
975
|
-
return orderedStaticAccounts.map(({ address }) =>
|
|
1337
|
+
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
|
976
1338
|
}
|
|
977
1339
|
|
|
978
1340
|
// src/message.ts
|
|
@@ -989,13 +1351,41 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
989
1351
|
};
|
|
990
1352
|
}
|
|
991
1353
|
|
|
1354
|
+
// src/compile-transaction.ts
|
|
1355
|
+
function getCompiledTransaction(transaction) {
|
|
1356
|
+
const compiledMessage = compileMessage(transaction);
|
|
1357
|
+
let signatures;
|
|
1358
|
+
if ("signatures" in transaction) {
|
|
1359
|
+
signatures = [];
|
|
1360
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1361
|
+
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1362
|
+
}
|
|
1363
|
+
} else {
|
|
1364
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1365
|
+
}
|
|
1366
|
+
return {
|
|
1367
|
+
compiledMessage,
|
|
1368
|
+
signatures
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
|
|
992
1372
|
// src/serializers/address-table-lookup.ts
|
|
1373
|
+
function addressSerializerCompat(compat) {
|
|
1374
|
+
const codec = getAddressCodec();
|
|
1375
|
+
return {
|
|
1376
|
+
description: compat?.description ?? codec.description,
|
|
1377
|
+
deserialize: codec.decode,
|
|
1378
|
+
fixedSize: codec.fixedSize,
|
|
1379
|
+
maxSize: codec.maxSize,
|
|
1380
|
+
serialize: codec.encode
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
993
1383
|
function getAddressTableLookupCodec() {
|
|
994
1384
|
return struct(
|
|
995
1385
|
[
|
|
996
1386
|
[
|
|
997
1387
|
"lookupTableAddress",
|
|
998
|
-
|
|
1388
|
+
addressSerializerCompat(
|
|
999
1389
|
{
|
|
1000
1390
|
description: "The address of the address lookup table account from which instruction addresses should be looked up"
|
|
1001
1391
|
}
|
|
@@ -1190,13 +1580,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1190
1580
|
).serialize(compiledMessage);
|
|
1191
1581
|
}
|
|
1192
1582
|
}
|
|
1583
|
+
function addressSerializerCompat2() {
|
|
1584
|
+
const codec = getAddressCodec();
|
|
1585
|
+
return {
|
|
1586
|
+
description: codec.description,
|
|
1587
|
+
deserialize: codec.decode,
|
|
1588
|
+
fixedSize: codec.fixedSize,
|
|
1589
|
+
maxSize: codec.maxSize,
|
|
1590
|
+
serialize: codec.encode
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1193
1593
|
function getPreludeStructSerializerTuple() {
|
|
1194
1594
|
return [
|
|
1195
1595
|
["version", getTransactionVersionCodec()],
|
|
1196
1596
|
["header", getMessageHeaderCodec()],
|
|
1197
1597
|
[
|
|
1198
1598
|
"staticAccounts",
|
|
1199
|
-
array(
|
|
1599
|
+
array(addressSerializerCompat2(), {
|
|
1200
1600
|
description: "A compact-array of static account addresses belonging to this transaction" ,
|
|
1201
1601
|
size: shortU16()
|
|
1202
1602
|
})
|
|
@@ -1232,48 +1632,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1232
1632
|
};
|
|
1233
1633
|
}
|
|
1234
1634
|
|
|
1235
|
-
// src/signatures.ts
|
|
1236
|
-
async function getCompiledMessageSignature(message, secretKey) {
|
|
1237
|
-
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1238
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1239
|
-
return signature;
|
|
1240
|
-
}
|
|
1241
|
-
async function signTransaction(keyPair, transaction) {
|
|
1242
|
-
const compiledMessage = compileMessage(transaction);
|
|
1243
|
-
const [signerPublicKey, signature] = await Promise.all([
|
|
1244
|
-
getAddressFromPublicKey(keyPair.publicKey),
|
|
1245
|
-
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1246
|
-
]);
|
|
1247
|
-
const nextSignatures = {
|
|
1248
|
-
..."signatures" in transaction ? transaction.signatures : null,
|
|
1249
|
-
...{ [signerPublicKey]: signature }
|
|
1250
|
-
};
|
|
1251
|
-
const out = {
|
|
1252
|
-
...transaction,
|
|
1253
|
-
signatures: nextSignatures
|
|
1254
|
-
};
|
|
1255
|
-
Object.freeze(out);
|
|
1256
|
-
return out;
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
// src/compile-transaction.ts
|
|
1260
|
-
function getCompiledTransaction(transaction) {
|
|
1261
|
-
const compiledMessage = compileMessage(transaction);
|
|
1262
|
-
let signatures;
|
|
1263
|
-
if ("signatures" in transaction) {
|
|
1264
|
-
signatures = [];
|
|
1265
|
-
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1266
|
-
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1267
|
-
}
|
|
1268
|
-
} else {
|
|
1269
|
-
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1270
|
-
}
|
|
1271
|
-
return {
|
|
1272
|
-
compiledMessage,
|
|
1273
|
-
signatures
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
1635
|
// src/serializers/transaction.ts
|
|
1278
1636
|
var BASE_CONFIG3 = {
|
|
1279
1637
|
description: "The wire format of a Solana transaction" ,
|
|
@@ -1301,6 +1659,89 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1301
1659
|
};
|
|
1302
1660
|
}
|
|
1303
1661
|
|
|
1662
|
+
// ../keys/dist/index.browser.js
|
|
1663
|
+
async function signBytes(key, data) {
|
|
1664
|
+
await assertSigningCapabilityIsAvailable();
|
|
1665
|
+
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
1666
|
+
return new Uint8Array(signedData);
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
// src/signatures.ts
|
|
1670
|
+
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
1671
|
+
try {
|
|
1672
|
+
if (
|
|
1673
|
+
// Lowest value (64 bytes of zeroes)
|
|
1674
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1675
|
+
putativeTransactionSignature.length > 88
|
|
1676
|
+
) {
|
|
1677
|
+
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1678
|
+
}
|
|
1679
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1680
|
+
const numBytes = bytes2.byteLength;
|
|
1681
|
+
if (numBytes !== 64) {
|
|
1682
|
+
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1683
|
+
}
|
|
1684
|
+
} catch (e2) {
|
|
1685
|
+
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1686
|
+
cause: e2
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
function isTransactionSignature(putativeTransactionSignature) {
|
|
1691
|
+
if (
|
|
1692
|
+
// Lowest value (64 bytes of zeroes)
|
|
1693
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1694
|
+
putativeTransactionSignature.length > 88
|
|
1695
|
+
) {
|
|
1696
|
+
return false;
|
|
1697
|
+
}
|
|
1698
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1699
|
+
const numBytes = bytes2.byteLength;
|
|
1700
|
+
if (numBytes !== 64) {
|
|
1701
|
+
return false;
|
|
1702
|
+
}
|
|
1703
|
+
return true;
|
|
1704
|
+
}
|
|
1705
|
+
async function getCompiledMessageSignature(message, secretKey) {
|
|
1706
|
+
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1707
|
+
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1708
|
+
return signature;
|
|
1709
|
+
}
|
|
1710
|
+
function getSignatureFromTransaction(transaction) {
|
|
1711
|
+
const signature = transaction.signatures[transaction.feePayer];
|
|
1712
|
+
if (!signature) {
|
|
1713
|
+
throw new Error(
|
|
1714
|
+
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
return signature;
|
|
1718
|
+
}
|
|
1719
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1720
|
+
const compiledMessage = compileMessage(transaction);
|
|
1721
|
+
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1722
|
+
const publicKeySignaturePairs = await Promise.all(
|
|
1723
|
+
keyPairs.map(
|
|
1724
|
+
(keyPair) => Promise.all([
|
|
1725
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1726
|
+
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1727
|
+
])
|
|
1728
|
+
)
|
|
1729
|
+
);
|
|
1730
|
+
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
1731
|
+
nextSignatures[signerPublicKey] = signature;
|
|
1732
|
+
}
|
|
1733
|
+
const out = {
|
|
1734
|
+
...transaction,
|
|
1735
|
+
signatures: nextSignatures
|
|
1736
|
+
};
|
|
1737
|
+
Object.freeze(out);
|
|
1738
|
+
return out;
|
|
1739
|
+
}
|
|
1740
|
+
function transactionSignature(putativeTransactionSignature) {
|
|
1741
|
+
assertIsTransactionSignature(putativeTransactionSignature);
|
|
1742
|
+
return putativeTransactionSignature;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1304
1745
|
// src/wire-transaction.ts
|
|
1305
1746
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1306
1747
|
const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
|
|
@@ -1312,13 +1753,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1312
1753
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1313
1754
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1314
1755
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1756
|
+
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
1315
1757
|
exports.createTransaction = createTransaction;
|
|
1316
1758
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1759
|
+
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1760
|
+
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1761
|
+
exports.isTransactionSignature = isTransactionSignature;
|
|
1317
1762
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1318
1763
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1319
1764
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1320
1765
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1321
1766
|
exports.signTransaction = signTransaction;
|
|
1767
|
+
exports.transactionSignature = transactionSignature;
|
|
1322
1768
|
|
|
1323
1769
|
return exports;
|
|
1324
1770
|
|