mirror of
https://github.com/fullstack-cash/fullstack-gatsby-theme-bch-wallet.git
synced 2026-09-21 16:52:06 -07:00
fix(decimals): Token 'Send max' needs floor()
This commit is contained in:
@@ -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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user