UNPKG

@dojima-wallet/connection

Version:

Initialise and connection for layer 1&2 blockchain

98 lines (97 loc) 2.4 kB
import { Address, Asset, BaseAmount } from "@dojima-wallet/utils"; export declare enum Network { Mainnet = "mainnet", Stagenet = "stagenet", Testnet = "testnet" } export type Balance = { asset: Asset; amount: BaseAmount; }; export declare enum TxType { Transfer = "transfer", Unknown = "unknown" } export type TxHash = string; export type TxTo = { to: Address; amount: BaseAmount; asset?: Asset; }; export type TxFrom = { from: Address | TxHash; amount: BaseAmount; asset?: Asset; }; export type Tx = { asset: Asset; from: TxFrom[]; to: TxTo[]; date: Date; type: TxType; hash: string; }; export type TxsPage = { total: number; txs: Tx[]; }; export type TxHistoryParams = { address: Address; offset?: number; limit?: number; startTime?: Date; asset?: string; }; export type TxParams = { walletIndex?: number; asset?: Asset; amount: BaseAmount; recipient: Address; memo?: string; }; export declare enum FeeOption { Average = "average", Fast = "fast", Fastest = "fastest" } export type FeeRate = number; export type FeeRates = Record<FeeOption, FeeRate>; export declare enum FeeType { FlatFee = "base", PerByte = "byte" } export type Fee = BaseAmount; export type Fees = Record<FeeOption, Fee> & { type: FeeType; }; export type FeesWithRates = { rates: FeeRates; fees: Fees; }; export type FeeBounds = { lower: number; upper: number; }; export type RootDerivationPaths = Record<Network, string>; export type ChainClientParams = { network: Network; phrase: string; feeBounds?: FeeBounds; rootDerivationPaths?: RootDerivationPaths; }; export interface ChainClient { setNetwork(net: Network): void; getNetwork(): Network; getExplorerUrl(): string; getExplorerAddressUrl(address: Address): string; getExplorerTxUrl(txID: string): string; validateAddress(address: string): boolean; getAddress(walletIndex?: number): Address; setPhrase(phrase: string, walletIndex: number): Address; getBalance(address: Address, assets?: Asset[]): Promise<Balance[]>; getTransactions(params?: TxHistoryParams): Promise<TxsPage>; getTransactionData(txId: string, assetAddress?: Address): Promise<Tx>; getFees(): Promise<Fees>; transfer(params: TxParams): Promise<TxHash>; purgeClient(): void; }