INNER CODE UNIT · TypeScript
immutable
blueshift-gg/doppler · packages/kit/src/index.ts:72
function immutable<T extends Instruction>(setAuthority: T): T {
return { ...setAuthority, accounts: setAuthority.accounts?.slice(0, 2) };
}
/** The compute budget `send` sets, then the instructions. */
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' }),