UNPKG

moac-api

Version:
60 lines (56 loc) 1.68 kB
var common = require('./common'); class Explorer { constructor(explorerAddress) { this.explorerAddress = explorerAddress; this.explorerIp = common.resolveAddress(this.explorerAddress).ip; this.explorerPort = common.resolveAddress(this.explorerAddress).port; return this; } /** * 获得母链指定账户地址查询交易记录 * @param addr 账户地址 * @param start 从第几条开始查询 * @param length 查询条数 * @param searchValue 搜索查询(hash, from, to) * */ getTxsByAddress(addr,start,length,searchValue){ if(start==undefined){ start = "1"; } if(length==undefined){ start = "20"; } if(searchValue==undefined){ searchValue = ""; } var param = {"addr": addr,"search":{"value":searchValue},"start":start,"length":length}; return common.explorerRequest(this.explorerIp, this.explorerPort, "addr", param).then((txs) => { return txs; }) } /** * 获得母链指定账户地址查询内部交易记录 * @param addr 账户地址 * @param start 从第几条开始查询 * @param length 查询条数 * @param searchValue 搜索查询(hash, from, to) * */ getInternalTxsByAddress(addr,start,length,searchValue){ if(start==undefined){ start = "1"; } if(length==undefined){ start = "20"; } if(searchValue==undefined){ searchValue = ""; } var param = {"addr": addr,"search":{"value":searchValue},"start":start,"length":length}; return common.explorerRequest(this.explorerIp, this.explorerPort, "internalTxs", param).then((txs) => { return txs; }) } } module.exports = Explorer;