@solana/transactions 2.0.0-experimental.cd89114 → 2.0.0-experimental.ce145c8

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2018 Solana Labs, Inc
1
+ Copyright (c) 2023 Solana Labs, Inc
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -2,6 +2,9 @@
2
2
 
3
3
  var umiSerializers = require('@metaplex-foundation/umi-serializers');
4
4
  var addresses = require('@solana/addresses');
5
+ var codecsCore = require('@solana/codecs-core');
6
+ var codecsDataStructures = require('@solana/codecs-data-structures');
7
+ var codecsNumbers = require('@solana/codecs-numbers');
5
8
  var keys = require('@solana/keys');
6
9
 
7
10
  // ../build-scripts/env-shim.ts
@@ -31,8 +34,8 @@ function assertIsBlockhash(putativeBlockhash) {
31
34
  ) {
32
35
  throw new Error("Expected input string to decode to a byte array of length 32.");
33
36
  }
34
- const bytes3 = umiSerializers.base58.serialize(putativeBlockhash);
35
- const numBytes = bytes3.byteLength;
37
+ const bytes2 = umiSerializers.base58.serialize(putativeBlockhash);
38
+ const numBytes = bytes2.byteLength;
36
39
  if (numBytes !== 32) {
37
40
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
38
41
  }
@@ -230,7 +233,7 @@ function getAddressMapFromInstructions(feePayer, instructions) {
230
233
  const shouldReplaceEntry = (
231
234
  // Consider using the new LOOKUP_TABLE if its address is different...
232
235
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
233
- (addressComparator || (addressComparator = addresses.getBase58EncodedAddressComparator()))(
236
+ (addressComparator || (addressComparator = addresses.getAddressComparator()))(
234
237
  accountMeta.lookupTableAddress,
235
238
  entry.lookupTableAddress
236
239
  ) < 0
@@ -336,7 +339,7 @@ function getOrderedAccountsFromAddressMap(addressMap) {
336
339
  if (leftIsWritable !== isWritableRole(rightEntry.role)) {
337
340
  return leftIsWritable ? -1 : 1;
338
341
  }
339
- addressComparator || (addressComparator = addresses.getBase58EncodedAddressComparator());
342
+ addressComparator || (addressComparator = addresses.getAddressComparator());
340
343
  if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
341
344
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
342
345
  } else {
@@ -365,7 +368,7 @@ function getCompiledAddressTableLookups(orderedAccounts) {
365
368
  entry.readableIndices.push(account.addressIndex);
366
369
  }
367
370
  }
368
- return Object.keys(index).sort(addresses.getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
371
+ return Object.keys(index).sort(addresses.getAddressComparator()).map((lookupTableAddress) => ({
369
372
  lookupTableAddress,
370
373
  ...index[lookupTableAddress]
371
374
  }));
@@ -444,151 +447,188 @@ function compileMessage(transaction) {
444
447
  version: transaction.version
445
448
  };
446
449
  }
447
- function getAddressTableLookupCodec() {
448
- return umiSerializers.struct(
449
- [
450
+
451
+ // src/compile-transaction.ts
452
+ function getCompiledTransaction(transaction) {
453
+ const compiledMessage = compileMessage(transaction);
454
+ let signatures;
455
+ if ("signatures" in transaction) {
456
+ signatures = [];
457
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
458
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
459
+ }
460
+ } else {
461
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
462
+ }
463
+ return {
464
+ compiledMessage,
465
+ signatures
466
+ };
467
+ }
468
+ var lookupTableAddressDescription = __DEV__ ? "The address of the address lookup table account from which instruction addresses should be looked up" : "lookupTableAddress";
469
+ var writableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as writeable" : "writableIndices";
470
+ var readableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as read-only" : "readableIndices";
471
+ 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";
472
+ var memoizedAddressTableLookupEncoder;
473
+ function getAddressTableLookupEncoder() {
474
+ if (!memoizedAddressTableLookupEncoder) {
475
+ memoizedAddressTableLookupEncoder = codecsDataStructures.getStructEncoder(
450
476
  [
451
- "lookupTableAddress",
452
- addresses.getBase58EncodedAddressCodec(
453
- __DEV__ ? {
454
- description: "The address of the address lookup table account from which instruction addresses should be looked up"
455
- } : void 0
456
- )
477
+ ["lookupTableAddress", addresses.getAddressEncoder({ description: lookupTableAddressDescription })],
478
+ [
479
+ "writableIndices",
480
+ codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), {
481
+ description: writableIndicesDescription,
482
+ size: codecsNumbers.getShortU16Encoder()
483
+ })
484
+ ],
485
+ [
486
+ "readableIndices",
487
+ codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder(), {
488
+ description: readableIndicesDescription,
489
+ size: codecsNumbers.getShortU16Encoder()
490
+ })
491
+ ]
457
492
  ],
493
+ { description: addressTableLookupDescription }
494
+ );
495
+ }
496
+ return memoizedAddressTableLookupEncoder;
497
+ }
498
+ var memoizedAddressTableLookupDecoder;
499
+ function getAddressTableLookupDecoder() {
500
+ if (!memoizedAddressTableLookupDecoder) {
501
+ memoizedAddressTableLookupDecoder = codecsDataStructures.getStructDecoder(
458
502
  [
459
- "writableIndices",
460
- umiSerializers.array(umiSerializers.u8(), {
461
- ...__DEV__ ? {
462
- description: "The indices of the accounts in the lookup table that should be loaded as writeable"
463
- } : null,
464
- size: umiSerializers.shortU16()
465
- })
503
+ ["lookupTableAddress", addresses.getAddressDecoder({ description: lookupTableAddressDescription })],
504
+ [
505
+ "writableIndices",
506
+ codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), {
507
+ description: writableIndicesDescription,
508
+ size: codecsNumbers.getShortU16Decoder()
509
+ })
510
+ ],
511
+ [
512
+ "readableIndices",
513
+ codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder(), {
514
+ description: readableIndicesDescription,
515
+ size: codecsNumbers.getShortU16Decoder()
516
+ })
517
+ ]
466
518
  ],
467
- [
468
- "readableIndices",
469
- umiSerializers.array(umiSerializers.u8(), {
470
- ...__DEV__ ? {
471
- description: "The indices of the accounts in the lookup table that should be loaded as read-only"
472
- } : void 0,
473
- size: umiSerializers.shortU16()
474
- })
475
- ]
476
- ],
477
- __DEV__ ? {
478
- description: "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"
479
- } : void 0
480
- );
519
+ { description: addressTableLookupDescription }
520
+ );
521
+ }
522
+ return memoizedAddressTableLookupDecoder;
523
+ }
524
+ function getAddressTableLookupCodec() {
525
+ return codecsCore.combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
526
+ }
527
+ var memoizedU8Codec;
528
+ function getMemoizedU8Codec() {
529
+ if (!memoizedU8Codec)
530
+ memoizedU8Codec = codecsNumbers.getU8Codec();
531
+ return memoizedU8Codec;
481
532
  }
533
+ function getMemoizedU8CodecDescription(description) {
534
+ const codec = getMemoizedU8Codec();
535
+ return {
536
+ ...codec,
537
+ description: description ?? codec.description
538
+ };
539
+ }
540
+ 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;
541
+ 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;
542
+ var numReadonlyNonSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" : void 0;
543
+ var messageHeaderDescription = __DEV__ ? "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" : void 0;
482
544
  function getMessageHeaderCodec() {
483
- return umiSerializers.struct(
545
+ return codecsDataStructures.getStructCodec(
484
546
  [
485
- [
486
- "numSignerAccounts",
487
- umiSerializers.u8(
488
- __DEV__ ? {
489
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
490
- } : void 0
491
- )
492
- ],
493
- [
494
- "numReadonlySignerAccounts",
495
- umiSerializers.u8(
496
- __DEV__ ? {
497
- description: "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"
498
- } : void 0
499
- )
500
- ],
501
- [
502
- "numReadonlyNonSignerAccounts",
503
- umiSerializers.u8(
504
- __DEV__ ? {
505
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
506
- } : void 0
507
- )
508
- ]
547
+ ["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
548
+ ["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
549
+ ["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
509
550
  ],
510
- __DEV__ ? {
511
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
512
- } : void 0
551
+ {
552
+ description: messageHeaderDescription
553
+ }
513
554
  );
514
555
  }
515
- function getInstructionCodec() {
516
- return umiSerializers.mapSerializer(
517
- umiSerializers.struct([
518
- [
519
- "programAddressIndex",
520
- umiSerializers.u8(
521
- __DEV__ ? {
522
- description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
523
- } : void 0
524
- )
525
- ],
526
- [
527
- "accountIndices",
528
- umiSerializers.array(
529
- umiSerializers.u8({
530
- description: __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : ""
531
- }),
532
- {
533
- description: __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" : "",
534
- size: umiSerializers.shortU16()
535
- }
536
- )
537
- ],
538
- [
539
- "data",
540
- umiSerializers.bytes({
541
- description: __DEV__ ? "An optional buffer of data passed to the instruction" : "",
542
- size: umiSerializers.shortU16()
543
- })
544
- ]
545
- ]),
546
- (value) => {
547
- if (value.accountIndices !== void 0 && value.data !== void 0) {
548
- return value;
556
+ var programAddressIndexDescription = __DEV__ ? "The index of the program being called, according to the well-ordered accounts list for this transaction" : "programAddressIndex";
557
+ var accountIndexDescription = __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : void 0;
558
+ 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";
559
+ var dataDescription = __DEV__ ? "An optional buffer of data passed to the instruction" : "data";
560
+ var memoizedGetInstructionEncoder;
561
+ function getInstructionEncoder() {
562
+ if (!memoizedGetInstructionEncoder) {
563
+ memoizedGetInstructionEncoder = codecsCore.mapEncoder(
564
+ codecsDataStructures.getStructEncoder([
565
+ ["programAddressIndex", codecsNumbers.getU8Encoder({ description: programAddressIndexDescription })],
566
+ [
567
+ "accountIndices",
568
+ codecsDataStructures.getArrayEncoder(codecsNumbers.getU8Encoder({ description: accountIndexDescription }), {
569
+ description: accountIndicesDescription,
570
+ size: codecsNumbers.getShortU16Encoder()
571
+ })
572
+ ],
573
+ ["data", codecsDataStructures.getBytesEncoder({ description: dataDescription, size: codecsNumbers.getShortU16Encoder() })]
574
+ ]),
575
+ // Convert an instruction to have all fields defined
576
+ (instruction) => {
577
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
578
+ return instruction;
579
+ }
580
+ return {
581
+ ...instruction,
582
+ accountIndices: instruction.accountIndices ?? [],
583
+ data: instruction.data ?? new Uint8Array(0)
584
+ };
549
585
  }
550
- return {
551
- ...value,
552
- accountIndices: value.accountIndices ?? [],
553
- data: value.data ?? new Uint8Array(0)
554
- };
555
- },
556
- (value) => {
557
- if (value.accountIndices.length && value.data.byteLength) {
558
- return value;
586
+ );
587
+ }
588
+ return memoizedGetInstructionEncoder;
589
+ }
590
+ var memoizedGetInstructionDecoder;
591
+ function getInstructionDecoder() {
592
+ if (!memoizedGetInstructionDecoder) {
593
+ memoizedGetInstructionDecoder = codecsCore.mapDecoder(
594
+ codecsDataStructures.getStructDecoder([
595
+ ["programAddressIndex", codecsNumbers.getU8Decoder({ description: programAddressIndexDescription })],
596
+ [
597
+ "accountIndices",
598
+ codecsDataStructures.getArrayDecoder(codecsNumbers.getU8Decoder({ description: accountIndexDescription }), {
599
+ description: accountIndicesDescription,
600
+ size: codecsNumbers.getShortU16Decoder()
601
+ })
602
+ ],
603
+ ["data", codecsDataStructures.getBytesDecoder({ description: dataDescription, size: codecsNumbers.getShortU16Decoder() })]
604
+ ]),
605
+ // Convert an instruction to exclude optional fields if they are empty
606
+ (instruction) => {
607
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
608
+ return instruction;
609
+ }
610
+ const { accountIndices, data, ...rest } = instruction;
611
+ return {
612
+ ...rest,
613
+ ...accountIndices.length ? { accountIndices } : null,
614
+ ...data.byteLength ? { data } : null
615
+ };
559
616
  }
560
- const { accountIndices, data, ...rest } = value;
561
- return {
562
- ...rest,
563
- ...accountIndices.length ? { accountIndices } : null,
564
- ...data.byteLength ? { data } : null
565
- };
566
- }
567
- );
568
- }
569
-
570
- // src/serializers/unimplemented.ts
571
- function getError(type, name) {
572
- const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
573
- return new Error(
574
- `No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
575
- );
617
+ );
618
+ }
619
+ return memoizedGetInstructionDecoder;
576
620
  }
577
- function getUnimplementedDecoder(name) {
578
- return () => {
579
- throw getError("decoder", name);
580
- };
621
+ function getInstructionCodec() {
622
+ return codecsCore.combineCodec(getInstructionEncoder(), getInstructionDecoder());
581
623
  }
582
-
583
- // src/serializers/transaction-version.ts
584
624
  var VERSION_FLAG_MASK = 128;
585
625
  var BASE_CONFIG = {
586
626
  description: __DEV__ ? "A single byte that encodes the version of the transaction" : "",
587
627
  fixedSize: null,
588
628
  maxSize: 1
589
629
  };
590
- function deserialize(bytes3, offset = 0) {
591
- const firstByte = bytes3[offset];
630
+ function decode(bytes2, offset = 0) {
631
+ const firstByte = bytes2[offset];
592
632
  if ((firstByte & VERSION_FLAG_MASK) === 0) {
593
633
  return ["legacy", offset];
594
634
  } else {
@@ -596,7 +636,7 @@ function deserialize(bytes3, offset = 0) {
596
636
  return [version, offset + 1];
597
637
  }
598
638
  }
599
- function serialize(value) {
639
+ function encode(value) {
600
640
  if (value === "legacy") {
601
641
  return new Uint8Array();
602
642
  }
@@ -605,11 +645,32 @@ function serialize(value) {
605
645
  }
606
646
  return new Uint8Array([value | VERSION_FLAG_MASK]);
607
647
  }
608
- function getTransactionVersionCodec() {
648
+ function getTransactionVersionDecoder() {
609
649
  return {
610
650
  ...BASE_CONFIG,
611
- deserialize,
612
- serialize
651
+ decode
652
+ };
653
+ }
654
+ function getTransactionVersionEncoder() {
655
+ return {
656
+ ...BASE_CONFIG,
657
+ encode
658
+ };
659
+ }
660
+ function getTransactionVersionCodec() {
661
+ return codecsCore.combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
662
+ }
663
+
664
+ // src/serializers/unimplemented.ts
665
+ function getError(type, name) {
666
+ const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
667
+ return new Error(
668
+ `No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
669
+ );
670
+ }
671
+ function getUnimplementedDecoder(name) {
672
+ return () => {
673
+ throw getError("decoder", name);
613
674
  };
614
675
  }
615
676
 
@@ -619,7 +680,7 @@ var BASE_CONFIG2 = {
619
680
  fixedSize: null,
620
681
  maxSize: null
621
682
  };
622
- function serialize2(compiledMessage) {
683
+ function serialize(compiledMessage) {
623
684
  if (compiledMessage.version === "legacy") {
624
685
  return umiSerializers.struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
625
686
  } else {
@@ -640,13 +701,22 @@ function serialize2(compiledMessage) {
640
701
  ).serialize(compiledMessage);
641
702
  }
642
703
  }
704
+ function toSerializer(codec) {
705
+ return {
706
+ description: codec.description,
707
+ deserialize: codec.decode,
708
+ fixedSize: codec.fixedSize,
709
+ maxSize: codec.maxSize,
710
+ serialize: codec.encode
711
+ };
712
+ }
643
713
  function getPreludeStructSerializerTuple() {
644
714
  return [
645
- ["version", getTransactionVersionCodec()],
646
- ["header", getMessageHeaderCodec()],
715
+ ["version", toSerializer(getTransactionVersionCodec())],
716
+ ["header", toSerializer(getMessageHeaderCodec())],
647
717
  [
648
718
  "staticAccounts",
649
- umiSerializers.array(addresses.getBase58EncodedAddressCodec(), {
719
+ umiSerializers.array(toSerializer(addresses.getAddressCodec()), {
650
720
  description: __DEV__ ? "A compact-array of static account addresses belonging to this transaction" : "",
651
721
  size: umiSerializers.shortU16()
652
722
  })
@@ -661,7 +731,7 @@ function getPreludeStructSerializerTuple() {
661
731
  ],
662
732
  [
663
733
  "instructions",
664
- umiSerializers.array(getInstructionCodec(), {
734
+ umiSerializers.array(toSerializer(getInstructionCodec()), {
665
735
  description: __DEV__ ? "A compact-array of instructions belonging to this transaction" : "",
666
736
  size: umiSerializers.shortU16()
667
737
  })
@@ -669,7 +739,7 @@ function getPreludeStructSerializerTuple() {
669
739
  ];
670
740
  }
671
741
  function getAddressTableLookupsSerializer() {
672
- return umiSerializers.array(getAddressTableLookupCodec(), {
742
+ return umiSerializers.array(toSerializer(getAddressTableLookupCodec()), {
673
743
  ...__DEV__ ? { description: "A compact array of address table lookups belonging to this transaction" } : null,
674
744
  size: umiSerializers.shortU16()
675
745
  });
@@ -678,16 +748,86 @@ function getCompiledMessageEncoder() {
678
748
  return {
679
749
  ...BASE_CONFIG2,
680
750
  deserialize: getUnimplementedDecoder("CompiledMessage"),
681
- serialize: serialize2
751
+ serialize
682
752
  };
683
753
  }
684
754
 
685
- // src/signatures.ts
755
+ // src/serializers/transaction.ts
756
+ var BASE_CONFIG3 = {
757
+ description: __DEV__ ? "The wire format of a Solana transaction" : "",
758
+ fixedSize: null,
759
+ maxSize: null
760
+ };
761
+ function serialize2(transaction) {
762
+ const compiledTransaction = getCompiledTransaction(transaction);
763
+ return umiSerializers.struct([
764
+ [
765
+ "signatures",
766
+ umiSerializers.array(umiSerializers.bytes({ size: 64 }), {
767
+ ...__DEV__ ? { description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } : null,
768
+ size: umiSerializers.shortU16()
769
+ })
770
+ ],
771
+ ["compiledMessage", getCompiledMessageEncoder()]
772
+ ]).serialize(compiledTransaction);
773
+ }
774
+ function getTransactionEncoder() {
775
+ return {
776
+ ...BASE_CONFIG3,
777
+ deserialize: getUnimplementedDecoder("CompiledMessage"),
778
+ serialize: serialize2
779
+ };
780
+ }
781
+ function assertIsTransactionSignature(putativeTransactionSignature) {
782
+ try {
783
+ if (
784
+ // Lowest value (64 bytes of zeroes)
785
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
786
+ putativeTransactionSignature.length > 88
787
+ ) {
788
+ throw new Error("Expected input string to decode to a byte array of length 64.");
789
+ }
790
+ const bytes2 = umiSerializers.base58.serialize(putativeTransactionSignature);
791
+ const numBytes = bytes2.byteLength;
792
+ if (numBytes !== 64) {
793
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
794
+ }
795
+ } catch (e) {
796
+ throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
797
+ cause: e
798
+ });
799
+ }
800
+ }
801
+ function isTransactionSignature(putativeTransactionSignature) {
802
+ if (
803
+ // Lowest value (64 bytes of zeroes)
804
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
805
+ putativeTransactionSignature.length > 88
806
+ ) {
807
+ return false;
808
+ }
809
+ const bytes2 = umiSerializers.base58.serialize(putativeTransactionSignature);
810
+ const numBytes = bytes2.byteLength;
811
+ if (numBytes !== 64) {
812
+ return false;
813
+ }
814
+ return true;
815
+ }
686
816
  async function getCompiledMessageSignature(message, secretKey) {
687
817
  const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
688
818
  const signature = await keys.signBytes(secretKey, wireMessageBytes);
689
819
  return signature;
690
820
  }
821
+ function getSignatureFromTransaction(transaction) {
822
+ const signatureBytes = transaction.signatures[transaction.feePayer];
823
+ if (!signatureBytes) {
824
+ throw new Error(
825
+ "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
826
+ );
827
+ }
828
+ const transactionSignature2 = umiSerializers.base58.deserialize(signatureBytes)[0];
829
+ return transactionSignature2;
830
+ }
691
831
  async function signTransaction(keyPairs, transaction) {
692
832
  const compiledMessage = compileMessage(transaction);
693
833
  const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
@@ -709,50 +849,9 @@ async function signTransaction(keyPairs, transaction) {
709
849
  Object.freeze(out);
710
850
  return out;
711
851
  }
712
-
713
- // src/compile-transaction.ts
714
- function getCompiledTransaction(transaction) {
715
- const compiledMessage = compileMessage(transaction);
716
- let signatures;
717
- if ("signatures" in transaction) {
718
- signatures = [];
719
- for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
720
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
721
- }
722
- } else {
723
- signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
724
- }
725
- return {
726
- compiledMessage,
727
- signatures
728
- };
729
- }
730
-
731
- // src/serializers/transaction.ts
732
- var BASE_CONFIG3 = {
733
- description: __DEV__ ? "The wire format of a Solana transaction" : "",
734
- fixedSize: null,
735
- maxSize: null
736
- };
737
- function serialize3(transaction) {
738
- const compiledTransaction = getCompiledTransaction(transaction);
739
- return umiSerializers.struct([
740
- [
741
- "signatures",
742
- umiSerializers.array(umiSerializers.bytes({ size: 64 }), {
743
- ...__DEV__ ? { description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } : null,
744
- size: umiSerializers.shortU16()
745
- })
746
- ],
747
- ["compiledMessage", getCompiledMessageEncoder()]
748
- ]).serialize(compiledTransaction);
749
- }
750
- function getTransactionEncoder() {
751
- return {
752
- ...BASE_CONFIG3,
753
- deserialize: getUnimplementedDecoder("CompiledMessage"),
754
- serialize: serialize3
755
- };
852
+ function transactionSignature(putativeTransactionSignature) {
853
+ assertIsTransactionSignature(putativeTransactionSignature);
854
+ return putativeTransactionSignature;
756
855
  }
757
856
 
758
857
  // src/wire-transaction.ts
@@ -766,12 +865,16 @@ function getBase64EncodedWireTransaction(transaction) {
766
865
  exports.appendTransactionInstruction = appendTransactionInstruction;
767
866
  exports.assertIsBlockhash = assertIsBlockhash;
768
867
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
868
+ exports.assertIsTransactionSignature = assertIsTransactionSignature;
769
869
  exports.createTransaction = createTransaction;
770
870
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
871
+ exports.getSignatureFromTransaction = getSignatureFromTransaction;
872
+ exports.getTransactionEncoder = getTransactionEncoder;
873
+ exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
874
+ exports.isTransactionSignature = isTransactionSignature;
771
875
  exports.prependTransactionInstruction = prependTransactionInstruction;
772
876
  exports.setTransactionFeePayer = setTransactionFeePayer;
773
877
  exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
774
878
  exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
775
879
  exports.signTransaction = signTransaction;
776
- //# sourceMappingURL=out.js.map
777
- //# sourceMappingURL=index.browser.cjs.map
880
+ exports.transactionSignature = transactionSignature;