@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
57 lines • 2.21 kB
JavaScript
;
/**
* @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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteBorrower = deleteBorrower;
const kit_1 = require("@solana/kit");
const instructions_1 = require("../generated/codama/instructions");
const config_1 = require("../utils/config");
const signer_1 = require("../utils/signer");
const instructions_2 = require("../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"
* });
* ```
*/
async function deleteBorrower(params, config) {
const finalConfig = (0, config_1.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 = (0, signer_1.toTransactionSigner)(params.admin);
const addresses = (0, config_1.getAddresses)(config);
const programAddress = (0, kit_1.address)(addresses.srsly);
const kitInstruction = await (0, instructions_1.getDeleteBorrowerInstructionAsync)({
admin: adminSigner,
borrower: (0, kit_1.address)(params.borrower),
borrowerState: (0, kit_1.address)(params.borrowerState),
}, { programAddress });
return (0, instructions_2.prepareInstructions)(kitInstruction, {
computeUnits: params.computeUnits,
PublicKey: finalConfig.PublicKey,
});
}
//# sourceMappingURL=deleteBorrower.js.map