Fixed bug when passing in hex string to formatEther.
This commit is contained in:
parent
7a37dd6949
commit
0e9df5cb76
@ -236,12 +236,14 @@ var zero = new utils.BN(0);
|
|||||||
var negative1 = new utils.BN(-1);
|
var negative1 = new utils.BN(-1);
|
||||||
var tenPower18 = new utils.BN('1000000000000000000');
|
var tenPower18 = new utils.BN('1000000000000000000');
|
||||||
utils.defineProperty(Wallet, 'formatEther', function(wei, options) {
|
utils.defineProperty(Wallet, 'formatEther', function(wei, options) {
|
||||||
|
|
||||||
if (typeof(wei) === 'number') {
|
if (typeof(wei) === 'number') {
|
||||||
// @TODO: Warn if truncation will occur?
|
// @TODO: Warn if truncation will occur?
|
||||||
wei = new utils.BN(wei);
|
wei = new utils.BN(wei);
|
||||||
} else if (utils.isHexString(wei)) {
|
} else if (utils.isHexString(wei)) {
|
||||||
wei = new utils.BN(wei.substring(2));
|
wei = new utils.BN(wei.substring(2), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options) { options = {}; }
|
if (!options) { options = {}; }
|
||||||
|
|
||||||
if (!(wei instanceof utils.BN)) { throw new Error('invalid wei'); }
|
if (!(wei instanceof utils.BN)) { throw new Error('invalid wei'); }
|
||||||
|
Loading…
Reference in New Issue
Block a user