INNER CODE UNIT · TypeScript
expect
blueshift-gg/doppler · packages/kit/src/index.ts:65
function expect(signers: readonly TransactionSigner[], key: Address): TransactionSigner {
const signer = signers.find((s) => s.address === key);
if (!signer) throw new Error(`${key} must sign`);
return signer;
}
/** The loader takes any third account as the new authority; the generated client fills the omitted one with its own address. */
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,