@solana/web3.js 1.47.4 → 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.
@@ -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';
@@ -2070,18 +2070,6 @@ class Account {
2070
2070
 
2071
2071
  }
2072
2072
 
2073
- const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
2074
-
2075
- /**
2076
- * Maximum over-the-wire size of a Transaction
2077
- *
2078
- * 1280 is IPv6 minimum MTU
2079
- * 40 bytes is the size of the IPv6 header
2080
- * 8 bytes is the size of the fragment header
2081
- */
2082
- const PACKET_DATA_SIZE = 1280 - 40 - 8;
2083
- const SIGNATURE_LENGTH_IN_BYTES = 64;
2084
-
2085
2073
  /**
2086
2074
  * Layout for a public key
2087
2075
  */
@@ -2143,17 +2131,170 @@ const voteInit = (property = 'voteInit') => {
2143
2131
  return BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), BufferLayout.u8('commission')], property);
2144
2132
  };
2145
2133
  function getAlloc(type, fields) {
2146
- let alloc = 0;
2147
- type.layout.fields.forEach(item => {
2134
+ const getItemAlloc = item => {
2148
2135
  if (item.span >= 0) {
2149
- alloc += item.span;
2136
+ return item.span;
2150
2137
  } else if (typeof item.alloc === 'function') {
2151
- alloc += item.alloc(fields[item.property]);
2152
- }
2138
+ return item.alloc(fields[item.property]);
2139
+ } else if ('count' in item && 'elementLayout' in item) {
2140
+ const field = fields[item.property];
2141
+
2142
+ if (Array.isArray(field)) {
2143
+ return field.length * getItemAlloc(item.elementLayout);
2144
+ }
2145
+ } // Couldn't determine allocated size of layout
2146
+
2147
+
2148
+ return 0;
2149
+ };
2150
+
2151
+ let alloc = 0;
2152
+ type.layout.fields.forEach(item => {
2153
+ alloc += getItemAlloc(item);
2153
2154
  });
2154
2155
  return alloc;
2155
2156
  }
2156
2157
 
2158
+ const encodeDecode = layout => {
2159
+ const decode = layout.decode.bind(layout);
2160
+ const encode = layout.encode.bind(layout);
2161
+ return {
2162
+ decode,
2163
+ encode
2164
+ };
2165
+ };
2166
+
2167
+ const bigInt = length => property => {
2168
+ const layout = blob(length, property);
2169
+ const {
2170
+ encode,
2171
+ decode
2172
+ } = encodeDecode(layout);
2173
+ const bigIntLayout = layout;
2174
+
2175
+ bigIntLayout.decode = (buffer, offset) => {
2176
+ const src = decode(buffer, offset);
2177
+ return toBigIntLE(Buffer.from(src));
2178
+ };
2179
+
2180
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
2181
+ const src = toBufferLE(bigInt, length);
2182
+ return encode(src, buffer, offset);
2183
+ };
2184
+
2185
+ return bigIntLayout;
2186
+ };
2187
+
2188
+ const u64 = bigInt(8);
2189
+
2190
+ /**
2191
+ * Populate a buffer of instruction data using an InstructionType
2192
+ * @internal
2193
+ */
2194
+ function encodeData(type, fields) {
2195
+ const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
2196
+ const data = Buffer.alloc(allocLength);
2197
+ const layoutFields = Object.assign({
2198
+ instruction: type.index
2199
+ }, fields);
2200
+ type.layout.encode(layoutFields, data);
2201
+ return data;
2202
+ }
2203
+ /**
2204
+ * Decode instruction data buffer using an InstructionType
2205
+ * @internal
2206
+ */
2207
+
2208
+ function decodeData(type, buffer) {
2209
+ let data;
2210
+
2211
+ try {
2212
+ data = type.layout.decode(buffer);
2213
+ } catch (err) {
2214
+ throw new Error('invalid instruction; ' + err);
2215
+ }
2216
+
2217
+ if (data.instruction !== type.index) {
2218
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
2219
+ }
2220
+
2221
+ return data;
2222
+ }
2223
+
2224
+ /**
2225
+ * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
2226
+ *
2227
+ * @internal
2228
+ */
2229
+
2230
+ const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
2231
+ /**
2232
+ * Calculator for transaction fees.
2233
+ */
2234
+
2235
+ /**
2236
+ * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
2237
+ *
2238
+ * @internal
2239
+ */
2240
+
2241
+ const NonceAccountLayout = BufferLayout.struct([BufferLayout.u32('version'), BufferLayout.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator')]);
2242
+ const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
2243
+
2244
+ /**
2245
+ * NonceAccount class
2246
+ */
2247
+ class NonceAccount {
2248
+ /**
2249
+ * @internal
2250
+ */
2251
+ constructor(args) {
2252
+ this.authorizedPubkey = void 0;
2253
+ this.nonce = void 0;
2254
+ this.feeCalculator = void 0;
2255
+ this.authorizedPubkey = args.authorizedPubkey;
2256
+ this.nonce = args.nonce;
2257
+ this.feeCalculator = args.feeCalculator;
2258
+ }
2259
+ /**
2260
+ * Deserialize NonceAccount from the account data.
2261
+ *
2262
+ * @param buffer account data
2263
+ * @return NonceAccount
2264
+ */
2265
+
2266
+
2267
+ static fromAccountData(buffer) {
2268
+ const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
2269
+ return new NonceAccount({
2270
+ authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
2271
+ nonce: new PublicKey(nonceAccount.nonce).toString(),
2272
+ feeCalculator: nonceAccount.feeCalculator
2273
+ });
2274
+ }
2275
+
2276
+ }
2277
+
2278
+ const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2279
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2280
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2281
+ const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2282
+ const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2283
+ const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2284
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2285
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2286
+ const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2287
+
2288
+ /**
2289
+ * Maximum over-the-wire size of a Transaction
2290
+ *
2291
+ * 1280 is IPv6 minimum MTU
2292
+ * 40 bytes is the size of the IPv6 header
2293
+ * 8 bytes is the size of the fragment header
2294
+ */
2295
+ const PACKET_DATA_SIZE = 1280 - 40 - 8;
2296
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
2297
+
2157
2298
  function decodeLength(bytes) {
2158
2299
  let len = 0;
2159
2300
  let size = 0;
@@ -3067,202 +3208,35 @@ class Transaction {
3067
3208
 
3068
3209
  }
3069
3210
 
3070
- const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
3071
- const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
3072
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
3073
- const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
3074
- const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
3075
- const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
3076
- const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
3077
- const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
3078
- const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
3079
-
3080
3211
  /**
3081
- * Sign, send and confirm a transaction.
3082
- *
3083
- * If `commitment` option is not specified, defaults to 'max' commitment.
3084
- *
3085
- * @param {Connection} connection
3086
- * @param {Transaction} transaction
3087
- * @param {Array<Signer>} signers
3088
- * @param {ConfirmOptions} [options]
3089
- * @returns {Promise<TransactionSignature>}
3212
+ * Create account system transaction params
3090
3213
  */
3091
- async function sendAndConfirmTransaction(connection, transaction, signers, options) {
3092
- const sendOptions = options && {
3093
- skipPreflight: options.skipPreflight,
3094
- preflightCommitment: options.preflightCommitment || options.commitment,
3095
- maxRetries: options.maxRetries,
3096
- minContextSlot: options.minContextSlot
3097
- };
3098
- const signature = await connection.sendTransaction(transaction, signers, sendOptions);
3099
- const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
3100
- signature: signature,
3101
- blockhash: transaction.recentBlockhash,
3102
- lastValidBlockHeight: transaction.lastValidBlockHeight
3103
- }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
3104
-
3105
- if (status.err) {
3106
- throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
3107
- }
3108
-
3109
- return signature;
3110
- }
3111
-
3112
- // zzz
3113
- function sleep(ms) {
3114
- return new Promise(resolve => setTimeout(resolve, ms));
3115
- }
3116
3214
 
3117
3215
  /**
3118
- * Populate a buffer of instruction data using an InstructionType
3119
- * @internal
3120
- */
3121
- function encodeData(type, fields) {
3122
- const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
3123
- const data = Buffer.alloc(allocLength);
3124
- const layoutFields = Object.assign({
3125
- instruction: type.index
3126
- }, fields);
3127
- type.layout.encode(layoutFields, data);
3128
- return data;
3129
- }
3130
- /**
3131
- * Decode instruction data buffer using an InstructionType
3132
- * @internal
3216
+ * System Instruction class
3133
3217
  */
3218
+ class SystemInstruction {
3219
+ /**
3220
+ * @internal
3221
+ */
3222
+ constructor() {}
3223
+ /**
3224
+ * Decode a system instruction and retrieve the instruction type.
3225
+ */
3134
3226
 
3135
- function decodeData(type, buffer) {
3136
- let data;
3137
3227
 
3138
- try {
3139
- data = type.layout.decode(buffer);
3140
- } catch (err) {
3141
- throw new Error('invalid instruction; ' + err);
3142
- }
3228
+ static decodeInstructionType(instruction) {
3229
+ this.checkProgramId(instruction.programId);
3230
+ const instructionTypeLayout = BufferLayout.u32('instruction');
3231
+ const typeIndex = instructionTypeLayout.decode(instruction.data);
3232
+ let type;
3143
3233
 
3144
- if (data.instruction !== type.index) {
3145
- throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3146
- }
3147
-
3148
- return data;
3149
- }
3150
-
3151
- /**
3152
- * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
3153
- *
3154
- * @internal
3155
- */
3156
-
3157
- const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
3158
- /**
3159
- * Calculator for transaction fees.
3160
- */
3161
-
3162
- /**
3163
- * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
3164
- *
3165
- * @internal
3166
- */
3167
-
3168
- const NonceAccountLayout = BufferLayout.struct([BufferLayout.u32('version'), BufferLayout.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator')]);
3169
- const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
3170
-
3171
- /**
3172
- * NonceAccount class
3173
- */
3174
- class NonceAccount {
3175
- /**
3176
- * @internal
3177
- */
3178
- constructor(args) {
3179
- this.authorizedPubkey = void 0;
3180
- this.nonce = void 0;
3181
- this.feeCalculator = void 0;
3182
- this.authorizedPubkey = args.authorizedPubkey;
3183
- this.nonce = args.nonce;
3184
- this.feeCalculator = args.feeCalculator;
3185
- }
3186
- /**
3187
- * Deserialize NonceAccount from the account data.
3188
- *
3189
- * @param buffer account data
3190
- * @return NonceAccount
3191
- */
3192
-
3193
-
3194
- static fromAccountData(buffer) {
3195
- const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
3196
- return new NonceAccount({
3197
- authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),
3198
- nonce: new PublicKey(nonceAccount.nonce).toString(),
3199
- feeCalculator: nonceAccount.feeCalculator
3200
- });
3201
- }
3202
-
3203
- }
3204
-
3205
- const encodeDecode = layout => {
3206
- const decode = layout.decode.bind(layout);
3207
- const encode = layout.encode.bind(layout);
3208
- return {
3209
- decode,
3210
- encode
3211
- };
3212
- };
3213
-
3214
- const bigInt = length => property => {
3215
- const layout = blob(length, property);
3216
- const {
3217
- encode,
3218
- decode
3219
- } = encodeDecode(layout);
3220
- const bigIntLayout = layout;
3221
-
3222
- bigIntLayout.decode = (buffer, offset) => {
3223
- const src = decode(buffer, offset);
3224
- return toBigIntLE(Buffer.from(src));
3225
- };
3226
-
3227
- bigIntLayout.encode = (bigInt, buffer, offset) => {
3228
- const src = toBufferLE(bigInt, length);
3229
- return encode(src, buffer, offset);
3230
- };
3231
-
3232
- return bigIntLayout;
3233
- };
3234
-
3235
- const u64 = bigInt(8);
3236
-
3237
- /**
3238
- * Create account system transaction params
3239
- */
3240
-
3241
- /**
3242
- * System Instruction class
3243
- */
3244
- class SystemInstruction {
3245
- /**
3246
- * @internal
3247
- */
3248
- constructor() {}
3249
- /**
3250
- * Decode a system instruction and retrieve the instruction type.
3251
- */
3252
-
3253
-
3254
- static decodeInstructionType(instruction) {
3255
- this.checkProgramId(instruction.programId);
3256
- const instructionTypeLayout = BufferLayout.u32('instruction');
3257
- const typeIndex = instructionTypeLayout.decode(instruction.data);
3258
- let type;
3259
-
3260
- for (const [ixType, layout] of Object.entries(SYSTEM_INSTRUCTION_LAYOUTS)) {
3261
- if (layout.index == typeIndex) {
3262
- type = ixType;
3263
- break;
3264
- }
3265
- }
3234
+ for (const [ixType, layout] of Object.entries(SYSTEM_INSTRUCTION_LAYOUTS)) {
3235
+ if (layout.index == typeIndex) {
3236
+ type = ixType;
3237
+ break;
3238
+ }
3239
+ }
3266
3240
 
3267
3241
  if (!type) {
3268
3242
  throw new Error('Instruction type incorrect; not a SystemInstruction');
@@ -3949,6 +3923,312 @@ class SystemProgram {
3949
3923
  }
3950
3924
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3951
3925
 
3926
+ /**
3927
+ * An enumeration of valid address lookup table InstructionType's
3928
+ * @internal
3929
+ */
3930
+ const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({
3931
+ CreateLookupTable: {
3932
+ index: 0,
3933
+ layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('recentSlot'), BufferLayout.u8('bumpSeed')])
3934
+ },
3935
+ FreezeLookupTable: {
3936
+ index: 1,
3937
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
3938
+ },
3939
+ ExtendLookupTable: {
3940
+ index: 2,
3941
+ layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64(), BufferLayout.seq(publicKey(), BufferLayout.offset(BufferLayout.u32(), -8), 'addresses')])
3942
+ },
3943
+ DeactivateLookupTable: {
3944
+ index: 3,
3945
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
3946
+ },
3947
+ CloseLookupTable: {
3948
+ index: 4,
3949
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
3950
+ }
3951
+ });
3952
+ class AddressLookupTableInstruction {
3953
+ /**
3954
+ * @internal
3955
+ */
3956
+ constructor() {}
3957
+
3958
+ static decodeInstructionType(instruction) {
3959
+ this.checkProgramId(instruction.programId);
3960
+ const instructionTypeLayout = BufferLayout.u32('instruction');
3961
+ const index = instructionTypeLayout.decode(instruction.data);
3962
+ let type;
3963
+
3964
+ for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
3965
+ if (layout.index == index) {
3966
+ type = layoutType;
3967
+ break;
3968
+ }
3969
+ }
3970
+
3971
+ if (!type) {
3972
+ throw new Error('Invalid Instruction. Should be a LookupTable Instruction');
3973
+ }
3974
+
3975
+ return type;
3976
+ }
3977
+
3978
+ static decodeCreateLookupTable(instruction) {
3979
+ this.checkProgramId(instruction.programId);
3980
+ this.checkKeysLength(instruction.keys, 4);
3981
+ const {
3982
+ recentSlot
3983
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);
3984
+ return {
3985
+ authority: instruction.keys[1].pubkey,
3986
+ payer: instruction.keys[2].pubkey,
3987
+ recentSlot: Number(recentSlot)
3988
+ };
3989
+ }
3990
+
3991
+ static decodeExtendLookupTable(instruction) {
3992
+ this.checkProgramId(instruction.programId);
3993
+
3994
+ if (instruction.keys.length < 2) {
3995
+ throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);
3996
+ }
3997
+
3998
+ const {
3999
+ addresses
4000
+ } = decodeData(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);
4001
+ return {
4002
+ lookupTable: instruction.keys[0].pubkey,
4003
+ authority: instruction.keys[1].pubkey,
4004
+ payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,
4005
+ addresses: addresses.map(buffer => new PublicKey(buffer))
4006
+ };
4007
+ }
4008
+
4009
+ static decodeCloseLookupTable(instruction) {
4010
+ this.checkProgramId(instruction.programId);
4011
+ this.checkKeysLength(instruction.keys, 3);
4012
+ return {
4013
+ lookupTable: instruction.keys[0].pubkey,
4014
+ authority: instruction.keys[1].pubkey,
4015
+ recipient: instruction.keys[2].pubkey
4016
+ };
4017
+ }
4018
+
4019
+ static decodeFreezeLookupTable(instruction) {
4020
+ this.checkProgramId(instruction.programId);
4021
+ this.checkKeysLength(instruction.keys, 2);
4022
+ return {
4023
+ lookupTable: instruction.keys[0].pubkey,
4024
+ authority: instruction.keys[1].pubkey
4025
+ };
4026
+ }
4027
+
4028
+ static decodeDeactivateLookupTable(instruction) {
4029
+ this.checkProgramId(instruction.programId);
4030
+ this.checkKeysLength(instruction.keys, 2);
4031
+ return {
4032
+ lookupTable: instruction.keys[0].pubkey,
4033
+ authority: instruction.keys[1].pubkey
4034
+ };
4035
+ }
4036
+ /**
4037
+ * @internal
4038
+ */
4039
+
4040
+
4041
+ static checkProgramId(programId) {
4042
+ if (!programId.equals(AddressLookupTableProgram.programId)) {
4043
+ throw new Error('invalid instruction; programId is not AddressLookupTable Program');
4044
+ }
4045
+ }
4046
+ /**
4047
+ * @internal
4048
+ */
4049
+
4050
+
4051
+ static checkKeysLength(keys, expectedLength) {
4052
+ if (keys.length < expectedLength) {
4053
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
4054
+ }
4055
+ }
4056
+
4057
+ }
4058
+ class AddressLookupTableProgram {
4059
+ /**
4060
+ * @internal
4061
+ */
4062
+ constructor() {}
4063
+
4064
+ static createLookupTable(params) {
4065
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE(BigInt(params.recentSlot), 8)], this.programId);
4066
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
4067
+ const data = encodeData(type, {
4068
+ recentSlot: BigInt(params.recentSlot),
4069
+ bumpSeed: bumpSeed
4070
+ });
4071
+ const keys = [{
4072
+ pubkey: lookupTableAddress,
4073
+ isSigner: false,
4074
+ isWritable: true
4075
+ }, {
4076
+ pubkey: params.authority,
4077
+ isSigner: true,
4078
+ isWritable: false
4079
+ }, {
4080
+ pubkey: params.payer,
4081
+ isSigner: true,
4082
+ isWritable: true
4083
+ }, {
4084
+ pubkey: SystemProgram.programId,
4085
+ isSigner: false,
4086
+ isWritable: false
4087
+ }];
4088
+ return [new TransactionInstruction({
4089
+ programId: this.programId,
4090
+ keys: keys,
4091
+ data: data
4092
+ }), lookupTableAddress];
4093
+ }
4094
+
4095
+ static freezeLookupTable(params) {
4096
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
4097
+ const data = encodeData(type);
4098
+ const keys = [{
4099
+ pubkey: params.lookupTable,
4100
+ isSigner: false,
4101
+ isWritable: true
4102
+ }, {
4103
+ pubkey: params.authority,
4104
+ isSigner: true,
4105
+ isWritable: false
4106
+ }];
4107
+ return new TransactionInstruction({
4108
+ programId: this.programId,
4109
+ keys: keys,
4110
+ data: data
4111
+ });
4112
+ }
4113
+
4114
+ static extendLookupTable(params) {
4115
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;
4116
+ const data = encodeData(type, {
4117
+ addresses: params.addresses.map(addr => addr.toBytes())
4118
+ });
4119
+ const keys = [{
4120
+ pubkey: params.lookupTable,
4121
+ isSigner: false,
4122
+ isWritable: true
4123
+ }, {
4124
+ pubkey: params.authority,
4125
+ isSigner: true,
4126
+ isWritable: false
4127
+ }];
4128
+
4129
+ if (params.payer) {
4130
+ keys.push({
4131
+ pubkey: params.payer,
4132
+ isSigner: true,
4133
+ isWritable: true
4134
+ }, {
4135
+ pubkey: SystemProgram.programId,
4136
+ isSigner: false,
4137
+ isWritable: false
4138
+ });
4139
+ }
4140
+
4141
+ return new TransactionInstruction({
4142
+ programId: this.programId,
4143
+ keys: keys,
4144
+ data: data
4145
+ });
4146
+ }
4147
+
4148
+ static deactivateLookupTable(params) {
4149
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
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
+ return new TransactionInstruction({
4161
+ programId: this.programId,
4162
+ keys: keys,
4163
+ data: data
4164
+ });
4165
+ }
4166
+
4167
+ static closeLookupTable(params) {
4168
+ const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
4169
+ const data = encodeData(type);
4170
+ const keys = [{
4171
+ pubkey: params.lookupTable,
4172
+ isSigner: false,
4173
+ isWritable: true
4174
+ }, {
4175
+ pubkey: params.authority,
4176
+ isSigner: true,
4177
+ isWritable: false
4178
+ }, {
4179
+ pubkey: params.recipient,
4180
+ isSigner: false,
4181
+ isWritable: true
4182
+ }];
4183
+ return new TransactionInstruction({
4184
+ programId: this.programId,
4185
+ keys: keys,
4186
+ data: data
4187
+ });
4188
+ }
4189
+
4190
+ }
4191
+ AddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');
4192
+
4193
+ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');
4194
+
4195
+ /**
4196
+ * Sign, send and confirm a transaction.
4197
+ *
4198
+ * If `commitment` option is not specified, defaults to 'max' commitment.
4199
+ *
4200
+ * @param {Connection} connection
4201
+ * @param {Transaction} transaction
4202
+ * @param {Array<Signer>} signers
4203
+ * @param {ConfirmOptions} [options]
4204
+ * @returns {Promise<TransactionSignature>}
4205
+ */
4206
+ async function sendAndConfirmTransaction(connection, transaction, signers, options) {
4207
+ const sendOptions = options && {
4208
+ skipPreflight: options.skipPreflight,
4209
+ preflightCommitment: options.preflightCommitment || options.commitment,
4210
+ maxRetries: options.maxRetries,
4211
+ minContextSlot: options.minContextSlot
4212
+ };
4213
+ const signature = await connection.sendTransaction(transaction, signers, sendOptions);
4214
+ const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
4215
+ signature: signature,
4216
+ blockhash: transaction.recentBlockhash,
4217
+ lastValidBlockHeight: transaction.lastValidBlockHeight
4218
+ }, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
4219
+
4220
+ if (status.err) {
4221
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
4222
+ }
4223
+
4224
+ return signature;
4225
+ }
4226
+
4227
+ // zzz
4228
+ function sleep(ms) {
4229
+ return new Promise(resolve => setTimeout(resolve, ms));
4230
+ }
4231
+
3952
4232
  // rest of the Transaction fields
3953
4233
  //
3954
4234
  // TODO: replace 300 with a proper constant for the size of the other
@@ -9935,5 +10215,5 @@ function clusterApiUrl(cluster, tls) {
9935
10215
 
9936
10216
  const LAMPORTS_PER_SOL = 1000000000;
9937
10217
 
9938
- 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 };
10218
+ 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 };
9939
10219
  //# sourceMappingURL=index.browser.esm.js.map