@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
53 lines • 1.75 kB
TypeScript
/**
* @purpose Rental account utilities for SRSLY
*
* Fetches rental state data from the SRSLY program.
*/
import { type Address } from '@solana/kit';
import { type RentalState } from '../generated/codama/accounts';
/**
* Fetch rental state from the SRSLY program
*
* @param rentalAddress - Rental state account address
* @param rpcUrl - Optional RPC endpoint URL. If not provided, uses RPC from global config
* @returns Rental state with borrower, borrowerState, contract, etc.
* @throws Error if rental account not found or fetch fails
*
* @example
* ```typescript
* // Uses RPC URL from global config
* const rental = await fetchRental('RentalAddress...');
* console.log(rental.data.borrower, rental.data.borrowerState);
*
* // Uses specific RPC URL
* const rental2 = await fetchRental(
* 'RentalAddress...',
* 'https://api.devnet.solana.com'
* );
* console.log('Rate:', rental2.data.rate);
* ```
*/
export declare function fetchRental(rentalAddress: Address | string, rpcUrl?: string): Promise<{
data: RentalState;
address: Address;
}>;
/**
* Fetch all rental state accounts from the SRSLY program
*
* Uses getProgramAccounts with a discriminator filter to find all RentalState accounts.
*
* @param rpcUrl - Optional RPC endpoint URL. If not provided, uses RPC from global config
* @returns Array of rental states with their addresses
*
* @example
* ```typescript
* const rentals = await fetchAllRentals();
* console.log(`Found ${rentals.length} rentals`);
* rentals.forEach(r => console.log(r.address, r.data.borrower));
* ```
*/
export declare function fetchAllRentals(rpcUrl?: string): Promise<Array<{
data: RentalState;
address: Address;
}>>;
//# sourceMappingURL=rental.d.ts.map