@solana/transactions 2.0.0-experimental.af584fc → 2.0.0-experimental.af9f012
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/dist/index.browser.cjs +288 -379
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +288 -383
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +288 -383
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +286 -379
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +288 -383
- package/dist/index.node.js.map +1 -1
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts +5 -7
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts +4 -4
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +1 -1
- package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
- package/dist/types/compile-header.d.ts +1 -1
- package/dist/types/compile-header.d.ts.map +1 -0
- package/dist/types/compile-instructions.d.ts +1 -1
- package/dist/types/compile-instructions.d.ts.map +1 -0
- package/dist/types/compile-lifetime-token.d.ts +1 -1
- package/dist/types/compile-lifetime-token.d.ts.map +1 -0
- package/dist/types/compile-static-accounts.d.ts +1 -1
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts +3 -3
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts +1 -1
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/decompile-transaction.d.ts +12 -4
- package/dist/types/decompile-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +2 -2
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +2 -2
- package/dist/types/fee-payer.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -11
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instructions.d.ts +2 -2
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/message.d.ts +6 -6
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts +5 -5
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
- package/dist/types/serializers/header.d.ts +5 -5
- package/dist/types/serializers/header.d.ts.map +1 -0
- package/dist/types/serializers/index.d.ts +2 -2
- package/dist/types/serializers/index.d.ts.map +1 -0
- package/dist/types/serializers/instruction.d.ts +5 -5
- package/dist/types/serializers/instruction.d.ts.map +1 -0
- package/dist/types/serializers/message.d.ts +5 -5
- package/dist/types/serializers/message.d.ts.map +1 -0
- package/dist/types/serializers/transaction-version.d.ts +5 -5
- package/dist/types/serializers/transaction-version.d.ts.map +1 -0
- package/dist/types/serializers/transaction.d.ts +9 -6
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +2 -2
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts +1 -1
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts +1 -1
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +18 -17
- package/dist/index.development.js +0 -1783
- package/dist/index.development.js.map +0 -1
- package/dist/index.production.min.js +0 -31
package/dist/index.browser.cjs
CHANGED
|
@@ -2,30 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var codecsStrings = require('@solana/codecs-strings');
|
|
4
4
|
var addresses = require('@solana/addresses');
|
|
5
|
+
var functional = require('@solana/functional');
|
|
5
6
|
var codecsCore = require('@solana/codecs-core');
|
|
6
7
|
var codecsDataStructures = require('@solana/codecs-data-structures');
|
|
7
8
|
var codecsNumbers = require('@solana/codecs-numbers');
|
|
8
|
-
var functional = require('@solana/functional');
|
|
9
9
|
var keys = require('@solana/keys');
|
|
10
10
|
|
|
11
|
-
// ../
|
|
12
|
-
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
13
|
-
|
|
14
|
-
// src/unsigned-transaction.ts
|
|
15
|
-
function getUnsignedTransaction(transaction) {
|
|
16
|
-
if ("signatures" in transaction) {
|
|
17
|
-
const {
|
|
18
|
-
signatures: _,
|
|
19
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
-
...unsignedTransaction
|
|
21
|
-
} = transaction;
|
|
22
|
-
return unsignedTransaction;
|
|
23
|
-
} else {
|
|
24
|
-
return transaction;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/blockhash.ts
|
|
11
|
+
// ../rpc-types/dist/index.browser.js
|
|
29
12
|
var base58Encoder;
|
|
30
13
|
function assertIsBlockhash(putativeBlockhash) {
|
|
31
14
|
if (!base58Encoder)
|
|
@@ -49,6 +32,38 @@ function assertIsBlockhash(putativeBlockhash) {
|
|
|
49
32
|
});
|
|
50
33
|
}
|
|
51
34
|
}
|
|
35
|
+
|
|
36
|
+
// src/unsigned-transaction.ts
|
|
37
|
+
function getUnsignedTransaction(transaction) {
|
|
38
|
+
if ("signatures" in transaction) {
|
|
39
|
+
const {
|
|
40
|
+
signatures: _,
|
|
41
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
42
|
+
...unsignedTransaction
|
|
43
|
+
} = transaction;
|
|
44
|
+
return unsignedTransaction;
|
|
45
|
+
} else {
|
|
46
|
+
return transaction;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/blockhash.ts
|
|
51
|
+
function isTransactionWithBlockhashLifetime(transaction) {
|
|
52
|
+
const lifetimeConstraintShapeMatches = "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.blockhash === "string" && typeof transaction.lifetimeConstraint.lastValidBlockHeight === "bigint";
|
|
53
|
+
if (!lifetimeConstraintShapeMatches)
|
|
54
|
+
return false;
|
|
55
|
+
try {
|
|
56
|
+
assertIsBlockhash(transaction.lifetimeConstraint.blockhash);
|
|
57
|
+
return true;
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function assertIsTransactionWithBlockhashLifetime(transaction) {
|
|
63
|
+
if (!isTransactionWithBlockhashLifetime(transaction)) {
|
|
64
|
+
throw new Error("Transaction does not have a blockhash lifetime");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
52
67
|
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
53
68
|
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
54
69
|
return transaction;
|
|
@@ -202,6 +217,151 @@ function prependTransactionInstruction(instruction, transaction) {
|
|
|
202
217
|
Object.freeze(out);
|
|
203
218
|
return out;
|
|
204
219
|
}
|
|
220
|
+
|
|
221
|
+
// src/decompile-transaction.ts
|
|
222
|
+
function getAccountMetas(message) {
|
|
223
|
+
const { header } = message;
|
|
224
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
225
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
226
|
+
const accountMetas = [];
|
|
227
|
+
let accountIndex = 0;
|
|
228
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
229
|
+
accountMetas.push({
|
|
230
|
+
address: message.staticAccounts[accountIndex],
|
|
231
|
+
role: AccountRole.WRITABLE_SIGNER
|
|
232
|
+
});
|
|
233
|
+
accountIndex++;
|
|
234
|
+
}
|
|
235
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
236
|
+
accountMetas.push({
|
|
237
|
+
address: message.staticAccounts[accountIndex],
|
|
238
|
+
role: AccountRole.READONLY_SIGNER
|
|
239
|
+
});
|
|
240
|
+
accountIndex++;
|
|
241
|
+
}
|
|
242
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
243
|
+
accountMetas.push({
|
|
244
|
+
address: message.staticAccounts[accountIndex],
|
|
245
|
+
role: AccountRole.WRITABLE
|
|
246
|
+
});
|
|
247
|
+
accountIndex++;
|
|
248
|
+
}
|
|
249
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
250
|
+
accountMetas.push({
|
|
251
|
+
address: message.staticAccounts[accountIndex],
|
|
252
|
+
role: AccountRole.READONLY
|
|
253
|
+
});
|
|
254
|
+
accountIndex++;
|
|
255
|
+
}
|
|
256
|
+
return accountMetas;
|
|
257
|
+
}
|
|
258
|
+
function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTableAddress) {
|
|
259
|
+
const compiledAddressTableLookupAddresses = compiledAddressTableLookups.map((l) => l.lookupTableAddress);
|
|
260
|
+
const missing = compiledAddressTableLookupAddresses.filter((a) => addressesByLookupTableAddress[a] === void 0);
|
|
261
|
+
if (missing.length > 0) {
|
|
262
|
+
const missingAddresses = missing.join(", ");
|
|
263
|
+
throw new Error(`Addresses not provided for lookup tables: [${missingAddresses}]`);
|
|
264
|
+
}
|
|
265
|
+
const readOnlyMetas = [];
|
|
266
|
+
const writableMetas = [];
|
|
267
|
+
for (const lookup of compiledAddressTableLookups) {
|
|
268
|
+
const addresses = addressesByLookupTableAddress[lookup.lookupTableAddress];
|
|
269
|
+
const highestIndex = Math.max(...lookup.readableIndices, ...lookup.writableIndices);
|
|
270
|
+
if (highestIndex >= addresses.length) {
|
|
271
|
+
throw new Error(
|
|
272
|
+
`Cannot look up index ${highestIndex} in lookup table [${lookup.lookupTableAddress}]. The lookup table may have been extended since the addresses provided were retrieved.`
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
const readOnlyForLookup = lookup.readableIndices.map((r) => ({
|
|
276
|
+
address: addresses[r],
|
|
277
|
+
addressIndex: r,
|
|
278
|
+
lookupTableAddress: lookup.lookupTableAddress,
|
|
279
|
+
role: AccountRole.READONLY
|
|
280
|
+
}));
|
|
281
|
+
readOnlyMetas.push(...readOnlyForLookup);
|
|
282
|
+
const writableForLookup = lookup.writableIndices.map((w) => ({
|
|
283
|
+
address: addresses[w],
|
|
284
|
+
addressIndex: w,
|
|
285
|
+
lookupTableAddress: lookup.lookupTableAddress,
|
|
286
|
+
role: AccountRole.WRITABLE
|
|
287
|
+
}));
|
|
288
|
+
writableMetas.push(...writableForLookup);
|
|
289
|
+
}
|
|
290
|
+
return [...writableMetas, ...readOnlyMetas];
|
|
291
|
+
}
|
|
292
|
+
function convertInstruction(instruction, accountMetas) {
|
|
293
|
+
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
294
|
+
if (!programAddress) {
|
|
295
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
296
|
+
}
|
|
297
|
+
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
298
|
+
const { data } = instruction;
|
|
299
|
+
return {
|
|
300
|
+
programAddress,
|
|
301
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
302
|
+
...data && data.length ? { data } : {}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
306
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
307
|
+
return {
|
|
308
|
+
blockhash: messageLifetimeToken,
|
|
309
|
+
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
310
|
+
// U64 MAX
|
|
311
|
+
};
|
|
312
|
+
} else {
|
|
313
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
314
|
+
addresses.assertIsAddress(nonceAccountAddress);
|
|
315
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
316
|
+
addresses.assertIsAddress(nonceAuthorityAddress);
|
|
317
|
+
return {
|
|
318
|
+
nonce: messageLifetimeToken,
|
|
319
|
+
nonceAccountAddress,
|
|
320
|
+
nonceAuthorityAddress
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function convertSignatures(compiledTransaction) {
|
|
325
|
+
const {
|
|
326
|
+
compiledMessage: { staticAccounts },
|
|
327
|
+
signatures
|
|
328
|
+
} = compiledTransaction;
|
|
329
|
+
return signatures.reduce((acc, sig, index) => {
|
|
330
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
331
|
+
if (allZeros)
|
|
332
|
+
return acc;
|
|
333
|
+
const address = staticAccounts[index];
|
|
334
|
+
return { ...acc, [address]: sig };
|
|
335
|
+
}, {});
|
|
336
|
+
}
|
|
337
|
+
function decompileTransaction(compiledTransaction, config) {
|
|
338
|
+
const { compiledMessage } = compiledTransaction;
|
|
339
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
340
|
+
if (!feePayer)
|
|
341
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
342
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
343
|
+
const accountLookupMetas = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? getAddressLookupMetas(compiledMessage.addressTableLookups, config?.addressesByLookupTableAddress ?? {}) : [];
|
|
344
|
+
const transactionMetas = [...accountMetas, ...accountLookupMetas];
|
|
345
|
+
const instructions = compiledMessage.instructions.map(
|
|
346
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, transactionMetas)
|
|
347
|
+
);
|
|
348
|
+
const firstInstruction = instructions[0];
|
|
349
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
350
|
+
compiledMessage.lifetimeToken,
|
|
351
|
+
firstInstruction,
|
|
352
|
+
config?.lastValidBlockHeight
|
|
353
|
+
);
|
|
354
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
355
|
+
return functional.pipe(
|
|
356
|
+
createTransaction({ version: compiledMessage.version }),
|
|
357
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
358
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
359
|
+
return appendTransactionInstruction(instruction, acc);
|
|
360
|
+
}, tx),
|
|
361
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
362
|
+
(tx) => Object.keys(signatures).length > 0 ? { ...tx, signatures } : tx
|
|
363
|
+
);
|
|
364
|
+
}
|
|
205
365
|
function upsert(addressMap, address, update) {
|
|
206
366
|
addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
|
|
207
367
|
}
|
|
@@ -467,59 +627,31 @@ function compileMessage(transaction) {
|
|
|
467
627
|
version: transaction.version
|
|
468
628
|
};
|
|
469
629
|
}
|
|
470
|
-
var lookupTableAddressDescription = __DEV__ ? "The address of the address lookup table account from which instruction addresses should be looked up" : "lookupTableAddress";
|
|
471
|
-
var writableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as writeable" : "writableIndices";
|
|
472
|
-
var readableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as read-only" : "readableIndices";
|
|
473
|
-
var addressTableLookupDescription = __DEV__ ? "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" : "addressTableLookup";
|
|
474
630
|
var memoizedAddressTableLookupEncoder;
|
|
475
631
|
function getAddressTableLookupEncoder() {
|
|
476
632
|
if (!memoizedAddressTableLookupEncoder) {
|
|
477
|
-
memoizedAddressTableLookupEncoder = codecsDataStructures.getStructEncoder(
|
|
633
|
+
memoizedAddressTableLookupEncoder = codecsDataStructures.getStructEncoder([
|
|
634
|
+
["lookupTableAddress", addresses.getAddressEncoder()],
|
|
478
635
|
[
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
"writableIndices",
|
|
482
|
-
codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), {
|
|
483
|
-
description: writableIndicesDescription,
|
|
484
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
485
|
-
})
|
|
486
|
-
],
|
|
487
|
-
[
|
|
488
|
-
"readableIndices",
|
|
489
|
-
codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), {
|
|
490
|
-
description: readableIndicesDescription,
|
|
491
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
492
|
-
})
|
|
493
|
-
]
|
|
636
|
+
"writableIndices",
|
|
637
|
+
codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), { size: codecsNumbers.getShortU16Encoder() })
|
|
494
638
|
],
|
|
495
|
-
|
|
496
|
-
|
|
639
|
+
[
|
|
640
|
+
"readableIndices",
|
|
641
|
+
codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), { size: codecsNumbers.getShortU16Encoder() })
|
|
642
|
+
]
|
|
643
|
+
]);
|
|
497
644
|
}
|
|
498
645
|
return memoizedAddressTableLookupEncoder;
|
|
499
646
|
}
|
|
500
647
|
var memoizedAddressTableLookupDecoder;
|
|
501
648
|
function getAddressTableLookupDecoder() {
|
|
502
649
|
if (!memoizedAddressTableLookupDecoder) {
|
|
503
|
-
memoizedAddressTableLookupDecoder = codecsDataStructures.getStructDecoder(
|
|
504
|
-
[
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), {
|
|
509
|
-
description: writableIndicesDescription,
|
|
510
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
511
|
-
})
|
|
512
|
-
],
|
|
513
|
-
[
|
|
514
|
-
"readableIndices",
|
|
515
|
-
codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), {
|
|
516
|
-
description: readableIndicesDescription,
|
|
517
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
518
|
-
})
|
|
519
|
-
]
|
|
520
|
-
],
|
|
521
|
-
{ description: addressTableLookupDescription }
|
|
522
|
-
);
|
|
650
|
+
memoizedAddressTableLookupDecoder = codecsDataStructures.getStructDecoder([
|
|
651
|
+
["lookupTableAddress", addresses.getAddressDecoder()],
|
|
652
|
+
["writableIndices", codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), { size: codecsNumbers.getShortU16Decoder() })],
|
|
653
|
+
["readableIndices", codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), { size: codecsNumbers.getShortU16Decoder() })]
|
|
654
|
+
]);
|
|
523
655
|
}
|
|
524
656
|
return memoizedAddressTableLookupDecoder;
|
|
525
657
|
}
|
|
@@ -529,72 +661,34 @@ function getMemoizedU8Encoder() {
|
|
|
529
661
|
memoizedU8Encoder = codecsNumbers.getU8Encoder();
|
|
530
662
|
return memoizedU8Encoder;
|
|
531
663
|
}
|
|
532
|
-
function getMemoizedU8EncoderDescription(description) {
|
|
533
|
-
const encoder = getMemoizedU8Encoder();
|
|
534
|
-
return {
|
|
535
|
-
...encoder,
|
|
536
|
-
description: description ?? encoder.description
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
664
|
var memoizedU8Decoder;
|
|
540
665
|
function getMemoizedU8Decoder() {
|
|
541
666
|
if (!memoizedU8Decoder)
|
|
542
667
|
memoizedU8Decoder = codecsNumbers.getU8Decoder();
|
|
543
668
|
return memoizedU8Decoder;
|
|
544
669
|
}
|
|
545
|
-
function getMemoizedU8DecoderDescription(description) {
|
|
546
|
-
const decoder = getMemoizedU8Decoder();
|
|
547
|
-
return {
|
|
548
|
-
...decoder,
|
|
549
|
-
description: description ?? decoder.description
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
var numSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" : void 0;
|
|
553
|
-
var numReadonlySignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" : void 0;
|
|
554
|
-
var numReadonlyNonSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" : void 0;
|
|
555
|
-
var messageHeaderDescription = __DEV__ ? "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" : void 0;
|
|
556
670
|
function getMessageHeaderEncoder() {
|
|
557
|
-
return codecsDataStructures.getStructEncoder(
|
|
558
|
-
[
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
],
|
|
563
|
-
{
|
|
564
|
-
description: messageHeaderDescription
|
|
565
|
-
}
|
|
566
|
-
);
|
|
671
|
+
return codecsDataStructures.getStructEncoder([
|
|
672
|
+
["numSignerAccounts", getMemoizedU8Encoder()],
|
|
673
|
+
["numReadonlySignerAccounts", getMemoizedU8Encoder()],
|
|
674
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
|
|
675
|
+
]);
|
|
567
676
|
}
|
|
568
677
|
function getMessageHeaderDecoder() {
|
|
569
|
-
return codecsDataStructures.getStructDecoder(
|
|
570
|
-
[
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
],
|
|
575
|
-
{
|
|
576
|
-
description: messageHeaderDescription
|
|
577
|
-
}
|
|
578
|
-
);
|
|
678
|
+
return codecsDataStructures.getStructDecoder([
|
|
679
|
+
["numSignerAccounts", getMemoizedU8Decoder()],
|
|
680
|
+
["numReadonlySignerAccounts", getMemoizedU8Decoder()],
|
|
681
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()]
|
|
682
|
+
]);
|
|
579
683
|
}
|
|
580
|
-
var programAddressIndexDescription = __DEV__ ? "The index of the program being called, according to the well-ordered accounts list for this transaction" : "programAddressIndex";
|
|
581
|
-
var accountIndexDescription = __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : void 0;
|
|
582
|
-
var accountIndicesDescription = __DEV__ ? "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" : "accountIndices";
|
|
583
|
-
var dataDescription = __DEV__ ? "An optional buffer of data passed to the instruction" : "data";
|
|
584
684
|
var memoizedGetInstructionEncoder;
|
|
585
685
|
function getInstructionEncoder() {
|
|
586
686
|
if (!memoizedGetInstructionEncoder) {
|
|
587
687
|
memoizedGetInstructionEncoder = codecsCore.mapEncoder(
|
|
588
688
|
codecsDataStructures.getStructEncoder([
|
|
589
|
-
["programAddressIndex", codecsNumbers.getU8Encoder(
|
|
590
|
-
[
|
|
591
|
-
|
|
592
|
-
codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder({ description: accountIndexDescription }), {
|
|
593
|
-
description: accountIndicesDescription,
|
|
594
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
595
|
-
})
|
|
596
|
-
],
|
|
597
|
-
["data", codecsDataStructures.getBytesEncoder({ description: dataDescription, size: codecsNumbers.getShortU16Encoder() })]
|
|
689
|
+
["programAddressIndex", codecsNumbers.getU8Encoder()],
|
|
690
|
+
["accountIndices", codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), { size: codecsNumbers.getShortU16Encoder() })],
|
|
691
|
+
["data", codecsDataStructures.getBytesEncoder({ size: codecsNumbers.getShortU16Encoder() })]
|
|
598
692
|
]),
|
|
599
693
|
// Convert an instruction to have all fields defined
|
|
600
694
|
(instruction) => {
|
|
@@ -616,15 +710,9 @@ function getInstructionDecoder() {
|
|
|
616
710
|
if (!memoizedGetInstructionDecoder) {
|
|
617
711
|
memoizedGetInstructionDecoder = codecsCore.mapDecoder(
|
|
618
712
|
codecsDataStructures.getStructDecoder([
|
|
619
|
-
["programAddressIndex", codecsNumbers.getU8Decoder(
|
|
620
|
-
[
|
|
621
|
-
|
|
622
|
-
codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder({ description: accountIndexDescription }), {
|
|
623
|
-
description: accountIndicesDescription,
|
|
624
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
625
|
-
})
|
|
626
|
-
],
|
|
627
|
-
["data", codecsDataStructures.getBytesDecoder({ description: dataDescription, size: codecsNumbers.getShortU16Decoder() })]
|
|
713
|
+
["programAddressIndex", codecsNumbers.getU8Decoder()],
|
|
714
|
+
["accountIndices", codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), { size: codecsNumbers.getShortU16Decoder() })],
|
|
715
|
+
["data", codecsDataStructures.getBytesDecoder({ size: codecsNumbers.getShortU16Decoder() })]
|
|
628
716
|
]),
|
|
629
717
|
// Convert an instruction to exclude optional fields if they are empty
|
|
630
718
|
(instruction) => {
|
|
@@ -643,47 +731,38 @@ function getInstructionDecoder() {
|
|
|
643
731
|
return memoizedGetInstructionDecoder;
|
|
644
732
|
}
|
|
645
733
|
var VERSION_FLAG_MASK = 128;
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
if (value === "legacy") {
|
|
662
|
-
return new Uint8Array();
|
|
663
|
-
}
|
|
664
|
-
if (value < 0 || value > 127) {
|
|
665
|
-
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
666
|
-
}
|
|
667
|
-
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
734
|
+
function getTransactionVersionEncoder() {
|
|
735
|
+
return codecsCore.createEncoder({
|
|
736
|
+
getSizeFromValue: (value) => value === "legacy" ? 0 : 1,
|
|
737
|
+
maxSize: 1,
|
|
738
|
+
write: (value, bytes, offset) => {
|
|
739
|
+
if (value === "legacy") {
|
|
740
|
+
return offset;
|
|
741
|
+
}
|
|
742
|
+
if (value < 0 || value > 127) {
|
|
743
|
+
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
744
|
+
}
|
|
745
|
+
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
746
|
+
return offset + 1;
|
|
747
|
+
}
|
|
748
|
+
});
|
|
668
749
|
}
|
|
669
750
|
function getTransactionVersionDecoder() {
|
|
670
|
-
return {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
751
|
+
return codecsCore.createDecoder({
|
|
752
|
+
maxSize: 1,
|
|
753
|
+
read: (bytes, offset) => {
|
|
754
|
+
const firstByte = bytes[offset];
|
|
755
|
+
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
756
|
+
return ["legacy", offset];
|
|
757
|
+
} else {
|
|
758
|
+
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
759
|
+
return [version, offset + 1];
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
});
|
|
680
763
|
}
|
|
681
764
|
|
|
682
765
|
// src/serializers/message.ts
|
|
683
|
-
var staticAccountsDescription = __DEV__ ? "A compact-array of static account addresses belonging to this transaction" : "staticAccounts";
|
|
684
|
-
var lifetimeTokenDescription = __DEV__ ? "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" : "lifetimeToken";
|
|
685
|
-
var instructionsDescription = __DEV__ ? "A compact-array of instructions belonging to this transaction" : "instructions";
|
|
686
|
-
var addressTableLookupsDescription = __DEV__ ? "A compact array of address table lookups belonging to this transaction" : "addressTableLookups";
|
|
687
766
|
function getCompiledMessageLegacyEncoder() {
|
|
688
767
|
return codecsDataStructures.getStructEncoder(getPreludeStructEncoderTuple());
|
|
689
768
|
}
|
|
@@ -708,98 +787,52 @@ function getPreludeStructEncoderTuple() {
|
|
|
708
787
|
return [
|
|
709
788
|
["version", getTransactionVersionEncoder()],
|
|
710
789
|
["header", getMessageHeaderEncoder()],
|
|
711
|
-
[
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
description: staticAccountsDescription,
|
|
715
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
716
|
-
})
|
|
717
|
-
],
|
|
718
|
-
[
|
|
719
|
-
"lifetimeToken",
|
|
720
|
-
codecsStrings.getStringEncoder({
|
|
721
|
-
description: lifetimeTokenDescription,
|
|
722
|
-
encoding: codecsStrings.getBase58Encoder(),
|
|
723
|
-
size: 32
|
|
724
|
-
})
|
|
725
|
-
],
|
|
726
|
-
[
|
|
727
|
-
"instructions",
|
|
728
|
-
codecsDataStructures.getArrayEncoder(getInstructionEncoder(), {
|
|
729
|
-
description: instructionsDescription,
|
|
730
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
731
|
-
})
|
|
732
|
-
]
|
|
790
|
+
["staticAccounts", codecsDataStructures.getArrayEncoder(addresses.getAddressEncoder(), { size: codecsNumbers.getShortU16Encoder() })],
|
|
791
|
+
["lifetimeToken", codecsStrings.getStringEncoder({ encoding: codecsStrings.getBase58Encoder(), size: 32 })],
|
|
792
|
+
["instructions", codecsDataStructures.getArrayEncoder(getInstructionEncoder(), { size: codecsNumbers.getShortU16Encoder() })]
|
|
733
793
|
];
|
|
734
794
|
}
|
|
735
795
|
function getPreludeStructDecoderTuple() {
|
|
736
796
|
return [
|
|
737
797
|
["version", getTransactionVersionDecoder()],
|
|
738
798
|
["header", getMessageHeaderDecoder()],
|
|
739
|
-
[
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
description: staticAccountsDescription,
|
|
743
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
744
|
-
})
|
|
745
|
-
],
|
|
746
|
-
[
|
|
747
|
-
"lifetimeToken",
|
|
748
|
-
codecsStrings.getStringDecoder({
|
|
749
|
-
description: lifetimeTokenDescription,
|
|
750
|
-
encoding: codecsStrings.getBase58Decoder(),
|
|
751
|
-
size: 32
|
|
752
|
-
})
|
|
753
|
-
],
|
|
754
|
-
[
|
|
755
|
-
"instructions",
|
|
756
|
-
codecsDataStructures.getArrayDecoder(getInstructionDecoder(), {
|
|
757
|
-
description: instructionsDescription,
|
|
758
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
759
|
-
})
|
|
760
|
-
],
|
|
799
|
+
["staticAccounts", codecsDataStructures.getArrayDecoder(addresses.getAddressDecoder(), { size: codecsNumbers.getShortU16Decoder() })],
|
|
800
|
+
["lifetimeToken", codecsStrings.getStringDecoder({ encoding: codecsStrings.getBase58Decoder(), size: 32 })],
|
|
801
|
+
["instructions", codecsDataStructures.getArrayDecoder(getInstructionDecoder(), { size: codecsNumbers.getShortU16Decoder() })],
|
|
761
802
|
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
762
803
|
];
|
|
763
804
|
}
|
|
764
805
|
function getAddressTableLookupArrayEncoder() {
|
|
765
|
-
return codecsDataStructures.getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
766
|
-
description: addressTableLookupsDescription,
|
|
767
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
768
|
-
});
|
|
806
|
+
return codecsDataStructures.getArrayEncoder(getAddressTableLookupEncoder(), { size: codecsNumbers.getShortU16Encoder() });
|
|
769
807
|
}
|
|
770
808
|
function getAddressTableLookupArrayDecoder() {
|
|
771
|
-
return codecsDataStructures.getArrayDecoder(getAddressTableLookupDecoder(), {
|
|
772
|
-
description: addressTableLookupsDescription,
|
|
773
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
774
|
-
});
|
|
809
|
+
return codecsDataStructures.getArrayDecoder(getAddressTableLookupDecoder(), { size: codecsNumbers.getShortU16Decoder() });
|
|
775
810
|
}
|
|
776
|
-
var messageDescription = __DEV__ ? "The wire format of a Solana transaction message" : "message";
|
|
777
811
|
function getCompiledMessageEncoder() {
|
|
778
|
-
return {
|
|
779
|
-
|
|
780
|
-
encode: (compiledMessage) => {
|
|
812
|
+
return codecsCore.createEncoder({
|
|
813
|
+
getSizeFromValue: (compiledMessage) => {
|
|
781
814
|
if (compiledMessage.version === "legacy") {
|
|
782
|
-
return getCompiledMessageLegacyEncoder().
|
|
815
|
+
return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);
|
|
783
816
|
} else {
|
|
784
|
-
return getCompiledMessageVersionedEncoder().
|
|
817
|
+
return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);
|
|
785
818
|
}
|
|
786
819
|
},
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
820
|
+
write: (compiledMessage, bytes, offset) => {
|
|
821
|
+
if (compiledMessage.version === "legacy") {
|
|
822
|
+
return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);
|
|
823
|
+
} else {
|
|
824
|
+
return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
});
|
|
790
828
|
}
|
|
791
829
|
function getCompiledMessageDecoder() {
|
|
792
|
-
return codecsCore.mapDecoder(
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}),
|
|
796
|
-
({ addressTableLookups, ...restOfMessage }) => {
|
|
797
|
-
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
798
|
-
return restOfMessage;
|
|
799
|
-
}
|
|
800
|
-
return { ...restOfMessage, addressTableLookups };
|
|
830
|
+
return codecsCore.mapDecoder(codecsDataStructures.getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {
|
|
831
|
+
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
832
|
+
return restOfMessage;
|
|
801
833
|
}
|
|
802
|
-
|
|
834
|
+
return { ...restOfMessage, addressTableLookups };
|
|
835
|
+
});
|
|
803
836
|
}
|
|
804
837
|
function getCompiledMessageCodec() {
|
|
805
838
|
return codecsCore.combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
|
|
@@ -822,168 +855,36 @@ function getCompiledTransaction(transaction) {
|
|
|
822
855
|
signatures
|
|
823
856
|
};
|
|
824
857
|
}
|
|
825
|
-
function getAccountMetas(message) {
|
|
826
|
-
const { header } = message;
|
|
827
|
-
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
828
|
-
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
829
|
-
const accountMetas = [];
|
|
830
|
-
let accountIndex = 0;
|
|
831
|
-
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
832
|
-
accountMetas.push({
|
|
833
|
-
address: message.staticAccounts[accountIndex],
|
|
834
|
-
role: AccountRole.WRITABLE_SIGNER
|
|
835
|
-
});
|
|
836
|
-
accountIndex++;
|
|
837
|
-
}
|
|
838
|
-
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
839
|
-
accountMetas.push({
|
|
840
|
-
address: message.staticAccounts[accountIndex],
|
|
841
|
-
role: AccountRole.READONLY_SIGNER
|
|
842
|
-
});
|
|
843
|
-
accountIndex++;
|
|
844
|
-
}
|
|
845
|
-
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
846
|
-
accountMetas.push({
|
|
847
|
-
address: message.staticAccounts[accountIndex],
|
|
848
|
-
role: AccountRole.WRITABLE
|
|
849
|
-
});
|
|
850
|
-
accountIndex++;
|
|
851
|
-
}
|
|
852
|
-
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
853
|
-
accountMetas.push({
|
|
854
|
-
address: message.staticAccounts[accountIndex],
|
|
855
|
-
role: AccountRole.READONLY
|
|
856
|
-
});
|
|
857
|
-
accountIndex++;
|
|
858
|
-
}
|
|
859
|
-
return accountMetas;
|
|
860
|
-
}
|
|
861
|
-
function convertInstruction(instruction, accountMetas) {
|
|
862
|
-
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
863
|
-
if (!programAddress) {
|
|
864
|
-
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
865
|
-
}
|
|
866
|
-
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
867
|
-
const { data } = instruction;
|
|
868
|
-
return {
|
|
869
|
-
programAddress,
|
|
870
|
-
...accounts && accounts.length ? { accounts } : {},
|
|
871
|
-
...data && data.length ? { data } : {}
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
875
|
-
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
876
|
-
return {
|
|
877
|
-
blockhash: messageLifetimeToken,
|
|
878
|
-
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
879
|
-
// U64 MAX
|
|
880
|
-
};
|
|
881
|
-
} else {
|
|
882
|
-
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
883
|
-
addresses.assertIsAddress(nonceAccountAddress);
|
|
884
|
-
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
885
|
-
addresses.assertIsAddress(nonceAuthorityAddress);
|
|
886
|
-
return {
|
|
887
|
-
nonce: messageLifetimeToken,
|
|
888
|
-
nonceAccountAddress,
|
|
889
|
-
nonceAuthorityAddress
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
function convertSignatures(compiledTransaction) {
|
|
894
|
-
const {
|
|
895
|
-
compiledMessage: { staticAccounts },
|
|
896
|
-
signatures
|
|
897
|
-
} = compiledTransaction;
|
|
898
|
-
return signatures.reduce((acc, sig, index) => {
|
|
899
|
-
const allZeros = sig.every((byte) => byte === 0);
|
|
900
|
-
if (allZeros)
|
|
901
|
-
return acc;
|
|
902
|
-
const address = staticAccounts[index];
|
|
903
|
-
return { ...acc, [address]: sig };
|
|
904
|
-
}, {});
|
|
905
|
-
}
|
|
906
|
-
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
907
|
-
const { compiledMessage } = compiledTransaction;
|
|
908
|
-
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
909
|
-
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
910
|
-
}
|
|
911
|
-
const feePayer = compiledMessage.staticAccounts[0];
|
|
912
|
-
if (!feePayer)
|
|
913
|
-
throw new Error("No fee payer set in CompiledTransaction");
|
|
914
|
-
const accountMetas = getAccountMetas(compiledMessage);
|
|
915
|
-
const instructions = compiledMessage.instructions.map(
|
|
916
|
-
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
917
|
-
);
|
|
918
|
-
const firstInstruction = instructions[0];
|
|
919
|
-
const lifetimeConstraint = getLifetimeConstraint(
|
|
920
|
-
compiledMessage.lifetimeToken,
|
|
921
|
-
firstInstruction,
|
|
922
|
-
lastValidBlockHeight
|
|
923
|
-
);
|
|
924
|
-
const signatures = convertSignatures(compiledTransaction);
|
|
925
|
-
return functional.pipe(
|
|
926
|
-
createTransaction({ version: compiledMessage.version }),
|
|
927
|
-
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
928
|
-
(tx) => instructions.reduce((acc, instruction) => {
|
|
929
|
-
return appendTransactionInstruction(instruction, acc);
|
|
930
|
-
}, tx),
|
|
931
|
-
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
932
|
-
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
933
|
-
);
|
|
934
|
-
}
|
|
935
858
|
|
|
936
859
|
// src/serializers/transaction.ts
|
|
937
|
-
var signaturesDescription = __DEV__ ? "A compact array of 64-byte, base-64 encoded Ed25519 signatures" : "signatures";
|
|
938
|
-
var transactionDescription = __DEV__ ? "The wire format of a Solana transaction" : "transaction";
|
|
939
860
|
function getCompiledTransactionEncoder() {
|
|
940
|
-
return codecsDataStructures.getStructEncoder(
|
|
941
|
-
[
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
codecsDataStructures.getArrayEncoder(codecsDataStructures.getBytesEncoder({ size: 64 }), {
|
|
945
|
-
description: signaturesDescription,
|
|
946
|
-
size: codecsNumbers.getShortU16Encoder()
|
|
947
|
-
})
|
|
948
|
-
],
|
|
949
|
-
["compiledMessage", getCompiledMessageEncoder()]
|
|
950
|
-
],
|
|
951
|
-
{
|
|
952
|
-
description: transactionDescription
|
|
953
|
-
}
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
function getSignatureDecoder() {
|
|
957
|
-
return codecsCore.mapDecoder(codecsDataStructures.getBytesDecoder({ size: 64 }), (bytes) => bytes);
|
|
861
|
+
return codecsDataStructures.getStructEncoder([
|
|
862
|
+
["signatures", codecsDataStructures.getArrayEncoder(codecsDataStructures.getBytesEncoder({ size: 64 }), { size: codecsNumbers.getShortU16Encoder() })],
|
|
863
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
864
|
+
]);
|
|
958
865
|
}
|
|
959
866
|
function getCompiledTransactionDecoder() {
|
|
960
|
-
return codecsDataStructures.getStructDecoder(
|
|
867
|
+
return codecsDataStructures.getStructDecoder([
|
|
961
868
|
[
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
size: codecsNumbers.getShortU16Decoder()
|
|
967
|
-
})
|
|
968
|
-
],
|
|
969
|
-
["compiledMessage", getCompiledMessageDecoder()]
|
|
869
|
+
"signatures",
|
|
870
|
+
codecsDataStructures.getArrayDecoder(codecsDataStructures.getBytesDecoder({ size: 64 }), {
|
|
871
|
+
size: codecsNumbers.getShortU16Decoder()
|
|
872
|
+
})
|
|
970
873
|
],
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
);
|
|
874
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
875
|
+
]);
|
|
975
876
|
}
|
|
976
877
|
function getTransactionEncoder() {
|
|
977
878
|
return codecsCore.mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
978
879
|
}
|
|
979
|
-
function getTransactionDecoder(
|
|
880
|
+
function getTransactionDecoder(config) {
|
|
980
881
|
return codecsCore.mapDecoder(
|
|
981
882
|
getCompiledTransactionDecoder(),
|
|
982
|
-
(compiledTransaction) => decompileTransaction(compiledTransaction,
|
|
883
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, config)
|
|
983
884
|
);
|
|
984
885
|
}
|
|
985
|
-
function getTransactionCodec(
|
|
986
|
-
return codecsCore.combineCodec(getTransactionEncoder(), getTransactionDecoder(
|
|
886
|
+
function getTransactionCodec(config) {
|
|
887
|
+
return codecsCore.combineCodec(getTransactionEncoder(), getTransactionDecoder(config));
|
|
987
888
|
}
|
|
988
889
|
var base58Decoder;
|
|
989
890
|
function getSignatureFromTransaction(transaction) {
|
|
@@ -995,7 +896,7 @@ function getSignatureFromTransaction(transaction) {
|
|
|
995
896
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
996
897
|
);
|
|
997
898
|
}
|
|
998
|
-
const transactionSignature = base58Decoder.decode(signatureBytes)
|
|
899
|
+
const transactionSignature = base58Decoder.decode(signatureBytes);
|
|
999
900
|
return transactionSignature;
|
|
1000
901
|
}
|
|
1001
902
|
async function partiallySignTransaction(keyPairs, transaction) {
|
|
@@ -1026,27 +927,33 @@ async function signTransaction(keyPairs, transaction) {
|
|
|
1026
927
|
function assertTransactionIsFullySigned(transaction) {
|
|
1027
928
|
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);
|
|
1028
929
|
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
930
|
+
const missingSigs = [];
|
|
1029
931
|
requiredSigners.forEach((address) => {
|
|
1030
932
|
if (!transaction.signatures[address]) {
|
|
1031
|
-
|
|
933
|
+
missingSigs.push(address);
|
|
1032
934
|
}
|
|
1033
935
|
});
|
|
936
|
+
if (missingSigs.length > 0) {
|
|
937
|
+
throw new Error("Transaction is missing signatures for addresses: " + missingSigs.join(", "));
|
|
938
|
+
}
|
|
1034
939
|
}
|
|
1035
940
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1036
941
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1037
|
-
return codecsStrings.getBase64Decoder().decode(wireTransactionBytes)
|
|
942
|
+
return codecsStrings.getBase64Decoder().decode(wireTransactionBytes);
|
|
1038
943
|
}
|
|
1039
944
|
|
|
1040
945
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1041
|
-
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1042
946
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
947
|
+
exports.assertIsTransactionWithBlockhashLifetime = assertIsTransactionWithBlockhashLifetime;
|
|
1043
948
|
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1044
949
|
exports.compileMessage = compileMessage;
|
|
1045
950
|
exports.createTransaction = createTransaction;
|
|
951
|
+
exports.decompileTransaction = decompileTransaction;
|
|
1046
952
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1047
953
|
exports.getCompiledMessageCodec = getCompiledMessageCodec;
|
|
1048
954
|
exports.getCompiledMessageDecoder = getCompiledMessageDecoder;
|
|
1049
955
|
exports.getCompiledMessageEncoder = getCompiledMessageEncoder;
|
|
956
|
+
exports.getCompiledTransactionDecoder = getCompiledTransactionDecoder;
|
|
1050
957
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1051
958
|
exports.getTransactionCodec = getTransactionCodec;
|
|
1052
959
|
exports.getTransactionDecoder = getTransactionDecoder;
|
|
@@ -1058,3 +965,5 @@ exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
|
1058
965
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1059
966
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1060
967
|
exports.signTransaction = signTransaction;
|
|
968
|
+
//# sourceMappingURL=out.js.map
|
|
969
|
+
//# sourceMappingURL=index.browser.cjs.map
|