@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.esm.js CHANGED
@@ -3,9 +3,9 @@ import { Buffer } from 'buffer';
3
3
  import BN from 'bn.js';
4
4
  import bs58 from 'bs58';
5
5
  import { serialize, deserialize, deserializeUnchecked } from 'borsh';
6
+ import { toBigIntLE, toBufferLE } from 'bigint-buffer';
6
7
  import * as BufferLayout from '@solana/buffer-layout';
7
8
  import { blob } from '@solana/buffer-layout';
8
- import { toBigIntLE, toBufferLE } from 'bigint-buffer';
9
9
  import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
10
10
  import { Client } from 'rpc-websockets';
11
11
  import RpcClient from 'jayson/lib/client/browser';
@@ -2060,18 +2060,6 @@ class Account {
2060
2060
  }
2061
2061
  }
2062
2062
 
2063
- const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
2064
-
2065
- /**
2066
- * Maximum over-the-wire size of a Transaction
2067
- *
2068
- * 1280 is IPv6 minimum MTU
2069
- * 40 bytes is the size of the IPv6 header
2070
- * 8 bytes is the size of the fragment header
2071
- */
2072
- const PACKET_DATA_SIZE = 1280 - 40 - 8;
2073
- const SIGNATURE_LENGTH_IN_BYTES = 64;
2074
-
2075
2063
  /**
2076
2064
  * Layout for a public key
2077
2065
  */
@@ -2123,17 +2111,159 @@ const voteInit = (property = 'voteInit') => {
2123
2111
  return BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), BufferLayout.u8('commission')], property);
2124
2112
  };
2125
2113
  function getAlloc(type, fields) {
2126
- let alloc = 0;
2127
- type.layout.fields.forEach(item => {
2114
+ const getItemAlloc = item => {
2128
2115
  if (item.span >= 0) {
2129
- alloc += item.span;
2116
+ return item.span;
2130
2117
  } else if (typeof item.alloc === 'function') {
2131
- alloc += item.alloc(fields[item.property]);
2118
+ return item.alloc(fields[item.property]);
2119
+ } else if ('count' in item && 'elementLayout' in item) {
2120
+ const field = fields[item.property];
2121
+ if (Array.isArray(field)) {
2122
+ return field.length * getItemAlloc(item.elementLayout);
2123
+ }
2132
2124
  }
2125
+ // Couldn't determine allocated size of layout
2126
+ return 0;
2127
+ };
2128
+ let alloc = 0;
2129
+ type.layout.fields.forEach(item => {
2130
+ alloc += getItemAlloc(item);
2133
2131
  });
2134
2132
  return alloc;
2135
2133
  }
2136
2134
 
2135
+ const encodeDecode = layout => {
2136
+ const decode = layout.decode.bind(layout);
2137
+ const encode = layout.encode.bind(layout);
2138
+ return {
2139
+ decode,
2140
+ encode
2141
+ };
2142
+ };
2143
+ const bigInt = length => property => {
2144
+ const layout = blob(length, property);
2145
+ const {
2146
+ encode,
2147
+ decode
2148
+ } = encodeDecode(layout);
2149
+ const bigIntLayout = layout;
2150
+ bigIntLayout.decode = (buffer, offset) => {
2151
+ const src = decode(buffer, offset);
2152
+ return toBigIntLE(Buffer.from(src));
2153
+ };
2154
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
2155
+ const src = toBufferLE(bigInt, length);
2156
+ return encode(src, buffer, offset);
2157
+ };
2158
+ return bigIntLayout;
2159
+ };
2160
+ const u64 = bigInt(8);
2161
+
2162
+ /**
2163
+ * @internal
2164
+ */
2165
+
2166
+ /**
2167
+ * Populate a buffer of instruction data using an InstructionType
2168
+ * @internal
2169
+ */
2170
+ function encodeData(type, fields) {
2171
+ const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
2172
+ const data = Buffer.alloc(allocLength);
2173
+ const layoutFields = Object.assign({
2174
+ instruction: type.index
2175
+ }, fields);
2176
+ type.layout.encode(layoutFields, data);
2177
+ return data;
2178
+ }
2179
+
2180
+ /**
2181
+ * Decode instruction data buffer using an InstructionType
2182
+ * @internal
2183
+ */
2184
+ function decodeData(type, buffer) {
2185
+ let data;
2186
+ try {
2187
+ data = type.layout.decode(buffer);
2188
+ } catch (err) {
2189
+ throw new Error('invalid instruction; ' + err);
2190
+ }
2191
+ if (data.instruction !== type.index) {
2192
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
2193
+ }
2194
+ return data;
2195
+ }
2196
+
2197
+ /**
2198
+ * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
2199
+ *
2200
+ * @internal
2201
+ */
2202
+ const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
2203
+
2204
+ /**
2205
+ * Calculator for transaction fees.
2206
+ */
2207
+
2208
+ /**
2209
+ * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
2210
+ *
2211
+ * @internal
2212
+ */
2213
+ const NonceAccountLayout = BufferLayout.struct([BufferLayout.u32('version'), BufferLayout.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator')]);
2214
+ const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
2215
+ /**
2216
+ * NonceAccount class
2217
+ */
2218
+ class NonceAccount {
2219
+ /**
2220
+ * @internal
2221
+ */
2222
+ constructor(args) {
2223
+ this.authorizedPubkey = void 0;
2224
+ this.nonce = void 0;
2225
+ this.feeCalculator = void 0;
2226
+ this.authorizedPubkey = args.authorizedPubkey;
2227
+ this.nonce = args.nonce;
2228
+ this.feeCalculator = args.feeCalculator;
2229
+ }
2230
+
2231
+ /**
2232
+ * Deserialize NonceAccount from the account data.
2233
+ *
2234
+ * @param buffer account data
2235
+ * @return NonceAccount
2236
+ */
2237
+ static fromAccountData(buffer) {
2238
+ const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
2239
+ return new NonceAccount({
2240
+ authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
2241
+ nonce: new PublicKey(nonceAccount.nonce).toString(),
2242
+ feeCalculator: nonceAccount.feeCalculator
2243
+ });
2244
+ }
2245
+ }
2246
+
2247
+ const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2248
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2249
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2250
+ const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2251
+ const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2252
+ const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2253
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2254
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2255
+ const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2256
+
2257
+ /**
2258
+ * Maximum over-the-wire size of a Transaction
2259
+ *
2260
+ * 1280 is IPv6 minimum MTU
2261
+ * 40 bytes is the size of the IPv6 header
2262
+ * 8 bytes is the size of the fragment header
2263
+ */
2264
+ const PACKET_DATA_SIZE = 1280 - 40 - 8;
2265
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
2266
+
2137
2267
  function decodeLength(bytes) {
2138
2268
  let len = 0;
2139
2269
  let size = 0;
@@ -3052,163 +3182,6 @@ class Transaction {
3052
3182
  }
3053
3183
  }
3054
3184
 
3055
- const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
3056
- const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
3057
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
3058
- const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
3059
- const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
3060
- const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
3061
- const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
3062
- const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
3063
- const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
3064
-
3065
- /**
3066
- * Sign, send and confirm a transaction.
3067
- *
3068
- * If `commitment` option is not specified, defaults to 'max' commitment.
3069
- *
3070
- * @param {Connection} connection
3071
- * @param {Transaction} transaction
3072
- * @param {Array<Signer>} signers
3073
- * @param {ConfirmOptions} [options]
3074
- * @returns {Promise<TransactionSignature>}
3075
- */
3076
- async function sendAndConfirmTransaction(connection, transaction, signers, options) {
3077
- const sendOptions = options && {
3078
- skipPreflight: options.skipPreflight,
3079
- preflightCommitment: options.preflightCommitment || options.commitment,
3080
- maxRetries: options.maxRetries,
3081
- minContextSlot: options.minContextSlot
3082
- };
3083
- const signature = await connection.sendTransaction(transaction, signers, sendOptions);
3084
- const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
3085
- signature: signature,
3086
- blockhash: transaction.recentBlockhash,
3087
- lastValidBlockHeight: transaction.lastValidBlockHeight
3088
- }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
3089
- if (status.err) {
3090
- throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
3091
- }
3092
- return signature;
3093
- }
3094
-
3095
- // zzz
3096
- function sleep(ms) {
3097
- return new Promise(resolve => setTimeout(resolve, ms));
3098
- }
3099
-
3100
- /**
3101
- * @internal
3102
- */
3103
-
3104
- /**
3105
- * Populate a buffer of instruction data using an InstructionType
3106
- * @internal
3107
- */
3108
- function encodeData(type, fields) {
3109
- const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
3110
- const data = Buffer.alloc(allocLength);
3111
- const layoutFields = Object.assign({
3112
- instruction: type.index
3113
- }, fields);
3114
- type.layout.encode(layoutFields, data);
3115
- return data;
3116
- }
3117
-
3118
- /**
3119
- * Decode instruction data buffer using an InstructionType
3120
- * @internal
3121
- */
3122
- function decodeData(type, buffer) {
3123
- let data;
3124
- try {
3125
- data = type.layout.decode(buffer);
3126
- } catch (err) {
3127
- throw new Error('invalid instruction; ' + err);
3128
- }
3129
- if (data.instruction !== type.index) {
3130
- throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3131
- }
3132
- return data;
3133
- }
3134
-
3135
- /**
3136
- * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
3137
- *
3138
- * @internal
3139
- */
3140
- const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
3141
-
3142
- /**
3143
- * Calculator for transaction fees.
3144
- */
3145
-
3146
- /**
3147
- * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
3148
- *
3149
- * @internal
3150
- */
3151
- const NonceAccountLayout = BufferLayout.struct([BufferLayout.u32('version'), BufferLayout.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator')]);
3152
- const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
3153
- /**
3154
- * NonceAccount class
3155
- */
3156
- class NonceAccount {
3157
- /**
3158
- * @internal
3159
- */
3160
- constructor(args) {
3161
- this.authorizedPubkey = void 0;
3162
- this.nonce = void 0;
3163
- this.feeCalculator = void 0;
3164
- this.authorizedPubkey = args.authorizedPubkey;
3165
- this.nonce = args.nonce;
3166
- this.feeCalculator = args.feeCalculator;
3167
- }
3168
-
3169
- /**
3170
- * Deserialize NonceAccount from the account data.
3171
- *
3172
- * @param buffer account data
3173
- * @return NonceAccount
3174
- */
3175
- static fromAccountData(buffer) {
3176
- const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
3177
- return new NonceAccount({
3178
- authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
3179
- nonce: new PublicKey(nonceAccount.nonce).toString(),
3180
- feeCalculator: nonceAccount.feeCalculator
3181
- });
3182
- }
3183
- }
3184
-
3185
- const encodeDecode = layout => {
3186
- const decode = layout.decode.bind(layout);
3187
- const encode = layout.encode.bind(layout);
3188
- return {
3189
- decode,
3190
- encode
3191
- };
3192
- };
3193
- const bigInt = length => property => {
3194
- const layout = blob(length, property);
3195
- const {
3196
- encode,
3197
- decode
3198
- } = encodeDecode(layout);
3199
- const bigIntLayout = layout;
3200
- bigIntLayout.decode = (buffer, offset) => {
3201
- const src = decode(buffer, offset);
3202
- return toBigIntLE(Buffer.from(src));
3203
- };
3204
- bigIntLayout.encode = (bigInt, buffer, offset) => {
3205
- const src = toBufferLE(bigInt, length);
3206
- return encode(src, buffer, offset);
3207
- };
3208
- return bigIntLayout;
3209
- };
3210
- const u64 = bigInt(8);
3211
-
3212
3185
  /**
3213
3186
  * Create account system transaction params
3214
3187
  */
@@ -3942,6 +3915,291 @@ class SystemProgram {
3942
3915
  }
3943
3916
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3944
3917
 
3918
+ /**
3919
+ * An enumeration of valid LookupTableInstructionType's
3920
+ */
3921
+
3922
+ /**
3923
+ * An enumeration of valid address lookup table InstructionType's
3924
+ * @internal
3925
+ */
3926
+ const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
3927
+ CreateLookupTable: {
3928
+ index: 0,
3929
+ layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('recentSlot'), BufferLayout.u8('bumpSeed')])
3930
+ },
3931
+ FreezeLookupTable: {
3932
+ index: 1,
3933
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
3934
+ },
3935
+ ExtendLookupTable: {
3936
+ index: 2,
3937
+ layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64(), BufferLayout.seq(publicKey(), BufferLayout.offset(BufferLayout.u32(), -8), 'addresses')])
3938
+ },
3939
+ DeactivateLookupTable: {
3940
+ index: 3,
3941
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
3942
+ },
3943
+ CloseLookupTable: {
3944
+ index: 4,
3945
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
3946
+ }
3947
+ });
3948
+ class AddressLookupTableInstruction {
3949
+ /**
3950
+ * @internal
3951
+ */
3952
+ constructor() {}
3953
+ static decodeInstructionType(instruction) {
3954
+ this.checkProgramId(instruction.programId);
3955
+ const instructionTypeLayout = BufferLayout.u32('instruction');
3956
+ const index = instructionTypeLayout.decode(instruction.data);
3957
+ let type;
3958
+ for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
3959
+ if (layout.index == index) {
3960
+ type = layoutType;
3961
+ break;
3962
+ }
3963
+ }
3964
+ if (!type) {
3965
+ throw new Error('Invalid Instruction. Should be a LookupTable Instruction');
3966
+ }
3967
+ return type;
3968
+ }
3969
+ static decodeCreateLookupTable(instruction) {
3970
+ this.checkProgramId(instruction.programId);
3971
+ this.checkKeysLength(instruction.keys, 4);
3972
+ const {
3973
+ recentSlot
3974
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);
3975
+ return {
3976
+ authority: instruction.keys[1].pubkey,
3977
+ payer: instruction.keys[2].pubkey,
3978
+ recentSlot: Number(recentSlot)
3979
+ };
3980
+ }
3981
+ static decodeExtendLookupTable(instruction) {
3982
+ this.checkProgramId(instruction.programId);
3983
+ if (instruction.keys.length < 2) {
3984
+ throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);
3985
+ }
3986
+ const {
3987
+ addresses
3988
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);
3989
+ return {
3990
+ lookupTable: instruction.keys[0].pubkey,
3991
+ authority: instruction.keys[1].pubkey,
3992
+ payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
3993
+ addresses: addresses.map(buffer => new PublicKey(buffer))
3994
+ };
3995
+ }
3996
+ static decodeCloseLookupTable(instruction) {
3997
+ this.checkProgramId(instruction.programId);
3998
+ this.checkKeysLength(instruction.keys, 3);
3999
+ return {
4000
+ lookupTable: instruction.keys[0].pubkey,
4001
+ authority: instruction.keys[1].pubkey,
4002
+ recipient: instruction.keys[2].pubkey
4003
+ };
4004
+ }
4005
+ static decodeFreezeLookupTable(instruction) {
4006
+ this.checkProgramId(instruction.programId);
4007
+ this.checkKeysLength(instruction.keys, 2);
4008
+ return {
4009
+ lookupTable: instruction.keys[0].pubkey,
4010
+ authority: instruction.keys[1].pubkey
4011
+ };
4012
+ }
4013
+ static decodeDeactivateLookupTable(instruction) {
4014
+ this.checkProgramId(instruction.programId);
4015
+ this.checkKeysLength(instruction.keys, 2);
4016
+ return {
4017
+ lookupTable: instruction.keys[0].pubkey,
4018
+ authority: instruction.keys[1].pubkey
4019
+ };
4020
+ }
4021
+
4022
+ /**
4023
+ * @internal
4024
+ */
4025
+ static checkProgramId(programId) {
4026
+ if (!programId.equals(AddressLookupTableProgram.programId)) {
4027
+ throw new Error('invalid instruction; programId is not AddressLookupTable Program');
4028
+ }
4029
+ }
4030
+ /**
4031
+ * @internal
4032
+ */
4033
+ static checkKeysLength(keys, expectedLength) {
4034
+ if (keys.length < expectedLength) {
4035
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
4036
+ }
4037
+ }
4038
+ }
4039
+ class AddressLookupTableProgram {
4040
+ /**
4041
+ * @internal
4042
+ */
4043
+ constructor() {}
4044
+ static createLookupTable(params) {
4045
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE(BigInt(params.recentSlot), 8)], this.programId);
4046
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
4047
+ const data = encodeData(type, {
4048
+ recentSlot: BigInt(params.recentSlot),
4049
+ bumpSeed: bumpSeed
4050
+ });
4051
+ const keys = [{
4052
+ pubkey: lookupTableAddress,
4053
+ isSigner: false,
4054
+ isWritable: true
4055
+ }, {
4056
+ pubkey: params.authority,
4057
+ isSigner: true,
4058
+ isWritable: false
4059
+ }, {
4060
+ pubkey: params.payer,
4061
+ isSigner: true,
4062
+ isWritable: true
4063
+ }, {
4064
+ pubkey: SystemProgram.programId,
4065
+ isSigner: false,
4066
+ isWritable: false
4067
+ }];
4068
+ return [new TransactionInstruction({
4069
+ programId: this.programId,
4070
+ keys: keys,
4071
+ data: data
4072
+ }), lookupTableAddress];
4073
+ }
4074
+ static freezeLookupTable(params) {
4075
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
4076
+ const data = encodeData(type);
4077
+ const keys = [{
4078
+ pubkey: params.lookupTable,
4079
+ isSigner: false,
4080
+ isWritable: true
4081
+ }, {
4082
+ pubkey: params.authority,
4083
+ isSigner: true,
4084
+ isWritable: false
4085
+ }];
4086
+ return new TransactionInstruction({
4087
+ programId: this.programId,
4088
+ keys: keys,
4089
+ data: data
4090
+ });
4091
+ }
4092
+ static extendLookupTable(params) {
4093
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
4094
+ const data = encodeData(type, {
4095
+ addresses: params.addresses.map(addr => addr.toBytes())
4096
+ });
4097
+ const keys = [{
4098
+ pubkey: params.lookupTable,
4099
+ isSigner: false,
4100
+ isWritable: true
4101
+ }, {
4102
+ pubkey: params.authority,
4103
+ isSigner: true,
4104
+ isWritable: false
4105
+ }];
4106
+ if (params.payer) {
4107
+ keys.push({
4108
+ pubkey: params.payer,
4109
+ isSigner: true,
4110
+ isWritable: true
4111
+ }, {
4112
+ pubkey: SystemProgram.programId,
4113
+ isSigner: false,
4114
+ isWritable: false
4115
+ });
4116
+ }
4117
+ return new TransactionInstruction({
4118
+ programId: this.programId,
4119
+ keys: keys,
4120
+ data: data
4121
+ });
4122
+ }
4123
+ static deactivateLookupTable(params) {
4124
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
4125
+ const data = encodeData(type);
4126
+ const keys = [{
4127
+ pubkey: params.lookupTable,
4128
+ isSigner: false,
4129
+ isWritable: true
4130
+ }, {
4131
+ pubkey: params.authority,
4132
+ isSigner: true,
4133
+ isWritable: false
4134
+ }];
4135
+ return new TransactionInstruction({
4136
+ programId: this.programId,
4137
+ keys: keys,
4138
+ data: data
4139
+ });
4140
+ }
4141
+ static closeLookupTable(params) {
4142
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
4143
+ const data = encodeData(type);
4144
+ const keys = [{
4145
+ pubkey: params.lookupTable,
4146
+ isSigner: false,
4147
+ isWritable: true
4148
+ }, {
4149
+ pubkey: params.authority,
4150
+ isSigner: true,
4151
+ isWritable: false
4152
+ }, {
4153
+ pubkey: params.recipient,
4154
+ isSigner: false,
4155
+ isWritable: true
4156
+ }];
4157
+ return new TransactionInstruction({
4158
+ programId: this.programId,
4159
+ keys: keys,
4160
+ data: data
4161
+ });
4162
+ }
4163
+ }
4164
+ AddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');
4165
+
4166
+ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
4167
+
4168
+ /**
4169
+ * Sign, send and confirm a transaction.
4170
+ *
4171
+ * If `commitment` option is not specified, defaults to 'max' commitment.
4172
+ *
4173
+ * @param {Connection} connection
4174
+ * @param {Transaction} transaction
4175
+ * @param {Array<Signer>} signers
4176
+ * @param {ConfirmOptions} [options]
4177
+ * @returns {Promise<TransactionSignature>}
4178
+ */
4179
+ async function sendAndConfirmTransaction(connection, transaction, signers, options) {
4180
+ const sendOptions = options && {
4181
+ skipPreflight: options.skipPreflight,
4182
+ preflightCommitment: options.preflightCommitment || options.commitment,
4183
+ maxRetries: options.maxRetries,
4184
+ minContextSlot: options.minContextSlot
4185
+ };
4186
+ const signature = await connection.sendTransaction(transaction, signers, sendOptions);
4187
+ const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
4188
+ signature: signature,
4189
+ blockhash: transaction.recentBlockhash,
4190
+ lastValidBlockHeight: transaction.lastValidBlockHeight
4191
+ }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
4192
+ if (status.err) {
4193
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
4194
+ }
4195
+ return signature;
4196
+ }
4197
+
4198
+ // zzz
4199
+ function sleep(ms) {
4200
+ return new Promise(resolve => setTimeout(resolve, ms));
4201
+ }
4202
+
3945
4203
  // Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the
3946
4204
  // rest of the Transaction fields
3947
4205
  //
@@ -5909,7 +6167,7 @@ const LogsNotificationResult = type({
5909
6167
 
5910
6168
  /** @internal */
5911
6169
  const COMMON_HTTP_HEADERS = {
5912
- 'solana-client': `js/${"1.47.5" }`
6170
+ 'solana-client': `js/${"1.48.1" }`
5913
6171
  };
5914
6172
 
5915
6173
  /**
@@ -9848,5 +10106,5 @@ function clusterApiUrl(cluster, tls) {
9848
10106
  */
9849
10107
  const LAMPORTS_PER_SOL = 1000000000;
9850
10108
 
9851
- export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, SolanaJSONRPCError, SolanaJSONRPCErrorCode, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionExpiredBlockheightExceededError, TransactionExpiredTimeoutError, TransactionInstruction, TransactionStatus, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
10109
+ export { Account, AddressLookupTableInstruction, AddressLookupTableProgram, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, LOOKUP_TABLE_INSTRUCTION_LAYOUTS, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, SolanaJSONRPCError, SolanaJSONRPCErrorCode, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionExpiredBlockheightExceededError, TransactionExpiredTimeoutError, TransactionInstruction, TransactionStatus, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
9852
10110
  //# sourceMappingURL=index.esm.js.map