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

Commit

Permalink
check crosschain fee
Browse files Browse the repository at this point in the history
  • Loading branch information
WoeOm committed Jan 27, 2021
1 parent 02b4899 commit c6bd71f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/page/CrossChain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class CrossChain extends Component {

checkFormDarwiniaToEthereum = (unit = 'ether') => {
const { crossChainBalance, crossChainKtonBalance, crossChainBalanceText, recipientAddress,
crossChainKtonBalanceText, ringBalance, ktonBalance } = this.state;
crossChainKtonBalanceText, ringBalance, ktonBalance, crossChainFee } = this.state;

const { t } = this.props;

Expand All @@ -574,7 +574,7 @@ class CrossChain extends Component {
return false
}

if (crossChainBalance.gt(ringBalance)) {
if ((crossChainBalance.add(crossChainFee).add(Web3.utils.toBN(2000000000))).gt(ringBalance)) {
formToast(t(`crosschain:The amount exceeds the account available balance`))
return false
}
Expand Down Expand Up @@ -995,7 +995,7 @@ class CrossChain extends Component {
<Form.Label>{t('crosschain:Token for cross-chain transfer', { token: 'RING' })}</Form.Label>
<InputWrapWithCheck text={t('crosschain:MAX')} onClick={
() => {
this.setValue('crossChainBalance', { target: { value: formatBalance(ringBalance.gte(Web3.utils.toBN(2000000000)) ? ringBalance.sub(Web3.utils.toBN(2000000000)) : Web3.utils.toBN(0), 'gwei') } }, (value) => this.toWeiBNMiddleware(value, 'gwei'), this.setRingBalanceText)
this.setValue('crossChainBalance', { target: { value: formatBalance(ringBalance.gte(Web3.utils.toBN(2000000000).add(crossChainFee)) ? ringBalance.sub(Web3.utils.toBN(2000000000)).sub(crossChainFee) : Web3.utils.toBN(0), 'gwei') } }, (value) => this.toWeiBNMiddleware(value, 'gwei'), this.setRingBalanceText)
}
} label="RING" inputText={crossChainBalanceText} placeholder={`${t('crosschain:Balance')} : ${formatBalance(ringBalance, 'gwei')} RING`} onChange={(value) => this.setValue('crossChainBalance', value, (value) => this.toWeiBNMiddleware(value, 'gwei'), this.setRingBalanceText)}
defaultIsDisable={false}>
Expand Down
7 changes: 4 additions & 3 deletions src/page/CrossChain/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@
}

.connectAccountBox {
padding: 15px;
margin-bottom: 15px;
padding-top: 15px;
padding-bottom: 15px;

h1 {
font-size: 14px;
font-weight: normal;
Expand Down Expand Up @@ -283,7 +284,7 @@
font-weight: normal;
flex-grow: 0;
flex-shrink: 0;
flex-basis: 100px;
flex-basis: 150px;
}
p{
word-break: break-all;
Expand Down

0 comments on commit c6bd71f

Please sign in to comment.