use web3 utils function instead
This commit is contained in:
parent
4ffb5c401f
commit
2a61b2251c
|
@ -61,39 +61,6 @@ class Test {
|
||||||
this.engine.startService("codeGenerator");
|
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) {
|
getBalance(balanceString) {
|
||||||
if (!balanceString) {
|
if (!balanceString) {
|
||||||
return 0xFFFFFFFFFFFFFFFFFF;
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
initWeb3Provider() {
|
||||||
|
|
Loading…
Reference in New Issue