提交 3e95e8dd authored 作者: 崔大师's avatar 崔大师

bugfix

上级 4e6ee157
......@@ -14,7 +14,7 @@ const init = (mnemonic) => {
const hdwallet = HDWallet.fromSeed(seed)
const privateKey = hdwallet.derive('m/44\'/60\'/0\'/0/0').getPrivateKey()
const address = utils.privateToAddress(privateKey)
console.log('Wallet: ' + toIban('0x'+address.toString('hex')))
console.log('Wallet: ' + toIban('0x' + address.toString('hex')))
web3.setProvider(new web3.providers.HttpProvider(rpxUrl));
web3.thk.defaultPrivateKey = privateKey
web3.thk.defaultAddress = '0x' + address.toString('hex').toLowerCase()
......@@ -55,8 +55,8 @@ const setVal = (value) => {
const ether = (amount) => {
return web3.toWei(amount);
}
const toIban = (THAddress) => {
return web3.Iban.toIban(THAddress).toString()
const toIban = (address) => {
return web3.Iban.toIban(address).toString()
}
const isIban = (THAddress) => {
return web3.Iban.isValid(THAddress)
......@@ -64,4 +64,7 @@ const isIban = (THAddress) => {
const toAddress = (THAddress) => {
return web3.Iban.toAddress(THAddress).toString()
}
module.exports = { init, getTxHash, callContract, deployContract, ether, setVal,toIban,toAddress,isIban };
\ No newline at end of file
const isAddress = (address) => {
return web3.isAddress(address).toString()
}
module.exports = { init, getTxHash, callContract, deployContract, ether, setVal, toIban, toAddress, isIban, isAddress };
\ No newline at end of file
#!/usr/bin/env node
const { init, callContract, ether, getTxHash, toIban, toAddress, isIban } = require('./ThkContract.js');
const Web3 = require('web3');
const { init, callContract, ether, getTxHash, toIban, toAddress, isIban, isAddress } = require('./ThkContract.js');
const fs = require('fs');
const path = require("path");
const inquirer = require('inquirer');
......@@ -127,13 +126,13 @@ const call = async(functionName, inputs, outputs) => {
name: inputs[i].name == "" ? inputs[i].desc : inputs[i].name,
message: inputs[i].type + " " + inputs[i].desc + ':',
validate: function (value) {
if (Web3.utils.isAddress(value)) {
if (isAddress(value)) {
return true;
}
return '地址输入不正确';
},
filter: function (value) {
return toAddress(val);
return isAddress(value) ? value : toAddress(value);
}
}
)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论