UNPKG

@wuwei-labs/srsly

Version:
114 lines 4.18 kB
/** * @purpose Simplified updateContract instruction wrapper * * Thin convenience wrapper around Codama-generated updateContract instruction. * Allows updating any subset of contract fields. Can be called by owner or delegate. */ 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'; /** * Parameters for updating a rental contract * All update fields are optional - only pass what you want to change */ export interface UpdateContractParams { /** * Contract authority (owner or delegate) * Delegates can only update the rate field. * Accepts string address, web3.js Keypair, or @solana/kit signer */ authority: UniversalSigner; /** * Contract address to update */ contract: Address | string; /** * New rental rate per payment period (optional). * Accepts a plain number / bigint (stardust), `{ atlas: number }`, or * `{ stardust: number | bigint }`. * @example { atlas: 100 } // 100 ATLAS * @example { atlas: 1.5 } // 1.5 ATLAS * @example { stardust: 150_000_000 } // Explicit stardust (smallest unit) */ rate?: AmountParam; /** * New minimum rental duration (optional) * @example { hours: 1 } // 1 hour minimum * @example { days: 1 } // 1 day minimum * @example 3600 // 1 hour in seconds */ durationMin?: DurationParam; /** * New maximum rental duration (optional) * @example { days: 30 } // 30 day maximum * @example { months: 3 } // 3 month maximum * @example 2592000 // 30 days in seconds */ durationMax?: DurationParam; /** * Minimum cancellation delay (optional) * Set to 0 or { seconds: 0 } to allow instant cancellation. * Set to a duration like { hours: 1 } to require advance notice. * @example { hours: 1 } // Require 1 hour notice * @example { seconds: 0 } // Allow instant cancel * @example 3600 // 1 hour in seconds */ cancelDelayMin?: DurationParam; /** * Whether reservations are disabled for this contract * When enabled, other borrowers cannot reserve this contract. * Owners can use this to opt out of the reservation system. */ reservationsDisabled?: boolean; /** * Cancel or re-enable deferred contract closure (optional, owner only) * Set to false to cancel a pending close (reverts contract_close when rental was active). * Set to true to flag contract for closure after current rental ends. */ toClose?: boolean; /** * Number of contests that must accumulate before the contract rate * auto-increments by `capture_rate_bps`. Owner-tunable per contract. * * - `0` disables capture-rate entirely (rate stays fixed forever). * - `1..=10` enables it with the chosen sensitivity. */ contestedThreshold?: number; /** * Sets compute units to allocate for the transaction. * @example 400000 */ computeUnits?: number; } /** * Update an existing contract's settings. Owners can change any field; * delegates may only adjust the rate. * * @param params - Contract update parameters * @param config - Optional SDK configuration overrides * @returns Kit instruction (or web3.js if PublicKey in config) * * @example * ```typescript * // Update only the rate (works for both owner and delegate) * const ix = await updateContract({ * authority: wallet, * contract: contractAddress, * rate: 150 // Increase rate to 150 ATLAS * }); * * // Update multiple fields (owner only) * const ix2 = await updateContract({ * authority: wallet, * contract: contractAddress, * rate: 100, * durationMax: { days: 60 }, * reservationsDisabled: false * }); * ``` */ export declare function updateContract(params: UpdateContractParams, config?: Partial<SdkConfig>): Promise<ReturnType<typeof prepareInstructions>>; //# sourceMappingURL=updateContract.d.ts.map