import { IContract } from "../../chain/contract"; import { Scalar } from "../../crypto/scalar"; import { AccountState } from "../../shielder/state"; import { Address } from "viem"; import { IRelayer } from "../../chain/relayer"; import { WithdrawReturn } from "../../crypto/circuits/withdraw"; export interface WithdrawCalldata { expectedContractVersion: `0x${string}`; calldata: WithdrawReturn; provingTimeMillis: number; amount: bigint; address: Address; merkleRoot: Scalar; } export declare class WithdrawAction { #private; contract: IContract; relayer: IRelayer; constructor(contract: IContract, relayer: IRelayer); /** * Return the updated state after withdrawing `amount` from `stateOld`. * Does not perform the actual withdrawal on blockchain. * @param stateOld * @param amount amount to withdraw * @returns updated state */ static rawWithdraw(stateOld: AccountState, amount: bigint): Promise; /** * Generate calldata for withdrawing `amount` from the account. * The amount must include the relayer fee, e.g. `amount = value + totalFee`, * where `value` is the targeted amount to withdraw. * @param state current account state * @param amount amount to withdraw, excluding the relayer fee * @param totalFee total relayer fee, usually a sum of base fee and relay fee (can be less, in which case relayer looses money) * @param address recipient address * @returns calldata for withdrawal action */ generateCalldata(state: AccountState, amount: bigint, totalFee: bigint, address: Address, expectedContractVersion: `0x${string}`): Promise; /** * Withdraw `amount` from the account. * Calls the relayer to perform the withdrawal on the blockchain. * @param calldata calldata for withdrawal action * @returns transaction hash of the withdraw transaction * @throws VersionRejectedByRelayer */ sendCalldata(calldata: WithdrawCalldata): Promise<`0x${string}`>; }