@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.esm.js
CHANGED
|
@@ -4072,6 +4072,136 @@ class BpfLoader {
|
|
|
4072
4072
|
|
|
4073
4073
|
}
|
|
4074
4074
|
|
|
4075
|
+
/**
|
|
4076
|
+
* Compute Budget Instruction class
|
|
4077
|
+
*/
|
|
4078
|
+
|
|
4079
|
+
class ComputeBudgetInstruction {
|
|
4080
|
+
/**
|
|
4081
|
+
* @internal
|
|
4082
|
+
*/
|
|
4083
|
+
constructor() {}
|
|
4084
|
+
/**
|
|
4085
|
+
* Decode a compute budget instruction and retrieve the instruction type.
|
|
4086
|
+
*/
|
|
4087
|
+
|
|
4088
|
+
|
|
4089
|
+
static decodeInstructionType(instruction) {
|
|
4090
|
+
this.checkProgramId(instruction.programId);
|
|
4091
|
+
const instructionTypeLayout = BufferLayout.u8('instruction');
|
|
4092
|
+
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
4093
|
+
let type;
|
|
4094
|
+
|
|
4095
|
+
for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
|
|
4096
|
+
if (layout.index == typeIndex) {
|
|
4097
|
+
type = ixType;
|
|
4098
|
+
break;
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
if (!type) {
|
|
4103
|
+
throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
return type;
|
|
4107
|
+
}
|
|
4108
|
+
/**
|
|
4109
|
+
* Decode request units compute budget instruction and retrieve the instruction params.
|
|
4110
|
+
*/
|
|
4111
|
+
|
|
4112
|
+
|
|
4113
|
+
static decodeRequestUnits(instruction) {
|
|
4114
|
+
this.checkProgramId(instruction.programId);
|
|
4115
|
+
const {
|
|
4116
|
+
units,
|
|
4117
|
+
additionalFee
|
|
4118
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);
|
|
4119
|
+
return {
|
|
4120
|
+
units,
|
|
4121
|
+
additionalFee
|
|
4122
|
+
};
|
|
4123
|
+
}
|
|
4124
|
+
/**
|
|
4125
|
+
* Decode request heap frame compute budget instruction and retrieve the instruction params.
|
|
4126
|
+
*/
|
|
4127
|
+
|
|
4128
|
+
|
|
4129
|
+
static decodeRequestHeapFrame(instruction) {
|
|
4130
|
+
this.checkProgramId(instruction.programId);
|
|
4131
|
+
const {
|
|
4132
|
+
bytes
|
|
4133
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);
|
|
4134
|
+
return {
|
|
4135
|
+
bytes
|
|
4136
|
+
};
|
|
4137
|
+
}
|
|
4138
|
+
/**
|
|
4139
|
+
* @internal
|
|
4140
|
+
*/
|
|
4141
|
+
|
|
4142
|
+
|
|
4143
|
+
static checkProgramId(programId) {
|
|
4144
|
+
if (!programId.equals(ComputeBudgetProgram.programId)) {
|
|
4145
|
+
throw new Error('invalid instruction; programId is not ComputeBudgetProgram');
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
}
|
|
4150
|
+
/**
|
|
4151
|
+
* An enumeration of valid ComputeBudgetInstructionType's
|
|
4152
|
+
*/
|
|
4153
|
+
|
|
4154
|
+
/**
|
|
4155
|
+
* An enumeration of valid ComputeBudget InstructionType's
|
|
4156
|
+
* @internal
|
|
4157
|
+
*/
|
|
4158
|
+
const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
4159
|
+
RequestUnits: {
|
|
4160
|
+
index: 0,
|
|
4161
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('units'), BufferLayout.u32('additionalFee')])
|
|
4162
|
+
},
|
|
4163
|
+
RequestHeapFrame: {
|
|
4164
|
+
index: 1,
|
|
4165
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('bytes')])
|
|
4166
|
+
}
|
|
4167
|
+
});
|
|
4168
|
+
/**
|
|
4169
|
+
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
4170
|
+
*/
|
|
4171
|
+
|
|
4172
|
+
class ComputeBudgetProgram {
|
|
4173
|
+
/**
|
|
4174
|
+
* @internal
|
|
4175
|
+
*/
|
|
4176
|
+
constructor() {}
|
|
4177
|
+
/**
|
|
4178
|
+
* Public key that identifies the Compute Budget program
|
|
4179
|
+
*/
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
static requestUnits(params) {
|
|
4183
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
|
|
4184
|
+
const data = encodeData(type, params);
|
|
4185
|
+
return new TransactionInstruction({
|
|
4186
|
+
keys: [],
|
|
4187
|
+
programId: this.programId,
|
|
4188
|
+
data
|
|
4189
|
+
});
|
|
4190
|
+
}
|
|
4191
|
+
|
|
4192
|
+
static requestHeapFrame(params) {
|
|
4193
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;
|
|
4194
|
+
const data = encodeData(type, params);
|
|
4195
|
+
return new TransactionInstruction({
|
|
4196
|
+
keys: [],
|
|
4197
|
+
programId: this.programId,
|
|
4198
|
+
data
|
|
4199
|
+
});
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
|
+
}
|
|
4203
|
+
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4204
|
+
|
|
4075
4205
|
var browserPonyfill = {exports: {}};
|
|
4076
4206
|
|
|
4077
4207
|
(function (module, exports) {
|
|
@@ -9869,5 +9999,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
9869
9999
|
|
|
9870
10000
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
9871
10001
|
|
|
9872
|
-
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 };
|
|
10002
|
+
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 };
|
|
9873
10003
|
//# sourceMappingURL=index.browser.esm.js.map
|