UNPKG

@wuwei-labs/srsly

Version:

[![npm version](https://img.shields.io/npm/v/ts-sdk-example.svg)](https://www.npmjs.com/package/ts-sdk-example)

56 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getResetRentalInstructionAsync = void 0; exports.resetRental = resetRental; const codama_1 = require("../codama"); Object.defineProperty(exports, "getResetRentalInstructionAsync", { enumerable: true, get: function () { return codama_1.getResetRentalInstructionAsync; } }); const utils_1 = require("../utils"); /** * Asynchronously creates an instruction to reset a rental with minimal required parameters. * This is used to reset a fleet's rental state after a rental has ended. * Can derive starbase, starbasePlayer, and rentalAuthority automatically. * * @example * ```typescript * // Create the instruction with minimum required parameters and faction * const ix = await resetRental({ * fleet: fleetAddress, * contract: contractAddress, * rentalState: rentalStateAddress, * faction: 'mud', * ownerProfile: ownerProfileAddress * }); * * // Or with explicit starbase and starbasePlayer * const ix = await resetRental({ * fleet: fleetAddress, * contract: contractAddress, * rentalState: rentalStateAddress, * starbase: starbaseAddress, * starbasePlayer: starbasePlayerAddress * }); * * // Add to transaction and sign * const tx = new Transaction().add(ix); * await sendAndConfirmTransaction(connection, tx, [owner]); * ``` * * @param params The simplified parameters for resetting a rental * @returns A promise that resolves to the instruction to reset a rental */ async function resetRental(params) { const { fleet, contract, rentalState, gameId = utils_1.DEFAULT_GAME_ID, faction, ownerProfile, } = params; // Derive the three accounts we need const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(ownerProfile, faction, gameId); // Let codama derive the rest (rentalAuthority) const input = { fleet, contract, rentalState, gameId, starbase, starbasePlayer, }; return (0, codama_1.getResetRentalInstructionAsync)(input, { programAddress: codama_1.SRSLY_PROGRAM_ADDRESS }); } //# sourceMappingURL=reset.js.map