import { BigNumber, ethers } from 'ethers';
import { BalanceView, ChainSymbol, WithdrawReceipt as UnifiedWithdrawReceipt } from '../../types';

export const CONTRACT_NAMES = [
    // LiqETH contracts
    "LiqEthAuthority",
    "BeaconState",
    "WithdrawalQueue",
    "LiqEthToken",
    "Accounting",
    "DepositManager",
    "WithdrawalVault",
    "StakingModule",
    // "YieldOracle",

    //Outpost contracts
    "OutpostManagerAuthority",
    "iodata",
    "Base58",
    "sysio_merkle",
    "ReceiptNFT",
    "Pool",
    "OutpostManager",
    "sysio_write",
    "EthUsdPriceConsumer",
    "BAR",
    "OPPCommon",
    "OPP",
    "Pretoken",
    "OPPInbound",
    "Depositor",
    // "MockAggregator",
] as const;

export type ContractName = typeof CONTRACT_NAMES[number];
export type AddressBook  = Record<ContractName, string>;


interface Result {
    /** EVM transaction hash */
    txHash: string;
    /** Full receipt, if you want it */
    receipt: ethers.providers.TransactionReceipt;
}


export interface DepositEvent {
    user: string;
    netEth: BigNumber;
    fee: BigNumber;
    shares: BigNumber;
}

export interface DepositResult extends Result {
    /** Parsed Deposited event, if present */
    deposited?: DepositEvent;
}

export interface WithdrawRequestedEvent {
    user: string;
    ethAmount: BigNumber;
    nftId: BigNumber;
    readyAt: string;
}

export interface WithdrawResult extends Result {
    /** Parsed WithdrawRequested event, if present */
    withdrawRequested?: WithdrawRequestedEvent;
}


export interface StakedEvent {
    user: string;
    amountLiq: BigNumber;
    shares: BigNumber;
    tokenId: BigNumber;
}

export interface StakedResult extends Result {
    /** Parsed Staked event, if present */
    staked?: StakedEvent;
}


export interface WithdrawnStakeEvent {
    user: string;
    tokenId: BigNumber;
    tokenOut: BigNumber;
}
export interface WithdrawnStakeResult extends Result {
    /** Parsed WithdrawnStake event, if present */
    withdrawnstake?: WithdrawnStakeEvent;
}

export interface DepositAndStakeResult extends Result {
    /** Parsed Staked event, if present */
    staked?: StakedEvent;
}

export interface DepositAndPurchaseResult extends Result {
}

export interface UnstakeAndWithdrawResult extends Result {
}

export interface SharesBurnedEvent {
    from: string;
    shares: BigNumber;
    tokenValue: BigNumber;
}

/**
 * Legacy stake/pretoken receipt (kept for compatibility; not used in withdraw UI).
 */
export interface preLaunchReceipt {
    tokenId: bigint;
    receipt: {
        account: string;
        currency: number;
        kind: number;
        indexAtMint: BalanceView;
        principal: BalanceView;
        shares: BalanceView;
        timestamp: string;
    };
}

export interface ClaimedEvent {
    user: string;
    amount: BigNumber;
}

// Unified withdraw receipt type is defined centrally in src/types.ts
export type WithdrawReceipt = UnifiedWithdrawReceipt;



export interface ValidatorDepositedEvent {
    sender: string;
    amount: BigNumber;
    shares: BigNumber
}
