Skip to content

Commit

Permalink
Merge pull request #308 from EYBlockchain/liju.jose/wallet-fixes-issu…
Browse files Browse the repository at this point in the history
…e-222

setInterval to fetch token balance
  • Loading branch information
IlyasRidhuan authored Nov 22, 2021
2 parents 22c0cc7 + aa53516 commit e06f8dd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
2 changes: 2 additions & 0 deletions wallet/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const METAMASK_MESSAGE =

const TRANSACTION_MAX_RETRIES = 10;
const TRANSACTION_RETRY_PERIOD = 10000; // 10s
const BALANCE_INTERVAL = 30000;

export {
DEFAULT_NF_ADDRESS_INDEX,
Expand All @@ -59,4 +60,5 @@ export {
METAMASK_MESSAGE,
TRANSACTION_MAX_RETRIES,
TRANSACTION_RETRY_PERIOD,
BALANCE_INTERVAL,
};
2 changes: 1 addition & 1 deletion wallet/src/views/login/login.view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function Login({ login, settings, onLoadWallet, onDeleteWallet }) {
}
} catch (err) {
// TODO
console.log('ERROR');
console.log('ERROR', err);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
deleteToken,
} from '../../../../store/token/token.actions';
import { TokenAddModal } from './token-add.view.jsx';
import * as Constant from '../../../../constants';

function WalletInfo({ login, token, onAddToken, onSelectToken, onUnselectToken, onDeleteToken }) {
const [modalTokenAddEnable, setModalTokenAddEnable] = React.useState(false);
Expand Down Expand Up @@ -101,7 +102,10 @@ function WalletInfo({ login, token, onAddToken, onSelectToken, onUnselectToken,
}

React.useEffect(() => {
reload();
const retrieveBalance = setInterval(() => {
reload();
}, Constant.BALANCE_INTERVAL);
return () => clearInterval(retrieveBalance);
}, []);

const handleOnTokenAddSubmit = (tokenName, tokenType, tokenAddress) => {
Expand All @@ -119,40 +123,40 @@ function WalletInfo({ login, token, onAddToken, onSelectToken, onUnselectToken,

return (
<Container>
<Table padded>
<Table padded fixed selectable>
<Table.Header>
<Table.Row>
<Table.HeaderCell colSpan="4" textAlign="left">
<Table.HeaderCell colSpan="4">
<Table.Cell>Account Address:</Table.Cell>
<Table.Cell id="wallet-info-cell-ethaddress"> {importedWallet()} </Table.Cell>
</Table.HeaderCell>
<Table.HeaderCell textAlign="right">
<Button
onClick={reload}
id="wallet-info-cell-reload"
disabled={token.activeTokenRowId === ''}
>
<Icon name="sync" />
Reload
</Button>
</Table.HeaderCell>
<Table.HeaderCell textAlign="right">
<Button onClick={toggleModalTokenAdd} id="wallet-info-cell-add-token">
<Icon name="plus" />
Add Token
</Button>
</Table.HeaderCell>
<Table.HeaderCell textAlign="right">
<Button
toggle
onClick={removeToken}
id="wallet-info-cell-remove-token"
active={removeTokenEnable && token.tokenPool.length}
disabled={token.tokenPool.length === 0}
>
{' '}
<Icon name="minus" /> Remove Token{' '}
</Button>
<Table.HeaderCell colSpan="3">
<Table.Cell />
<Table.Cell />
<Table.Cell>
<Button
icon
labelPosition="left"
onClick={toggleModalTokenAdd}
id="wallet-info-cell-add-token"
>
<Icon name="plus" />
Add Token
</Button>
</Table.Cell>
<Table.Cell>
<Button
icon
labelPosition="left"
id="wallet-info-cell-remove-token"
toggle
onClick={removeToken}
active={removeTokenEnable && token.tokenPool.length}
disabled={token.tokenPool.length === 0}
>
<Icon name="minus" /> Remove Token
</Button>
</Table.Cell>
</Table.HeaderCell>
</Table.Row>
</Table.Header>
Expand Down

0 comments on commit e06f8dd

Please sign in to comment.