getDisplayValue = (value, decimals=2) => {
const displayVal = utils.fromWei(value.toString(), 'ether');
if (displayVal.indexOf('.') !== -1) {
return displayVal.substr(0, displayVal.indexOf('.') + decimals + 1);
}
return displayVal;
}
Suggest maybe update ERC20Asset, add a new optional parameter; decimals and do some fancy BigNumber mathematics to display the token appropriately rather than fromWei
. Alternatively, create a new subclass ERC20AssetDetailed which can implement this functionality.
A cool future way might be to include the ERC20AssetDetailed ABI and actually call the decimals()
function to determine appropriate decimals on construction of the Asset.