@solana/transactions 2.0.0-experimental.0099b2a

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.
Files changed (42) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +334 -0
  3. package/dist/index.browser.cjs +1098 -0
  4. package/dist/index.browser.cjs.map +1 -0
  5. package/dist/index.browser.js +1080 -0
  6. package/dist/index.browser.js.map +1 -0
  7. package/dist/index.development.js +1778 -0
  8. package/dist/index.development.js.map +1 -0
  9. package/dist/index.native.js +1080 -0
  10. package/dist/index.native.js.map +1 -0
  11. package/dist/index.node.cjs +1098 -0
  12. package/dist/index.node.cjs.map +1 -0
  13. package/dist/index.node.js +1080 -0
  14. package/dist/index.node.js.map +1 -0
  15. package/dist/index.production.min.js +29 -0
  16. package/dist/types/accounts.d.ts +28 -0
  17. package/dist/types/blockhash.d.ts +18 -0
  18. package/dist/types/compile-address-table-lookups.d.ts +10 -0
  19. package/dist/types/compile-header.d.ts +9 -0
  20. package/dist/types/compile-instructions.d.ts +10 -0
  21. package/dist/types/compile-lifetime-token.d.ts +3 -0
  22. package/dist/types/compile-static-accounts.d.ts +4 -0
  23. package/dist/types/compile-transaction.d.ts +11 -0
  24. package/dist/types/create-transaction.d.ts +9 -0
  25. package/dist/types/decompile-transaction.d.ts +7 -0
  26. package/dist/types/durable-nonce.d.ts +35 -0
  27. package/dist/types/fee-payer.d.ts +9 -0
  28. package/dist/types/index.d.ts +10 -0
  29. package/dist/types/instructions.d.ts +5 -0
  30. package/dist/types/message.d.ts +30 -0
  31. package/dist/types/serializers/address-table-lookup.d.ts +8 -0
  32. package/dist/types/serializers/header.d.ts +8 -0
  33. package/dist/types/serializers/index.d.ts +2 -0
  34. package/dist/types/serializers/instruction.d.ts +8 -0
  35. package/dist/types/serializers/message.d.ts +6 -0
  36. package/dist/types/serializers/transaction-version.d.ts +6 -0
  37. package/dist/types/serializers/transaction.d.ts +9 -0
  38. package/dist/types/signatures.d.ts +20 -0
  39. package/dist/types/types.d.ts +26 -0
  40. package/dist/types/unsigned-transaction.d.ts +4 -0
  41. package/dist/types/wire-transaction.d.ts +6 -0
  42. package/package.json +103 -0
@@ -0,0 +1,1080 @@
1
+ import { getBase58Encoder, getBase58Decoder, getStringEncoder, getStringDecoder } from '@solana/codecs-strings';
2
+ import { mapEncoder, mapDecoder, combineCodec } from '@solana/codecs-core';
3
+ import { getStructEncoder, getArrayEncoder, getBytesEncoder, getStructDecoder, getArrayDecoder, getBytesDecoder } from '@solana/codecs-data-structures';
4
+ import { getShortU16Encoder, getShortU16Decoder, getU8Encoder, getU8Decoder } from '@solana/codecs-numbers';
5
+ import { getAddressFromPublicKey, getAddressComparator, assertIsAddress, getAddressEncoder, getAddressDecoder } from '@solana/addresses';
6
+ import { pipe } from '@solana/functional';
7
+ import { signBytes } from '@solana/keys';
8
+
9
+ // ../build-scripts/env-shim.ts
10
+ var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
11
+
12
+ // src/unsigned-transaction.ts
13
+ function getUnsignedTransaction(transaction) {
14
+ if ("signatures" in transaction) {
15
+ const {
16
+ signatures: _,
17
+ // eslint-disable-line @typescript-eslint/no-unused-vars
18
+ ...unsignedTransaction
19
+ } = transaction;
20
+ return unsignedTransaction;
21
+ } else {
22
+ return transaction;
23
+ }
24
+ }
25
+
26
+ // src/blockhash.ts
27
+ var base58Encoder;
28
+ function assertIsBlockhash(putativeBlockhash) {
29
+ if (!base58Encoder)
30
+ base58Encoder = getBase58Encoder();
31
+ try {
32
+ if (
33
+ // Lowest value (32 bytes of zeroes)
34
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
35
+ putativeBlockhash.length > 44
36
+ ) {
37
+ throw new Error("Expected input string to decode to a byte array of length 32.");
38
+ }
39
+ const bytes = base58Encoder.encode(putativeBlockhash);
40
+ const numBytes = bytes.byteLength;
41
+ if (numBytes !== 32) {
42
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
43
+ }
44
+ } catch (e) {
45
+ throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
46
+ cause: e
47
+ });
48
+ }
49
+ }
50
+ function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
51
+ if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
52
+ return transaction;
53
+ }
54
+ const out = {
55
+ ...getUnsignedTransaction(transaction),
56
+ lifetimeConstraint: blockhashLifetimeConstraint
57
+ };
58
+ Object.freeze(out);
59
+ return out;
60
+ }
61
+
62
+ // src/create-transaction.ts
63
+ function createTransaction({
64
+ version
65
+ }) {
66
+ const out = {
67
+ instructions: [],
68
+ version
69
+ };
70
+ Object.freeze(out);
71
+ return out;
72
+ }
73
+
74
+ // ../instructions/dist/index.browser.js
75
+ var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
76
+ AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
77
+ 3] = "WRITABLE_SIGNER";
78
+ AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
79
+ 2] = "READONLY_SIGNER";
80
+ AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
81
+ 1] = "WRITABLE";
82
+ AccountRole2[AccountRole2["READONLY"] = /* 0 */
83
+ 0] = "READONLY";
84
+ return AccountRole2;
85
+ })(AccountRole || {});
86
+ var IS_WRITABLE_BITMASK = 1;
87
+ function isSignerRole(role) {
88
+ return role >= 2;
89
+ }
90
+ function isWritableRole(role) {
91
+ return (role & IS_WRITABLE_BITMASK) !== 0;
92
+ }
93
+ function mergeRoles(roleA, roleB) {
94
+ return roleA | roleB;
95
+ }
96
+
97
+ // src/durable-nonce.ts
98
+ var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
99
+ var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
100
+ function assertIsDurableNonceTransaction(transaction) {
101
+ if (!isDurableNonceTransaction(transaction)) {
102
+ throw new Error("Transaction is not a durable nonce transaction");
103
+ }
104
+ }
105
+ function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
106
+ return {
107
+ accounts: [
108
+ { address: nonceAccountAddress, role: AccountRole.WRITABLE },
109
+ {
110
+ address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
111
+ role: AccountRole.READONLY
112
+ },
113
+ { address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
114
+ ],
115
+ data: new Uint8Array([4, 0, 0, 0]),
116
+ programAddress: SYSTEM_PROGRAM_ADDRESS
117
+ };
118
+ }
119
+ function isAdvanceNonceAccountInstruction(instruction) {
120
+ return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
121
+ instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
122
+ instruction.accounts?.length === 3 && // First account is nonce account address
123
+ instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
124
+ instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
125
+ instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
126
+ }
127
+ function isAdvanceNonceAccountInstructionData(data) {
128
+ return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
129
+ }
130
+ function isDurableNonceTransaction(transaction) {
131
+ return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
132
+ }
133
+ function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
134
+ return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
135
+ }
136
+ function setTransactionLifetimeUsingDurableNonce({
137
+ nonce,
138
+ nonceAccountAddress,
139
+ nonceAuthorityAddress
140
+ }, transaction) {
141
+ let newInstructions;
142
+ const firstInstruction = transaction.instructions[0];
143
+ if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
144
+ if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
145
+ if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
146
+ return transaction;
147
+ } else {
148
+ newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
149
+ }
150
+ } else {
151
+ newInstructions = [
152
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
153
+ ...transaction.instructions.slice(1)
154
+ ];
155
+ }
156
+ } else {
157
+ newInstructions = [
158
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
159
+ ...transaction.instructions
160
+ ];
161
+ }
162
+ const out = {
163
+ ...getUnsignedTransaction(transaction),
164
+ instructions: newInstructions,
165
+ lifetimeConstraint: {
166
+ nonce
167
+ }
168
+ };
169
+ Object.freeze(out);
170
+ return out;
171
+ }
172
+
173
+ // src/fee-payer.ts
174
+ function setTransactionFeePayer(feePayer, transaction) {
175
+ if ("feePayer" in transaction && feePayer === transaction.feePayer) {
176
+ return transaction;
177
+ }
178
+ const out = {
179
+ ...getUnsignedTransaction(transaction),
180
+ feePayer
181
+ };
182
+ Object.freeze(out);
183
+ return out;
184
+ }
185
+
186
+ // src/instructions.ts
187
+ function appendTransactionInstruction(instruction, transaction) {
188
+ const out = {
189
+ ...getUnsignedTransaction(transaction),
190
+ instructions: [...transaction.instructions, instruction]
191
+ };
192
+ Object.freeze(out);
193
+ return out;
194
+ }
195
+ function prependTransactionInstruction(instruction, transaction) {
196
+ const out = {
197
+ ...getUnsignedTransaction(transaction),
198
+ instructions: [instruction, ...transaction.instructions]
199
+ };
200
+ Object.freeze(out);
201
+ return out;
202
+ }
203
+ function upsert(addressMap, address, update) {
204
+ addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
205
+ }
206
+ var TYPE = Symbol("AddressMapTypeProperty");
207
+ function getAddressMapFromInstructions(feePayer, instructions) {
208
+ const addressMap = {
209
+ [feePayer]: { [TYPE]: 0 /* FEE_PAYER */, role: AccountRole.WRITABLE_SIGNER }
210
+ };
211
+ const addressesOfInvokedPrograms = /* @__PURE__ */ new Set();
212
+ for (const instruction of instructions) {
213
+ upsert(addressMap, instruction.programAddress, (entry) => {
214
+ addressesOfInvokedPrograms.add(instruction.programAddress);
215
+ if (TYPE in entry) {
216
+ if (isWritableRole(entry.role)) {
217
+ switch (entry[TYPE]) {
218
+ case 0 /* FEE_PAYER */:
219
+ throw new Error(
220
+ `This transaction includes an address (\`${instruction.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`
221
+ );
222
+ default:
223
+ throw new Error(
224
+ `This transaction includes an address (\`${instruction.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`
225
+ );
226
+ }
227
+ }
228
+ if (entry[TYPE] === 2 /* STATIC */) {
229
+ return entry;
230
+ }
231
+ }
232
+ return { [TYPE]: 2 /* STATIC */, role: AccountRole.READONLY };
233
+ });
234
+ let addressComparator;
235
+ if (!instruction.accounts) {
236
+ continue;
237
+ }
238
+ for (const account of instruction.accounts) {
239
+ upsert(addressMap, account.address, (entry) => {
240
+ const {
241
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
242
+ address: _,
243
+ ...accountMeta
244
+ } = account;
245
+ if (TYPE in entry) {
246
+ switch (entry[TYPE]) {
247
+ case 0 /* FEE_PAYER */:
248
+ return entry;
249
+ case 1 /* LOOKUP_TABLE */: {
250
+ const nextRole = mergeRoles(entry.role, accountMeta.role);
251
+ if ("lookupTableAddress" in accountMeta) {
252
+ const shouldReplaceEntry = (
253
+ // Consider using the new LOOKUP_TABLE if its address is different...
254
+ entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
255
+ (addressComparator || (addressComparator = getAddressComparator()))(
256
+ accountMeta.lookupTableAddress,
257
+ entry.lookupTableAddress
258
+ ) < 0
259
+ );
260
+ if (shouldReplaceEntry) {
261
+ return {
262
+ [TYPE]: 1 /* LOOKUP_TABLE */,
263
+ ...accountMeta,
264
+ role: nextRole
265
+ };
266
+ }
267
+ } else if (isSignerRole(accountMeta.role)) {
268
+ return {
269
+ [TYPE]: 2 /* STATIC */,
270
+ role: nextRole
271
+ };
272
+ }
273
+ if (entry.role !== nextRole) {
274
+ return {
275
+ ...entry,
276
+ role: nextRole
277
+ };
278
+ } else {
279
+ return entry;
280
+ }
281
+ }
282
+ case 2 /* STATIC */: {
283
+ const nextRole = mergeRoles(entry.role, accountMeta.role);
284
+ if (
285
+ // Check to see if this address represents a program that is invoked
286
+ // in this transaction.
287
+ addressesOfInvokedPrograms.has(account.address)
288
+ ) {
289
+ if (isWritableRole(accountMeta.role)) {
290
+ throw new Error(
291
+ `This transaction includes an address (\`${account.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`
292
+ );
293
+ }
294
+ if (entry.role !== nextRole) {
295
+ return {
296
+ ...entry,
297
+ role: nextRole
298
+ };
299
+ } else {
300
+ return entry;
301
+ }
302
+ } else if ("lookupTableAddress" in accountMeta && // Static accounts can be 'upgraded' to lookup table accounts as
303
+ // long as they are not require to sign the transaction.
304
+ !isSignerRole(entry.role)) {
305
+ return {
306
+ ...accountMeta,
307
+ [TYPE]: 1 /* LOOKUP_TABLE */,
308
+ role: nextRole
309
+ };
310
+ } else {
311
+ if (entry.role !== nextRole) {
312
+ return {
313
+ ...entry,
314
+ role: nextRole
315
+ };
316
+ } else {
317
+ return entry;
318
+ }
319
+ }
320
+ }
321
+ }
322
+ }
323
+ if ("lookupTableAddress" in accountMeta) {
324
+ return {
325
+ ...accountMeta,
326
+ [TYPE]: 1 /* LOOKUP_TABLE */
327
+ };
328
+ } else {
329
+ return {
330
+ ...accountMeta,
331
+ [TYPE]: 2 /* STATIC */
332
+ };
333
+ }
334
+ });
335
+ }
336
+ }
337
+ return addressMap;
338
+ }
339
+ function getOrderedAccountsFromAddressMap(addressMap) {
340
+ let addressComparator;
341
+ const orderedAccounts = Object.entries(addressMap).sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {
342
+ if (leftEntry[TYPE] !== rightEntry[TYPE]) {
343
+ if (leftEntry[TYPE] === 0 /* FEE_PAYER */) {
344
+ return -1;
345
+ } else if (rightEntry[TYPE] === 0 /* FEE_PAYER */) {
346
+ return 1;
347
+ } else if (leftEntry[TYPE] === 2 /* STATIC */) {
348
+ return -1;
349
+ } else if (rightEntry[TYPE] === 2 /* STATIC */) {
350
+ return 1;
351
+ }
352
+ }
353
+ const leftIsSigner = isSignerRole(leftEntry.role);
354
+ if (leftIsSigner !== isSignerRole(rightEntry.role)) {
355
+ return leftIsSigner ? -1 : 1;
356
+ }
357
+ const leftIsWritable = isWritableRole(leftEntry.role);
358
+ if (leftIsWritable !== isWritableRole(rightEntry.role)) {
359
+ return leftIsWritable ? -1 : 1;
360
+ }
361
+ addressComparator || (addressComparator = getAddressComparator());
362
+ if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
363
+ return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
364
+ } else {
365
+ return addressComparator(leftAddress, rightAddress);
366
+ }
367
+ }).map(([address, addressMeta]) => ({
368
+ address,
369
+ ...addressMeta
370
+ }));
371
+ return orderedAccounts;
372
+ }
373
+ function getCompiledAddressTableLookups(orderedAccounts) {
374
+ var _a;
375
+ const index = {};
376
+ for (const account of orderedAccounts) {
377
+ if (!("lookupTableAddress" in account)) {
378
+ continue;
379
+ }
380
+ const entry = index[_a = account.lookupTableAddress] || (index[_a] = {
381
+ readableIndices: [],
382
+ writableIndices: []
383
+ });
384
+ if (account.role === AccountRole.WRITABLE) {
385
+ entry.writableIndices.push(account.addressIndex);
386
+ } else {
387
+ entry.readableIndices.push(account.addressIndex);
388
+ }
389
+ }
390
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
391
+ lookupTableAddress,
392
+ ...index[lookupTableAddress]
393
+ }));
394
+ }
395
+
396
+ // src/compile-header.ts
397
+ function getCompiledMessageHeader(orderedAccounts) {
398
+ let numReadonlyNonSignerAccounts = 0;
399
+ let numReadonlySignerAccounts = 0;
400
+ let numSignerAccounts = 0;
401
+ for (const account of orderedAccounts) {
402
+ if ("lookupTableAddress" in account) {
403
+ break;
404
+ }
405
+ const accountIsWritable = isWritableRole(account.role);
406
+ if (isSignerRole(account.role)) {
407
+ numSignerAccounts++;
408
+ if (!accountIsWritable) {
409
+ numReadonlySignerAccounts++;
410
+ }
411
+ } else if (!accountIsWritable) {
412
+ numReadonlyNonSignerAccounts++;
413
+ }
414
+ }
415
+ return {
416
+ numReadonlyNonSignerAccounts,
417
+ numReadonlySignerAccounts,
418
+ numSignerAccounts
419
+ };
420
+ }
421
+
422
+ // src/compile-instructions.ts
423
+ function getAccountIndex(orderedAccounts) {
424
+ const out = {};
425
+ for (const [index, account] of orderedAccounts.entries()) {
426
+ out[account.address] = index;
427
+ }
428
+ return out;
429
+ }
430
+ function getCompiledInstructions(instructions, orderedAccounts) {
431
+ const accountIndex = getAccountIndex(orderedAccounts);
432
+ return instructions.map(({ accounts, data, programAddress }) => {
433
+ return {
434
+ programAddressIndex: accountIndex[programAddress],
435
+ ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
436
+ ...data ? { data } : null
437
+ };
438
+ });
439
+ }
440
+
441
+ // src/compile-lifetime-token.ts
442
+ function getCompiledLifetimeToken(lifetimeConstraint) {
443
+ if ("nonce" in lifetimeConstraint) {
444
+ return lifetimeConstraint.nonce;
445
+ }
446
+ return lifetimeConstraint.blockhash;
447
+ }
448
+
449
+ // src/compile-static-accounts.ts
450
+ function getCompiledStaticAccounts(orderedAccounts) {
451
+ const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
452
+ const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
453
+ return orderedStaticAccounts.map(({ address }) => address);
454
+ }
455
+
456
+ // src/message.ts
457
+ function compileMessage(transaction) {
458
+ const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
459
+ const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
460
+ return {
461
+ ...transaction.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
462
+ header: getCompiledMessageHeader(orderedAccounts),
463
+ instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),
464
+ lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),
465
+ staticAccounts: getCompiledStaticAccounts(orderedAccounts),
466
+ version: transaction.version
467
+ };
468
+ }
469
+
470
+ // src/compile-transaction.ts
471
+ function getCompiledTransaction(transaction) {
472
+ const compiledMessage = compileMessage(transaction);
473
+ let signatures;
474
+ if ("signatures" in transaction) {
475
+ signatures = [];
476
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
477
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
478
+ }
479
+ } else {
480
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
481
+ }
482
+ return {
483
+ compiledMessage,
484
+ signatures
485
+ };
486
+ }
487
+ function getAccountMetas(message) {
488
+ const { header } = message;
489
+ const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
490
+ const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
491
+ const accountMetas = [];
492
+ let accountIndex = 0;
493
+ for (let i = 0; i < numWritableSignerAccounts; i++) {
494
+ accountMetas.push({
495
+ address: message.staticAccounts[accountIndex],
496
+ role: AccountRole.WRITABLE_SIGNER
497
+ });
498
+ accountIndex++;
499
+ }
500
+ for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
501
+ accountMetas.push({
502
+ address: message.staticAccounts[accountIndex],
503
+ role: AccountRole.READONLY_SIGNER
504
+ });
505
+ accountIndex++;
506
+ }
507
+ for (let i = 0; i < numWritableNonSignerAccounts; i++) {
508
+ accountMetas.push({
509
+ address: message.staticAccounts[accountIndex],
510
+ role: AccountRole.WRITABLE
511
+ });
512
+ accountIndex++;
513
+ }
514
+ for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
515
+ accountMetas.push({
516
+ address: message.staticAccounts[accountIndex],
517
+ role: AccountRole.READONLY
518
+ });
519
+ accountIndex++;
520
+ }
521
+ return accountMetas;
522
+ }
523
+ function convertInstruction(instruction, accountMetas) {
524
+ const programAddress = accountMetas[instruction.programAddressIndex]?.address;
525
+ if (!programAddress) {
526
+ throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
527
+ }
528
+ const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
529
+ const { data } = instruction;
530
+ return {
531
+ programAddress,
532
+ ...accounts && accounts.length ? { accounts } : {},
533
+ ...data && data.length ? { data } : {}
534
+ };
535
+ }
536
+ function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
537
+ if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
538
+ return {
539
+ blockhash: messageLifetimeToken,
540
+ lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
541
+ // U64 MAX
542
+ };
543
+ } else {
544
+ const nonceAccountAddress = firstInstruction.accounts[0].address;
545
+ assertIsAddress(nonceAccountAddress);
546
+ const nonceAuthorityAddress = firstInstruction.accounts[2].address;
547
+ assertIsAddress(nonceAuthorityAddress);
548
+ return {
549
+ nonce: messageLifetimeToken,
550
+ nonceAccountAddress,
551
+ nonceAuthorityAddress
552
+ };
553
+ }
554
+ }
555
+ function convertSignatures(compiledTransaction) {
556
+ const {
557
+ compiledMessage: { staticAccounts },
558
+ signatures
559
+ } = compiledTransaction;
560
+ return signatures.reduce((acc, sig, index) => {
561
+ const allZeros = sig.every((byte) => byte === 0);
562
+ if (allZeros)
563
+ return acc;
564
+ const address = staticAccounts[index];
565
+ return { ...acc, [address]: sig };
566
+ }, {});
567
+ }
568
+ function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
569
+ const { compiledMessage } = compiledTransaction;
570
+ if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
571
+ throw new Error("Cannot convert transaction with addressTableLookups");
572
+ }
573
+ const feePayer = compiledMessage.staticAccounts[0];
574
+ if (!feePayer)
575
+ throw new Error("No fee payer set in CompiledTransaction");
576
+ const accountMetas = getAccountMetas(compiledMessage);
577
+ const instructions = compiledMessage.instructions.map(
578
+ (compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
579
+ );
580
+ const firstInstruction = instructions[0];
581
+ const lifetimeConstraint = getLifetimeConstraint(
582
+ compiledMessage.lifetimeToken,
583
+ firstInstruction,
584
+ lastValidBlockHeight
585
+ );
586
+ const signatures = convertSignatures(compiledTransaction);
587
+ return pipe(
588
+ createTransaction({ version: compiledMessage.version }),
589
+ (tx) => setTransactionFeePayer(feePayer, tx),
590
+ (tx) => instructions.reduce((acc, instruction) => {
591
+ return appendTransactionInstruction(instruction, acc);
592
+ }, tx),
593
+ (tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
594
+ (tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
595
+ );
596
+ }
597
+ var lookupTableAddressDescription = __DEV__ ? "The address of the address lookup table account from which instruction addresses should be looked up" : "lookupTableAddress";
598
+ var writableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as writeable" : "writableIndices";
599
+ var readableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as read-only" : "readableIndices";
600
+ var 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";
601
+ var memoizedAddressTableLookupEncoder;
602
+ function getAddressTableLookupEncoder() {
603
+ if (!memoizedAddressTableLookupEncoder) {
604
+ memoizedAddressTableLookupEncoder = getStructEncoder(
605
+ [
606
+ ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
607
+ [
608
+ "writableIndices",
609
+ getArrayEncoder(getU8Encoder(), {
610
+ description: writableIndicesDescription,
611
+ size: getShortU16Encoder()
612
+ })
613
+ ],
614
+ [
615
+ "readableIndices",
616
+ getArrayEncoder(getU8Encoder(), {
617
+ description: readableIndicesDescription,
618
+ size: getShortU16Encoder()
619
+ })
620
+ ]
621
+ ],
622
+ { description: addressTableLookupDescription }
623
+ );
624
+ }
625
+ return memoizedAddressTableLookupEncoder;
626
+ }
627
+ var memoizedAddressTableLookupDecoder;
628
+ function getAddressTableLookupDecoder() {
629
+ if (!memoizedAddressTableLookupDecoder) {
630
+ memoizedAddressTableLookupDecoder = getStructDecoder(
631
+ [
632
+ ["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
633
+ [
634
+ "writableIndices",
635
+ getArrayDecoder(getU8Decoder(), {
636
+ description: writableIndicesDescription,
637
+ size: getShortU16Decoder()
638
+ })
639
+ ],
640
+ [
641
+ "readableIndices",
642
+ getArrayDecoder(getU8Decoder(), {
643
+ description: readableIndicesDescription,
644
+ size: getShortU16Decoder()
645
+ })
646
+ ]
647
+ ],
648
+ { description: addressTableLookupDescription }
649
+ );
650
+ }
651
+ return memoizedAddressTableLookupDecoder;
652
+ }
653
+ var memoizedU8Encoder;
654
+ function getMemoizedU8Encoder() {
655
+ if (!memoizedU8Encoder)
656
+ memoizedU8Encoder = getU8Encoder();
657
+ return memoizedU8Encoder;
658
+ }
659
+ function getMemoizedU8EncoderDescription(description) {
660
+ const encoder = getMemoizedU8Encoder();
661
+ return {
662
+ ...encoder,
663
+ description: description ?? encoder.description
664
+ };
665
+ }
666
+ var memoizedU8Decoder;
667
+ function getMemoizedU8Decoder() {
668
+ if (!memoizedU8Decoder)
669
+ memoizedU8Decoder = getU8Decoder();
670
+ return memoizedU8Decoder;
671
+ }
672
+ function getMemoizedU8DecoderDescription(description) {
673
+ const decoder = getMemoizedU8Decoder();
674
+ return {
675
+ ...decoder,
676
+ description: description ?? decoder.description
677
+ };
678
+ }
679
+ var numSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" : void 0;
680
+ var 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;
681
+ var numReadonlyNonSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" : void 0;
682
+ var messageHeaderDescription = __DEV__ ? "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" : void 0;
683
+ function getMessageHeaderEncoder() {
684
+ return getStructEncoder(
685
+ [
686
+ ["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
687
+ ["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
688
+ ["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
689
+ ],
690
+ {
691
+ description: messageHeaderDescription
692
+ }
693
+ );
694
+ }
695
+ function getMessageHeaderDecoder() {
696
+ return getStructDecoder(
697
+ [
698
+ ["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
699
+ ["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
700
+ ["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
701
+ ],
702
+ {
703
+ description: messageHeaderDescription
704
+ }
705
+ );
706
+ }
707
+ var programAddressIndexDescription = __DEV__ ? "The index of the program being called, according to the well-ordered accounts list for this transaction" : "programAddressIndex";
708
+ var accountIndexDescription = __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : void 0;
709
+ var 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";
710
+ var dataDescription = __DEV__ ? "An optional buffer of data passed to the instruction" : "data";
711
+ var memoizedGetInstructionEncoder;
712
+ function getInstructionEncoder() {
713
+ if (!memoizedGetInstructionEncoder) {
714
+ memoizedGetInstructionEncoder = mapEncoder(
715
+ getStructEncoder([
716
+ ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
717
+ [
718
+ "accountIndices",
719
+ getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
720
+ description: accountIndicesDescription,
721
+ size: getShortU16Encoder()
722
+ })
723
+ ],
724
+ ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
725
+ ]),
726
+ // Convert an instruction to have all fields defined
727
+ (instruction) => {
728
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
729
+ return instruction;
730
+ }
731
+ return {
732
+ ...instruction,
733
+ accountIndices: instruction.accountIndices ?? [],
734
+ data: instruction.data ?? new Uint8Array(0)
735
+ };
736
+ }
737
+ );
738
+ }
739
+ return memoizedGetInstructionEncoder;
740
+ }
741
+ var memoizedGetInstructionDecoder;
742
+ function getInstructionDecoder() {
743
+ if (!memoizedGetInstructionDecoder) {
744
+ memoizedGetInstructionDecoder = mapDecoder(
745
+ getStructDecoder([
746
+ ["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
747
+ [
748
+ "accountIndices",
749
+ getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
750
+ description: accountIndicesDescription,
751
+ size: getShortU16Decoder()
752
+ })
753
+ ],
754
+ ["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
755
+ ]),
756
+ // Convert an instruction to exclude optional fields if they are empty
757
+ (instruction) => {
758
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
759
+ return instruction;
760
+ }
761
+ const { accountIndices, data, ...rest } = instruction;
762
+ return {
763
+ ...rest,
764
+ ...accountIndices.length ? { accountIndices } : null,
765
+ ...data.byteLength ? { data } : null
766
+ };
767
+ }
768
+ );
769
+ }
770
+ return memoizedGetInstructionDecoder;
771
+ }
772
+ var VERSION_FLAG_MASK = 128;
773
+ var BASE_CONFIG = {
774
+ description: __DEV__ ? "A single byte that encodes the version of the transaction" : "",
775
+ fixedSize: null,
776
+ maxSize: 1
777
+ };
778
+ function decode(bytes, offset = 0) {
779
+ const firstByte = bytes[offset];
780
+ if ((firstByte & VERSION_FLAG_MASK) === 0) {
781
+ return ["legacy", offset];
782
+ } else {
783
+ const version = firstByte ^ VERSION_FLAG_MASK;
784
+ return [version, offset + 1];
785
+ }
786
+ }
787
+ function encode(value) {
788
+ if (value === "legacy") {
789
+ return new Uint8Array();
790
+ }
791
+ if (value < 0 || value > 127) {
792
+ throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
793
+ }
794
+ return new Uint8Array([value | VERSION_FLAG_MASK]);
795
+ }
796
+ function getTransactionVersionDecoder() {
797
+ return {
798
+ ...BASE_CONFIG,
799
+ decode
800
+ };
801
+ }
802
+ function getTransactionVersionEncoder() {
803
+ return {
804
+ ...BASE_CONFIG,
805
+ encode
806
+ };
807
+ }
808
+
809
+ // src/serializers/message.ts
810
+ var staticAccountsDescription = __DEV__ ? "A compact-array of static account addresses belonging to this transaction" : "staticAccounts";
811
+ var lifetimeTokenDescription = __DEV__ ? "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" : "lifetimeToken";
812
+ var instructionsDescription = __DEV__ ? "A compact-array of instructions belonging to this transaction" : "instructions";
813
+ var addressTableLookupsDescription = __DEV__ ? "A compact array of address table lookups belonging to this transaction" : "addressTableLookups";
814
+ function getCompiledMessageLegacyEncoder() {
815
+ return getStructEncoder(getPreludeStructEncoderTuple());
816
+ }
817
+ function getCompiledMessageVersionedEncoder() {
818
+ return mapEncoder(
819
+ getStructEncoder([
820
+ ...getPreludeStructEncoderTuple(),
821
+ ["addressTableLookups", getAddressTableLookupArrayEncoder()]
822
+ ]),
823
+ (value) => {
824
+ if (value.version === "legacy") {
825
+ return value;
826
+ }
827
+ return {
828
+ ...value,
829
+ addressTableLookups: value.addressTableLookups ?? []
830
+ };
831
+ }
832
+ );
833
+ }
834
+ function getPreludeStructEncoderTuple() {
835
+ return [
836
+ ["version", getTransactionVersionEncoder()],
837
+ ["header", getMessageHeaderEncoder()],
838
+ [
839
+ "staticAccounts",
840
+ getArrayEncoder(getAddressEncoder(), {
841
+ description: staticAccountsDescription,
842
+ size: getShortU16Encoder()
843
+ })
844
+ ],
845
+ [
846
+ "lifetimeToken",
847
+ getStringEncoder({
848
+ description: lifetimeTokenDescription,
849
+ encoding: getBase58Encoder(),
850
+ size: 32
851
+ })
852
+ ],
853
+ [
854
+ "instructions",
855
+ getArrayEncoder(getInstructionEncoder(), {
856
+ description: instructionsDescription,
857
+ size: getShortU16Encoder()
858
+ })
859
+ ]
860
+ ];
861
+ }
862
+ function getPreludeStructDecoderTuple() {
863
+ return [
864
+ ["version", getTransactionVersionDecoder()],
865
+ ["header", getMessageHeaderDecoder()],
866
+ [
867
+ "staticAccounts",
868
+ getArrayDecoder(getAddressDecoder(), {
869
+ description: staticAccountsDescription,
870
+ size: getShortU16Decoder()
871
+ })
872
+ ],
873
+ [
874
+ "lifetimeToken",
875
+ getStringDecoder({
876
+ description: lifetimeTokenDescription,
877
+ encoding: getBase58Decoder(),
878
+ size: 32
879
+ })
880
+ ],
881
+ [
882
+ "instructions",
883
+ getArrayDecoder(getInstructionDecoder(), {
884
+ description: instructionsDescription,
885
+ size: getShortU16Decoder()
886
+ })
887
+ ],
888
+ ["addressTableLookups", getAddressTableLookupArrayDecoder()]
889
+ ];
890
+ }
891
+ function getAddressTableLookupArrayEncoder() {
892
+ return getArrayEncoder(getAddressTableLookupEncoder(), {
893
+ description: addressTableLookupsDescription,
894
+ size: getShortU16Encoder()
895
+ });
896
+ }
897
+ function getAddressTableLookupArrayDecoder() {
898
+ return getArrayDecoder(getAddressTableLookupDecoder(), {
899
+ description: addressTableLookupsDescription,
900
+ size: getShortU16Decoder()
901
+ });
902
+ }
903
+ var messageDescription = __DEV__ ? "The wire format of a Solana transaction message" : "message";
904
+ function getCompiledMessageEncoder() {
905
+ return {
906
+ description: messageDescription,
907
+ encode: (compiledMessage) => {
908
+ if (compiledMessage.version === "legacy") {
909
+ return getCompiledMessageLegacyEncoder().encode(compiledMessage);
910
+ } else {
911
+ return getCompiledMessageVersionedEncoder().encode(compiledMessage);
912
+ }
913
+ },
914
+ fixedSize: null,
915
+ maxSize: null
916
+ };
917
+ }
918
+ function getCompiledMessageDecoder() {
919
+ return mapDecoder(
920
+ getStructDecoder(getPreludeStructDecoderTuple(), {
921
+ description: messageDescription
922
+ }),
923
+ ({ addressTableLookups, ...restOfMessage }) => {
924
+ if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
925
+ return restOfMessage;
926
+ }
927
+ return { ...restOfMessage, addressTableLookups };
928
+ }
929
+ );
930
+ }
931
+
932
+ // src/serializers/transaction.ts
933
+ var signaturesDescription = __DEV__ ? "A compact array of 64-byte, base-64 encoded Ed25519 signatures" : "signatures";
934
+ var transactionDescription = __DEV__ ? "The wire format of a Solana transaction" : "transaction";
935
+ function getCompiledTransactionEncoder() {
936
+ return getStructEncoder(
937
+ [
938
+ [
939
+ "signatures",
940
+ getArrayEncoder(getBytesEncoder({ size: 64 }), {
941
+ description: signaturesDescription,
942
+ size: getShortU16Encoder()
943
+ })
944
+ ],
945
+ ["compiledMessage", getCompiledMessageEncoder()]
946
+ ],
947
+ {
948
+ description: transactionDescription
949
+ }
950
+ );
951
+ }
952
+ function getSignatureDecoder() {
953
+ return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
954
+ }
955
+ function getCompiledTransactionDecoder() {
956
+ return getStructDecoder(
957
+ [
958
+ [
959
+ "signatures",
960
+ getArrayDecoder(getSignatureDecoder(), {
961
+ description: signaturesDescription,
962
+ size: getShortU16Decoder()
963
+ })
964
+ ],
965
+ ["compiledMessage", getCompiledMessageDecoder()]
966
+ ],
967
+ {
968
+ description: transactionDescription
969
+ }
970
+ );
971
+ }
972
+ function getTransactionEncoder() {
973
+ return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
974
+ }
975
+ function getTransactionDecoder(lastValidBlockHeight) {
976
+ return mapDecoder(
977
+ getCompiledTransactionDecoder(),
978
+ (compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
979
+ );
980
+ }
981
+ function getTransactionCodec(lastValidBlockHeight) {
982
+ return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
983
+ }
984
+ var base58Encoder2;
985
+ var base58Decoder;
986
+ function assertIsTransactionSignature(putativeTransactionSignature) {
987
+ if (!base58Encoder2)
988
+ base58Encoder2 = getBase58Encoder();
989
+ try {
990
+ if (
991
+ // Lowest value (64 bytes of zeroes)
992
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
993
+ putativeTransactionSignature.length > 88
994
+ ) {
995
+ throw new Error("Expected input string to decode to a byte array of length 64.");
996
+ }
997
+ const bytes = base58Encoder2.encode(putativeTransactionSignature);
998
+ const numBytes = bytes.byteLength;
999
+ if (numBytes !== 64) {
1000
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
1001
+ }
1002
+ } catch (e) {
1003
+ throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
1004
+ cause: e
1005
+ });
1006
+ }
1007
+ }
1008
+ function isTransactionSignature(putativeTransactionSignature) {
1009
+ if (!base58Encoder2)
1010
+ base58Encoder2 = getBase58Encoder();
1011
+ if (
1012
+ // Lowest value (64 bytes of zeroes)
1013
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
1014
+ putativeTransactionSignature.length > 88
1015
+ ) {
1016
+ return false;
1017
+ }
1018
+ const bytes = base58Encoder2.encode(putativeTransactionSignature);
1019
+ const numBytes = bytes.byteLength;
1020
+ if (numBytes !== 64) {
1021
+ return false;
1022
+ }
1023
+ return true;
1024
+ }
1025
+ function getSignatureFromTransaction(transaction) {
1026
+ if (!base58Decoder)
1027
+ base58Decoder = getBase58Decoder();
1028
+ const signatureBytes = transaction.signatures[transaction.feePayer];
1029
+ if (!signatureBytes) {
1030
+ throw new Error(
1031
+ "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
1032
+ );
1033
+ }
1034
+ const transactionSignature2 = base58Decoder.decode(signatureBytes)[0];
1035
+ return transactionSignature2;
1036
+ }
1037
+ async function signTransaction(keyPairs, transaction) {
1038
+ const compiledMessage = compileMessage(transaction);
1039
+ const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
1040
+ const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
1041
+ const publicKeySignaturePairs = await Promise.all(
1042
+ keyPairs.map(
1043
+ (keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
1044
+ )
1045
+ );
1046
+ for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
1047
+ nextSignatures[signerPublicKey] = signature;
1048
+ }
1049
+ const out = {
1050
+ ...transaction,
1051
+ signatures: nextSignatures
1052
+ };
1053
+ Object.freeze(out);
1054
+ return out;
1055
+ }
1056
+ function transactionSignature(putativeTransactionSignature) {
1057
+ assertIsTransactionSignature(putativeTransactionSignature);
1058
+ return putativeTransactionSignature;
1059
+ }
1060
+ function assertTransactionIsFullySigned(transaction) {
1061
+ const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);
1062
+ const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
1063
+ requiredSigners.forEach((address) => {
1064
+ if (!transaction.signatures[address]) {
1065
+ throw new Error(`Transaction is missing signature for address \`${address}\``);
1066
+ }
1067
+ });
1068
+ }
1069
+
1070
+ // src/wire-transaction.ts
1071
+ function getBase64EncodedWireTransaction(transaction) {
1072
+ const wireTransactionBytes = getTransactionEncoder().encode(transaction);
1073
+ {
1074
+ return btoa(String.fromCharCode(...wireTransactionBytes));
1075
+ }
1076
+ }
1077
+
1078
+ export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, assertIsTransactionSignature, assertTransactionIsFullySigned, createTransaction, getBase64EncodedWireTransaction, getSignatureFromTransaction, getTransactionCodec, getTransactionDecoder, getTransactionEncoder, isAdvanceNonceAccountInstruction, isTransactionSignature, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, setTransactionLifetimeUsingDurableNonce, signTransaction, transactionSignature };
1079
+ //# sourceMappingURL=out.js.map
1080
+ //# sourceMappingURL=index.native.js.map