import { type PublicKey, type Transaction, type VersionedTransaction } from '@solana/web3.js';

export interface AnchorWallet {
    publicKey: PublicKey;
    signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
    signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
}

export type ETFTokenConstituent = {
    token: string;
    weight: number;
};


export type ETFCreateParams = {
    name: string;
    symbol: string;
    description: string;
    url: string;
    assets: ETFTokenConstituent[];
};

export type ETFBurnParams = {
    etfAddress: string;
    lamports: number | bigint;
};

/** 
 * purchase share parameters
 * lamports use Solana standard precision (9 digits)
 * for example: purchase 1 full share = 1000000000 (1e9)
 * purchase 0.5 share = 500000000 (5e8)
 */
export type MintETFTokenParams = {
    etfAddress: string;
    lamports: number;
};

export interface ETFCreateResult {
    success: boolean;
    txid?: string;
    error?: string;
    data?: {
        etfAddress?: PublicKey;
        etfCoreAddress?: PublicKey;
        symbol?: string;
        name?: string;
        description?: string;
        creator?: string;
        assets?: Array<{
            token: PublicKey;
            weight: number;
        }>;
    };
}

export type MintETFResult = {
    success: boolean;
    txid: string;
    error?: string;
    data?: {
        mintTokenataAccount?: PublicKey;  // mint 后的 ATA 账户
        balance: number;              // mint 后的余额
        etfAddress: string;        // ETF 地址
    };
};



