@solana/transactions 2.0.0-experimental.f07dced → 2.0.0-experimental.f3eba18
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 +127 -66
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +120 -62
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +143 -81
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +122 -62
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +127 -66
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +120 -62
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +11 -8
- package/dist/types/accounts.d.ts +1 -1
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts +5 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +18 -6
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +1 -1
- package/dist/types/fee-payer.d.ts.map +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.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/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.map +1 -0
- package/dist/types/serializers/unimplemented.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +3 -4
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts +4 -0
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +7 -9
package/dist/index.browser.cjs
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var umiSerializers = require('@metaplex-foundation/umi-serializers');
|
|
4
|
+
var addresses = require('@solana/addresses');
|
|
4
5
|
var keys = require('@solana/keys');
|
|
5
6
|
|
|
6
7
|
// ../build-scripts/env-shim.ts
|
|
7
8
|
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
9
|
+
|
|
10
|
+
// src/unsigned-transaction.ts
|
|
11
|
+
function getUnsignedTransaction(transaction) {
|
|
12
|
+
if ("signatures" in transaction) {
|
|
13
|
+
const {
|
|
14
|
+
signatures: _,
|
|
15
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
16
|
+
...unsignedTransaction
|
|
17
|
+
} = transaction;
|
|
18
|
+
return unsignedTransaction;
|
|
19
|
+
} else {
|
|
20
|
+
return transaction;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/blockhash.ts
|
|
8
25
|
function assertIsBlockhash(putativeBlockhash) {
|
|
9
26
|
try {
|
|
10
27
|
if (
|
|
@@ -25,6 +42,17 @@ function assertIsBlockhash(putativeBlockhash) {
|
|
|
25
42
|
});
|
|
26
43
|
}
|
|
27
44
|
}
|
|
45
|
+
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
46
|
+
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
47
|
+
return transaction;
|
|
48
|
+
}
|
|
49
|
+
const out = {
|
|
50
|
+
...getUnsignedTransaction(transaction),
|
|
51
|
+
lifetimeConstraint: blockhashLifetimeConstraint
|
|
52
|
+
};
|
|
53
|
+
Object.freeze(out);
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
28
56
|
|
|
29
57
|
// src/create-transaction.ts
|
|
30
58
|
function createTransaction({
|
|
@@ -38,66 +66,6 @@ function createTransaction({
|
|
|
38
66
|
return out;
|
|
39
67
|
}
|
|
40
68
|
|
|
41
|
-
// src/fee-payer.ts
|
|
42
|
-
function setTransactionFeePayer(feePayer, transaction) {
|
|
43
|
-
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
44
|
-
return transaction;
|
|
45
|
-
}
|
|
46
|
-
let out;
|
|
47
|
-
if ("signatures" in transaction) {
|
|
48
|
-
const {
|
|
49
|
-
signatures: _,
|
|
50
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
51
|
-
...unsignedTransaction
|
|
52
|
-
} = transaction;
|
|
53
|
-
out = {
|
|
54
|
-
...unsignedTransaction,
|
|
55
|
-
feePayer
|
|
56
|
-
};
|
|
57
|
-
} else {
|
|
58
|
-
out = {
|
|
59
|
-
...transaction,
|
|
60
|
-
feePayer
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
Object.freeze(out);
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/instructions.ts
|
|
68
|
-
function replaceInstructions(transaction, nextInstructions) {
|
|
69
|
-
let out;
|
|
70
|
-
if ("signatures" in transaction) {
|
|
71
|
-
const {
|
|
72
|
-
signatures: _,
|
|
73
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
74
|
-
...unsignedTransaction
|
|
75
|
-
} = transaction;
|
|
76
|
-
out = {
|
|
77
|
-
...unsignedTransaction,
|
|
78
|
-
instructions: nextInstructions
|
|
79
|
-
};
|
|
80
|
-
} else {
|
|
81
|
-
out = {
|
|
82
|
-
...transaction,
|
|
83
|
-
instructions: nextInstructions
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return out;
|
|
87
|
-
}
|
|
88
|
-
function appendTransactionInstruction(instruction, transaction) {
|
|
89
|
-
const nextInstructions = [...transaction.instructions, instruction];
|
|
90
|
-
const out = replaceInstructions(transaction, nextInstructions);
|
|
91
|
-
Object.freeze(out);
|
|
92
|
-
return out;
|
|
93
|
-
}
|
|
94
|
-
function prependTransactionInstruction(instruction, transaction) {
|
|
95
|
-
const nextInstructions = [instruction, ...transaction.instructions];
|
|
96
|
-
const out = replaceInstructions(transaction, nextInstructions);
|
|
97
|
-
Object.freeze(out);
|
|
98
|
-
return out;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
69
|
// ../instructions/dist/index.browser.js
|
|
102
70
|
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
103
71
|
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
@@ -120,6 +88,96 @@ function isWritableRole(role) {
|
|
|
120
88
|
function mergeRoles(roleA, roleB) {
|
|
121
89
|
return roleA | roleB;
|
|
122
90
|
}
|
|
91
|
+
|
|
92
|
+
// src/durable-nonce.ts
|
|
93
|
+
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
94
|
+
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
95
|
+
function assertIsDurableNonceTransaction(transaction) {
|
|
96
|
+
if (!isDurableNonceTransaction(transaction)) {
|
|
97
|
+
throw new Error("Transaction is not a durable nonce transaction");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
101
|
+
return {
|
|
102
|
+
accounts: [
|
|
103
|
+
{ address: nonceAccountAddress, role: AccountRole.WRITABLE },
|
|
104
|
+
{
|
|
105
|
+
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
106
|
+
role: AccountRole.READONLY
|
|
107
|
+
},
|
|
108
|
+
{ address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
|
|
109
|
+
],
|
|
110
|
+
data: new Uint8Array([4, 0, 0, 0]),
|
|
111
|
+
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function isAdvanceNonceAccountInstruction(instruction) {
|
|
115
|
+
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
116
|
+
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
117
|
+
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
118
|
+
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
119
|
+
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
120
|
+
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
|
|
121
|
+
}
|
|
122
|
+
function isAdvanceNonceAccountInstructionData(data) {
|
|
123
|
+
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
124
|
+
}
|
|
125
|
+
function isDurableNonceTransaction(transaction) {
|
|
126
|
+
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
127
|
+
}
|
|
128
|
+
function setTransactionLifetimeUsingDurableNonce({
|
|
129
|
+
nonce,
|
|
130
|
+
nonceAccountAddress,
|
|
131
|
+
nonceAuthorityAddress
|
|
132
|
+
}, transaction) {
|
|
133
|
+
const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
|
|
134
|
+
if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
|
|
135
|
+
return transaction;
|
|
136
|
+
}
|
|
137
|
+
const out = {
|
|
138
|
+
...getUnsignedTransaction(transaction),
|
|
139
|
+
instructions: [
|
|
140
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
141
|
+
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
142
|
+
],
|
|
143
|
+
lifetimeConstraint: {
|
|
144
|
+
nonce
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
Object.freeze(out);
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/fee-payer.ts
|
|
152
|
+
function setTransactionFeePayer(feePayer, transaction) {
|
|
153
|
+
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
154
|
+
return transaction;
|
|
155
|
+
}
|
|
156
|
+
const out = {
|
|
157
|
+
...getUnsignedTransaction(transaction),
|
|
158
|
+
feePayer
|
|
159
|
+
};
|
|
160
|
+
Object.freeze(out);
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/instructions.ts
|
|
165
|
+
function appendTransactionInstruction(instruction, transaction) {
|
|
166
|
+
const out = {
|
|
167
|
+
...getUnsignedTransaction(transaction),
|
|
168
|
+
instructions: [...transaction.instructions, instruction]
|
|
169
|
+
};
|
|
170
|
+
Object.freeze(out);
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
function prependTransactionInstruction(instruction, transaction) {
|
|
174
|
+
const out = {
|
|
175
|
+
...getUnsignedTransaction(transaction),
|
|
176
|
+
instructions: [instruction, ...transaction.instructions]
|
|
177
|
+
};
|
|
178
|
+
Object.freeze(out);
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
123
181
|
function upsert(addressMap, address, update) {
|
|
124
182
|
addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
|
|
125
183
|
}
|
|
@@ -172,7 +230,7 @@ function getAddressMapFromInstructions(feePayer, instructions) {
|
|
|
172
230
|
const shouldReplaceEntry = (
|
|
173
231
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
174
232
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
175
|
-
(addressComparator || (addressComparator =
|
|
233
|
+
(addressComparator || (addressComparator = addresses.getBase58EncodedAddressComparator()))(
|
|
176
234
|
accountMeta.lookupTableAddress,
|
|
177
235
|
entry.lookupTableAddress
|
|
178
236
|
) < 0
|
|
@@ -278,7 +336,7 @@ function getOrderedAccountsFromAddressMap(addressMap) {
|
|
|
278
336
|
if (leftIsWritable !== isWritableRole(rightEntry.role)) {
|
|
279
337
|
return leftIsWritable ? -1 : 1;
|
|
280
338
|
}
|
|
281
|
-
addressComparator || (addressComparator =
|
|
339
|
+
addressComparator || (addressComparator = addresses.getBase58EncodedAddressComparator());
|
|
282
340
|
if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
283
341
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
284
342
|
} else {
|
|
@@ -307,7 +365,7 @@ function getCompiledAddressTableLookups(orderedAccounts) {
|
|
|
307
365
|
entry.readableIndices.push(account.addressIndex);
|
|
308
366
|
}
|
|
309
367
|
}
|
|
310
|
-
return Object.keys(index).sort(
|
|
368
|
+
return Object.keys(index).sort(addresses.getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
|
|
311
369
|
lookupTableAddress,
|
|
312
370
|
...index[lookupTableAddress]
|
|
313
371
|
}));
|
|
@@ -391,7 +449,7 @@ function getAddressTableLookupCodec() {
|
|
|
391
449
|
[
|
|
392
450
|
[
|
|
393
451
|
"lookupTableAddress",
|
|
394
|
-
|
|
452
|
+
addresses.getBase58EncodedAddressCodec(
|
|
395
453
|
__DEV__ ? {
|
|
396
454
|
description: "The address of the address lookup table account from which instruction addresses should be looked up"
|
|
397
455
|
} : void 0
|
|
@@ -588,7 +646,7 @@ function getPreludeStructSerializerTuple() {
|
|
|
588
646
|
["header", getMessageHeaderCodec()],
|
|
589
647
|
[
|
|
590
648
|
"staticAccounts",
|
|
591
|
-
umiSerializers.array(
|
|
649
|
+
umiSerializers.array(addresses.getBase58EncodedAddressCodec(), {
|
|
592
650
|
description: __DEV__ ? "A compact-array of static account addresses belonging to this transaction" : "",
|
|
593
651
|
size: umiSerializers.shortU16()
|
|
594
652
|
})
|
|
@@ -633,7 +691,7 @@ async function getCompiledMessageSignature(message, secretKey) {
|
|
|
633
691
|
async function signTransaction(keyPair, transaction) {
|
|
634
692
|
const compiledMessage = compileMessage(transaction);
|
|
635
693
|
const [signerPublicKey, signature] = await Promise.all([
|
|
636
|
-
|
|
694
|
+
addresses.getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
|
|
637
695
|
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
638
696
|
]);
|
|
639
697
|
const nextSignatures = {
|
|
@@ -703,10 +761,13 @@ function getBase64EncodedWireTransaction(transaction) {
|
|
|
703
761
|
|
|
704
762
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
705
763
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
764
|
+
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
706
765
|
exports.createTransaction = createTransaction;
|
|
707
766
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
708
767
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
709
768
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
769
|
+
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
770
|
+
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
710
771
|
exports.signTransaction = signTransaction;
|
|
711
772
|
//# sourceMappingURL=out.js.map
|
|
712
773
|
//# sourceMappingURL=index.browser.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/blockhash.ts","../src/create-transaction.ts","../src/fee-payer.ts","../src/instructions.ts","../src/signatures.ts","../../instructions/dist/index.browser.js","../src/accounts.ts","../src/compile-address-table-lookups.ts","../src/compile-header.ts","../src/compile-instructions.ts","../src/compile-lifetime-token.ts","../src/compile-static-accounts.ts","../src/message.ts","../src/serializers/message.ts","../src/serializers/address-table-lookup.ts","../src/serializers/header.ts","../src/serializers/instruction.ts","../src/serializers/unimplemented.ts","../src/serializers/transaction-version.ts","../src/serializers/transaction.ts","../src/compile-transaction.ts","../src/wire-transaction.ts"],"names":["bytes","getBase58EncodedAddressComparator","array","base58","mapSerializer","shortU16","struct","getBase58EncodedAddressCodec","u8","BASE_CONFIG","serialize"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,cAAc;AAahB,SAAS,kBAAkB,mBAAmE;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,kBAAkB,SAAS;AAAA,MAE3B,kBAAkB,SAAS;AAAA,MAC7B;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAMA,SAAQ,OAAO,UAAU,iBAAiB;AAChD,UAAM,WAAWA,OAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,0CAA0C;AAAA,MAC3D,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;;;AC1BO,SAAS,kBAAuD;AAAA,EACnE;AACJ,GAA6C;AACzC,QAAM,MAAmB;AAA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AMG,eAAc;AAAA,EAChB,aAAa,UAAU,4CAA4C;AAAA,EACnE,WAAW;AAAA,EACX,SAAS;AACb;AAIA,SAASC,WAAU,aAAsC;AACrD,QAAM,sBAAsB,uBAAuB,WAAW;AAC9D,SAAOJ,QAAO;AAAA,IACV;AAAA,MACI;AAAA,MACAJ,OAAMF,OAAM,EAAE,MAAM,GAAG,CAAC,GAAG;AAAA,QACvB,GAAI,UAAU,EAAE,aAAa,iEAAiE,IAAI;AAAA,QAClG,MAAMK,UAAS;AAAA,MACnB,CAAC;AAAA,IACL;AAAA,IACA,CAAC,mBAAmB,0BAA0B,CAAC;AAAA,EACnD,CAAC,EAAE,UAAU,mBAAmB;AACpC;AAEO,SAAS,wBAA6D;AACzE,SAAO;AAAA,IACH,GAAGI;AAAA,IACH,aAAa,wBAAwB,iBAAiB;AAAA,IACtD,WAAAC;AAAA,EACJ;AACJ;;;AE5BO,SAAS,gCACZ,aAC4B;AAC5B,QAAM,uBAAuB,sBAAsB,EAAE,UAAU,WAAW;AAC1E,MAAI,OAAY;AACZ,WAAO,OAAO,KAAK,oBAAoB,EAAE,SAAS,QAAQ;AAAA,EAC9D,OAAO;AACH,WAAQ,KAAwB,OAAO,aAAa,GAAG,oBAAoB,CAAC;AAAA,EAChF;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58 } from '@metaplex-foundation/umi-serializers';\n\nexport type Blockhash = string & { readonly __blockhash: unique symbol };\n\ntype BlockhashLifetimeConstraint = Readonly<{\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n}>;\n\nexport interface ITransactionWithBlockhashLifetime {\n readonly lifetimeConstraint: BlockhashLifetimeConstraint;\n}\n\nexport function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (32 bytes of zeroes)\n putativeBlockhash.length < 32 ||\n // Highest value (32 bytes of 255)\n putativeBlockhash.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBlockhash);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBlockhash}\\` is not a blockhash`, {\n cause: e,\n });\n }\n}\n","import { Transaction, TransactionVersion } from './types';\n\ntype TransactionConfig<TVersion extends TransactionVersion> = Readonly<{\n version: TVersion;\n}>;\n\nexport function createTransaction<TVersion extends TransactionVersion>(\n config: TransactionConfig<TVersion>\n): Extract<Transaction, { version: TVersion }>;\nexport function createTransaction<TVersion extends TransactionVersion>({\n version,\n}: TransactionConfig<TVersion>): Transaction {\n const out: Transaction = {\n instructions: [],\n version,\n };\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress } from '@solana/keys';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\n\nexport interface ITransactionWithFeePayer<TAddress extends string = string> {\n readonly feePayer: Base58EncodedAddress<TAddress>;\n}\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction:\n | TTransaction\n | (TTransaction & ITransactionWithFeePayer<TFeePayerAddress>)\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<TFeePayerAddress> & ITransactionWithSignatures)\n):\n | (TTransaction & ITransactionWithFeePayer<TFeePayerAddress>)\n | (Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithFeePayer<TFeePayerAddress>) {\n if ('feePayer' in transaction && feePayer === transaction.feePayer) {\n return transaction;\n }\n let out;\n if ('signatures' in transaction) {\n // The implication of the fee payer changing is that any existing signatures are invalid.\n const {\n signatures: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n out = {\n ...unsignedTransaction,\n feePayer,\n };\n } else {\n out = {\n ...transaction,\n feePayer,\n };\n }\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\n\nfunction replaceInstructions<TTransaction extends BaseTransaction, TInstructions>(\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n nextInstructions: TInstructions\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n let out;\n if ('signatures' in transaction) {\n // The implication of the instructions changing is that any existing signatures are invalid.\n const {\n signatures: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n out = {\n ...unsignedTransaction,\n instructions: nextInstructions,\n };\n } else {\n out = {\n ...transaction,\n instructions: nextInstructions,\n };\n }\n return out;\n}\n\nexport function appendTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const nextInstructions = [...transaction.instructions, instruction] as const;\n const out = replaceInstructions(transaction, nextInstructions);\n Object.freeze(out);\n return out;\n}\n\nexport function prependTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const nextInstructions = [instruction, ...transaction.instructions] as const;\n const out = replaceInstructions(transaction, nextInstructions);\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress, Ed25519Signature, getBase58EncodedAddressFromPublicKey, signBytes } from '@solana/keys';\n\nimport { CompiledMessage, compileMessage } from './message';\nimport { getCompiledMessageEncoder } from './serializers/message';\n\nexport interface IFullySignedTransaction extends ITransactionWithSignatures {\n readonly __fullySignedTransaction: unique symbol;\n}\nexport interface ITransactionWithSignatures {\n readonly signatures: { readonly [publicKey: Base58EncodedAddress]: Ed25519Signature };\n}\n\nasync function getCompiledMessageSignature(message: CompiledMessage, secretKey: CryptoKey) {\n const wireMessageBytes = getCompiledMessageEncoder().serialize(message);\n const signature = await signBytes(secretKey, wireMessageBytes);\n return signature;\n}\n\nexport async function signTransaction<TTransaction extends Parameters<typeof compileMessage>[0]>(\n keyPair: CryptoKeyPair,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Promise<TTransaction & ITransactionWithSignatures> {\n const compiledMessage = compileMessage(transaction);\n const [signerPublicKey, signature] = await Promise.all([\n getBase58EncodedAddressFromPublicKey(keyPair.publicKey),\n getCompiledMessageSignature(compiledMessage, keyPair.privateKey),\n ]);\n const nextSignatures = {\n ...('signatures' in transaction ? transaction.signatures : null),\n ...({ [signerPublicKey]: signature } as ITransactionWithSignatures['signatures']),\n };\n const out = {\n ...transaction,\n signatures: nextSignatures,\n };\n Object.freeze(out);\n return out;\n}\n","// src/roles.ts\nvar AccountRole = /* @__PURE__ */ ((AccountRole2) => {\n AccountRole2[AccountRole2[\"WRITABLE_SIGNER\"] = /* 3 */\n 3] = \"WRITABLE_SIGNER\";\n AccountRole2[AccountRole2[\"READONLY_SIGNER\"] = /* 2 */\n 2] = \"READONLY_SIGNER\";\n AccountRole2[AccountRole2[\"WRITABLE\"] = /* 1 */\n 1] = \"WRITABLE\";\n AccountRole2[AccountRole2[\"READONLY\"] = /* 0 */\n 0] = \"READONLY\";\n return AccountRole2;\n})(AccountRole || {});\nvar IS_SIGNER_BITMASK = 2;\nvar IS_WRITABLE_BITMASK = 1;\nfunction downgradeRoleToNonSigner(role) {\n return role & ~IS_SIGNER_BITMASK;\n}\nfunction downgradeRoleToReadonly(role) {\n return role & ~IS_WRITABLE_BITMASK;\n}\nfunction isSignerRole(role) {\n return role >= 2 /* READONLY_SIGNER */;\n}\nfunction isWritableRole(role) {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\nfunction mergeRoles(roleA, roleB) {\n return roleA | roleB;\n}\nfunction upgradeRoleToSigner(role) {\n return role | IS_SIGNER_BITMASK;\n}\nfunction upgradeRoleToWritable(role) {\n return role | IS_WRITABLE_BITMASK;\n}\n\nexport { AccountRole, downgradeRoleToNonSigner, downgradeRoleToReadonly, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable };\n","import {\n AccountRole,\n IAccountLookupMeta,\n IAccountMeta,\n IInstruction,\n isSignerRole,\n isWritableRole,\n mergeRoles,\n ReadonlyAccount,\n ReadonlyAccountLookup,\n ReadonlySignerAccount,\n WritableAccount,\n WritableAccountLookup,\n WritableSignerAccount,\n} from '@solana/instructions';\nimport { Base58EncodedAddress, getBase58EncodedAddressComparator } from '@solana/keys';\n\nexport const enum AddressMapEntryType {\n FEE_PAYER,\n LOOKUP_TABLE,\n STATIC,\n}\n\ntype AddressMap = {\n [address: string]: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry;\n};\ntype FeePayerAccountEntry = Omit<WritableSignerAccount, 'address'> & {\n [TYPE]: AddressMapEntryType.FEE_PAYER;\n};\ntype LookupTableAccountEntry = Omit<ReadonlyAccountLookup | WritableAccountLookup, 'address'> & {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE;\n};\nexport type OrderedAccounts = (IAccountMeta | IAccountLookupMeta)[] & { readonly __orderedAccounts: unique symbol };\ntype StaticAccountEntry = Omit<\n ReadonlyAccount | ReadonlySignerAccount | WritableAccount | WritableSignerAccount,\n 'address'\n> & { [TYPE]: AddressMapEntryType.STATIC };\n\nfunction upsert(\n addressMap: AddressMap,\n address: Base58EncodedAddress,\n update: (\n entry: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry | Record<never, never>\n ) => AddressMap[Base58EncodedAddress]\n) {\n addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });\n}\n\nconst TYPE = Symbol('AddressMapTypeProperty');\nexport const ADDRESS_MAP_TYPE_PROPERTY: typeof TYPE = TYPE;\n\nexport function getAddressMapFromInstructions(\n feePayer: Base58EncodedAddress,\n instructions: readonly IInstruction[]\n): AddressMap {\n const addressMap: AddressMap = {\n [feePayer]: { [TYPE]: AddressMapEntryType.FEE_PAYER, role: AccountRole.WRITABLE_SIGNER },\n };\n const addressesOfInvokedPrograms = new Set<Base58EncodedAddress>();\n for (const instruction of instructions) {\n upsert(addressMap, instruction.programAddress, entry => {\n addressesOfInvokedPrograms.add(instruction.programAddress);\n if (TYPE in entry) {\n if (isWritableRole(entry.role)) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and set as the fee payer. Program addresses may not pay fees.'\n );\n default:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and marked writable. Program addresses may not be writable.'\n );\n }\n }\n if (entry[TYPE] === AddressMapEntryType.STATIC) {\n return entry;\n }\n }\n return { [TYPE]: AddressMapEntryType.STATIC, role: AccountRole.READONLY };\n });\n let addressComparator: ReturnType<typeof getBase58EncodedAddressComparator>;\n if (!instruction.accounts) {\n continue;\n }\n for (const account of instruction.accounts) {\n upsert(addressMap, account.address, entry => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n address: _,\n ...accountMeta\n } = account;\n if (TYPE in entry) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // The fee payer already has the highest rank -- it is by definition\n // writable-signer. Return it, no matter how `account` is configured\n return entry as FeePayerAccountEntry;\n case AddressMapEntryType.LOOKUP_TABLE: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if ('lookupTableAddress' in accountMeta) {\n const shouldReplaceEntry =\n // Consider using the new LOOKUP_TABLE if its address is different...\n entry.lookupTableAddress !== accountMeta.lookupTableAddress &&\n // ...and sorts before the existing one.\n (addressComparator ||= getBase58EncodedAddressComparator())(\n accountMeta.lookupTableAddress,\n entry.lookupTableAddress\n ) < 0;\n if (shouldReplaceEntry) {\n return {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n ...accountMeta,\n role: nextRole,\n } as LookupTableAccountEntry;\n }\n } else if (isSignerRole(accountMeta.role)) {\n // Upgrade this LOOKUP_TABLE entry to a static entry if it must sign.\n return {\n [TYPE]: AddressMapEntryType.STATIC,\n role: nextRole,\n } as StaticAccountEntry;\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n return entry as LookupTableAccountEntry;\n }\n }\n case AddressMapEntryType.STATIC: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if (\n // Check to see if this address represents a program that is invoked\n // in this transaction.\n addressesOfInvokedPrograms.has(account.address)\n ) {\n if (isWritableRole(accountMeta.role)) {\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${account.address}\\`) which is both invoked and ` +\n 'marked writable. Program addresses may not be ' +\n 'writable.'\n );\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n } else if (\n 'lookupTableAddress' in accountMeta &&\n // Static accounts can be 'upgraded' to lookup table accounts as\n // long as they are not require to sign the transaction.\n !isSignerRole(entry.role)\n ) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n if (entry.role !== nextRole) {\n // The account's role ranks higher than the current entry's.\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n }\n }\n }\n }\n if ('lookupTableAddress' in accountMeta) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n };\n } else {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.STATIC,\n };\n }\n });\n }\n }\n return addressMap;\n}\n\nexport function getOrderedAccountsFromAddressMap(addressMap: AddressMap): OrderedAccounts {\n let addressComparator: ReturnType<typeof getBase58EncodedAddressComparator>;\n const orderedAccounts: (IAccountMeta | IAccountLookupMeta)[] = Object.entries(addressMap)\n .sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {\n // STEP 1: Rapid precedence check. Fee payer, then static addresses, then lookups.\n if (leftEntry[TYPE] !== rightEntry[TYPE]) {\n if (leftEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return 1;\n } else if (leftEntry[TYPE] === AddressMapEntryType.STATIC) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.STATIC) {\n return 1;\n }\n }\n // STEP 2: Sort by signer-writability.\n const leftIsSigner = isSignerRole(leftEntry.role);\n if (leftIsSigner !== isSignerRole(rightEntry.role)) {\n return leftIsSigner ? -1 : 1;\n }\n const leftIsWritable = isWritableRole(leftEntry.role);\n if (leftIsWritable !== isWritableRole(rightEntry.role)) {\n return leftIsWritable ? -1 : 1;\n }\n // STEP 3: Sort by address.\n addressComparator ||= getBase58EncodedAddressComparator();\n if (\n leftEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n rightEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress\n ) {\n return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);\n } else {\n return addressComparator(leftAddress, rightAddress);\n }\n })\n .map(([address, addressMeta]) => ({\n address: address as Base58EncodedAddress<typeof address>,\n ...addressMeta,\n }));\n return orderedAccounts as unknown as OrderedAccounts;\n}\n","import { AccountRole } from '@solana/instructions';\nimport { Base58EncodedAddress, getBase58EncodedAddressComparator } from '@solana/keys';\n\nimport { OrderedAccounts } from './accounts';\n\ntype AddressTableLookup = Readonly<{\n lookupTableAddress: Base58EncodedAddress;\n readableIndices: readonly number[];\n writableIndices: readonly number[];\n}>;\n\nexport function getCompiledAddressTableLookups(orderedAccounts: OrderedAccounts): AddressTableLookup[] {\n const index: Record<\n Base58EncodedAddress,\n { readonly readableIndices: number[]; readonly writableIndices: number[] }\n > = {};\n for (const account of orderedAccounts) {\n if (!('lookupTableAddress' in account)) {\n continue;\n }\n const entry = (index[account.lookupTableAddress] ||= {\n readableIndices: [],\n writableIndices: [],\n });\n if (account.role === AccountRole.WRITABLE) {\n entry.writableIndices.push(account.addressIndex);\n } else {\n entry.readableIndices.push(account.addressIndex);\n }\n }\n return Object.keys(index)\n .sort(getBase58EncodedAddressComparator())\n .map(lookupTableAddress => ({\n lookupTableAddress: lookupTableAddress as Base58EncodedAddress,\n ...index[lookupTableAddress as unknown as Base58EncodedAddress],\n }));\n}\n","import { isSignerRole, isWritableRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype MessageHeader = Readonly<{\n numReadonlyNonSignerAccounts: number;\n numReadonlySignerAccounts: number;\n numSignerAccounts: number;\n}>;\n\nexport function getCompiledMessageHeader(orderedAccounts: OrderedAccounts): MessageHeader {\n let numReadonlyNonSignerAccounts = 0;\n let numReadonlySignerAccounts = 0;\n let numSignerAccounts = 0;\n for (const account of orderedAccounts) {\n if ('lookupTableAddress' in account) {\n break;\n }\n const accountIsWritable = isWritableRole(account.role);\n if (isSignerRole(account.role)) {\n numSignerAccounts++;\n if (!accountIsWritable) {\n numReadonlySignerAccounts++;\n }\n } else if (!accountIsWritable) {\n numReadonlyNonSignerAccounts++;\n }\n }\n return {\n numReadonlyNonSignerAccounts,\n numReadonlySignerAccounts,\n numSignerAccounts,\n };\n}\n","import { IInstruction } from '@solana/instructions';\nimport { Base58EncodedAddress } from '@solana/keys';\n\nimport { OrderedAccounts } from './accounts';\n\ntype CompiledInstruction = Readonly<{\n addressIndices?: number[];\n data?: Uint8Array;\n programAddressIndex: number;\n}>;\n\nfunction getAccountIndex(orderedAccounts: OrderedAccounts) {\n const out: Record<Base58EncodedAddress, number> = {};\n for (const [index, account] of orderedAccounts.entries()) {\n out[account.address] = index;\n }\n return out;\n}\n\nexport function getCompiledInstructions(\n instructions: readonly IInstruction[],\n orderedAccounts: OrderedAccounts\n): CompiledInstruction[] {\n const accountIndex = getAccountIndex(orderedAccounts);\n return instructions.map(({ accounts, data, programAddress }) => {\n return {\n programAddressIndex: accountIndex[programAddress],\n ...(accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null),\n ...(data ? { data } : null),\n };\n });\n}\n","import { IDurableNonceTransaction, ITransactionWithBlockhashLifetime } from './index';\n\nexport function getCompiledLifetimeToken(\n lifetimeConstraint: (ITransactionWithBlockhashLifetime | IDurableNonceTransaction)['lifetimeConstraint']\n): string {\n if ('nonce' in lifetimeConstraint) {\n return lifetimeConstraint.nonce;\n }\n return lifetimeConstraint.blockhash;\n}\n","import { Base58EncodedAddress } from '@solana/keys';\n\nimport { OrderedAccounts } from './accounts';\n\nexport function getCompiledStaticAccounts(orderedAccounts: OrderedAccounts): Base58EncodedAddress[] {\n const firstLookupTableAccountIndex = orderedAccounts.findIndex(account => 'lookupTableAddress' in account);\n const orderedStaticAccounts =\n firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);\n return orderedStaticAccounts.map(({ address }) => address);\n}\n","import { getAddressMapFromInstructions, getOrderedAccountsFromAddressMap } from './accounts';\nimport { ITransactionWithBlockhashLifetime } from './blockhash';\nimport { getCompiledAddressTableLookups } from './compile-address-table-lookups';\nimport { getCompiledMessageHeader } from './compile-header';\nimport { getCompiledInstructions } from './compile-instructions';\nimport { getCompiledLifetimeToken } from './compile-lifetime-token';\nimport { getCompiledStaticAccounts } from './compile-static-accounts';\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithFeePayer } from './fee-payer';\nimport { BaseTransaction } from './types';\n\ntype BaseCompiledMessage = Readonly<{\n header: ReturnType<typeof getCompiledMessageHeader>;\n instructions: ReturnType<typeof getCompiledInstructions>;\n lifetimeToken: ReturnType<typeof getCompiledLifetimeToken>;\n staticAccounts: ReturnType<typeof getCompiledStaticAccounts>;\n}>;\n\ntype CompilableTransaction = BaseTransaction &\n ITransactionWithFeePayer &\n (ITransactionWithBlockhashLifetime | IDurableNonceTransaction);\n\nexport type CompiledMessage = LegacyCompiledMessage | VersionedCompiledMessage;\n\ntype LegacyCompiledMessage = BaseCompiledMessage &\n Readonly<{\n version: 'legacy';\n }>;\n\ntype VersionedCompiledMessage = BaseCompiledMessage &\n Readonly<{\n addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups>;\n version: number;\n }>;\n\nexport function compileMessage(\n transaction: CompilableTransaction & Readonly<{ version: 'legacy' }>\n): LegacyCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): VersionedCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): CompiledMessage {\n const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);\n const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);\n return {\n ...(transaction.version !== 'legacy'\n ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) }\n : null),\n header: getCompiledMessageHeader(orderedAccounts),\n instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),\n lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),\n staticAccounts: getCompiledStaticAccounts(orderedAccounts),\n version: transaction.version,\n };\n}\n","import {\n array,\n base58,\n mapSerializer,\n Serializer,\n shortU16,\n string,\n struct,\n StructToSerializerTuple,\n} from '@metaplex-foundation/umi-serializers';\nimport { getBase58EncodedAddressCodec } from '@solana/keys';\n\nimport { CompiledMessage } from '../message';\nimport { getAddressTableLookupCodec } from './address-table-lookup';\nimport { getMessageHeaderCodec } from './header';\nimport { getInstructionCodec } from './instruction';\nimport { getTransactionVersionCodec } from './transaction-version';\nimport { getUnimplementedDecoder, getUnimplementedEncoder } from './unimplemented';\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'The wire format of a Solana transaction message' : '',\n fixedSize: null,\n maxSize: null,\n} as const;\n\nfunction deserialize(bytes: Uint8Array, offset = 0): [CompiledMessage, number] {\n const preludeAndOffset = struct(getPreludeStructSerializerTuple()).deserialize(bytes, offset);\n const [prelude, endOfPreludeOffset] = preludeAndOffset;\n if (prelude.version === 'legacy') {\n return preludeAndOffset;\n }\n const [addressTableLookups, finalOffset] = getAddressTableLookupsSerializer().deserialize(\n bytes,\n endOfPreludeOffset\n );\n return [\n {\n ...prelude,\n ...(addressTableLookups.length ? { addressTableLookups } : null),\n },\n finalOffset,\n ];\n}\n\nfunction serialize(compiledMessage: CompiledMessage) {\n if (compiledMessage.version === 'legacy') {\n return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);\n } else {\n return mapSerializer(\n struct([\n ...getPreludeStructSerializerTuple(),\n ['addressTableLookups', getAddressTableLookupsSerializer()],\n ] as StructToSerializerTuple<CompiledMessage, CompiledMessage>),\n (value: CompiledMessage) => {\n if (value.version === 'legacy') {\n return value;\n }\n return {\n ...value,\n addressTableLookups: value.addressTableLookups ?? [],\n } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n }\n ).serialize(compiledMessage);\n }\n}\n\nfunction getPreludeStructSerializerTuple(): StructToSerializerTuple<CompiledMessage, CompiledMessage> {\n return [\n ['version', getTransactionVersionCodec()],\n ['header', getMessageHeaderCodec()],\n [\n 'staticAccounts',\n array(getBase58EncodedAddressCodec(), {\n description: __DEV__ ? 'A compact-array of static account addresses belonging to this transaction' : '',\n size: shortU16(),\n }),\n ],\n [\n 'lifetimeToken',\n string({\n description: __DEV__\n ? 'A 32-byte token that specifies the lifetime of this transaction (eg. a ' +\n 'recent blockhash, or a durable nonce)'\n : '',\n encoding: base58,\n size: 32,\n }),\n ],\n [\n 'instructions',\n array(getInstructionCodec(), {\n description: __DEV__ ? 'A compact-array of instructions belonging to this transaction' : '',\n size: shortU16(),\n }),\n ],\n ];\n}\n\nfunction getAddressTableLookupsSerializer() {\n return array(getAddressTableLookupCodec(), {\n ...(__DEV__ ? { description: 'A compact array of address table lookups belonging to this transaction' } : null),\n size: shortU16(),\n });\n}\n\nexport function getCompiledMessageEncoder(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('CompiledMessage'),\n serialize,\n };\n}\n\nexport function getCompiledMessageDecoder(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize: getUnimplementedEncoder('CompiledMessage'),\n };\n}\n\nexport function getCompiledMessageCodec(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize,\n };\n}\n","import { array, Serializer, shortU16, struct, StructToSerializerTuple, u8 } from '@metaplex-foundation/umi-serializers';\nimport { getBase58EncodedAddressCodec } from '@solana/keys';\n\nimport { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\n\ntype AddressTableLookup = ReturnType<typeof getCompiledAddressTableLookups>[number];\n\nexport function getAddressTableLookupCodec(): Serializer<AddressTableLookup> {\n return struct(\n [\n [\n 'lookupTableAddress',\n getBase58EncodedAddressCodec(\n __DEV__\n ? {\n description:\n 'The address of the address lookup table account from which ' +\n 'instruction addresses should be looked up',\n }\n : undefined\n ),\n ],\n [\n 'writableIndices',\n array(u8(), {\n ...(__DEV__\n ? {\n description:\n 'The indices of the accounts in the lookup table that should ' +\n 'be loaded as writeable',\n }\n : null),\n size: shortU16(),\n }),\n ],\n [\n 'readableIndices',\n array(u8(), {\n ...(__DEV__\n ? {\n description:\n 'The indices of the accounts in the lookup table that should ' +\n 'be loaded as read-only',\n }\n : undefined),\n size: shortU16(),\n }),\n ],\n ] as StructToSerializerTuple<AddressTableLookup, AddressTableLookup>,\n __DEV__\n ? {\n description:\n 'A pointer to the address of an address lookup table, along with the ' +\n 'readonly/writeable indices of the addresses that should be loaded from it',\n }\n : undefined\n );\n}\n","import { Serializer, struct, u8 } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledMessageHeader } from '../compile-header';\n\ntype MessageHeader = ReturnType<typeof getCompiledMessageHeader>;\n\nexport function getMessageHeaderCodec(): Serializer<MessageHeader> {\n return struct(\n [\n [\n 'numSignerAccounts',\n u8(\n __DEV__\n ? {\n description:\n 'The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction',\n }\n : undefined\n ),\n ],\n [\n 'numReadonlySignerAccounts',\n u8(\n __DEV__\n ? {\n description:\n 'The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable',\n }\n : undefined\n ),\n ],\n [\n 'numReadonlyNonSignerAccounts',\n u8(\n __DEV__\n ? {\n description:\n 'The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable',\n }\n : undefined\n ),\n ],\n ],\n __DEV__\n ? {\n description:\n 'The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses',\n }\n : undefined\n );\n}\n","import { array, bytes, mapSerializer, Serializer, shortU16, struct, u8 } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledInstructions } from '../compile-instructions';\n\ntype Instruction = ReturnType<typeof getCompiledInstructions>[number];\n\nexport function getInstructionCodec(): Serializer<Instruction> {\n return mapSerializer<Instruction, Required<Instruction>>(\n struct([\n [\n 'programAddressIndex',\n u8(\n __DEV__\n ? {\n description:\n 'The index of the program being called, according to the ' +\n 'well-ordered accounts list for this transaction',\n }\n : undefined\n ),\n ],\n [\n 'addressIndices',\n array(\n u8({\n description: __DEV__\n ? 'The index of an account, according to the well-ordered accounts ' +\n 'list for this transaction'\n : '',\n }),\n {\n description: __DEV__\n ? 'An optional list of account indices, according to the ' +\n 'well-ordered accounts list for this transaction, in the order in ' +\n 'which the program being called expects them'\n : '',\n size: shortU16(),\n }\n ),\n ],\n [\n 'data',\n bytes({\n description: __DEV__ ? 'An optional buffer of data passed to the instruction' : '',\n size: shortU16(),\n }),\n ],\n ]),\n (value: Instruction) => {\n if (value.addressIndices !== undefined && value.data !== undefined) {\n return value as Required<Instruction>;\n }\n return {\n ...value,\n addressIndices: value.addressIndices ?? [],\n data: value.data ?? new Uint8Array(0),\n } as Required<Instruction>;\n },\n (value: Required<Instruction>) => {\n if (value.addressIndices.length && value.data.byteLength) {\n return value;\n }\n const { addressIndices, data, ...rest } = value;\n return {\n ...rest,\n ...(addressIndices.length ? { addressIndices } : null),\n ...(data.byteLength ? { data } : null),\n };\n }\n );\n}\n","function getError(type: 'decoder' | 'encoder', name: string) {\n const functionSuffix = name + type[0].toUpperCase() + type.slice(1);\n return new Error(\n `No ${type} exists for ${name}. Use \\`get${functionSuffix}()\\` if you need a ${type}, and \\`get${name}Codec()\\` if you need to both encode and decode ${name}`\n );\n}\n\nexport function getUnimplementedDecoder(name: string): () => never {\n return () => {\n throw getError('decoder', name);\n };\n}\n\nexport function getUnimplementedEncoder(name: string): () => never {\n return () => {\n throw getError('encoder', name);\n };\n}\n","import { Serializer } from '@metaplex-foundation/umi-serializers';\n\nimport { TransactionVersion } from '../types';\nimport { getUnimplementedDecoder, getUnimplementedEncoder } from './unimplemented';\n\nconst VERSION_FLAG_MASK = 0x80;\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'A single byte that encodes the version of the transaction' : '',\n fixedSize: null,\n maxSize: 1,\n} as const;\n\nfunction deserialize(bytes: Uint8Array, offset = 0): [TransactionVersion, number] {\n const firstByte = bytes[offset];\n if ((firstByte & VERSION_FLAG_MASK) === 0) {\n // No version flag set; it's a legacy (unversioned) transaction.\n return ['legacy', offset];\n } else {\n const version = (firstByte ^ VERSION_FLAG_MASK) as TransactionVersion;\n return [version, offset + 1];\n }\n}\n\nfunction serialize(value: TransactionVersion): Uint8Array {\n if (value === 'legacy') {\n return new Uint8Array();\n }\n if (value < 0 || value > 127) {\n // TODO: Coded error.\n throw new Error(`Transaction version must be in the range [0, 127]. \\`${value}\\` given.`);\n }\n return new Uint8Array([value | VERSION_FLAG_MASK]);\n}\n\nexport function getTransactionVersionDecoder(): Serializer<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize: getUnimplementedEncoder('TransactionVersion'),\n };\n}\n\nexport function getTransactionVersionEncoder(): Serializer<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('TransactionVersion'),\n serialize,\n };\n}\n\nexport function getTransactionVersionCodec(): Serializer<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize,\n };\n}\n","import { array, bytes, Serializer, shortU16, struct } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledTransaction } from '../compile-transaction';\nimport { getCompiledMessageEncoder } from './message';\nimport { getUnimplementedDecoder } from './unimplemented';\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'The wire format of a Solana transaction' : '',\n fixedSize: null,\n maxSize: null,\n} as const;\n\ntype SerializableTransaction = Parameters<typeof getCompiledTransaction>[0];\n\nfunction serialize(transaction: SerializableTransaction) {\n const compiledTransaction = getCompiledTransaction(transaction);\n return struct([\n [\n 'signatures',\n array(bytes({ size: 64 }), {\n ...(__DEV__ ? { description: 'A compact array of 64-byte, base-64 encoded Ed25519 signatures' } : null),\n size: shortU16(),\n }),\n ],\n ['compiledMessage', getCompiledMessageEncoder()],\n ]).serialize(compiledTransaction);\n}\n\nexport function getTransactionEncoder(): Serializer<SerializableTransaction> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('CompiledMessage'),\n serialize,\n };\n}\n","import { Ed25519Signature } from '@solana/keys';\n\nimport { CompiledMessage, compileMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\n\ntype CompiledTransaction = Readonly<{\n compiledMessage: CompiledMessage;\n signatures: Ed25519Signature[];\n}>;\n\ntype CompilableTransaction = Parameters<typeof compileMessage>[0];\n\nexport function getCompiledTransaction(\n transaction: CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)\n): CompiledTransaction {\n const compiledMessage = compileMessage(transaction);\n let signatures;\n if ('signatures' in transaction) {\n signatures = [];\n for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {\n signatures[ii] =\n transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));\n }\n } else {\n signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));\n }\n return {\n compiledMessage,\n signatures,\n };\n}\n","import { getTransactionEncoder } from './serializers/transaction';\n\nexport type Base64EncodedWireTransaction = string & {\n readonly __base64EncodedWireTransaction: unique symbol;\n};\n\nexport function getBase64EncodedWireTransaction(\n transaction: Parameters<ReturnType<typeof getTransactionEncoder>['serialize']>[0]\n): Base64EncodedWireTransaction {\n const wireTransactionBytes = getTransactionEncoder().serialize(transaction);\n if (__NODEJS__) {\n return Buffer.from(wireTransactionBytes).toString('base64') as Base64EncodedWireTransaction;\n } else {\n return (btoa as Window['btoa'])(String.fromCharCode(...wireTransactionBytes)) as Base64EncodedWireTransaction;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/blockhash.ts","../src/unsigned-transaction.ts","../src/create-transaction.ts","../../instructions/src/roles.ts","../src/durable-nonce.ts","../src/fee-payer.ts","../src/instructions.ts","../src/signatures.ts","../src/accounts.ts","../src/compile-address-table-lookups.ts","../src/compile-header.ts","../src/compile-instructions.ts","../src/compile-lifetime-token.ts","../src/compile-static-accounts.ts","../src/message.ts","../src/serializers/message.ts","../src/serializers/address-table-lookup.ts","../src/serializers/header.ts","../src/serializers/instruction.ts","../src/serializers/unimplemented.ts","../src/serializers/transaction-version.ts","../src/serializers/transaction.ts","../src/compile-transaction.ts","../src/wire-transaction.ts"],"names":["bytes","AccountRole","getBase58EncodedAddressComparator","array","base58","mapSerializer","shortU16","struct","getBase58EncodedAddressCodec","u8","BASE_CONFIG","serialize"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,cAAc;;;ACGhB,SAAS,uBACZ,aACgG;AAChG,MAAI,gBAAgB,aAAa;AAE7B,UAAM;AAAA,MACF,YAAY;AAAA;AAAA,MACZ,GAAG;AA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iE,IAAI;AAAA,QAClG,MAAMM,UAAS;AAAA,MACnB,CAAC;AAAA,IACL;AAAA,IACA,CAAC,mBAAmB,0BAA0B,CAAC;AAAA,EACnD,CAAC,EAAE,UAAU,mBAAmB;AACpC;AAEO,SAAS,wBAA6D;AACzE,SAAO;AAAA,IACH,GAAGI;AAAA,IACH,aAAa,wBAAwB,iBAAiB;AAAA,IACtD,WAAAC;AAAA,EACJ;AACJ;;;AE5BO,SAAS,gCACZ,aAC4B;AAC5B,QAAM,uBAAuB,sBAAsB,EAAE,UAAU,WAAW;AAC1E,MAAI,OAAY;AACZ,WAAO,OAAO,KAAK,oBAAoB,EAAE,SAAS,QAAQ;AAAA,EAC9D,OAAO;AACH,WAAQ,KAAwB,OAAO,aAAa,GAAG,oBAAoB,CAAC;AAAA,EAChF;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58 } from '@metaplex-foundation/umi-serializers';\n\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport type Blockhash = string & { readonly __blockhash: unique symbol };\n\ntype BlockhashLifetimeConstraint = Readonly<{\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n}>;\n\nexport interface ITransactionWithBlockhashLifetime {\n readonly lifetimeConstraint: BlockhashLifetimeConstraint;\n}\n\nexport function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (32 bytes of zeroes)\n putativeBlockhash.length < 32 ||\n // Highest value (32 bytes of 255)\n putativeBlockhash.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBlockhash);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBlockhash}\\` is not a blockhash`, {\n cause: e,\n });\n }\n}\n\nexport function setTransactionLifetimeUsingBlockhash<TTransaction extends BaseTransaction & IDurableNonceTransaction>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures | 'lifetimeConstraint'> & ITransactionWithBlockhashLifetime;\nexport function setTransactionLifetimeUsingBlockhash<\n TTransaction extends BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)\n>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithBlockhashLifetime;\nexport function setTransactionLifetimeUsingBlockhash(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)\n) {\n if (\n 'lifetimeConstraint' in transaction &&\n transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash &&\n transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight\n ) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n lifetimeConstraint: blockhashLifetimeConstraint,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from '.';\nimport { BaseTransaction } from './types';\n\nexport function getUnsignedTransaction<TTransaction extends BaseTransaction>(\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction & ITransactionWithSignatures, keyof ITransactionWithSignatures> {\n if ('signatures' in transaction) {\n // The implication of the lifetime constraint changing is that any existing signatures are invalid.\n const {\n signatures: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n return unsignedTransaction;\n } else {\n return transaction;\n }\n}\n","import { Transaction, TransactionVersion } from './types';\n\ntype TransactionConfig<TVersion extends TransactionVersion> = Readonly<{\n version: TVersion;\n}>;\n\nexport function createTransaction<TVersion extends TransactionVersion>(\n config: TransactionConfig<TVersion>\n): Extract<Transaction, { version: TVersion }>;\nexport function createTransaction<TVersion extends TransactionVersion>({\n version,\n}: TransactionConfig<TVersion>): Transaction {\n const out: Transaction = {\n instructions: [],\n version,\n };\n Object.freeze(out);\n return out;\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\nimport { AccountRole, IInstruction, IInstructionWithAccounts, IInstructionWithData } from '@solana/instructions';\nimport { ReadonlyAccount, ReadonlySignerAccount, WritableAccount } from '@solana/instructions/dist/types/accounts';\n\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\ntype AdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string\n> = IInstruction<'11111111111111111111111111111111'> &\n IInstructionWithAccounts<\n readonly [\n WritableAccount<TNonceAccountAddress>,\n ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,\n ReadonlySignerAccount<TNonceAuthorityAddress>\n ]\n > &\n IInstructionWithData<AdvanceNonceAccountInstructionData>;\ntype AdvanceNonceAccountInstructionData = Uint8Array & {\n readonly __advanceNonceAccountInstructionData: unique symbol;\n};\ntype DurableNonceConfig<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n> = Readonly<{\n readonly nonce: Nonce<TNonceValue>;\n readonly nonceAccountAddress: Base58EncodedAddress<TNonceAccountAddress>;\n readonly nonceAuthorityAddress: Base58EncodedAddress<TNonceAuthorityAddress>;\n}>;\nexport type Nonce<TNonceValue extends string = string> = TNonceValue & { readonly __nonce: unique symbol };\ntype NonceLifetimeConstraint<TNonceValue extends string = string> = Readonly<{\n nonce: Nonce<TNonceValue>;\n}>;\n\nconst RECENT_BLOCKHASHES_SYSVAR_ADDRESS =\n 'SysvarRecentB1ockHashes11111111111111111111' as Base58EncodedAddress<'SysvarRecentB1ockHashes11111111111111111111'>;\nconst SYSTEM_PROGRAM_ADDRESS =\n '11111111111111111111111111111111' as Base58EncodedAddress<'11111111111111111111111111111111'>;\n\nexport interface IDurableNonceTransaction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n> {\n readonly instructions: readonly [\n // The first instruction *must* be the system program's `AdvanceNonceAccount` instruction.\n AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,\n ...IInstruction[]\n ];\n readonly lifetimeConstraint: NonceLifetimeConstraint<TNonceValue>;\n}\n\nexport function assertIsDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)\n): asserts transaction is BaseTransaction & IDurableNonceTransaction {\n if (!isDurableNonceTransaction(transaction)) {\n // TODO: Coded error.\n throw new Error('Transaction is not a durable nonce transaction');\n }\n}\n\nfunction createAdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string\n>(\n nonceAccountAddress: Base58EncodedAddress<TNonceAccountAddress>,\n nonceAuthorityAddress: Base58EncodedAddress<TNonceAuthorityAddress>\n): AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress> {\n return {\n accounts: [\n { address: nonceAccountAddress, role: AccountRole.WRITABLE },\n {\n address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,\n role: AccountRole.READONLY,\n },\n { address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER },\n ],\n data: new Uint8Array([4, 0, 0, 0]) as AdvanceNonceAccountInstructionData,\n programAddress: SYSTEM_PROGRAM_ADDRESS,\n };\n}\n\nfunction isAdvanceNonceAccountInstruction(instruction: IInstruction): instruction is AdvanceNonceAccountInstruction {\n return (\n instruction.programAddress === SYSTEM_PROGRAM_ADDRESS &&\n // Test for `AdvanceNonceAccount` instruction data\n instruction.data != null &&\n isAdvanceNonceAccountInstructionData(instruction.data) &&\n // Test for exactly 3 accounts\n instruction.accounts?.length === 3 &&\n // First account is nonce account address\n instruction.accounts[0].address != null &&\n instruction.accounts[0].role === AccountRole.WRITABLE &&\n // Second account is recent blockhashes sysvar\n instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS &&\n instruction.accounts[1].role === AccountRole.READONLY &&\n // Third account is nonce authority account\n instruction.accounts[2].address != null &&\n instruction.accounts[2].role === AccountRole.READONLY_SIGNER\n );\n}\n\nfunction isAdvanceNonceAccountInstructionData(data: Uint8Array): data is AdvanceNonceAccountInstructionData {\n // AdvanceNonceAccount is the fifth instruction in the System Program (index 4)\n return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;\n}\n\nfunction isDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)\n): transaction is BaseTransaction & IDurableNonceTransaction {\n return (\n 'lifetimeConstraint' in transaction &&\n typeof transaction.lifetimeConstraint.nonce === 'string' &&\n transaction.instructions[0] != null &&\n isAdvanceNonceAccountInstruction(transaction.instructions[0])\n );\n}\n\nexport function setTransactionLifetimeUsingDurableNonce<\n TTransaction extends BaseTransaction,\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n>(\n {\n nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n }: DurableNonceConfig<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>,\n transaction: TTransaction | (TTransaction & IDurableNonceTransaction)\n): TTransaction & IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue> {\n const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);\n if (\n isAlreadyDurableNonceTransaction &&\n transaction.lifetimeConstraint.nonce === nonce &&\n transaction.instructions[0].accounts[0].address === nonceAccountAddress &&\n transaction.instructions[0].accounts[2].address === nonceAuthorityAddress\n ) {\n return transaction as TTransaction &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...(isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions),\n ],\n lifetimeConstraint: {\n nonce,\n },\n } as TTransaction & IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport interface ITransactionWithFeePayer<TAddress extends string = string> {\n readonly feePayer: Base58EncodedAddress<TAddress>;\n}\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction:\n | TTransaction\n | (TTransaction & ITransactionWithFeePayer<TFeePayerAddress>)\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<TFeePayerAddress> & ITransactionWithSignatures)\n):\n | (TTransaction & ITransactionWithFeePayer<TFeePayerAddress>)\n | (Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithFeePayer<TFeePayerAddress>) {\n if ('feePayer' in transaction && feePayer === transaction.feePayer) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n feePayer,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport function appendTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [...transaction.instructions, instruction],\n };\n Object.freeze(out);\n return out;\n}\n\nexport function prependTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [instruction, ...transaction.instructions],\n };\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress, getBase58EncodedAddressFromPublicKey } from '@solana/addresses';\nimport { Ed25519Signature, signBytes } from '@solana/keys';\n\nimport { CompiledMessage, compileMessage } from './message';\nimport { getCompiledMessageEncoder } from './serializers/message';\n\nexport interface IFullySignedTransaction extends ITransactionWithSignatures {\n readonly __fullySignedTransaction: unique symbol;\n}\nexport interface ITransactionWithSignatures {\n readonly signatures: Readonly<Record<Base58EncodedAddress, Ed25519Signature>>;\n}\n\nasync function getCompiledMessageSignature(message: CompiledMessage, secretKey: CryptoKey) {\n const wireMessageBytes = getCompiledMessageEncoder().serialize(message);\n const signature = await signBytes(secretKey, wireMessageBytes);\n return signature;\n}\n\nexport async function signTransaction<TTransaction extends Parameters<typeof compileMessage>[0]>(\n keyPair: CryptoKeyPair,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Promise<TTransaction & ITransactionWithSignatures> {\n const compiledMessage = compileMessage(transaction);\n const [signerPublicKey, signature] = await Promise.all([\n getBase58EncodedAddressFromPublicKey(keyPair.publicKey),\n getCompiledMessageSignature(compiledMessage, keyPair.privateKey),\n ]);\n const nextSignatures = {\n ...('signatures' in transaction ? transaction.signatures : null),\n ...({ [signerPublicKey]: signature } as ITransactionWithSignatures['signatures']),\n };\n const out = {\n ...transaction,\n signatures: nextSignatures,\n };\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress, getBase58EncodedAddressComparator } from '@solana/addresses';\nimport {\n AccountRole,\n IAccountLookupMeta,\n IAccountMeta,\n IInstruction,\n isSignerRole,\n isWritableRole,\n mergeRoles,\n ReadonlyAccount,\n ReadonlyAccountLookup,\n ReadonlySignerAccount,\n WritableAccount,\n WritableAccountLookup,\n WritableSignerAccount,\n} from '@solana/instructions';\n\nexport const enum AddressMapEntryType {\n FEE_PAYER,\n LOOKUP_TABLE,\n STATIC,\n}\n\ntype AddressMap = {\n [address: string]: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry;\n};\ntype FeePayerAccountEntry = Omit<WritableSignerAccount, 'address'> & {\n [TYPE]: AddressMapEntryType.FEE_PAYER;\n};\ntype LookupTableAccountEntry = Omit<ReadonlyAccountLookup | WritableAccountLookup, 'address'> & {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE;\n};\nexport type OrderedAccounts = (IAccountMeta | IAccountLookupMeta)[] & { readonly __orderedAccounts: unique symbol };\ntype StaticAccountEntry = Omit<\n ReadonlyAccount | ReadonlySignerAccount | WritableAccount | WritableSignerAccount,\n 'address'\n> & { [TYPE]: AddressMapEntryType.STATIC };\n\nfunction upsert(\n addressMap: AddressMap,\n address: Base58EncodedAddress,\n update: (\n entry: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry | Record<never, never>\n ) => AddressMap[Base58EncodedAddress]\n) {\n addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });\n}\n\nconst TYPE = Symbol('AddressMapTypeProperty');\nexport const ADDRESS_MAP_TYPE_PROPERTY: typeof TYPE = TYPE;\n\nexport function getAddressMapFromInstructions(\n feePayer: Base58EncodedAddress,\n instructions: readonly IInstruction[]\n): AddressMap {\n const addressMap: AddressMap = {\n [feePayer]: { [TYPE]: AddressMapEntryType.FEE_PAYER, role: AccountRole.WRITABLE_SIGNER },\n };\n const addressesOfInvokedPrograms = new Set<Base58EncodedAddress>();\n for (const instruction of instructions) {\n upsert(addressMap, instruction.programAddress, entry => {\n addressesOfInvokedPrograms.add(instruction.programAddress);\n if (TYPE in entry) {\n if (isWritableRole(entry.role)) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and set as the fee payer. Program addresses may not pay fees.'\n );\n default:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and marked writable. Program addresses may not be writable.'\n );\n }\n }\n if (entry[TYPE] === AddressMapEntryType.STATIC) {\n return entry;\n }\n }\n return { [TYPE]: AddressMapEntryType.STATIC, role: AccountRole.READONLY };\n });\n let addressComparator: ReturnType<typeof getBase58EncodedAddressComparator>;\n if (!instruction.accounts) {\n continue;\n }\n for (const account of instruction.accounts) {\n upsert(addressMap, account.address, entry => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n address: _,\n ...accountMeta\n } = account;\n if (TYPE in entry) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // The fee payer already has the highest rank -- it is by definition\n // writable-signer. Return it, no matter how `account` is configured\n return entry as FeePayerAccountEntry;\n case AddressMapEntryType.LOOKUP_TABLE: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if ('lookupTableAddress' in accountMeta) {\n const shouldReplaceEntry =\n // Consider using the new LOOKUP_TABLE if its address is different...\n entry.lookupTableAddress !== accountMeta.lookupTableAddress &&\n // ...and sorts before the existing one.\n (addressComparator ||= getBase58EncodedAddressComparator())(\n accountMeta.lookupTableAddress,\n entry.lookupTableAddress\n ) < 0;\n if (shouldReplaceEntry) {\n return {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n ...accountMeta,\n role: nextRole,\n } as LookupTableAccountEntry;\n }\n } else if (isSignerRole(accountMeta.role)) {\n // Upgrade this LOOKUP_TABLE entry to a static entry if it must sign.\n return {\n [TYPE]: AddressMapEntryType.STATIC,\n role: nextRole,\n } as StaticAccountEntry;\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n return entry as LookupTableAccountEntry;\n }\n }\n case AddressMapEntryType.STATIC: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if (\n // Check to see if this address represents a program that is invoked\n // in this transaction.\n addressesOfInvokedPrograms.has(account.address)\n ) {\n if (isWritableRole(accountMeta.role)) {\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${account.address}\\`) which is both invoked and ` +\n 'marked writable. Program addresses may not be ' +\n 'writable.'\n );\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n } else if (\n 'lookupTableAddress' in accountMeta &&\n // Static accounts can be 'upgraded' to lookup table accounts as\n // long as they are not require to sign the transaction.\n !isSignerRole(entry.role)\n ) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n if (entry.role !== nextRole) {\n // The account's role ranks higher than the current entry's.\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n }\n }\n }\n }\n if ('lookupTableAddress' in accountMeta) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n };\n } else {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.STATIC,\n };\n }\n });\n }\n }\n return addressMap;\n}\n\nexport function getOrderedAccountsFromAddressMap(addressMap: AddressMap): OrderedAccounts {\n let addressComparator: ReturnType<typeof getBase58EncodedAddressComparator>;\n const orderedAccounts: (IAccountMeta | IAccountLookupMeta)[] = Object.entries(addressMap)\n .sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {\n // STEP 1: Rapid precedence check. Fee payer, then static addresses, then lookups.\n if (leftEntry[TYPE] !== rightEntry[TYPE]) {\n if (leftEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return 1;\n } else if (leftEntry[TYPE] === AddressMapEntryType.STATIC) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.STATIC) {\n return 1;\n }\n }\n // STEP 2: Sort by signer-writability.\n const leftIsSigner = isSignerRole(leftEntry.role);\n if (leftIsSigner !== isSignerRole(rightEntry.role)) {\n return leftIsSigner ? -1 : 1;\n }\n const leftIsWritable = isWritableRole(leftEntry.role);\n if (leftIsWritable !== isWritableRole(rightEntry.role)) {\n return leftIsWritable ? -1 : 1;\n }\n // STEP 3: Sort by address.\n addressComparator ||= getBase58EncodedAddressComparator();\n if (\n leftEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n rightEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress\n ) {\n return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);\n } else {\n return addressComparator(leftAddress, rightAddress);\n }\n })\n .map(([address, addressMeta]) => ({\n address: address as Base58EncodedAddress<typeof address>,\n ...addressMeta,\n }));\n return orderedAccounts as unknown as OrderedAccounts;\n}\n","import { Base58EncodedAddress, getBase58EncodedAddressComparator } from '@solana/addresses';\nimport { AccountRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype AddressTableLookup = Readonly<{\n lookupTableAddress: Base58EncodedAddress;\n readableIndices: readonly number[];\n writableIndices: readonly number[];\n}>;\n\nexport function getCompiledAddressTableLookups(orderedAccounts: OrderedAccounts): AddressTableLookup[] {\n const index: Record<\n Base58EncodedAddress,\n { readonly readableIndices: number[]; readonly writableIndices: number[] }\n > = {};\n for (const account of orderedAccounts) {\n if (!('lookupTableAddress' in account)) {\n continue;\n }\n const entry = (index[account.lookupTableAddress] ||= {\n readableIndices: [],\n writableIndices: [],\n });\n if (account.role === AccountRole.WRITABLE) {\n entry.writableIndices.push(account.addressIndex);\n } else {\n entry.readableIndices.push(account.addressIndex);\n }\n }\n return Object.keys(index)\n .sort(getBase58EncodedAddressComparator())\n .map(lookupTableAddress => ({\n lookupTableAddress: lookupTableAddress as Base58EncodedAddress,\n ...index[lookupTableAddress as unknown as Base58EncodedAddress],\n }));\n}\n","import { isSignerRole, isWritableRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype MessageHeader = Readonly<{\n numReadonlyNonSignerAccounts: number;\n numReadonlySignerAccounts: number;\n numSignerAccounts: number;\n}>;\n\nexport function getCompiledMessageHeader(orderedAccounts: OrderedAccounts): MessageHeader {\n let numReadonlyNonSignerAccounts = 0;\n let numReadonlySignerAccounts = 0;\n let numSignerAccounts = 0;\n for (const account of orderedAccounts) {\n if ('lookupTableAddress' in account) {\n break;\n }\n const accountIsWritable = isWritableRole(account.role);\n if (isSignerRole(account.role)) {\n numSignerAccounts++;\n if (!accountIsWritable) {\n numReadonlySignerAccounts++;\n }\n } else if (!accountIsWritable) {\n numReadonlyNonSignerAccounts++;\n }\n }\n return {\n numReadonlyNonSignerAccounts,\n numReadonlySignerAccounts,\n numSignerAccounts,\n };\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\nimport { IInstruction } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype CompiledInstruction = Readonly<{\n addressIndices?: number[];\n data?: Uint8Array;\n programAddressIndex: number;\n}>;\n\nfunction getAccountIndex(orderedAccounts: OrderedAccounts) {\n const out: Record<Base58EncodedAddress, number> = {};\n for (const [index, account] of orderedAccounts.entries()) {\n out[account.address] = index;\n }\n return out;\n}\n\nexport function getCompiledInstructions(\n instructions: readonly IInstruction[],\n orderedAccounts: OrderedAccounts\n): CompiledInstruction[] {\n const accountIndex = getAccountIndex(orderedAccounts);\n return instructions.map(({ accounts, data, programAddress }) => {\n return {\n programAddressIndex: accountIndex[programAddress],\n ...(accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null),\n ...(data ? { data } : null),\n };\n });\n}\n","import { IDurableNonceTransaction, ITransactionWithBlockhashLifetime } from './index';\n\nexport function getCompiledLifetimeToken(\n lifetimeConstraint: (ITransactionWithBlockhashLifetime | IDurableNonceTransaction)['lifetimeConstraint']\n): string {\n if ('nonce' in lifetimeConstraint) {\n return lifetimeConstraint.nonce;\n }\n return lifetimeConstraint.blockhash;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\n\nimport { OrderedAccounts } from './accounts';\n\nexport function getCompiledStaticAccounts(orderedAccounts: OrderedAccounts): Base58EncodedAddress[] {\n const firstLookupTableAccountIndex = orderedAccounts.findIndex(account => 'lookupTableAddress' in account);\n const orderedStaticAccounts =\n firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);\n return orderedStaticAccounts.map(({ address }) => address);\n}\n","import { getAddressMapFromInstructions, getOrderedAccountsFromAddressMap } from './accounts';\nimport { ITransactionWithBlockhashLifetime } from './blockhash';\nimport { getCompiledAddressTableLookups } from './compile-address-table-lookups';\nimport { getCompiledMessageHeader } from './compile-header';\nimport { getCompiledInstructions } from './compile-instructions';\nimport { getCompiledLifetimeToken } from './compile-lifetime-token';\nimport { getCompiledStaticAccounts } from './compile-static-accounts';\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithFeePayer } from './fee-payer';\nimport { BaseTransaction } from './types';\n\ntype BaseCompiledMessage = Readonly<{\n header: ReturnType<typeof getCompiledMessageHeader>;\n instructions: ReturnType<typeof getCompiledInstructions>;\n lifetimeToken: ReturnType<typeof getCompiledLifetimeToken>;\n staticAccounts: ReturnType<typeof getCompiledStaticAccounts>;\n}>;\n\ntype CompilableTransaction = BaseTransaction &\n ITransactionWithFeePayer &\n (ITransactionWithBlockhashLifetime | IDurableNonceTransaction);\n\nexport type CompiledMessage = LegacyCompiledMessage | VersionedCompiledMessage;\n\ntype LegacyCompiledMessage = BaseCompiledMessage &\n Readonly<{\n version: 'legacy';\n }>;\n\ntype VersionedCompiledMessage = BaseCompiledMessage &\n Readonly<{\n addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups>;\n version: number;\n }>;\n\nexport function compileMessage(\n transaction: CompilableTransaction & Readonly<{ version: 'legacy' }>\n): LegacyCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): VersionedCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): CompiledMessage {\n const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);\n const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);\n return {\n ...(transaction.version !== 'legacy'\n ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) }\n : null),\n header: getCompiledMessageHeader(orderedAccounts),\n instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),\n lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),\n staticAccounts: getCompiledStaticAccounts(orderedAccounts),\n version: transaction.version,\n };\n}\n","import {\n array,\n base58,\n mapSerializer,\n Serializer,\n shortU16,\n string,\n struct,\n StructToSerializerTuple,\n} from '@metaplex-foundation/umi-serializers';\nimport { getBase58EncodedAddressCodec } from '@solana/addresses';\n\nimport { CompiledMessage } from '../message';\nimport { getAddressTableLookupCodec } from './address-table-lookup';\nimport { getMessageHeaderCodec } from './header';\nimport { getInstructionCodec } from './instruction';\nimport { getTransactionVersionCodec } from './transaction-version';\nimport { getUnimplementedDecoder, getUnimplementedEncoder } from './unimplemented';\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'The wire format of a Solana transaction message' : '',\n fixedSize: null,\n maxSize: null,\n} as const;\n\nfunction deserialize(bytes: Uint8Array, offset = 0): [CompiledMessage, number] {\n const preludeAndOffset = struct(getPreludeStructSerializerTuple()).deserialize(bytes, offset);\n const [prelude, endOfPreludeOffset] = preludeAndOffset;\n if (prelude.version === 'legacy') {\n return preludeAndOffset;\n }\n const [addressTableLookups, finalOffset] = getAddressTableLookupsSerializer().deserialize(\n bytes,\n endOfPreludeOffset\n );\n return [\n {\n ...prelude,\n ...(addressTableLookups.length ? { addressTableLookups } : null),\n },\n finalOffset,\n ];\n}\n\nfunction serialize(compiledMessage: CompiledMessage) {\n if (compiledMessage.version === 'legacy') {\n return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);\n } else {\n return mapSerializer(\n struct([\n ...getPreludeStructSerializerTuple(),\n ['addressTableLookups', getAddressTableLookupsSerializer()],\n ] as StructToSerializerTuple<CompiledMessage, CompiledMessage>),\n (value: CompiledMessage) => {\n if (value.version === 'legacy') {\n return value;\n }\n return {\n ...value,\n addressTableLookups: value.addressTableLookups ?? [],\n } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n }\n ).serialize(compiledMessage);\n }\n}\n\nfunction getPreludeStructSerializerTuple(): StructToSerializerTuple<CompiledMessage, CompiledMessage> {\n return [\n ['version', getTransactionVersionCodec()],\n ['header', getMessageHeaderCodec()],\n [\n 'staticAccounts',\n array(getBase58EncodedAddressCodec(), {\n description: __DEV__ ? 'A compact-array of static account addresses belonging to this transaction' : '',\n size: shortU16(),\n }),\n ],\n [\n 'lifetimeToken',\n string({\n description: __DEV__\n ? 'A 32-byte token that specifies the lifetime of this transaction (eg. a ' +\n 'recent blockhash, or a durable nonce)'\n : '',\n encoding: base58,\n size: 32,\n }),\n ],\n [\n 'instructions',\n array(getInstructionCodec(), {\n description: __DEV__ ? 'A compact-array of instructions belonging to this transaction' : '',\n size: shortU16(),\n }),\n ],\n ];\n}\n\nfunction getAddressTableLookupsSerializer() {\n return array(getAddressTableLookupCodec(), {\n ...(__DEV__ ? { description: 'A compact array of address table lookups belonging to this transaction' } : null),\n size: shortU16(),\n });\n}\n\nexport function getCompiledMessageEncoder(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('CompiledMessage'),\n serialize,\n };\n}\n\nexport function getCompiledMessageDecoder(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize: getUnimplementedEncoder('CompiledMessage'),\n };\n}\n\nexport function getCompiledMessageCodec(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize,\n };\n}\n","import { array, Serializer, shortU16, struct, StructToSerializerTuple, u8 } from '@metaplex-foundation/umi-serializers';\nimport { getBase58EncodedAddressCodec } from '@solana/addresses';\n\nimport { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\n\ntype AddressTableLookup = ReturnType<typeof getCompiledAddressTableLookups>[number];\n\nexport function getAddressTableLookupCodec(): Serializer<AddressTableLookup> {\n return struct(\n [\n [\n 'lookupTableAddress',\n getBase58EncodedAddressCodec(\n __DEV__\n ? {\n description:\n 'The address of the address lookup table account from which ' +\n 'instruction addresses should be looked up',\n }\n : undefined\n ),\n ],\n [\n 'writableIndices',\n array(u8(), {\n ...(__DEV__\n ? {\n description:\n 'The indices of the accounts in the lookup table that should ' +\n 'be loaded as writeable',\n }\n : null),\n size: shortU16(),\n }),\n ],\n [\n 'readableIndices',\n array(u8(), {\n ...(__DEV__\n ? {\n description:\n 'The indices of the accounts in the lookup table that should ' +\n 'be loaded as read-only',\n }\n : undefined),\n size: shortU16(),\n }),\n ],\n ] as StructToSerializerTuple<AddressTableLookup, AddressTableLookup>,\n __DEV__\n ? {\n description:\n 'A pointer to the address of an address lookup table, along with the ' +\n 'readonly/writeable indices of the addresses that should be loaded from it',\n }\n : undefined\n );\n}\n","import { Serializer, struct, u8 } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledMessageHeader } from '../compile-header';\n\ntype MessageHeader = ReturnType<typeof getCompiledMessageHeader>;\n\nexport function getMessageHeaderCodec(): Serializer<MessageHeader> {\n return struct(\n [\n [\n 'numSignerAccounts',\n u8(\n __DEV__\n ? {\n description:\n 'The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction',\n }\n : undefined\n ),\n ],\n [\n 'numReadonlySignerAccounts',\n u8(\n __DEV__\n ? {\n description:\n 'The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable',\n }\n : undefined\n ),\n ],\n [\n 'numReadonlyNonSignerAccounts',\n u8(\n __DEV__\n ? {\n description:\n 'The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable',\n }\n : undefined\n ),\n ],\n ],\n __DEV__\n ? {\n description:\n 'The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses',\n }\n : undefined\n );\n}\n","import { array, bytes, mapSerializer, Serializer, shortU16, struct, u8 } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledInstructions } from '../compile-instructions';\n\ntype Instruction = ReturnType<typeof getCompiledInstructions>[number];\n\nexport function getInstructionCodec(): Serializer<Instruction> {\n return mapSerializer<Instruction, Required<Instruction>>(\n struct([\n [\n 'programAddressIndex',\n u8(\n __DEV__\n ? {\n description:\n 'The index of the program being called, according to the ' +\n 'well-ordered accounts list for this transaction',\n }\n : undefined\n ),\n ],\n [\n 'addressIndices',\n array(\n u8({\n description: __DEV__\n ? 'The index of an account, according to the well-ordered accounts ' +\n 'list for this transaction'\n : '',\n }),\n {\n description: __DEV__\n ? 'An optional list of account indices, according to the ' +\n 'well-ordered accounts list for this transaction, in the order in ' +\n 'which the program being called expects them'\n : '',\n size: shortU16(),\n }\n ),\n ],\n [\n 'data',\n bytes({\n description: __DEV__ ? 'An optional buffer of data passed to the instruction' : '',\n size: shortU16(),\n }),\n ],\n ]),\n (value: Instruction) => {\n if (value.addressIndices !== undefined && value.data !== undefined) {\n return value as Required<Instruction>;\n }\n return {\n ...value,\n addressIndices: value.addressIndices ?? [],\n data: value.data ?? new Uint8Array(0),\n } as Required<Instruction>;\n },\n (value: Required<Instruction>) => {\n if (value.addressIndices.length && value.data.byteLength) {\n return value;\n }\n const { addressIndices, data, ...rest } = value;\n return {\n ...rest,\n ...(addressIndices.length ? { addressIndices } : null),\n ...(data.byteLength ? { data } : null),\n };\n }\n );\n}\n","function getError(type: 'decoder' | 'encoder', name: string) {\n const functionSuffix = name + type[0].toUpperCase() + type.slice(1);\n return new Error(\n `No ${type} exists for ${name}. Use \\`get${functionSuffix}()\\` if you need a ${type}, and \\`get${name}Codec()\\` if you need to both encode and decode ${name}`\n );\n}\n\nexport function getUnimplementedDecoder(name: string): () => never {\n return () => {\n throw getError('decoder', name);\n };\n}\n\nexport function getUnimplementedEncoder(name: string): () => never {\n return () => {\n throw getError('encoder', name);\n };\n}\n","import { Serializer } from '@metaplex-foundation/umi-serializers';\n\nimport { TransactionVersion } from '../types';\nimport { getUnimplementedDecoder, getUnimplementedEncoder } from './unimplemented';\n\nconst VERSION_FLAG_MASK = 0x80;\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'A single byte that encodes the version of the transaction' : '',\n fixedSize: null,\n maxSize: 1,\n} as const;\n\nfunction deserialize(bytes: Uint8Array, offset = 0): [TransactionVersion, number] {\n const firstByte = bytes[offset];\n if ((firstByte & VERSION_FLAG_MASK) === 0) {\n // No version flag set; it's a legacy (unversioned) transaction.\n return ['legacy', offset];\n } else {\n const version = (firstByte ^ VERSION_FLAG_MASK) as TransactionVersion;\n return [version, offset + 1];\n }\n}\n\nfunction serialize(value: TransactionVersion): Uint8Array {\n if (value === 'legacy') {\n return new Uint8Array();\n }\n if (value < 0 || value > 127) {\n // TODO: Coded error.\n throw new Error(`Transaction version must be in the range [0, 127]. \\`${value}\\` given.`);\n }\n return new Uint8Array([value | VERSION_FLAG_MASK]);\n}\n\nexport function getTransactionVersionDecoder(): Serializer<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize: getUnimplementedEncoder('TransactionVersion'),\n };\n}\n\nexport function getTransactionVersionEncoder(): Serializer<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('TransactionVersion'),\n serialize,\n };\n}\n\nexport function getTransactionVersionCodec(): Serializer<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize,\n };\n}\n","import { array, bytes, Serializer, shortU16, struct } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledTransaction } from '../compile-transaction';\nimport { getCompiledMessageEncoder } from './message';\nimport { getUnimplementedDecoder } from './unimplemented';\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'The wire format of a Solana transaction' : '',\n fixedSize: null,\n maxSize: null,\n} as const;\n\ntype SerializableTransaction = Parameters<typeof getCompiledTransaction>[0];\n\nfunction serialize(transaction: SerializableTransaction) {\n const compiledTransaction = getCompiledTransaction(transaction);\n return struct([\n [\n 'signatures',\n array(bytes({ size: 64 }), {\n ...(__DEV__ ? { description: 'A compact array of 64-byte, base-64 encoded Ed25519 signatures' } : null),\n size: shortU16(),\n }),\n ],\n ['compiledMessage', getCompiledMessageEncoder()],\n ]).serialize(compiledTransaction);\n}\n\nexport function getTransactionEncoder(): Serializer<SerializableTransaction> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('CompiledMessage'),\n serialize,\n };\n}\n","import { Ed25519Signature } from '@solana/keys';\n\nimport { CompiledMessage, compileMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\n\ntype CompiledTransaction = Readonly<{\n compiledMessage: CompiledMessage;\n signatures: Ed25519Signature[];\n}>;\n\ntype CompilableTransaction = Parameters<typeof compileMessage>[0];\n\nexport function getCompiledTransaction(\n transaction: CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)\n): CompiledTransaction {\n const compiledMessage = compileMessage(transaction);\n let signatures;\n if ('signatures' in transaction) {\n signatures = [];\n for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {\n signatures[ii] =\n transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));\n }\n } else {\n signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));\n }\n return {\n compiledMessage,\n signatures,\n };\n}\n","import { getTransactionEncoder } from './serializers/transaction';\n\nexport type Base64EncodedWireTransaction = string & {\n readonly __base64EncodedWireTransaction: unique symbol;\n};\n\nexport function getBase64EncodedWireTransaction(\n transaction: Parameters<ReturnType<typeof getTransactionEncoder>['serialize']>[0]\n): Base64EncodedWireTransaction {\n const wireTransactionBytes = getTransactionEncoder().serialize(transaction);\n if (__NODEJS__) {\n return Buffer.from(wireTransactionBytes).toString('base64') as Base64EncodedWireTransaction;\n } else {\n return (btoa as Window['btoa'])(String.fromCharCode(...wireTransactionBytes)) as Base64EncodedWireTransaction;\n }\n}\n"]}
|