@solana/transactions 2.0.0-experimental.06517d7 → 2.0.0-experimental.080a7d1
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 +42 -27
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +42 -27
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +42 -27
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +42 -27
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +42 -27
- package/dist/index.node.js.map +1 -1
- package/dist/types/accounts.d.ts.map +1 -1
- package/dist/types/blockhash.d.ts.map +1 -1
- package/dist/types/decompile-transaction.d.ts.map +1 -1
- package/dist/types/durable-nonce.d.ts.map +1 -1
- package/dist/types/serializers/message.d.ts.map +1 -1
- package/dist/types/serializers/transaction-version.d.ts.map +1 -1
- package/package.json +17 -40
package/dist/index.browser.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var errors = require('@solana/errors');
|
|
3
4
|
var codecsStrings = require('@solana/codecs-strings');
|
|
4
5
|
var addresses = require('@solana/addresses');
|
|
5
6
|
var functional = require('@solana/functional');
|
|
6
7
|
var codecsCore = require('@solana/codecs-core');
|
|
7
8
|
var codecsDataStructures = require('@solana/codecs-data-structures');
|
|
8
9
|
var codecsNumbers = require('@solana/codecs-numbers');
|
|
9
|
-
var errors = require('@solana/errors');
|
|
10
10
|
var keys = require('@solana/keys');
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// src/blockhash.ts
|
|
13
13
|
var base58Encoder;
|
|
14
14
|
function assertIsBlockhash(putativeBlockhash) {
|
|
15
15
|
if (!base58Encoder)
|
|
@@ -62,7 +62,7 @@ function isTransactionWithBlockhashLifetime(transaction) {
|
|
|
62
62
|
}
|
|
63
63
|
function assertIsTransactionWithBlockhashLifetime(transaction) {
|
|
64
64
|
if (!isTransactionWithBlockhashLifetime(transaction)) {
|
|
65
|
-
throw new
|
|
65
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_EXPECTED_BLOCKHASH_LIFETIME);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
@@ -111,13 +111,11 @@ function isWritableRole(role) {
|
|
|
111
111
|
function mergeRoles(roleA, roleB) {
|
|
112
112
|
return roleA | roleB;
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
// src/durable-nonce.ts
|
|
116
114
|
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
117
115
|
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
118
116
|
function assertIsDurableNonceTransaction(transaction) {
|
|
119
117
|
if (!isDurableNonceTransaction(transaction)) {
|
|
120
|
-
throw new
|
|
118
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_EXPECTED_NONCE_LIFETIME);
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
121
|
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
@@ -266,8 +264,9 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
266
264
|
const compiledAddressTableLookupAddresses = compiledAddressTableLookups.map((l) => l.lookupTableAddress);
|
|
267
265
|
const missing = compiledAddressTableLookupAddresses.filter((a) => addressesByLookupTableAddress[a] === void 0);
|
|
268
266
|
if (missing.length > 0) {
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING, {
|
|
268
|
+
lookupTableAddresses: missing
|
|
269
|
+
});
|
|
271
270
|
}
|
|
272
271
|
const readOnlyMetas = [];
|
|
273
272
|
const writableMetas = [];
|
|
@@ -275,8 +274,13 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
275
274
|
const addresses = addressesByLookupTableAddress[lookup.lookupTableAddress];
|
|
276
275
|
const highestIndex = Math.max(...lookup.readableIndices, ...lookup.writableIndices);
|
|
277
276
|
if (highestIndex >= addresses.length) {
|
|
278
|
-
throw new
|
|
279
|
-
|
|
277
|
+
throw new errors.SolanaError(
|
|
278
|
+
errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE,
|
|
279
|
+
{
|
|
280
|
+
highestKnownIndex: addresses.length - 1,
|
|
281
|
+
highestRequestedIndex: highestIndex,
|
|
282
|
+
lookupTableAddress: lookup.lookupTableAddress
|
|
283
|
+
}
|
|
280
284
|
);
|
|
281
285
|
}
|
|
282
286
|
const readOnlyForLookup = lookup.readableIndices.map((r) => ({
|
|
@@ -299,7 +303,9 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
299
303
|
function convertInstruction(instruction, accountMetas) {
|
|
300
304
|
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
301
305
|
if (!programAddress) {
|
|
302
|
-
throw new
|
|
306
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND, {
|
|
307
|
+
index: instruction.programAddressIndex
|
|
308
|
+
});
|
|
303
309
|
}
|
|
304
310
|
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
305
311
|
const { data } = instruction;
|
|
@@ -344,8 +350,9 @@ function convertSignatures(compiledTransaction) {
|
|
|
344
350
|
function decompileTransaction(compiledTransaction, config) {
|
|
345
351
|
const { compiledMessage } = compiledTransaction;
|
|
346
352
|
const feePayer = compiledMessage.staticAccounts[0];
|
|
347
|
-
if (!feePayer)
|
|
348
|
-
throw new
|
|
353
|
+
if (!feePayer) {
|
|
354
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING);
|
|
355
|
+
}
|
|
349
356
|
const accountMetas = getAccountMetas(compiledMessage);
|
|
350
357
|
const accountLookupMetas = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? getAddressLookupMetas(compiledMessage.addressTableLookups, config?.addressesByLookupTableAddress ?? {}) : [];
|
|
351
358
|
const transactionMetas = [...accountMetas, ...accountLookupMetas];
|
|
@@ -385,13 +392,13 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
385
392
|
if (isWritableRole(entry.role)) {
|
|
386
393
|
switch (entry[TYPE]) {
|
|
387
394
|
case 0 /* FEE_PAYER */:
|
|
388
|
-
throw new
|
|
389
|
-
|
|
390
|
-
);
|
|
395
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_CANNOT_PAY_FEES, {
|
|
396
|
+
programAddress: instruction.programAddress
|
|
397
|
+
});
|
|
391
398
|
default:
|
|
392
|
-
throw new
|
|
393
|
-
|
|
394
|
-
);
|
|
399
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, {
|
|
400
|
+
programAddress: instruction.programAddress
|
|
401
|
+
});
|
|
395
402
|
}
|
|
396
403
|
}
|
|
397
404
|
if (entry[TYPE] === 2 /* STATIC */) {
|
|
@@ -456,8 +463,11 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
456
463
|
addressesOfInvokedPrograms.has(account.address)
|
|
457
464
|
) {
|
|
458
465
|
if (isWritableRole(accountMeta.role)) {
|
|
459
|
-
throw new
|
|
460
|
-
|
|
466
|
+
throw new errors.SolanaError(
|
|
467
|
+
errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE,
|
|
468
|
+
{
|
|
469
|
+
programAddress: account.address
|
|
470
|
+
}
|
|
461
471
|
);
|
|
462
472
|
}
|
|
463
473
|
if (entry.role !== nextRole) {
|
|
@@ -747,7 +757,9 @@ function getTransactionVersionEncoder() {
|
|
|
747
757
|
return offset;
|
|
748
758
|
}
|
|
749
759
|
if (value < 0 || value > 127) {
|
|
750
|
-
throw new
|
|
760
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_VERSION_NUMBER_OUT_OF_RANGE, {
|
|
761
|
+
actualVersion: value
|
|
762
|
+
});
|
|
751
763
|
}
|
|
752
764
|
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
753
765
|
return offset + 1;
|
|
@@ -834,12 +846,15 @@ function getCompiledMessageEncoder() {
|
|
|
834
846
|
});
|
|
835
847
|
}
|
|
836
848
|
function getCompiledMessageDecoder() {
|
|
837
|
-
return codecsCore.mapDecoder(
|
|
838
|
-
|
|
839
|
-
|
|
849
|
+
return codecsCore.mapDecoder(
|
|
850
|
+
codecsDataStructures.getStructDecoder(getPreludeStructDecoderTuple()),
|
|
851
|
+
({ addressTableLookups, ...restOfMessage }) => {
|
|
852
|
+
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
853
|
+
return restOfMessage;
|
|
854
|
+
}
|
|
855
|
+
return { ...restOfMessage, addressTableLookups };
|
|
840
856
|
}
|
|
841
|
-
|
|
842
|
-
});
|
|
857
|
+
);
|
|
843
858
|
}
|
|
844
859
|
function getCompiledMessageCodec() {
|
|
845
860
|
return codecsCore.combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
|