@solana/web3.js 2.0.0-experimental.f464b8b → 2.0.0-experimental.f8b14a7

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.
@@ -12,8 +12,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
12
12
  var __esm = (fn, res) => function __init() {
13
13
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
14
14
  };
15
- var __commonJS = (cb, mod) => function __require() {
16
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ var __commonJS = (cb, mod2) => function __require() {
16
+ return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
17
17
  };
18
18
  var __copyProps = (to, from, except, desc) => {
19
19
  if (from && typeof from === "object" || typeof from === "function") {
@@ -23,13 +23,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
23
23
  }
24
24
  return to;
25
25
  };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
27
27
  // If the importer is in node compatibility mode or this is not an ESM
28
28
  // file that has been converted to a CommonJS file using a Babel-
29
29
  // compatible transform (i.e. "__esModule" has not been set), then set
30
30
  // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
31
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
32
+ mod2
33
33
  ));
34
34
  var __publicField = (obj, key, value) => {
35
35
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -122,44 +122,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
122
122
  // src/index.ts
123
123
  init_env_shim();
124
124
 
125
- // ../instructions/dist/index.browser.js
126
- init_env_shim();
127
- var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
128
- AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
129
- 3] = "WRITABLE_SIGNER";
130
- AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
131
- 2] = "READONLY_SIGNER";
132
- AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
133
- 1] = "WRITABLE";
134
- AccountRole22[AccountRole22["READONLY"] = /* 0 */
135
- 0] = "READONLY";
136
- return AccountRole22;
137
- })(AccountRole || {});
138
- var IS_SIGNER_BITMASK = 2;
139
- var IS_WRITABLE_BITMASK = 1;
140
- function downgradeRoleToNonSigner(role) {
141
- return role & ~IS_SIGNER_BITMASK;
142
- }
143
- function downgradeRoleToReadonly(role) {
144
- return role & ~IS_WRITABLE_BITMASK;
145
- }
146
- function isSignerRole(role) {
147
- return role >= 2;
148
- }
149
- function isWritableRole(role) {
150
- return (role & IS_WRITABLE_BITMASK) !== 0;
151
- }
152
- function mergeRoles(roleA, roleB) {
153
- return roleA | roleB;
154
- }
155
- function upgradeRoleToSigner(role) {
156
- return role | IS_SIGNER_BITMASK;
157
- }
158
- function upgradeRoleToWritable(role) {
159
- return role | IS_WRITABLE_BITMASK;
160
- }
161
-
162
- // ../keys/dist/index.browser.js
125
+ // ../addresses/dist/index.browser.js
163
126
  init_env_shim();
164
127
 
165
128
  // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
@@ -685,43 +648,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
685
648
  }
686
649
  };
687
650
  }
688
- function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
689
- try {
690
- if (
691
- // Lowest address (32 bytes of zeroes)
692
- putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
693
- putativeBase58EncodedAddress.length > 44
694
- ) {
695
- throw new Error("Expected input string to decode to a byte array of length 32.");
696
- }
697
- const bytes2 = base58.serialize(putativeBase58EncodedAddress);
698
- const numBytes = bytes2.byteLength;
699
- if (numBytes !== 32) {
700
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
701
- }
702
- } catch (e2) {
703
- throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
704
- cause: e2
705
- });
706
- }
707
- }
708
- function getBase58EncodedAddressCodec(config) {
709
- return string({
710
- description: config?.description ?? ("A 32-byte account address" ),
711
- encoding: base58,
712
- size: 32
713
- });
714
- }
715
- function getBase58EncodedAddressComparator() {
716
- return new Intl.Collator("en", {
717
- caseFirst: "lower",
718
- ignorePunctuation: false,
719
- localeMatcher: "best fit",
720
- numeric: false,
721
- sensitivity: "variant",
722
- usage: "sort"
723
- }).compare;
724
- }
651
+
652
+ // ../assertions/dist/index.browser.js
653
+ init_env_shim();
725
654
  function assertIsSecureContext() {
726
655
  if (!globalThis.isSecureContext) {
727
656
  throw new Error(
@@ -751,6 +680,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
751
680
  return await cachedEd25519Decision;
752
681
  }
753
682
  }
683
+ async function assertDigestCapabilityIsAvailable() {
684
+ assertIsSecureContext();
685
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
686
+ throw new Error("No digest implementation could be found");
687
+ }
688
+ }
754
689
  async function assertKeyGenerationIsAvailable() {
755
690
  assertIsSecureContext();
756
691
  if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
@@ -780,6 +715,253 @@ this.globalThis.solanaWeb3 = (function (exports) {
780
715
  throw new Error("No signature verification implementation could be found");
781
716
  }
782
717
  }
718
+ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
719
+ try {
720
+ if (
721
+ // Lowest address (32 bytes of zeroes)
722
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
723
+ putativeBase58EncodedAddress.length > 44
724
+ ) {
725
+ throw new Error("Expected input string to decode to a byte array of length 32.");
726
+ }
727
+ const bytes2 = base58.serialize(putativeBase58EncodedAddress);
728
+ const numBytes = bytes2.byteLength;
729
+ if (numBytes !== 32) {
730
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
731
+ }
732
+ } catch (e2) {
733
+ throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
734
+ cause: e2
735
+ });
736
+ }
737
+ }
738
+ function getBase58EncodedAddressCodec(config) {
739
+ return string({
740
+ description: config?.description ?? ("A 32-byte account address" ),
741
+ encoding: base58,
742
+ size: 32
743
+ });
744
+ }
745
+ function getBase58EncodedAddressComparator() {
746
+ return new Intl.Collator("en", {
747
+ caseFirst: "lower",
748
+ ignorePunctuation: false,
749
+ localeMatcher: "best fit",
750
+ numeric: false,
751
+ sensitivity: "variant",
752
+ usage: "sort"
753
+ }).compare;
754
+ }
755
+ var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
756
+ var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
757
+ var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
758
+ function mod(a) {
759
+ const r = a % P;
760
+ return r >= 0n ? r : P + r;
761
+ }
762
+ function pow2(x, power) {
763
+ let r = x;
764
+ while (power-- > 0n) {
765
+ r *= r;
766
+ r %= P;
767
+ }
768
+ return r;
769
+ }
770
+ function pow_2_252_3(x) {
771
+ const x2 = x * x % P;
772
+ const b2 = x2 * x % P;
773
+ const b4 = pow2(b2, 2n) * b2 % P;
774
+ const b5 = pow2(b4, 1n) * x % P;
775
+ const b10 = pow2(b5, 5n) * b5 % P;
776
+ const b20 = pow2(b10, 10n) * b10 % P;
777
+ const b40 = pow2(b20, 20n) * b20 % P;
778
+ const b80 = pow2(b40, 40n) * b40 % P;
779
+ const b160 = pow2(b80, 80n) * b80 % P;
780
+ const b240 = pow2(b160, 80n) * b80 % P;
781
+ const b250 = pow2(b240, 10n) * b10 % P;
782
+ const pow_p_5_8 = pow2(b250, 2n) * x % P;
783
+ return pow_p_5_8;
784
+ }
785
+ function uvRatio(u, v) {
786
+ const v3 = mod(v * v * v);
787
+ const v7 = mod(v3 * v3 * v);
788
+ const pow = pow_2_252_3(u * v7);
789
+ let x = mod(u * v3 * pow);
790
+ const vx2 = mod(v * x * x);
791
+ const root1 = x;
792
+ const root2 = mod(x * RM1);
793
+ const useRoot1 = vx2 === u;
794
+ const useRoot2 = vx2 === mod(-u);
795
+ const noRoot = vx2 === mod(-u * RM1);
796
+ if (useRoot1)
797
+ x = root1;
798
+ if (useRoot2 || noRoot)
799
+ x = root2;
800
+ if ((mod(x) & 1n) === 1n)
801
+ x = mod(-x);
802
+ if (!useRoot1 && !useRoot2) {
803
+ return null;
804
+ }
805
+ return x;
806
+ }
807
+ function pointIsOnCurve(y, lastByte) {
808
+ const y2 = mod(y * y);
809
+ const u = mod(y2 - 1n);
810
+ const v = mod(D * y2 + 1n);
811
+ const x = uvRatio(u, v);
812
+ if (x === null) {
813
+ return false;
814
+ }
815
+ const isLastByteOdd = (lastByte & 128) !== 0;
816
+ if (x === 0n && isLastByteOdd) {
817
+ return false;
818
+ }
819
+ return true;
820
+ }
821
+ function byteToHex(byte) {
822
+ const hexString = byte.toString(16);
823
+ if (hexString.length === 1) {
824
+ return `0${hexString}`;
825
+ } else {
826
+ return hexString;
827
+ }
828
+ }
829
+ function decompressPointBytes(bytes2) {
830
+ const hexString = bytes2.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
831
+ const integerLiteralString = `0x${hexString}`;
832
+ return BigInt(integerLiteralString);
833
+ }
834
+ async function compressedPointBytesAreOnCurve(bytes2) {
835
+ if (bytes2.byteLength !== 32) {
836
+ return false;
837
+ }
838
+ const y = decompressPointBytes(bytes2);
839
+ return pointIsOnCurve(y, bytes2[31]);
840
+ }
841
+ var MAX_SEED_LENGTH = 32;
842
+ var MAX_SEEDS = 16;
843
+ var PDA_MARKER_BYTES = [
844
+ // The string 'ProgramDerivedAddress'
845
+ 80,
846
+ 114,
847
+ 111,
848
+ 103,
849
+ 114,
850
+ 97,
851
+ 109,
852
+ 68,
853
+ 101,
854
+ 114,
855
+ 105,
856
+ 118,
857
+ 101,
858
+ 100,
859
+ 65,
860
+ 100,
861
+ 100,
862
+ 114,
863
+ 101,
864
+ 115,
865
+ 115
866
+ ];
867
+ var PointOnCurveError = class extends Error {
868
+ };
869
+ async function createProgramDerivedAddress({ programAddress, seeds }) {
870
+ await assertDigestCapabilityIsAvailable();
871
+ if (seeds.length > MAX_SEEDS) {
872
+ throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
873
+ }
874
+ let textEncoder;
875
+ const seedBytes = seeds.reduce((acc, seed, ii) => {
876
+ const bytes2 = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
877
+ if (bytes2.byteLength > MAX_SEED_LENGTH) {
878
+ throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
879
+ }
880
+ acc.push(...bytes2);
881
+ return acc;
882
+ }, []);
883
+ const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
884
+ const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
885
+ const addressBytesBuffer = await crypto.subtle.digest(
886
+ "SHA-256",
887
+ new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
888
+ );
889
+ const addressBytes = new Uint8Array(addressBytesBuffer);
890
+ if (await compressedPointBytesAreOnCurve(addressBytes)) {
891
+ throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
892
+ }
893
+ return base58EncodedAddressCodec.deserialize(addressBytes)[0];
894
+ }
895
+ async function getProgramDerivedAddress({ programAddress, seeds }) {
896
+ let bumpSeed = 255;
897
+ while (bumpSeed > 0) {
898
+ try {
899
+ return {
900
+ bumpSeed,
901
+ pda: await createProgramDerivedAddress({
902
+ programAddress,
903
+ seeds: [...seeds, new Uint8Array([bumpSeed])]
904
+ })
905
+ };
906
+ } catch (e2) {
907
+ if (e2 instanceof PointOnCurveError) {
908
+ bumpSeed--;
909
+ } else {
910
+ throw e2;
911
+ }
912
+ }
913
+ }
914
+ throw new Error("Unable to find a viable program address bump seed");
915
+ }
916
+ async function getBase58EncodedAddressFromPublicKey(publicKey) {
917
+ await assertKeyExporterIsAvailable();
918
+ if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
919
+ throw new Error("The `CryptoKey` must be an `Ed25519` public key");
920
+ }
921
+ const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
922
+ const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
923
+ return base58EncodedAddress;
924
+ }
925
+
926
+ // ../instructions/dist/index.browser.js
927
+ init_env_shim();
928
+ var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
929
+ AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
930
+ 3] = "WRITABLE_SIGNER";
931
+ AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
932
+ 2] = "READONLY_SIGNER";
933
+ AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
934
+ 1] = "WRITABLE";
935
+ AccountRole22[AccountRole22["READONLY"] = /* 0 */
936
+ 0] = "READONLY";
937
+ return AccountRole22;
938
+ })(AccountRole || {});
939
+ var IS_SIGNER_BITMASK = 2;
940
+ var IS_WRITABLE_BITMASK = 1;
941
+ function downgradeRoleToNonSigner(role) {
942
+ return role & ~IS_SIGNER_BITMASK;
943
+ }
944
+ function downgradeRoleToReadonly(role) {
945
+ return role & ~IS_WRITABLE_BITMASK;
946
+ }
947
+ function isSignerRole(role) {
948
+ return role >= 2;
949
+ }
950
+ function isWritableRole(role) {
951
+ return (role & IS_WRITABLE_BITMASK) !== 0;
952
+ }
953
+ function mergeRoles(roleA, roleB) {
954
+ return roleA | roleB;
955
+ }
956
+ function upgradeRoleToSigner(role) {
957
+ return role | IS_SIGNER_BITMASK;
958
+ }
959
+ function upgradeRoleToWritable(role) {
960
+ return role | IS_WRITABLE_BITMASK;
961
+ }
962
+
963
+ // ../keys/dist/index.browser.js
964
+ init_env_shim();
783
965
  async function generateKeyPair() {
784
966
  await assertKeyGenerationIsAvailable();
785
967
  const keyPair = await crypto.subtle.generateKey(
@@ -794,15 +976,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
794
976
  );
795
977
  return keyPair;
796
978
  }
797
- async function getBase58EncodedAddressFromPublicKey(publicKey) {
798
- await assertKeyExporterIsAvailable();
799
- if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
800
- throw new Error("The `CryptoKey` must be an `Ed25519` public key");
801
- }
802
- const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
803
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
804
- return base58EncodedAddress;
805
- }
806
979
  async function signBytes(key, data) {
807
980
  await assertSigningCapabilityIsAvailable();
808
981
  const signedData = await crypto.subtle.sign("Ed25519", key, data);
@@ -815,6 +988,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
815
988
 
816
989
  // ../transactions/dist/index.browser.js
817
990
  init_env_shim();
991
+ function getUnsignedTransaction(transaction) {
992
+ if ("signatures" in transaction) {
993
+ const {
994
+ signatures: _,
995
+ // eslint-disable-line @typescript-eslint/no-unused-vars
996
+ ...unsignedTransaction
997
+ } = transaction;
998
+ return unsignedTransaction;
999
+ } else {
1000
+ return transaction;
1001
+ }
1002
+ }
818
1003
  function assertIsBlockhash(putativeBlockhash) {
819
1004
  try {
820
1005
  if (
@@ -835,6 +1020,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
835
1020
  });
836
1021
  }
837
1022
  }
1023
+ function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
1024
+ if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
1025
+ return transaction;
1026
+ }
1027
+ const out = {
1028
+ ...getUnsignedTransaction(transaction),
1029
+ lifetimeConstraint: blockhashLifetimeConstraint
1030
+ };
1031
+ Object.freeze(out);
1032
+ return out;
1033
+ }
838
1034
  function createTransaction({
839
1035
  version
840
1036
  }) {
@@ -845,62 +1041,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
845
1041
  Object.freeze(out);
846
1042
  return out;
847
1043
  }
848
- function setTransactionFeePayer(feePayer, transaction) {
849
- if ("feePayer" in transaction && feePayer === transaction.feePayer) {
850
- return transaction;
851
- }
852
- let out;
853
- if ("signatures" in transaction) {
854
- const {
855
- signatures: _,
856
- // eslint-disable-line @typescript-eslint/no-unused-vars
857
- ...unsignedTransaction
858
- } = transaction;
859
- out = {
860
- ...unsignedTransaction,
861
- feePayer
862
- };
863
- } else {
864
- out = {
865
- ...transaction,
866
- feePayer
867
- };
868
- }
869
- Object.freeze(out);
870
- return out;
871
- }
872
- function replaceInstructions(transaction, nextInstructions) {
873
- let out;
874
- if ("signatures" in transaction) {
875
- const {
876
- signatures: _,
877
- // eslint-disable-line @typescript-eslint/no-unused-vars
878
- ...unsignedTransaction
879
- } = transaction;
880
- out = {
881
- ...unsignedTransaction,
882
- instructions: nextInstructions
883
- };
884
- } else {
885
- out = {
886
- ...transaction,
887
- instructions: nextInstructions
888
- };
889
- }
890
- return out;
891
- }
892
- function appendTransactionInstruction(instruction, transaction) {
893
- const nextInstructions = [...transaction.instructions, instruction];
894
- const out = replaceInstructions(transaction, nextInstructions);
895
- Object.freeze(out);
896
- return out;
897
- }
898
- function prependTransactionInstruction(instruction, transaction) {
899
- const nextInstructions = [instruction, ...transaction.instructions];
900
- const out = replaceInstructions(transaction, nextInstructions);
901
- Object.freeze(out);
902
- return out;
903
- }
904
1044
  var AccountRole2 = /* @__PURE__ */ ((AccountRole22) => {
905
1045
  AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
906
1046
  3] = "WRITABLE_SIGNER";
@@ -922,6 +1062,90 @@ this.globalThis.solanaWeb3 = (function (exports) {
922
1062
  function mergeRoles2(roleA, roleB) {
923
1063
  return roleA | roleB;
924
1064
  }
1065
+ var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
1066
+ var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
1067
+ function assertIsDurableNonceTransaction(transaction) {
1068
+ if (!isDurableNonceTransaction(transaction)) {
1069
+ throw new Error("Transaction is not a durable nonce transaction");
1070
+ }
1071
+ }
1072
+ function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
1073
+ return {
1074
+ accounts: [
1075
+ { address: nonceAccountAddress, role: AccountRole2.WRITABLE },
1076
+ {
1077
+ address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
1078
+ role: AccountRole2.READONLY
1079
+ },
1080
+ { address: nonceAuthorityAddress, role: AccountRole2.READONLY_SIGNER }
1081
+ ],
1082
+ data: new Uint8Array([4, 0, 0, 0]),
1083
+ programAddress: SYSTEM_PROGRAM_ADDRESS
1084
+ };
1085
+ }
1086
+ function isAdvanceNonceAccountInstruction(instruction) {
1087
+ return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
1088
+ instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
1089
+ instruction.accounts?.length === 3 && // First account is nonce account address
1090
+ instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
1091
+ instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
1092
+ instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole2.READONLY_SIGNER;
1093
+ }
1094
+ function isAdvanceNonceAccountInstructionData(data) {
1095
+ return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
1096
+ }
1097
+ function isDurableNonceTransaction(transaction) {
1098
+ return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
1099
+ }
1100
+ function setTransactionLifetimeUsingDurableNonce({
1101
+ nonce,
1102
+ nonceAccountAddress,
1103
+ nonceAuthorityAddress
1104
+ }, transaction) {
1105
+ const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
1106
+ if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
1107
+ return transaction;
1108
+ }
1109
+ const out = {
1110
+ ...getUnsignedTransaction(transaction),
1111
+ instructions: [
1112
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1113
+ ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
1114
+ ],
1115
+ lifetimeConstraint: {
1116
+ nonce
1117
+ }
1118
+ };
1119
+ Object.freeze(out);
1120
+ return out;
1121
+ }
1122
+ function setTransactionFeePayer(feePayer, transaction) {
1123
+ if ("feePayer" in transaction && feePayer === transaction.feePayer) {
1124
+ return transaction;
1125
+ }
1126
+ const out = {
1127
+ ...getUnsignedTransaction(transaction),
1128
+ feePayer
1129
+ };
1130
+ Object.freeze(out);
1131
+ return out;
1132
+ }
1133
+ function appendTransactionInstruction(instruction, transaction) {
1134
+ const out = {
1135
+ ...getUnsignedTransaction(transaction),
1136
+ instructions: [...transaction.instructions, instruction]
1137
+ };
1138
+ Object.freeze(out);
1139
+ return out;
1140
+ }
1141
+ function prependTransactionInstruction(instruction, transaction) {
1142
+ const out = {
1143
+ ...getUnsignedTransaction(transaction),
1144
+ instructions: [instruction, ...transaction.instructions]
1145
+ };
1146
+ Object.freeze(out);
1147
+ return out;
1148
+ }
925
1149
  function upsert(addressMap, address, update) {
926
1150
  addressMap[address] = update(addressMap[address] ?? { role: AccountRole2.READONLY });
927
1151
  }
@@ -1955,6 +2179,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1955
2179
  exports.appendTransactionInstruction = appendTransactionInstruction;
1956
2180
  exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
1957
2181
  exports.assertIsBlockhash = assertIsBlockhash;
2182
+ exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
1958
2183
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
1959
2184
  exports.createSolanaRpc = createSolanaRpc;
1960
2185
  exports.createTransaction = createTransaction;
@@ -1965,11 +2190,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1965
2190
  exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
1966
2191
  exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
1967
2192
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
2193
+ exports.getProgramDerivedAddress = getProgramDerivedAddress;
1968
2194
  exports.isSignerRole = isSignerRole;
1969
2195
  exports.isWritableRole = isWritableRole;
1970
2196
  exports.mergeRoles = mergeRoles;
1971
2197
  exports.prependTransactionInstruction = prependTransactionInstruction;
1972
2198
  exports.setTransactionFeePayer = setTransactionFeePayer;
2199
+ exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
2200
+ exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
1973
2201
  exports.signBytes = signBytes;
1974
2202
  exports.signTransaction = signTransaction;
1975
2203
  exports.upgradeRoleToSigner = upgradeRoleToSigner;