@solana/transactions 2.0.0-experimental.06517d7 → 2.0.0-experimental.07c30c1
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 -29
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +42 -29
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +42 -29
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +42 -29
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +42 -29
- 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) {
|
|
@@ -88,8 +88,6 @@ function createTransaction({
|
|
|
88
88
|
Object.freeze(out);
|
|
89
89
|
return out;
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
// ../instructions/dist/index.browser.js
|
|
93
91
|
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
94
92
|
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
95
93
|
3] = "WRITABLE_SIGNER";
|
|
@@ -111,13 +109,11 @@ function isWritableRole(role) {
|
|
|
111
109
|
function mergeRoles(roleA, roleB) {
|
|
112
110
|
return roleA | roleB;
|
|
113
111
|
}
|
|
114
|
-
|
|
115
|
-
// src/durable-nonce.ts
|
|
116
112
|
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
117
113
|
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
118
114
|
function assertIsDurableNonceTransaction(transaction) {
|
|
119
115
|
if (!isDurableNonceTransaction(transaction)) {
|
|
120
|
-
throw new
|
|
116
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_EXPECTED_NONCE_LIFETIME);
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
119
|
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
@@ -266,8 +262,9 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
266
262
|
const compiledAddressTableLookupAddresses = compiledAddressTableLookups.map((l) => l.lookupTableAddress);
|
|
267
263
|
const missing = compiledAddressTableLookupAddresses.filter((a) => addressesByLookupTableAddress[a] === void 0);
|
|
268
264
|
if (missing.length > 0) {
|
|
269
|
-
|
|
270
|
-
|
|
265
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING, {
|
|
266
|
+
lookupTableAddresses: missing
|
|
267
|
+
});
|
|
271
268
|
}
|
|
272
269
|
const readOnlyMetas = [];
|
|
273
270
|
const writableMetas = [];
|
|
@@ -275,8 +272,13 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
275
272
|
const addresses = addressesByLookupTableAddress[lookup.lookupTableAddress];
|
|
276
273
|
const highestIndex = Math.max(...lookup.readableIndices, ...lookup.writableIndices);
|
|
277
274
|
if (highestIndex >= addresses.length) {
|
|
278
|
-
throw new
|
|
279
|
-
|
|
275
|
+
throw new errors.SolanaError(
|
|
276
|
+
errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE,
|
|
277
|
+
{
|
|
278
|
+
highestKnownIndex: addresses.length - 1,
|
|
279
|
+
highestRequestedIndex: highestIndex,
|
|
280
|
+
lookupTableAddress: lookup.lookupTableAddress
|
|
281
|
+
}
|
|
280
282
|
);
|
|
281
283
|
}
|
|
282
284
|
const readOnlyForLookup = lookup.readableIndices.map((r) => ({
|
|
@@ -299,7 +301,9 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
299
301
|
function convertInstruction(instruction, accountMetas) {
|
|
300
302
|
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
301
303
|
if (!programAddress) {
|
|
302
|
-
throw new
|
|
304
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND, {
|
|
305
|
+
index: instruction.programAddressIndex
|
|
306
|
+
});
|
|
303
307
|
}
|
|
304
308
|
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
305
309
|
const { data } = instruction;
|
|
@@ -344,8 +348,9 @@ function convertSignatures(compiledTransaction) {
|
|
|
344
348
|
function decompileTransaction(compiledTransaction, config) {
|
|
345
349
|
const { compiledMessage } = compiledTransaction;
|
|
346
350
|
const feePayer = compiledMessage.staticAccounts[0];
|
|
347
|
-
if (!feePayer)
|
|
348
|
-
throw new
|
|
351
|
+
if (!feePayer) {
|
|
352
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING);
|
|
353
|
+
}
|
|
349
354
|
const accountMetas = getAccountMetas(compiledMessage);
|
|
350
355
|
const accountLookupMetas = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? getAddressLookupMetas(compiledMessage.addressTableLookups, config?.addressesByLookupTableAddress ?? {}) : [];
|
|
351
356
|
const transactionMetas = [...accountMetas, ...accountLookupMetas];
|
|
@@ -385,13 +390,13 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
385
390
|
if (isWritableRole(entry.role)) {
|
|
386
391
|
switch (entry[TYPE]) {
|
|
387
392
|
case 0 /* FEE_PAYER */:
|
|
388
|
-
throw new
|
|
389
|
-
|
|
390
|
-
);
|
|
393
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_CANNOT_PAY_FEES, {
|
|
394
|
+
programAddress: instruction.programAddress
|
|
395
|
+
});
|
|
391
396
|
default:
|
|
392
|
-
throw new
|
|
393
|
-
|
|
394
|
-
);
|
|
397
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, {
|
|
398
|
+
programAddress: instruction.programAddress
|
|
399
|
+
});
|
|
395
400
|
}
|
|
396
401
|
}
|
|
397
402
|
if (entry[TYPE] === 2 /* STATIC */) {
|
|
@@ -456,8 +461,11 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
456
461
|
addressesOfInvokedPrograms.has(account.address)
|
|
457
462
|
) {
|
|
458
463
|
if (isWritableRole(accountMeta.role)) {
|
|
459
|
-
throw new
|
|
460
|
-
|
|
464
|
+
throw new errors.SolanaError(
|
|
465
|
+
errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE,
|
|
466
|
+
{
|
|
467
|
+
programAddress: account.address
|
|
468
|
+
}
|
|
461
469
|
);
|
|
462
470
|
}
|
|
463
471
|
if (entry.role !== nextRole) {
|
|
@@ -747,7 +755,9 @@ function getTransactionVersionEncoder() {
|
|
|
747
755
|
return offset;
|
|
748
756
|
}
|
|
749
757
|
if (value < 0 || value > 127) {
|
|
750
|
-
throw new
|
|
758
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_VERSION_NUMBER_OUT_OF_RANGE, {
|
|
759
|
+
actualVersion: value
|
|
760
|
+
});
|
|
751
761
|
}
|
|
752
762
|
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
753
763
|
return offset + 1;
|
|
@@ -834,12 +844,15 @@ function getCompiledMessageEncoder() {
|
|
|
834
844
|
});
|
|
835
845
|
}
|
|
836
846
|
function getCompiledMessageDecoder() {
|
|
837
|
-
return codecsCore.mapDecoder(
|
|
838
|
-
|
|
839
|
-
|
|
847
|
+
return codecsCore.mapDecoder(
|
|
848
|
+
codecsDataStructures.getStructDecoder(getPreludeStructDecoderTuple()),
|
|
849
|
+
({ addressTableLookups, ...restOfMessage }) => {
|
|
850
|
+
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
851
|
+
return restOfMessage;
|
|
852
|
+
}
|
|
853
|
+
return { ...restOfMessage, addressTableLookups };
|
|
840
854
|
}
|
|
841
|
-
|
|
842
|
-
});
|
|
855
|
+
);
|
|
843
856
|
}
|
|
844
857
|
function getCompiledMessageCodec() {
|
|
845
858
|
return codecsCore.combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
|