@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.cjs.js CHANGED
@@ -7,8 +7,8 @@ var buffer = require('buffer');
7
7
  var BN = require('bn.js');
8
8
  var bs58 = require('bs58');
9
9
  var borsh = require('borsh');
10
- var BufferLayout = require('@solana/buffer-layout');
11
10
  var bigintBuffer = require('bigint-buffer');
11
+ var BufferLayout = require('@solana/buffer-layout');
12
12
  var superstruct = require('superstruct');
13
13
  var rpcWebsockets = require('rpc-websockets');
14
14
  var RpcClient = require('jayson/lib/client/browser');
@@ -2094,18 +2094,6 @@ class Account {
2094
2094
  }
2095
2095
  }
2096
2096
 
2097
- const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
2098
-
2099
- /**
2100
- * Maximum over-the-wire size of a Transaction
2101
- *
2102
- * 1280 is IPv6 minimum MTU
2103
- * 40 bytes is the size of the IPv6 header
2104
- * 8 bytes is the size of the fragment header
2105
- */
2106
- const PACKET_DATA_SIZE = 1280 - 40 - 8;
2107
- const SIGNATURE_LENGTH_IN_BYTES = 64;
2108
-
2109
2097
  /**
2110
2098
  * Layout for a public key
2111
2099
  */
@@ -2157,17 +2145,159 @@ const voteInit = (property = 'voteInit') => {
2157
2145
  return BufferLayout__namespace.struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), BufferLayout__namespace.u8('commission')], property);
2158
2146
  };
2159
2147
  function getAlloc(type, fields) {
2160
- let alloc = 0;
2161
- type.layout.fields.forEach(item => {
2148
+ const getItemAlloc = item => {
2162
2149
  if (item.span >= 0) {
2163
- alloc += item.span;
2150
+ return item.span;
2164
2151
  } else if (typeof item.alloc === 'function') {
2165
- alloc += item.alloc(fields[item.property]);
2152
+ return item.alloc(fields[item.property]);
2153
+ } else if ('count' in item && 'elementLayout' in item) {
2154
+ const field = fields[item.property];
2155
+ if (Array.isArray(field)) {
2156
+ return field.length * getItemAlloc(item.elementLayout);
2157
+ }
2166
2158
  }
2159
+ // Couldn't determine allocated size of layout
2160
+ return 0;
2161
+ };
2162
+ let alloc = 0;
2163
+ type.layout.fields.forEach(item => {
2164
+ alloc += getItemAlloc(item);
2167
2165
  });
2168
2166
  return alloc;
2169
2167
  }
2170
2168
 
2169
+ const encodeDecode = layout => {
2170
+ const decode = layout.decode.bind(layout);
2171
+ const encode = layout.encode.bind(layout);
2172
+ return {
2173
+ decode,
2174
+ encode
2175
+ };
2176
+ };
2177
+ const bigInt = length => property => {
2178
+ const layout = BufferLayout.blob(length, property);
2179
+ const {
2180
+ encode,
2181
+ decode
2182
+ } = encodeDecode(layout);
2183
+ const bigIntLayout = layout;
2184
+ bigIntLayout.decode = (buffer$1, offset) => {
2185
+ const src = decode(buffer$1, offset);
2186
+ return bigintBuffer.toBigIntLE(buffer.Buffer.from(src));
2187
+ };
2188
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
2189
+ const src = bigintBuffer.toBufferLE(bigInt, length);
2190
+ return encode(src, buffer, offset);
2191
+ };
2192
+ return bigIntLayout;
2193
+ };
2194
+ const u64 = bigInt(8);
2195
+
2196
+ /**
2197
+ * @internal
2198
+ */
2199
+
2200
+ /**
2201
+ * Populate a buffer of instruction data using an InstructionType
2202
+ * @internal
2203
+ */
2204
+ function encodeData(type, fields) {
2205
+ const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
2206
+ const data = buffer.Buffer.alloc(allocLength);
2207
+ const layoutFields = Object.assign({
2208
+ instruction: type.index
2209
+ }, fields);
2210
+ type.layout.encode(layoutFields, data);
2211
+ return data;
2212
+ }
2213
+
2214
+ /**
2215
+ * Decode instruction data buffer using an InstructionType
2216
+ * @internal
2217
+ */
2218
+ function decodeData(type, buffer) {
2219
+ let data;
2220
+ try {
2221
+ data = type.layout.decode(buffer);
2222
+ } catch (err) {
2223
+ throw new Error('invalid instruction; ' + err);
2224
+ }
2225
+ if (data.instruction !== type.index) {
2226
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
2227
+ }
2228
+ return data;
2229
+ }
2230
+
2231
+ /**
2232
+ * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
2233
+ *
2234
+ * @internal
2235
+ */
2236
+ const FeeCalculatorLayout = BufferLayout__namespace.nu64('lamportsPerSignature');
2237
+
2238
+ /**
2239
+ * Calculator for transaction fees.
2240
+ */
2241
+
2242
+ /**
2243
+ * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
2244
+ *
2245
+ * @internal
2246
+ */
2247
+ const NonceAccountLayout = BufferLayout__namespace.struct([BufferLayout__namespace.u32('version'), BufferLayout__namespace.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout__namespace.struct([FeeCalculatorLayout], 'feeCalculator')]);
2248
+ const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
2249
+ /**
2250
+ * NonceAccount class
2251
+ */
2252
+ class NonceAccount {
2253
+ /**
2254
+ * @internal
2255
+ */
2256
+ constructor(args) {
2257
+ this.authorizedPubkey = void 0;
2258
+ this.nonce = void 0;
2259
+ this.feeCalculator = void 0;
2260
+ this.authorizedPubkey = args.authorizedPubkey;
2261
+ this.nonce = args.nonce;
2262
+ this.feeCalculator = args.feeCalculator;
2263
+ }
2264
+
2265
+ /**
2266
+ * Deserialize NonceAccount from the account data.
2267
+ *
2268
+ * @param buffer account data
2269
+ * @return NonceAccount
2270
+ */
2271
+ static fromAccountData(buffer) {
2272
+ const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
2273
+ return new NonceAccount({
2274
+ authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
2275
+ nonce: new PublicKey(nonceAccount.nonce).toString(),
2276
+ feeCalculator: nonceAccount.feeCalculator
2277
+ });
2278
+ }
2279
+ }
2280
+
2281
+ const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2282
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2283
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2284
+ const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2285
+ const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2286
+ const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2287
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2288
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2289
+ const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2290
+
2291
+ /**
2292
+ * Maximum over-the-wire size of a Transaction
2293
+ *
2294
+ * 1280 is IPv6 minimum MTU
2295
+ * 40 bytes is the size of the IPv6 header
2296
+ * 8 bytes is the size of the fragment header
2297
+ */
2298
+ const PACKET_DATA_SIZE = 1280 - 40 - 8;
2299
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
2300
+
2171
2301
  function decodeLength(bytes) {
2172
2302
  let len = 0;
2173
2303
  let size = 0;
@@ -3086,163 +3216,6 @@ class Transaction {
3086
3216
  }
3087
3217
  }
3088
3218
 
3089
- const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
3090
- const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
3091
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
3092
- const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
3093
- const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
3094
- const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
3095
- const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
3096
- const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
3097
- const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
3098
-
3099
- /**
3100
- * Sign, send and confirm a transaction.
3101
- *
3102
- * If `commitment` option is not specified, defaults to 'max' commitment.
3103
- *
3104
- * @param {Connection} connection
3105
- * @param {Transaction} transaction
3106
- * @param {Array<Signer>} signers
3107
- * @param {ConfirmOptions} [options]
3108
- * @returns {Promise<TransactionSignature>}
3109
- */
3110
- async function sendAndConfirmTransaction(connection, transaction, signers, options) {
3111
- const sendOptions = options && {
3112
- skipPreflight: options.skipPreflight,
3113
- preflightCommitment: options.preflightCommitment || options.commitment,
3114
- maxRetries: options.maxRetries,
3115
- minContextSlot: options.minContextSlot
3116
- };
3117
- const signature = await connection.sendTransaction(transaction, signers, sendOptions);
3118
- const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
3119
- signature: signature,
3120
- blockhash: transaction.recentBlockhash,
3121
- lastValidBlockHeight: transaction.lastValidBlockHeight
3122
- }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
3123
- if (status.err) {
3124
- throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
3125
- }
3126
- return signature;
3127
- }
3128
-
3129
- // zzz
3130
- function sleep(ms) {
3131
- return new Promise(resolve => setTimeout(resolve, ms));
3132
- }
3133
-
3134
- /**
3135
- * @internal
3136
- */
3137
-
3138
- /**
3139
- * Populate a buffer of instruction data using an InstructionType
3140
- * @internal
3141
- */
3142
- function encodeData(type, fields) {
3143
- const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
3144
- const data = buffer.Buffer.alloc(allocLength);
3145
- const layoutFields = Object.assign({
3146
- instruction: type.index
3147
- }, fields);
3148
- type.layout.encode(layoutFields, data);
3149
- return data;
3150
- }
3151
-
3152
- /**
3153
- * Decode instruction data buffer using an InstructionType
3154
- * @internal
3155
- */
3156
- function decodeData(type, buffer) {
3157
- let data;
3158
- try {
3159
- data = type.layout.decode(buffer);
3160
- } catch (err) {
3161
- throw new Error('invalid instruction; ' + err);
3162
- }
3163
- if (data.instruction !== type.index) {
3164
- throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3165
- }
3166
- return data;
3167
- }
3168
-
3169
- /**
3170
- * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
3171
- *
3172
- * @internal
3173
- */
3174
- const FeeCalculatorLayout = BufferLayout__namespace.nu64('lamportsPerSignature');
3175
-
3176
- /**
3177
- * Calculator for transaction fees.
3178
- */
3179
-
3180
- /**
3181
- * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
3182
- *
3183
- * @internal
3184
- */
3185
- const NonceAccountLayout = BufferLayout__namespace.struct([BufferLayout__namespace.u32('version'), BufferLayout__namespace.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout__namespace.struct([FeeCalculatorLayout], 'feeCalculator')]);
3186
- const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
3187
- /**
3188
- * NonceAccount class
3189
- */
3190
- class NonceAccount {
3191
- /**
3192
- * @internal
3193
- */
3194
- constructor(args) {
3195
- this.authorizedPubkey = void 0;
3196
- this.nonce = void 0;
3197
- this.feeCalculator = void 0;
3198
- this.authorizedPubkey = args.authorizedPubkey;
3199
- this.nonce = args.nonce;
3200
- this.feeCalculator = args.feeCalculator;
3201
- }
3202
-
3203
- /**
3204
- * Deserialize NonceAccount from the account data.
3205
- *
3206
- * @param buffer account data
3207
- * @return NonceAccount
3208
- */
3209
- static fromAccountData(buffer) {
3210
- const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
3211
- return new NonceAccount({
3212
- authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
3213
- nonce: new PublicKey(nonceAccount.nonce).toString(),
3214
- feeCalculator: nonceAccount.feeCalculator
3215
- });
3216
- }
3217
- }
3218
-
3219
- const encodeDecode = layout => {
3220
- const decode = layout.decode.bind(layout);
3221
- const encode = layout.encode.bind(layout);
3222
- return {
3223
- decode,
3224
- encode
3225
- };
3226
- };
3227
- const bigInt = length => property => {
3228
- const layout = BufferLayout.blob(length, property);
3229
- const {
3230
- encode,
3231
- decode
3232
- } = encodeDecode(layout);
3233
- const bigIntLayout = layout;
3234
- bigIntLayout.decode = (buffer$1, offset) => {
3235
- const src = decode(buffer$1, offset);
3236
- return bigintBuffer.toBigIntLE(buffer.Buffer.from(src));
3237
- };
3238
- bigIntLayout.encode = (bigInt, buffer, offset) => {
3239
- const src = bigintBuffer.toBufferLE(bigInt, length);
3240
- return encode(src, buffer, offset);
3241
- };
3242
- return bigIntLayout;
3243
- };
3244
- const u64 = bigInt(8);
3245
-
3246
3219
  /**
3247
3220
  * Create account system transaction params
3248
3221
  */
@@ -3976,6 +3949,291 @@ class SystemProgram {
3976
3949
  }
3977
3950
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3978
3951
 
3952
+ /**
3953
+ * An enumeration of valid LookupTableInstructionType's
3954
+ */
3955
+
3956
+ /**
3957
+ * An enumeration of valid address lookup table InstructionType's
3958
+ * @internal
3959
+ */
3960
+ const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
3961
+ CreateLookupTable: {
3962
+ index: 0,
3963
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('recentSlot'), BufferLayout__namespace.u8('bumpSeed')])
3964
+ },
3965
+ FreezeLookupTable: {
3966
+ index: 1,
3967
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
3968
+ },
3969
+ ExtendLookupTable: {
3970
+ index: 2,
3971
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64(), BufferLayout__namespace.seq(publicKey(), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'addresses')])
3972
+ },
3973
+ DeactivateLookupTable: {
3974
+ index: 3,
3975
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
3976
+ },
3977
+ CloseLookupTable: {
3978
+ index: 4,
3979
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
3980
+ }
3981
+ });
3982
+ class AddressLookupTableInstruction {
3983
+ /**
3984
+ * @internal
3985
+ */
3986
+ constructor() {}
3987
+ static decodeInstructionType(instruction) {
3988
+ this.checkProgramId(instruction.programId);
3989
+ const instructionTypeLayout = BufferLayout__namespace.u32('instruction');
3990
+ const index = instructionTypeLayout.decode(instruction.data);
3991
+ let type;
3992
+ for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
3993
+ if (layout.index == index) {
3994
+ type = layoutType;
3995
+ break;
3996
+ }
3997
+ }
3998
+ if (!type) {
3999
+ throw new Error('Invalid Instruction. Should be a LookupTable Instruction');
4000
+ }
4001
+ return type;
4002
+ }
4003
+ static decodeCreateLookupTable(instruction) {
4004
+ this.checkProgramId(instruction.programId);
4005
+ this.checkKeysLength(instruction.keys, 4);
4006
+ const {
4007
+ recentSlot
4008
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);
4009
+ return {
4010
+ authority: instruction.keys[1].pubkey,
4011
+ payer: instruction.keys[2].pubkey,
4012
+ recentSlot: Number(recentSlot)
4013
+ };
4014
+ }
4015
+ static decodeExtendLookupTable(instruction) {
4016
+ this.checkProgramId(instruction.programId);
4017
+ if (instruction.keys.length < 2) {
4018
+ throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);
4019
+ }
4020
+ const {
4021
+ addresses
4022
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);
4023
+ return {
4024
+ lookupTable: instruction.keys[0].pubkey,
4025
+ authority: instruction.keys[1].pubkey,
4026
+ payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
4027
+ addresses: addresses.map(buffer => new PublicKey(buffer))
4028
+ };
4029
+ }
4030
+ static decodeCloseLookupTable(instruction) {
4031
+ this.checkProgramId(instruction.programId);
4032
+ this.checkKeysLength(instruction.keys, 3);
4033
+ return {
4034
+ lookupTable: instruction.keys[0].pubkey,
4035
+ authority: instruction.keys[1].pubkey,
4036
+ recipient: instruction.keys[2].pubkey
4037
+ };
4038
+ }
4039
+ static decodeFreezeLookupTable(instruction) {
4040
+ this.checkProgramId(instruction.programId);
4041
+ this.checkKeysLength(instruction.keys, 2);
4042
+ return {
4043
+ lookupTable: instruction.keys[0].pubkey,
4044
+ authority: instruction.keys[1].pubkey
4045
+ };
4046
+ }
4047
+ static decodeDeactivateLookupTable(instruction) {
4048
+ this.checkProgramId(instruction.programId);
4049
+ this.checkKeysLength(instruction.keys, 2);
4050
+ return {
4051
+ lookupTable: instruction.keys[0].pubkey,
4052
+ authority: instruction.keys[1].pubkey
4053
+ };
4054
+ }
4055
+
4056
+ /**
4057
+ * @internal
4058
+ */
4059
+ static checkProgramId(programId) {
4060
+ if (!programId.equals(AddressLookupTableProgram.programId)) {
4061
+ throw new Error('invalid instruction; programId is not AddressLookupTable Program');
4062
+ }
4063
+ }
4064
+ /**
4065
+ * @internal
4066
+ */
4067
+ static checkKeysLength(keys, expectedLength) {
4068
+ if (keys.length < expectedLength) {
4069
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
4070
+ }
4071
+ }
4072
+ }
4073
+ class AddressLookupTableProgram {
4074
+ /**
4075
+ * @internal
4076
+ */
4077
+ constructor() {}
4078
+ static createLookupTable(params) {
4079
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), bigintBuffer.toBufferLE(BigInt(params.recentSlot), 8)], this.programId);
4080
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
4081
+ const data = encodeData(type, {
4082
+ recentSlot: BigInt(params.recentSlot),
4083
+ bumpSeed: bumpSeed
4084
+ });
4085
+ const keys = [{
4086
+ pubkey: lookupTableAddress,
4087
+ isSigner: false,
4088
+ isWritable: true
4089
+ }, {
4090
+ pubkey: params.authority,
4091
+ isSigner: true,
4092
+ isWritable: false
4093
+ }, {
4094
+ pubkey: params.payer,
4095
+ isSigner: true,
4096
+ isWritable: true
4097
+ }, {
4098
+ pubkey: SystemProgram.programId,
4099
+ isSigner: false,
4100
+ isWritable: false
4101
+ }];
4102
+ return [new TransactionInstruction({
4103
+ programId: this.programId,
4104
+ keys: keys,
4105
+ data: data
4106
+ }), lookupTableAddress];
4107
+ }
4108
+ static freezeLookupTable(params) {
4109
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
4110
+ const data = encodeData(type);
4111
+ const keys = [{
4112
+ pubkey: params.lookupTable,
4113
+ isSigner: false,
4114
+ isWritable: true
4115
+ }, {
4116
+ pubkey: params.authority,
4117
+ isSigner: true,
4118
+ isWritable: false
4119
+ }];
4120
+ return new TransactionInstruction({
4121
+ programId: this.programId,
4122
+ keys: keys,
4123
+ data: data
4124
+ });
4125
+ }
4126
+ static extendLookupTable(params) {
4127
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
4128
+ const data = encodeData(type, {
4129
+ addresses: params.addresses.map(addr => addr.toBytes())
4130
+ });
4131
+ const keys = [{
4132
+ pubkey: params.lookupTable,
4133
+ isSigner: false,
4134
+ isWritable: true
4135
+ }, {
4136
+ pubkey: params.authority,
4137
+ isSigner: true,
4138
+ isWritable: false
4139
+ }];
4140
+ if (params.payer) {
4141
+ keys.push({
4142
+ pubkey: params.payer,
4143
+ isSigner: true,
4144
+ isWritable: true
4145
+ }, {
4146
+ pubkey: SystemProgram.programId,
4147
+ isSigner: false,
4148
+ isWritable: false
4149
+ });
4150
+ }
4151
+ return new TransactionInstruction({
4152
+ programId: this.programId,
4153
+ keys: keys,
4154
+ data: data
4155
+ });
4156
+ }
4157
+ static deactivateLookupTable(params) {
4158
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
4159
+ const data = encodeData(type);
4160
+ const keys = [{
4161
+ pubkey: params.lookupTable,
4162
+ isSigner: false,
4163
+ isWritable: true
4164
+ }, {
4165
+ pubkey: params.authority,
4166
+ isSigner: true,
4167
+ isWritable: false
4168
+ }];
4169
+ return new TransactionInstruction({
4170
+ programId: this.programId,
4171
+ keys: keys,
4172
+ data: data
4173
+ });
4174
+ }
4175
+ static closeLookupTable(params) {
4176
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
4177
+ const data = encodeData(type);
4178
+ const keys = [{
4179
+ pubkey: params.lookupTable,
4180
+ isSigner: false,
4181
+ isWritable: true
4182
+ }, {
4183
+ pubkey: params.authority,
4184
+ isSigner: true,
4185
+ isWritable: false
4186
+ }, {
4187
+ pubkey: params.recipient,
4188
+ isSigner: false,
4189
+ isWritable: true
4190
+ }];
4191
+ return new TransactionInstruction({
4192
+ programId: this.programId,
4193
+ keys: keys,
4194
+ data: data
4195
+ });
4196
+ }
4197
+ }
4198
+ AddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');
4199
+
4200
+ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
4201
+
4202
+ /**
4203
+ * Sign, send and confirm a transaction.
4204
+ *
4205
+ * If `commitment` option is not specified, defaults to 'max' commitment.
4206
+ *
4207
+ * @param {Connection} connection
4208
+ * @param {Transaction} transaction
4209
+ * @param {Array<Signer>} signers
4210
+ * @param {ConfirmOptions} [options]
4211
+ * @returns {Promise<TransactionSignature>}
4212
+ */
4213
+ async function sendAndConfirmTransaction(connection, transaction, signers, options) {
4214
+ const sendOptions = options && {
4215
+ skipPreflight: options.skipPreflight,
4216
+ preflightCommitment: options.preflightCommitment || options.commitment,
4217
+ maxRetries: options.maxRetries,
4218
+ minContextSlot: options.minContextSlot
4219
+ };
4220
+ const signature = await connection.sendTransaction(transaction, signers, sendOptions);
4221
+ const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
4222
+ signature: signature,
4223
+ blockhash: transaction.recentBlockhash,
4224
+ lastValidBlockHeight: transaction.lastValidBlockHeight
4225
+ }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
4226
+ if (status.err) {
4227
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
4228
+ }
4229
+ return signature;
4230
+ }
4231
+
4232
+ // zzz
4233
+ function sleep(ms) {
4234
+ return new Promise(resolve => setTimeout(resolve, ms));
4235
+ }
4236
+
3979
4237
  // Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the
3980
4238
  // rest of the Transaction fields
3981
4239
  //
@@ -5943,7 +6201,7 @@ const LogsNotificationResult = superstruct.type({
5943
6201
 
5944
6202
  /** @internal */
5945
6203
  const COMMON_HTTP_HEADERS = {
5946
- 'solana-client': `js/${"1.47.5" }`
6204
+ 'solana-client': `js/${"1.48.1" }`
5947
6205
  };
5948
6206
 
5949
6207
  /**
@@ -9883,6 +10141,8 @@ function clusterApiUrl(cluster, tls) {
9883
10141
  const LAMPORTS_PER_SOL = 1000000000;
9884
10142
 
9885
10143
  exports.Account = Account;
10144
+ exports.AddressLookupTableInstruction = AddressLookupTableInstruction;
10145
+ exports.AddressLookupTableProgram = AddressLookupTableProgram;
9886
10146
  exports.Authorized = Authorized;
9887
10147
  exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
9888
10148
  exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
@@ -9898,6 +10158,7 @@ exports.EpochSchedule = EpochSchedule;
9898
10158
  exports.FeeCalculatorLayout = FeeCalculatorLayout;
9899
10159
  exports.Keypair = Keypair;
9900
10160
  exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
10161
+ exports.LOOKUP_TABLE_INSTRUCTION_LAYOUTS = LOOKUP_TABLE_INSTRUCTION_LAYOUTS;
9901
10162
  exports.Loader = Loader;
9902
10163
  exports.Lockup = Lockup;
9903
10164
  exports.MAX_SEED_LENGTH = MAX_SEED_LENGTH;