import { ChainId } from "@abstraxn/core-types";
import { BytesLike, Interface, InterfaceAbi, JsonRpcError, Provider, Signer, TransactionReceipt } from "ethers";
export interface RelayerConfig {
    relayerUrl: string;
    chainId?: ChainId;
    signer?: Signer;
    provider?: Provider;
    isSafeTx?: boolean;
    webSocket?: WebSocketConfig;
}
export type BuildRelayerTxParams<T extends any[] = any[]> = {
    contractAddress: string;
    abi: Interface | InterfaceAbi;
    method: string;
    args: T;
};
export type BuildRelayerTxResponse = {
    userAddress: string;
    functionSignature: BytesLike;
    signature: BytesLike;
    data: BytesLike;
    chainId: ChainId;
    contractAddress: string;
};
export type SendRelayerTxParams = {
    userAddress: string;
    functionSignature: BytesLike;
    signature: BytesLike;
    chainId: ChainId;
    contractAddress: string;
};
export type SafeTx = {
    to: string;
    value: bigint;
    data: string;
    operation: number;
    safeTxGas: bigint;
    baseGas: bigint;
    gasPrice: bigint;
    gasToken: string;
    refundReceiver: string;
    nonce: bigint;
};
export type SendSafeRelayerTxParams = {
    safeAddress: string;
    safeExecTxPayload: {
        safeTx: SafeTx;
        signatureBytes: BytesLike;
    };
    chainId: ChainId;
};
export type RelayerResponse = {
    message: string;
    transactionId: string;
};
export type SendRelayerResponse = {
    jsonrpc: string;
    id: number;
    message: string;
    result: string;
    error?: JsonRpcError;
};
export type RelayerTxStatus = {
    hash: string | null;
    data: string | null;
    status: string;
    receipt: TransactionReceipt | null;
    createdAt: string;
    reason?: string | null;
};
export type LegacyRelayerTxStatus = {
    state: string;
    transactionHash?: string;
    txReceipt?: TransactionReceipt;
};
export type TransactionInfo = {
    hash: string | null;
    status: string;
    blockNumber?: number;
    gasUsed?: string;
    effectiveGasPrice?: string;
    from: string | null;
    to: string | null;
    createdAt: string;
    reason?: string | null;
};
export type GetRelayerTxStatusResponse = {
    jsonrpc: string;
    id: number;
    result: RelayerTxStatus;
    error?: JsonRpcError;
};
export interface TransactionStatusUpdate {
    txId: string;
    status: 'initiated' | 'pending' | 'confirmed' | 'failed' | 'rejected';
    hash?: string;
    blockHash?: string;
    blockNumber?: number;
    receipt?: any;
    reason?: string;
    timestamp: string;
    gasUsed?: string;
    effectiveGasPrice?: string;
}
export interface TransactionCreatedEvent {
    txId: string;
    status: 'initiated';
    chainId: ChainId;
    to: string;
    timestamp: string;
    message: string;
}
export interface WebSocketConfig {
    enabled?: boolean;
    autoConnect?: boolean;
    reconnection?: boolean;
    timeout?: number;
}
export interface RelayerWebSocketEvents {
    onTransactionUpdate?: (update: TransactionStatusUpdate) => void;
    onTransactionCreated?: (event: TransactionCreatedEvent) => void;
    onConnect?: () => void;
    onDisconnect?: () => void;
    onError?: (error: Error) => void;
}
export interface SendRelayerTxWithWebSocketParams extends SendRelayerTxParams {
    enableRealTimeUpdates?: boolean;
    webSocketEvents?: RelayerWebSocketEvents;
}
export interface SendSafeRelayerTxWithWebSocketParams extends SendSafeRelayerTxParams {
    enableRealTimeUpdates?: boolean;
    webSocketEvents?: RelayerWebSocketEvents;
}
