@solana/transactions 2.0.0-experimental.9c8a30e → 2.0.0-experimental.9d0a506
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 +14 -59
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +15 -58
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +154 -156
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +15 -58
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +16 -59
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +15 -58
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +17 -19
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts +7 -0
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +2 -2
- 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 +2 -2
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts +5 -6
- 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 +2 -4
- package/dist/types/decompile-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +3 -3
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +4 -4
- 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 +1 -5
- 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.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 +1 -3
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +8 -13
- 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 +10 -10
package/dist/index.node.cjs
CHANGED
|
@@ -254,7 +254,7 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
254
254
|
const shouldReplaceEntry = (
|
|
255
255
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
256
256
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
257
|
-
(addressComparator
|
|
257
|
+
(addressComparator ||= addresses.getAddressComparator())(
|
|
258
258
|
accountMeta.lookupTableAddress,
|
|
259
259
|
entry.lookupTableAddress
|
|
260
260
|
) < 0
|
|
@@ -360,7 +360,7 @@ function getOrderedAccountsFromAddressMap(addressMap) {
|
|
|
360
360
|
if (leftIsWritable !== isWritableRole(rightEntry.role)) {
|
|
361
361
|
return leftIsWritable ? -1 : 1;
|
|
362
362
|
}
|
|
363
|
-
addressComparator
|
|
363
|
+
addressComparator ||= addresses.getAddressComparator();
|
|
364
364
|
if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
365
365
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
366
366
|
} else {
|
|
@@ -373,16 +373,15 @@ function getOrderedAccountsFromAddressMap(addressMap) {
|
|
|
373
373
|
return orderedAccounts;
|
|
374
374
|
}
|
|
375
375
|
function getCompiledAddressTableLookups(orderedAccounts) {
|
|
376
|
-
var _a;
|
|
377
376
|
const index = {};
|
|
378
377
|
for (const account of orderedAccounts) {
|
|
379
378
|
if (!("lookupTableAddress" in account)) {
|
|
380
379
|
continue;
|
|
381
380
|
}
|
|
382
|
-
const entry = index[
|
|
381
|
+
const entry = index[account.lookupTableAddress] ||= {
|
|
383
382
|
readableIndices: [],
|
|
384
383
|
writableIndices: []
|
|
385
|
-
}
|
|
384
|
+
};
|
|
386
385
|
if (account.role === AccountRole.WRITABLE) {
|
|
387
386
|
entry.writableIndices.push(account.addressIndex);
|
|
388
387
|
} else {
|
|
@@ -983,47 +982,7 @@ function getTransactionDecoder(lastValidBlockHeight) {
|
|
|
983
982
|
function getTransactionCodec(lastValidBlockHeight) {
|
|
984
983
|
return codecsCore.combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
985
984
|
}
|
|
986
|
-
var base58Encoder2;
|
|
987
985
|
var base58Decoder;
|
|
988
|
-
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
989
|
-
if (!base58Encoder2)
|
|
990
|
-
base58Encoder2 = codecsStrings.getBase58Encoder();
|
|
991
|
-
try {
|
|
992
|
-
if (
|
|
993
|
-
// Lowest value (64 bytes of zeroes)
|
|
994
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
995
|
-
putativeTransactionSignature.length > 88
|
|
996
|
-
) {
|
|
997
|
-
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
998
|
-
}
|
|
999
|
-
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
1000
|
-
const numBytes = bytes.byteLength;
|
|
1001
|
-
if (numBytes !== 64) {
|
|
1002
|
-
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1003
|
-
}
|
|
1004
|
-
} catch (e) {
|
|
1005
|
-
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1006
|
-
cause: e
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
function isTransactionSignature(putativeTransactionSignature) {
|
|
1011
|
-
if (!base58Encoder2)
|
|
1012
|
-
base58Encoder2 = codecsStrings.getBase58Encoder();
|
|
1013
|
-
if (
|
|
1014
|
-
// Lowest value (64 bytes of zeroes)
|
|
1015
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1016
|
-
putativeTransactionSignature.length > 88
|
|
1017
|
-
) {
|
|
1018
|
-
return false;
|
|
1019
|
-
}
|
|
1020
|
-
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
1021
|
-
const numBytes = bytes.byteLength;
|
|
1022
|
-
if (numBytes !== 64) {
|
|
1023
|
-
return false;
|
|
1024
|
-
}
|
|
1025
|
-
return true;
|
|
1026
|
-
}
|
|
1027
986
|
function getSignatureFromTransaction(transaction) {
|
|
1028
987
|
if (!base58Decoder)
|
|
1029
988
|
base58Decoder = codecsStrings.getBase58Decoder();
|
|
@@ -1033,10 +992,10 @@ function getSignatureFromTransaction(transaction) {
|
|
|
1033
992
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1034
993
|
);
|
|
1035
994
|
}
|
|
1036
|
-
const
|
|
1037
|
-
return
|
|
995
|
+
const transactionSignature = base58Decoder.decode(signatureBytes)[0];
|
|
996
|
+
return transactionSignature;
|
|
1038
997
|
}
|
|
1039
|
-
async function
|
|
998
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1040
999
|
const compiledMessage = compileMessage(transaction);
|
|
1041
1000
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1042
1001
|
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
@@ -1055,9 +1014,11 @@ async function signTransaction(keyPairs, transaction) {
|
|
|
1055
1014
|
Object.freeze(out);
|
|
1056
1015
|
return out;
|
|
1057
1016
|
}
|
|
1058
|
-
function
|
|
1059
|
-
|
|
1060
|
-
|
|
1017
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1018
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
1019
|
+
assertTransactionIsFullySigned(out);
|
|
1020
|
+
Object.freeze(out);
|
|
1021
|
+
return out;
|
|
1061
1022
|
}
|
|
1062
1023
|
function assertTransactionIsFullySigned(transaction) {
|
|
1063
1024
|
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);
|
|
@@ -1068,19 +1029,14 @@ function assertTransactionIsFullySigned(transaction) {
|
|
|
1068
1029
|
}
|
|
1069
1030
|
});
|
|
1070
1031
|
}
|
|
1071
|
-
|
|
1072
|
-
// src/wire-transaction.ts
|
|
1073
1032
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1074
1033
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1075
|
-
|
|
1076
|
-
return Buffer.from(wireTransactionBytes).toString("base64");
|
|
1077
|
-
}
|
|
1034
|
+
return codecsStrings.getBase64Decoder().decode(wireTransactionBytes)[0];
|
|
1078
1035
|
}
|
|
1079
1036
|
|
|
1080
1037
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1081
1038
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1082
1039
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1083
|
-
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
1084
1040
|
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1085
1041
|
exports.createTransaction = createTransaction;
|
|
1086
1042
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
@@ -1089,10 +1045,11 @@ exports.getTransactionCodec = getTransactionCodec;
|
|
|
1089
1045
|
exports.getTransactionDecoder = getTransactionDecoder;
|
|
1090
1046
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1091
1047
|
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1092
|
-
exports.
|
|
1048
|
+
exports.partiallySignTransaction = partiallySignTransaction;
|
|
1093
1049
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1094
1050
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1095
1051
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1096
1052
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1097
1053
|
exports.signTransaction = signTransaction;
|
|
1098
|
-
|
|
1054
|
+
//# sourceMappingURL=out.js.map
|
|
1055
|
+
//# sourceMappingURL=index.node.cjs.map
|