Skip to content

Commit

Permalink
correctly handle empty wallets (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
CAPtheorem authored Apr 15, 2022
1 parent 011b23f commit 6469435
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ function InputStep({ handleClose, token, isBridge, openTokenPicker }) {
convertToUSD = true
}

if( Number(logAmount(token.balance, token.decimals)) === 0) {
//no token in this account
return (
<Box>
<Typography variant="body2" sx={{fontWeight: 700, mb: 1, color: 'yellow'}}>
Sorry, nothing to deposit - no {token.symbol} in this wallet
</Typography>
<Button
onClick={handleClose}
disabled={false}
variant='outlined'
color='primary'
size='large'
>
Cancel
</Button>
</Box>)
}

return (
<>
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,25 @@ function InputStepFast({ handleClose, token, isBridge, openTokenPicker }) {
}
}

if( Number(logAmount(token.balance, token.decimals)) === 0) {
//no token in this account
return (
<Box>
<Typography variant="body2" sx={{fontWeight: 700, mb: 1, color: 'yellow'}}>
Sorry, nothing to deposit - no {token.symbol} in this wallet
</Typography>
<Button
onClick={handleClose}
disabled={false}
variant='outlined'
color='primary'
size='large'
>
Cancel
</Button>
</Box>)
}

return (
<>
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,25 @@ function DoExitStep({ handleClose, token, isBridge, openTokenPicker }) {
${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''}.
Your funds will be available on L1 in 7 days.`

if( Number(logAmount(token.balance, token.decimals)) === 0) {
//no token in this account
return (
<Box>
<Typography variant="body2" sx={{fontWeight: 700, mb: 1, color: 'yellow'}}>
Sorry, nothing to exit - no {token.symbol} in this wallet
</Typography>
<Button
onClick={handleClose}
disabled={false}
variant='outlined'
color='primary'
size='large'
>
Cancel
</Button>
</Box>)
}

return (
<>
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,25 @@ function DoExitStepFast({ handleClose, token, isBridge, openTokenPicker }) {
let receiveL1 = `Est. receive ${receivableAmount(value)} ${token.symbol}
${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''}`

if( Number(logAmount(token.balance, token.decimals)) === 0) {
//no token in this account
return (
<Box>
<Typography variant="body2" sx={{fontWeight: 700, mb: 1, color: 'yellow'}}>
Sorry, nothing to exit - no {token.symbol} in this wallet
</Typography>
<Button
onClick={handleClose}
disabled={false}
variant='outlined'
color='primary'
size='large'
>
Cancel
</Button>
</Box>)
}

return (
<>
<Box>
Expand Down

0 comments on commit 6469435

Please sign in to comment.