Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

DRAFT: Fix - 516 refactor input number consistency #549

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ class FarmDepositModal extends React.Component {
approvedAllowance = approvedAllowance.toString()
}

this.setState({ approvedAllowance, stakeToken })
this.setState({
approvedAllowance,
stakeToken,
maxValue: logAmount(stakeToken.balance, stakeToken.decimals),
maxValue_Wei_String: stakeToken.balance.toString()
})
}

}
Expand All @@ -74,25 +79,25 @@ class FarmDepositModal extends React.Component {
this.props.dispatch(closeModal("farmDepositModal"))
}

handleStakeValue(value) {
handleStakeValue(value, value_Wei_String) {

const { stakeToken } = this.state
const { maxValue } = this.state

if( value &&
Number(value) > 0.0 &&
Number(value) <= Number(this.getMaxTransferValue())
) {
this.setState({
stakeValue: value,
stakeValueValid: true,
value_Wei_String: toWei_String(value, stakeToken.decimals)
})
} else {
const tooSmall = new BN(value).lte(new BN(0.0))
const tooBig = new BN(value).gt(new BN(maxValue))

if (tooBig || tooSmall) {
this.setState({
stakeValue: value,
stakeValueValid: false,
value_Wei_String: ''
})
} else {
this.setState({
value_Wei_String,
stakeValue: value,
stakeValueValid: true
})
}
}

Expand Down Expand Up @@ -169,6 +174,7 @@ class FarmDepositModal extends React.Component {
//stakeValueBadEntry,
approvedAllowance,
loading,
maxValue_Wei_String
} = this.state


Expand Down Expand Up @@ -199,8 +205,12 @@ class FarmDepositModal extends React.Component {
type="number"
unit={stakeToken.symbol}
maxValue={this.getMaxTransferValue()}
onChange={i=>{this.handleStakeValue(i.target.value)}}
onUseMax={i=>{this.handleStakeValue(this.getMaxTransferValue())}}
onChange={i => {
this.handleStakeValue(i.target.value, toWei_String(i.target.value, stakeToken.decimals))
}}
onUseMax={i => {
this.handleStakeValue(this.getMaxTransferValue(), maxValue_Wei_String)
}}
allowUseAll={true}
newStyle
variant="standard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FarmWithdrawModal extends React.Component {
LPBalance_Wei_String = await networkService.L2LPBalance(withdrawToken.currency)
}

//console.log("LPBalance current", LPBalance_Wei_String)
console.log("LPBalance current", LPBalance_Wei_String)

this.setState({
LPBalance: logAmount(LPBalance_Wei_String, withdrawToken.decimals),
Expand Down