UNPKG

@dojima-wallet/connection

Version:

Initialise and connection for layer 1&2 blockchain

55 lines (54 loc) 2.96 kB
import { ChainClientParams, Network } from "../client"; import { SwapAssetList } from "@dojima-wallet/utils"; import Arweave from "arweave"; import { ApiConfig } from "arweave/node/lib/api"; import Transaction, { Tag } from "arweave/node/lib/transaction"; import ArweaveTxClient from "./tx-client"; import { ArTxDataResult, ArTxParams, ArTxs, ArTxsHistoryParams, GasfeeResult, TxStatusResponse } from "./types"; import { PoolData, SwapFeeResult } from "../swap_utils"; export interface ArweaveChainClient { getAddress(): Promise<string>; mintArTokens(pubAddress: string): Promise<void>; getBalance(address: string): Promise<number>; getFees(rawTx: Transaction): GasfeeResult; transfer({ recipient, amount }: ArTxParams): Promise<string>; getTransactionData(txHash: string): Promise<ArTxDataResult>; getTransactionsHistory(params: ArTxsHistoryParams): Promise<ArTxs>; getTxStatus(txHash: string): Promise<TxStatusResponse>; } export type ChainConfigParams = { config: ApiConfig; }; declare class ArweaveClient extends ArweaveTxClient implements ArweaveChainClient { protected network: Network; protected arweave: Arweave; private phrase; protected apiConfig: ApiConfig; constructor({ phrase, network, config, }: ChainClientParams & ChainConfigParams); getAddress(): Promise<string>; /** testnet tokens in winston */ mintArTokens(address: string): Promise<void>; getBalance(address: string): Promise<number>; /** Calculate gasFee required for transaction */ getFees(rawTx: Transaction): GasfeeResult; /** Create transaction based on user inputs */ createTransaction(recipient: string, amount: number, tag?: Tag): Promise<Transaction>; /** Sign and Send the transaction */ signAndSend(rawTx: Transaction): Promise<string>; transfer({ recipient, amount }: ArTxParams): Promise<string>; /** Get status data using transaction hash / id */ getTxStatus(txHash: string): Promise<TxStatusResponse>; dummyTx(recipient: string, amount: number): Promise<string>; getTransactionData(txHash: string): Promise<ArTxDataResult>; getTransactionsHistory(params: ArTxsHistoryParams): Promise<ArTxs>; getSwapOutput(inputAmount: number, pool: PoolData, toDoj: boolean): number; getDoubleSwapOutput(inputAmount: number, pool1: PoolData, pool2: PoolData): number; getSwapSlip(inputAmount: number, pool: PoolData, toDoj: boolean): number; getDoubleSwapSlip(inputAmount: number, pool1: PoolData, pool2: PoolData): number; getSwapFeesData(): Promise<SwapFeeResult>; getArweaveInboundAddress(hermesApiUrl: string): Promise<string>; getDefaultLiquidityPoolGasFee(hermesApiUrl: string): Promise<number>; addLiquidityPool(amount: number, inboundAddress: string, hermesAddress?: string): Promise<string>; swap(amount: number, token: SwapAssetList, inboundAddress: string, recipient: string): Promise<string>; } export { ArweaveClient };