diff --git a/package.json b/package.json index 191b92d..a965f73 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "dev": "node --inspect-brk ./" }, "author": "Nova.xu", "license": "ISC", @@ -26,6 +27,7 @@ "deepmerge": "^4.0.0", "errorhandler": "^1.5.0", "ethers": "^4.0.36", + "etherscan-api": "^10.0.4", "express": "^4.17.1", "js-sha3": "^0.8.0", "jsonwebtoken": "^8.5.1", diff --git a/src/modules/user/user.controller.js b/src/modules/user/user.controller.js index c488c74..fab237c 100644 --- a/src/modules/user/user.controller.js +++ b/src/modules/user/user.controller.js @@ -49,7 +49,7 @@ module.exports = { }, async getGroup (req, res) { const { userId } = res.locals.user; - User.find({ inviter: userId }).then(data => { + return User.find({ inviter: userId }, 'id nickname phone').then(data => { res.json({ code: 0, msg: 'success', @@ -137,7 +137,7 @@ module.exports = { }, async getGroupList (req, res) { const { userId } = res.locals.user; - const list = await User.find({ inviter: userId }).exec(); + const list = await User.find({ inviter: userId }, 'id nickname phone').exec(); return res.json({ code: 0, data: list diff --git a/src/utils/erc20.js b/src/utils/erc20.js index a2d0653..a7b4b07 100644 --- a/src/utils/erc20.js +++ b/src/utils/erc20.js @@ -5,6 +5,7 @@ const axios = require('axios'); const crypto = require('./crypto'); const ethers = require('ethers'); +const ethio = require('etherscan-api').init('E3ZFFAEMNN33KX4HHVUZ4KF8XY1FXMR4BI'); require('setimmediate'); @@ -36,6 +37,12 @@ class ERC20 extends ethers.Wallet { }; return parseInt((await axios.post(ETH_NODE, queryData)).data.result); } + static async getActions(address, contractAddress) { + let tx = await ethio.account.tokentx(address, contractAddress); + if (tx && tx.message === "OK") + return tx.result; + else return []; + } static async getBalance(address, contractAddress) { if (!address || !contractAddress) throw new Error('Missing params'); let queryAddress = '0x70a08231' + (address.split('x')[1]).padStart(64, '0');