@solana/transactions 2.0.0-experimental.8245fa6 → 2.0.0-experimental.85b7dfe
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 +167 -190
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +165 -189
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +445 -423
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +165 -189
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +167 -188
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +165 -189
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +23 -20
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts +3 -2
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- 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.map +1 -0
- package/dist/types/compile-transaction.d.ts +2 -2
- 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.map +1 -0
- package/dist/types/durable-nonce.d.ts.map +1 -0
- 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.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 +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.map +1 -0
- package/dist/types/signatures.d.ts +5 -10
- 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 +13 -13
|
@@ -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
|
}
|
|
@@ -421,6 +444,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
421
444
|
});
|
|
422
445
|
}
|
|
423
446
|
}
|
|
447
|
+
function isTransactionWithBlockhashLifetime(transaction) {
|
|
448
|
+
const lifetimeConstraintShapeMatches = "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.blockhash === "string" && typeof transaction.lifetimeConstraint.lastValidBlockHeight === "bigint";
|
|
449
|
+
if (!lifetimeConstraintShapeMatches)
|
|
450
|
+
return false;
|
|
451
|
+
try {
|
|
452
|
+
assertIsBlockhash(transaction.lifetimeConstraint.blockhash);
|
|
453
|
+
return true;
|
|
454
|
+
} catch {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function assertIsTransactionWithBlockhashLifetime(transaction) {
|
|
459
|
+
if (!isTransactionWithBlockhashLifetime(transaction)) {
|
|
460
|
+
throw new Error("Transaction does not have a blockhash lifetime");
|
|
461
|
+
}
|
|
462
|
+
}
|
|
424
463
|
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
425
464
|
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
426
465
|
return transaction;
|
|
@@ -491,9 +530,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
491
530
|
};
|
|
492
531
|
}
|
|
493
532
|
function isAdvanceNonceAccountInstruction(instruction) {
|
|
533
|
+
var _a;
|
|
494
534
|
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
495
535
|
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
496
|
-
instruction.accounts
|
|
536
|
+
((_a = instruction.accounts) == null ? void 0 : _a.length) === 3 && // First account is nonce account address
|
|
497
537
|
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
498
538
|
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
499
539
|
instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
|
|
@@ -575,184 +615,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
575
615
|
return out;
|
|
576
616
|
}
|
|
577
617
|
|
|
578
|
-
// ../codecs-data-structures/dist/index.browser.js
|
|
579
|
-
function sumCodecSizes(sizes) {
|
|
580
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
581
|
-
}
|
|
582
|
-
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
583
|
-
if (typeof size === "number") {
|
|
584
|
-
return [size, offset];
|
|
585
|
-
}
|
|
586
|
-
if (typeof size === "object") {
|
|
587
|
-
return size.decode(bytes, offset);
|
|
588
|
-
}
|
|
589
|
-
if (size === "remainder") {
|
|
590
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
591
|
-
if (childrenSize === null) {
|
|
592
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
593
|
-
}
|
|
594
|
-
const remainder = bytes.slice(offset).length;
|
|
595
|
-
if (remainder % childrenSize !== 0) {
|
|
596
|
-
throw new Error(
|
|
597
|
-
`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.`
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
return [remainder / childrenSize, offset];
|
|
601
|
-
}
|
|
602
|
-
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
603
|
-
}
|
|
604
|
-
function getArrayLikeCodecSizeDescription(size) {
|
|
605
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
606
|
-
}
|
|
607
|
-
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
608
|
-
if (typeof size !== "number")
|
|
609
|
-
return null;
|
|
610
|
-
if (size === 0)
|
|
611
|
-
return 0;
|
|
612
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
613
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
614
|
-
}
|
|
615
|
-
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
616
|
-
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
617
|
-
}
|
|
618
|
-
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
619
|
-
if (expected !== actual) {
|
|
620
|
-
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
function arrayCodecHelper(item, size, description) {
|
|
624
|
-
if (size === "remainder" && item.fixedSize === null) {
|
|
625
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
626
|
-
}
|
|
627
|
-
return {
|
|
628
|
-
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
629
|
-
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
630
|
-
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
function getArrayEncoder(item, options = {}) {
|
|
634
|
-
const size = options.size ?? getU32Encoder();
|
|
635
|
-
return {
|
|
636
|
-
...arrayCodecHelper(item, size, options.description),
|
|
637
|
-
encode: (value) => {
|
|
638
|
-
if (typeof size === "number") {
|
|
639
|
-
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
640
|
-
}
|
|
641
|
-
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
function getArrayDecoder(item, options = {}) {
|
|
646
|
-
const size = options.size ?? getU32Decoder();
|
|
647
|
-
return {
|
|
648
|
-
...arrayCodecHelper(item, size, options.description),
|
|
649
|
-
decode: (bytes, offset = 0) => {
|
|
650
|
-
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
651
|
-
return [[], offset];
|
|
652
|
-
}
|
|
653
|
-
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
|
|
654
|
-
offset = newOffset;
|
|
655
|
-
const values = [];
|
|
656
|
-
for (let i = 0; i < resolvedSize; i += 1) {
|
|
657
|
-
const [value, newOffset2] = item.decode(bytes, offset);
|
|
658
|
-
values.push(value);
|
|
659
|
-
offset = newOffset2;
|
|
660
|
-
}
|
|
661
|
-
return [values, offset];
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
function getBytesEncoder(options = {}) {
|
|
666
|
-
const size = options.size ?? "variable";
|
|
667
|
-
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
668
|
-
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
669
|
-
const byteEncoder = {
|
|
670
|
-
description,
|
|
671
|
-
encode: (value) => value,
|
|
672
|
-
fixedSize: null,
|
|
673
|
-
maxSize: null
|
|
674
|
-
};
|
|
675
|
-
if (size === "variable") {
|
|
676
|
-
return byteEncoder;
|
|
677
|
-
}
|
|
678
|
-
if (typeof size === "number") {
|
|
679
|
-
return fixEncoder(byteEncoder, size, description);
|
|
680
|
-
}
|
|
681
|
-
return {
|
|
682
|
-
...byteEncoder,
|
|
683
|
-
encode: (value) => {
|
|
684
|
-
const contentBytes = byteEncoder.encode(value);
|
|
685
|
-
const lengthBytes = size.encode(contentBytes.length);
|
|
686
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
function getBytesDecoder(options = {}) {
|
|
691
|
-
const size = options.size ?? "variable";
|
|
692
|
-
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
693
|
-
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
694
|
-
const byteDecoder = {
|
|
695
|
-
decode: (bytes, offset = 0) => {
|
|
696
|
-
const slice = bytes.slice(offset);
|
|
697
|
-
return [slice, offset + slice.length];
|
|
698
|
-
},
|
|
699
|
-
description,
|
|
700
|
-
fixedSize: null,
|
|
701
|
-
maxSize: null
|
|
702
|
-
};
|
|
703
|
-
if (size === "variable") {
|
|
704
|
-
return byteDecoder;
|
|
705
|
-
}
|
|
706
|
-
if (typeof size === "number") {
|
|
707
|
-
return fixDecoder(byteDecoder, size, description);
|
|
708
|
-
}
|
|
709
|
-
return {
|
|
710
|
-
...byteDecoder,
|
|
711
|
-
decode: (bytes, offset = 0) => {
|
|
712
|
-
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
713
|
-
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
714
|
-
const length = Number(lengthBigInt);
|
|
715
|
-
offset = lengthOffset;
|
|
716
|
-
const contentBytes = bytes.slice(offset, offset + length);
|
|
717
|
-
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
718
|
-
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
719
|
-
offset += contentOffset;
|
|
720
|
-
return [value, offset];
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
function structCodecHelper(fields, description) {
|
|
725
|
-
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
726
|
-
return {
|
|
727
|
-
description: description ?? `struct(${fieldDescriptions})`,
|
|
728
|
-
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
729
|
-
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
function getStructEncoder(fields, options = {}) {
|
|
733
|
-
return {
|
|
734
|
-
...structCodecHelper(fields, options.description),
|
|
735
|
-
encode: (struct) => {
|
|
736
|
-
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
737
|
-
return mergeBytes(fieldBytes);
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
function getStructDecoder(fields, options = {}) {
|
|
742
|
-
return {
|
|
743
|
-
...structCodecHelper(fields, options.description),
|
|
744
|
-
decode: (bytes, offset = 0) => {
|
|
745
|
-
const struct = {};
|
|
746
|
-
fields.forEach(([key, codec]) => {
|
|
747
|
-
const [value, newOffset] = codec.decode(bytes, offset);
|
|
748
|
-
offset = newOffset;
|
|
749
|
-
struct[key] = value;
|
|
750
|
-
});
|
|
751
|
-
return [struct, offset];
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
|
|
756
618
|
// ../assertions/dist/index.browser.js
|
|
757
619
|
function assertIsSecureContext() {
|
|
758
620
|
if (!globalThis.isSecureContext) {
|
|
@@ -762,14 +624,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
762
624
|
}
|
|
763
625
|
}
|
|
764
626
|
async function assertKeyExporterIsAvailable() {
|
|
627
|
+
var _a;
|
|
765
628
|
assertIsSecureContext();
|
|
766
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
629
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
|
|
767
630
|
throw new Error("No key export implementation could be found");
|
|
768
631
|
}
|
|
769
632
|
}
|
|
770
633
|
async function assertSigningCapabilityIsAvailable() {
|
|
634
|
+
var _a;
|
|
771
635
|
assertIsSecureContext();
|
|
772
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
636
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
|
|
773
637
|
throw new Error("No signing implementation could be found");
|
|
774
638
|
}
|
|
775
639
|
}
|
|
@@ -796,8 +660,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
796
660
|
) {
|
|
797
661
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
798
662
|
}
|
|
799
|
-
const
|
|
800
|
-
const bytes =
|
|
663
|
+
const base58Encoder2 = getMemoizedBase58Encoder();
|
|
664
|
+
const bytes = base58Encoder2.encode(putativeAddress);
|
|
801
665
|
const numBytes = bytes.byteLength;
|
|
802
666
|
if (numBytes !== 32) {
|
|
803
667
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
@@ -813,9 +677,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
813
677
|
return putativeAddress;
|
|
814
678
|
}
|
|
815
679
|
function getAddressEncoder(config) {
|
|
680
|
+
var _a;
|
|
816
681
|
return mapEncoder(
|
|
817
682
|
getStringEncoder({
|
|
818
|
-
description: config
|
|
683
|
+
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
819
684
|
encoding: getMemoizedBase58Encoder(),
|
|
820
685
|
size: 32
|
|
821
686
|
}),
|
|
@@ -823,8 +688,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
823
688
|
);
|
|
824
689
|
}
|
|
825
690
|
function getAddressDecoder(config) {
|
|
691
|
+
var _a;
|
|
826
692
|
return getStringDecoder({
|
|
827
|
-
description: config
|
|
693
|
+
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
828
694
|
encoding: getMemoizedBase58Decoder(),
|
|
829
695
|
size: 32
|
|
830
696
|
});
|
|
@@ -851,7 +717,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
851
717
|
|
|
852
718
|
// src/accounts.ts
|
|
853
719
|
function upsert(addressMap, address2, update) {
|
|
854
|
-
|
|
720
|
+
var _a;
|
|
721
|
+
addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole.READONLY });
|
|
855
722
|
}
|
|
856
723
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
857
724
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -1119,139 +986,186 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1119
986
|
};
|
|
1120
987
|
}
|
|
1121
988
|
|
|
1122
|
-
//
|
|
1123
|
-
function
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
989
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
990
|
+
function sumCodecSizes(sizes) {
|
|
991
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
992
|
+
}
|
|
993
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
994
|
+
if (typeof size === "number") {
|
|
995
|
+
return [size, offset];
|
|
996
|
+
}
|
|
997
|
+
if (typeof size === "object") {
|
|
998
|
+
return size.decode(bytes, offset);
|
|
999
|
+
}
|
|
1000
|
+
if (size === "remainder") {
|
|
1001
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1002
|
+
if (childrenSize === null) {
|
|
1003
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1130
1004
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1005
|
+
const remainder = bytes.slice(offset).length;
|
|
1006
|
+
if (remainder % childrenSize !== 0) {
|
|
1007
|
+
throw new Error(
|
|
1008
|
+
`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.`
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
return [remainder / childrenSize, offset];
|
|
1133
1012
|
}
|
|
1134
|
-
|
|
1135
|
-
compiledMessage,
|
|
1136
|
-
signatures
|
|
1137
|
-
};
|
|
1013
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1138
1014
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
function pipe(init, ...fns) {
|
|
1142
|
-
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1015
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
1016
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
1143
1017
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1018
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
1019
|
+
if (typeof size !== "number")
|
|
1020
|
+
return null;
|
|
1021
|
+
if (size === 0)
|
|
1022
|
+
return 0;
|
|
1023
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1024
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
1025
|
+
}
|
|
1026
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
1027
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
1028
|
+
}
|
|
1029
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1030
|
+
if (expected !== actual) {
|
|
1031
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1158
1032
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
});
|
|
1164
|
-
accountIndex++;
|
|
1033
|
+
}
|
|
1034
|
+
function arrayCodecHelper(item, size, description) {
|
|
1035
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
1036
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1165
1037
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1038
|
+
return {
|
|
1039
|
+
description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1040
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1041
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
function getArrayEncoder(item, config = {}) {
|
|
1045
|
+
var _a;
|
|
1046
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
1047
|
+
return {
|
|
1048
|
+
...arrayCodecHelper(item, size, config.description),
|
|
1049
|
+
encode: (value) => {
|
|
1050
|
+
if (typeof size === "number") {
|
|
1051
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
1052
|
+
}
|
|
1053
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
function getArrayDecoder(item, config = {}) {
|
|
1058
|
+
var _a;
|
|
1059
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
1060
|
+
return {
|
|
1061
|
+
...arrayCodecHelper(item, size, config.description),
|
|
1062
|
+
decode: (bytes, offset = 0) => {
|
|
1063
|
+
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
1064
|
+
return [[], offset];
|
|
1065
|
+
}
|
|
1066
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
|
|
1067
|
+
offset = newOffset;
|
|
1068
|
+
const values = [];
|
|
1069
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1070
|
+
const [value, newOffset2] = item.decode(bytes, offset);
|
|
1071
|
+
values.push(value);
|
|
1072
|
+
offset = newOffset2;
|
|
1073
|
+
}
|
|
1074
|
+
return [values, offset];
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
function getBytesEncoder(config = {}) {
|
|
1079
|
+
var _a, _b;
|
|
1080
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
1081
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1082
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
1083
|
+
const byteEncoder = {
|
|
1084
|
+
description,
|
|
1085
|
+
encode: (value) => value,
|
|
1086
|
+
fixedSize: null,
|
|
1087
|
+
maxSize: null
|
|
1088
|
+
};
|
|
1089
|
+
if (size === "variable") {
|
|
1090
|
+
return byteEncoder;
|
|
1172
1091
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
address: message.staticAccounts[accountIndex],
|
|
1176
|
-
role: AccountRole.READONLY
|
|
1177
|
-
});
|
|
1178
|
-
accountIndex++;
|
|
1092
|
+
if (typeof size === "number") {
|
|
1093
|
+
return fixEncoder(byteEncoder, size, description);
|
|
1179
1094
|
}
|
|
1180
|
-
return
|
|
1095
|
+
return {
|
|
1096
|
+
...byteEncoder,
|
|
1097
|
+
encode: (value) => {
|
|
1098
|
+
const contentBytes = byteEncoder.encode(value);
|
|
1099
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
1100
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1181
1103
|
}
|
|
1182
|
-
function
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1104
|
+
function getBytesDecoder(config = {}) {
|
|
1105
|
+
var _a, _b;
|
|
1106
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
1107
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
1108
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
1109
|
+
const byteDecoder = {
|
|
1110
|
+
decode: (bytes, offset = 0) => {
|
|
1111
|
+
const slice = bytes.slice(offset);
|
|
1112
|
+
return [slice, offset + slice.length];
|
|
1113
|
+
},
|
|
1114
|
+
description,
|
|
1115
|
+
fixedSize: null,
|
|
1116
|
+
maxSize: null
|
|
1117
|
+
};
|
|
1118
|
+
if (size === "variable") {
|
|
1119
|
+
return byteDecoder;
|
|
1120
|
+
}
|
|
1121
|
+
if (typeof size === "number") {
|
|
1122
|
+
return fixDecoder(byteDecoder, size, description);
|
|
1186
1123
|
}
|
|
1187
|
-
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
1188
|
-
const { data } = instruction;
|
|
1189
1124
|
return {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1125
|
+
...byteDecoder,
|
|
1126
|
+
decode: (bytes, offset = 0) => {
|
|
1127
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
1128
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
1129
|
+
const length = Number(lengthBigInt);
|
|
1130
|
+
offset = lengthOffset;
|
|
1131
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
1132
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1133
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
1134
|
+
offset += contentOffset;
|
|
1135
|
+
return [value, offset];
|
|
1136
|
+
}
|
|
1193
1137
|
};
|
|
1194
1138
|
}
|
|
1195
|
-
function
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
} else {
|
|
1203
|
-
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
1204
|
-
assertIsAddress(nonceAccountAddress);
|
|
1205
|
-
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
1206
|
-
assertIsAddress(nonceAuthorityAddress);
|
|
1207
|
-
return {
|
|
1208
|
-
nonce: messageLifetimeToken,
|
|
1209
|
-
nonceAccountAddress,
|
|
1210
|
-
nonceAuthorityAddress
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1139
|
+
function structCodecHelper(fields, description) {
|
|
1140
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
1141
|
+
return {
|
|
1142
|
+
description: description != null ? description : `struct(${fieldDescriptions})`,
|
|
1143
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
1144
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1145
|
+
};
|
|
1213
1146
|
}
|
|
1214
|
-
function
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
return acc;
|
|
1223
|
-
const address2 = staticAccounts[index];
|
|
1224
|
-
return { ...acc, [address2]: sig };
|
|
1225
|
-
}, {});
|
|
1147
|
+
function getStructEncoder(fields, config = {}) {
|
|
1148
|
+
return {
|
|
1149
|
+
...structCodecHelper(fields, config.description),
|
|
1150
|
+
encode: (struct) => {
|
|
1151
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
1152
|
+
return mergeBytes(fieldBytes);
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1226
1155
|
}
|
|
1227
|
-
function
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
const lifetimeConstraint = getLifetimeConstraint(
|
|
1241
|
-
compiledMessage.lifetimeToken,
|
|
1242
|
-
firstInstruction,
|
|
1243
|
-
lastValidBlockHeight
|
|
1244
|
-
);
|
|
1245
|
-
const signatures = convertSignatures(compiledTransaction);
|
|
1246
|
-
return pipe(
|
|
1247
|
-
createTransaction({ version: compiledMessage.version }),
|
|
1248
|
-
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
1249
|
-
(tx) => instructions.reduce((acc, instruction) => {
|
|
1250
|
-
return appendTransactionInstruction(instruction, acc);
|
|
1251
|
-
}, tx),
|
|
1252
|
-
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
1253
|
-
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
1254
|
-
);
|
|
1156
|
+
function getStructDecoder(fields, config = {}) {
|
|
1157
|
+
return {
|
|
1158
|
+
...structCodecHelper(fields, config.description),
|
|
1159
|
+
decode: (bytes, offset = 0) => {
|
|
1160
|
+
const struct = {};
|
|
1161
|
+
fields.forEach(([key, codec]) => {
|
|
1162
|
+
const [value, newOffset] = codec.decode(bytes, offset);
|
|
1163
|
+
offset = newOffset;
|
|
1164
|
+
struct[key] = value;
|
|
1165
|
+
});
|
|
1166
|
+
return [struct, offset];
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1255
1169
|
}
|
|
1256
1170
|
|
|
1257
1171
|
// src/serializers/address-table-lookup.ts
|
|
@@ -1323,7 +1237,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1323
1237
|
const encoder = getMemoizedU8Encoder();
|
|
1324
1238
|
return {
|
|
1325
1239
|
...encoder,
|
|
1326
|
-
description: description
|
|
1240
|
+
description: description != null ? description : encoder.description
|
|
1327
1241
|
};
|
|
1328
1242
|
}
|
|
1329
1243
|
var memoizedU8Decoder;
|
|
@@ -1336,7 +1250,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1336
1250
|
const decoder = getMemoizedU8Decoder();
|
|
1337
1251
|
return {
|
|
1338
1252
|
...decoder,
|
|
1339
|
-
description: description
|
|
1253
|
+
description: description != null ? description : decoder.description
|
|
1340
1254
|
};
|
|
1341
1255
|
}
|
|
1342
1256
|
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
@@ -1390,13 +1304,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1390
1304
|
]),
|
|
1391
1305
|
// Convert an instruction to have all fields defined
|
|
1392
1306
|
(instruction) => {
|
|
1307
|
+
var _a, _b;
|
|
1393
1308
|
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1394
1309
|
return instruction;
|
|
1395
1310
|
}
|
|
1396
1311
|
return {
|
|
1397
1312
|
...instruction,
|
|
1398
|
-
accountIndices: instruction.accountIndices
|
|
1399
|
-
data: instruction.data
|
|
1313
|
+
accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
|
|
1314
|
+
data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
|
|
1400
1315
|
};
|
|
1401
1316
|
}
|
|
1402
1317
|
);
|
|
@@ -1488,12 +1403,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1488
1403
|
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1489
1404
|
]),
|
|
1490
1405
|
(value) => {
|
|
1406
|
+
var _a;
|
|
1491
1407
|
if (value.version === "legacy") {
|
|
1492
1408
|
return value;
|
|
1493
1409
|
}
|
|
1494
1410
|
return {
|
|
1495
1411
|
...value,
|
|
1496
|
-
addressTableLookups: value.addressTableLookups
|
|
1412
|
+
addressTableLookups: (_a = value.addressTableLookups) != null ? _a : []
|
|
1497
1413
|
};
|
|
1498
1414
|
}
|
|
1499
1415
|
);
|
|
@@ -1588,13 +1504,153 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1588
1504
|
description: messageDescription
|
|
1589
1505
|
}),
|
|
1590
1506
|
({ addressTableLookups, ...restOfMessage }) => {
|
|
1591
|
-
if (restOfMessage.version === "legacy" || !addressTableLookups
|
|
1507
|
+
if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
|
|
1592
1508
|
return restOfMessage;
|
|
1593
1509
|
}
|
|
1594
1510
|
return { ...restOfMessage, addressTableLookups };
|
|
1595
1511
|
}
|
|
1596
1512
|
);
|
|
1597
1513
|
}
|
|
1514
|
+
function getCompiledMessageCodec() {
|
|
1515
|
+
return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
// src/compile-transaction.ts
|
|
1519
|
+
function getCompiledTransaction(transaction) {
|
|
1520
|
+
var _a;
|
|
1521
|
+
const compiledMessage = compileMessage(transaction);
|
|
1522
|
+
let signatures;
|
|
1523
|
+
if ("signatures" in transaction) {
|
|
1524
|
+
signatures = [];
|
|
1525
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1526
|
+
signatures[ii] = (_a = transaction.signatures[compiledMessage.staticAccounts[ii]]) != null ? _a : new Uint8Array(Array(64).fill(0));
|
|
1527
|
+
}
|
|
1528
|
+
} else {
|
|
1529
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1530
|
+
}
|
|
1531
|
+
return {
|
|
1532
|
+
compiledMessage,
|
|
1533
|
+
signatures
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// ../functional/dist/index.browser.js
|
|
1538
|
+
function pipe(init, ...fns) {
|
|
1539
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// src/decompile-transaction.ts
|
|
1543
|
+
function getAccountMetas(message) {
|
|
1544
|
+
const { header } = message;
|
|
1545
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
1546
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
1547
|
+
const accountMetas = [];
|
|
1548
|
+
let accountIndex = 0;
|
|
1549
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
1550
|
+
accountMetas.push({
|
|
1551
|
+
address: message.staticAccounts[accountIndex],
|
|
1552
|
+
role: AccountRole.WRITABLE_SIGNER
|
|
1553
|
+
});
|
|
1554
|
+
accountIndex++;
|
|
1555
|
+
}
|
|
1556
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
1557
|
+
accountMetas.push({
|
|
1558
|
+
address: message.staticAccounts[accountIndex],
|
|
1559
|
+
role: AccountRole.READONLY_SIGNER
|
|
1560
|
+
});
|
|
1561
|
+
accountIndex++;
|
|
1562
|
+
}
|
|
1563
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
1564
|
+
accountMetas.push({
|
|
1565
|
+
address: message.staticAccounts[accountIndex],
|
|
1566
|
+
role: AccountRole.WRITABLE
|
|
1567
|
+
});
|
|
1568
|
+
accountIndex++;
|
|
1569
|
+
}
|
|
1570
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
1571
|
+
accountMetas.push({
|
|
1572
|
+
address: message.staticAccounts[accountIndex],
|
|
1573
|
+
role: AccountRole.READONLY
|
|
1574
|
+
});
|
|
1575
|
+
accountIndex++;
|
|
1576
|
+
}
|
|
1577
|
+
return accountMetas;
|
|
1578
|
+
}
|
|
1579
|
+
function convertInstruction(instruction, accountMetas) {
|
|
1580
|
+
var _a, _b;
|
|
1581
|
+
const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
|
|
1582
|
+
if (!programAddress) {
|
|
1583
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
1584
|
+
}
|
|
1585
|
+
const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
|
|
1586
|
+
const { data } = instruction;
|
|
1587
|
+
return {
|
|
1588
|
+
programAddress,
|
|
1589
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
1590
|
+
...data && data.length ? { data } : {}
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
1594
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1595
|
+
return {
|
|
1596
|
+
blockhash: messageLifetimeToken,
|
|
1597
|
+
lastValidBlockHeight: lastValidBlockHeight != null ? lastValidBlockHeight : 2n ** 64n - 1n
|
|
1598
|
+
// U64 MAX
|
|
1599
|
+
};
|
|
1600
|
+
} else {
|
|
1601
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
1602
|
+
assertIsAddress(nonceAccountAddress);
|
|
1603
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
1604
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
1605
|
+
return {
|
|
1606
|
+
nonce: messageLifetimeToken,
|
|
1607
|
+
nonceAccountAddress,
|
|
1608
|
+
nonceAuthorityAddress
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
function convertSignatures(compiledTransaction) {
|
|
1613
|
+
const {
|
|
1614
|
+
compiledMessage: { staticAccounts },
|
|
1615
|
+
signatures
|
|
1616
|
+
} = compiledTransaction;
|
|
1617
|
+
return signatures.reduce((acc, sig, index) => {
|
|
1618
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
1619
|
+
if (allZeros)
|
|
1620
|
+
return acc;
|
|
1621
|
+
const address2 = staticAccounts[index];
|
|
1622
|
+
return { ...acc, [address2]: sig };
|
|
1623
|
+
}, {});
|
|
1624
|
+
}
|
|
1625
|
+
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
1626
|
+
const { compiledMessage } = compiledTransaction;
|
|
1627
|
+
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
1628
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
1629
|
+
}
|
|
1630
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
1631
|
+
if (!feePayer)
|
|
1632
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
1633
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
1634
|
+
const instructions = compiledMessage.instructions.map(
|
|
1635
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
1636
|
+
);
|
|
1637
|
+
const firstInstruction = instructions[0];
|
|
1638
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
1639
|
+
compiledMessage.lifetimeToken,
|
|
1640
|
+
firstInstruction,
|
|
1641
|
+
lastValidBlockHeight
|
|
1642
|
+
);
|
|
1643
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
1644
|
+
return pipe(
|
|
1645
|
+
createTransaction({ version: compiledMessage.version }),
|
|
1646
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
1647
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
1648
|
+
return appendTransactionInstruction(instruction, acc);
|
|
1649
|
+
}, tx),
|
|
1650
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
1651
|
+
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1598
1654
|
|
|
1599
1655
|
// src/serializers/transaction.ts
|
|
1600
1656
|
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
@@ -1657,47 +1713,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1657
1713
|
}
|
|
1658
1714
|
|
|
1659
1715
|
// src/signatures.ts
|
|
1660
|
-
var base58Encoder2;
|
|
1661
1716
|
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
1717
|
function getSignatureFromTransaction(transaction) {
|
|
1702
1718
|
if (!base58Decoder)
|
|
1703
1719
|
base58Decoder = getBase58Decoder();
|
|
@@ -1707,10 +1723,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1707
1723
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1708
1724
|
);
|
|
1709
1725
|
}
|
|
1710
|
-
const
|
|
1711
|
-
return
|
|
1726
|
+
const transactionSignature = base58Decoder.decode(signatureBytes)[0];
|
|
1727
|
+
return transactionSignature;
|
|
1712
1728
|
}
|
|
1713
|
-
async function
|
|
1729
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1714
1730
|
const compiledMessage = compileMessage(transaction);
|
|
1715
1731
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1716
1732
|
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
@@ -1729,12 +1745,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1729
1745
|
Object.freeze(out);
|
|
1730
1746
|
return out;
|
|
1731
1747
|
}
|
|
1732
|
-
function
|
|
1733
|
-
|
|
1734
|
-
|
|
1748
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1749
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
1750
|
+
assertTransactionIsFullySigned(out);
|
|
1751
|
+
Object.freeze(out);
|
|
1752
|
+
return out;
|
|
1735
1753
|
}
|
|
1736
1754
|
function assertTransactionIsFullySigned(transaction) {
|
|
1737
|
-
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) =>
|
|
1755
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
|
|
1756
|
+
var _a, _b;
|
|
1757
|
+
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole(a.role))) != null ? _b : [];
|
|
1758
|
+
}).map((a) => a.address);
|
|
1738
1759
|
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
1739
1760
|
requiredSigners.forEach((address2) => {
|
|
1740
1761
|
if (!transaction.signatures[address2]) {
|
|
@@ -1746,30 +1767,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1746
1767
|
// src/wire-transaction.ts
|
|
1747
1768
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1748
1769
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1749
|
-
|
|
1750
|
-
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1751
|
-
}
|
|
1770
|
+
return getBase64Decoder().decode(wireTransactionBytes)[0];
|
|
1752
1771
|
}
|
|
1753
1772
|
|
|
1754
1773
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1755
1774
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1756
1775
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1757
|
-
exports.
|
|
1776
|
+
exports.assertIsTransactionWithBlockhashLifetime = assertIsTransactionWithBlockhashLifetime;
|
|
1758
1777
|
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1778
|
+
exports.compileMessage = compileMessage;
|
|
1759
1779
|
exports.createTransaction = createTransaction;
|
|
1760
1780
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1781
|
+
exports.getCompiledMessageCodec = getCompiledMessageCodec;
|
|
1782
|
+
exports.getCompiledMessageDecoder = getCompiledMessageDecoder;
|
|
1783
|
+
exports.getCompiledMessageEncoder = getCompiledMessageEncoder;
|
|
1761
1784
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1762
1785
|
exports.getTransactionCodec = getTransactionCodec;
|
|
1763
1786
|
exports.getTransactionDecoder = getTransactionDecoder;
|
|
1764
1787
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1765
1788
|
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1766
|
-
exports.
|
|
1789
|
+
exports.partiallySignTransaction = partiallySignTransaction;
|
|
1767
1790
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1768
1791
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1769
1792
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1770
1793
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1771
1794
|
exports.signTransaction = signTransaction;
|
|
1772
|
-
exports.transactionSignature = transactionSignature;
|
|
1773
1795
|
|
|
1774
1796
|
return exports;
|
|
1775
1797
|
|