@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.cjs.js
CHANGED
|
@@ -4116,6 +4116,136 @@ class BpfLoader {
|
|
|
4116
4116
|
|
|
4117
4117
|
}
|
|
4118
4118
|
|
|
4119
|
+
/**
|
|
4120
|
+
* Compute Budget Instruction class
|
|
4121
|
+
*/
|
|
4122
|
+
|
|
4123
|
+
class ComputeBudgetInstruction {
|
|
4124
|
+
/**
|
|
4125
|
+
* @internal
|
|
4126
|
+
*/
|
|
4127
|
+
constructor() {}
|
|
4128
|
+
/**
|
|
4129
|
+
* Decode a compute budget instruction and retrieve the instruction type.
|
|
4130
|
+
*/
|
|
4131
|
+
|
|
4132
|
+
|
|
4133
|
+
static decodeInstructionType(instruction) {
|
|
4134
|
+
this.checkProgramId(instruction.programId);
|
|
4135
|
+
const instructionTypeLayout = BufferLayout__namespace.u8('instruction');
|
|
4136
|
+
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
4137
|
+
let type;
|
|
4138
|
+
|
|
4139
|
+
for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
|
|
4140
|
+
if (layout.index == typeIndex) {
|
|
4141
|
+
type = ixType;
|
|
4142
|
+
break;
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
if (!type) {
|
|
4147
|
+
throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
return type;
|
|
4151
|
+
}
|
|
4152
|
+
/**
|
|
4153
|
+
* Decode request units compute budget instruction and retrieve the instruction params.
|
|
4154
|
+
*/
|
|
4155
|
+
|
|
4156
|
+
|
|
4157
|
+
static decodeRequestUnits(instruction) {
|
|
4158
|
+
this.checkProgramId(instruction.programId);
|
|
4159
|
+
const {
|
|
4160
|
+
units,
|
|
4161
|
+
additionalFee
|
|
4162
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);
|
|
4163
|
+
return {
|
|
4164
|
+
units,
|
|
4165
|
+
additionalFee
|
|
4166
|
+
};
|
|
4167
|
+
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Decode request heap frame compute budget instruction and retrieve the instruction params.
|
|
4170
|
+
*/
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
static decodeRequestHeapFrame(instruction) {
|
|
4174
|
+
this.checkProgramId(instruction.programId);
|
|
4175
|
+
const {
|
|
4176
|
+
bytes
|
|
4177
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);
|
|
4178
|
+
return {
|
|
4179
|
+
bytes
|
|
4180
|
+
};
|
|
4181
|
+
}
|
|
4182
|
+
/**
|
|
4183
|
+
* @internal
|
|
4184
|
+
*/
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
static checkProgramId(programId) {
|
|
4188
|
+
if (!programId.equals(ComputeBudgetProgram.programId)) {
|
|
4189
|
+
throw new Error('invalid instruction; programId is not ComputeBudgetProgram');
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
}
|
|
4194
|
+
/**
|
|
4195
|
+
* An enumeration of valid ComputeBudgetInstructionType's
|
|
4196
|
+
*/
|
|
4197
|
+
|
|
4198
|
+
/**
|
|
4199
|
+
* An enumeration of valid ComputeBudget InstructionType's
|
|
4200
|
+
* @internal
|
|
4201
|
+
*/
|
|
4202
|
+
const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
4203
|
+
RequestUnits: {
|
|
4204
|
+
index: 0,
|
|
4205
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), BufferLayout__namespace.u32('units'), BufferLayout__namespace.u32('additionalFee')])
|
|
4206
|
+
},
|
|
4207
|
+
RequestHeapFrame: {
|
|
4208
|
+
index: 1,
|
|
4209
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), BufferLayout__namespace.u32('bytes')])
|
|
4210
|
+
}
|
|
4211
|
+
});
|
|
4212
|
+
/**
|
|
4213
|
+
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
4214
|
+
*/
|
|
4215
|
+
|
|
4216
|
+
class ComputeBudgetProgram {
|
|
4217
|
+
/**
|
|
4218
|
+
* @internal
|
|
4219
|
+
*/
|
|
4220
|
+
constructor() {}
|
|
4221
|
+
/**
|
|
4222
|
+
* Public key that identifies the Compute Budget program
|
|
4223
|
+
*/
|
|
4224
|
+
|
|
4225
|
+
|
|
4226
|
+
static requestUnits(params) {
|
|
4227
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
|
|
4228
|
+
const data = encodeData(type, params);
|
|
4229
|
+
return new TransactionInstruction({
|
|
4230
|
+
keys: [],
|
|
4231
|
+
programId: this.programId,
|
|
4232
|
+
data
|
|
4233
|
+
});
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4236
|
+
static requestHeapFrame(params) {
|
|
4237
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;
|
|
4238
|
+
const data = encodeData(type, params);
|
|
4239
|
+
return new TransactionInstruction({
|
|
4240
|
+
keys: [],
|
|
4241
|
+
programId: this.programId,
|
|
4242
|
+
data
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
|
|
4246
|
+
}
|
|
4247
|
+
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4248
|
+
|
|
4119
4249
|
const DESTROY_TIMEOUT_MS = 5000;
|
|
4120
4250
|
class AgentManager {
|
|
4121
4251
|
static _newAgent(useHttps) {
|
|
@@ -9413,6 +9543,9 @@ exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
|
9413
9543
|
exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
|
|
9414
9544
|
exports.BPF_LOADER_PROGRAM_ID = BPF_LOADER_PROGRAM_ID;
|
|
9415
9545
|
exports.BpfLoader = BpfLoader;
|
|
9546
|
+
exports.COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS;
|
|
9547
|
+
exports.ComputeBudgetInstruction = ComputeBudgetInstruction;
|
|
9548
|
+
exports.ComputeBudgetProgram = ComputeBudgetProgram;
|
|
9416
9549
|
exports.Connection = Connection;
|
|
9417
9550
|
exports.Ed25519Program = Ed25519Program;
|
|
9418
9551
|
exports.Enum = Enum;
|