@solana/transactions 2.0.0-experimental.dfb72ea → 2.0.0-experimental.e00f668
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 +48 -40
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +48 -40
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +48 -40
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +48 -40
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +48 -40
- 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/transaction-version.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/index.browser.cjs
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
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)
|
|
16
16
|
base58Encoder = codecsStrings.getBase58Encoder();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
32
|
-
cause: e
|
|
17
|
+
if (
|
|
18
|
+
// Lowest value (32 bytes of zeroes)
|
|
19
|
+
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
|
|
20
|
+
putativeBlockhash.length > 44
|
|
21
|
+
) {
|
|
22
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE, {
|
|
23
|
+
actualLength: putativeBlockhash.length
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const bytes = base58Encoder.encode(putativeBlockhash);
|
|
27
|
+
const numBytes = bytes.byteLength;
|
|
28
|
+
if (numBytes !== 32) {
|
|
29
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__BLOCKHASH_BYTE_LENGTH_OUT_OF_RANGE, {
|
|
30
|
+
actualLength: numBytes
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -62,7 +60,7 @@ function isTransactionWithBlockhashLifetime(transaction) {
|
|
|
62
60
|
}
|
|
63
61
|
function assertIsTransactionWithBlockhashLifetime(transaction) {
|
|
64
62
|
if (!isTransactionWithBlockhashLifetime(transaction)) {
|
|
65
|
-
throw new
|
|
63
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_EXPECTED_BLOCKHASH_LIFETIME);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
@@ -88,8 +86,6 @@ function createTransaction({
|
|
|
88
86
|
Object.freeze(out);
|
|
89
87
|
return out;
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
// ../instructions/dist/index.browser.js
|
|
93
89
|
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
94
90
|
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
95
91
|
3] = "WRITABLE_SIGNER";
|
|
@@ -111,13 +107,11 @@ function isWritableRole(role) {
|
|
|
111
107
|
function mergeRoles(roleA, roleB) {
|
|
112
108
|
return roleA | roleB;
|
|
113
109
|
}
|
|
114
|
-
|
|
115
|
-
// src/durable-nonce.ts
|
|
116
110
|
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
117
111
|
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
118
112
|
function assertIsDurableNonceTransaction(transaction) {
|
|
119
113
|
if (!isDurableNonceTransaction(transaction)) {
|
|
120
|
-
throw new
|
|
114
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_EXPECTED_NONCE_LIFETIME);
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
@@ -266,8 +260,9 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
266
260
|
const compiledAddressTableLookupAddresses = compiledAddressTableLookups.map((l) => l.lookupTableAddress);
|
|
267
261
|
const missing = compiledAddressTableLookupAddresses.filter((a) => addressesByLookupTableAddress[a] === void 0);
|
|
268
262
|
if (missing.length > 0) {
|
|
269
|
-
|
|
270
|
-
|
|
263
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING, {
|
|
264
|
+
lookupTableAddresses: missing
|
|
265
|
+
});
|
|
271
266
|
}
|
|
272
267
|
const readOnlyMetas = [];
|
|
273
268
|
const writableMetas = [];
|
|
@@ -275,8 +270,13 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
275
270
|
const addresses = addressesByLookupTableAddress[lookup.lookupTableAddress];
|
|
276
271
|
const highestIndex = Math.max(...lookup.readableIndices, ...lookup.writableIndices);
|
|
277
272
|
if (highestIndex >= addresses.length) {
|
|
278
|
-
throw new
|
|
279
|
-
|
|
273
|
+
throw new errors.SolanaError(
|
|
274
|
+
errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE,
|
|
275
|
+
{
|
|
276
|
+
highestKnownIndex: addresses.length - 1,
|
|
277
|
+
highestRequestedIndex: highestIndex,
|
|
278
|
+
lookupTableAddress: lookup.lookupTableAddress
|
|
279
|
+
}
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
282
|
const readOnlyForLookup = lookup.readableIndices.map((r) => ({
|
|
@@ -299,7 +299,9 @@ function getAddressLookupMetas(compiledAddressTableLookups, addressesByLookupTab
|
|
|
299
299
|
function convertInstruction(instruction, accountMetas) {
|
|
300
300
|
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
301
301
|
if (!programAddress) {
|
|
302
|
-
throw new
|
|
302
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND, {
|
|
303
|
+
index: instruction.programAddressIndex
|
|
304
|
+
});
|
|
303
305
|
}
|
|
304
306
|
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
305
307
|
const { data } = instruction;
|
|
@@ -344,8 +346,9 @@ function convertSignatures(compiledTransaction) {
|
|
|
344
346
|
function decompileTransaction(compiledTransaction, config) {
|
|
345
347
|
const { compiledMessage } = compiledTransaction;
|
|
346
348
|
const feePayer = compiledMessage.staticAccounts[0];
|
|
347
|
-
if (!feePayer)
|
|
348
|
-
throw new
|
|
349
|
+
if (!feePayer) {
|
|
350
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_FAILED_TO_DECOMPILE_FEE_PAYER_MISSING);
|
|
351
|
+
}
|
|
349
352
|
const accountMetas = getAccountMetas(compiledMessage);
|
|
350
353
|
const accountLookupMetas = "addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups !== void 0 && compiledMessage.addressTableLookups.length > 0 ? getAddressLookupMetas(compiledMessage.addressTableLookups, config?.addressesByLookupTableAddress ?? {}) : [];
|
|
351
354
|
const transactionMetas = [...accountMetas, ...accountLookupMetas];
|
|
@@ -385,13 +388,13 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
385
388
|
if (isWritableRole(entry.role)) {
|
|
386
389
|
switch (entry[TYPE]) {
|
|
387
390
|
case 0 /* FEE_PAYER */:
|
|
388
|
-
throw new
|
|
389
|
-
|
|
390
|
-
);
|
|
391
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_CANNOT_PAY_FEES, {
|
|
392
|
+
programAddress: instruction.programAddress
|
|
393
|
+
});
|
|
391
394
|
default:
|
|
392
|
-
throw new
|
|
393
|
-
|
|
394
|
-
);
|
|
395
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, {
|
|
396
|
+
programAddress: instruction.programAddress
|
|
397
|
+
});
|
|
395
398
|
}
|
|
396
399
|
}
|
|
397
400
|
if (entry[TYPE] === 2 /* STATIC */) {
|
|
@@ -456,8 +459,11 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
456
459
|
addressesOfInvokedPrograms.has(account.address)
|
|
457
460
|
) {
|
|
458
461
|
if (isWritableRole(accountMeta.role)) {
|
|
459
|
-
throw new
|
|
460
|
-
|
|
462
|
+
throw new errors.SolanaError(
|
|
463
|
+
errors.SOLANA_ERROR__TRANSACTION_INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE,
|
|
464
|
+
{
|
|
465
|
+
programAddress: account.address
|
|
466
|
+
}
|
|
461
467
|
);
|
|
462
468
|
}
|
|
463
469
|
if (entry.role !== nextRole) {
|
|
@@ -747,7 +753,9 @@ function getTransactionVersionEncoder() {
|
|
|
747
753
|
return offset;
|
|
748
754
|
}
|
|
749
755
|
if (value < 0 || value > 127) {
|
|
750
|
-
throw new
|
|
756
|
+
throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION_VERSION_NUMBER_OUT_OF_RANGE, {
|
|
757
|
+
actualVersion: value
|
|
758
|
+
});
|
|
751
759
|
}
|
|
752
760
|
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
753
761
|
return offset + 1;
|