@solana/signers 2.0.0-experimental.efe6f4d → 2.0.0-experimental.f054d90

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 (51) hide show
  1. package/README.md +214 -12
  2. package/dist/index.browser.cjs +222 -9
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +212 -11
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.native.js +212 -11
  7. package/dist/index.native.js.map +1 -1
  8. package/dist/index.node.cjs +222 -9
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.js +212 -11
  11. package/dist/index.node.js.map +1 -1
  12. package/dist/types/account-signer-meta.d.ts +21 -0
  13. package/dist/types/account-signer-meta.d.ts.map +1 -0
  14. package/dist/types/add-signers.d.ts +9 -0
  15. package/dist/types/add-signers.d.ts.map +1 -0
  16. package/dist/types/deduplicate-signers.d.ts +5 -0
  17. package/dist/types/deduplicate-signers.d.ts.map +1 -0
  18. package/dist/types/fee-payer-signer.d.ts +10 -0
  19. package/dist/types/fee-payer-signer.d.ts.map +1 -0
  20. package/dist/types/index.d.ts +16 -10
  21. package/dist/types/index.d.ts.map +1 -0
  22. package/dist/types/keypair-signer.d.ts +4 -2
  23. package/dist/types/keypair-signer.d.ts.map +1 -0
  24. package/dist/types/message-modifying-signer.d.ts +4 -2
  25. package/dist/types/message-modifying-signer.d.ts.map +1 -0
  26. package/dist/types/message-partial-signer.d.ts +4 -3
  27. package/dist/types/message-partial-signer.d.ts.map +1 -0
  28. package/dist/types/message-signer.d.ts +2 -2
  29. package/dist/types/message-signer.d.ts.map +1 -0
  30. package/dist/types/noop-signer.d.ts +8 -0
  31. package/dist/types/noop-signer.d.ts.map +1 -0
  32. package/dist/types/sign-transaction.d.ts +33 -0
  33. package/dist/types/sign-transaction.d.ts.map +1 -0
  34. package/dist/types/signable-message.d.ts +1 -1
  35. package/dist/types/signable-message.d.ts.map +1 -0
  36. package/dist/types/transaction-modifying-signer.d.ts +3 -1
  37. package/dist/types/transaction-modifying-signer.d.ts.map +1 -0
  38. package/dist/types/transaction-partial-signer.d.ts +3 -2
  39. package/dist/types/transaction-partial-signer.d.ts.map +1 -0
  40. package/dist/types/transaction-sending-signer.d.ts +3 -1
  41. package/dist/types/transaction-sending-signer.d.ts.map +1 -0
  42. package/dist/types/transaction-signer.d.ts +3 -3
  43. package/dist/types/transaction-signer.d.ts.map +1 -0
  44. package/dist/types/transaction-with-single-sending-signer.d.ts +11 -0
  45. package/dist/types/transaction-with-single-sending-signer.d.ts.map +1 -0
  46. package/dist/types/types.d.ts +3 -0
  47. package/dist/types/types.d.ts.map +1 -0
  48. package/package.json +16 -37
  49. package/dist/index.development.js +0 -1200
  50. package/dist/index.development.js.map +0 -1
  51. package/dist/index.production.min.js +0 -33
package/README.md CHANGED
@@ -336,33 +336,235 @@ assertIsKeyPairSigner({ address: address('1234..5678') }); // ❌ Throws an erro
336
336
 
337
337
  ## Creating Noop signers
338
338
 
339
- ### Functions
340
-
341
- #### `createNoopSigner()`
342
-
343
- _Coming soon..._
344
-
345
- Creates a Noop (No-Operation) signer from a given address. It will return an implementation of both the `MessagePartialSigner` and `TransactionPartialSigner` interfaces that do not sign anything. Namely, signing a transaction or a message will return an empty `SignatureDictionary`.
339
+ For a given address, a Noop (No-Operation) signer can be created to offer an implementation of both the `MessagePartialSigner` and `TransactionPartialSigner` interfaces such that they do not sign anything. Namely, signing a transaction or a message with a `NoopSigner` will return an empty `SignatureDictionary`.
346
340
 
347
341
  This signer may be useful:
348
342
 
349
343
  - For testing purposes.
350
344
  - For indicating that a given account is a signer and taking the responsibility to provide the signature for that account ourselves. For instance, if we need to send the transaction to a server that will sign it and send it for us.
351
345
 
346
+ ### Types
347
+
348
+ #### `NoopSigner<TAddress>`
349
+
350
+ Defines a Noop (No-Operation) signer.
351
+
352
+ ```ts
353
+ const myNoopSigner: NoopSigner;
354
+ myNoopSigner satisfies MessagePartialSigner;
355
+ myNoopSigner satisfies TransactionPartialSigner;
356
+ ```
357
+
358
+ ### Functions
359
+
360
+ #### `createNoopSigner()`
361
+
362
+ Creates a Noop (No-Operation) signer from a given address.
363
+
352
364
  ```ts
353
365
  import { createNoopSigner } from '@solana/signers';
354
366
 
355
- const myAddress = address('1234..5678');
356
- const myNoopSigner = createNoopSigner(myAddress);
357
- // ^ MessagePartialSigner<'1234..5678'> & TransactionPartialSigner<'1234..5678'>
367
+ const myNoopSigner = createNoopSigner(address('1234..5678'));
368
+ const [myMessageSignatures] = await myNoopSigner.signMessages([myMessage]); // <- Empty signature dictionary.
369
+ const [myTransactionSignatures] = await myNoopSigner.signTransactions([myTransaction]); // <- Empty signature dictionary.
358
370
  ```
359
371
 
360
372
  ## Storing transaction signers inside instruction account metas
361
373
 
374
+ This package defines an alternative definition for account metas that allows us to store `TransactionSigners` inside them. This means each instruction can keep track of its own set of signers and, by extension, so can transactions.
375
+
376
+ It also provides helper functions that deduplicate and extract signers from instructions and transactions which makes it possible to sign an entire transaction automatically as we will see in the next section.
377
+
362
378
  ### Types
363
379
 
364
- _Coming soon..._
380
+ #### `IAccountSignerMeta`
381
+
382
+ Alternative `IAccountMeta` definition for signer accounts that allows us to store `TransactionSigners` inside it.
383
+
384
+ ```ts
385
+ const mySignerMeta: IAccountSignerMeta = {
386
+ address: myTransactionSigner.address,
387
+ role: AccountRole.READONLY_SIGNER,
388
+ signer: myTransactionSigner,
389
+ };
390
+ ```
391
+
392
+ #### `IInstructionWithSigners`
393
+
394
+ Composable type that allows `IAccountSignerMetas` to be used inside the instruction's `accounts` array.
395
+
396
+ ```ts
397
+ const myInstructionWithSigners: IInstruction & IInstructionWithSigners = {
398
+ programAddress: address('1234..5678'),
399
+ accounts: [
400
+ {
401
+ address: myTransactionSigner.address,
402
+ role: AccountRole.READONLY_SIGNER,
403
+ signer: myTransactionSigner,
404
+ },
405
+ ],
406
+ };
407
+ ```
408
+
409
+ #### `ITransactionWithSigners`
410
+
411
+ Composable type that allows `IAccountSignerMetas` to be used inside all of the transaction's account metas.
412
+
413
+ ```ts
414
+ const myTransactionWithSigners: BaseTransaction & ITransactionWithSigners = {
415
+ instructions: [
416
+ myInstructionA as IInstruction & IInstructionWithSigners,
417
+ myInstructionB as IInstruction & IInstructionWithSigners,
418
+ myInstructionC as IInstruction,
419
+ ],
420
+ version: 0,
421
+ };
422
+ ```
365
423
 
366
424
  ### Functions
367
425
 
368
- _Coming soon..._
426
+ #### `getSignersFromInstruction()`
427
+
428
+ Extracts and deduplicates all signers stored inside the account metas of an instruction.
429
+
430
+ ```ts
431
+ const mySignerA = { address: address('1111..1111'), signTransactions: async () => {} };
432
+ const mySignerB = { address: address('2222..2222'), signTransactions: async () => {} };
433
+ const myInstructionWithSigners: IInstructionWithSigners = {
434
+ programAddress: address('1234..5678'),
435
+ accounts: [
436
+ { address: mySignerA.address, role: AccountRole.READONLY_SIGNER, signer: mySignerA },
437
+ { address: mySignerB.address, role: AccountRole.WRITABLE_SIGNER, signer: mySignerB },
438
+ { address: mySignerA.address, role: AccountRole.WRITABLE_SIGNER, signer: mySignerA },
439
+ ],
440
+ };
441
+
442
+ const instructionSigners = getSignersFromInstruction(myInstructionWithSigners);
443
+ // ^ [mySignerA, mySignerB]
444
+ ```
445
+
446
+ #### `getSignersFromTransaction()`
447
+
448
+ Similarly to `getSignersFromInstruction`, this function extracts and deduplicates all signers stored inside the account metas of all the instructions inside a transaction.
449
+
450
+ ```ts
451
+ const transactionSigners = getSignersFromTransaction(myTransactionWithSigners);
452
+ ```
453
+
454
+ #### `addSignersToInstruction()`
455
+
456
+ Helper function that adds the provided signers to any of the applicable account metas. For an account meta to match a provided signer it:
457
+
458
+ - Must have a signer role (`AccountRole.READONLY_SIGNER` or `AccountRole.WRITABLE_SIGNER`).
459
+ - Must have the same address as the provided signer.
460
+ - Must not have an attached signer already.
461
+
462
+ ```ts
463
+ const myInstruction: IInstruction = {
464
+ accounts: [
465
+ { address: '1111' as Address, role: AccountRole.READONLY_SIGNER },
466
+ { address: '2222' as Address, role: AccountRole.WRITABLE_SIGNER },
467
+ ],
468
+ // ...
469
+ };
470
+
471
+ const signerA: TransactionSigner<'1111'>;
472
+ const signerB: TransactionSigner<'2222'>;
473
+ const myInstructionWithSigners = addSignersToInstruction([mySignerA, mySignerB], myInstruction);
474
+
475
+ // myInstructionWithSigners.accounts[0].signer === mySignerA
476
+ // myInstructionWithSigners.accounts[1].signer === mySignerB
477
+ ```
478
+
479
+ #### `addSignersToTransaction()`
480
+
481
+ Similarly to `addSignersToInstruction`, this function adds signer to all the applicable account metas of all the instructions inside a transaction.
482
+
483
+ ```ts
484
+ const myTransactionWithSigners = addSignersToTransaction(mySigners, myTransaction);
485
+ ```
486
+
487
+ ## Signing transactions with signers
488
+
489
+ As we've seen in the previous section, we can store and extract `TransactionSigners` from instructions and transactions. This allows us to provide helper methods that sign transactions using the signers stored inside them.
490
+
491
+ ### Functions
492
+
493
+ #### `partiallySignTransactionWithSigners()`
494
+
495
+ Extracts all signers inside the provided transaction and uses them to sign it. It first uses all `TransactionModifyingSigners` sequentially before using all `TransactionPartialSigners` in parallel.
496
+
497
+ If a composite signer implements both interfaces, it will be used as a modifying signer if no other signer implements that interface. Otherwise, it will be used as a partial signer.
498
+
499
+ ```ts
500
+ const mySignedTransaction = await partiallySignTransactionWithSigners(myTransaction);
501
+ ```
502
+
503
+ It also accepts an optional `AbortSignal` that will be propagated to all signers.
504
+
505
+ ```ts
506
+ const mySignedTransaction = await partiallySignTransactionWithSigners(myTransaction, {
507
+ abortSignal: myAbortController.signal,
508
+ });
509
+ ```
510
+
511
+ Finally, note that this function ignores `TransactionSendingSigners` as it does not send the transaction. See the `signAndSendTransactionWithSigners` function below for more details on how to use sending signers.
512
+
513
+ #### `signTransactionWithSigners()`
514
+
515
+ This function works the same as the `partiallySignTransactionWithSigners` function described above except that it also ensures the transaction is fully signed before returning it. An error will be thrown if that's not the case.
516
+
517
+ ```ts
518
+ const mySignedTransaction = await signTransactionWithSigners(myTransaction);
519
+
520
+ // With additional config.
521
+ const mySignedTransaction = await signTransactionWithSigners(myTransaction, {
522
+ abortSignal: myAbortController.signal,
523
+ });
524
+
525
+ // We now know the transaction is fully signed.
526
+ mySignedTransaction satisfies IFullySignedTransaction;
527
+ ```
528
+
529
+ #### `signAndSendTransactionWithSigners()`
530
+
531
+ Extracts all signers inside the provided transaction and uses them to sign it before sending it immediately to the blockchain. It returns the signature of the sent transaction (i.e. its identifier).
532
+
533
+ ```ts
534
+ const myTransactionSignature = await signAndSendTransactionWithSigners(myTransaction);
535
+
536
+ // With additional config.
537
+ const myTransactionSignature = await signAndSendTransactionWithSigners(myTransaction, {
538
+ abortSignal: myAbortController.signal,
539
+ });
540
+ ```
541
+
542
+ Similarly to the `partiallySignTransactionWithSigners` function, it first uses all `TransactionModifyingSigners` sequentially before using all `TransactionPartialSigners` in parallel. It then sends the transaction using the `TransactionSendingSigner` it identified.
543
+
544
+ Here as well, composite transaction signers are treated such that at least one sending signer is used if any. When a `TransactionSigner` implements more than one interface, use it as a:
545
+
546
+ - `TransactionSendingSigner`, if no other `TransactionSendingSigner` exists.
547
+ - `TransactionModifyingSigner`, if no other `TransactionModifyingSigner` exists.
548
+ - `TransactionPartialSigner`, otherwise.
549
+
550
+ The provided transaction must be of type `ITransactionWithSingleSendingSigner` meaning that it must contain exactly one `TransactionSendingSigner` inside its account metas. If more than one composite signers implement the `TransactionSendingSigner` interface, one of them will be selected as the sending signer.
551
+
552
+ Therefore, you may use the `assertIsTransactionWithSingleSendingSigner()` function to ensure the transaction is of the expected type.
553
+
554
+ ```ts
555
+ assertIsTransactionWithSingleSendingSigner(myTransaction);
556
+ const myTransactionSignature = await signAndSendTransactionWithSigners(myTransaction);
557
+ ```
558
+
559
+ Alternatively, you may use the `isTransactionWithSingleSendingSigner()` function to provide a fallback in case the transaction does not contain any sending signer.
560
+
561
+ ```ts
562
+ let transactionSignature: SignatureBytes;
563
+ if (isTransactionWithSingleSendingSigner(transaction)) {
564
+ transactionSignature = await signAndSendTransactionWithSigners(transaction);
565
+ } else {
566
+ const signedTransaction = await signTransactionWithSigners(transaction);
567
+ const encodedTransaction = getBase64EncodedWireTransaction(signedTransaction);
568
+ transactionSignature = await rpc.sendTransaction(encodedTransaction).send();
569
+ }
570
+ ```
@@ -1,10 +1,78 @@
1
1
  'use strict';
2
2
 
3
+ var instructions = require('@solana/instructions');
4
+ var transactions = require('@solana/transactions');
3
5
  var addresses = require('@solana/addresses');
4
6
  var keys = require('@solana/keys');
5
- var transactions = require('@solana/transactions');
6
7
 
7
- // src/keypair-signer.ts
8
+ // src/deduplicate-signers.ts
9
+ function deduplicateSigners(signers) {
10
+ const deduplicated = {};
11
+ signers.forEach((signer) => {
12
+ if (!deduplicated[signer.address]) {
13
+ deduplicated[signer.address] = signer;
14
+ } else if (deduplicated[signer.address] !== signer) {
15
+ throw new Error(
16
+ `Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
17
+ );
18
+ }
19
+ });
20
+ return Object.values(deduplicated);
21
+ }
22
+
23
+ // src/account-signer-meta.ts
24
+ function getSignersFromInstruction(instruction) {
25
+ return deduplicateSigners(
26
+ (instruction.accounts ?? []).flatMap((account) => "signer" in account ? account.signer : [])
27
+ );
28
+ }
29
+ function getSignersFromTransaction(transaction) {
30
+ return deduplicateSigners([
31
+ ...transaction.feePayerSigner ? [transaction.feePayerSigner] : [],
32
+ ...transaction.instructions.flatMap(getSignersFromInstruction)
33
+ ]);
34
+ }
35
+ function addSignersToInstruction(signers, instruction) {
36
+ if (!instruction.accounts || instruction.accounts.length === 0) {
37
+ return instruction;
38
+ }
39
+ const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer]));
40
+ return Object.freeze({
41
+ ...instruction,
42
+ accounts: instruction.accounts.map((account) => {
43
+ const signer = signerByAddress.get(account.address);
44
+ if (!instructions.isSignerRole(account.role) || "signer" in account || !signer) {
45
+ return account;
46
+ }
47
+ return Object.freeze({ ...account, signer });
48
+ })
49
+ });
50
+ }
51
+ function addSignersToTransaction(signers, transaction) {
52
+ if (transaction.instructions.length === 0) {
53
+ return transaction;
54
+ }
55
+ return Object.freeze({
56
+ ...transaction,
57
+ instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
58
+ });
59
+ }
60
+ function setTransactionFeePayerSigner(feePayerSigner, transaction) {
61
+ if ("feePayer" in transaction && feePayerSigner.address === transaction.feePayer) {
62
+ if ("feePayerSigner" in transaction)
63
+ return transaction;
64
+ const out2 = { ...transaction, feePayerSigner };
65
+ Object.freeze(out2);
66
+ return out2;
67
+ }
68
+ const out = {
69
+ ...transactions.getUnsignedTransaction(transaction),
70
+ feePayer: feePayerSigner.address,
71
+ feePayerSigner
72
+ };
73
+ Object.freeze(out);
74
+ return out;
75
+ }
8
76
 
9
77
  // src/message-partial-signer.ts
10
78
  function isMessagePartialSigner(value) {
@@ -57,6 +125,9 @@ async function createSignerFromKeyPair(keyPair) {
57
125
  async function generateKeyPairSigner() {
58
126
  return createSignerFromKeyPair(await keys.generateKeyPair());
59
127
  }
128
+ async function createKeyPairSignerFromBytes(bytes, extractable) {
129
+ return createSignerFromKeyPair(await keys.createKeyPairFromBytes(bytes, extractable));
130
+ }
60
131
  function isMessageModifyingSigner(value) {
61
132
  return addresses.isAddress(value.address) && "modifyAndSignMessages" in value && typeof value.modifyAndSignMessages === "function";
62
133
  }
@@ -75,14 +146,15 @@ function assertIsMessageSigner(value) {
75
146
  throw new Error("The provided value does not implement any of the MessageSigner interfaces");
76
147
  }
77
148
  }
78
- var o = globalThis.TextEncoder;
79
149
 
80
- // src/signable-message.ts
81
- function createSignableMessage(content, signatures = {}) {
82
- return Object.freeze({
83
- content: typeof content === "string" ? new o().encode(content) : content,
84
- signatures: Object.freeze({ ...signatures })
85
- });
150
+ // src/noop-signer.ts
151
+ function createNoopSigner(address) {
152
+ const out = {
153
+ address,
154
+ signMessages: async (messages) => messages.map(() => Object.freeze({})),
155
+ signTransactions: async (transactions) => transactions.map(() => Object.freeze({}))
156
+ };
157
+ return Object.freeze(out);
86
158
  }
87
159
 
88
160
  // src/transaction-modifying-signer.ts
@@ -115,6 +187,137 @@ function assertIsTransactionSigner(value) {
115
187
  }
116
188
  }
117
189
 
190
+ // src/sign-transaction.ts
191
+ async function partiallySignTransactionWithSigners(transaction, config = {}) {
192
+ const { partialSigners, modifyingSigners } = categorizeTransactionSigners(
193
+ deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)),
194
+ { identifySendingSigner: false }
195
+ );
196
+ return signModifyingAndPartialTransactionSigners(transaction, modifyingSigners, partialSigners, config.abortSignal);
197
+ }
198
+ async function signTransactionWithSigners(transaction, config = {}) {
199
+ const signedTransaction = await partiallySignTransactionWithSigners(transaction, config);
200
+ transactions.assertTransactionIsFullySigned(signedTransaction);
201
+ return signedTransaction;
202
+ }
203
+ async function signAndSendTransactionWithSigners(transaction, config = {}) {
204
+ const abortSignal = config.abortSignal;
205
+ const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners(
206
+ deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner))
207
+ );
208
+ abortSignal?.throwIfAborted();
209
+ const signedTransaction = await signModifyingAndPartialTransactionSigners(
210
+ transaction,
211
+ modifyingSigners,
212
+ partialSigners,
213
+ abortSignal
214
+ );
215
+ if (!sendingSigner) {
216
+ throw new Error(
217
+ "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
218
+ );
219
+ }
220
+ abortSignal?.throwIfAborted();
221
+ const [signature] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal });
222
+ abortSignal?.throwIfAborted();
223
+ return signature;
224
+ }
225
+ function categorizeTransactionSigners(signers, config = {}) {
226
+ const identifySendingSigner = config.identifySendingSigner ?? true;
227
+ const sendingSigner = identifySendingSigner ? identifyTransactionSendingSigner(signers) : null;
228
+ const otherSigners = signers.filter(
229
+ (signer) => signer !== sendingSigner && (isTransactionModifyingSigner(signer) || isTransactionPartialSigner(signer))
230
+ );
231
+ const modifyingSigners = identifyTransactionModifyingSigners(otherSigners);
232
+ const partialSigners = otherSigners.filter(isTransactionPartialSigner).filter((signer) => !modifyingSigners.includes(signer));
233
+ return Object.freeze({ modifyingSigners, partialSigners, sendingSigner });
234
+ }
235
+ function identifyTransactionSendingSigner(signers) {
236
+ const sendingSigners = signers.filter(isTransactionSendingSigner);
237
+ if (sendingSigners.length === 0)
238
+ return null;
239
+ const sendingOnlySigners = sendingSigners.filter(
240
+ (signer) => !isTransactionModifyingSigner(signer) && !isTransactionPartialSigner(signer)
241
+ );
242
+ if (sendingOnlySigners.length > 0) {
243
+ return sendingOnlySigners[0];
244
+ }
245
+ return sendingSigners[0];
246
+ }
247
+ function identifyTransactionModifyingSigners(signers) {
248
+ const modifyingSigners = signers.filter(isTransactionModifyingSigner);
249
+ if (modifyingSigners.length === 0)
250
+ return [];
251
+ const nonPartialSigners = modifyingSigners.filter((signer) => !isTransactionPartialSigner(signer));
252
+ if (nonPartialSigners.length > 0)
253
+ return nonPartialSigners;
254
+ return [modifyingSigners[0]];
255
+ }
256
+ async function signModifyingAndPartialTransactionSigners(transaction, modifyingSigners = [], partialSigners = [], abortSignal) {
257
+ const modifiedTransaction = await modifyingSigners.reduce(
258
+ async (transaction2, modifyingSigner) => {
259
+ abortSignal?.throwIfAborted();
260
+ const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction2], { abortSignal });
261
+ return Object.freeze(tx);
262
+ },
263
+ Promise.resolve(transaction)
264
+ );
265
+ abortSignal?.throwIfAborted();
266
+ const signatureDictionaries = await Promise.all(
267
+ partialSigners.map(async (partialSigner) => {
268
+ const [signatures] = await partialSigner.signTransactions([modifiedTransaction], { abortSignal });
269
+ return signatures;
270
+ })
271
+ );
272
+ const signedTransaction = {
273
+ ...modifiedTransaction,
274
+ signatures: Object.freeze(
275
+ signatureDictionaries.reduce((signatures, signatureDictionary) => {
276
+ return { ...signatures, ...signatureDictionary };
277
+ }, modifiedTransaction.signatures ?? {})
278
+ )
279
+ };
280
+ return Object.freeze(signedTransaction);
281
+ }
282
+ var o = globalThis.TextEncoder;
283
+
284
+ // src/signable-message.ts
285
+ function createSignableMessage(content, signatures = {}) {
286
+ return Object.freeze({
287
+ content: typeof content === "string" ? new o().encode(content) : content,
288
+ signatures: Object.freeze({ ...signatures })
289
+ });
290
+ }
291
+
292
+ // src/transaction-with-single-sending-signer.ts
293
+ function isTransactionWithSingleSendingSigner(transaction) {
294
+ try {
295
+ assertIsTransactionWithSingleSendingSigner(transaction);
296
+ return true;
297
+ } catch {
298
+ return false;
299
+ }
300
+ }
301
+ function assertIsTransactionWithSingleSendingSigner(transaction) {
302
+ const signers = getSignersFromTransaction(transaction);
303
+ const sendingSigners = signers.filter(isTransactionSendingSigner);
304
+ if (sendingSigners.length === 0) {
305
+ const error = new Error("No `TransactionSendingSigner` was identified.");
306
+ error.name = "MissingTransactionSendingSignerError";
307
+ throw error;
308
+ }
309
+ const sendingOnlySigners = sendingSigners.filter(
310
+ (signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer)
311
+ );
312
+ if (sendingOnlySigners.length > 1) {
313
+ const error = new Error("More than one `TransactionSendingSigner` was identified.");
314
+ error.name = "MultipleTransactionSendingSignersError";
315
+ throw error;
316
+ }
317
+ }
318
+
319
+ exports.addSignersToInstruction = addSignersToInstruction;
320
+ exports.addSignersToTransaction = addSignersToTransaction;
118
321
  exports.assertIsKeyPairSigner = assertIsKeyPairSigner;
119
322
  exports.assertIsMessageModifyingSigner = assertIsMessageModifyingSigner;
120
323
  exports.assertIsMessagePartialSigner = assertIsMessagePartialSigner;
@@ -123,9 +326,14 @@ exports.assertIsTransactionModifyingSigner = assertIsTransactionModifyingSigner;
123
326
  exports.assertIsTransactionPartialSigner = assertIsTransactionPartialSigner;
124
327
  exports.assertIsTransactionSendingSigner = assertIsTransactionSendingSigner;
125
328
  exports.assertIsTransactionSigner = assertIsTransactionSigner;
329
+ exports.assertIsTransactionWithSingleSendingSigner = assertIsTransactionWithSingleSendingSigner;
330
+ exports.createKeyPairSignerFromBytes = createKeyPairSignerFromBytes;
331
+ exports.createNoopSigner = createNoopSigner;
126
332
  exports.createSignableMessage = createSignableMessage;
127
333
  exports.createSignerFromKeyPair = createSignerFromKeyPair;
128
334
  exports.generateKeyPairSigner = generateKeyPairSigner;
335
+ exports.getSignersFromInstruction = getSignersFromInstruction;
336
+ exports.getSignersFromTransaction = getSignersFromTransaction;
129
337
  exports.isKeyPairSigner = isKeyPairSigner;
130
338
  exports.isMessageModifyingSigner = isMessageModifyingSigner;
131
339
  exports.isMessagePartialSigner = isMessagePartialSigner;
@@ -134,5 +342,10 @@ exports.isTransactionModifyingSigner = isTransactionModifyingSigner;
134
342
  exports.isTransactionPartialSigner = isTransactionPartialSigner;
135
343
  exports.isTransactionSendingSigner = isTransactionSendingSigner;
136
344
  exports.isTransactionSigner = isTransactionSigner;
345
+ exports.isTransactionWithSingleSendingSigner = isTransactionWithSingleSendingSigner;
346
+ exports.partiallySignTransactionWithSigners = partiallySignTransactionWithSigners;
347
+ exports.setTransactionFeePayerSigner = setTransactionFeePayerSigner;
348
+ exports.signAndSendTransactionWithSigners = signAndSendTransactionWithSigners;
349
+ exports.signTransactionWithSigners = signTransactionWithSigners;
137
350
  //# sourceMappingURL=out.js.map
138
351
  //# sourceMappingURL=index.browser.cjs.map