import { Cell, Hash, Script } from '@ckb-lumos/base'; import { BtcApiTransaction } from './btc'; export interface RgbppApis { getRgbppPaymasterInfo(): Promise; getRgbppTransactionHash(btcTxId: string): Promise; getRgbppTransactionState(btcTxId: string): Promise; getRgbppAssetsByBtcTxId(btcTxId: string): Promise; getRgbppAssetsByBtcUtxo(btcTxId: string, vout: number): Promise; getRgbppAssetsByBtcAddress(btcAddress: string, params?: RgbppApiAssetsByAddressParams): Promise; getRgbppBalanceByBtcAddress(btcAddress: string, params?: RgbppApiBalanceByAddressParams): Promise; getRgbppActivityByBtcAddress(btcAddress: string, params?: RgbppApiActivityByAddressParams): Promise; getRgbppSpvProof(btcTxId: string, confirmations: number): Promise; sendRgbppCkbTransaction(payload: RgbppApiSendCkbTransactionPayload): Promise; retryRgbppCkbTransaction(payload: RgbppApiRetryCkbTransactionPayload): Promise; } export type RgbppTransactionState = 'completed' | 'failed' | 'delayed' | 'active' | 'waiting'; export interface RgbppApiPaymasterInfo { btc_address: string; fee: number; } export interface RgbppApiCkbTransactionHash { txhash: string; } export interface RgbppApiTransactionStateParams { with_data?: boolean; } export interface RgbppApiTransactionState { state: RgbppTransactionState; attempts: number; failedReason?: string; data?: { txid: string; ckbVirtualResult: { ckbRawTx: CKBComponents.RawTransaction; needPaymasterCell: boolean; sumInputsCapacity: string; commitment: string; }; }; } export interface RgbppCell extends Cell { typeHash?: Hash; } export interface RgbppApiAssetsByAddressParams { type_script?: string; no_cache?: boolean; } export interface RgbppApiBalanceByAddressParams { type_script?: string; no_cache?: boolean; } export interface RgbppApiBalance { address: string; xudt: RgbppApiXudtBalance[]; } export interface RgbppApiXudtBalance { name: string; decimal: number; symbol: string; total_amount: string; available_amount: string; pending_amount: string; type_hash: string; type_script: Script; } export interface RgbppApiActivityByAddressParams { rgbpp_only?: boolean; type_script?: string; after_btc_txid?: string; } export interface RgbppApiActivity { address: string; cursor: string; txs: { btcTx: BtcApiTransaction; isRgbpp: boolean; isomorphicTx?: { ckbVirtualTx?: CKBComponents.RawTransaction; ckbTx?: CKBComponents.Transaction; inputs?: CKBComponents.CellOutput[]; outputs?: CKBComponents.CellOutput[]; status: { confirmed: boolean; }; }; }[]; } export interface RgbppApiSpvProof { proof: string; spv_client: { tx_hash: string; index: string; }; } export interface RgbppApiSendCkbTransactionPayload { btc_txid: string; // Support ckbVirtualTxResult and it's JSON string as request parameter ckb_virtual_result: RgbppApiSendCkbVirtualResult | string; } export interface RgbppApiSendCkbVirtualResult { ckbRawTx: CKBComponents.RawTransaction; needPaymasterCell: boolean; sumInputsCapacity: string; commitment: string; } export interface RgbppApiRetryCkbTransactionPayload { btc_txid: string; } export interface RgbppApiTransactionRetry { success: boolean; state: RgbppTransactionState; } export interface RgbppApiXudtAssetInfo { type: string; // 'xudt' type_hash: string; type_script: Script; symbol: string; name: string; decimal: number; total_supply?: string; issuer?: string; circulating_supply?: string; token_info_cell_type_hash?: string; } export interface RgbppApiSporeAssetInfo { type: string; // 'spore' content_type: string; cluster: { id: string; name: string; description: string; }; } export type RgbppApiAssetInfo = RgbppApiXudtAssetInfo | RgbppApiSporeAssetInfo;