@solana/transactions 2.0.0-experimental.9c8a30e → 2.0.0-experimental.9d0a506
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -43
- package/dist/index.browser.cjs +14 -59
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +15 -58
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +154 -156
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +15 -58
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +16 -59
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +15 -58
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +17 -19
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts +7 -0
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +2 -2
- package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
- package/dist/types/compile-header.d.ts.map +1 -0
- package/dist/types/compile-instructions.d.ts.map +1 -0
- package/dist/types/compile-lifetime-token.d.ts.map +1 -0
- package/dist/types/compile-static-accounts.d.ts +2 -2
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts +5 -6
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/decompile-transaction.d.ts +2 -4
- package/dist/types/decompile-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +3 -3
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +4 -4
- package/dist/types/fee-payer.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/message.d.ts +1 -5
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
- package/dist/types/serializers/header.d.ts.map +1 -0
- package/dist/types/serializers/index.d.ts.map +1 -0
- package/dist/types/serializers/instruction.d.ts.map +1 -0
- package/dist/types/serializers/message.d.ts.map +1 -0
- package/dist/types/serializers/transaction-version.d.ts.map +1 -0
- package/dist/types/serializers/transaction.d.ts +1 -3
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +8 -13
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts +6 -13
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +10 -10
|
@@ -57,7 +57,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
57
57
|
}
|
|
58
58
|
return {
|
|
59
59
|
decode: decoder.decode,
|
|
60
|
-
description: description
|
|
60
|
+
description: description != null ? description : encoder.description,
|
|
61
61
|
encode: encoder.encode,
|
|
62
62
|
fixedSize: encoder.fixedSize,
|
|
63
63
|
maxSize: encoder.maxSize
|
|
@@ -65,7 +65,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
65
65
|
}
|
|
66
66
|
function fixCodecHelper(data, fixedBytes, description) {
|
|
67
67
|
return {
|
|
68
|
-
description: description
|
|
68
|
+
description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
|
|
69
69
|
fixedSize: fixedBytes,
|
|
70
70
|
maxSize: fixedBytes
|
|
71
71
|
};
|
|
@@ -121,14 +121,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
function sharedNumberFactory(input) {
|
|
124
|
+
var _a;
|
|
124
125
|
let littleEndian;
|
|
125
126
|
let defaultDescription = input.name;
|
|
126
127
|
if (input.size > 1) {
|
|
127
|
-
littleEndian = !("endian" in input.
|
|
128
|
+
littleEndian = !("endian" in input.config) || input.config.endian === 0;
|
|
128
129
|
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
129
130
|
}
|
|
130
131
|
return {
|
|
131
|
-
description: input.
|
|
132
|
+
description: (_a = input.config.description) != null ? _a : defaultDescription,
|
|
132
133
|
fixedSize: input.size,
|
|
133
134
|
littleEndian,
|
|
134
135
|
maxSize: input.size
|
|
@@ -165,74 +166,80 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
165
166
|
};
|
|
166
167
|
}
|
|
167
168
|
function toArrayBuffer(bytes, offset, length) {
|
|
168
|
-
const bytesOffset = bytes.byteOffset + (offset
|
|
169
|
-
const bytesLength = length
|
|
169
|
+
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
170
|
+
const bytesLength = length != null ? length : bytes.byteLength;
|
|
170
171
|
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
171
172
|
}
|
|
172
|
-
var getShortU16Encoder = (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
bytes[ii
|
|
173
|
+
var getShortU16Encoder = (config = {}) => {
|
|
174
|
+
var _a;
|
|
175
|
+
return {
|
|
176
|
+
description: (_a = config.description) != null ? _a : "shortU16",
|
|
177
|
+
encode: (value) => {
|
|
178
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
179
|
+
const bytes = [0];
|
|
180
|
+
for (let ii = 0; ; ii += 1) {
|
|
181
|
+
const alignedValue = value >> ii * 7;
|
|
182
|
+
if (alignedValue === 0) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
const nextSevenBits = 127 & alignedValue;
|
|
186
|
+
bytes[ii] = nextSevenBits;
|
|
187
|
+
if (ii > 0) {
|
|
188
|
+
bytes[ii - 1] |= 128;
|
|
189
|
+
}
|
|
186
190
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
var getShortU16Decoder = (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
191
|
+
return new Uint8Array(bytes);
|
|
192
|
+
},
|
|
193
|
+
fixedSize: null,
|
|
194
|
+
maxSize: 3
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
var getShortU16Decoder = (config = {}) => {
|
|
198
|
+
var _a;
|
|
199
|
+
return {
|
|
200
|
+
decode: (bytes, offset = 0) => {
|
|
201
|
+
let value = 0;
|
|
202
|
+
let byteCount = 0;
|
|
203
|
+
while (++byteCount) {
|
|
204
|
+
const byteIndex = byteCount - 1;
|
|
205
|
+
const currentByte = bytes[offset + byteIndex];
|
|
206
|
+
const nextSevenBits = 127 & currentByte;
|
|
207
|
+
value |= nextSevenBits << byteIndex * 7;
|
|
208
|
+
if ((currentByte & 128) === 0) {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
204
211
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
var getU32Encoder = (
|
|
212
|
+
return [value, offset + byteCount];
|
|
213
|
+
},
|
|
214
|
+
description: (_a = config.description) != null ? _a : "shortU16",
|
|
215
|
+
fixedSize: null,
|
|
216
|
+
maxSize: 3
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
220
|
+
config,
|
|
213
221
|
name: "u32",
|
|
214
|
-
options,
|
|
215
222
|
range: [0, Number("0xffffffff")],
|
|
216
223
|
set: (view, value, le) => view.setUint32(0, value, le),
|
|
217
224
|
size: 4
|
|
218
225
|
});
|
|
219
|
-
var getU32Decoder = (
|
|
226
|
+
var getU32Decoder = (config = {}) => numberDecoderFactory({
|
|
227
|
+
config,
|
|
220
228
|
get: (view, le) => view.getUint32(0, le),
|
|
221
229
|
name: "u32",
|
|
222
|
-
options,
|
|
223
230
|
size: 4
|
|
224
231
|
});
|
|
225
|
-
var getU8Encoder = (
|
|
232
|
+
var getU8Encoder = (config = {}) => numberEncoderFactory({
|
|
233
|
+
config,
|
|
226
234
|
name: "u8",
|
|
227
|
-
options,
|
|
228
235
|
range: [0, Number("0xff")],
|
|
229
236
|
set: (view, value) => view.setUint8(0, value),
|
|
230
237
|
size: 1
|
|
231
238
|
});
|
|
232
|
-
var getU8Decoder = (
|
|
239
|
+
var getU8Decoder = (config = {}) => numberDecoderFactory({
|
|
240
|
+
config,
|
|
233
241
|
get: (view) => view.getUint8(0),
|
|
234
242
|
name: "u8",
|
|
235
|
-
options,
|
|
236
243
|
size: 1
|
|
237
244
|
});
|
|
238
245
|
|
|
@@ -304,6 +311,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
304
311
|
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
305
312
|
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
306
313
|
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
314
|
+
var getBase64Decoder = () => {
|
|
315
|
+
{
|
|
316
|
+
return {
|
|
317
|
+
decode(bytes, offset = 0) {
|
|
318
|
+
const slice = bytes.slice(offset);
|
|
319
|
+
const value = btoa(String.fromCharCode(...slice));
|
|
320
|
+
return [value, bytes.length];
|
|
321
|
+
},
|
|
322
|
+
description: `base64`,
|
|
323
|
+
fixedSize: null,
|
|
324
|
+
maxSize: null
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
};
|
|
307
328
|
var removeNullCharacters = (value) => (
|
|
308
329
|
// eslint-disable-next-line no-control-regex
|
|
309
330
|
value.replace(/\u0000/g, "")
|
|
@@ -331,10 +352,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
331
352
|
maxSize: null
|
|
332
353
|
};
|
|
333
354
|
};
|
|
334
|
-
var getStringEncoder = (
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
const
|
|
355
|
+
var getStringEncoder = (config = {}) => {
|
|
356
|
+
var _a, _b, _c;
|
|
357
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
358
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
|
|
359
|
+
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
338
360
|
if (size === "variable") {
|
|
339
361
|
return { ...encoding, description };
|
|
340
362
|
}
|
|
@@ -352,10 +374,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
352
374
|
maxSize: null
|
|
353
375
|
};
|
|
354
376
|
};
|
|
355
|
-
var getStringDecoder = (
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
-
const
|
|
377
|
+
var getStringDecoder = (config = {}) => {
|
|
378
|
+
var _a, _b, _c;
|
|
379
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
380
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
|
|
381
|
+
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
359
382
|
if (size === "variable") {
|
|
360
383
|
return { ...encoding, description };
|
|
361
384
|
}
|
|
@@ -491,9 +514,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
491
514
|
};
|
|
492
515
|
}
|
|
493
516
|
function isAdvanceNonceAccountInstruction(instruction) {
|
|
517
|
+
var _a;
|
|
494
518
|
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
495
519
|
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
496
|
-
instruction.accounts
|
|
520
|
+
((_a = instruction.accounts) == null ? void 0 : _a.length) === 3 && // First account is nonce account address
|
|
497
521
|
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
498
522
|
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
499
523
|
instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
|
|
@@ -625,15 +649,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
625
649
|
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
626
650
|
}
|
|
627
651
|
return {
|
|
628
|
-
description: description
|
|
652
|
+
description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
629
653
|
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
630
654
|
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
631
655
|
};
|
|
632
656
|
}
|
|
633
|
-
function getArrayEncoder(item,
|
|
634
|
-
|
|
657
|
+
function getArrayEncoder(item, config = {}) {
|
|
658
|
+
var _a;
|
|
659
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
635
660
|
return {
|
|
636
|
-
...arrayCodecHelper(item, size,
|
|
661
|
+
...arrayCodecHelper(item, size, config.description),
|
|
637
662
|
encode: (value) => {
|
|
638
663
|
if (typeof size === "number") {
|
|
639
664
|
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
@@ -642,10 +667,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
642
667
|
}
|
|
643
668
|
};
|
|
644
669
|
}
|
|
645
|
-
function getArrayDecoder(item,
|
|
646
|
-
|
|
670
|
+
function getArrayDecoder(item, config = {}) {
|
|
671
|
+
var _a;
|
|
672
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
647
673
|
return {
|
|
648
|
-
...arrayCodecHelper(item, size,
|
|
674
|
+
...arrayCodecHelper(item, size, config.description),
|
|
649
675
|
decode: (bytes, offset = 0) => {
|
|
650
676
|
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
651
677
|
return [[], offset];
|
|
@@ -662,10 +688,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
662
688
|
}
|
|
663
689
|
};
|
|
664
690
|
}
|
|
665
|
-
function getBytesEncoder(
|
|
666
|
-
|
|
691
|
+
function getBytesEncoder(config = {}) {
|
|
692
|
+
var _a, _b;
|
|
693
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
667
694
|
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
668
|
-
const description =
|
|
695
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
669
696
|
const byteEncoder = {
|
|
670
697
|
description,
|
|
671
698
|
encode: (value) => value,
|
|
@@ -687,10 +714,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
687
714
|
}
|
|
688
715
|
};
|
|
689
716
|
}
|
|
690
|
-
function getBytesDecoder(
|
|
691
|
-
|
|
717
|
+
function getBytesDecoder(config = {}) {
|
|
718
|
+
var _a, _b;
|
|
719
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
692
720
|
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
693
|
-
const description =
|
|
721
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
694
722
|
const byteDecoder = {
|
|
695
723
|
decode: (bytes, offset = 0) => {
|
|
696
724
|
const slice = bytes.slice(offset);
|
|
@@ -724,23 +752,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
724
752
|
function structCodecHelper(fields, description) {
|
|
725
753
|
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
726
754
|
return {
|
|
727
|
-
description: description
|
|
755
|
+
description: description != null ? description : `struct(${fieldDescriptions})`,
|
|
728
756
|
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
729
757
|
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
730
758
|
};
|
|
731
759
|
}
|
|
732
|
-
function getStructEncoder(fields,
|
|
760
|
+
function getStructEncoder(fields, config = {}) {
|
|
733
761
|
return {
|
|
734
|
-
...structCodecHelper(fields,
|
|
762
|
+
...structCodecHelper(fields, config.description),
|
|
735
763
|
encode: (struct) => {
|
|
736
764
|
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
737
765
|
return mergeBytes(fieldBytes);
|
|
738
766
|
}
|
|
739
767
|
};
|
|
740
768
|
}
|
|
741
|
-
function getStructDecoder(fields,
|
|
769
|
+
function getStructDecoder(fields, config = {}) {
|
|
742
770
|
return {
|
|
743
|
-
...structCodecHelper(fields,
|
|
771
|
+
...structCodecHelper(fields, config.description),
|
|
744
772
|
decode: (bytes, offset = 0) => {
|
|
745
773
|
const struct = {};
|
|
746
774
|
fields.forEach(([key, codec]) => {
|
|
@@ -762,14 +790,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
762
790
|
}
|
|
763
791
|
}
|
|
764
792
|
async function assertKeyExporterIsAvailable() {
|
|
793
|
+
var _a;
|
|
765
794
|
assertIsSecureContext();
|
|
766
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
795
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
|
|
767
796
|
throw new Error("No key export implementation could be found");
|
|
768
797
|
}
|
|
769
798
|
}
|
|
770
799
|
async function assertSigningCapabilityIsAvailable() {
|
|
800
|
+
var _a;
|
|
771
801
|
assertIsSecureContext();
|
|
772
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
802
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
|
|
773
803
|
throw new Error("No signing implementation could be found");
|
|
774
804
|
}
|
|
775
805
|
}
|
|
@@ -787,35 +817,36 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
787
817
|
memoizedBase58Decoder = getBase58Decoder();
|
|
788
818
|
return memoizedBase58Decoder;
|
|
789
819
|
}
|
|
790
|
-
function assertIsAddress(
|
|
820
|
+
function assertIsAddress(putativeAddress) {
|
|
791
821
|
try {
|
|
792
822
|
if (
|
|
793
823
|
// Lowest address (32 bytes of zeroes)
|
|
794
|
-
|
|
795
|
-
|
|
824
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
825
|
+
putativeAddress.length > 44
|
|
796
826
|
) {
|
|
797
827
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
798
828
|
}
|
|
799
|
-
const
|
|
800
|
-
const bytes =
|
|
829
|
+
const base58Encoder2 = getMemoizedBase58Encoder();
|
|
830
|
+
const bytes = base58Encoder2.encode(putativeAddress);
|
|
801
831
|
const numBytes = bytes.byteLength;
|
|
802
832
|
if (numBytes !== 32) {
|
|
803
833
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
804
834
|
}
|
|
805
835
|
} catch (e2) {
|
|
806
|
-
throw new Error(`\`${
|
|
836
|
+
throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
|
|
807
837
|
cause: e2
|
|
808
838
|
});
|
|
809
839
|
}
|
|
810
840
|
}
|
|
811
|
-
function address(
|
|
812
|
-
assertIsAddress(
|
|
813
|
-
return
|
|
841
|
+
function address(putativeAddress) {
|
|
842
|
+
assertIsAddress(putativeAddress);
|
|
843
|
+
return putativeAddress;
|
|
814
844
|
}
|
|
815
845
|
function getAddressEncoder(config) {
|
|
846
|
+
var _a;
|
|
816
847
|
return mapEncoder(
|
|
817
848
|
getStringEncoder({
|
|
818
|
-
description: config
|
|
849
|
+
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
819
850
|
encoding: getMemoizedBase58Encoder(),
|
|
820
851
|
size: 32
|
|
821
852
|
}),
|
|
@@ -823,8 +854,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
823
854
|
);
|
|
824
855
|
}
|
|
825
856
|
function getAddressDecoder(config) {
|
|
857
|
+
var _a;
|
|
826
858
|
return getStringDecoder({
|
|
827
|
-
description: config
|
|
859
|
+
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
828
860
|
encoding: getMemoizedBase58Decoder(),
|
|
829
861
|
size: 32
|
|
830
862
|
});
|
|
@@ -851,7 +883,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
851
883
|
|
|
852
884
|
// src/accounts.ts
|
|
853
885
|
function upsert(addressMap, address2, update) {
|
|
854
|
-
|
|
886
|
+
var _a;
|
|
887
|
+
addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole.READONLY });
|
|
855
888
|
}
|
|
856
889
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
857
890
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -1121,12 +1154,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1121
1154
|
|
|
1122
1155
|
// src/compile-transaction.ts
|
|
1123
1156
|
function getCompiledTransaction(transaction) {
|
|
1157
|
+
var _a;
|
|
1124
1158
|
const compiledMessage = compileMessage(transaction);
|
|
1125
1159
|
let signatures;
|
|
1126
1160
|
if ("signatures" in transaction) {
|
|
1127
1161
|
signatures = [];
|
|
1128
1162
|
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1129
|
-
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]]
|
|
1163
|
+
signatures[ii] = (_a = transaction.signatures[compiledMessage.staticAccounts[ii]]) != null ? _a : new Uint8Array(Array(64).fill(0));
|
|
1130
1164
|
}
|
|
1131
1165
|
} else {
|
|
1132
1166
|
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
@@ -1180,11 +1214,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1180
1214
|
return accountMetas;
|
|
1181
1215
|
}
|
|
1182
1216
|
function convertInstruction(instruction, accountMetas) {
|
|
1183
|
-
|
|
1217
|
+
var _a, _b;
|
|
1218
|
+
const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
|
|
1184
1219
|
if (!programAddress) {
|
|
1185
1220
|
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
1186
1221
|
}
|
|
1187
|
-
const accounts = instruction.accountIndices
|
|
1222
|
+
const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
|
|
1188
1223
|
const { data } = instruction;
|
|
1189
1224
|
return {
|
|
1190
1225
|
programAddress,
|
|
@@ -1196,7 +1231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1196
1231
|
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1197
1232
|
return {
|
|
1198
1233
|
blockhash: messageLifetimeToken,
|
|
1199
|
-
lastValidBlockHeight: lastValidBlockHeight
|
|
1234
|
+
lastValidBlockHeight: lastValidBlockHeight != null ? lastValidBlockHeight : 2n ** 64n - 1n
|
|
1200
1235
|
// U64 MAX
|
|
1201
1236
|
};
|
|
1202
1237
|
} else {
|
|
@@ -1323,7 +1358,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1323
1358
|
const encoder = getMemoizedU8Encoder();
|
|
1324
1359
|
return {
|
|
1325
1360
|
...encoder,
|
|
1326
|
-
description: description
|
|
1361
|
+
description: description != null ? description : encoder.description
|
|
1327
1362
|
};
|
|
1328
1363
|
}
|
|
1329
1364
|
var memoizedU8Decoder;
|
|
@@ -1336,7 +1371,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1336
1371
|
const decoder = getMemoizedU8Decoder();
|
|
1337
1372
|
return {
|
|
1338
1373
|
...decoder,
|
|
1339
|
-
description: description
|
|
1374
|
+
description: description != null ? description : decoder.description
|
|
1340
1375
|
};
|
|
1341
1376
|
}
|
|
1342
1377
|
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
@@ -1390,13 +1425,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1390
1425
|
]),
|
|
1391
1426
|
// Convert an instruction to have all fields defined
|
|
1392
1427
|
(instruction) => {
|
|
1428
|
+
var _a, _b;
|
|
1393
1429
|
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1394
1430
|
return instruction;
|
|
1395
1431
|
}
|
|
1396
1432
|
return {
|
|
1397
1433
|
...instruction,
|
|
1398
|
-
accountIndices: instruction.accountIndices
|
|
1399
|
-
data: instruction.data
|
|
1434
|
+
accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
|
|
1435
|
+
data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
|
|
1400
1436
|
};
|
|
1401
1437
|
}
|
|
1402
1438
|
);
|
|
@@ -1488,12 +1524,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1488
1524
|
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1489
1525
|
]),
|
|
1490
1526
|
(value) => {
|
|
1527
|
+
var _a;
|
|
1491
1528
|
if (value.version === "legacy") {
|
|
1492
1529
|
return value;
|
|
1493
1530
|
}
|
|
1494
1531
|
return {
|
|
1495
1532
|
...value,
|
|
1496
|
-
addressTableLookups: value.addressTableLookups
|
|
1533
|
+
addressTableLookups: (_a = value.addressTableLookups) != null ? _a : []
|
|
1497
1534
|
};
|
|
1498
1535
|
}
|
|
1499
1536
|
);
|
|
@@ -1588,7 +1625,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1588
1625
|
description: messageDescription
|
|
1589
1626
|
}),
|
|
1590
1627
|
({ addressTableLookups, ...restOfMessage }) => {
|
|
1591
|
-
if (restOfMessage.version === "legacy" || !addressTableLookups
|
|
1628
|
+
if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
|
|
1592
1629
|
return restOfMessage;
|
|
1593
1630
|
}
|
|
1594
1631
|
return { ...restOfMessage, addressTableLookups };
|
|
@@ -1657,47 +1694,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1657
1694
|
}
|
|
1658
1695
|
|
|
1659
1696
|
// src/signatures.ts
|
|
1660
|
-
var base58Encoder2;
|
|
1661
1697
|
var base58Decoder;
|
|
1662
|
-
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
1663
|
-
if (!base58Encoder2)
|
|
1664
|
-
base58Encoder2 = getBase58Encoder();
|
|
1665
|
-
try {
|
|
1666
|
-
if (
|
|
1667
|
-
// Lowest value (64 bytes of zeroes)
|
|
1668
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1669
|
-
putativeTransactionSignature.length > 88
|
|
1670
|
-
) {
|
|
1671
|
-
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1672
|
-
}
|
|
1673
|
-
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
1674
|
-
const numBytes = bytes.byteLength;
|
|
1675
|
-
if (numBytes !== 64) {
|
|
1676
|
-
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1677
|
-
}
|
|
1678
|
-
} catch (e2) {
|
|
1679
|
-
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1680
|
-
cause: e2
|
|
1681
|
-
});
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
function isTransactionSignature(putativeTransactionSignature) {
|
|
1685
|
-
if (!base58Encoder2)
|
|
1686
|
-
base58Encoder2 = getBase58Encoder();
|
|
1687
|
-
if (
|
|
1688
|
-
// Lowest value (64 bytes of zeroes)
|
|
1689
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1690
|
-
putativeTransactionSignature.length > 88
|
|
1691
|
-
) {
|
|
1692
|
-
return false;
|
|
1693
|
-
}
|
|
1694
|
-
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
1695
|
-
const numBytes = bytes.byteLength;
|
|
1696
|
-
if (numBytes !== 64) {
|
|
1697
|
-
return false;
|
|
1698
|
-
}
|
|
1699
|
-
return true;
|
|
1700
|
-
}
|
|
1701
1698
|
function getSignatureFromTransaction(transaction) {
|
|
1702
1699
|
if (!base58Decoder)
|
|
1703
1700
|
base58Decoder = getBase58Decoder();
|
|
@@ -1707,10 +1704,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1707
1704
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1708
1705
|
);
|
|
1709
1706
|
}
|
|
1710
|
-
const
|
|
1711
|
-
return
|
|
1707
|
+
const transactionSignature = base58Decoder.decode(signatureBytes)[0];
|
|
1708
|
+
return transactionSignature;
|
|
1712
1709
|
}
|
|
1713
|
-
async function
|
|
1710
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1714
1711
|
const compiledMessage = compileMessage(transaction);
|
|
1715
1712
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1716
1713
|
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
@@ -1729,12 +1726,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1729
1726
|
Object.freeze(out);
|
|
1730
1727
|
return out;
|
|
1731
1728
|
}
|
|
1732
|
-
function
|
|
1733
|
-
|
|
1734
|
-
|
|
1729
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1730
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
1731
|
+
assertTransactionIsFullySigned(out);
|
|
1732
|
+
Object.freeze(out);
|
|
1733
|
+
return out;
|
|
1735
1734
|
}
|
|
1736
1735
|
function assertTransactionIsFullySigned(transaction) {
|
|
1737
|
-
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) =>
|
|
1736
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
|
|
1737
|
+
var _a, _b;
|
|
1738
|
+
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole(a.role))) != null ? _b : [];
|
|
1739
|
+
}).map((a) => a.address);
|
|
1738
1740
|
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
1739
1741
|
requiredSigners.forEach((address2) => {
|
|
1740
1742
|
if (!transaction.signatures[address2]) {
|
|
@@ -1746,15 +1748,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1746
1748
|
// src/wire-transaction.ts
|
|
1747
1749
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1748
1750
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1749
|
-
|
|
1750
|
-
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1751
|
-
}
|
|
1751
|
+
return getBase64Decoder().decode(wireTransactionBytes)[0];
|
|
1752
1752
|
}
|
|
1753
1753
|
|
|
1754
1754
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1755
1755
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1756
1756
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1757
|
-
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
1758
1757
|
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1759
1758
|
exports.createTransaction = createTransaction;
|
|
1760
1759
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
@@ -1763,13 +1762,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1763
1762
|
exports.getTransactionDecoder = getTransactionDecoder;
|
|
1764
1763
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1765
1764
|
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1766
|
-
exports.
|
|
1765
|
+
exports.partiallySignTransaction = partiallySignTransaction;
|
|
1767
1766
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1768
1767
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1769
1768
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1770
1769
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1771
1770
|
exports.signTransaction = signTransaction;
|
|
1772
|
-
exports.transactionSignature = transactionSignature;
|
|
1773
1771
|
|
|
1774
1772
|
return exports;
|
|
1775
1773
|
|