@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.browser.cjs.js
CHANGED
|
@@ -4104,6 +4104,136 @@ class BpfLoader {
|
|
|
4104
4104
|
|
|
4105
4105
|
}
|
|
4106
4106
|
|
|
4107
|
+
/**
|
|
4108
|
+
* Compute Budget Instruction class
|
|
4109
|
+
*/
|
|
4110
|
+
|
|
4111
|
+
class ComputeBudgetInstruction {
|
|
4112
|
+
/**
|
|
4113
|
+
* @internal
|
|
4114
|
+
*/
|
|
4115
|
+
constructor() {}
|
|
4116
|
+
/**
|
|
4117
|
+
* Decode a compute budget instruction and retrieve the instruction type.
|
|
4118
|
+
*/
|
|
4119
|
+
|
|
4120
|
+
|
|
4121
|
+
static decodeInstructionType(instruction) {
|
|
4122
|
+
this.checkProgramId(instruction.programId);
|
|
4123
|
+
const instructionTypeLayout = BufferLayout__namespace.u8('instruction');
|
|
4124
|
+
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
4125
|
+
let type;
|
|
4126
|
+
|
|
4127
|
+
for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
|
|
4128
|
+
if (layout.index == typeIndex) {
|
|
4129
|
+
type = ixType;
|
|
4130
|
+
break;
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
if (!type) {
|
|
4135
|
+
throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
return type;
|
|
4139
|
+
}
|
|
4140
|
+
/**
|
|
4141
|
+
* Decode request units compute budget instruction and retrieve the instruction params.
|
|
4142
|
+
*/
|
|
4143
|
+
|
|
4144
|
+
|
|
4145
|
+
static decodeRequestUnits(instruction) {
|
|
4146
|
+
this.checkProgramId(instruction.programId);
|
|
4147
|
+
const {
|
|
4148
|
+
units,
|
|
4149
|
+
additionalFee
|
|
4150
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);
|
|
4151
|
+
return {
|
|
4152
|
+
units,
|
|
4153
|
+
additionalFee
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4156
|
+
/**
|
|
4157
|
+
* Decode request heap frame compute budget instruction and retrieve the instruction params.
|
|
4158
|
+
*/
|
|
4159
|
+
|
|
4160
|
+
|
|
4161
|
+
static decodeRequestHeapFrame(instruction) {
|
|
4162
|
+
this.checkProgramId(instruction.programId);
|
|
4163
|
+
const {
|
|
4164
|
+
bytes
|
|
4165
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);
|
|
4166
|
+
return {
|
|
4167
|
+
bytes
|
|
4168
|
+
};
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* @internal
|
|
4172
|
+
*/
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
static checkProgramId(programId) {
|
|
4176
|
+
if (!programId.equals(ComputeBudgetProgram.programId)) {
|
|
4177
|
+
throw new Error('invalid instruction; programId is not ComputeBudgetProgram');
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
}
|
|
4182
|
+
/**
|
|
4183
|
+
* An enumeration of valid ComputeBudgetInstructionType's
|
|
4184
|
+
*/
|
|
4185
|
+
|
|
4186
|
+
/**
|
|
4187
|
+
* An enumeration of valid ComputeBudget InstructionType's
|
|
4188
|
+
* @internal
|
|
4189
|
+
*/
|
|
4190
|
+
const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
4191
|
+
RequestUnits: {
|
|
4192
|
+
index: 0,
|
|
4193
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), BufferLayout__namespace.u32('units'), BufferLayout__namespace.u32('additionalFee')])
|
|
4194
|
+
},
|
|
4195
|
+
RequestHeapFrame: {
|
|
4196
|
+
index: 1,
|
|
4197
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u8('instruction'), BufferLayout__namespace.u32('bytes')])
|
|
4198
|
+
}
|
|
4199
|
+
});
|
|
4200
|
+
/**
|
|
4201
|
+
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
4202
|
+
*/
|
|
4203
|
+
|
|
4204
|
+
class ComputeBudgetProgram {
|
|
4205
|
+
/**
|
|
4206
|
+
* @internal
|
|
4207
|
+
*/
|
|
4208
|
+
constructor() {}
|
|
4209
|
+
/**
|
|
4210
|
+
* Public key that identifies the Compute Budget program
|
|
4211
|
+
*/
|
|
4212
|
+
|
|
4213
|
+
|
|
4214
|
+
static requestUnits(params) {
|
|
4215
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
|
|
4216
|
+
const data = encodeData(type, params);
|
|
4217
|
+
return new TransactionInstruction({
|
|
4218
|
+
keys: [],
|
|
4219
|
+
programId: this.programId,
|
|
4220
|
+
data
|
|
4221
|
+
});
|
|
4222
|
+
}
|
|
4223
|
+
|
|
4224
|
+
static requestHeapFrame(params) {
|
|
4225
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;
|
|
4226
|
+
const data = encodeData(type, params);
|
|
4227
|
+
return new TransactionInstruction({
|
|
4228
|
+
keys: [],
|
|
4229
|
+
programId: this.programId,
|
|
4230
|
+
data
|
|
4231
|
+
});
|
|
4232
|
+
}
|
|
4233
|
+
|
|
4234
|
+
}
|
|
4235
|
+
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4236
|
+
|
|
4107
4237
|
var browserPonyfill = {exports: {}};
|
|
4108
4238
|
|
|
4109
4239
|
(function (module, exports) {
|
|
@@ -9907,6 +10037,9 @@ exports.BLOCKHASH_CACHE_TIMEOUT_MS = BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
|
9907
10037
|
exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
|
|
9908
10038
|
exports.BPF_LOADER_PROGRAM_ID = BPF_LOADER_PROGRAM_ID;
|
|
9909
10039
|
exports.BpfLoader = BpfLoader;
|
|
10040
|
+
exports.COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS;
|
|
10041
|
+
exports.ComputeBudgetInstruction = ComputeBudgetInstruction;
|
|
10042
|
+
exports.ComputeBudgetProgram = ComputeBudgetProgram;
|
|
9910
10043
|
exports.Connection = Connection;
|
|
9911
10044
|
exports.Ed25519Program = Ed25519Program;
|
|
9912
10045
|
exports.Enum = Enum;
|