@solana/transactions 2.0.0-experimental.7da1908 → 2.0.0-experimental.819a6f7

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 (44) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.browser.cjs +126 -103
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +127 -105
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.development.js +567 -121
  7. package/dist/index.development.js.map +1 -1
  8. package/dist/index.native.js +127 -105
  9. package/dist/index.native.js.map +1 -1
  10. package/dist/index.node.cjs +128 -103
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.js +129 -105
  13. package/dist/index.node.js.map +1 -1
  14. package/dist/index.production.min.js +16 -15
  15. package/dist/types/index.d.ts +1 -0
  16. package/dist/types/serializers/header.d.ts +4 -2
  17. package/dist/types/serializers/index.d.ts +2 -0
  18. package/dist/types/serializers/transaction-version.d.ts +4 -4
  19. package/package.json +10 -7
  20. package/dist/types/accounts.d.ts.map +0 -1
  21. package/dist/types/blockhash.d.ts.map +0 -1
  22. package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
  23. package/dist/types/compile-header.d.ts.map +0 -1
  24. package/dist/types/compile-instructions.d.ts.map +0 -1
  25. package/dist/types/compile-lifetime-token.d.ts.map +0 -1
  26. package/dist/types/compile-static-accounts.d.ts.map +0 -1
  27. package/dist/types/compile-transaction.d.ts.map +0 -1
  28. package/dist/types/create-transaction.d.ts.map +0 -1
  29. package/dist/types/durable-nonce.d.ts.map +0 -1
  30. package/dist/types/fee-payer.d.ts.map +0 -1
  31. package/dist/types/index.d.ts.map +0 -1
  32. package/dist/types/instructions.d.ts.map +0 -1
  33. package/dist/types/message.d.ts.map +0 -1
  34. package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
  35. package/dist/types/serializers/header.d.ts.map +0 -1
  36. package/dist/types/serializers/instruction.d.ts.map +0 -1
  37. package/dist/types/serializers/message.d.ts.map +0 -1
  38. package/dist/types/serializers/transaction-version.d.ts.map +0 -1
  39. package/dist/types/serializers/transaction.d.ts.map +0 -1
  40. package/dist/types/serializers/unimplemented.d.ts.map +0 -1
  41. package/dist/types/signatures.d.ts.map +0 -1
  42. package/dist/types/types.d.ts.map +0 -1
  43. package/dist/types/unsigned-transaction.d.ts.map +0 -1
  44. package/dist/types/wire-transaction.d.ts.map +0 -1
@@ -522,9 +522,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
522
522
  if (numBytes !== 32) {
523
523
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
524
524
  }
525
- } catch (e) {
525
+ } catch (e2) {
526
526
  throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
527
- cause: e
527
+ cause: e2
528
528
  });
529
529
  }
530
530
  }
@@ -665,6 +665,337 @@ this.globalThis.solanaWeb3 = (function (exports) {
665
665
  return out;
666
666
  }
667
667
 
668
+ // ../codecs-core/dist/index.browser.js
669
+ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes2, offset = 0) {
670
+ if (bytes2.length - offset <= 0) {
671
+ throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
672
+ }
673
+ }
674
+ function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
675
+ const bytesLength = bytes2.length - offset;
676
+ if (bytesLength < expected) {
677
+ throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
678
+ }
679
+ }
680
+ var mergeBytes2 = (byteArrays) => {
681
+ const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
682
+ if (nonEmptyByteArrays.length === 0) {
683
+ return byteArrays.length ? byteArrays[0] : new Uint8Array();
684
+ }
685
+ if (nonEmptyByteArrays.length === 1) {
686
+ return nonEmptyByteArrays[0];
687
+ }
688
+ const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
689
+ const result = new Uint8Array(totalLength);
690
+ let offset = 0;
691
+ nonEmptyByteArrays.forEach((arr) => {
692
+ result.set(arr, offset);
693
+ offset += arr.length;
694
+ });
695
+ return result;
696
+ };
697
+ var padBytes2 = (bytes2, length) => {
698
+ if (bytes2.length >= length)
699
+ return bytes2;
700
+ const paddedBytes = new Uint8Array(length).fill(0);
701
+ paddedBytes.set(bytes2);
702
+ return paddedBytes;
703
+ };
704
+ var fixBytes2 = (bytes2, length) => padBytes2(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
705
+ function combineCodec(encoder, decoder, description) {
706
+ if (encoder.fixedSize !== decoder.fixedSize) {
707
+ throw new Error(
708
+ `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
709
+ );
710
+ }
711
+ if (encoder.maxSize !== decoder.maxSize) {
712
+ throw new Error(
713
+ `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
714
+ );
715
+ }
716
+ if (description === void 0 && encoder.description !== decoder.description) {
717
+ throw new Error(
718
+ `Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
719
+ );
720
+ }
721
+ return {
722
+ decode: decoder.decode,
723
+ description: description ?? encoder.description,
724
+ encode: encoder.encode,
725
+ fixedSize: encoder.fixedSize,
726
+ maxSize: encoder.maxSize
727
+ };
728
+ }
729
+ function fixCodecHelper(data, fixedBytes, description) {
730
+ return {
731
+ description: description ?? `fixed(${fixedBytes}, ${data.description})`,
732
+ fixedSize: fixedBytes,
733
+ maxSize: fixedBytes
734
+ };
735
+ }
736
+ function fixEncoder(encoder, fixedBytes, description) {
737
+ return {
738
+ ...fixCodecHelper(encoder, fixedBytes, description),
739
+ encode: (value) => fixBytes2(encoder.encode(value), fixedBytes)
740
+ };
741
+ }
742
+ function fixDecoder(decoder, fixedBytes, description) {
743
+ return {
744
+ ...fixCodecHelper(decoder, fixedBytes, description),
745
+ decode: (bytes2, offset = 0) => {
746
+ assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes2, offset);
747
+ if (offset > 0 || bytes2.length > fixedBytes) {
748
+ bytes2 = bytes2.slice(offset, offset + fixedBytes);
749
+ }
750
+ if (decoder.fixedSize !== null) {
751
+ bytes2 = fixBytes2(bytes2, decoder.fixedSize);
752
+ }
753
+ const [value] = decoder.decode(bytes2, 0);
754
+ return [value, offset + fixedBytes];
755
+ }
756
+ };
757
+ }
758
+ function mapEncoder(encoder, unmap) {
759
+ return {
760
+ description: encoder.description,
761
+ encode: (value) => encoder.encode(unmap(value)),
762
+ fixedSize: encoder.fixedSize,
763
+ maxSize: encoder.maxSize
764
+ };
765
+ }
766
+
767
+ // ../codecs-numbers/dist/index.browser.js
768
+ function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
769
+ if (value < min || value > max) {
770
+ throw new Error(
771
+ `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
772
+ );
773
+ }
774
+ }
775
+ function sharedNumberFactory(input) {
776
+ let littleEndian;
777
+ let defaultDescription = input.name;
778
+ if (input.size > 1) {
779
+ littleEndian = !("endian" in input.options) || input.options.endian === 0;
780
+ defaultDescription += littleEndian ? "(le)" : "(be)";
781
+ }
782
+ return {
783
+ description: input.options.description ?? defaultDescription,
784
+ fixedSize: input.size,
785
+ littleEndian,
786
+ maxSize: input.size
787
+ };
788
+ }
789
+ function numberEncoderFactory(input) {
790
+ const codecData = sharedNumberFactory(input);
791
+ return {
792
+ description: codecData.description,
793
+ encode(value) {
794
+ if (input.range) {
795
+ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
796
+ }
797
+ const arrayBuffer = new ArrayBuffer(input.size);
798
+ input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
799
+ return new Uint8Array(arrayBuffer);
800
+ },
801
+ fixedSize: codecData.fixedSize,
802
+ maxSize: codecData.maxSize
803
+ };
804
+ }
805
+ function numberDecoderFactory(input) {
806
+ const codecData = sharedNumberFactory(input);
807
+ return {
808
+ decode(bytes2, offset = 0) {
809
+ assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
810
+ assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
811
+ const view = new DataView(toArrayBuffer2(bytes2, offset, input.size));
812
+ return [input.get(view, codecData.littleEndian), offset + input.size];
813
+ },
814
+ description: codecData.description,
815
+ fixedSize: codecData.fixedSize,
816
+ maxSize: codecData.maxSize
817
+ };
818
+ }
819
+ function toArrayBuffer2(bytes2, offset, length) {
820
+ const bytesOffset = bytes2.byteOffset + (offset ?? 0);
821
+ const bytesLength = length ?? bytes2.byteLength;
822
+ return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
823
+ }
824
+ var getU32Encoder = (options = {}) => numberEncoderFactory({
825
+ name: "u32",
826
+ options,
827
+ range: [0, Number("0xffffffff")],
828
+ set: (view, value, le) => view.setUint32(0, value, le),
829
+ size: 4
830
+ });
831
+ var getU32Decoder = (options = {}) => numberDecoderFactory({
832
+ get: (view, le) => view.getUint32(0, le),
833
+ name: "u32",
834
+ options,
835
+ size: 4
836
+ });
837
+ var getU8Encoder = (options = {}) => numberEncoderFactory({
838
+ name: "u8",
839
+ options,
840
+ range: [0, Number("0xff")],
841
+ set: (view, value) => view.setUint8(0, value),
842
+ size: 1
843
+ });
844
+ var getU8Decoder = (options = {}) => numberDecoderFactory({
845
+ get: (view) => view.getUint8(0),
846
+ name: "u8",
847
+ options,
848
+ size: 1
849
+ });
850
+ var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
851
+
852
+ // ../codecs-strings/dist/index.browser.js
853
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
854
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
855
+ throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
856
+ }
857
+ }
858
+ var getBaseXEncoder = (alphabet4) => {
859
+ const base = alphabet4.length;
860
+ const baseBigInt = BigInt(base);
861
+ return {
862
+ description: `base${base}`,
863
+ encode(value) {
864
+ assertValidBaseString(alphabet4, value);
865
+ if (value === "")
866
+ return new Uint8Array();
867
+ const chars = [...value];
868
+ let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
869
+ trailIndex = trailIndex === -1 ? chars.length : trailIndex;
870
+ const leadingZeroes = Array(trailIndex).fill(0);
871
+ if (trailIndex === chars.length)
872
+ return Uint8Array.from(leadingZeroes);
873
+ const tailChars = chars.slice(trailIndex);
874
+ let base10Number = 0n;
875
+ let baseXPower = 1n;
876
+ for (let i = tailChars.length - 1; i >= 0; i -= 1) {
877
+ base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
878
+ baseXPower *= baseBigInt;
879
+ }
880
+ const tailBytes = [];
881
+ while (base10Number > 0n) {
882
+ tailBytes.unshift(Number(base10Number % 256n));
883
+ base10Number /= 256n;
884
+ }
885
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
886
+ },
887
+ fixedSize: null,
888
+ maxSize: null
889
+ };
890
+ };
891
+ var getBaseXDecoder = (alphabet4) => {
892
+ const base = alphabet4.length;
893
+ const baseBigInt = BigInt(base);
894
+ return {
895
+ decode(rawBytes, offset = 0) {
896
+ const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
897
+ if (bytes2.length === 0)
898
+ return ["", 0];
899
+ let trailIndex = bytes2.findIndex((n) => n !== 0);
900
+ trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
901
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
902
+ if (trailIndex === bytes2.length)
903
+ return [leadingZeroes, rawBytes.length];
904
+ let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
905
+ const tailChars = [];
906
+ while (base10Number > 0n) {
907
+ tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
908
+ base10Number /= baseBigInt;
909
+ }
910
+ return [leadingZeroes + tailChars.join(""), rawBytes.length];
911
+ },
912
+ description: `base${base}`,
913
+ fixedSize: null,
914
+ maxSize: null
915
+ };
916
+ };
917
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
918
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
919
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
920
+ var removeNullCharacters2 = (value) => (
921
+ // eslint-disable-next-line no-control-regex
922
+ value.replace(/\u0000/g, "")
923
+ );
924
+ var e = globalThis.TextDecoder;
925
+ var o = globalThis.TextEncoder;
926
+ var getUtf8Encoder = () => {
927
+ let textEncoder;
928
+ return {
929
+ description: "utf8",
930
+ encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
931
+ fixedSize: null,
932
+ maxSize: null
933
+ };
934
+ };
935
+ var getUtf8Decoder = () => {
936
+ let textDecoder;
937
+ return {
938
+ decode(bytes2, offset = 0) {
939
+ const value = (textDecoder || (textDecoder = new e())).decode(bytes2.slice(offset));
940
+ return [removeNullCharacters2(value), bytes2.length];
941
+ },
942
+ description: "utf8",
943
+ fixedSize: null,
944
+ maxSize: null
945
+ };
946
+ };
947
+ var getStringEncoder = (options = {}) => {
948
+ const size = options.size ?? getU32Encoder();
949
+ const encoding = options.encoding ?? getUtf8Encoder();
950
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
951
+ if (size === "variable") {
952
+ return { ...encoding, description };
953
+ }
954
+ if (typeof size === "number") {
955
+ return fixEncoder(encoding, size, description);
956
+ }
957
+ return {
958
+ description,
959
+ encode: (value) => {
960
+ const contentBytes = encoding.encode(value);
961
+ const lengthBytes = size.encode(contentBytes.length);
962
+ return mergeBytes2([lengthBytes, contentBytes]);
963
+ },
964
+ fixedSize: null,
965
+ maxSize: null
966
+ };
967
+ };
968
+ var getStringDecoder = (options = {}) => {
969
+ const size = options.size ?? getU32Decoder();
970
+ const encoding = options.encoding ?? getUtf8Decoder();
971
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
972
+ if (size === "variable") {
973
+ return { ...encoding, description };
974
+ }
975
+ if (typeof size === "number") {
976
+ return fixDecoder(encoding, size, description);
977
+ }
978
+ return {
979
+ decode: (bytes2, offset = 0) => {
980
+ assertByteArrayIsNotEmptyForCodec("string", bytes2, offset);
981
+ const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
982
+ const length = Number(lengthBigInt);
983
+ offset = lengthOffset;
984
+ const contentBytes = bytes2.slice(offset, offset + length);
985
+ assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
986
+ const [value, contentOffset] = encoding.decode(contentBytes);
987
+ offset += contentOffset;
988
+ return [value, offset];
989
+ },
990
+ description,
991
+ fixedSize: null,
992
+ maxSize: null
993
+ };
994
+ };
995
+ function getSizeDescription2(size) {
996
+ return typeof size === "object" ? size.description : `${size}`;
997
+ }
998
+
668
999
  // ../assertions/dist/index.browser.js
669
1000
  function assertIsSecureContext() {
670
1001
  if (!globalThis.isSecureContext) {
@@ -685,14 +1016,66 @@ this.globalThis.solanaWeb3 = (function (exports) {
685
1016
  throw new Error("No signing implementation could be found");
686
1017
  }
687
1018
  }
688
- function getBase58EncodedAddressCodec(config) {
689
- return string({
690
- description: config?.description ?? ("A 32-byte account address" ),
691
- encoding: base58,
1019
+
1020
+ // ../addresses/dist/index.browser.js
1021
+ var memoizedBase58Encoder;
1022
+ var memoizedBase58Decoder;
1023
+ function getMemoizedBase58Encoder() {
1024
+ if (!memoizedBase58Encoder)
1025
+ memoizedBase58Encoder = getBase58Encoder();
1026
+ return memoizedBase58Encoder;
1027
+ }
1028
+ function getMemoizedBase58Decoder() {
1029
+ if (!memoizedBase58Decoder)
1030
+ memoizedBase58Decoder = getBase58Decoder();
1031
+ return memoizedBase58Decoder;
1032
+ }
1033
+ function assertIsAddress(putativeBase58EncodedAddress) {
1034
+ try {
1035
+ if (
1036
+ // Lowest address (32 bytes of zeroes)
1037
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
1038
+ putativeBase58EncodedAddress.length > 44
1039
+ ) {
1040
+ throw new Error("Expected input string to decode to a byte array of length 32.");
1041
+ }
1042
+ const base58Encoder = getMemoizedBase58Encoder();
1043
+ const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
1044
+ const numBytes = bytes2.byteLength;
1045
+ if (numBytes !== 32) {
1046
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
1047
+ }
1048
+ } catch (e2) {
1049
+ throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
1050
+ cause: e2
1051
+ });
1052
+ }
1053
+ }
1054
+ function address(putativeBase58EncodedAddress) {
1055
+ assertIsAddress(putativeBase58EncodedAddress);
1056
+ return putativeBase58EncodedAddress;
1057
+ }
1058
+ function getAddressEncoder(config) {
1059
+ return mapEncoder(
1060
+ getStringEncoder({
1061
+ description: config?.description ?? "Base58EncodedAddress",
1062
+ encoding: getMemoizedBase58Encoder(),
1063
+ size: 32
1064
+ }),
1065
+ (putativeAddress) => address(putativeAddress)
1066
+ );
1067
+ }
1068
+ function getAddressDecoder(config) {
1069
+ return getStringDecoder({
1070
+ description: config?.description ?? "Base58EncodedAddress",
1071
+ encoding: getMemoizedBase58Decoder(),
692
1072
  size: 32
693
1073
  });
694
1074
  }
695
- function getBase58EncodedAddressComparator() {
1075
+ function getAddressCodec(config) {
1076
+ return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
1077
+ }
1078
+ function getAddressComparator() {
696
1079
  return new Intl.Collator("en", {
697
1080
  caseFirst: "lower",
698
1081
  ignorePunctuation: false,
@@ -708,20 +1091,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
708
1091
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
709
1092
  }
710
1093
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
711
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
1094
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
712
1095
  return base58EncodedAddress;
713
1096
  }
714
1097
 
715
- // ../keys/dist/index.browser.js
716
- async function signBytes(key, data) {
717
- await assertSigningCapabilityIsAvailable();
718
- const signedData = await crypto.subtle.sign("Ed25519", key, data);
719
- return new Uint8Array(signedData);
720
- }
721
-
722
1098
  // src/accounts.ts
723
- function upsert(addressMap, address, update) {
724
- addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
1099
+ function upsert(addressMap, address2, update) {
1100
+ addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
725
1101
  }
726
1102
  var TYPE = Symbol("AddressMapTypeProperty");
727
1103
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -772,7 +1148,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
772
1148
  const shouldReplaceEntry = (
773
1149
  // Consider using the new LOOKUP_TABLE if its address is different...
774
1150
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
775
- (addressComparator || (addressComparator = getBase58EncodedAddressComparator()))(
1151
+ (addressComparator || (addressComparator = getAddressComparator()))(
776
1152
  accountMeta.lookupTableAddress,
777
1153
  entry.lookupTableAddress
778
1154
  ) < 0
@@ -878,14 +1254,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
878
1254
  if (leftIsWritable !== isWritableRole(rightEntry.role)) {
879
1255
  return leftIsWritable ? -1 : 1;
880
1256
  }
881
- addressComparator || (addressComparator = getBase58EncodedAddressComparator());
1257
+ addressComparator || (addressComparator = getAddressComparator());
882
1258
  if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
883
1259
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
884
1260
  } else {
885
1261
  return addressComparator(leftAddress, rightAddress);
886
1262
  }
887
- }).map(([address, addressMeta]) => ({
888
- address,
1263
+ }).map(([address2, addressMeta]) => ({
1264
+ address: address2,
889
1265
  ...addressMeta
890
1266
  }));
891
1267
  return orderedAccounts;
@@ -909,7 +1285,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
909
1285
  entry.readableIndices.push(account.addressIndex);
910
1286
  }
911
1287
  }
912
- return Object.keys(index).sort(getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
1288
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
913
1289
  lookupTableAddress,
914
1290
  ...index[lookupTableAddress]
915
1291
  }));
@@ -954,7 +1330,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
954
1330
  return instructions.map(({ accounts, data, programAddress }) => {
955
1331
  return {
956
1332
  programAddressIndex: accountIndex[programAddress],
957
- ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
1333
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
958
1334
  ...data ? { data } : null
959
1335
  };
960
1336
  });
@@ -972,7 +1348,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
972
1348
  function getCompiledStaticAccounts(orderedAccounts) {
973
1349
  const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
974
1350
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
975
- return orderedStaticAccounts.map(({ address }) => address);
1351
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
976
1352
  }
977
1353
 
978
1354
  // src/message.ts
@@ -989,13 +1365,41 @@ this.globalThis.solanaWeb3 = (function (exports) {
989
1365
  };
990
1366
  }
991
1367
 
1368
+ // src/compile-transaction.ts
1369
+ function getCompiledTransaction(transaction) {
1370
+ const compiledMessage = compileMessage(transaction);
1371
+ let signatures;
1372
+ if ("signatures" in transaction) {
1373
+ signatures = [];
1374
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1375
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1376
+ }
1377
+ } else {
1378
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1379
+ }
1380
+ return {
1381
+ compiledMessage,
1382
+ signatures
1383
+ };
1384
+ }
1385
+
992
1386
  // src/serializers/address-table-lookup.ts
1387
+ function addressSerializerCompat(compat) {
1388
+ const codec = getAddressCodec();
1389
+ return {
1390
+ description: compat?.description ?? codec.description,
1391
+ deserialize: codec.decode,
1392
+ fixedSize: codec.fixedSize,
1393
+ maxSize: codec.maxSize,
1394
+ serialize: codec.encode
1395
+ };
1396
+ }
993
1397
  function getAddressTableLookupCodec() {
994
1398
  return struct(
995
1399
  [
996
1400
  [
997
1401
  "lookupTableAddress",
998
- getBase58EncodedAddressCodec(
1402
+ addressSerializerCompat(
999
1403
  {
1000
1404
  description: "The address of the address lookup table account from which instruction addresses should be looked up"
1001
1405
  }
@@ -1026,38 +1430,73 @@ this.globalThis.solanaWeb3 = (function (exports) {
1026
1430
  );
1027
1431
  }
1028
1432
 
1433
+ // ../codecs-data-structures/dist/index.browser.js
1434
+ function sumCodecSizes(sizes) {
1435
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1436
+ }
1437
+ function structCodecHelper(fields, description) {
1438
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1439
+ return {
1440
+ description: description ?? `struct(${fieldDescriptions})`,
1441
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1442
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1443
+ };
1444
+ }
1445
+ function getStructEncoder(fields, options = {}) {
1446
+ return {
1447
+ ...structCodecHelper(fields, options.description),
1448
+ encode: (struct2) => {
1449
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
1450
+ return mergeBytes2(fieldBytes);
1451
+ }
1452
+ };
1453
+ }
1454
+ function getStructDecoder(fields, options = {}) {
1455
+ return {
1456
+ ...structCodecHelper(fields, options.description),
1457
+ decode: (bytes2, offset = 0) => {
1458
+ const struct2 = {};
1459
+ fields.forEach(([key, codec]) => {
1460
+ const [value, newOffset] = codec.decode(bytes2, offset);
1461
+ offset = newOffset;
1462
+ struct2[key] = value;
1463
+ });
1464
+ return [struct2, offset];
1465
+ }
1466
+ };
1467
+ }
1468
+ function getStructCodec(fields, options = {}) {
1469
+ return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
1470
+ }
1471
+
1029
1472
  // src/serializers/header.ts
1473
+ var memoizedU8Codec;
1474
+ function getMemoizedU8Codec() {
1475
+ if (!memoizedU8Codec)
1476
+ memoizedU8Codec = getU8Codec();
1477
+ return memoizedU8Codec;
1478
+ }
1479
+ function getMemoizedU8CodecDescription(description) {
1480
+ const codec = getMemoizedU8Codec();
1481
+ return {
1482
+ ...codec,
1483
+ description: description ?? codec.description
1484
+ };
1485
+ }
1486
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1487
+ var numReadonlySignerAccountsDescription = "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" ;
1488
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1489
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1030
1490
  function getMessageHeaderCodec() {
1031
- return struct(
1491
+ return getStructCodec(
1032
1492
  [
1033
- [
1034
- "numSignerAccounts",
1035
- u8(
1036
- {
1037
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
1038
- }
1039
- )
1040
- ],
1041
- [
1042
- "numReadonlySignerAccounts",
1043
- u8(
1044
- {
1045
- 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"
1046
- }
1047
- )
1048
- ],
1049
- [
1050
- "numReadonlyNonSignerAccounts",
1051
- u8(
1052
- {
1053
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
1054
- }
1055
- )
1056
- ]
1493
+ ["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
1494
+ ["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
1495
+ ["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
1057
1496
  ],
1058
1497
  {
1059
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1060
- }
1498
+ description: messageHeaderDescription
1499
+ }
1061
1500
  );
1062
1501
  }
1063
1502
 
@@ -1117,19 +1556,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
1117
1556
  );
1118
1557
  }
1119
1558
 
1120
- // src/serializers/unimplemented.ts
1121
- function getError(type, name) {
1122
- const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1123
- return new Error(
1124
- `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}`
1125
- );
1126
- }
1127
- function getUnimplementedDecoder(name) {
1128
- return () => {
1129
- throw getError("decoder", name);
1130
- };
1131
- }
1132
-
1133
1559
  // src/serializers/transaction-version.ts
1134
1560
  var VERSION_FLAG_MASK = 128;
1135
1561
  var BASE_CONFIG = {
@@ -1137,7 +1563,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1137
1563
  fixedSize: null,
1138
1564
  maxSize: 1
1139
1565
  };
1140
- function deserialize(bytes2, offset = 0) {
1566
+ function decode(bytes2, offset = 0) {
1141
1567
  const firstByte = bytes2[offset];
1142
1568
  if ((firstByte & VERSION_FLAG_MASK) === 0) {
1143
1569
  return ["legacy", offset];
@@ -1146,7 +1572,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1146
1572
  return [version, offset + 1];
1147
1573
  }
1148
1574
  }
1149
- function serialize(value) {
1575
+ function encode(value) {
1150
1576
  if (value === "legacy") {
1151
1577
  return new Uint8Array();
1152
1578
  }
@@ -1155,11 +1581,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
1155
1581
  }
1156
1582
  return new Uint8Array([value | VERSION_FLAG_MASK]);
1157
1583
  }
1158
- function getTransactionVersionCodec() {
1584
+ function getTransactionVersionDecoder() {
1159
1585
  return {
1160
1586
  ...BASE_CONFIG,
1161
- deserialize,
1162
- serialize
1587
+ decode
1588
+ };
1589
+ }
1590
+ function getTransactionVersionEncoder() {
1591
+ return {
1592
+ ...BASE_CONFIG,
1593
+ encode
1594
+ };
1595
+ }
1596
+ function getTransactionVersionCodec() {
1597
+ return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
1598
+ }
1599
+
1600
+ // src/serializers/unimplemented.ts
1601
+ function getError(type, name) {
1602
+ const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1603
+ return new Error(
1604
+ `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}`
1605
+ );
1606
+ }
1607
+ function getUnimplementedDecoder(name) {
1608
+ return () => {
1609
+ throw getError("decoder", name);
1163
1610
  };
1164
1611
  }
1165
1612
 
@@ -1169,7 +1616,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1169
1616
  fixedSize: null,
1170
1617
  maxSize: null
1171
1618
  };
1172
- function serialize2(compiledMessage) {
1619
+ function serialize(compiledMessage) {
1173
1620
  if (compiledMessage.version === "legacy") {
1174
1621
  return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
1175
1622
  } else {
@@ -1190,13 +1637,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
1190
1637
  ).serialize(compiledMessage);
1191
1638
  }
1192
1639
  }
1640
+ function toSerializer(codec) {
1641
+ return {
1642
+ description: codec.description,
1643
+ deserialize: codec.decode,
1644
+ fixedSize: codec.fixedSize,
1645
+ maxSize: codec.maxSize,
1646
+ serialize: codec.encode
1647
+ };
1648
+ }
1193
1649
  function getPreludeStructSerializerTuple() {
1194
1650
  return [
1195
- ["version", getTransactionVersionCodec()],
1196
- ["header", getMessageHeaderCodec()],
1651
+ ["version", toSerializer(getTransactionVersionCodec())],
1652
+ ["header", toSerializer(getMessageHeaderCodec())],
1197
1653
  [
1198
1654
  "staticAccounts",
1199
- array(getBase58EncodedAddressCodec(), {
1655
+ array(toSerializer(getAddressCodec()), {
1200
1656
  description: "A compact-array of static account addresses belonging to this transaction" ,
1201
1657
  size: shortU16()
1202
1658
  })
@@ -1228,10 +1684,44 @@ this.globalThis.solanaWeb3 = (function (exports) {
1228
1684
  return {
1229
1685
  ...BASE_CONFIG2,
1230
1686
  deserialize: getUnimplementedDecoder("CompiledMessage"),
1687
+ serialize
1688
+ };
1689
+ }
1690
+
1691
+ // src/serializers/transaction.ts
1692
+ var BASE_CONFIG3 = {
1693
+ description: "The wire format of a Solana transaction" ,
1694
+ fixedSize: null,
1695
+ maxSize: null
1696
+ };
1697
+ function serialize2(transaction) {
1698
+ const compiledTransaction = getCompiledTransaction(transaction);
1699
+ return struct([
1700
+ [
1701
+ "signatures",
1702
+ array(bytes({ size: 64 }), {
1703
+ ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
1704
+ size: shortU16()
1705
+ })
1706
+ ],
1707
+ ["compiledMessage", getCompiledMessageEncoder()]
1708
+ ]).serialize(compiledTransaction);
1709
+ }
1710
+ function getTransactionEncoder() {
1711
+ return {
1712
+ ...BASE_CONFIG3,
1713
+ deserialize: getUnimplementedDecoder("CompiledMessage"),
1231
1714
  serialize: serialize2
1232
1715
  };
1233
1716
  }
1234
1717
 
1718
+ // ../keys/dist/index.browser.js
1719
+ async function signBytes(key, data) {
1720
+ await assertSigningCapabilityIsAvailable();
1721
+ const signedData = await crypto.subtle.sign("Ed25519", key, data);
1722
+ return new Uint8Array(signedData);
1723
+ }
1724
+
1235
1725
  // src/signatures.ts
1236
1726
  function assertIsTransactionSignature(putativeTransactionSignature) {
1237
1727
  try {
@@ -1247,9 +1737,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
1247
1737
  if (numBytes !== 64) {
1248
1738
  throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
1249
1739
  }
1250
- } catch (e) {
1740
+ } catch (e2) {
1251
1741
  throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
1252
- cause: e
1742
+ cause: e2
1253
1743
  });
1254
1744
  }
1255
1745
  }
@@ -1308,51 +1798,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
1308
1798
  return putativeTransactionSignature;
1309
1799
  }
1310
1800
 
1311
- // src/compile-transaction.ts
1312
- function getCompiledTransaction(transaction) {
1313
- const compiledMessage = compileMessage(transaction);
1314
- let signatures;
1315
- if ("signatures" in transaction) {
1316
- signatures = [];
1317
- for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1318
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1319
- }
1320
- } else {
1321
- signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1322
- }
1323
- return {
1324
- compiledMessage,
1325
- signatures
1326
- };
1327
- }
1328
-
1329
- // src/serializers/transaction.ts
1330
- var BASE_CONFIG3 = {
1331
- description: "The wire format of a Solana transaction" ,
1332
- fixedSize: null,
1333
- maxSize: null
1334
- };
1335
- function serialize3(transaction) {
1336
- const compiledTransaction = getCompiledTransaction(transaction);
1337
- return struct([
1338
- [
1339
- "signatures",
1340
- array(bytes({ size: 64 }), {
1341
- ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
1342
- size: shortU16()
1343
- })
1344
- ],
1345
- ["compiledMessage", getCompiledMessageEncoder()]
1346
- ]).serialize(compiledTransaction);
1347
- }
1348
- function getTransactionEncoder() {
1349
- return {
1350
- ...BASE_CONFIG3,
1351
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1352
- serialize: serialize3
1353
- };
1354
- }
1355
-
1356
1801
  // src/wire-transaction.ts
1357
1802
  function getBase64EncodedWireTransaction(transaction) {
1358
1803
  const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
@@ -1368,6 +1813,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1368
1813
  exports.createTransaction = createTransaction;
1369
1814
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
1370
1815
  exports.getSignatureFromTransaction = getSignatureFromTransaction;
1816
+ exports.getTransactionEncoder = getTransactionEncoder;
1371
1817
  exports.isTransactionSignature = isTransactionSignature;
1372
1818
  exports.prependTransactionInstruction = prependTransactionInstruction;
1373
1819
  exports.setTransactionFeePayer = setTransactionFeePayer;