@solana/web3.js 1.47.5 → 1.48.1

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/lib/index.iife.js CHANGED
@@ -11444,7 +11444,69 @@ var solanaWeb3 = (function (exports) {
11444
11444
  }
11445
11445
  }
11446
11446
 
11447
- const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
11447
+ var browser$1 = {};
11448
+
11449
+ Object.defineProperty(browser$1, "__esModule", { value: true });
11450
+ /**
11451
+ * Convert a little-endian buffer into a BigInt.
11452
+ * @param buf The little-endian buffer to convert
11453
+ * @returns A BigInt with the little-endian representation of buf.
11454
+ */
11455
+ function toBigIntLE(buf) {
11456
+ {
11457
+ const reversed = Buffer.from(buf);
11458
+ reversed.reverse();
11459
+ const hex = reversed.toString('hex');
11460
+ if (hex.length === 0) {
11461
+ return BigInt(0);
11462
+ }
11463
+ return BigInt(`0x${hex}`);
11464
+ }
11465
+ }
11466
+ var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
11467
+ /**
11468
+ * Convert a big-endian buffer into a BigInt
11469
+ * @param buf The big-endian buffer to convert.
11470
+ * @returns A BigInt with the big-endian representation of buf.
11471
+ */
11472
+ function toBigIntBE(buf) {
11473
+ {
11474
+ const hex = buf.toString('hex');
11475
+ if (hex.length === 0) {
11476
+ return BigInt(0);
11477
+ }
11478
+ return BigInt(`0x${hex}`);
11479
+ }
11480
+ }
11481
+ browser$1.toBigIntBE = toBigIntBE;
11482
+ /**
11483
+ * Convert a BigInt to a little-endian buffer.
11484
+ * @param num The BigInt to convert.
11485
+ * @param width The number of bytes that the resulting buffer should be.
11486
+ * @returns A little-endian buffer representation of num.
11487
+ */
11488
+ function toBufferLE(num, width) {
11489
+ {
11490
+ const hex = num.toString(16);
11491
+ const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
11492
+ buffer.reverse();
11493
+ return buffer;
11494
+ }
11495
+ }
11496
+ var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
11497
+ /**
11498
+ * Convert a BigInt to a big-endian buffer.
11499
+ * @param num The BigInt to convert.
11500
+ * @param width The number of bytes that the resulting buffer should be.
11501
+ * @returns A big-endian buffer representation of num.
11502
+ */
11503
+ function toBufferBE(num, width) {
11504
+ {
11505
+ const hex = num.toString(16);
11506
+ return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
11507
+ }
11508
+ }
11509
+ browser$1.toBufferBE = toBufferBE;
11448
11510
 
11449
11511
  var Layout$1 = {};
11450
11512
 
@@ -13729,16 +13791,6 @@ var solanaWeb3 = (function (exports) {
13729
13791
  /** Factory for {@link Constant} values. */
13730
13792
  Layout$1.constant = ((value, property) => new Constant(value, property));
13731
13793
 
13732
- /**
13733
- * Maximum over-the-wire size of a Transaction
13734
- *
13735
- * 1280 is IPv6 minimum MTU
13736
- * 40 bytes is the size of the IPv6 header
13737
- * 8 bytes is the size of the fragment header
13738
- */
13739
- const PACKET_DATA_SIZE = 1280 - 40 - 8;
13740
- const SIGNATURE_LENGTH_IN_BYTES = 64;
13741
-
13742
13794
  /**
13743
13795
  * Layout for a public key
13744
13796
  */
@@ -13790,17 +13842,159 @@ var solanaWeb3 = (function (exports) {
13790
13842
  return struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), u8('commission')], property);
13791
13843
  };
13792
13844
  function getAlloc(type, fields) {
13793
- let alloc = 0;
13794
- type.layout.fields.forEach(item => {
13845
+ const getItemAlloc = item => {
13795
13846
  if (item.span >= 0) {
13796
- alloc += item.span;
13847
+ return item.span;
13797
13848
  } else if (typeof item.alloc === 'function') {
13798
- alloc += item.alloc(fields[item.property]);
13849
+ return item.alloc(fields[item.property]);
13850
+ } else if ('count' in item && 'elementLayout' in item) {
13851
+ const field = fields[item.property];
13852
+ if (Array.isArray(field)) {
13853
+ return field.length * getItemAlloc(item.elementLayout);
13854
+ }
13799
13855
  }
13856
+ // Couldn't determine allocated size of layout
13857
+ return 0;
13858
+ };
13859
+ let alloc = 0;
13860
+ type.layout.fields.forEach(item => {
13861
+ alloc += getItemAlloc(item);
13800
13862
  });
13801
13863
  return alloc;
13802
13864
  }
13803
13865
 
13866
+ const encodeDecode = layout => {
13867
+ const decode = layout.decode.bind(layout);
13868
+ const encode = layout.encode.bind(layout);
13869
+ return {
13870
+ decode,
13871
+ encode
13872
+ };
13873
+ };
13874
+ const bigInt = length => property => {
13875
+ const layout = blob(length, property);
13876
+ const {
13877
+ encode,
13878
+ decode
13879
+ } = encodeDecode(layout);
13880
+ const bigIntLayout = layout;
13881
+ bigIntLayout.decode = (buffer$1, offset) => {
13882
+ const src = decode(buffer$1, offset);
13883
+ return toBigIntLE_1(buffer.Buffer.from(src));
13884
+ };
13885
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
13886
+ const src = toBufferLE_1(bigInt, length);
13887
+ return encode(src, buffer, offset);
13888
+ };
13889
+ return bigIntLayout;
13890
+ };
13891
+ const u64 = bigInt(8);
13892
+
13893
+ /**
13894
+ * @internal
13895
+ */
13896
+
13897
+ /**
13898
+ * Populate a buffer of instruction data using an InstructionType
13899
+ * @internal
13900
+ */
13901
+ function encodeData(type, fields) {
13902
+ const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
13903
+ const data = buffer.Buffer.alloc(allocLength);
13904
+ const layoutFields = Object.assign({
13905
+ instruction: type.index
13906
+ }, fields);
13907
+ type.layout.encode(layoutFields, data);
13908
+ return data;
13909
+ }
13910
+
13911
+ /**
13912
+ * Decode instruction data buffer using an InstructionType
13913
+ * @internal
13914
+ */
13915
+ function decodeData(type, buffer) {
13916
+ let data;
13917
+ try {
13918
+ data = type.layout.decode(buffer);
13919
+ } catch (err) {
13920
+ throw new Error('invalid instruction; ' + err);
13921
+ }
13922
+ if (data.instruction !== type.index) {
13923
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
13924
+ }
13925
+ return data;
13926
+ }
13927
+
13928
+ /**
13929
+ * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
13930
+ *
13931
+ * @internal
13932
+ */
13933
+ const FeeCalculatorLayout = nu64('lamportsPerSignature');
13934
+
13935
+ /**
13936
+ * Calculator for transaction fees.
13937
+ */
13938
+
13939
+ /**
13940
+ * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
13941
+ *
13942
+ * @internal
13943
+ */
13944
+ const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
13945
+ const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
13946
+ /**
13947
+ * NonceAccount class
13948
+ */
13949
+ class NonceAccount {
13950
+ /**
13951
+ * @internal
13952
+ */
13953
+ constructor(args) {
13954
+ this.authorizedPubkey = void 0;
13955
+ this.nonce = void 0;
13956
+ this.feeCalculator = void 0;
13957
+ this.authorizedPubkey = args.authorizedPubkey;
13958
+ this.nonce = args.nonce;
13959
+ this.feeCalculator = args.feeCalculator;
13960
+ }
13961
+
13962
+ /**
13963
+ * Deserialize NonceAccount from the account data.
13964
+ *
13965
+ * @param buffer account data
13966
+ * @return NonceAccount
13967
+ */
13968
+ static fromAccountData(buffer) {
13969
+ const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
13970
+ return new NonceAccount({
13971
+ authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
13972
+ nonce: new PublicKey(nonceAccount.nonce).toString(),
13973
+ feeCalculator: nonceAccount.feeCalculator
13974
+ });
13975
+ }
13976
+ }
13977
+
13978
+ const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
13979
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
13980
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
13981
+ const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
13982
+ const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
13983
+ const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
13984
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
13985
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
13986
+ const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
13987
+
13988
+ /**
13989
+ * Maximum over-the-wire size of a Transaction
13990
+ *
13991
+ * 1280 is IPv6 minimum MTU
13992
+ * 40 bytes is the size of the IPv6 header
13993
+ * 8 bytes is the size of the fragment header
13994
+ */
13995
+ const PACKET_DATA_SIZE = 1280 - 40 - 8;
13996
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
13997
+
13804
13998
  function decodeLength(bytes) {
13805
13999
  let len = 0;
13806
14000
  let size = 0;
@@ -14719,229 +14913,8 @@ var solanaWeb3 = (function (exports) {
14719
14913
  }
14720
14914
  }
14721
14915
 
14722
- const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
14723
- const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
14724
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
14725
- const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
14726
- const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
14727
- const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
14728
- const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
14729
- const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
14730
- const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
14731
-
14732
14916
  /**
14733
- * Sign, send and confirm a transaction.
14734
- *
14735
- * If `commitment` option is not specified, defaults to 'max' commitment.
14736
- *
14737
- * @param {Connection} connection
14738
- * @param {Transaction} transaction
14739
- * @param {Array<Signer>} signers
14740
- * @param {ConfirmOptions} [options]
14741
- * @returns {Promise<TransactionSignature>}
14742
- */
14743
- async function sendAndConfirmTransaction(connection, transaction, signers, options) {
14744
- const sendOptions = options && {
14745
- skipPreflight: options.skipPreflight,
14746
- preflightCommitment: options.preflightCommitment || options.commitment,
14747
- maxRetries: options.maxRetries,
14748
- minContextSlot: options.minContextSlot
14749
- };
14750
- const signature = await connection.sendTransaction(transaction, signers, sendOptions);
14751
- const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
14752
- signature: signature,
14753
- blockhash: transaction.recentBlockhash,
14754
- lastValidBlockHeight: transaction.lastValidBlockHeight
14755
- }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
14756
- if (status.err) {
14757
- throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
14758
- }
14759
- return signature;
14760
- }
14761
-
14762
- // zzz
14763
- function sleep(ms) {
14764
- return new Promise(resolve => setTimeout(resolve, ms));
14765
- }
14766
-
14767
- /**
14768
- * @internal
14769
- */
14770
-
14771
- /**
14772
- * Populate a buffer of instruction data using an InstructionType
14773
- * @internal
14774
- */
14775
- function encodeData(type, fields) {
14776
- const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
14777
- const data = buffer.Buffer.alloc(allocLength);
14778
- const layoutFields = Object.assign({
14779
- instruction: type.index
14780
- }, fields);
14781
- type.layout.encode(layoutFields, data);
14782
- return data;
14783
- }
14784
-
14785
- /**
14786
- * Decode instruction data buffer using an InstructionType
14787
- * @internal
14788
- */
14789
- function decodeData(type, buffer) {
14790
- let data;
14791
- try {
14792
- data = type.layout.decode(buffer);
14793
- } catch (err) {
14794
- throw new Error('invalid instruction; ' + err);
14795
- }
14796
- if (data.instruction !== type.index) {
14797
- throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
14798
- }
14799
- return data;
14800
- }
14801
-
14802
- /**
14803
- * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
14804
- *
14805
- * @internal
14806
- */
14807
- const FeeCalculatorLayout = nu64('lamportsPerSignature');
14808
-
14809
- /**
14810
- * Calculator for transaction fees.
14811
- */
14812
-
14813
- /**
14814
- * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
14815
- *
14816
- * @internal
14817
- */
14818
- const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
14819
- const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
14820
- /**
14821
- * NonceAccount class
14822
- */
14823
- class NonceAccount {
14824
- /**
14825
- * @internal
14826
- */
14827
- constructor(args) {
14828
- this.authorizedPubkey = void 0;
14829
- this.nonce = void 0;
14830
- this.feeCalculator = void 0;
14831
- this.authorizedPubkey = args.authorizedPubkey;
14832
- this.nonce = args.nonce;
14833
- this.feeCalculator = args.feeCalculator;
14834
- }
14835
-
14836
- /**
14837
- * Deserialize NonceAccount from the account data.
14838
- *
14839
- * @param buffer account data
14840
- * @return NonceAccount
14841
- */
14842
- static fromAccountData(buffer) {
14843
- const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
14844
- return new NonceAccount({
14845
- authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
14846
- nonce: new PublicKey(nonceAccount.nonce).toString(),
14847
- feeCalculator: nonceAccount.feeCalculator
14848
- });
14849
- }
14850
- }
14851
-
14852
- var browser$1 = {};
14853
-
14854
- Object.defineProperty(browser$1, "__esModule", { value: true });
14855
- /**
14856
- * Convert a little-endian buffer into a BigInt.
14857
- * @param buf The little-endian buffer to convert
14858
- * @returns A BigInt with the little-endian representation of buf.
14859
- */
14860
- function toBigIntLE(buf) {
14861
- {
14862
- const reversed = Buffer.from(buf);
14863
- reversed.reverse();
14864
- const hex = reversed.toString('hex');
14865
- if (hex.length === 0) {
14866
- return BigInt(0);
14867
- }
14868
- return BigInt(`0x${hex}`);
14869
- }
14870
- }
14871
- var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
14872
- /**
14873
- * Convert a big-endian buffer into a BigInt
14874
- * @param buf The big-endian buffer to convert.
14875
- * @returns A BigInt with the big-endian representation of buf.
14876
- */
14877
- function toBigIntBE(buf) {
14878
- {
14879
- const hex = buf.toString('hex');
14880
- if (hex.length === 0) {
14881
- return BigInt(0);
14882
- }
14883
- return BigInt(`0x${hex}`);
14884
- }
14885
- }
14886
- browser$1.toBigIntBE = toBigIntBE;
14887
- /**
14888
- * Convert a BigInt to a little-endian buffer.
14889
- * @param num The BigInt to convert.
14890
- * @param width The number of bytes that the resulting buffer should be.
14891
- * @returns A little-endian buffer representation of num.
14892
- */
14893
- function toBufferLE(num, width) {
14894
- {
14895
- const hex = num.toString(16);
14896
- const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
14897
- buffer.reverse();
14898
- return buffer;
14899
- }
14900
- }
14901
- var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
14902
- /**
14903
- * Convert a BigInt to a big-endian buffer.
14904
- * @param num The BigInt to convert.
14905
- * @param width The number of bytes that the resulting buffer should be.
14906
- * @returns A big-endian buffer representation of num.
14907
- */
14908
- function toBufferBE(num, width) {
14909
- {
14910
- const hex = num.toString(16);
14911
- return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
14912
- }
14913
- }
14914
- browser$1.toBufferBE = toBufferBE;
14915
-
14916
- const encodeDecode = layout => {
14917
- const decode = layout.decode.bind(layout);
14918
- const encode = layout.encode.bind(layout);
14919
- return {
14920
- decode,
14921
- encode
14922
- };
14923
- };
14924
- const bigInt = length => property => {
14925
- const layout = blob(length, property);
14926
- const {
14927
- encode,
14928
- decode
14929
- } = encodeDecode(layout);
14930
- const bigIntLayout = layout;
14931
- bigIntLayout.decode = (buffer$1, offset) => {
14932
- const src = decode(buffer$1, offset);
14933
- return toBigIntLE_1(buffer.Buffer.from(src));
14934
- };
14935
- bigIntLayout.encode = (bigInt, buffer, offset) => {
14936
- const src = toBufferLE_1(bigInt, length);
14937
- return encode(src, buffer, offset);
14938
- };
14939
- return bigIntLayout;
14940
- };
14941
- const u64 = bigInt(8);
14942
-
14943
- /**
14944
- * Create account system transaction params
14917
+ * Create account system transaction params
14945
14918
  */
14946
14919
 
14947
14920
  /**
@@ -15673,6 +15646,291 @@ var solanaWeb3 = (function (exports) {
15673
15646
  }
15674
15647
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
15675
15648
 
15649
+ /**
15650
+ * An enumeration of valid LookupTableInstructionType's
15651
+ */
15652
+
15653
+ /**
15654
+ * An enumeration of valid address lookup table InstructionType's
15655
+ * @internal
15656
+ */
15657
+ const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
15658
+ CreateLookupTable: {
15659
+ index: 0,
15660
+ layout: struct([u32('instruction'), u64('recentSlot'), u8('bumpSeed')])
15661
+ },
15662
+ FreezeLookupTable: {
15663
+ index: 1,
15664
+ layout: struct([u32('instruction')])
15665
+ },
15666
+ ExtendLookupTable: {
15667
+ index: 2,
15668
+ layout: struct([u32('instruction'), u64(), seq(publicKey(), offset(u32(), -8), 'addresses')])
15669
+ },
15670
+ DeactivateLookupTable: {
15671
+ index: 3,
15672
+ layout: struct([u32('instruction')])
15673
+ },
15674
+ CloseLookupTable: {
15675
+ index: 4,
15676
+ layout: struct([u32('instruction')])
15677
+ }
15678
+ });
15679
+ class AddressLookupTableInstruction {
15680
+ /**
15681
+ * @internal
15682
+ */
15683
+ constructor() {}
15684
+ static decodeInstructionType(instruction) {
15685
+ this.checkProgramId(instruction.programId);
15686
+ const instructionTypeLayout = u32('instruction');
15687
+ const index = instructionTypeLayout.decode(instruction.data);
15688
+ let type;
15689
+ for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
15690
+ if (layout.index == index) {
15691
+ type = layoutType;
15692
+ break;
15693
+ }
15694
+ }
15695
+ if (!type) {
15696
+ throw new Error('Invalid Instruction. Should be a LookupTable Instruction');
15697
+ }
15698
+ return type;
15699
+ }
15700
+ static decodeCreateLookupTable(instruction) {
15701
+ this.checkProgramId(instruction.programId);
15702
+ this.checkKeysLength(instruction.keys, 4);
15703
+ const {
15704
+ recentSlot
15705
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);
15706
+ return {
15707
+ authority: instruction.keys[1].pubkey,
15708
+ payer: instruction.keys[2].pubkey,
15709
+ recentSlot: Number(recentSlot)
15710
+ };
15711
+ }
15712
+ static decodeExtendLookupTable(instruction) {
15713
+ this.checkProgramId(instruction.programId);
15714
+ if (instruction.keys.length < 2) {
15715
+ throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);
15716
+ }
15717
+ const {
15718
+ addresses
15719
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);
15720
+ return {
15721
+ lookupTable: instruction.keys[0].pubkey,
15722
+ authority: instruction.keys[1].pubkey,
15723
+ payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
15724
+ addresses: addresses.map(buffer => new PublicKey(buffer))
15725
+ };
15726
+ }
15727
+ static decodeCloseLookupTable(instruction) {
15728
+ this.checkProgramId(instruction.programId);
15729
+ this.checkKeysLength(instruction.keys, 3);
15730
+ return {
15731
+ lookupTable: instruction.keys[0].pubkey,
15732
+ authority: instruction.keys[1].pubkey,
15733
+ recipient: instruction.keys[2].pubkey
15734
+ };
15735
+ }
15736
+ static decodeFreezeLookupTable(instruction) {
15737
+ this.checkProgramId(instruction.programId);
15738
+ this.checkKeysLength(instruction.keys, 2);
15739
+ return {
15740
+ lookupTable: instruction.keys[0].pubkey,
15741
+ authority: instruction.keys[1].pubkey
15742
+ };
15743
+ }
15744
+ static decodeDeactivateLookupTable(instruction) {
15745
+ this.checkProgramId(instruction.programId);
15746
+ this.checkKeysLength(instruction.keys, 2);
15747
+ return {
15748
+ lookupTable: instruction.keys[0].pubkey,
15749
+ authority: instruction.keys[1].pubkey
15750
+ };
15751
+ }
15752
+
15753
+ /**
15754
+ * @internal
15755
+ */
15756
+ static checkProgramId(programId) {
15757
+ if (!programId.equals(AddressLookupTableProgram.programId)) {
15758
+ throw new Error('invalid instruction; programId is not AddressLookupTable Program');
15759
+ }
15760
+ }
15761
+ /**
15762
+ * @internal
15763
+ */
15764
+ static checkKeysLength(keys, expectedLength) {
15765
+ if (keys.length < expectedLength) {
15766
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
15767
+ }
15768
+ }
15769
+ }
15770
+ class AddressLookupTableProgram {
15771
+ /**
15772
+ * @internal
15773
+ */
15774
+ constructor() {}
15775
+ static createLookupTable(params) {
15776
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE_1(BigInt(params.recentSlot), 8)], this.programId);
15777
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
15778
+ const data = encodeData(type, {
15779
+ recentSlot: BigInt(params.recentSlot),
15780
+ bumpSeed: bumpSeed
15781
+ });
15782
+ const keys = [{
15783
+ pubkey: lookupTableAddress,
15784
+ isSigner: false,
15785
+ isWritable: true
15786
+ }, {
15787
+ pubkey: params.authority,
15788
+ isSigner: true,
15789
+ isWritable: false
15790
+ }, {
15791
+ pubkey: params.payer,
15792
+ isSigner: true,
15793
+ isWritable: true
15794
+ }, {
15795
+ pubkey: SystemProgram.programId,
15796
+ isSigner: false,
15797
+ isWritable: false
15798
+ }];
15799
+ return [new TransactionInstruction({
15800
+ programId: this.programId,
15801
+ keys: keys,
15802
+ data: data
15803
+ }), lookupTableAddress];
15804
+ }
15805
+ static freezeLookupTable(params) {
15806
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
15807
+ const data = encodeData(type);
15808
+ const keys = [{
15809
+ pubkey: params.lookupTable,
15810
+ isSigner: false,
15811
+ isWritable: true
15812
+ }, {
15813
+ pubkey: params.authority,
15814
+ isSigner: true,
15815
+ isWritable: false
15816
+ }];
15817
+ return new TransactionInstruction({
15818
+ programId: this.programId,
15819
+ keys: keys,
15820
+ data: data
15821
+ });
15822
+ }
15823
+ static extendLookupTable(params) {
15824
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
15825
+ const data = encodeData(type, {
15826
+ addresses: params.addresses.map(addr => addr.toBytes())
15827
+ });
15828
+ const keys = [{
15829
+ pubkey: params.lookupTable,
15830
+ isSigner: false,
15831
+ isWritable: true
15832
+ }, {
15833
+ pubkey: params.authority,
15834
+ isSigner: true,
15835
+ isWritable: false
15836
+ }];
15837
+ if (params.payer) {
15838
+ keys.push({
15839
+ pubkey: params.payer,
15840
+ isSigner: true,
15841
+ isWritable: true
15842
+ }, {
15843
+ pubkey: SystemProgram.programId,
15844
+ isSigner: false,
15845
+ isWritable: false
15846
+ });
15847
+ }
15848
+ return new TransactionInstruction({
15849
+ programId: this.programId,
15850
+ keys: keys,
15851
+ data: data
15852
+ });
15853
+ }
15854
+ static deactivateLookupTable(params) {
15855
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
15856
+ const data = encodeData(type);
15857
+ const keys = [{
15858
+ pubkey: params.lookupTable,
15859
+ isSigner: false,
15860
+ isWritable: true
15861
+ }, {
15862
+ pubkey: params.authority,
15863
+ isSigner: true,
15864
+ isWritable: false
15865
+ }];
15866
+ return new TransactionInstruction({
15867
+ programId: this.programId,
15868
+ keys: keys,
15869
+ data: data
15870
+ });
15871
+ }
15872
+ static closeLookupTable(params) {
15873
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
15874
+ const data = encodeData(type);
15875
+ const keys = [{
15876
+ pubkey: params.lookupTable,
15877
+ isSigner: false,
15878
+ isWritable: true
15879
+ }, {
15880
+ pubkey: params.authority,
15881
+ isSigner: true,
15882
+ isWritable: false
15883
+ }, {
15884
+ pubkey: params.recipient,
15885
+ isSigner: false,
15886
+ isWritable: true
15887
+ }];
15888
+ return new TransactionInstruction({
15889
+ programId: this.programId,
15890
+ keys: keys,
15891
+ data: data
15892
+ });
15893
+ }
15894
+ }
15895
+ AddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');
15896
+
15897
+ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
15898
+
15899
+ /**
15900
+ * Sign, send and confirm a transaction.
15901
+ *
15902
+ * If `commitment` option is not specified, defaults to 'max' commitment.
15903
+ *
15904
+ * @param {Connection} connection
15905
+ * @param {Transaction} transaction
15906
+ * @param {Array<Signer>} signers
15907
+ * @param {ConfirmOptions} [options]
15908
+ * @returns {Promise<TransactionSignature>}
15909
+ */
15910
+ async function sendAndConfirmTransaction(connection, transaction, signers, options) {
15911
+ const sendOptions = options && {
15912
+ skipPreflight: options.skipPreflight,
15913
+ preflightCommitment: options.preflightCommitment || options.commitment,
15914
+ maxRetries: options.maxRetries,
15915
+ minContextSlot: options.minContextSlot
15916
+ };
15917
+ const signature = await connection.sendTransaction(transaction, signers, sendOptions);
15918
+ const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
15919
+ signature: signature,
15920
+ blockhash: transaction.recentBlockhash,
15921
+ lastValidBlockHeight: transaction.lastValidBlockHeight
15922
+ }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
15923
+ if (status.err) {
15924
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
15925
+ }
15926
+ return signature;
15927
+ }
15928
+
15929
+ // zzz
15930
+ function sleep(ms) {
15931
+ return new Promise(resolve => setTimeout(resolve, ms));
15932
+ }
15933
+
15676
15934
  // Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the
15677
15935
  // rest of the Transaction fields
15678
15936
  //
@@ -20693,7 +20951,7 @@ var solanaWeb3 = (function (exports) {
20693
20951
 
20694
20952
  /** @internal */
20695
20953
  const COMMON_HTTP_HEADERS = {
20696
- 'solana-client': `js/${"1.47.5" }`
20954
+ 'solana-client': `js/${"1.48.1" }`
20697
20955
  };
20698
20956
 
20699
20957
  /**
@@ -30226,6 +30484,8 @@ var solanaWeb3 = (function (exports) {
30226
30484
  const LAMPORTS_PER_SOL = 1000000000;
30227
30485
 
30228
30486
  exports.Account = Account;
30487
+ exports.AddressLookupTableInstruction = AddressLookupTableInstruction;
30488
+ exports.AddressLookupTableProgram = AddressLookupTableProgram;
30229
30489
  exports.Authorized = Authorized;
30230
30490
  exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
30231
30491
  exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
@@ -30241,6 +30501,7 @@ var solanaWeb3 = (function (exports) {
30241
30501
  exports.FeeCalculatorLayout = FeeCalculatorLayout;
30242
30502
  exports.Keypair = Keypair;
30243
30503
  exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
30504
+ exports.LOOKUP_TABLE_INSTRUCTION_LAYOUTS = LOOKUP_TABLE_INSTRUCTION_LAYOUTS;
30244
30505
  exports.Loader = Loader;
30245
30506
  exports.Lockup = Lockup;
30246
30507
  exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;