Merge pull request #147 from Permissionless-Software-Foundation/dh-fix-send

fix(decimals): Token 'Send max' needs floor()
This commit is contained in:
Chris Troutner
2021-05-21 05:49:42 -07:00
committed by GitHub
+15 -2
View File
@@ -139,10 +139,23 @@ class SendTokens extends React.Component {
// console.log(_this.state) // 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 () { async handleSendMax () {
const { qty } = _this.props.selectedToken const { qty, decimals } = _this.props.selectedToken
_this.setState({ _this.setState({
amountSat: qty amountSat: _this.floorQty(qty, decimals)
}) })
} }