import {IReturnResult} from "../config"; export interface IChainsClass { new(params: IChainsParams): IChains } export interface IChains { // 获取path readonly getPath: (index?: number) => string // 验证 readonly verify: IChainsVerify // 从助记词生成钱包 readonly fromMnemonicToWallet: (mnemonic: string, params?: IFromMnemonicParams) => Promise> // 从助记词生成钱包 readonly fromPrivateKeyToWallet: (privateKey: string) => IReturnResult // 随机生成钱包 readonly fromRandomToWallet: () => Promise> // 获取地址 readonly getAddress: (value: string) => string // 获取公钥 readonly getPublicKey: (privateKey: string) => string // 获取单个余额 readonly getBalance: (address: string, params?: IGetBalanceParams) => Promise> // 获取全部余额 readonly getAllBalance: (address: string, params?: string[]) => Promise> // 获取当前链高度 readonly getBlockHeight: () => Promise> // 获取合约 readonly getContract: (address: string, abi: string, privateKey?: string) => any // 获取合约详细 readonly getContractDetails: (address: string) => Promise> // 获取交易详细 readonly getTxDetailsByHash: (hash: string, address?: string) => Promise> // 获取交易记录 readonly getTxList: (address: string, params?: ITxListParams) => Promise> // 直接转账 readonly transfer: (from: string, to: string, amount: string, params?: ISignParams) => Promise> // 签名 readonly sign: (from: string, to: string, amount: string, params?: ISignParams) => Promise> // 发送交易 readonly sendTx: (value: string) => Promise> } // 验证 export interface IChainsVerify { readonly address: (address: string) => boolean readonly privateKey: (privateKey: string) => boolean readonly publicKey: (publicKey: string) => boolean readonly balance: (address: string, amount: string, params?: IVerifyBalanceParams) => Promise> } // 链参数 export type IChainsParams = { api: string rpcUrl: string symbol: string chainId: number // api key key?: string // api key[] keys?: string[] // 网络 network?: string } // 返回钱包 export type IToWallet = { address: string privateKey: string publicKey?: string } // 从助记词生成params参数 export type IFromMnemonicParams = { path?: string } // 获取余额params export type IGetBalanceParams = { contract?: string decimals?: number } // 验证余额params export type IVerifyBalanceParams = { contract?: string decimals?: number fee?: string } // 交易列表 params export type ITxListParams = { contract?: string size?: number page?: number decimals?: number type?: "all" | "in" | "out" | "self" } export type ContractType = 'erc-20' | 'erc-721' | 'trc-20' // 签名 params export type ISignParams = { privateKey?: string contract?: string decimals?: number contractType?: ContractType // 备注 note?: string nonce?: number // 是否替换nonce hasReplace?: boolean abi?: string data?: string gasPrice?: string gasLimit?: string // 是否已解锁 hasUnlock?: boolean } // 交易列表 to 数据 export type ITxListToList = { address: string amount: string } // 交易列表数据 export type ITxList = { type: string stat: number // 波长状态 statTrx?: number hash: string from: string to: ITxListToList[] value: string timestamp: string time: string fee: string contractAddress: string contractDecimals: number contractSymbol: string contractName: string } // 余额 export type IBalance = { // 余额 balance: string, // 可用 usable: string, // 锁定 lock?: string, // 未确认 unconfirmed?: string, } // 合约详细 export type IContractDetails = { name?: string decimals?: number symbol?: string address?: string } export type ITxDetails = { type: string, stat: number, hash: string, blockHash: string, blockNumber: string, from: string, to: string, fee: string, nonce: string, value: string, time: string, timestamp: string, }