@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
98 lines • 3.49 kB
TypeScript
/**
* @purpose Simplified acceptRental instruction wrapper
*
* Thin convenience wrapper around Codama-generated acceptRental instruction.
* Accepts a rental contract and begins the rental period.
*/
import { type Address } from '@solana/kit';
import { type SdkConfig } from '../utils/config';
import { type UniversalSigner } from '../utils/signer';
import { type AmountParam } from '../params/amount';
import { type DurationParam } from '../params/duration';
import { prepareInstructions } from '../utils/instructions';
import { type SerializedDiscountAuth } from '../utils/discountAuth';
/**
* Parameters for accepting a rental contract
*/
export interface AcceptRentalParams {
/**
* Borrower who will rent the fleet
* Accepts string address, web3.js Keypair, or @solana/kit signer
*/
borrower: UniversalSigner;
/**
* Borrower's profile address in Star Atlas SAGE
* This is the profile that will control the fleet during rental
*/
borrowerProfile: Address | string;
/**
* Rental contract address to accept
*/
contract: Address | string;
/**
* Affiliate member state address (optional)
* If provided, the affiliate receives a portion of fees
*/
referrer?: Address | string;
/**
* Rental duration
* @example { hours: 12 } // 12 hours
* @example { days: 7 } // 7 days
* @example { weeks: 2 } // 2 weeks
* @example 604800 // 7 days in seconds
*/
duration: DurationParam;
/**
* Sets compute units to allocate for the transaction.
* @example 400000
*/
computeUnits: number;
/**
* Discount authorization from createDiscount() — pass directly from API response.
* No deserialization needed.
*/
discountAuth?: SerializedDiscountAuth;
/**
* Expected rental rate (optional client-side safety check).
*
* If provided, the SDK will compare this against the on-chain contract rate
* and throw before building the transaction if they don't match.
* Useful for detecting rate changes between UI display and transaction submission.
*
* Accepts a plain number / bigint (stardust), `{ atlas: number }`, or
* `{ stardust: number | bigint }`.
*
* @example { atlas: 1 } // 1 ATLAS per period
* @example { stardust: 500_000_000 } // 5 ATLAS in stardust (smallest unit)
*/
rate?: AmountParam;
/**
* BorrowerState of the expired rental's borrower (optional)
*
* Required when accepting a contract that has an expired active rental
* (inline replacement). If not provided, the SDK will auto-detect by
* fetching the active rental state.
*/
expiredBorrowerState?: Address | string;
}
/**
* Activate a rental: transfer fleet control to the borrower for the
* chosen duration and pay the first period's rate.
*
* @param params - Rental acceptance parameters
* @param config - Optional SDK configuration overrides
* @returns Array of instructions (Kit format or web3.js if PublicKey in config)
*
* @example
* ```typescript
* const ixs = await acceptRental({
* borrower: wallet,
* borrowerProfile: "BORROWER_PROFILE_ADDRESS",
* contract: "CONTRACT_ADDRESS",
* duration: { days: 7 },
* computeUnits: 400_000
* });
* ```
*/
export declare function acceptRental(params: AcceptRentalParams, config?: Partial<SdkConfig>): Promise<ReturnType<typeof prepareInstructions>>;
//# sourceMappingURL=acceptRental.d.ts.map