UNPKG

@wuwei-labs/srsly

Version:
77 lines 2.53 kB
/** * @purpose Simplified cancelRental instruction wrapper * * Thin convenience wrapper around Codama-generated cancelRental instruction. * Cancels an active rental with an optional delay. */ import { type Address } from '@solana/kit'; import { type SdkConfig } from '../utils/config'; import { type UniversalSigner } from '../utils/signer'; import { prepareInstructions } from '../utils/instructions'; import { type DurationParam } from '../params/duration'; /** * Parameters for canceling a rental */ export interface CancelRentalParams { /** * Borrower who is canceling the rental * Accepts string address, web3.js Keypair, or @solana/kit signer */ borrower: UniversalSigner; /** * Contract address to cancel */ contract: Address | string; /** * Cancellation delay * * - 0: Instant cancellation (requires contract.cancelDelayMin = 0) * - > 0: Deferred cancellation - rental continues for the specified delay * * Accepts seconds as a number, or an object with time units: * @example 0 // Instant cancel * @example { hours: 12 } // Cancel after 12 hours * @example { days: 1 } // Cancel after 1 day * @example { weeks: 1 } // Cancel after 1 week * @default contract.cancelDelayMin (fetched on-chain) */ cancelDelay?: DurationParam; /** * Sets compute units to allocate for the transaction. * @example 400000 */ computeUnits?: number; } /** * Cancel an active rental and refund the borrower for unused time. * Takes effect immediately or after a delay set by `cancelDelay`. * * @param params - Cancellation parameters (borrower, contract, cancelDelay) * @param config - Optional SDK configuration overrides * @returns Kit instruction (or web3.js if PublicKey in config) * * @example * ```typescript * // Default cancellation (uses contract's cancelDelayMin) * const ix = await cancelRental({ * borrower: borrowerWallet, * contract: contractAddress * }); * * // Instant cancellation * const ix2 = await cancelRental({ * borrower: borrowerWallet, * contract: contractAddress, * cancelDelay: 0 * }); * * // Cancel after 12 hours * const ix3 = await cancelRental({ * borrower: borrowerWallet, * contract: contractAddress, * cancelDelay: { hours: 12 } * }); * ``` */ export declare function cancelRental(params: CancelRentalParams, config?: Partial<SdkConfig>): Promise<ReturnType<typeof prepareInstructions>>; //# sourceMappingURL=cancelRental.d.ts.map