@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.native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getBase58Encoder, getBase58Decoder, getStringEncoder, getStringDecoder } from '@solana/codecs-strings';
|
|
1
|
+
import { getBase58Encoder, getBase58Decoder, getBase64Decoder, getStringEncoder, getStringDecoder } from '@solana/codecs-strings';
|
|
2
2
|
import { mapEncoder, mapDecoder, combineCodec } from '@solana/codecs-core';
|
|
3
3
|
import { getStructEncoder, getArrayEncoder, getBytesEncoder, getStructDecoder, getArrayDecoder, getBytesDecoder } from '@solana/codecs-data-structures';
|
|
4
4
|
import { getShortU16Encoder, getShortU16Decoder, getU8Encoder, getU8Decoder } from '@solana/codecs-numbers';
|
|
@@ -252,7 +252,7 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
252
252
|
const shouldReplaceEntry = (
|
|
253
253
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
254
254
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
255
|
-
(addressComparator
|
|
255
|
+
(addressComparator ||= getAddressComparator())(
|
|
256
256
|
accountMeta.lookupTableAddress,
|
|
257
257
|
entry.lookupTableAddress
|
|
258
258
|
) < 0
|
|
@@ -358,7 +358,7 @@ function getOrderedAccountsFromAddressMap(addressMap) {
|
|
|
358
358
|
if (leftIsWritable !== isWritableRole(rightEntry.role)) {
|
|
359
359
|
return leftIsWritable ? -1 : 1;
|
|
360
360
|
}
|
|
361
|
-
addressComparator
|
|
361
|
+
addressComparator ||= getAddressComparator();
|
|
362
362
|
if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
363
363
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
364
364
|
} else {
|
|
@@ -371,16 +371,15 @@ function getOrderedAccountsFromAddressMap(addressMap) {
|
|
|
371
371
|
return orderedAccounts;
|
|
372
372
|
}
|
|
373
373
|
function getCompiledAddressTableLookups(orderedAccounts) {
|
|
374
|
-
var _a;
|
|
375
374
|
const index = {};
|
|
376
375
|
for (const account of orderedAccounts) {
|
|
377
376
|
if (!("lookupTableAddress" in account)) {
|
|
378
377
|
continue;
|
|
379
378
|
}
|
|
380
|
-
const entry = index[
|
|
379
|
+
const entry = index[account.lookupTableAddress] ||= {
|
|
381
380
|
readableIndices: [],
|
|
382
381
|
writableIndices: []
|
|
383
|
-
}
|
|
382
|
+
};
|
|
384
383
|
if (account.role === AccountRole.WRITABLE) {
|
|
385
384
|
entry.writableIndices.push(account.addressIndex);
|
|
386
385
|
} else {
|
|
@@ -981,47 +980,7 @@ function getTransactionDecoder(lastValidBlockHeight) {
|
|
|
981
980
|
function getTransactionCodec(lastValidBlockHeight) {
|
|
982
981
|
return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
983
982
|
}
|
|
984
|
-
var base58Encoder2;
|
|
985
983
|
var base58Decoder;
|
|
986
|
-
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
987
|
-
if (!base58Encoder2)
|
|
988
|
-
base58Encoder2 = getBase58Encoder();
|
|
989
|
-
try {
|
|
990
|
-
if (
|
|
991
|
-
// Lowest value (64 bytes of zeroes)
|
|
992
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
993
|
-
putativeTransactionSignature.length > 88
|
|
994
|
-
) {
|
|
995
|
-
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
996
|
-
}
|
|
997
|
-
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
998
|
-
const numBytes = bytes.byteLength;
|
|
999
|
-
if (numBytes !== 64) {
|
|
1000
|
-
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1001
|
-
}
|
|
1002
|
-
} catch (e) {
|
|
1003
|
-
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1004
|
-
cause: e
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
function isTransactionSignature(putativeTransactionSignature) {
|
|
1009
|
-
if (!base58Encoder2)
|
|
1010
|
-
base58Encoder2 = getBase58Encoder();
|
|
1011
|
-
if (
|
|
1012
|
-
// Lowest value (64 bytes of zeroes)
|
|
1013
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1014
|
-
putativeTransactionSignature.length > 88
|
|
1015
|
-
) {
|
|
1016
|
-
return false;
|
|
1017
|
-
}
|
|
1018
|
-
const bytes = base58Encoder2.encode(putativeTransactionSignature);
|
|
1019
|
-
const numBytes = bytes.byteLength;
|
|
1020
|
-
if (numBytes !== 64) {
|
|
1021
|
-
return false;
|
|
1022
|
-
}
|
|
1023
|
-
return true;
|
|
1024
|
-
}
|
|
1025
984
|
function getSignatureFromTransaction(transaction) {
|
|
1026
985
|
if (!base58Decoder)
|
|
1027
986
|
base58Decoder = getBase58Decoder();
|
|
@@ -1031,10 +990,10 @@ function getSignatureFromTransaction(transaction) {
|
|
|
1031
990
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1032
991
|
);
|
|
1033
992
|
}
|
|
1034
|
-
const
|
|
1035
|
-
return
|
|
993
|
+
const transactionSignature = base58Decoder.decode(signatureBytes)[0];
|
|
994
|
+
return transactionSignature;
|
|
1036
995
|
}
|
|
1037
|
-
async function
|
|
996
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1038
997
|
const compiledMessage = compileMessage(transaction);
|
|
1039
998
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1040
999
|
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
@@ -1053,9 +1012,11 @@ async function signTransaction(keyPairs, transaction) {
|
|
|
1053
1012
|
Object.freeze(out);
|
|
1054
1013
|
return out;
|
|
1055
1014
|
}
|
|
1056
|
-
function
|
|
1057
|
-
|
|
1058
|
-
|
|
1015
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1016
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
1017
|
+
assertTransactionIsFullySigned(out);
|
|
1018
|
+
Object.freeze(out);
|
|
1019
|
+
return out;
|
|
1059
1020
|
}
|
|
1060
1021
|
function assertTransactionIsFullySigned(transaction) {
|
|
1061
1022
|
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);
|
|
@@ -1066,15 +1027,11 @@ function assertTransactionIsFullySigned(transaction) {
|
|
|
1066
1027
|
}
|
|
1067
1028
|
});
|
|
1068
1029
|
}
|
|
1069
|
-
|
|
1070
|
-
// src/wire-transaction.ts
|
|
1071
1030
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1072
1031
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1073
|
-
|
|
1074
|
-
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1075
|
-
}
|
|
1032
|
+
return getBase64Decoder().decode(wireTransactionBytes)[0];
|
|
1076
1033
|
}
|
|
1077
1034
|
|
|
1078
|
-
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction,
|
|
1035
|
+
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, assertTransactionIsFullySigned, createTransaction, getBase64EncodedWireTransaction, getSignatureFromTransaction, getTransactionCodec, getTransactionDecoder, getTransactionEncoder, isAdvanceNonceAccountInstruction, partiallySignTransaction, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, setTransactionLifetimeUsingDurableNonce, signTransaction };
|
|
1079
1036
|
//# sourceMappingURL=out.js.map
|
|
1080
1037
|
//# sourceMappingURL=index.native.js.map
|