@solana/web3.js 1.40.1 → 1.41.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.
- package/lib/index.browser.cjs.js +133 -0
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +131 -1
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +133 -0
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +59 -0
- package/lib/index.esm.js +131 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +133 -0
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/compute-budget.ts +189 -0
- package/src/index.ts +1 -0
package/lib/index.d.ts
CHANGED
|
@@ -2165,6 +2165,65 @@ declare module '@solana/web3.js' {
|
|
|
2165
2165
|
): Promise<boolean>;
|
|
2166
2166
|
}
|
|
2167
2167
|
|
|
2168
|
+
/**
|
|
2169
|
+
* Compute Budget Instruction class
|
|
2170
|
+
*/
|
|
2171
|
+
export class ComputeBudgetInstruction {
|
|
2172
|
+
/**
|
|
2173
|
+
* Decode a compute budget instruction and retrieve the instruction type.
|
|
2174
|
+
*/
|
|
2175
|
+
static decodeInstructionType(
|
|
2176
|
+
instruction: TransactionInstruction,
|
|
2177
|
+
): ComputeBudgetInstructionType;
|
|
2178
|
+
/**
|
|
2179
|
+
* Decode request units compute budget instruction and retrieve the instruction params.
|
|
2180
|
+
*/
|
|
2181
|
+
static decodeRequestUnits(
|
|
2182
|
+
instruction: TransactionInstruction,
|
|
2183
|
+
): RequestUnitsParams;
|
|
2184
|
+
/**
|
|
2185
|
+
* Decode request heap frame compute budget instruction and retrieve the instruction params.
|
|
2186
|
+
*/
|
|
2187
|
+
static decodeRequestHeapFrame(
|
|
2188
|
+
instruction: TransactionInstruction,
|
|
2189
|
+
): RequestHeapFrameParams;
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* An enumeration of valid ComputeBudgetInstructionType's
|
|
2193
|
+
*/
|
|
2194
|
+
export type ComputeBudgetInstructionType =
|
|
2195
|
+
| 'RequestUnits'
|
|
2196
|
+
| 'RequestHeapFrame';
|
|
2197
|
+
/**
|
|
2198
|
+
* Request units instruction params
|
|
2199
|
+
*/
|
|
2200
|
+
interface RequestUnitsParams {
|
|
2201
|
+
/** Units to request for transaction-wide compute */
|
|
2202
|
+
units: number;
|
|
2203
|
+
/** Additional fee to pay */
|
|
2204
|
+
additionalFee: number;
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Request heap frame instruction params
|
|
2208
|
+
*/
|
|
2209
|
+
export type RequestHeapFrameParams = {
|
|
2210
|
+
/** Requested transaction-wide program heap size in bytes. Must be multiple of 1024. Applies to each program, including CPIs. */
|
|
2211
|
+
bytes: number;
|
|
2212
|
+
};
|
|
2213
|
+
/**
|
|
2214
|
+
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
2215
|
+
*/
|
|
2216
|
+
export class ComputeBudgetProgram {
|
|
2217
|
+
/**
|
|
2218
|
+
* Public key that identifies the Compute Budget program
|
|
2219
|
+
*/
|
|
2220
|
+
static programId: PublicKey;
|
|
2221
|
+
static requestUnits(params: RequestUnitsParams): TransactionInstruction;
|
|
2222
|
+
static requestHeapFrame(
|
|
2223
|
+
params: RequestHeapFrameParams,
|
|
2224
|
+
): TransactionInstruction;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2168
2227
|
/**
|
|
2169
2228
|
* Params for creating an ed25519 instruction using a public key
|
|
2170
2229
|
*/
|
package/lib/index.esm.js
CHANGED
|
@@ -4081,6 +4081,136 @@ class BpfLoader {
|
|
|
4081
4081
|
|
|
4082
4082
|
}
|
|
4083
4083
|
|
|
4084
|
+
/**
|
|
4085
|
+
* Compute Budget Instruction class
|
|
4086
|
+
*/
|
|
4087
|
+
|
|
4088
|
+
class ComputeBudgetInstruction {
|
|
4089
|
+
/**
|
|
4090
|
+
* @internal
|
|
4091
|
+
*/
|
|
4092
|
+
constructor() {}
|
|
4093
|
+
/**
|
|
4094
|
+
* Decode a compute budget instruction and retrieve the instruction type.
|
|
4095
|
+
*/
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
static decodeInstructionType(instruction) {
|
|
4099
|
+
this.checkProgramId(instruction.programId);
|
|
4100
|
+
const instructionTypeLayout = BufferLayout.u8('instruction');
|
|
4101
|
+
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
4102
|
+
let type;
|
|
4103
|
+
|
|
4104
|
+
for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
|
|
4105
|
+
if (layout.index == typeIndex) {
|
|
4106
|
+
type = ixType;
|
|
4107
|
+
break;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
if (!type) {
|
|
4112
|
+
throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
return type;
|
|
4116
|
+
}
|
|
4117
|
+
/**
|
|
4118
|
+
* Decode request units compute budget instruction and retrieve the instruction params.
|
|
4119
|
+
*/
|
|
4120
|
+
|
|
4121
|
+
|
|
4122
|
+
static decodeRequestUnits(instruction) {
|
|
4123
|
+
this.checkProgramId(instruction.programId);
|
|
4124
|
+
const {
|
|
4125
|
+
units,
|
|
4126
|
+
additionalFee
|
|
4127
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);
|
|
4128
|
+
return {
|
|
4129
|
+
units,
|
|
4130
|
+
additionalFee
|
|
4131
|
+
};
|
|
4132
|
+
}
|
|
4133
|
+
/**
|
|
4134
|
+
* Decode request heap frame compute budget instruction and retrieve the instruction params.
|
|
4135
|
+
*/
|
|
4136
|
+
|
|
4137
|
+
|
|
4138
|
+
static decodeRequestHeapFrame(instruction) {
|
|
4139
|
+
this.checkProgramId(instruction.programId);
|
|
4140
|
+
const {
|
|
4141
|
+
bytes
|
|
4142
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);
|
|
4143
|
+
return {
|
|
4144
|
+
bytes
|
|
4145
|
+
};
|
|
4146
|
+
}
|
|
4147
|
+
/**
|
|
4148
|
+
* @internal
|
|
4149
|
+
*/
|
|
4150
|
+
|
|
4151
|
+
|
|
4152
|
+
static checkProgramId(programId) {
|
|
4153
|
+
if (!programId.equals(ComputeBudgetProgram.programId)) {
|
|
4154
|
+
throw new Error('invalid instruction; programId is not ComputeBudgetProgram');
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
}
|
|
4159
|
+
/**
|
|
4160
|
+
* An enumeration of valid ComputeBudgetInstructionType's
|
|
4161
|
+
*/
|
|
4162
|
+
|
|
4163
|
+
/**
|
|
4164
|
+
* An enumeration of valid ComputeBudget InstructionType's
|
|
4165
|
+
* @internal
|
|
4166
|
+
*/
|
|
4167
|
+
const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
4168
|
+
RequestUnits: {
|
|
4169
|
+
index: 0,
|
|
4170
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('units'), BufferLayout.u32('additionalFee')])
|
|
4171
|
+
},
|
|
4172
|
+
RequestHeapFrame: {
|
|
4173
|
+
index: 1,
|
|
4174
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('bytes')])
|
|
4175
|
+
}
|
|
4176
|
+
});
|
|
4177
|
+
/**
|
|
4178
|
+
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
4179
|
+
*/
|
|
4180
|
+
|
|
4181
|
+
class ComputeBudgetProgram {
|
|
4182
|
+
/**
|
|
4183
|
+
* @internal
|
|
4184
|
+
*/
|
|
4185
|
+
constructor() {}
|
|
4186
|
+
/**
|
|
4187
|
+
* Public key that identifies the Compute Budget program
|
|
4188
|
+
*/
|
|
4189
|
+
|
|
4190
|
+
|
|
4191
|
+
static requestUnits(params) {
|
|
4192
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
|
|
4193
|
+
const data = encodeData(type, params);
|
|
4194
|
+
return new TransactionInstruction({
|
|
4195
|
+
keys: [],
|
|
4196
|
+
programId: this.programId,
|
|
4197
|
+
data
|
|
4198
|
+
});
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
static requestHeapFrame(params) {
|
|
4202
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;
|
|
4203
|
+
const data = encodeData(type, params);
|
|
4204
|
+
return new TransactionInstruction({
|
|
4205
|
+
keys: [],
|
|
4206
|
+
programId: this.programId,
|
|
4207
|
+
data
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
}
|
|
4212
|
+
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4213
|
+
|
|
4084
4214
|
const DESTROY_TIMEOUT_MS = 5000;
|
|
4085
4215
|
class AgentManager {
|
|
4086
4216
|
static _newAgent(useHttps) {
|
|
@@ -9372,5 +9502,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
9372
9502
|
|
|
9373
9503
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
9374
9504
|
|
|
9375
|
-
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, 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, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
9505
|
+
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, 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, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
9376
9506
|
//# sourceMappingURL=index.esm.js.map
|