UNPKG

mcps-sdk-js

Version:

MCPS JavaScript SDK

133 lines (132 loc) 3.8 kB
import * as consts from './types/constants'; import * as modules from './modules'; import { RpcClient } from './nets/rpc-client'; import { EventListener } from './nets/event-listener'; import { AxiosRequestConfig } from 'axios'; import * as types from './types'; export { KeyDAO, CacheKeyDAO } from './keydao'; import { KeyDAO } from './keydao'; /** MCPS Client */ export declare class Client { /** MCPS Client Config */ config: DefaultClientConfig; /** Axios client for tendermint rpc requests */ rpcClient: RpcClient; /** WebSocket event listener */ eventListener: EventListener; /** Auth module */ auth: modules.Auth; /** Bank module */ bank: modules.Bank; /** Key management module */ keys: modules.Keys; /** Protobuf module */ protobuf: modules.Protobuf; /** Tx module */ tx: modules.Tx; /** Oracle module */ oracle: modules.Oracle; /** Random module */ random: modules.Random; /** Utils module */ utils: modules.Utils; /** Tendermint module */ tendermint: modules.Tendermint; /** Contract module */ contract: modules.Contract; /** MCPS SDK Constructor */ constructor(config: DefaultClientConfig); /** * Set Key DAO Implemention * * @param keyDAO Key DAO Implemention * @returns The SDK itself */ withKeyDAO(keyDAO: KeyDAO): this; /** * Set MCPS network type * * @param network MCPS network type, mainnet / testnet * @returns The SDK itself */ withNetwork(network: consts.Network): this; /** * Set MCPS chain-id * * @param chainId MCPS chain-id * @returns The SDK itself */ withChainId(chainId: string): this; /** * Set default gas limit * * @param gas Default gas limit * @returns The SDK itself */ withGas(gas: string): this; /** * Set default fees * * @param fee Default fee amount * @returns The SDK itself */ withFee(fee: types.Coin): this; /** * Set Axios config for tendermint rpc requests, refer to: https://github.com/axios/axios#request-config. * * Note the `baseURL` is set by `SdkConfig.node` and cannot be overwritten by this config * * @param rpcConfig Axios config for tendermint rpc requests * @returns The SDK itself */ withRpcConfig(rpcConfig: AxiosRequestConfig): this; } /** MCPS SDK Config */ export interface ClientConfig { /** MCPS node rpc address */ node: string; /** MCPS network type, mainnet / testnet */ network?: consts.Network; /** MCPS chain-id */ chainId?: string; /** Default gas limit */ gas?: string; /** Default fee amount */ fee?: types.Coin; /** Key DAO Implemention */ keyDAO?: KeyDAO; /** Bech32 prefix of the network, will be overwritten by network type */ bech32Prefix?: Bech32Prefix; /** Axios request config for tendermint rpc requests */ rpcConfig?: AxiosRequestConfig; } /** Default MCPS Client Config */ export declare class DefaultClientConfig implements ClientConfig { node: string; network: consts.Network; chainId: string; gas: string; fee: types.Coin; keyDAO: KeyDAO; bech32Prefix: Bech32Prefix; rpcConfig: AxiosRequestConfig; constructor(); } /** * Bech32 Prefix */ export interface Bech32Prefix { AccAddr: string; AccPub: string; ValAddr: string; ValPub: string; ConsAddr: string; ConsPub: string; } export declare class DefaultKeyDAOImpl implements KeyDAO { write(name: string, key: types.Key): void; read(name: string): types.Key; delete(name: string): void; encrypt(privKey: string, password: string): string; decrypt(encrptedPrivKey: string, password: string): string; }