@solana/web3.js 1.47.3 → 1.49.0

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
@@ -11478,7 +11478,69 @@ var solanaWeb3 = (function (exports) {
11478
11478
 
11479
11479
  }
11480
11480
 
11481
- const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
11481
+ var browser$1 = {};
11482
+
11483
+ Object.defineProperty(browser$1, "__esModule", { value: true });
11484
+ /**
11485
+ * Convert a little-endian buffer into a BigInt.
11486
+ * @param buf The little-endian buffer to convert
11487
+ * @returns A BigInt with the little-endian representation of buf.
11488
+ */
11489
+ function toBigIntLE(buf) {
11490
+ {
11491
+ const reversed = Buffer.from(buf);
11492
+ reversed.reverse();
11493
+ const hex = reversed.toString('hex');
11494
+ if (hex.length === 0) {
11495
+ return BigInt(0);
11496
+ }
11497
+ return BigInt(`0x${hex}`);
11498
+ }
11499
+ }
11500
+ var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
11501
+ /**
11502
+ * Convert a big-endian buffer into a BigInt
11503
+ * @param buf The big-endian buffer to convert.
11504
+ * @returns A BigInt with the big-endian representation of buf.
11505
+ */
11506
+ function toBigIntBE(buf) {
11507
+ {
11508
+ const hex = buf.toString('hex');
11509
+ if (hex.length === 0) {
11510
+ return BigInt(0);
11511
+ }
11512
+ return BigInt(`0x${hex}`);
11513
+ }
11514
+ }
11515
+ browser$1.toBigIntBE = toBigIntBE;
11516
+ /**
11517
+ * Convert a BigInt to a little-endian buffer.
11518
+ * @param num The BigInt to convert.
11519
+ * @param width The number of bytes that the resulting buffer should be.
11520
+ * @returns A little-endian buffer representation of num.
11521
+ */
11522
+ function toBufferLE(num, width) {
11523
+ {
11524
+ const hex = num.toString(16);
11525
+ const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
11526
+ buffer.reverse();
11527
+ return buffer;
11528
+ }
11529
+ }
11530
+ var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
11531
+ /**
11532
+ * Convert a BigInt to a big-endian buffer.
11533
+ * @param num The BigInt to convert.
11534
+ * @param width The number of bytes that the resulting buffer should be.
11535
+ * @returns A big-endian buffer representation of num.
11536
+ */
11537
+ function toBufferBE(num, width) {
11538
+ {
11539
+ const hex = num.toString(16);
11540
+ return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
11541
+ }
11542
+ }
11543
+ browser$1.toBufferBE = toBufferBE;
11482
11544
 
11483
11545
  var Layout$1 = {};
11484
11546
 
@@ -13763,16 +13825,6 @@ var solanaWeb3 = (function (exports) {
13763
13825
  /** Factory for {@link Constant} values. */
13764
13826
  Layout$1.constant = ((value, property) => new Constant(value, property));
13765
13827
 
13766
- /**
13767
- * Maximum over-the-wire size of a Transaction
13768
- *
13769
- * 1280 is IPv6 minimum MTU
13770
- * 40 bytes is the size of the IPv6 header
13771
- * 8 bytes is the size of the fragment header
13772
- */
13773
- const PACKET_DATA_SIZE = 1280 - 40 - 8;
13774
- const SIGNATURE_LENGTH_IN_BYTES = 64;
13775
-
13776
13828
  /**
13777
13829
  * Layout for a public key
13778
13830
  */
@@ -13834,17 +13886,170 @@ var solanaWeb3 = (function (exports) {
13834
13886
  return struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), u8('commission')], property);
13835
13887
  };
13836
13888
  function getAlloc(type, fields) {
13837
- let alloc = 0;
13838
- type.layout.fields.forEach(item => {
13889
+ const getItemAlloc = item => {
13839
13890
  if (item.span >= 0) {
13840
- alloc += item.span;
13891
+ return item.span;
13841
13892
  } else if (typeof item.alloc === 'function') {
13842
- alloc += item.alloc(fields[item.property]);
13843
- }
13893
+ return item.alloc(fields[item.property]);
13894
+ } else if ('count' in item && 'elementLayout' in item) {
13895
+ const field = fields[item.property];
13896
+
13897
+ if (Array.isArray(field)) {
13898
+ return field.length * getItemAlloc(item.elementLayout);
13899
+ }
13900
+ } // Couldn't determine allocated size of layout
13901
+
13902
+
13903
+ return 0;
13904
+ };
13905
+
13906
+ let alloc = 0;
13907
+ type.layout.fields.forEach(item => {
13908
+ alloc += getItemAlloc(item);
13844
13909
  });
13845
13910
  return alloc;
13846
13911
  }
13847
13912
 
13913
+ const encodeDecode = layout => {
13914
+ const decode = layout.decode.bind(layout);
13915
+ const encode = layout.encode.bind(layout);
13916
+ return {
13917
+ decode,
13918
+ encode
13919
+ };
13920
+ };
13921
+
13922
+ const bigInt = length => property => {
13923
+ const layout = blob(length, property);
13924
+ const {
13925
+ encode,
13926
+ decode
13927
+ } = encodeDecode(layout);
13928
+ const bigIntLayout = layout;
13929
+
13930
+ bigIntLayout.decode = (buffer$1, offset) => {
13931
+ const src = decode(buffer$1, offset);
13932
+ return toBigIntLE_1(buffer.Buffer.from(src));
13933
+ };
13934
+
13935
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
13936
+ const src = toBufferLE_1(bigInt, length);
13937
+ return encode(src, buffer, offset);
13938
+ };
13939
+
13940
+ return bigIntLayout;
13941
+ };
13942
+
13943
+ const u64 = bigInt(8);
13944
+
13945
+ /**
13946
+ * Populate a buffer of instruction data using an InstructionType
13947
+ * @internal
13948
+ */
13949
+ function encodeData(type, fields) {
13950
+ const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
13951
+ const data = buffer.Buffer.alloc(allocLength);
13952
+ const layoutFields = Object.assign({
13953
+ instruction: type.index
13954
+ }, fields);
13955
+ type.layout.encode(layoutFields, data);
13956
+ return data;
13957
+ }
13958
+ /**
13959
+ * Decode instruction data buffer using an InstructionType
13960
+ * @internal
13961
+ */
13962
+
13963
+ function decodeData(type, buffer) {
13964
+ let data;
13965
+
13966
+ try {
13967
+ data = type.layout.decode(buffer);
13968
+ } catch (err) {
13969
+ throw new Error('invalid instruction; ' + err);
13970
+ }
13971
+
13972
+ if (data.instruction !== type.index) {
13973
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
13974
+ }
13975
+
13976
+ return data;
13977
+ }
13978
+
13979
+ /**
13980
+ * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
13981
+ *
13982
+ * @internal
13983
+ */
13984
+
13985
+ const FeeCalculatorLayout = nu64('lamportsPerSignature');
13986
+ /**
13987
+ * Calculator for transaction fees.
13988
+ */
13989
+
13990
+ /**
13991
+ * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
13992
+ *
13993
+ * @internal
13994
+ */
13995
+
13996
+ const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
13997
+ const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
13998
+
13999
+ /**
14000
+ * NonceAccount class
14001
+ */
14002
+ class NonceAccount {
14003
+ /**
14004
+ * @internal
14005
+ */
14006
+ constructor(args) {
14007
+ this.authorizedPubkey = void 0;
14008
+ this.nonce = void 0;
14009
+ this.feeCalculator = void 0;
14010
+ this.authorizedPubkey = args.authorizedPubkey;
14011
+ this.nonce = args.nonce;
14012
+ this.feeCalculator = args.feeCalculator;
14013
+ }
14014
+ /**
14015
+ * Deserialize NonceAccount from the account data.
14016
+ *
14017
+ * @param buffer account data
14018
+ * @return NonceAccount
14019
+ */
14020
+
14021
+
14022
+ static fromAccountData(buffer) {
14023
+ const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
14024
+ return new NonceAccount({
14025
+ authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
14026
+ nonce: new PublicKey(nonceAccount.nonce).toString(),
14027
+ feeCalculator: nonceAccount.feeCalculator
14028
+ });
14029
+ }
14030
+
14031
+ }
14032
+
14033
+ const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
14034
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
14035
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
14036
+ const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
14037
+ const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
14038
+ const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
14039
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
14040
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
14041
+ const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
14042
+
14043
+ /**
14044
+ * Maximum over-the-wire size of a Transaction
14045
+ *
14046
+ * 1280 is IPv6 minimum MTU
14047
+ * 40 bytes is the size of the IPv6 header
14048
+ * 8 bytes is the size of the fragment header
14049
+ */
14050
+ const PACKET_DATA_SIZE = 1280 - 40 - 8;
14051
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
14052
+
13848
14053
  function decodeLength(bytes) {
13849
14054
  let len = 0;
13850
14055
  let size = 0;
@@ -14729,265 +14934,34 @@ var solanaWeb3 = (function (exports) {
14729
14934
  transaction.feePayer = message.accountKeys[0];
14730
14935
  }
14731
14936
 
14732
- signatures.forEach((signature, index) => {
14733
- const sigPubkeyPair = {
14734
- signature: signature == bs58$1.encode(DEFAULT_SIGNATURE) ? null : bs58$1.decode(signature),
14735
- publicKey: message.accountKeys[index]
14736
- };
14737
- transaction.signatures.push(sigPubkeyPair);
14738
- });
14739
- message.instructions.forEach(instruction => {
14740
- const keys = instruction.accounts.map(account => {
14741
- const pubkey = message.accountKeys[account];
14742
- return {
14743
- pubkey,
14744
- isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
14745
- isWritable: message.isAccountWritable(account)
14746
- };
14747
- });
14748
- transaction.instructions.push(new TransactionInstruction({
14749
- keys,
14750
- programId: message.accountKeys[instruction.programIdIndex],
14751
- data: bs58$1.decode(instruction.data)
14752
- }));
14753
- });
14754
- transaction._message = message;
14755
- transaction._json = transaction.toJSON();
14756
- return transaction;
14757
- }
14758
-
14759
- }
14760
-
14761
- const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
14762
- const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
14763
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
14764
- const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
14765
- const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
14766
- const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
14767
- const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
14768
- const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
14769
- const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
14770
-
14771
- /**
14772
- * Sign, send and confirm a transaction.
14773
- *
14774
- * If `commitment` option is not specified, defaults to 'max' commitment.
14775
- *
14776
- * @param {Connection} connection
14777
- * @param {Transaction} transaction
14778
- * @param {Array<Signer>} signers
14779
- * @param {ConfirmOptions} [options]
14780
- * @returns {Promise<TransactionSignature>}
14781
- */
14782
- async function sendAndConfirmTransaction(connection, transaction, signers, options) {
14783
- const sendOptions = options && {
14784
- skipPreflight: options.skipPreflight,
14785
- preflightCommitment: options.preflightCommitment || options.commitment,
14786
- maxRetries: options.maxRetries,
14787
- minContextSlot: options.minContextSlot
14788
- };
14789
- const signature = await connection.sendTransaction(transaction, signers, sendOptions);
14790
- const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
14791
- signature: signature,
14792
- blockhash: transaction.recentBlockhash,
14793
- lastValidBlockHeight: transaction.lastValidBlockHeight
14794
- }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
14795
-
14796
- if (status.err) {
14797
- throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
14798
- }
14799
-
14800
- return signature;
14801
- }
14802
-
14803
- // zzz
14804
- function sleep(ms) {
14805
- return new Promise(resolve => setTimeout(resolve, ms));
14806
- }
14807
-
14808
- /**
14809
- * Populate a buffer of instruction data using an InstructionType
14810
- * @internal
14811
- */
14812
- function encodeData(type, fields) {
14813
- const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
14814
- const data = buffer.Buffer.alloc(allocLength);
14815
- const layoutFields = Object.assign({
14816
- instruction: type.index
14817
- }, fields);
14818
- type.layout.encode(layoutFields, data);
14819
- return data;
14820
- }
14821
- /**
14822
- * Decode instruction data buffer using an InstructionType
14823
- * @internal
14824
- */
14825
-
14826
- function decodeData(type, buffer) {
14827
- let data;
14828
-
14829
- try {
14830
- data = type.layout.decode(buffer);
14831
- } catch (err) {
14832
- throw new Error('invalid instruction; ' + err);
14833
- }
14834
-
14835
- if (data.instruction !== type.index) {
14836
- throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
14837
- }
14838
-
14839
- return data;
14840
- }
14841
-
14842
- /**
14843
- * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
14844
- *
14845
- * @internal
14846
- */
14847
-
14848
- const FeeCalculatorLayout = nu64('lamportsPerSignature');
14849
- /**
14850
- * Calculator for transaction fees.
14851
- */
14852
-
14853
- /**
14854
- * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
14855
- *
14856
- * @internal
14857
- */
14858
-
14859
- const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
14860
- const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
14861
-
14862
- /**
14863
- * NonceAccount class
14864
- */
14865
- class NonceAccount {
14866
- /**
14867
- * @internal
14868
- */
14869
- constructor(args) {
14870
- this.authorizedPubkey = void 0;
14871
- this.nonce = void 0;
14872
- this.feeCalculator = void 0;
14873
- this.authorizedPubkey = args.authorizedPubkey;
14874
- this.nonce = args.nonce;
14875
- this.feeCalculator = args.feeCalculator;
14876
- }
14877
- /**
14878
- * Deserialize NonceAccount from the account data.
14879
- *
14880
- * @param buffer account data
14881
- * @return NonceAccount
14882
- */
14883
-
14884
-
14885
- static fromAccountData(buffer) {
14886
- const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
14887
- return new NonceAccount({
14888
- authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
14889
- nonce: new PublicKey(nonceAccount.nonce).toString(),
14890
- feeCalculator: nonceAccount.feeCalculator
14891
- });
14892
- }
14893
-
14894
- }
14895
-
14896
- var browser$1 = {};
14897
-
14898
- Object.defineProperty(browser$1, "__esModule", { value: true });
14899
- /**
14900
- * Convert a little-endian buffer into a BigInt.
14901
- * @param buf The little-endian buffer to convert
14902
- * @returns A BigInt with the little-endian representation of buf.
14903
- */
14904
- function toBigIntLE(buf) {
14905
- {
14906
- const reversed = Buffer.from(buf);
14907
- reversed.reverse();
14908
- const hex = reversed.toString('hex');
14909
- if (hex.length === 0) {
14910
- return BigInt(0);
14911
- }
14912
- return BigInt(`0x${hex}`);
14913
- }
14914
- }
14915
- var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
14916
- /**
14917
- * Convert a big-endian buffer into a BigInt
14918
- * @param buf The big-endian buffer to convert.
14919
- * @returns A BigInt with the big-endian representation of buf.
14920
- */
14921
- function toBigIntBE(buf) {
14922
- {
14923
- const hex = buf.toString('hex');
14924
- if (hex.length === 0) {
14925
- return BigInt(0);
14926
- }
14927
- return BigInt(`0x${hex}`);
14928
- }
14929
- }
14930
- browser$1.toBigIntBE = toBigIntBE;
14931
- /**
14932
- * Convert a BigInt to a little-endian buffer.
14933
- * @param num The BigInt to convert.
14934
- * @param width The number of bytes that the resulting buffer should be.
14935
- * @returns A little-endian buffer representation of num.
14936
- */
14937
- function toBufferLE(num, width) {
14938
- {
14939
- const hex = num.toString(16);
14940
- const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
14941
- buffer.reverse();
14942
- return buffer;
14943
- }
14944
- }
14945
- var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
14946
- /**
14947
- * Convert a BigInt to a big-endian buffer.
14948
- * @param num The BigInt to convert.
14949
- * @param width The number of bytes that the resulting buffer should be.
14950
- * @returns A big-endian buffer representation of num.
14951
- */
14952
- function toBufferBE(num, width) {
14953
- {
14954
- const hex = num.toString(16);
14955
- return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
14956
- }
14957
- }
14958
- browser$1.toBufferBE = toBufferBE;
14959
-
14960
- const encodeDecode = layout => {
14961
- const decode = layout.decode.bind(layout);
14962
- const encode = layout.encode.bind(layout);
14963
- return {
14964
- decode,
14965
- encode
14966
- };
14967
- };
14968
-
14969
- const bigInt = length => property => {
14970
- const layout = blob(length, property);
14971
- const {
14972
- encode,
14973
- decode
14974
- } = encodeDecode(layout);
14975
- const bigIntLayout = layout;
14976
-
14977
- bigIntLayout.decode = (buffer$1, offset) => {
14978
- const src = decode(buffer$1, offset);
14979
- return toBigIntLE_1(buffer.Buffer.from(src));
14980
- };
14981
-
14982
- bigIntLayout.encode = (bigInt, buffer, offset) => {
14983
- const src = toBufferLE_1(bigInt, length);
14984
- return encode(src, buffer, offset);
14985
- };
14986
-
14987
- return bigIntLayout;
14988
- };
14937
+ signatures.forEach((signature, index) => {
14938
+ const sigPubkeyPair = {
14939
+ signature: signature == bs58$1.encode(DEFAULT_SIGNATURE) ? null : bs58$1.decode(signature),
14940
+ publicKey: message.accountKeys[index]
14941
+ };
14942
+ transaction.signatures.push(sigPubkeyPair);
14943
+ });
14944
+ message.instructions.forEach(instruction => {
14945
+ const keys = instruction.accounts.map(account => {
14946
+ const pubkey = message.accountKeys[account];
14947
+ return {
14948
+ pubkey,
14949
+ isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
14950
+ isWritable: message.isAccountWritable(account)
14951
+ };
14952
+ });
14953
+ transaction.instructions.push(new TransactionInstruction({
14954
+ keys,
14955
+ programId: message.accountKeys[instruction.programIdIndex],
14956
+ data: bs58$1.decode(instruction.data)
14957
+ }));
14958
+ });
14959
+ transaction._message = message;
14960
+ transaction._json = transaction.toJSON();
14961
+ return transaction;
14962
+ }
14989
14963
 
14990
- const u64 = bigInt(8);
14964
+ }
14991
14965
 
14992
14966
  /**
14993
14967
  * Create account system transaction params
@@ -15704,6 +15678,312 @@ var solanaWeb3 = (function (exports) {
15704
15678
  }
15705
15679
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
15706
15680
 
15681
+ /**
15682
+ * An enumeration of valid address lookup table InstructionType's
15683
+ * @internal
15684
+ */
15685
+ const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
15686
+ CreateLookupTable: {
15687
+ index: 0,
15688
+ layout: struct([u32('instruction'), u64('recentSlot'), u8('bumpSeed')])
15689
+ },
15690
+ FreezeLookupTable: {
15691
+ index: 1,
15692
+ layout: struct([u32('instruction')])
15693
+ },
15694
+ ExtendLookupTable: {
15695
+ index: 2,
15696
+ layout: struct([u32('instruction'), u64(), seq(publicKey(), offset(u32(), -8), 'addresses')])
15697
+ },
15698
+ DeactivateLookupTable: {
15699
+ index: 3,
15700
+ layout: struct([u32('instruction')])
15701
+ },
15702
+ CloseLookupTable: {
15703
+ index: 4,
15704
+ layout: struct([u32('instruction')])
15705
+ }
15706
+ });
15707
+ class AddressLookupTableInstruction {
15708
+ /**
15709
+ * @internal
15710
+ */
15711
+ constructor() {}
15712
+
15713
+ static decodeInstructionType(instruction) {
15714
+ this.checkProgramId(instruction.programId);
15715
+ const instructionTypeLayout = u32('instruction');
15716
+ const index = instructionTypeLayout.decode(instruction.data);
15717
+ let type;
15718
+
15719
+ for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
15720
+ if (layout.index == index) {
15721
+ type = layoutType;
15722
+ break;
15723
+ }
15724
+ }
15725
+
15726
+ if (!type) {
15727
+ throw new Error('Invalid Instruction. Should be a LookupTable Instruction');
15728
+ }
15729
+
15730
+ return type;
15731
+ }
15732
+
15733
+ static decodeCreateLookupTable(instruction) {
15734
+ this.checkProgramId(instruction.programId);
15735
+ this.checkKeysLength(instruction.keys, 4);
15736
+ const {
15737
+ recentSlot
15738
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);
15739
+ return {
15740
+ authority: instruction.keys[1].pubkey,
15741
+ payer: instruction.keys[2].pubkey,
15742
+ recentSlot: Number(recentSlot)
15743
+ };
15744
+ }
15745
+
15746
+ static decodeExtendLookupTable(instruction) {
15747
+ this.checkProgramId(instruction.programId);
15748
+
15749
+ if (instruction.keys.length < 2) {
15750
+ throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);
15751
+ }
15752
+
15753
+ const {
15754
+ addresses
15755
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);
15756
+ return {
15757
+ lookupTable: instruction.keys[0].pubkey,
15758
+ authority: instruction.keys[1].pubkey,
15759
+ payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
15760
+ addresses: addresses.map(buffer => new PublicKey(buffer))
15761
+ };
15762
+ }
15763
+
15764
+ static decodeCloseLookupTable(instruction) {
15765
+ this.checkProgramId(instruction.programId);
15766
+ this.checkKeysLength(instruction.keys, 3);
15767
+ return {
15768
+ lookupTable: instruction.keys[0].pubkey,
15769
+ authority: instruction.keys[1].pubkey,
15770
+ recipient: instruction.keys[2].pubkey
15771
+ };
15772
+ }
15773
+
15774
+ static decodeFreezeLookupTable(instruction) {
15775
+ this.checkProgramId(instruction.programId);
15776
+ this.checkKeysLength(instruction.keys, 2);
15777
+ return {
15778
+ lookupTable: instruction.keys[0].pubkey,
15779
+ authority: instruction.keys[1].pubkey
15780
+ };
15781
+ }
15782
+
15783
+ static decodeDeactivateLookupTable(instruction) {
15784
+ this.checkProgramId(instruction.programId);
15785
+ this.checkKeysLength(instruction.keys, 2);
15786
+ return {
15787
+ lookupTable: instruction.keys[0].pubkey,
15788
+ authority: instruction.keys[1].pubkey
15789
+ };
15790
+ }
15791
+ /**
15792
+ * @internal
15793
+ */
15794
+
15795
+
15796
+ static checkProgramId(programId) {
15797
+ if (!programId.equals(AddressLookupTableProgram.programId)) {
15798
+ throw new Error('invalid instruction; programId is not AddressLookupTable Program');
15799
+ }
15800
+ }
15801
+ /**
15802
+ * @internal
15803
+ */
15804
+
15805
+
15806
+ static checkKeysLength(keys, expectedLength) {
15807
+ if (keys.length < expectedLength) {
15808
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
15809
+ }
15810
+ }
15811
+
15812
+ }
15813
+ class AddressLookupTableProgram {
15814
+ /**
15815
+ * @internal
15816
+ */
15817
+ constructor() {}
15818
+
15819
+ static createLookupTable(params) {
15820
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE_1(BigInt(params.recentSlot), 8)], this.programId);
15821
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
15822
+ const data = encodeData(type, {
15823
+ recentSlot: BigInt(params.recentSlot),
15824
+ bumpSeed: bumpSeed
15825
+ });
15826
+ const keys = [{
15827
+ pubkey: lookupTableAddress,
15828
+ isSigner: false,
15829
+ isWritable: true
15830
+ }, {
15831
+ pubkey: params.authority,
15832
+ isSigner: true,
15833
+ isWritable: false
15834
+ }, {
15835
+ pubkey: params.payer,
15836
+ isSigner: true,
15837
+ isWritable: true
15838
+ }, {
15839
+ pubkey: SystemProgram.programId,
15840
+ isSigner: false,
15841
+ isWritable: false
15842
+ }];
15843
+ return [new TransactionInstruction({
15844
+ programId: this.programId,
15845
+ keys: keys,
15846
+ data: data
15847
+ }), lookupTableAddress];
15848
+ }
15849
+
15850
+ static freezeLookupTable(params) {
15851
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
15852
+ const data = encodeData(type);
15853
+ const keys = [{
15854
+ pubkey: params.lookupTable,
15855
+ isSigner: false,
15856
+ isWritable: true
15857
+ }, {
15858
+ pubkey: params.authority,
15859
+ isSigner: true,
15860
+ isWritable: false
15861
+ }];
15862
+ return new TransactionInstruction({
15863
+ programId: this.programId,
15864
+ keys: keys,
15865
+ data: data
15866
+ });
15867
+ }
15868
+
15869
+ static extendLookupTable(params) {
15870
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
15871
+ const data = encodeData(type, {
15872
+ addresses: params.addresses.map(addr => addr.toBytes())
15873
+ });
15874
+ const keys = [{
15875
+ pubkey: params.lookupTable,
15876
+ isSigner: false,
15877
+ isWritable: true
15878
+ }, {
15879
+ pubkey: params.authority,
15880
+ isSigner: true,
15881
+ isWritable: false
15882
+ }];
15883
+
15884
+ if (params.payer) {
15885
+ keys.push({
15886
+ pubkey: params.payer,
15887
+ isSigner: true,
15888
+ isWritable: true
15889
+ }, {
15890
+ pubkey: SystemProgram.programId,
15891
+ isSigner: false,
15892
+ isWritable: false
15893
+ });
15894
+ }
15895
+
15896
+ return new TransactionInstruction({
15897
+ programId: this.programId,
15898
+ keys: keys,
15899
+ data: data
15900
+ });
15901
+ }
15902
+
15903
+ static deactivateLookupTable(params) {
15904
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
15905
+ const data = encodeData(type);
15906
+ const keys = [{
15907
+ pubkey: params.lookupTable,
15908
+ isSigner: false,
15909
+ isWritable: true
15910
+ }, {
15911
+ pubkey: params.authority,
15912
+ isSigner: true,
15913
+ isWritable: false
15914
+ }];
15915
+ return new TransactionInstruction({
15916
+ programId: this.programId,
15917
+ keys: keys,
15918
+ data: data
15919
+ });
15920
+ }
15921
+
15922
+ static closeLookupTable(params) {
15923
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
15924
+ const data = encodeData(type);
15925
+ const keys = [{
15926
+ pubkey: params.lookupTable,
15927
+ isSigner: false,
15928
+ isWritable: true
15929
+ }, {
15930
+ pubkey: params.authority,
15931
+ isSigner: true,
15932
+ isWritable: false
15933
+ }, {
15934
+ pubkey: params.recipient,
15935
+ isSigner: false,
15936
+ isWritable: true
15937
+ }];
15938
+ return new TransactionInstruction({
15939
+ programId: this.programId,
15940
+ keys: keys,
15941
+ data: data
15942
+ });
15943
+ }
15944
+
15945
+ }
15946
+ AddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');
15947
+
15948
+ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
15949
+
15950
+ /**
15951
+ * Sign, send and confirm a transaction.
15952
+ *
15953
+ * If `commitment` option is not specified, defaults to 'max' commitment.
15954
+ *
15955
+ * @param {Connection} connection
15956
+ * @param {Transaction} transaction
15957
+ * @param {Array<Signer>} signers
15958
+ * @param {ConfirmOptions} [options]
15959
+ * @returns {Promise<TransactionSignature>}
15960
+ */
15961
+ async function sendAndConfirmTransaction(connection, transaction, signers, options) {
15962
+ const sendOptions = options && {
15963
+ skipPreflight: options.skipPreflight,
15964
+ preflightCommitment: options.preflightCommitment || options.commitment,
15965
+ maxRetries: options.maxRetries,
15966
+ minContextSlot: options.minContextSlot
15967
+ };
15968
+ const signature = await connection.sendTransaction(transaction, signers, sendOptions);
15969
+ const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
15970
+ signature: signature,
15971
+ blockhash: transaction.recentBlockhash,
15972
+ lastValidBlockHeight: transaction.lastValidBlockHeight
15973
+ }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
15974
+
15975
+ if (status.err) {
15976
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
15977
+ }
15978
+
15979
+ return signature;
15980
+ }
15981
+
15982
+ // zzz
15983
+ function sleep(ms) {
15984
+ return new Promise(resolve => setTimeout(resolve, ms));
15985
+ }
15986
+
15707
15987
  // rest of the Transaction fields
15708
15988
  //
15709
15989
  // TODO: replace 300 with a proper constant for the size of the other
@@ -19273,6 +19553,8 @@ var solanaWeb3 = (function (exports) {
19273
19553
 
19274
19554
  var RpcClient = browser;
19275
19555
 
19556
+ const URL = globalThis.URL;
19557
+
19276
19558
  const MINIMUM_SLOT_PER_EPOCH = 32; // Returns the number of trailing zeros in the binary representation of self.
19277
19559
 
19278
19560
  function trailingZeros(n) {
@@ -19670,7 +19952,11 @@ var solanaWeb3 = (function (exports) {
19670
19952
  data: array(string()),
19671
19953
  rentEpoch: optional(number())
19672
19954
  }))))),
19673
- unitsConsumed: optional(number())
19955
+ unitsConsumed: optional(number()),
19956
+ returnData: optional(nullable(type({
19957
+ programId: string(),
19958
+ data: tuple([string(), literal('base64')])
19959
+ })))
19674
19960
  }));
19675
19961
 
19676
19962
  /**
@@ -21550,8 +21836,15 @@ var solanaWeb3 = (function (exports) {
21550
21836
  */
21551
21837
 
21552
21838
 
21553
- async getBlock(slot, opts) {
21554
- const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
21839
+ async getBlock(slot, rawConfig) {
21840
+ const {
21841
+ commitment,
21842
+ config
21843
+ } = extractCommitmentFromConfig(rawConfig);
21844
+
21845
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined
21846
+ /* encoding */
21847
+ , config);
21555
21848
 
21556
21849
  const unsafeRes = await this._rpcRequest('getBlock', args);
21557
21850
  const res = create(unsafeRes, GetBlockRpcResult);
@@ -21637,8 +21930,15 @@ var solanaWeb3 = (function (exports) {
21637
21930
  */
21638
21931
 
21639
21932
 
21640
- async getTransaction(signature, opts) {
21641
- const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
21933
+ async getTransaction(signature, rawConfig) {
21934
+ const {
21935
+ commitment,
21936
+ config
21937
+ } = extractCommitmentFromConfig(rawConfig);
21938
+
21939
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
21940
+ /* encoding */
21941
+ , config);
21642
21942
 
21643
21943
  const unsafeRes = await this._rpcRequest('getTransaction', args);
21644
21944
  const res = create(unsafeRes, GetTransactionRpcResult);
@@ -30379,6 +30679,8 @@ var solanaWeb3 = (function (exports) {
30379
30679
  const LAMPORTS_PER_SOL = 1000000000;
30380
30680
 
30381
30681
  exports.Account = Account;
30682
+ exports.AddressLookupTableInstruction = AddressLookupTableInstruction;
30683
+ exports.AddressLookupTableProgram = AddressLookupTableProgram;
30382
30684
  exports.Authorized = Authorized;
30383
30685
  exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
30384
30686
  exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
@@ -30394,6 +30696,7 @@ var solanaWeb3 = (function (exports) {
30394
30696
  exports.FeeCalculatorLayout = FeeCalculatorLayout;
30395
30697
  exports.Keypair = Keypair;
30396
30698
  exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
30699
+ exports.LOOKUP_TABLE_INSTRUCTION_LAYOUTS = LOOKUP_TABLE_INSTRUCTION_LAYOUTS;
30397
30700
  exports.Loader = Loader;
30398
30701
  exports.Lockup = Lockup;
30399
30702
  exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;