fix(decimals): Token 'Send max' needs floor()

This commit is contained in:
Daniel Gonzalez
2021-05-19 21:05:36 -04:00
parent 6aeec92191
commit fbf4576cd0
+15 -2
View File
@@ -139,10 +139,23 @@ class SendTokens extends React.Component {
// console.log(_this.state)
}
// Sets the qty property with
// the corresponding token decimals
floorQty (qty, decimals) {
try {
const a = qty * Math.pow(10, decimals)
const b = Math.floor(a)
const result = b / Math.pow(10, decimals)
return result
} catch (error) {
console.warn(error)
}
}
async handleSendMax () {
const { qty } = _this.props.selectedToken
const { qty, decimals } = _this.props.selectedToken
_this.setState({
amountSat: qty
amountSat: _this.floorQty(qty, decimals)
})
}