UNPKG

@onekeyfe/blockchain-link

Version:

High-level javascript interface for blockchain communication

156 lines (155 loc) 3.69 kB
import { SubscriptionAccountInfo, BlockchainSettings } from './common'; import * as MESSAGES from '../constants/messages'; export interface Connect { type: typeof MESSAGES.CONNECT; } export interface Disconnect { type: typeof MESSAGES.DISCONNECT; } export interface GetInfo { type: typeof MESSAGES.GET_INFO; } export interface GetBlockHash { type: typeof MESSAGES.GET_BLOCK_HASH; payload: number; } export interface AccountInfoParams { descriptor: string; details?: 'basic' | 'tokens' | 'tokenBalances' | 'txids' | 'txs'; tokens?: 'nonzero' | 'used' | 'derived'; page?: number; pageSize?: number; from?: number; to?: number; contractFilter?: string; gap?: number; marker?: { ledger: number; seq: number; }; } export interface GetAccountInfo { type: typeof MESSAGES.GET_ACCOUNT_INFO; payload: AccountInfoParams; } export interface GetAccountUtxo { type: typeof MESSAGES.GET_ACCOUNT_UTXO; payload: string; } export interface GetTransaction { type: typeof MESSAGES.GET_TRANSACTION; payload: string; } export interface GetFiatRatesTickersList { type: typeof MESSAGES.GET_FIAT_RATES_TICKERS_LIST; payload: { timestamp?: number; }; } export interface AccountBalanceHistoryParams { descriptor: string; from: number; to: number; currencies?: string[]; groupBy?: number; } export interface GetAccountBalanceHistory { type: typeof MESSAGES.GET_ACCOUNT_BALANCE_HISTORY; payload: AccountBalanceHistoryParams; } export interface GetCurrentFiatRates { type: typeof MESSAGES.GET_CURRENT_FIAT_RATES; payload: { currencies?: string[]; }; } export interface GetFiatRatesForTimestamps { type: typeof MESSAGES.GET_FIAT_RATES_FOR_TIMESTAMPS; payload: { timestamps: number[]; currencies?: string[]; }; } export interface EstimateFeeParams { blocks?: number[]; specific?: { conservative?: boolean; txsize?: number; from?: string; to?: string; data?: string; value?: string; }; } export interface EstimateFee { type: typeof MESSAGES.ESTIMATE_FEE; payload: EstimateFeeParams; } export interface Subscribe { type: typeof MESSAGES.SUBSCRIBE; payload: { type: 'block'; } | { type: 'addresses'; addresses: string[]; } | { type: 'accounts'; accounts: SubscriptionAccountInfo[]; } | { type: 'fiatRates'; currency?: string; }; } export interface Unsubscribe { type: typeof MESSAGES.UNSUBSCRIBE; payload: { type: 'block'; } | { type: 'addresses'; addresses?: string[]; } | { type: 'accounts'; accounts?: SubscriptionAccountInfo[]; } | { type: 'fiatRates'; }; } export interface PushTransaction { type: typeof MESSAGES.PUSH_TRANSACTION; payload: string; } export declare type Message = { id: number; type: typeof MESSAGES.HANDSHAKE; settings: BlockchainSettings; } | ({ id: number; } & Connect) | ({ id: number; } & Disconnect) | ({ id: number; } & GetInfo) | ({ id: number; } & GetBlockHash) | ({ id: number; } & GetAccountInfo) | ({ id: number; } & GetAccountUtxo) | ({ id: number; } & GetTransaction) | ({ id: number; } & GetCurrentFiatRates) | ({ id: number; } & GetFiatRatesForTimestamps) | ({ id: number; } & GetAccountBalanceHistory) | ({ id: number; } & GetFiatRatesTickersList) | ({ id: number; } & EstimateFee) | ({ id: number; } & Subscribe) | ({ id: number; } & Unsubscribe) | ({ id: number; } & PushTransaction);