@solana/compat 2.0.0-experimental.ffeddf6 → 2.0.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -4
- package/dist/index.browser.cjs +88 -114
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +88 -114
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +88 -114
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +88 -114
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +88 -114
- package/dist/index.node.js.map +1 -1
- package/dist/types/address.d.ts +3 -3
- package/dist/types/address.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/keypair.d.ts.map +1 -1
- package/dist/types/transaction.d.ts +2 -2
- package/dist/types/transaction.d.ts.map +1 -1
- package/package.json +15 -37
- package/dist/index.development.js +0 -412
- package/dist/index.development.js.map +0 -1
- package/dist/index.production.min.js +0 -14
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
this.globalThis = this.globalThis || {};
|
|
2
|
-
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
// src/address.ts
|
|
6
|
-
function fromLegacyPublicKey(publicKey) {
|
|
7
|
-
return publicKey.toBase58();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// src/keypair.ts
|
|
11
|
-
function addPkcs8Header(bytes) {
|
|
12
|
-
return new Uint8Array([
|
|
13
|
-
/**
|
|
14
|
-
* PKCS#8 header
|
|
15
|
-
*/
|
|
16
|
-
48,
|
|
17
|
-
// ASN.1 sequence tag
|
|
18
|
-
46,
|
|
19
|
-
// Length of sequence (46 more bytes)
|
|
20
|
-
2,
|
|
21
|
-
// ASN.1 integer tag
|
|
22
|
-
1,
|
|
23
|
-
// Length of integer
|
|
24
|
-
0,
|
|
25
|
-
// Version number
|
|
26
|
-
48,
|
|
27
|
-
// ASN.1 sequence tag
|
|
28
|
-
5,
|
|
29
|
-
// Length of sequence
|
|
30
|
-
6,
|
|
31
|
-
// ASN.1 object identifier tag
|
|
32
|
-
3,
|
|
33
|
-
// Length of object identifier
|
|
34
|
-
// Edwards curve algorithms identifier https://oid-rep.orange-labs.fr/get/1.3.101.112
|
|
35
|
-
43,
|
|
36
|
-
// iso(1) / identified-organization(3) (The first node is multiplied by the decimal 40 and the result is added to the value of the second node)
|
|
37
|
-
101,
|
|
38
|
-
// thawte(101)
|
|
39
|
-
// Ed25519 identifier
|
|
40
|
-
112,
|
|
41
|
-
// id-Ed25519(112)
|
|
42
|
-
/**
|
|
43
|
-
* Private key payload
|
|
44
|
-
*/
|
|
45
|
-
4,
|
|
46
|
-
// ASN.1 octet string tag
|
|
47
|
-
34,
|
|
48
|
-
// String length (34 more bytes)
|
|
49
|
-
// Private key bytes as octet string
|
|
50
|
-
4,
|
|
51
|
-
// ASN.1 octet string tag
|
|
52
|
-
32,
|
|
53
|
-
// String length (32 bytes)
|
|
54
|
-
...bytes
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
async function fromLegacyKeypair(keypair, extractable) {
|
|
58
|
-
const publicKey = await crypto.subtle.importKey("raw", keypair.publicKey.toBytes(), "Ed25519", true, [
|
|
59
|
-
"verify"
|
|
60
|
-
]);
|
|
61
|
-
const privateKeyBytesPkcs8 = addPkcs8Header(keypair.secretKey.slice(0, 32));
|
|
62
|
-
const privateKey = await crypto.subtle.importKey(
|
|
63
|
-
"pkcs8",
|
|
64
|
-
privateKeyBytesPkcs8,
|
|
65
|
-
"Ed25519",
|
|
66
|
-
extractable ?? false,
|
|
67
|
-
["sign"]
|
|
68
|
-
);
|
|
69
|
-
return {
|
|
70
|
-
privateKey,
|
|
71
|
-
publicKey
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ../codecs-strings/dist/index.browser.js
|
|
76
|
-
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
77
|
-
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
78
|
-
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
var getBaseXEncoder = (alphabet4) => {
|
|
82
|
-
const base = alphabet4.length;
|
|
83
|
-
const baseBigInt = BigInt(base);
|
|
84
|
-
return {
|
|
85
|
-
description: `base${base}`,
|
|
86
|
-
encode(value) {
|
|
87
|
-
assertValidBaseString(alphabet4, value);
|
|
88
|
-
if (value === "")
|
|
89
|
-
return new Uint8Array();
|
|
90
|
-
const chars = [...value];
|
|
91
|
-
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
92
|
-
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
93
|
-
const leadingZeroes = Array(trailIndex).fill(0);
|
|
94
|
-
if (trailIndex === chars.length)
|
|
95
|
-
return Uint8Array.from(leadingZeroes);
|
|
96
|
-
const tailChars = chars.slice(trailIndex);
|
|
97
|
-
let base10Number = 0n;
|
|
98
|
-
let baseXPower = 1n;
|
|
99
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
100
|
-
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
101
|
-
baseXPower *= baseBigInt;
|
|
102
|
-
}
|
|
103
|
-
const tailBytes = [];
|
|
104
|
-
while (base10Number > 0n) {
|
|
105
|
-
tailBytes.unshift(Number(base10Number % 256n));
|
|
106
|
-
base10Number /= 256n;
|
|
107
|
-
}
|
|
108
|
-
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
109
|
-
},
|
|
110
|
-
fixedSize: null,
|
|
111
|
-
maxSize: null
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
115
|
-
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
116
|
-
|
|
117
|
-
// ../addresses/dist/index.browser.js
|
|
118
|
-
var memoizedBase58Encoder;
|
|
119
|
-
function getMemoizedBase58Encoder() {
|
|
120
|
-
if (!memoizedBase58Encoder)
|
|
121
|
-
memoizedBase58Encoder = getBase58Encoder();
|
|
122
|
-
return memoizedBase58Encoder;
|
|
123
|
-
}
|
|
124
|
-
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
125
|
-
try {
|
|
126
|
-
if (
|
|
127
|
-
// Lowest address (32 bytes of zeroes)
|
|
128
|
-
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
129
|
-
putativeBase58EncodedAddress.length > 44
|
|
130
|
-
) {
|
|
131
|
-
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
132
|
-
}
|
|
133
|
-
const base58Encoder = getMemoizedBase58Encoder();
|
|
134
|
-
const bytes = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
135
|
-
const numBytes = bytes.byteLength;
|
|
136
|
-
if (numBytes !== 32) {
|
|
137
|
-
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
138
|
-
}
|
|
139
|
-
} catch (e2) {
|
|
140
|
-
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
141
|
-
cause: e2
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ../functional/dist/index.browser.js
|
|
147
|
-
function pipe(init, ...fns) {
|
|
148
|
-
return fns.reduce((acc, fn) => fn(acc), init);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// ../instructions/dist/index.browser.js
|
|
152
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
153
|
-
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
154
|
-
3] = "WRITABLE_SIGNER";
|
|
155
|
-
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
156
|
-
2] = "READONLY_SIGNER";
|
|
157
|
-
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
158
|
-
1] = "WRITABLE";
|
|
159
|
-
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
160
|
-
0] = "READONLY";
|
|
161
|
-
return AccountRole22;
|
|
162
|
-
})(AccountRole || {});
|
|
163
|
-
|
|
164
|
-
// ../transactions/dist/index.browser.js
|
|
165
|
-
function getUnsignedTransaction(transaction) {
|
|
166
|
-
if ("signatures" in transaction) {
|
|
167
|
-
const {
|
|
168
|
-
signatures: _,
|
|
169
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
170
|
-
...unsignedTransaction
|
|
171
|
-
} = transaction;
|
|
172
|
-
return unsignedTransaction;
|
|
173
|
-
} else {
|
|
174
|
-
return transaction;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
178
|
-
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
179
|
-
return transaction;
|
|
180
|
-
}
|
|
181
|
-
const out = {
|
|
182
|
-
...getUnsignedTransaction(transaction),
|
|
183
|
-
lifetimeConstraint: blockhashLifetimeConstraint
|
|
184
|
-
};
|
|
185
|
-
Object.freeze(out);
|
|
186
|
-
return out;
|
|
187
|
-
}
|
|
188
|
-
function createTransaction({
|
|
189
|
-
version
|
|
190
|
-
}) {
|
|
191
|
-
const out = {
|
|
192
|
-
instructions: [],
|
|
193
|
-
version
|
|
194
|
-
};
|
|
195
|
-
Object.freeze(out);
|
|
196
|
-
return out;
|
|
197
|
-
}
|
|
198
|
-
var AccountRole2 = /* @__PURE__ */ ((AccountRole22) => {
|
|
199
|
-
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
200
|
-
3] = "WRITABLE_SIGNER";
|
|
201
|
-
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
202
|
-
2] = "READONLY_SIGNER";
|
|
203
|
-
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
204
|
-
1] = "WRITABLE";
|
|
205
|
-
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
206
|
-
0] = "READONLY";
|
|
207
|
-
return AccountRole22;
|
|
208
|
-
})(AccountRole2 || {});
|
|
209
|
-
function isSignerRole(role) {
|
|
210
|
-
return role >= 2;
|
|
211
|
-
}
|
|
212
|
-
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
213
|
-
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
214
|
-
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
215
|
-
return {
|
|
216
|
-
accounts: [
|
|
217
|
-
{ address: nonceAccountAddress, role: AccountRole2.WRITABLE },
|
|
218
|
-
{
|
|
219
|
-
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
220
|
-
role: AccountRole2.READONLY
|
|
221
|
-
},
|
|
222
|
-
{ address: nonceAuthorityAddress, role: AccountRole2.READONLY_SIGNER }
|
|
223
|
-
],
|
|
224
|
-
data: new Uint8Array([4, 0, 0, 0]),
|
|
225
|
-
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
function isAdvanceNonceAccountInstruction(instruction) {
|
|
229
|
-
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
230
|
-
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
231
|
-
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
232
|
-
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
|
|
233
|
-
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
|
|
234
|
-
instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
|
|
235
|
-
}
|
|
236
|
-
function isAdvanceNonceAccountInstructionData(data) {
|
|
237
|
-
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
238
|
-
}
|
|
239
|
-
function isDurableNonceTransaction(transaction) {
|
|
240
|
-
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
241
|
-
}
|
|
242
|
-
function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
|
|
243
|
-
return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
|
|
244
|
-
}
|
|
245
|
-
function setTransactionLifetimeUsingDurableNonce({
|
|
246
|
-
nonce,
|
|
247
|
-
nonceAccountAddress,
|
|
248
|
-
nonceAuthorityAddress
|
|
249
|
-
}, transaction) {
|
|
250
|
-
let newInstructions;
|
|
251
|
-
const firstInstruction = transaction.instructions[0];
|
|
252
|
-
if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
253
|
-
if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
|
|
254
|
-
if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
|
|
255
|
-
return transaction;
|
|
256
|
-
} else {
|
|
257
|
-
newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
newInstructions = [
|
|
261
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
262
|
-
...transaction.instructions.slice(1)
|
|
263
|
-
];
|
|
264
|
-
}
|
|
265
|
-
} else {
|
|
266
|
-
newInstructions = [
|
|
267
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
268
|
-
...transaction.instructions
|
|
269
|
-
];
|
|
270
|
-
}
|
|
271
|
-
const out = {
|
|
272
|
-
...getUnsignedTransaction(transaction),
|
|
273
|
-
instructions: newInstructions,
|
|
274
|
-
lifetimeConstraint: {
|
|
275
|
-
nonce
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
Object.freeze(out);
|
|
279
|
-
return out;
|
|
280
|
-
}
|
|
281
|
-
function setTransactionFeePayer(feePayer, transaction) {
|
|
282
|
-
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
283
|
-
return transaction;
|
|
284
|
-
}
|
|
285
|
-
const out = {
|
|
286
|
-
...getUnsignedTransaction(transaction),
|
|
287
|
-
feePayer
|
|
288
|
-
};
|
|
289
|
-
Object.freeze(out);
|
|
290
|
-
return out;
|
|
291
|
-
}
|
|
292
|
-
function appendTransactionInstruction(instruction, transaction) {
|
|
293
|
-
const out = {
|
|
294
|
-
...getUnsignedTransaction(transaction),
|
|
295
|
-
instructions: [...transaction.instructions, instruction]
|
|
296
|
-
};
|
|
297
|
-
Object.freeze(out);
|
|
298
|
-
return out;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/transaction.ts
|
|
302
|
-
function convertAccount(message, accountKeys, accountIndex) {
|
|
303
|
-
const accountPublicKey = accountKeys.get(accountIndex);
|
|
304
|
-
if (!accountPublicKey) {
|
|
305
|
-
throw new Error(`Could not find account address at index ${accountIndex}`);
|
|
306
|
-
}
|
|
307
|
-
const isSigner = message.isAccountSigner(accountIndex);
|
|
308
|
-
const isWritable = message.isAccountWritable(accountIndex);
|
|
309
|
-
const role = isSigner ? isWritable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER : isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
310
|
-
return {
|
|
311
|
-
address: accountPublicKey.toBase58(),
|
|
312
|
-
role
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
function convertInstruction(message, accountKeys, instruction) {
|
|
316
|
-
const programAddressPublicKey = accountKeys.get(instruction.programIdIndex);
|
|
317
|
-
if (!programAddressPublicKey) {
|
|
318
|
-
throw new Error(`Could not find program address at index ${instruction.programIdIndex}`);
|
|
319
|
-
}
|
|
320
|
-
const accounts = instruction.accountKeyIndexes.map(
|
|
321
|
-
(accountIndex) => convertAccount(message, accountKeys, accountIndex)
|
|
322
|
-
);
|
|
323
|
-
return {
|
|
324
|
-
programAddress: programAddressPublicKey.toBase58(),
|
|
325
|
-
...accounts.length ? { accounts } : {},
|
|
326
|
-
...instruction.data.length ? { data: instruction.data } : {}
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function convertSignatures(transaction, staticAccountKeys) {
|
|
330
|
-
return transaction.signatures.reduce((acc, sig, index) => {
|
|
331
|
-
const allZeros = sig.every((byte) => byte === 0);
|
|
332
|
-
if (allZeros)
|
|
333
|
-
return acc;
|
|
334
|
-
const address = staticAccountKeys[index].toBase58();
|
|
335
|
-
return { ...acc, [address]: sig };
|
|
336
|
-
}, {});
|
|
337
|
-
}
|
|
338
|
-
function fromVersionedTransactionWithBlockhash(transaction, lastValidBlockHeight) {
|
|
339
|
-
if (transaction.message.addressTableLookups.length > 0) {
|
|
340
|
-
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
341
|
-
}
|
|
342
|
-
const accountKeys = transaction.message.getAccountKeys();
|
|
343
|
-
const feePayer = accountKeys.staticAccountKeys[0];
|
|
344
|
-
if (!feePayer)
|
|
345
|
-
throw new Error("No fee payer set in VersionedTransaction");
|
|
346
|
-
const blockhashLifetime = {
|
|
347
|
-
blockhash: transaction.message.recentBlockhash,
|
|
348
|
-
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
349
|
-
// U64 MAX
|
|
350
|
-
};
|
|
351
|
-
const instructions = transaction.message.compiledInstructions.map(
|
|
352
|
-
(instruction) => convertInstruction(transaction.message, accountKeys, instruction)
|
|
353
|
-
);
|
|
354
|
-
const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);
|
|
355
|
-
return pipe(
|
|
356
|
-
createTransaction({ version: transaction.version }),
|
|
357
|
-
(tx) => setTransactionFeePayer(feePayer.toBase58(), tx),
|
|
358
|
-
(tx) => setTransactionLifetimeUsingBlockhash(blockhashLifetime, tx),
|
|
359
|
-
(tx) => instructions.reduce((acc, instruction) => {
|
|
360
|
-
return appendTransactionInstruction(instruction, acc);
|
|
361
|
-
}, tx),
|
|
362
|
-
(tx) => transaction.signatures.length ? { ...tx, signatures } : tx
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
function fromVersionedTransactionWithDurableNonce(transaction) {
|
|
366
|
-
if (transaction.message.addressTableLookups.length > 0) {
|
|
367
|
-
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
368
|
-
}
|
|
369
|
-
const accountKeys = transaction.message.getAccountKeys();
|
|
370
|
-
const feePayer = accountKeys.staticAccountKeys[0];
|
|
371
|
-
if (!feePayer)
|
|
372
|
-
throw new Error("No fee payer set in VersionedTransaction");
|
|
373
|
-
const instructions = transaction.message.compiledInstructions.map(
|
|
374
|
-
(instruction) => convertInstruction(transaction.message, accountKeys, instruction)
|
|
375
|
-
);
|
|
376
|
-
if (instructions.length === 0) {
|
|
377
|
-
throw new Error("transaction with no instructions cannot be durable nonce transaction");
|
|
378
|
-
}
|
|
379
|
-
if (!isAdvanceNonceAccountInstruction(instructions[0])) {
|
|
380
|
-
throw new Error("transaction first instruction is not advance nonce account instruction");
|
|
381
|
-
}
|
|
382
|
-
const nonceAccountAddress = instructions[0].accounts[0].address;
|
|
383
|
-
assertIsAddress(nonceAccountAddress);
|
|
384
|
-
const nonceAuthorityAddress = instructions[0].accounts[2].address;
|
|
385
|
-
assertIsAddress(nonceAuthorityAddress);
|
|
386
|
-
const durableNonceLifetime = {
|
|
387
|
-
nonce: transaction.message.recentBlockhash,
|
|
388
|
-
nonceAccountAddress,
|
|
389
|
-
nonceAuthorityAddress
|
|
390
|
-
};
|
|
391
|
-
const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);
|
|
392
|
-
return pipe(
|
|
393
|
-
createTransaction({ version: transaction.version }),
|
|
394
|
-
(tx) => setTransactionFeePayer(feePayer.toBase58(), tx),
|
|
395
|
-
(tx) => setTransactionLifetimeUsingDurableNonce(durableNonceLifetime, tx),
|
|
396
|
-
(tx) => instructions.slice(1).reduce((acc, instruction) => {
|
|
397
|
-
return appendTransactionInstruction(instruction, acc);
|
|
398
|
-
}, tx),
|
|
399
|
-
(tx) => transaction.signatures.length ? { ...tx, signatures } : tx
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
exports.fromLegacyKeypair = fromLegacyKeypair;
|
|
404
|
-
exports.fromLegacyPublicKey = fromLegacyPublicKey;
|
|
405
|
-
exports.fromVersionedTransactionWithBlockhash = fromVersionedTransactionWithBlockhash;
|
|
406
|
-
exports.fromVersionedTransactionWithDurableNonce = fromVersionedTransactionWithDurableNonce;
|
|
407
|
-
|
|
408
|
-
return exports;
|
|
409
|
-
|
|
410
|
-
})({});
|
|
411
|
-
//# sourceMappingURL=out.js.map
|
|
412
|
-
//# sourceMappingURL=index.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/address.ts","../src/keypair.ts","../../codecs-strings/src/assertions.ts","../../codecs-strings/src/baseX.ts","../../codecs-strings/src/base16.ts","../../codecs-strings/src/base64.ts","../../addresses/src/address.ts","../../functional/src/pipe.ts","../../instructions/src/roles.ts","../../transactions/dist/index.browser.js","../src/transaction.ts"],"names":["alphabet","e","AccountRole","AccountRole2"],"mappings":";AAQO,SAAS,oBAA6C,WAAsD;AAC/G,SAAO,UAAU,SAAS;AAC9B;;;ACRA,SAAS,eAAe,OAA+B;AAEnD,SAAO,IAAI,WAAW;AAAA;AAAA;AAAA;AAAA,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I,MAAM,wEAAwE;AAAA,EAC5F;AAGA,QAAM,sBAAsB,aAAa,CAAC,EAAE,SAAU,CAAC,EAAE;AACzD,kBAAgB,mBAAmB;AAEnC,QAAM,wBAAwB,aAAa,CAAC,EAAE,SAAU,CAAC,EAAE;AAC3D,kBAAgB,qBAAqB;AAErC,QAAM,uBAAuB;AAAA,IACzB,OAAO,YAAY,QAAQ;AAAA,IAC3B;AAAA,IACA;AAAA,EACJ;AAEA,QAAM,aAAa,kBAAkB,aAAa,YAAY,iBAAiB;AAE/E,SAAO;AAAA,IACH,kBAAkB,EAAE,SAAS,YAAY,QAAQ,CAAC;AAAA,IAClD,QAAM,uBAAuB,SAAS,SAAS,GAA2B,EAAE;AAAA,IAC5E,QAAM,wCAAwC,sBAAsB,EAAE;AAAA,IACtE,QACI,aAAa,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,gBAAgB;AAC/C,aAAO,6BAA6B,aAAa,GAAG;AAAA,IACxD,GAAG,EAAE;AAAA,IACT,QAAO,YAAY,WAAW,SAAS,EAAE,GAAG,IAAI,WAAW,IAAI;AAAA,EACnE;AACJ","sourcesContent":["import { Base58EncodedAddress } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns A Base58EncodedAddress\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Base58EncodedAddress<TAddress> {\n return publicKey.toBase58() as Base58EncodedAddress<TAddress>;\n}\n","import { Keypair } from '@solana/web3.js';\n\nfunction addPkcs8Header(bytes: Uint8Array): Uint8Array {\n // prettier-ignore\n return new Uint8Array([\n /**\n * PKCS#8 header\n */\n 0x30, // ASN.1 sequence tag\n 0x2e, // Length of sequence (46 more bytes)\n\n 0x02, // ASN.1 integer tag\n 0x01, // Length of integer\n 0x00, // Version number\n\n 0x30, // ASN.1 sequence tag\n 0x05, // Length of sequence\n 0x06, // ASN.1 object identifier tag\n 0x03, // Length of object identifier\n // Edwards curve algorithms identifier https://oid-rep.orange-labs.fr/get/1.3.101.112\n 0x2b, // iso(1) / identified-organization(3) (The first node is multiplied by the decimal 40 and the result is added to the value of the second node)\n 0x65, // thawte(101)\n // Ed25519 identifier\n 0x70, // id-Ed25519(112)\n\n /**\n * Private key payload\n */\n 0x04, // ASN.1 octet string tag\n 0x22, // String length (34 more bytes)\n\n // Private key bytes as octet string\n 0x04, // ASN.1 octet string tag\n 0x20, // String length (32 bytes)\n\n ...bytes\n ]);\n}\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const publicKey: CryptoKey = await crypto.subtle.importKey('raw', keypair.publicKey.toBytes(), 'Ed25519', true, [\n 'verify',\n ]);\n const privateKeyBytesPkcs8 = addPkcs8Header(keypair.secretKey.slice(0, 32));\n const privateKey: CryptoKey = await crypto.subtle.importKey(\n 'pkcs8',\n privateKeyBytesPkcs8,\n 'Ed25519',\n extractable ?? false,\n ['sign']\n );\n return {\n privateKey,\n publicKey,\n } as CryptoKeyPair;\n}\n","/**\n * Asserts that a given string matches a given alphabet.\n */\nexport function assertValidBaseString(alphabet: string, testValue: string, givenValue = testValue) {\n if (!testValue.match(new RegExp(`^[${alphabet}]*$`))) {\n // TODO: Coded error.\n throw new Error(`Expected a string of base ${alphabet.length}, got [${givenValue}].`);\n }\n}\n","import { Codec, combineCodec, Decoder, Encoder } from '@solana/codecs-core';\n\nimport { assertValidBaseString } from './assertions';\n\n/**\n * Encodes a string using a custom alphabet by dividing\n * by the base and handling leading zeroes.\n * @see {@link getBaseXCodec} for a more detailed description.\n */\nexport const getBaseXEncoder = (alphabet: string): Encoder<string> => {\n const base = alphabet.length;\n const baseBigInt = BigInt(base);\n return {\n description: `base${base}`,\n encode(value: string): Uint8Array {\n // Check if the value is valid.\n assertValidBaseString(alphabet, value);\n if (value === '') return new Uint8Array();\n\n // Handle leading zeroes.\n const chars = [...value];\n let trailIndex = chars.findIndex(c => c !== alphabet[0]);\n trailIndex = trailIndex === -1 ? chars.length : trailIndex;\n const leadingZeroes = Array(trailIndex).fill(0);\n if (trailIndex === chars.length) return Uint8Array.from(leadingZeroes);\n\n // From baseX to base10.\n const tailChars = chars.slice(trailIndex);\n let base10Number = 0n;\n let baseXPower = 1n;\n for (let i = tailChars.length - 1; i >= 0; i -= 1) {\n base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));\n baseXPower *= baseBigInt;\n }\n\n // From base10 to bytes.\n const tailBytes = [];\n while (base10Number > 0n) {\n tailBytes.unshift(Number(base10Number % 256n));\n base10Number /= 256n;\n }\n return Uint8Array.from(leadingZeroes.concat(tailBytes));\n },\n fixedSize: null,\n maxSize: null,\n };\n};\n\n/**\n * Decodes a string using a custom alphabet by dividing\n * by the base and handling leading zeroes.\n * @see {@link getBaseXCodec} for a more detailed description.\n */\nexport const getBaseXDecoder = (alphabet: string): Decoder<string> => {\n const base = alphabet.length;\n const baseBigInt = BigInt(base);\n return {\n decode(rawBytes, offset = 0): [string, number] {\n const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);\n if (bytes.length === 0) return ['', 0];\n\n // Handle leading zeroes.\n let trailIndex = bytes.findIndex(n => n !== 0);\n trailIndex = trailIndex === -1 ? bytes.length : trailIndex;\n const leadingZeroes = alphabet[0].repeat(trailIndex);\n if (trailIndex === bytes.length) return [leadingZeroes, rawBytes.length];\n\n // From bytes to base10.\n let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);\n\n // From base10 to baseX.\n const tailChars = [];\n while (base10Number > 0n) {\n tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);\n base10Number /= baseBigInt;\n }\n\n return [leadingZeroes + tailChars.join(''), rawBytes.length];\n },\n description: `base${base}`,\n fixedSize: null,\n maxSize: null,\n };\n};\n\n/**\n * A string codec that requires a custom alphabet and uses\n * the length of that alphabet as the base. It then divides\n * the input by the base as many times as necessary to get\n * the output. It also supports leading zeroes by using the\n * first character of the alphabet as the zero character.\n *\n * This can be used to create codecs such as base10 or base58.\n */\nexport const getBaseXCodec = (alphabet: string): Codec<string> =>\n combineCodec(getBaseXEncoder(alphabet), getBaseXDecoder(alphabet));\n","import { Codec, combineCodec, Decoder, Encoder } from '@solana/codecs-core';\n\nimport { assertValidBaseString } from './assertions';\n\n/** Encodes strings in base16. */\nexport const getBase16Encoder = (): Encoder<string> => ({\n description: 'base16',\n encode(value: string) {\n const lowercaseValue = value.toLowerCase();\n assertValidBaseString('0123456789abcdef', lowercaseValue, value);\n const matches = lowercaseValue.match(/.{1,2}/g);\n return Uint8Array.from(matches ? matches.map((byte: string) => parseInt(byte, 16)) : []);\n },\n fixedSize: null,\n maxSize: null,\n});\n\n/** Decodes strings in base16. */\nexport const getBase16Decoder = (): Decoder<string> => ({\n decode(bytes, offset = 0) {\n const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');\n return [value, bytes.length];\n },\n description: 'base16',\n fixedSize: null,\n maxSize: null,\n});\n\n/** Encodes and decodes strings in base16. */\nexport const getBase16Codec = (): Codec<string> => combineCodec(getBase16Encoder(), getBase16Decoder());\n","import { combineCodec, Decoder, Encoder, mapDecoder, mapEncoder } from '@solana/codecs-core';\n\nimport { assertValidBaseString } from './assertions';\nimport { getBaseXResliceDecoder, getBaseXResliceEncoder } from './baseX-reslice';\n\nconst alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n/** Encodes strings in base64. */\nexport const getBase64Encoder = (): Encoder<string> => {\n if (__BROWSER__) {\n return {\n description: `base64`,\n encode(value: string): Uint8Array {\n try {\n const bytes = (atob as Window['atob'])(value)\n .split('')\n .map(c => c.charCodeAt(0));\n return new Uint8Array(bytes);\n } catch (e) {\n // TODO: Coded error.\n throw new Error(`Expected a string of base 64, got [${value}].`);\n }\n },\n fixedSize: null,\n maxSize: null,\n };\n }\n\n if (__NODEJS__) {\n return {\n description: `base64`,\n encode(value: string): Uint8Array {\n assertValidBaseString(alphabet, value.replace(/=/g, ''));\n return new Uint8Array(Buffer.from(value, 'base64'));\n },\n fixedSize: null,\n maxSize: null,\n };\n }\n\n return mapEncoder(getBaseXResliceEncoder(alphabet, 6), (value: string): string => value.replace(/=/g, ''));\n};\n\n/** Decodes strings in base64. */\nexport const getBase64Decoder = (): Decoder<string> => {\n if (__BROWSER__) {\n return {\n decode(bytes, offset = 0) {\n const slice = bytes.slice(offset);\n const value = (btoa as Window['btoa'])(String.fromCharCode(...slice));\n return [value, bytes.length];\n },\n description: `base64`,\n fixedSize: null,\n maxSize: null,\n };\n }\n\n if (__NODEJS__) {\n return {\n decode: (bytes, offset = 0) => [Buffer.from(bytes, offset).toString('base64'), bytes.length],\n description: `base64`,\n fixedSize: null,\n maxSize: null,\n };\n }\n\n return mapDecoder(getBaseXResliceDecoder(alphabet, 6), (value: string): string =>\n value.padEnd(Math.ceil(value.length / 4) * 4, '=')\n );\n};\n\n/** Encodes and decodes strings in base64. */\nexport const getBase64Codec = () => combineCodec(getBase64Encoder(), getBase64Decoder());\n","import { Codec, combineCodec, Decoder, Encoder, mapEncoder } from '@solana/codecs-core';\nimport { getBase58Decoder, getBase58Encoder, getStringDecoder, getStringEncoder } from '@solana/codecs-strings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __brand: unique symbol;\n};\n\nlet memoizedBase58Encoder: Encoder<string> | undefined;\nlet memoizedBase58Decoder: Decoder<string> | undefined;\n\nfunction getMemoizedBase58Encoder(): Encoder<string> {\n if (!memoizedBase58Encoder) memoizedBase58Encoder = getBase58Encoder();\n return memoizedBase58Encoder;\n}\n\nfunction getMemoizedBase58Decoder(): Decoder<string> {\n if (!memoizedBase58Decoder) memoizedBase58Decoder = getBase58Decoder();\n return memoizedBase58Decoder;\n}\n\nexport function isAddress(\n putativeBase58EncodedAddress: string\n): putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n return false;\n }\n // Slow-path; actually attempt to decode the input string.\n const base58Encoder = getMemoizedBase58Encoder();\n const bytes = base58Encoder.encode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n return false;\n }\n return true;\n}\n\nexport function assertIsAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.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 base58Encoder = getMemoizedBase58Encoder();\n const bytes = base58Encoder.encode(putativeBase58EncodedAddress);\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(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function address<TAddress extends string = string>(\n putativeBase58EncodedAddress: TAddress\n): Base58EncodedAddress<TAddress> {\n assertIsAddress(putativeBase58EncodedAddress);\n return putativeBase58EncodedAddress as Base58EncodedAddress<TAddress>;\n}\n\nexport function getAddressEncoder(config?: Readonly<{ description: string }>): Encoder<Base58EncodedAddress> {\n return mapEncoder(\n getStringEncoder({\n description: config?.description ?? 'Base58EncodedAddress',\n encoding: getMemoizedBase58Encoder(),\n size: 32,\n }),\n putativeAddress => address(putativeAddress)\n );\n}\n\nexport function getAddressDecoder(config?: Readonly<{ description: string }>): Decoder<Base58EncodedAddress> {\n return getStringDecoder({\n description: config?.description ?? 'Base58EncodedAddress',\n encoding: getMemoizedBase58Decoder(),\n size: 32,\n }) as Decoder<Base58EncodedAddress>;\n}\n\nexport function getAddressCodec(config?: Readonly<{ description: string }>): Codec<Base58EncodedAddress> {\n return combineCodec(getAddressEncoder(config), getAddressDecoder(config));\n}\n\nexport function getAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n","/**\n * General pipe function.\n * Provide an initial value and a list of functions to pipe it through.\n *\n * Following common implementations of pipe functions that use TypeScript,\n * this function supports a maximum arity of 10 for type safety.\n * @see https://github.com/ramda/ramda/blob/master/source/pipe.js\n * @see https://github.com/darky/rocket-pipes/blob/master/index.ts\n *\n * Note you can use nested pipes to extend this limitation, like so:\n * ```typescript\n * const myValue = pipe(\n * pipe(\n * 1,\n * (x) => x + 1,\n * (x) => x * 2,\n * (x) => x - 1,\n * ),\n * (y) => y / 3,\n * (y) => y + 1,\n * );\n * ```\n * @param init The initial value\n * @param fns Any number of functions to pipe the value through\n * @returns The final value with all functions applied\n */\nexport function pipe<TInitial>(init: TInitial): TInitial;\nexport function pipe<TInitial, R1>(init: TInitial, init_r1: (init: TInitial) => R1): R1;\nexport function pipe<TInitial, R1, R2>(init: TInitial, init_r1: (init: TInitial) => R1, r1_r2: (r1: R1) => R2): R2;\nexport function pipe<TInitial, R1, R2, R3>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3\n): R3;\nexport function pipe<TInitial, R1, R2, R3, R4>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4\n): R4;\nexport function pipe<TInitial, R1, R2, R3, R4, R5>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5\n): R5;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6\n): R6;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7\n): R7;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7, R8>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7,\n r7_r8: (r7: R7) => R8\n): R8;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7, R8, R9>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7,\n r7_r8: (r7: R7) => R8,\n r8_r9: (r8: R8) => R9\n): R9;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7,\n r7_r8: (r7: R7) => R8,\n r8_r9: (r8: R8) => R9,\n r9_r10: (r9: R9) => R10\n): R10;\nexport function pipe<TInitial>(init: TInitial, ...fns: CallableFunction[]) {\n return fns.reduce((acc, fn) => fn(acc), init);\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 { getBase58Encoder, getBase58Decoder, getStringEncoder, getStringDecoder } from '@solana/codecs-strings';\nimport { mapEncoder, mapDecoder, combineCodec } from '@solana/codecs-core';\nimport { getStructEncoder, getArrayEncoder, getBytesEncoder, getStructDecoder, getArrayDecoder, getBytesDecoder } from '@solana/codecs-data-structures';\nimport { getShortU16Encoder, getShortU16Decoder, getU8Encoder, getU8Decoder } from '@solana/codecs-numbers';\nimport { getAddressFromPublicKey, getAddressComparator, assertIsAddress, getAddressEncoder, getAddressDecoder } from '@solana/addresses';\nimport { pipe } from '@solana/functional';\nimport { signBytes } from '@solana/keys';\n\n// ../build-scripts/env-shim.ts\nvar __DEV__ = /* @__PURE__ */ (() => process[\"env\"].NODE_ENV === \"development\")();\n\n// src/unsigned-transaction.ts\nfunction getUnsignedTransaction(transaction) {\n if (\"signatures\" in transaction) {\n const {\n signatures: _,\n // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n return unsignedTransaction;\n } else {\n return transaction;\n }\n}\n\n// src/blockhash.ts\nvar base58Encoder;\nfunction assertIsBlockhash(putativeBlockhash) {\n if (!base58Encoder)\n base58Encoder = getBase58Encoder();\n try {\n if (\n // Lowest value (32 bytes of zeroes)\n putativeBlockhash.length < 32 || // 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 const bytes = base58Encoder.encode(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}\nfunction setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {\n if (\"lifetimeConstraint\" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n lifetimeConstraint: blockhashLifetimeConstraint\n };\n Object.freeze(out);\n return out;\n}\n\n// src/create-transaction.ts\nfunction createTransaction({\n version\n}) {\n const out = {\n instructions: [],\n version\n };\n Object.freeze(out);\n return out;\n}\n\n// ../instructions/dist/index.browser.js\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_WRITABLE_BITMASK = 1;\nfunction isSignerRole(role) {\n return role >= 2;\n}\nfunction isWritableRole(role) {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\nfunction mergeRoles(roleA, roleB) {\n return roleA | roleB;\n}\n\n// src/durable-nonce.ts\nvar RECENT_BLOCKHASHES_SYSVAR_ADDRESS = \"SysvarRecentB1ockHashes11111111111111111111\";\nvar SYSTEM_PROGRAM_ADDRESS = \"11111111111111111111111111111111\";\nfunction assertIsDurableNonceTransaction(transaction) {\n if (!isDurableNonceTransaction(transaction)) {\n throw new Error(\"Transaction is not a durable nonce transaction\");\n }\n}\nfunction createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {\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]),\n programAddress: SYSTEM_PROGRAM_ADDRESS\n };\n}\nfunction isAdvanceNonceAccountInstruction(instruction) {\n return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data\n instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts\n instruction.accounts?.length === 3 && // First account is nonce account address\n instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar\n instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account\n instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);\n}\nfunction isAdvanceNonceAccountInstructionData(data) {\n return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;\n}\nfunction isDurableNonceTransaction(transaction) {\n return \"lifetimeConstraint\" in transaction && typeof transaction.lifetimeConstraint.nonce === \"string\" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);\n}\nfunction isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {\n return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;\n}\nfunction setTransactionLifetimeUsingDurableNonce({\n nonce,\n nonceAccountAddress,\n nonceAuthorityAddress\n}, transaction) {\n let newInstructions;\n const firstInstruction = transaction.instructions[0];\n if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {\n if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {\n if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {\n return transaction;\n } else {\n newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];\n }\n } else {\n newInstructions = [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...transaction.instructions.slice(1)\n ];\n }\n } else {\n newInstructions = [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...transaction.instructions\n ];\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: newInstructions,\n lifetimeConstraint: {\n nonce\n }\n };\n Object.freeze(out);\n return out;\n}\n\n// src/fee-payer.ts\nfunction setTransactionFeePayer(feePayer, transaction) {\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\n// src/instructions.ts\nfunction appendTransactionInstruction(instruction, transaction) {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [...transaction.instructions, instruction]\n };\n Object.freeze(out);\n return out;\n}\nfunction prependTransactionInstruction(instruction, transaction) {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [instruction, ...transaction.instructions]\n };\n Object.freeze(out);\n return out;\n}\nfunction upsert(addressMap, address, update) {\n addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });\n}\nvar TYPE = Symbol(\"AddressMapTypeProperty\");\nfunction getAddressMapFromInstructions(feePayer, instructions) {\n const addressMap = {\n [feePayer]: { [TYPE]: 0 /* FEE_PAYER */, role: AccountRole.WRITABLE_SIGNER }\n };\n const addressesOfInvokedPrograms = /* @__PURE__ */ new Set();\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 0 /* FEE_PAYER */:\n throw new Error(\n `This transaction includes an address (\\`${instruction.programAddress}\\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`\n );\n default:\n throw new Error(\n `This transaction includes an address (\\`${instruction.programAddress}\\`) which is both invoked and marked writable. Program addresses may not be writable.`\n );\n }\n }\n if (entry[TYPE] === 2 /* STATIC */) {\n return entry;\n }\n }\n return { [TYPE]: 2 /* STATIC */, role: AccountRole.READONLY };\n });\n let addressComparator;\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 0 /* FEE_PAYER */:\n return entry;\n case 1 /* 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 && // ...and sorts before the existing one.\n (addressComparator || (addressComparator = getAddressComparator()))(\n accountMeta.lookupTableAddress,\n entry.lookupTableAddress\n ) < 0\n );\n if (shouldReplaceEntry) {\n return {\n [TYPE]: 1 /* LOOKUP_TABLE */,\n ...accountMeta,\n role: nextRole\n };\n }\n } else if (isSignerRole(accountMeta.role)) {\n return {\n [TYPE]: 2 /* STATIC */,\n role: nextRole\n };\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole\n };\n } else {\n return entry;\n }\n }\n case 2 /* 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 throw new Error(\n `This transaction includes an address (\\`${account.address}\\`) which is both invoked and marked writable. Program addresses may not be writable.`\n );\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole\n };\n } else {\n return entry;\n }\n } else if (\"lookupTableAddress\" in accountMeta && // 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 return {\n ...accountMeta,\n [TYPE]: 1 /* LOOKUP_TABLE */,\n role: nextRole\n };\n } else {\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole\n };\n } else {\n return entry;\n }\n }\n }\n }\n }\n if (\"lookupTableAddress\" in accountMeta) {\n return {\n ...accountMeta,\n [TYPE]: 1 /* LOOKUP_TABLE */\n };\n } else {\n return {\n ...accountMeta,\n [TYPE]: 2 /* STATIC */\n };\n }\n });\n }\n }\n return addressMap;\n}\nfunction getOrderedAccountsFromAddressMap(addressMap) {\n let addressComparator;\n const orderedAccounts = Object.entries(addressMap).sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {\n if (leftEntry[TYPE] !== rightEntry[TYPE]) {\n if (leftEntry[TYPE] === 0 /* FEE_PAYER */) {\n return -1;\n } else if (rightEntry[TYPE] === 0 /* FEE_PAYER */) {\n return 1;\n } else if (leftEntry[TYPE] === 2 /* STATIC */) {\n return -1;\n } else if (rightEntry[TYPE] === 2 /* STATIC */) {\n return 1;\n }\n }\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 addressComparator || (addressComparator = getAddressComparator());\n if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {\n return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);\n } else {\n return addressComparator(leftAddress, rightAddress);\n }\n }).map(([address, addressMeta]) => ({\n address,\n ...addressMeta\n }));\n return orderedAccounts;\n}\nfunction getCompiledAddressTableLookups(orderedAccounts) {\n var _a;\n const index = {};\n for (const account of orderedAccounts) {\n if (!(\"lookupTableAddress\" in account)) {\n continue;\n }\n const entry = index[_a = account.lookupTableAddress] || (index[_a] = {\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).sort(getAddressComparator()).map((lookupTableAddress) => ({\n lookupTableAddress,\n ...index[lookupTableAddress]\n }));\n}\n\n// src/compile-header.ts\nfunction getCompiledMessageHeader(orderedAccounts) {\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\n// src/compile-instructions.ts\nfunction getAccountIndex(orderedAccounts) {\n const out = {};\n for (const [index, account] of orderedAccounts.entries()) {\n out[account.address] = index;\n }\n return out;\n}\nfunction getCompiledInstructions(instructions, orderedAccounts) {\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\n// src/compile-lifetime-token.ts\nfunction getCompiledLifetimeToken(lifetimeConstraint) {\n if (\"nonce\" in lifetimeConstraint) {\n return lifetimeConstraint.nonce;\n }\n return lifetimeConstraint.blockhash;\n}\n\n// src/compile-static-accounts.ts\nfunction getCompiledStaticAccounts(orderedAccounts) {\n const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => \"lookupTableAddress\" in account);\n const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);\n return orderedStaticAccounts.map(({ address }) => address);\n}\n\n// src/message.ts\nfunction compileMessage(transaction) {\n const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);\n const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);\n return {\n ...transaction.version !== \"legacy\" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : 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\n// src/compile-transaction.ts\nfunction getCompiledTransaction(transaction) {\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] = 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}\nfunction getAccountMetas(message) {\n const { header } = message;\n const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;\n const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;\n const accountMetas = [];\n let accountIndex = 0;\n for (let i = 0; i < numWritableSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.WRITABLE_SIGNER\n });\n accountIndex++;\n }\n for (let i = 0; i < header.numReadonlySignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.READONLY_SIGNER\n });\n accountIndex++;\n }\n for (let i = 0; i < numWritableNonSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.WRITABLE\n });\n accountIndex++;\n }\n for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.READONLY\n });\n accountIndex++;\n }\n return accountMetas;\n}\nfunction convertInstruction(instruction, accountMetas) {\n const programAddress = accountMetas[instruction.programAddressIndex]?.address;\n if (!programAddress) {\n throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);\n }\n const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);\n const { data } = instruction;\n return {\n programAddress,\n ...accounts && accounts.length ? { accounts } : {},\n ...data && data.length ? { data } : {}\n };\n}\nfunction getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {\n if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {\n return {\n blockhash: messageLifetimeToken,\n lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n\n // U64 MAX\n };\n } else {\n const nonceAccountAddress = firstInstruction.accounts[0].address;\n assertIsAddress(nonceAccountAddress);\n const nonceAuthorityAddress = firstInstruction.accounts[2].address;\n assertIsAddress(nonceAuthorityAddress);\n return {\n nonce: messageLifetimeToken,\n nonceAccountAddress,\n nonceAuthorityAddress\n };\n }\n}\nfunction convertSignatures(compiledTransaction) {\n const {\n compiledMessage: { staticAccounts },\n signatures\n } = compiledTransaction;\n return signatures.reduce((acc, sig, index) => {\n const allZeros = sig.every((byte) => byte === 0);\n if (allZeros)\n return acc;\n const address = staticAccounts[index];\n return { ...acc, [address]: sig };\n }, {});\n}\nfunction decompileTransaction(compiledTransaction, lastValidBlockHeight) {\n const { compiledMessage } = compiledTransaction;\n if (\"addressTableLookups\" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {\n throw new Error(\"Cannot convert transaction with addressTableLookups\");\n }\n const feePayer = compiledMessage.staticAccounts[0];\n if (!feePayer)\n throw new Error(\"No fee payer set in CompiledTransaction\");\n const accountMetas = getAccountMetas(compiledMessage);\n const instructions = compiledMessage.instructions.map(\n (compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)\n );\n const firstInstruction = instructions[0];\n const lifetimeConstraint = getLifetimeConstraint(\n compiledMessage.lifetimeToken,\n firstInstruction,\n lastValidBlockHeight\n );\n const signatures = convertSignatures(compiledTransaction);\n return pipe(\n createTransaction({ version: compiledMessage.version }),\n (tx) => setTransactionFeePayer(feePayer, tx),\n (tx) => instructions.reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n (tx) => \"blockhash\" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),\n (tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx\n );\n}\nvar lookupTableAddressDescription = __DEV__ ? \"The address of the address lookup table account from which instruction addresses should be looked up\" : \"lookupTableAddress\";\nvar writableIndicesDescription = __DEV__ ? \"The indices of the accounts in the lookup table that should be loaded as writeable\" : \"writableIndices\";\nvar readableIndicesDescription = __DEV__ ? \"The indices of the accounts in the lookup table that should be loaded as read-only\" : \"readableIndices\";\nvar addressTableLookupDescription = __DEV__ ? \"A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it\" : \"addressTableLookup\";\nvar memoizedAddressTableLookupEncoder;\nfunction getAddressTableLookupEncoder() {\n if (!memoizedAddressTableLookupEncoder) {\n memoizedAddressTableLookupEncoder = getStructEncoder(\n [\n [\"lookupTableAddress\", getAddressEncoder({ description: lookupTableAddressDescription })],\n [\n \"writableIndices\",\n getArrayEncoder(getU8Encoder(), {\n description: writableIndicesDescription,\n size: getShortU16Encoder()\n })\n ],\n [\n \"readableIndices\",\n getArrayEncoder(getU8Encoder(), {\n description: readableIndicesDescription,\n size: getShortU16Encoder()\n })\n ]\n ],\n { description: addressTableLookupDescription }\n );\n }\n return memoizedAddressTableLookupEncoder;\n}\nvar memoizedAddressTableLookupDecoder;\nfunction getAddressTableLookupDecoder() {\n if (!memoizedAddressTableLookupDecoder) {\n memoizedAddressTableLookupDecoder = getStructDecoder(\n [\n [\"lookupTableAddress\", getAddressDecoder({ description: lookupTableAddressDescription })],\n [\n \"writableIndices\",\n getArrayDecoder(getU8Decoder(), {\n description: writableIndicesDescription,\n size: getShortU16Decoder()\n })\n ],\n [\n \"readableIndices\",\n getArrayDecoder(getU8Decoder(), {\n description: readableIndicesDescription,\n size: getShortU16Decoder()\n })\n ]\n ],\n { description: addressTableLookupDescription }\n );\n }\n return memoizedAddressTableLookupDecoder;\n}\nvar memoizedU8Encoder;\nfunction getMemoizedU8Encoder() {\n if (!memoizedU8Encoder)\n memoizedU8Encoder = getU8Encoder();\n return memoizedU8Encoder;\n}\nfunction getMemoizedU8EncoderDescription(description) {\n const encoder = getMemoizedU8Encoder();\n return {\n ...encoder,\n description: description ?? encoder.description\n };\n}\nvar memoizedU8Decoder;\nfunction getMemoizedU8Decoder() {\n if (!memoizedU8Decoder)\n memoizedU8Decoder = getU8Decoder();\n return memoizedU8Decoder;\n}\nfunction getMemoizedU8DecoderDescription(description) {\n const decoder = getMemoizedU8Decoder();\n return {\n ...decoder,\n description: description ?? decoder.description\n };\n}\nvar numSignerAccountsDescription = __DEV__ ? \"The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction\" : void 0;\nvar numReadonlySignerAccountsDescription = __DEV__ ? \"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\" : void 0;\nvar numReadonlyNonSignerAccountsDescription = __DEV__ ? \"The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable\" : void 0;\nvar messageHeaderDescription = __DEV__ ? \"The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses\" : void 0;\nfunction getMessageHeaderEncoder() {\n return getStructEncoder(\n [\n [\"numSignerAccounts\", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],\n [\"numReadonlySignerAccounts\", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],\n [\"numReadonlyNonSignerAccounts\", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]\n ],\n {\n description: messageHeaderDescription\n }\n );\n}\nfunction getMessageHeaderDecoder() {\n return getStructDecoder(\n [\n [\"numSignerAccounts\", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],\n [\"numReadonlySignerAccounts\", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],\n [\"numReadonlyNonSignerAccounts\", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]\n ],\n {\n description: messageHeaderDescription\n }\n );\n}\nvar programAddressIndexDescription = __DEV__ ? \"The index of the program being called, according to the well-ordered accounts list for this transaction\" : \"programAddressIndex\";\nvar accountIndexDescription = __DEV__ ? \"The index of an account, according to the well-ordered accounts list for this transaction\" : void 0;\nvar accountIndicesDescription = __DEV__ ? \"An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them\" : \"accountIndices\";\nvar dataDescription = __DEV__ ? \"An optional buffer of data passed to the instruction\" : \"data\";\nvar memoizedGetInstructionEncoder;\nfunction getInstructionEncoder() {\n if (!memoizedGetInstructionEncoder) {\n memoizedGetInstructionEncoder = mapEncoder(\n getStructEncoder([\n [\"programAddressIndex\", getU8Encoder({ description: programAddressIndexDescription })],\n [\n \"accountIndices\",\n getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {\n description: accountIndicesDescription,\n size: getShortU16Encoder()\n })\n ],\n [\"data\", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]\n ]),\n // Convert an instruction to have all fields defined\n (instruction) => {\n if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {\n return instruction;\n }\n return {\n ...instruction,\n accountIndices: instruction.accountIndices ?? [],\n data: instruction.data ?? new Uint8Array(0)\n };\n }\n );\n }\n return memoizedGetInstructionEncoder;\n}\nvar memoizedGetInstructionDecoder;\nfunction getInstructionDecoder() {\n if (!memoizedGetInstructionDecoder) {\n memoizedGetInstructionDecoder = mapDecoder(\n getStructDecoder([\n [\"programAddressIndex\", getU8Decoder({ description: programAddressIndexDescription })],\n [\n \"accountIndices\",\n getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {\n description: accountIndicesDescription,\n size: getShortU16Decoder()\n })\n ],\n [\"data\", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]\n ]),\n // Convert an instruction to exclude optional fields if they are empty\n (instruction) => {\n if (instruction.accountIndices.length && instruction.data.byteLength) {\n return instruction;\n }\n const { accountIndices, data, ...rest } = instruction;\n return {\n ...rest,\n ...accountIndices.length ? { accountIndices } : null,\n ...data.byteLength ? { data } : null\n };\n }\n );\n }\n return memoizedGetInstructionDecoder;\n}\nvar VERSION_FLAG_MASK = 128;\nvar BASE_CONFIG = {\n description: __DEV__ ? \"A single byte that encodes the version of the transaction\" : \"\",\n fixedSize: null,\n maxSize: 1\n};\nfunction decode(bytes, offset = 0) {\n const firstByte = bytes[offset];\n if ((firstByte & VERSION_FLAG_MASK) === 0) {\n return [\"legacy\", offset];\n } else {\n const version = firstByte ^ VERSION_FLAG_MASK;\n return [version, offset + 1];\n }\n}\nfunction encode(value) {\n if (value === \"legacy\") {\n return new Uint8Array();\n }\n if (value < 0 || value > 127) {\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}\nfunction getTransactionVersionDecoder() {\n return {\n ...BASE_CONFIG,\n decode\n };\n}\nfunction getTransactionVersionEncoder() {\n return {\n ...BASE_CONFIG,\n encode\n };\n}\n\n// src/serializers/message.ts\nvar staticAccountsDescription = __DEV__ ? \"A compact-array of static account addresses belonging to this transaction\" : \"staticAccounts\";\nvar lifetimeTokenDescription = __DEV__ ? \"A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)\" : \"lifetimeToken\";\nvar instructionsDescription = __DEV__ ? \"A compact-array of instructions belonging to this transaction\" : \"instructions\";\nvar addressTableLookupsDescription = __DEV__ ? \"A compact array of address table lookups belonging to this transaction\" : \"addressTableLookups\";\nfunction getCompiledMessageLegacyEncoder() {\n return getStructEncoder(getPreludeStructEncoderTuple());\n}\nfunction getCompiledMessageVersionedEncoder() {\n return mapEncoder(\n getStructEncoder([\n ...getPreludeStructEncoderTuple(),\n [\"addressTableLookups\", getAddressTableLookupArrayEncoder()]\n ]),\n (value) => {\n if (value.version === \"legacy\") {\n return value;\n }\n return {\n ...value,\n addressTableLookups: value.addressTableLookups ?? []\n };\n }\n );\n}\nfunction getPreludeStructEncoderTuple() {\n return [\n [\"version\", getTransactionVersionEncoder()],\n [\"header\", getMessageHeaderEncoder()],\n [\n \"staticAccounts\",\n getArrayEncoder(getAddressEncoder(), {\n description: staticAccountsDescription,\n size: getShortU16Encoder()\n })\n ],\n [\n \"lifetimeToken\",\n getStringEncoder({\n description: lifetimeTokenDescription,\n encoding: getBase58Encoder(),\n size: 32\n })\n ],\n [\n \"instructions\",\n getArrayEncoder(getInstructionEncoder(), {\n description: instructionsDescription,\n size: getShortU16Encoder()\n })\n ]\n ];\n}\nfunction getPreludeStructDecoderTuple() {\n return [\n [\"version\", getTransactionVersionDecoder()],\n [\"header\", getMessageHeaderDecoder()],\n [\n \"staticAccounts\",\n getArrayDecoder(getAddressDecoder(), {\n description: staticAccountsDescription,\n size: getShortU16Decoder()\n })\n ],\n [\n \"lifetimeToken\",\n getStringDecoder({\n description: lifetimeTokenDescription,\n encoding: getBase58Decoder(),\n size: 32\n })\n ],\n [\n \"instructions\",\n getArrayDecoder(getInstructionDecoder(), {\n description: instructionsDescription,\n size: getShortU16Decoder()\n })\n ],\n [\"addressTableLookups\", getAddressTableLookupArrayDecoder()]\n ];\n}\nfunction getAddressTableLookupArrayEncoder() {\n return getArrayEncoder(getAddressTableLookupEncoder(), {\n description: addressTableLookupsDescription,\n size: getShortU16Encoder()\n });\n}\nfunction getAddressTableLookupArrayDecoder() {\n return getArrayDecoder(getAddressTableLookupDecoder(), {\n description: addressTableLookupsDescription,\n size: getShortU16Decoder()\n });\n}\nvar messageDescription = __DEV__ ? \"The wire format of a Solana transaction message\" : \"message\";\nfunction getCompiledMessageEncoder() {\n return {\n description: messageDescription,\n encode: (compiledMessage) => {\n if (compiledMessage.version === \"legacy\") {\n return getCompiledMessageLegacyEncoder().encode(compiledMessage);\n } else {\n return getCompiledMessageVersionedEncoder().encode(compiledMessage);\n }\n },\n fixedSize: null,\n maxSize: null\n };\n}\nfunction getCompiledMessageDecoder() {\n return mapDecoder(\n getStructDecoder(getPreludeStructDecoderTuple(), {\n description: messageDescription\n }),\n ({ addressTableLookups, ...restOfMessage }) => {\n if (restOfMessage.version === \"legacy\" || !addressTableLookups?.length) {\n return restOfMessage;\n }\n return { ...restOfMessage, addressTableLookups };\n }\n );\n}\n\n// src/serializers/transaction.ts\nvar signaturesDescription = __DEV__ ? \"A compact array of 64-byte, base-64 encoded Ed25519 signatures\" : \"signatures\";\nvar transactionDescription = __DEV__ ? \"The wire format of a Solana transaction\" : \"transaction\";\nfunction getCompiledTransactionEncoder() {\n return getStructEncoder(\n [\n [\n \"signatures\",\n getArrayEncoder(getBytesEncoder({ size: 64 }), {\n description: signaturesDescription,\n size: getShortU16Encoder()\n })\n ],\n [\"compiledMessage\", getCompiledMessageEncoder()]\n ],\n {\n description: transactionDescription\n }\n );\n}\nfunction getSignatureDecoder() {\n return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);\n}\nfunction getCompiledTransactionDecoder() {\n return getStructDecoder(\n [\n [\n \"signatures\",\n getArrayDecoder(getSignatureDecoder(), {\n description: signaturesDescription,\n size: getShortU16Decoder()\n })\n ],\n [\"compiledMessage\", getCompiledMessageDecoder()]\n ],\n {\n description: transactionDescription\n }\n );\n}\nfunction getTransactionEncoder() {\n return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);\n}\nfunction getTransactionDecoder(lastValidBlockHeight) {\n return mapDecoder(\n getCompiledTransactionDecoder(),\n (compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)\n );\n}\nfunction getTransactionCodec(lastValidBlockHeight) {\n return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));\n}\nvar base58Encoder2;\nvar base58Decoder;\nfunction assertIsTransactionSignature(putativeTransactionSignature) {\n if (!base58Encoder2)\n base58Encoder2 = getBase58Encoder();\n try {\n if (\n // Lowest value (64 bytes of zeroes)\n putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)\n putativeTransactionSignature.length > 88\n ) {\n throw new Error(\"Expected input string to decode to a byte array of length 64.\");\n }\n const bytes = base58Encoder2.encode(putativeTransactionSignature);\n const numBytes = bytes.byteLength;\n if (numBytes !== 64) {\n throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeTransactionSignature}\\` is not a transaction signature`, {\n cause: e\n });\n }\n}\nfunction isTransactionSignature(putativeTransactionSignature) {\n if (!base58Encoder2)\n base58Encoder2 = getBase58Encoder();\n if (\n // Lowest value (64 bytes of zeroes)\n putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)\n putativeTransactionSignature.length > 88\n ) {\n return false;\n }\n const bytes = base58Encoder2.encode(putativeTransactionSignature);\n const numBytes = bytes.byteLength;\n if (numBytes !== 64) {\n return false;\n }\n return true;\n}\nfunction getSignatureFromTransaction(transaction) {\n if (!base58Decoder)\n base58Decoder = getBase58Decoder();\n const signatureBytes = transaction.signatures[transaction.feePayer];\n if (!signatureBytes) {\n throw new Error(\n \"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.\"\n );\n }\n const transactionSignature2 = base58Decoder.decode(signatureBytes)[0];\n return transactionSignature2;\n}\nasync function signTransaction(keyPairs, transaction) {\n const compiledMessage = compileMessage(transaction);\n const nextSignatures = \"signatures\" in transaction ? { ...transaction.signatures } : {};\n const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);\n const publicKeySignaturePairs = await Promise.all(\n keyPairs.map(\n (keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])\n )\n );\n for (const [signerPublicKey, signature] of publicKeySignaturePairs) {\n nextSignatures[signerPublicKey] = signature;\n }\n const out = {\n ...transaction,\n signatures: nextSignatures\n };\n Object.freeze(out);\n return out;\n}\nfunction transactionSignature(putativeTransactionSignature) {\n assertIsTransactionSignature(putativeTransactionSignature);\n return putativeTransactionSignature;\n}\nfunction assertTransactionIsFullySigned(transaction) {\n const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);\n const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);\n requiredSigners.forEach((address) => {\n if (!transaction.signatures[address]) {\n throw new Error(`Transaction is missing signature for address \\`${address}\\``);\n }\n });\n}\n\n// src/wire-transaction.ts\nfunction getBase64EncodedWireTransaction(transaction) {\n const wireTransactionBytes = getTransactionEncoder().encode(transaction);\n {\n return btoa(String.fromCharCode(...wireTransactionBytes));\n }\n}\n\nexport { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, assertIsTransactionSignature, assertTransactionIsFullySigned, createTransaction, getBase64EncodedWireTransaction, getSignatureFromTransaction, getTransactionCodec, getTransactionDecoder, getTransactionEncoder, isAdvanceNonceAccountInstruction, isTransactionSignature, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, setTransactionLifetimeUsingDurableNonce, signTransaction, transactionSignature };\n","import { assertIsAddress, type Base58EncodedAddress } from '@solana/addresses';\nimport { pipe } from '@solana/functional';\nimport type { IAccountMeta, IInstruction } from '@solana/instructions';\nimport { AccountRole } from '@solana/instructions';\nimport type { Ed25519Signature } from '@solana/keys';\nimport {\n appendTransactionInstruction,\n type Blockhash,\n createTransaction,\n type IDurableNonceTransaction,\n isAdvanceNonceAccountInstruction,\n type ITransactionWithBlockhashLifetime,\n type ITransactionWithFeePayer,\n type ITransactionWithSignatures,\n type Nonce,\n setTransactionFeePayer,\n setTransactionLifetimeUsingBlockhash,\n setTransactionLifetimeUsingDurableNonce,\n type Transaction,\n} from '@solana/transactions';\nimport type {\n MessageAccountKeys,\n MessageCompiledInstruction,\n PublicKey,\n VersionedMessage,\n VersionedTransaction,\n} from '@solana/web3.js';\n\nfunction convertAccount(\n message: VersionedMessage,\n accountKeys: MessageAccountKeys,\n accountIndex: number\n): IAccountMeta {\n const accountPublicKey = accountKeys.get(accountIndex);\n if (!accountPublicKey) {\n // TODO coded error\n throw new Error(`Could not find account address at index ${accountIndex}`);\n }\n const isSigner = message.isAccountSigner(accountIndex);\n const isWritable = message.isAccountWritable(accountIndex);\n\n const role = isSigner\n ? isWritable\n ? AccountRole.WRITABLE_SIGNER\n : AccountRole.READONLY_SIGNER\n : isWritable\n ? AccountRole.WRITABLE\n : AccountRole.READONLY;\n\n return {\n address: accountPublicKey.toBase58() as Base58EncodedAddress,\n role,\n };\n}\n\nfunction convertInstruction(\n message: VersionedMessage,\n accountKeys: MessageAccountKeys,\n instruction: MessageCompiledInstruction\n): IInstruction {\n const programAddressPublicKey = accountKeys.get(instruction.programIdIndex);\n if (!programAddressPublicKey) {\n // TODO coded error\n throw new Error(`Could not find program address at index ${instruction.programIdIndex}`);\n }\n\n const accounts = instruction.accountKeyIndexes.map(accountIndex =>\n convertAccount(message, accountKeys, accountIndex)\n );\n\n return {\n programAddress: programAddressPublicKey.toBase58() as Base58EncodedAddress,\n ...(accounts.length ? { accounts } : {}),\n ...(instruction.data.length ? { data: instruction.data } : {}),\n };\n}\n\nfunction convertSignatures(\n transaction: VersionedTransaction,\n staticAccountKeys: PublicKey[]\n): ITransactionWithSignatures['signatures'] {\n return transaction.signatures.reduce((acc, sig, index) => {\n // legacy web3js includes a fake all 0 signature if it hasn't been signed\n // we don't do that for the new tx model. So just skip if it's all 0s\n const allZeros = sig.every(byte => byte === 0);\n if (allZeros) return acc;\n\n const address = staticAccountKeys[index].toBase58() as Base58EncodedAddress;\n return { ...acc, [address]: sig as Ed25519Signature };\n }, {});\n}\n\nexport function fromVersionedTransactionWithBlockhash(\n transaction: VersionedTransaction,\n lastValidBlockHeight?: bigint\n): Transaction & ITransactionWithFeePayer & ITransactionWithBlockhashLifetime {\n // TODO: add support for address table lookups\n // - will need to take `AddressLookupTableAccounts[]` as input\n // - will need to convert account instructions to `IAccountLookupMeta` when appropriate\n if (transaction.message.addressTableLookups.length > 0) {\n // TODO coded error\n throw new Error('Cannot convert transaction with addressTableLookups');\n }\n\n const accountKeys = transaction.message.getAccountKeys();\n\n // Fee payer is first account\n const feePayer = accountKeys.staticAccountKeys[0];\n // TODO: coded error\n if (!feePayer) throw new Error('No fee payer set in VersionedTransaction');\n\n const blockhashLifetime = {\n blockhash: transaction.message.recentBlockhash as Blockhash,\n lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n, // U64 MAX\n };\n\n const instructions = transaction.message.compiledInstructions.map(instruction =>\n convertInstruction(transaction.message, accountKeys, instruction)\n );\n\n const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);\n\n return pipe(\n createTransaction({ version: transaction.version }),\n tx => setTransactionFeePayer(feePayer.toBase58() as Base58EncodedAddress, tx),\n tx => setTransactionLifetimeUsingBlockhash(blockhashLifetime, tx),\n tx =>\n instructions.reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n tx => (transaction.signatures.length ? { ...tx, signatures } : tx)\n );\n}\n\nexport function fromVersionedTransactionWithDurableNonce(\n transaction: VersionedTransaction\n): Transaction & ITransactionWithFeePayer & IDurableNonceTransaction {\n // TODO: add support for address table lookups\n // - will need to take `AddressLookupTableAccounts[]` as input\n // - will need to convert account instructions to `IAccountLookupMeta` when appropriate\n if (transaction.message.addressTableLookups.length > 0) {\n // TODO coded error\n throw new Error('Cannot convert transaction with addressTableLookups');\n }\n\n const accountKeys = transaction.message.getAccountKeys();\n\n // Fee payer is first account\n const feePayer = accountKeys.staticAccountKeys[0];\n // TODO: coded error\n if (!feePayer) throw new Error('No fee payer set in VersionedTransaction');\n\n const instructions = transaction.message.compiledInstructions.map(instruction =>\n convertInstruction(transaction.message, accountKeys, instruction)\n );\n\n // Check first instruction is durable nonce + extract params\n if (instructions.length === 0) {\n // TODO: coded error\n throw new Error('transaction with no instructions cannot be durable nonce transaction');\n }\n\n if (!isAdvanceNonceAccountInstruction(instructions[0])) {\n // TODO: coded error\n throw new Error('transaction first instruction is not advance nonce account instruction');\n }\n\n // We know these accounts are defined because we checked `isAdvanceNonceAccountInstruction`\n const nonceAccountAddress = instructions[0].accounts![0].address;\n assertIsAddress(nonceAccountAddress);\n\n const nonceAuthorityAddress = instructions[0].accounts![2].address;\n assertIsAddress(nonceAuthorityAddress);\n\n const durableNonceLifetime = {\n nonce: transaction.message.recentBlockhash as Nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n };\n\n const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);\n\n return pipe(\n createTransaction({ version: transaction.version }),\n tx => setTransactionFeePayer(feePayer.toBase58() as Base58EncodedAddress, tx),\n tx => setTransactionLifetimeUsingDurableNonce(durableNonceLifetime, tx),\n tx =>\n instructions.slice(1).reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n tx => (transaction.signatures.length ? { ...tx, signatures } : tx)\n );\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
this.globalThis = this.globalThis || {};
|
|
2
|
-
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
function $(e){return e.toBase58()}function R(e){return new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32,...e])}async function Y(e,n){let r=await crypto.subtle.importKey("raw",e.publicKey.toBytes(),"Ed25519",!0,["verify"]),t=R(e.secretKey.slice(0,32));return {privateKey:await crypto.subtle.importKey("pkcs8",t,"Ed25519",n??!1,["sign"]),publicKey:r}}function N(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var z=e=>{let n=e.length,r=BigInt(n);return {description:`base${n}`,encode(t){if(N(e,t),t==="")return new Uint8Array;let o=[...t],s=o.findIndex(f=>f!==e[0]);s=s===-1?o.length:s;let a=Array(s).fill(0);if(s===o.length)return Uint8Array.from(a);let i=o.slice(s),c=0n,u=1n;for(let f=i.length-1;f>=0;f-=1)c+=u*BigInt(e.indexOf(i[f])),u*=r;let p=[];for(;c>0n;)p.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(a.concat(p))},fixedSize:null,maxSize:null}};var C="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",I=()=>z(C);var b;function _(){return b||(b=I()),b}function A(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=_().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function y(e,...n){return n.reduce((r,t)=>t(r),e)}var l=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(l||{});function m(e){if("signatures"in e){let{signatures:n,...r}=e;return r}else return e}function v(e,n){if("lifetimeConstraint"in n&&n.lifetimeConstraint.blockhash===e.blockhash&&n.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return n;let r={...m(n),lifetimeConstraint:e};return Object.freeze(r),r}function E({version:e}){let n={instructions:[],version:e};return Object.freeze(n),n}var g=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(g||{});function P(e){return e>=2}var x="SysvarRecentB1ockHashes11111111111111111111",B="11111111111111111111111111111111";function S(e,n){return {accounts:[{address:e,role:g.WRITABLE},{address:x,role:g.READONLY},{address:n,role:g.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:B}}function h(e){return e.programAddress===B&&e.data!=null&&K(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===g.WRITABLE&&e.accounts[1].address===x&&e.accounts[1].role===g.READONLY&&e.accounts[2].address!=null&&P(e.accounts[2].role)}function K(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function M(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&h(e.instructions[0])}function U(e,n,r){return e.accounts[0].address===n&&e.accounts[2].address===r}function D({nonce:e,nonceAccountAddress:n,nonceAuthorityAddress:r},t){let o,s=t.instructions[0];if(s&&h(s))if(U(s,n,r)){if(M(t)&&t.lifetimeConstraint.nonce===e)return t;o=[s,...t.instructions.slice(1)];}else o=[S(n,r),...t.instructions.slice(1)];else o=[S(n,r),...t.instructions];let a={...m(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(a),a}function w(e,n){if("feePayer"in n&&e===n.feePayer)return n;let r={...m(n),feePayer:e};return Object.freeze(r),r}function T(e,n){let r={...m(n),instructions:[...n.instructions,e]};return Object.freeze(r),r}function O(e,n,r){let t=n.get(r);if(!t)throw new Error(`Could not find account address at index ${r}`);let o=e.isAccountSigner(r),s=e.isAccountWritable(r),a=o?s?l.WRITABLE_SIGNER:l.READONLY_SIGNER:s?l.WRITABLE:l.READONLY;return {address:t.toBase58(),role:a}}function k(e,n,r){let t=n.get(r.programIdIndex);if(!t)throw new Error(`Could not find program address at index ${r.programIdIndex}`);let o=r.accountKeyIndexes.map(s=>O(e,n,s));return {programAddress:t.toBase58(),...o.length?{accounts:o}:{},...r.data.length?{data:r.data}:{}}}function L(e,n){return e.signatures.reduce((r,t,o)=>{if(t.every(i=>i===0))return r;let a=n[o].toBase58();return {...r,[a]:t}},{})}function me(e,n){if(e.message.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let r=e.message.getAccountKeys(),t=r.staticAccountKeys[0];if(!t)throw new Error("No fee payer set in VersionedTransaction");let o={blockhash:e.message.recentBlockhash,lastValidBlockHeight:n??2n**64n-1n},s=e.message.compiledInstructions.map(i=>k(e.message,r,i)),a=L(e,r.staticAccountKeys);return y(E({version:e.version}),i=>w(t.toBase58(),i),i=>v(o,i),i=>s.reduce((c,u)=>T(u,c),i),i=>e.signatures.length?{...i,signatures:a}:i)}function he(e){if(e.message.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let n=e.message.getAccountKeys(),r=n.staticAccountKeys[0];if(!r)throw new Error("No fee payer set in VersionedTransaction");let t=e.message.compiledInstructions.map(c=>k(e.message,n,c));if(t.length===0)throw new Error("transaction with no instructions cannot be durable nonce transaction");if(!h(t[0]))throw new Error("transaction first instruction is not advance nonce account instruction");let o=t[0].accounts[0].address;A(o);let s=t[0].accounts[2].address;A(s);let a={nonce:e.message.recentBlockhash,nonceAccountAddress:o,nonceAuthorityAddress:s},i=L(e,n.staticAccountKeys);return y(E({version:e.version}),c=>w(r.toBase58(),c),c=>D(a,c),c=>t.slice(1).reduce((u,p)=>T(p,u),c),c=>e.signatures.length?{...c,signatures:i}:c)}
|
|
6
|
-
|
|
7
|
-
exports.fromLegacyKeypair = Y;
|
|
8
|
-
exports.fromLegacyPublicKey = $;
|
|
9
|
-
exports.fromVersionedTransactionWithBlockhash = me;
|
|
10
|
-
exports.fromVersionedTransactionWithDurableNonce = he;
|
|
11
|
-
|
|
12
|
-
return exports;
|
|
13
|
-
|
|
14
|
-
})({});
|