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