import { AppCurrency, SwapProvider } from "@keplr-wallet/types"; export { SwapProvider }; /** * Stored recent send history record. */ export interface RecentSendHistory { sender: string; recipient: string; amount: { amount: string; denom: string; }[]; memo: string; ibcChannels: { portId: string; channelId: string; counterpartyChainId: string; }[] | undefined; timestamp: number; } /** * Data required to record an IBC transfer history. * Used by tx-executor when creating history entries. */ export interface IBCTransferHistoryData { readonly historyType: string; readonly sourceChainId: string; readonly destinationChainId: string; readonly channels: { portId: string; channelId: string; counterpartyChainId: string; }[]; readonly sender: string; readonly recipient: string; readonly amount: { readonly amount: string; readonly denom: string; }[]; readonly memo: string; readonly notificationInfo: { readonly currencies: AppCurrency[]; }; } /** * Data required to record an IBC swap history. * Used by tx-executor when creating history entries. */ export interface IBCSwapHistoryData { readonly swapType: "amount-in" | "amount-out"; readonly chainId: string; readonly destinationChainId: string; readonly sender: string; readonly amount: { amount: string; denom: string; }[]; readonly memo: string; readonly ibcChannels: { portId: string; channelId: string; counterpartyChainId: string; }[]; readonly destinationAsset: { chainId: string; denom: string; }; readonly swapChannelIndex: number; readonly swapReceiver: string[]; readonly notificationInfo: { currencies: AppCurrency[]; }; } export type IBCSwapMinimalTrackingData = Pick; /** * Stored IBC transfer history record (subset of IBCHistory). */ export interface IBCTransferHistory { recipient: string; } /** * Stored IBC swap history record (subset of IBCHistory). */ export interface IBCSwapHistory { swapType: "amount-in" | "amount-out"; swapChannelIndex: number; swapReceiver: string[]; destinationAsset: { chainId: string; denom: string; }; resAmount: { amount: string; denom: string; }[][]; swapRefundInfo?: { chainId: string; amount: { amount: string; denom: string; }[]; }; } export type IbcHop = { portId: string; channelId: string; counterpartyChainId: string; sequence?: string; dstChannelId?: string; completed: boolean; error?: string; rewound?: boolean; rewoundButNextRewindingBlocked?: boolean; }; /** * Stored IBC history record (union of IBCTransferHistory and IBCSwapHistory). */ export type IBCHistory = { id: string; chainId: string; destinationChainId: string; timestamp: number; sender: string; amount: { amount: string; denom: string; }[]; memo: string; txHash: string; txFulfilled?: boolean; txError?: string; packetTimeout?: boolean; ibcHistory: IbcHop[]; notified?: boolean; notificationInfo?: { currencies: AppCurrency[]; }; } & (IBCTransferHistory | IBCSwapHistory); export declare enum SwapV2RouteStepStatus { IN_PROGRESS = "in_progress", SUCCESS = "success", FAILED = "failed", UNKNOWN = "unknown" } export declare enum SwapV2TxStatus { IN_PROGRESS = "in_progress", SUCCESS = "success", PARTIAL_SUCCESS = "partial_success", FAILED = "failed", UNKNOWN = "unknown" } export interface SwapV2TxStatusStep { chain_id: string; status: SwapV2RouteStepStatus; tx_hash?: string; explorer_url?: string; } export interface SwapV2AssetLocation { chain_id: string; denom: string; amount: string; } export interface SwapV2TxStatusRequest { provider: SwapProvider; from_chain: string; to_chain?: string; tx_hash: string; squid_quote_id?: string; } export interface SwapV2TxStatusResponse { provider: SwapProvider; status: SwapV2TxStatus; steps: SwapV2TxStatusStep[]; asset_location?: SwapV2AssetLocation | null; } /** * Base interface for SwapV2History data. * Contains common fields between SwapV2HistoryData and SwapV2History. */ export interface SwapV2HistoryBase { fromChainId: string; toChainId: string; provider: SwapProvider; sender: string; recipient: string; amount: { amount: string; denom: string; }[]; simpleRoute: { isOnlyEvm: boolean; chainId: string; receiver: string; }[]; destinationAsset: { chainId: string; denom: string; expectedAmount: string; }; routeDurationSeconds: number; notificationInfo: { currencies: AppCurrency[]; }; isOnlyUseBridge?: boolean; squidQuoteId?: string; } /** * Data required to record a SwapV2 history. * Used by tx-executor when creating history entries. */ export type SwapV2HistoryData = SwapV2HistoryBase; /** * Stored SwapV2 history record. */ export interface SwapV2History extends SwapV2HistoryBase { id: string; timestamp: number; txHash: string; status: SwapV2TxStatus; routeIndex: number; resAmount: { amount: string; denom: string; }[][]; assetLocationInfo?: { chainId: string; amount: { amount: string; denom: string; }[]; /** * "refund": 실패/오류로 인해 자산이 중간에서 릴리즈된 경우 * "intermediate": TX는 성공했지만 자산이 최종 목적지가 아닌 중간 단계에 도달한 경우 * (예: base USDC -> osmosis OSMO 스왑 시, noble USDC가 먼저 도착) * 이 경우 추가 TX를 실행하여 최종 목적지로 자산을 보내거나, * 현재 받은 자산을 그대로 둘 수 있음 */ type: "refund" | "intermediate"; }; backgroundExecutionId?: string; additionalTrackingData?: { type: "evm"; chainId: string; txHash: string; } | { type: "cosmos-ibc"; chainId: string; swapReceiver: string[]; swapChannelIndex: number; txHash: string; txFulfilled?: boolean; packetTimeout?: boolean; dynamicHopDetected?: boolean; ibcHistory: IbcHop[]; }; additionalTrackDone?: boolean; additionalTrackError?: string; trackDone?: boolean; trackError?: string; finalizationRetryCount?: number; unknownStatusFirstSeenAt?: number; notified?: boolean; hidden?: boolean; } export type SkipHistory = { id: string; chainId: string; destinationChainId: string; timestamp: number; sender: string; recipient: string; amount: { amount: string; denom: string; }[]; txHash: string; trackDone?: boolean; trackError?: string; trackStatus?: StatusState; notified?: boolean; notificationInfo?: { currencies: AppCurrency[]; }; simpleRoute: { isOnlyEvm: boolean; chainId: string; receiver: string; }[]; routeIndex: number; routeDurationSeconds: number; destinationAsset: { chainId: string; denom: string; expectedAmount?: string; }; resAmount: { amount: string; denom: string; }[][]; swapRefundInfo?: { chainId: string; amount: { amount: string; denom: string; }[]; }; transferAssetRelease?: TransferAssetRelease; isOnlyUseBridge?: boolean; }; /** * Union type of all history data types. */ export type HistoryData = IBCTransferHistoryData | IBCSwapHistoryData | SwapV2HistoryData; export type StatusState = "STATE_UNKNOWN" | "STATE_SUBMITTED" | "STATE_PENDING" | "STATE_RECEIVED" | "STATE_COMPLETED" | "STATE_ABANDONED" | "STATE_COMPLETED_SUCCESS" | "STATE_COMPLETED_ERROR" | "STATE_PENDING_ERROR"; export type NextBlockingTransfer = { transfer_sequence_index: number; }; export type StatusRequest = { tx_hash: string; chain_id: string; }; export type TransferState = "TRANSFER_UNKNOWN" | "TRANSFER_PENDING" | "TRANSFER_RECEIVED" | "TRANSFER_SUCCESS" | "TRANSFER_FAILURE"; export type TransferInfo = { from_chain_id: string; to_chain_id: string; state: TransferState; packet_txs: Packet; src_chain_id: string; dst_chain_id: string; }; export type TransferAssetRelease = { chain_id: string; denom: string; released: boolean; }; export type TxStatusResponse = { status: StatusState; transfer_sequence: TransferEvent[]; next_blocking_transfer: NextBlockingTransfer | null; transfer_asset_release: TransferAssetRelease | null; error: StatusError | null; state: StatusState; transfers: TransferStatus[]; }; export type TransferStatus = { state: StatusState; transfer_sequence: TransferEvent[]; next_blocking_transfer: NextBlockingTransfer | null; transfer_asset_release: TransferAssetRelease | null; error: StatusError | null; }; export type Packet = { send_tx: ChainTransaction | null; receive_tx: ChainTransaction | null; acknowledge_tx: ChainTransaction | null; timeout_tx: ChainTransaction | null; error: PacketError | null; }; export type StatusErrorType = "STATUS_ERROR_UNKNOWN" | "STATUS_ERROR_TRANSACTION_EXECUTION" | "STATUS_ERROR_INDEXING"; export type TransactionExecutionError = { code: number; message: string; }; export type StatusError = { code: number; message: string; type: StatusErrorType; details: { transactionExecutionError: TransactionExecutionError; }; }; export type PacketErrorType = "PACKET_ERROR_UNKNOWN" | "PACKET_ERROR_ACKNOWLEDGEMENT" | "PACKET_ERROR_TIMEOUT"; export type AcknowledgementError = { message: string; code: number; }; export type PacketError = { code: number; message: string; type: PacketErrorType; details: { acknowledgement_error: AcknowledgementError; }; }; export type ChainTransaction = { chain_id: string; tx_hash: string; explorer_link: string; }; export type TrackTxRequest = { tx_hash: string; chain_id: string; }; export type TrackTxResponse = { tx_hash: string; explorer_link: string; }; export type AxelarTransferType = "AXELAR_TRANSFER_CONTRACT_CALL_WITH_TOKEN" | "AXELAR_TRANSFER_SEND_TOKEN"; export type AxelarTransferState = "AXELAR_TRANSFER_UNKNOWN" | "AXELAR_TRANSFER_PENDING_CONFIRMATION" | "AXELAR_TRANSFER_PENDING_RECEIPT" | "AXELAR_TRANSFER_SUCCESS" | "AXELAR_TRANSFER_FAILURE"; export type AxelarTransferInfo = { from_chain_id: string; to_chain_id: string; type: AxelarTransferType; state: AxelarTransferState; txs: AxelarTransferTransactions; axelar_scan_link: string; src_chain_id: string; dst_chain_id: string; }; export type AxelarTransferTransactions = { contract_call_with_token_txs: ContractCallWithTokenTransactions; } | { send_token_txs: SendTokenTransactions; }; export type ContractCallWithTokenTransactions = { send_tx: ChainTransaction | null; gas_paid_tx: ChainTransaction | null; confirm_tx: ChainTransaction | null; approve_tx: ChainTransaction | null; execute_tx: ChainTransaction | null; error: ContractCallWithTokenError | null; }; export type ContractCallWithTokenError = { message: string; type: ContractCallWithTokenErrorType; }; export type ContractCallWithTokenErrorType = "CONTRACT_CALL_WITH_TOKEN_EXECUTION_ERROR"; export type SendTokenTransactions = { send_tx: ChainTransaction | null; confirm_tx: ChainTransaction | null; execute_tx: ChainTransaction | null; error: SendTokenError | null; }; export type SendTokenErrorType = "SEND_TOKEN_EXECUTION_ERROR"; export type SendTokenError = { message: string; type: SendTokenErrorType; }; export type CCTPTransferState = "CCTP_TRANSFER_UNKNOWN" | "CCTP_TRANSFER_SENT" | "CCTP_TRANSFER_PENDING_CONFIRMATION" | "CCTP_TRANSFER_CONFIRMED" | "CCTP_TRANSFER_RECEIVED"; export type CCTPTransferTransactions = { send_tx: ChainTransaction | null; receive_tx: ChainTransaction | null; }; export type CCTPTransferInfo = { from_chain_id: string; to_chain_id: string; state: CCTPTransferState; txs: CCTPTransferTransactions; src_chain_id: string; dst_chain_id: string; }; export type HyperlaneTransferState = "HYPERLANE_TRANSFER_UNKNOWN" | "HYPERLANE_TRANSFER_SENT" | "HYPERLANE_TRANSFER_FAILED" | "HYPERLANE_TRANSFER_RECEIVED"; export type HyperlaneTransferTransactions = { send_tx: ChainTransaction | null; receive_tx: ChainTransaction | null; }; export type HyperlaneTransferInfo = { from_chain_id: string; to_chain_id: string; state: HyperlaneTransferState; txs: HyperlaneTransferTransactions; }; export type GoFastTransferTransactions = { order_submitted_tx: ChainTransaction | null; order_filled_tx: ChainTransaction | null; order_refunded_tx: ChainTransaction | null; order_timeout_tx: ChainTransaction | null; }; export type GoFastTransferState = "GO_FAST_TRANSFER_UNKNOWN" | "GO_FAST_TRANSFER_SENT" | "GO_FAST_POST_ACTION_FAILED" | "GO_FAST_TRANSFER_TIMEOUT" | "GO_FAST_TRANSFER_FILLED" | "GO_FAST_TRANSFER_REFUNDED"; export type GoFastTransferInfo = { from_chain_id: string; to_chain_id: string; state: GoFastTransferState; txs: GoFastTransferTransactions; }; export type StargateTransferState = "STARGATE_TRANSFER_UNKNOWN" | "STARGATE_TRANSFER_SENT" | "STARGATE_TRANSFER_RECEIVED" | "STARGATE_TRANSFER_FAILED"; export type StargateTransferTransactions = { send_tx: ChainTransaction | null; receive_tx: ChainTransaction | null; error_tx: ChainTransaction | null; }; export type StargateTransferInfo = { from_chain_id: string; to_chain_id: string; state: StargateTransferState; txs: StargateTransferTransactions; }; export type OPInitTransferState = "OPINIT_TRANSFER_UNKNOWN" | "OPINIT_TRANSFER_SENT" | "OPINIT_TRANSFER_RECEIVED"; export type OPInitTransferTransactions = { send_tx: ChainTransaction | null; receive_tx: ChainTransaction | null; }; export type OPInitTransferInfo = { from_chain_id: string; to_chain_id: string; state: OPInitTransferState; txs: OPInitTransferTransactions; }; export type EurekaTransferState = "TRANSFER_UNKNOWN" | "TRANSFER_PENDING" | "TRANSFER_RECEIVED" | "TRANSFER_SUCCESS" | "TRANSFER_FAILURE"; export type EurekaTransferTransactions = { send_tx: ChainTransaction | null; acknowledge_tx: ChainTransaction | null; receive_tx: ChainTransaction | null; timeout_tx: ChainTransaction | null; }; export type EurekaTransferInfo = { from_chain_id: string; to_chain_id: string; state: EurekaTransferState; packet_txs: EurekaTransferTransactions; }; export type TransferEvent = { ibc_transfer: TransferInfo; } | { axelar_transfer: AxelarTransferInfo; } | { cctp_transfer: CCTPTransferInfo; } | { hyperlane_transfer: HyperlaneTransferInfo; } | { op_init_transfer: OPInitTransferInfo; } | { go_fast_transfer: GoFastTransferInfo; } | { stargate_transfer: StargateTransferInfo; } | { eureka_transfer: EurekaTransferInfo; };