@solana-program/compute-budget 0.19.0 → 0.20.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.
@@ -77,10 +77,11 @@ export function getSetLoadedAccountsDataSizeLimitInstruction<
77
77
  TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,
78
78
  >(
79
79
  input: SetLoadedAccountsDataSizeLimitInput,
80
- config?: { programAddress?: TProgramAddress },
80
+ config?: { programAddress?: TProgramAddress | { readonly address: TProgramAddress } },
81
81
  ): SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress> {
82
82
  // Program address.
83
- const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;
83
+ const programAddressInput = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;
84
+ const programAddress = typeof programAddressInput === 'string' ? programAddressInput : programAddressInput.address;
84
85
 
85
86
  // Original args.
86
87
  const args = { ...input };
@@ -17,6 +17,7 @@ import {
17
17
  type ClientWithTransactionPlanning,
18
18
  type ClientWithTransactionSending,
19
19
  type ExtendedClient,
20
+ type HasAddress,
20
21
  type Instruction,
21
22
  type InstructionWithData,
22
23
  type ReadonlyUint8Array,
@@ -146,39 +147,70 @@ export type ComputeBudgetPlugin = {
146
147
  export type ComputeBudgetPluginInstructions = {
147
148
  requestUnits: (
148
149
  input: RequestUnitsInput,
150
+ config?: { programAddress?: Address | HasAddress },
149
151
  ) => ReturnType<typeof getRequestUnitsInstruction> & SelfPlanAndSendFunctions;
150
152
  requestHeapFrame: (
151
153
  input: RequestHeapFrameInput,
154
+ config?: { programAddress?: Address | HasAddress },
152
155
  ) => ReturnType<typeof getRequestHeapFrameInstruction> & SelfPlanAndSendFunctions;
153
156
  setComputeUnitLimit: (
154
157
  input: SetComputeUnitLimitInput,
158
+ config?: { programAddress?: Address | HasAddress },
155
159
  ) => ReturnType<typeof getSetComputeUnitLimitInstruction> & SelfPlanAndSendFunctions;
156
160
  setComputeUnitPrice: (
157
161
  input: SetComputeUnitPriceInput,
162
+ config?: { programAddress?: Address | HasAddress },
158
163
  ) => ReturnType<typeof getSetComputeUnitPriceInstruction> & SelfPlanAndSendFunctions;
159
164
  setLoadedAccountsDataSizeLimit: (
160
165
  input: SetLoadedAccountsDataSizeLimitInput,
166
+ config?: { programAddress?: Address | HasAddress },
161
167
  ) => ReturnType<typeof getSetLoadedAccountsDataSizeLimitInstruction> & SelfPlanAndSendFunctions;
162
168
  };
163
169
 
164
170
  export type ComputeBudgetPluginRequirements = ClientWithTransactionPlanning & ClientWithTransactionSending;
165
171
 
166
- export function computeBudgetProgram() {
172
+ export function computeBudgetProgram(config: { programAddress?: Address | HasAddress } = {}) {
167
173
  return <T extends ComputeBudgetPluginRequirements>(
168
174
  client: T,
169
175
  ): ExtendedClient<T, { computeBudget: ComputeBudgetPlugin }> => {
170
176
  return extendClient(client, {
171
177
  computeBudget: <ComputeBudgetPlugin>{
172
178
  instructions: {
173
- requestUnits: input => addSelfPlanAndSendFunctions(client, getRequestUnitsInstruction(input)),
174
- requestHeapFrame: input =>
175
- addSelfPlanAndSendFunctions(client, getRequestHeapFrameInstruction(input)),
176
- setComputeUnitLimit: input =>
177
- addSelfPlanAndSendFunctions(client, getSetComputeUnitLimitInstruction(input)),
178
- setComputeUnitPrice: input =>
179
- addSelfPlanAndSendFunctions(client, getSetComputeUnitPriceInstruction(input)),
180
- setLoadedAccountsDataSizeLimit: input =>
181
- addSelfPlanAndSendFunctions(client, getSetLoadedAccountsDataSizeLimitInstruction(input)),
179
+ requestUnits: (input, instructionConfig) =>
180
+ addSelfPlanAndSendFunctions(
181
+ client,
182
+ getRequestUnitsInstruction(input, {
183
+ programAddress: instructionConfig?.programAddress ?? config.programAddress,
184
+ }),
185
+ ),
186
+ requestHeapFrame: (input, instructionConfig) =>
187
+ addSelfPlanAndSendFunctions(
188
+ client,
189
+ getRequestHeapFrameInstruction(input, {
190
+ programAddress: instructionConfig?.programAddress ?? config.programAddress,
191
+ }),
192
+ ),
193
+ setComputeUnitLimit: (input, instructionConfig) =>
194
+ addSelfPlanAndSendFunctions(
195
+ client,
196
+ getSetComputeUnitLimitInstruction(input, {
197
+ programAddress: instructionConfig?.programAddress ?? config.programAddress,
198
+ }),
199
+ ),
200
+ setComputeUnitPrice: (input, instructionConfig) =>
201
+ addSelfPlanAndSendFunctions(
202
+ client,
203
+ getSetComputeUnitPriceInstruction(input, {
204
+ programAddress: instructionConfig?.programAddress ?? config.programAddress,
205
+ }),
206
+ ),
207
+ setLoadedAccountsDataSizeLimit: (input, instructionConfig) =>
208
+ addSelfPlanAndSendFunctions(
209
+ client,
210
+ getSetLoadedAccountsDataSizeLimitInstruction(input, {
211
+ programAddress: instructionConfig?.programAddress ?? config.programAddress,
212
+ }),
213
+ ),
182
214
  },
183
215
  identifyInstruction: identifyComputeBudgetInstruction,
184
216
  parseInstruction: parseComputeBudgetInstruction,