@solana/web3.js 1.47.2 → 1.48.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;
@@ -14138,15 +14343,34 @@ var solanaWeb3 = (function (exports) {
14138
14343
 
14139
14344
  if (!opts) {
14140
14345
  return;
14141
- } else if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {
14142
- const newOpts = opts;
14143
- Object.assign(this, newOpts);
14144
- this.recentBlockhash = newOpts.blockhash;
14145
- this.lastValidBlockHeight = newOpts.lastValidBlockHeight;
14346
+ }
14347
+
14348
+ if (opts.feePayer) {
14349
+ this.feePayer = opts.feePayer;
14350
+ }
14351
+
14352
+ if (opts.signatures) {
14353
+ this.signatures = opts.signatures;
14354
+ }
14355
+
14356
+ if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {
14357
+ const {
14358
+ blockhash,
14359
+ lastValidBlockHeight
14360
+ } = opts;
14361
+ this.recentBlockhash = blockhash;
14362
+ this.lastValidBlockHeight = lastValidBlockHeight;
14146
14363
  } else {
14147
- const oldOpts = opts;
14148
- Object.assign(this, oldOpts);
14149
- this.recentBlockhash = oldOpts.recentBlockhash;
14364
+ const {
14365
+ recentBlockhash,
14366
+ nonceInfo
14367
+ } = opts;
14368
+
14369
+ if (nonceInfo) {
14370
+ this.nonceInfo = nonceInfo;
14371
+ }
14372
+
14373
+ this.recentBlockhash = recentBlockhash;
14150
14374
  }
14151
14375
  }
14152
14376
  /**
@@ -14708,267 +14932,36 @@ var solanaWeb3 = (function (exports) {
14708
14932
 
14709
14933
  if (message.header.numRequiredSignatures > 0) {
14710
14934
  transaction.feePayer = message.accountKeys[0];
14711
- }
14712
-
14713
- signatures.forEach((signature, index) => {
14714
- const sigPubkeyPair = {
14715
- signature: signature == bs58$1.encode(DEFAULT_SIGNATURE) ? null : bs58$1.decode(signature),
14716
- publicKey: message.accountKeys[index]
14717
- };
14718
- transaction.signatures.push(sigPubkeyPair);
14719
- });
14720
- message.instructions.forEach(instruction => {
14721
- const keys = instruction.accounts.map(account => {
14722
- const pubkey = message.accountKeys[account];
14723
- return {
14724
- pubkey,
14725
- isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
14726
- isWritable: message.isAccountWritable(account)
14727
- };
14728
- });
14729
- transaction.instructions.push(new TransactionInstruction({
14730
- keys,
14731
- programId: message.accountKeys[instruction.programIdIndex],
14732
- data: bs58$1.decode(instruction.data)
14733
- }));
14734
- });
14735
- transaction._message = message;
14736
- transaction._json = transaction.toJSON();
14737
- return transaction;
14738
- }
14739
-
14740
- }
14741
-
14742
- const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
14743
- const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
14744
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
14745
- const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
14746
- const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
14747
- const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
14748
- const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
14749
- const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
14750
- const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
14751
-
14752
- /**
14753
- * Sign, send and confirm a transaction.
14754
- *
14755
- * If `commitment` option is not specified, defaults to 'max' commitment.
14756
- *
14757
- * @param {Connection} connection
14758
- * @param {Transaction} transaction
14759
- * @param {Array<Signer>} signers
14760
- * @param {ConfirmOptions} [options]
14761
- * @returns {Promise<TransactionSignature>}
14762
- */
14763
- async function sendAndConfirmTransaction(connection, transaction, signers, options) {
14764
- const sendOptions = options && {
14765
- skipPreflight: options.skipPreflight,
14766
- preflightCommitment: options.preflightCommitment || options.commitment,
14767
- maxRetries: options.maxRetries,
14768
- minContextSlot: options.minContextSlot
14769
- };
14770
- const signature = await connection.sendTransaction(transaction, signers, sendOptions);
14771
- const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
14772
- signature: signature,
14773
- blockhash: transaction.recentBlockhash,
14774
- lastValidBlockHeight: transaction.lastValidBlockHeight
14775
- }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
14776
-
14777
- if (status.err) {
14778
- throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
14779
- }
14780
-
14781
- return signature;
14782
- }
14783
-
14784
- // zzz
14785
- function sleep(ms) {
14786
- return new Promise(resolve => setTimeout(resolve, ms));
14787
- }
14788
-
14789
- /**
14790
- * Populate a buffer of instruction data using an InstructionType
14791
- * @internal
14792
- */
14793
- function encodeData(type, fields) {
14794
- const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
14795
- const data = buffer.Buffer.alloc(allocLength);
14796
- const layoutFields = Object.assign({
14797
- instruction: type.index
14798
- }, fields);
14799
- type.layout.encode(layoutFields, data);
14800
- return data;
14801
- }
14802
- /**
14803
- * Decode instruction data buffer using an InstructionType
14804
- * @internal
14805
- */
14806
-
14807
- function decodeData(type, buffer) {
14808
- let data;
14809
-
14810
- try {
14811
- data = type.layout.decode(buffer);
14812
- } catch (err) {
14813
- throw new Error('invalid instruction; ' + err);
14814
- }
14815
-
14816
- if (data.instruction !== type.index) {
14817
- throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
14818
- }
14819
-
14820
- return data;
14821
- }
14822
-
14823
- /**
14824
- * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
14825
- *
14826
- * @internal
14827
- */
14828
-
14829
- const FeeCalculatorLayout = nu64('lamportsPerSignature');
14830
- /**
14831
- * Calculator for transaction fees.
14832
- */
14833
-
14834
- /**
14835
- * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
14836
- *
14837
- * @internal
14838
- */
14839
-
14840
- const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
14841
- const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
14842
-
14843
- /**
14844
- * NonceAccount class
14845
- */
14846
- class NonceAccount {
14847
- /**
14848
- * @internal
14849
- */
14850
- constructor(args) {
14851
- this.authorizedPubkey = void 0;
14852
- this.nonce = void 0;
14853
- this.feeCalculator = void 0;
14854
- this.authorizedPubkey = args.authorizedPubkey;
14855
- this.nonce = args.nonce;
14856
- this.feeCalculator = args.feeCalculator;
14857
- }
14858
- /**
14859
- * Deserialize NonceAccount from the account data.
14860
- *
14861
- * @param buffer account data
14862
- * @return NonceAccount
14863
- */
14864
-
14865
-
14866
- static fromAccountData(buffer) {
14867
- const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
14868
- return new NonceAccount({
14869
- authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
14870
- nonce: new PublicKey(nonceAccount.nonce).toString(),
14871
- feeCalculator: nonceAccount.feeCalculator
14872
- });
14873
- }
14874
-
14875
- }
14876
-
14877
- var browser$1 = {};
14878
-
14879
- Object.defineProperty(browser$1, "__esModule", { value: true });
14880
- /**
14881
- * Convert a little-endian buffer into a BigInt.
14882
- * @param buf The little-endian buffer to convert
14883
- * @returns A BigInt with the little-endian representation of buf.
14884
- */
14885
- function toBigIntLE(buf) {
14886
- {
14887
- const reversed = Buffer.from(buf);
14888
- reversed.reverse();
14889
- const hex = reversed.toString('hex');
14890
- if (hex.length === 0) {
14891
- return BigInt(0);
14892
- }
14893
- return BigInt(`0x${hex}`);
14894
- }
14895
- }
14896
- var toBigIntLE_1 = browser$1.toBigIntLE = toBigIntLE;
14897
- /**
14898
- * Convert a big-endian buffer into a BigInt
14899
- * @param buf The big-endian buffer to convert.
14900
- * @returns A BigInt with the big-endian representation of buf.
14901
- */
14902
- function toBigIntBE(buf) {
14903
- {
14904
- const hex = buf.toString('hex');
14905
- if (hex.length === 0) {
14906
- return BigInt(0);
14907
- }
14908
- return BigInt(`0x${hex}`);
14909
- }
14910
- }
14911
- browser$1.toBigIntBE = toBigIntBE;
14912
- /**
14913
- * Convert a BigInt to a little-endian buffer.
14914
- * @param num The BigInt to convert.
14915
- * @param width The number of bytes that the resulting buffer should be.
14916
- * @returns A little-endian buffer representation of num.
14917
- */
14918
- function toBufferLE(num, width) {
14919
- {
14920
- const hex = num.toString(16);
14921
- const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
14922
- buffer.reverse();
14923
- return buffer;
14924
- }
14925
- }
14926
- var toBufferLE_1 = browser$1.toBufferLE = toBufferLE;
14927
- /**
14928
- * Convert a BigInt to a big-endian buffer.
14929
- * @param num The BigInt to convert.
14930
- * @param width The number of bytes that the resulting buffer should be.
14931
- * @returns A big-endian buffer representation of num.
14932
- */
14933
- function toBufferBE(num, width) {
14934
- {
14935
- const hex = num.toString(16);
14936
- return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
14937
- }
14938
- }
14939
- browser$1.toBufferBE = toBufferBE;
14940
-
14941
- const encodeDecode = layout => {
14942
- const decode = layout.decode.bind(layout);
14943
- const encode = layout.encode.bind(layout);
14944
- return {
14945
- decode,
14946
- encode
14947
- };
14948
- };
14949
-
14950
- const bigInt = length => property => {
14951
- const layout = blob(length, property);
14952
- const {
14953
- encode,
14954
- decode
14955
- } = encodeDecode(layout);
14956
- const bigIntLayout = layout;
14957
-
14958
- bigIntLayout.decode = (buffer$1, offset) => {
14959
- const src = decode(buffer$1, offset);
14960
- return toBigIntLE_1(buffer.Buffer.from(src));
14961
- };
14962
-
14963
- bigIntLayout.encode = (bigInt, buffer, offset) => {
14964
- const src = toBufferLE_1(bigInt, length);
14965
- return encode(src, buffer, offset);
14966
- };
14935
+ }
14967
14936
 
14968
- return bigIntLayout;
14969
- };
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
+ }
14970
14963
 
14971
- const u64 = bigInt(8);
14964
+ }
14972
14965
 
14973
14966
  /**
14974
14967
  * Create account system transaction params
@@ -15685,6 +15678,312 @@ var solanaWeb3 = (function (exports) {
15685
15678
  }
15686
15679
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
15687
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
+
15688
15987
  // rest of the Transaction fields
15689
15988
  //
15690
15989
  // TODO: replace 300 with a proper constant for the size of the other
@@ -19254,6 +19553,8 @@ var solanaWeb3 = (function (exports) {
19254
19553
 
19255
19554
  var RpcClient = browser;
19256
19555
 
19556
+ const URL = globalThis.URL;
19557
+
19257
19558
  const MINIMUM_SLOT_PER_EPOCH = 32; // Returns the number of trailing zeros in the binary representation of self.
19258
19559
 
19259
19560
  function trailingZeros(n) {
@@ -19651,7 +19952,11 @@ var solanaWeb3 = (function (exports) {
19651
19952
  data: array(string()),
19652
19953
  rentEpoch: optional(number())
19653
19954
  }))))),
19654
- unitsConsumed: optional(number())
19955
+ unitsConsumed: optional(number()),
19956
+ returnData: optional(nullable(type({
19957
+ programId: string(),
19958
+ data: tuple([string(), literal('base64')])
19959
+ })))
19655
19960
  }));
19656
19961
 
19657
19962
  /**
@@ -20988,16 +21293,6 @@ var solanaWeb3 = (function (exports) {
20988
21293
  reject(err);
20989
21294
  }
20990
21295
  });
20991
-
20992
- const checkBlockHeight = async () => {
20993
- try {
20994
- const blockHeight = await this.getBlockHeight(commitment);
20995
- return blockHeight;
20996
- } catch (_e) {
20997
- return -1;
20998
- }
20999
- };
21000
-
21001
21296
  const expiryPromise = new Promise(resolve => {
21002
21297
  if (typeof strategy === 'string') {
21003
21298
  let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
@@ -21021,6 +21316,15 @@ var solanaWeb3 = (function (exports) {
21021
21316
  } else {
21022
21317
  let config = strategy;
21023
21318
 
21319
+ const checkBlockHeight = async () => {
21320
+ try {
21321
+ const blockHeight = await this.getBlockHeight(commitment);
21322
+ return blockHeight;
21323
+ } catch (_e) {
21324
+ return -1;
21325
+ }
21326
+ };
21327
+
21024
21328
  (async () => {
21025
21329
  let currentBlockHeight = await checkBlockHeight();
21026
21330
  if (done) return;
@@ -30361,6 +30665,8 @@ var solanaWeb3 = (function (exports) {
30361
30665
  const LAMPORTS_PER_SOL = 1000000000;
30362
30666
 
30363
30667
  exports.Account = Account;
30668
+ exports.AddressLookupTableInstruction = AddressLookupTableInstruction;
30669
+ exports.AddressLookupTableProgram = AddressLookupTableProgram;
30364
30670
  exports.Authorized = Authorized;
30365
30671
  exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
30366
30672
  exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
@@ -30376,6 +30682,7 @@ var solanaWeb3 = (function (exports) {
30376
30682
  exports.FeeCalculatorLayout = FeeCalculatorLayout;
30377
30683
  exports.Keypair = Keypair;
30378
30684
  exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
30685
+ exports.LOOKUP_TABLE_INSTRUCTION_LAYOUTS = LOOKUP_TABLE_INSTRUCTION_LAYOUTS;
30379
30686
  exports.Loader = Loader;
30380
30687
  exports.Lockup = Lockup;
30381
30688
  exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;