INNER CODE UNIT · TypeScript
budgeted
blueshift-gg/doppler · packages/kit/src/index.ts:77
function budgeted(unitPrice: number | bigint, budget: Budget, instructions: readonly Instruction[]): Instruction[] {
return [
getSetComputeUnitPriceInstruction({ microLamports: unitPrice }),
getSetLoadedAccountsDataSizeLimitInstruction({ accountDataSizeLimit: budget.requestedLoadedBytes }),
getSetComputeUnitLimitInstruction({ units: budget.requestedComputeUnits }),
...instructions,
];
}
async function send(rpc: DopplerRpc, payer: TransactionSigner, instructions: readonly Instruction[]): Promise<Signature> {
const { value: lifetime } = await rpc.getLatestBlockhash().send();
const transactionMessage = pipe(
createTransactionMessage({ version: 'legacy' }),
(m) => setTransactionMessageFeePayerSigner(payer, m),
(m) => setTransactionMessageLifetimeUsingBlockhash(lifetime, m),
(m) => appendTransactionMessageInstructions(instructions, m),
);
const transaction = await signTransactionMessageWithSigners(transactionMessage);