import chain3 = require("jcc_chain3"); interface IWalletModel { address: string; secret: string; } /** * toolkit of moac * * @export * @class Moac */ export default class Moac { /** * instance of chain3 * * @protected * @type {chain3} * @memberof Moac */ protected _chain3: chain3; /** * moac node * * @private * @type {string} * @memberof Moac */ private _node; /** * main or test net * * @private * @type {number} * @memberof Moac */ private _network; /** * main net * the value is 99 * @private * @type {number} * @memberof Moac */ private readonly MAINNET; /** * test net * the value is 101 * @private * @type {number} * @memberof Moac */ private readonly TESTNET; /** * gas limit * * @private * @type {number} * @memberof Moac */ private _gasLimit; /** * minimum gas price * * @private * @type {number} * @memberof Moac */ private _minGasPrice; /** * Creates an instance of Moac * @param {string} node * @param {boolean} mainnet * @memberof Moac */ constructor(node: string, mainnet: boolean); /** * set & get _gasLimit * * @type {number} * @memberof Moac */ get gasLimit(): number; set gasLimit(gas: number); /** * set & get _minGasPrice * * @type {number} * @memberof Moac */ get minGasPrice(): number; set minGasPrice(value: number); /** * validate moac address * * @static * @param {string} address moac address * @returns {boolean} return true if the address is valid * @memberof Moac */ static isValidAddress(address: string): boolean; /** * validate moac secret * * @static * @param {string} secret moac secret * @returns {boolean} return true if the secret is valid * @memberof Moac */ static isValidSecret(secret: string): boolean; /** * get moac address with secret * * @static * @param {string} secret moac secret * @returns {string} return address if the secret is valid, otherwise return null * @memberof Moac */ static getAddress(secret: string): string; /** * create moac wallet * * @static * @returns {IWalletModel} * @memberof Moac */ static createWallet(): IWalletModel; /** * prefix `0x` before the given moac address if it's not start with `0x` * * @public * @static * @param {string} address moac address * @returns {string} return itself if the address is empty or start with `0x` * @memberof Moac */ static prefix0x(address: string): string; /** * init instance of chain3 * * @memberof Moac */ initChain3(): void; setScs(scs: string): void; /** * destroy instance of chain3 * * @memberof Moac */ destroyChain3(): void; /** * get instance of chain3 * * @memberof Moac */ getChain3(): chain3; /** * request info of block * * @param {number|string} block number or string latest * @returns {Promise} resolve null if request failed, return block info * @memberof Moac */ getBlock(block: number | string): Promise; /** * request balance of moac * * @param {string} address moac address * @returns {Promise} resolve 0 if request failed, it is 18-digit decimal, convert it into number will lose * @memberof Moac */ getBalance(address: string): Promise; /** * request nonce * * @param {string} address moac address * @returns {Promise} resolve nonce if successful * @memberof Moac */ getNonce(address: string): Promise; /** * request gas price * * @param {number} limit min gas * @returns {Promise} if request failed, the default response gas is 20000000000. if the response gas is less than * the given limit, resolve the value of given limit * @memberof Moac */ getGasPrice(limit: number): Promise; /** * get transaction count * * @param {string} address moac address * @returns {Promise} transaction count * @memberof Moac */ getTransactionCount(address: string): Promise; /** * transfer moac * * @param {string} moacSecret * @param {string} dest destination address * @param {string} amount * @param {string} [memo] * @param {ITransactionOption} [options] * @returns {Promise} * @memberof Moac */ transferMoac(moacSecret: string, dest: string, amount: string, memo?: string, options?: ITransactionOption): Promise; /** * structuring transaction data * * @param {string} from moac address * @param {string} to moac address * @param {number} nonce current nonce * @param {number} gasLimit gas limit * @param {string} gasPrice gas price * @param {string} value MOAC amount * @param {string} calldata generated by `getData` api of contract * @returns {IMoacTransaction} return transaction object * @memberof Moac */ getTx(from: string, to: string, nonce: number, gasLimit: number | string, gasPrice: number | string, value: string, calldata: string, via?: string, shardingFlag?: string): IMoacTransaction; /** * sign transaction * * @param {IMoacTransaction} tx object * @param {string} secret moac account secret * @returns {string} signed string * @memberof Moac */ signTransaction(tx: IMoacTransaction, secret: string): string; /** * send signed transaction * * @param {string} signedTransaction generated by `signTransaction` api of chain3 instance * @returns {Promise} resolve hash if successful * @memberof Moac */ sendSignedTransaction(signedTransaction: string): Promise; /** * send raw signed transaction * * @param {string} signedTransaction generated by `signTransaction` api of chain3 instance * @returns {Promise} resolve hash if successful * @deprecated * @memberof Moac */ sendRawSignedTransaction(signedTransaction: string): Promise; /** * send raw signed transaction by calldata * * @param {string} secret moac account secret * @param {string} contractAddr contract address * @param {string} value amount of moac * @param {any} calldata call data * @param {ITransactionOption} options options of transaction * @returns {Promise} resolve hash if successful * @memberof Moac */ sendTransactionWithCallData(secret: string, contractAddr: string, value: string, calldata: any, options?: ITransactionOption): Promise; /** * get transaction * * @param {string} hash transaction hash * @returns {any} null or transaction object * @memberof Moac */ getTransaction(hash: string): Promise; /** * get transaction receipt * * @param {string} hash transaction hash * @returns {any} null or transaction receipt object * @memberof Moac */ getTransactionReceipt(hash: string): Promise; /** * get instance of moac contract(ERC20,ERC721, Fingate etc) * * @public * @param {object} abi definition of moac abi or erc20 abi * @returns {chain3.mc.contract} return instance of moac or erc20 contract * @memberof Moac */ contract(abi: object): chain3.mc.contract; /** * check instance of contract if initialied * * @public * @param {chain3.mc.contract} contract * @param {string} address * @returns {boolean} * @memberof Moac */ contractInitialied(contract: chain3.mc.contract, address: string): boolean; /** * check and set transaction options * * @param {ITransactionOption} options * @param {string} sender moac address * @returns {Promise} * @memberof Moac */ getOptions(options: ITransactionOption, sender: string): Promise; } export {};