UNPKG

@wuwei-labs/srsly

Version:
54 lines 2.03 kB
/** * @purpose Simplified deleteBorrower instruction wrapper * * Thin convenience wrapper around Codama-generated deleteBorrower instruction. * Admin-only instruction to delete borrower state for schema migrations. * Uses UncheckedAccount to bypass deserialization for old-format accounts. */ import { address } from '@solana/kit'; import { getDeleteBorrowerInstructionAsync } from '../generated/codama/instructions'; import { mergeConfig, getAddresses } from '../utils/config'; import { toTransactionSigner } from '../utils/signer'; import { prepareInstructions } from '../utils/instructions'; /** * Admin escape hatch to delete an unparseable BorrowerState (used during * schema migrations). Returns rent to the borrower wallet. * * @param params - Delete borrower parameters * @param config - Optional SDK configuration overrides * @returns Kit instruction (or web3.js if PublicKey in config) * * @example * ```typescript * const ix = await deleteBorrower({ * admin: adminWallet, * borrower: "BORROWER_WALLET_ADDRESS", * borrowerState: "BORROWER_STATE_PDA_ADDRESS" * }); * ``` */ export async function deleteBorrower(params, config) { const finalConfig = mergeConfig(config); if (!params.admin) { throw new Error('admin is required'); } if (!params.borrower) { throw new Error('borrower is required'); } if (!params.borrowerState) { throw new Error('borrowerState is required'); } const adminSigner = toTransactionSigner(params.admin); const addresses = getAddresses(config); const programAddress = address(addresses.srsly); const kitInstruction = await getDeleteBorrowerInstructionAsync({ admin: adminSigner, borrower: address(params.borrower), borrowerState: address(params.borrowerState), }, { programAddress }); return prepareInstructions(kitInstruction, { computeUnits: params.computeUnits, PublicKey: finalConfig.PublicKey, }); } //# sourceMappingURL=deleteBorrower.js.map