@wuwei-labs/srsly
Version:
[](https://www.npmjs.com/package/ts-sdk-example)
39 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCloseRentalInstructionAsync = void 0;
exports.closeRental = closeRental;
const codama_1 = require("../codama");
Object.defineProperty(exports, "getCloseRentalInstructionAsync", { enumerable: true, get: function () { return codama_1.getCloseRentalInstructionAsync; } });
/**
* Asynchronously creates an instruction to close a rental with minimal required parameters.
* This is called by an owner to close a rental that was previously accepted by a borrower.
* Derives rentalState, rentalThread, rentalTokenAccount and rentalAuthority automatically if not provided.
*
* @example
* ```typescript
* // Create the instruction with minimal parameters
* const ix = await closeRental({
* borrower: borrowerAddress,
* ownerTokenAccount: ownerTokenAccountAddress,
* contract: contractAddress
* });
*
* // Add to transaction and sign
* const tx = new Transaction().add(ix);
* await sendAndConfirmTransaction(connection, tx, [owner]);
* ```
*
* @param params The simplified parameters for closing a rental
* @returns A promise that resolves to the instruction to close a rental
*/
async function closeRental(params) {
const { borrower, ownerTokenAccount, contract, } = params;
// Let codama derive the optional accounts
const input = {
borrower,
ownerTokenAccount,
contract,
};
return (0, codama_1.getCloseRentalInstructionAsync)(input, { programAddress: codama_1.SRSLY_PROGRAM_ADDRESS });
}
//# sourceMappingURL=close.js.map