@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
60 lines • 1.9 kB
TypeScript
/**
* @purpose Simplified setDelegate instruction wrapper
*
* Thin convenience wrapper around Codama-generated setDelegate instruction.
* Allows contract owners to set or remove a delegate address that can update the contract rate.
*/
import { type Address } from '@solana/kit';
import { type SdkConfig } from '../utils/config';
import { type UniversalSigner } from '../utils/signer';
import { prepareInstructions } from '../utils/instructions';
/**
* Parameters for setting/removing a contract delegate
*/
export interface SetDelegateParams {
/**
* Contract owner (must be the original owner)
* Accepts string address, web3.js Keypair, or @solana/kit signer
*/
owner: UniversalSigner;
/**
* Contract address to update
*/
contract: Address | string;
/**
* Delegate address to set, or null/undefined to remove delegate
* The delegate can update the contract rate on behalf of the owner
*/
delegate?: Address | string | null;
/**
* Sets compute units to allocate for the transaction.
* @example 400000
*/
computeUnits?: number;
}
/**
* Set or clear a delegate that may update a contract's rate. Owner-only.
*
* @param params - Delegate parameters
* @param config - Optional SDK configuration overrides
* @returns Kit instruction (or web3.js if PublicKey in config)
*
* @example
* ```typescript
* // Set a delegate
* const ix = await setDelegate({
* owner: wallet,
* contract: contractAddress,
* delegate: delegateAddress
* });
*
* // Remove delegate
* const ix2 = await setDelegate({
* owner: wallet,
* contract: contractAddress,
* delegate: null // or omit delegate entirely
* });
* ```
*/
export declare function setDelegate(params: SetDelegateParams, config?: Partial<SdkConfig>): Promise<ReturnType<typeof prepareInstructions>>;
//# sourceMappingURL=setDelegate.d.ts.map