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