use web3 utils function instead

This commit is contained in:
Jonathan Rainville 2018-06-06 16:53:28 -04:00
parent 4ffb5c401f
commit 2a61b2251c
1 changed files with 1 additions and 34 deletions

View File

@ -61,39 +61,6 @@ class Test {
this.engine.startService("codeGenerator");
}
// eslint-disable-next-line complexity
getMutliplicator(keyword) {
switch (keyword.toLowerCase()) {
case 'wei': return 1;
case 'ether':
case 'eth': return 1000000000000000000;
case 'finney':
case 'milli':
case 'milliether': return 1000000000000000;
case 'szabo':
case 'microether,':
case 'micro': return 1000000000000;
case 'gwei':
case 'nanoether':
case 'shannon':
case 'nano': return 1000000000;
case 'mwei':
case 'babbage':
case 'picoether': return 1000000;
case 'kwei':
case 'ada':
case 'femtoether': return 1000;
case 'kether':
case 'grand':
case 'einstein': return 1000000000000000000000;
case 'mether': return 1000000000000000000000000;
case 'gether': return 1000000000000000000000000000;
case 'tether': return 1000000000000000000000000000000;
default: console.warn('\n' + __(`Unrecognised keyword ${keyword} in balance. Will assume Wei`).yellow);
return 1;
}
}
getBalance(balanceString) {
if (!balanceString) {
return 0xFFFFFFFFFFFFFFFFFF;
@ -106,7 +73,7 @@ class Test {
return this.web3.utils.toHex(parseInt(match[1], 10));
}
return this.web3.utils.toHex(parseInt(match[1], 10) * this.getMutliplicator(match[2]));
return this.web3.utils.toHex(this.web3.utils.toWei(match[1], match[2]));
}
initWeb3Provider() {