Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Dec 19, 2024
1 parent fae4f76 commit bdc72a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions packages/example/src/containers/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ export const Dashboard = (): React.JSX.Element => {
const isReady = await rpc.isReady;

if (api && isReady) {
const balances = await api.getBalances();
const address = await api.getAddress();

setAddress(address);
setNonce((await rpc.derive.balances.account(address)).accountNonce.toString());

if (address != '') {
const balances = await api.getBalances();
setNonce((await rpc.derive.balances.account(address)).accountNonce.toString());
setBalance(balances.free);
}

setPublicKey(await api.getPublicKey());
setBalance(balances.free);
setLatestBlock(await api.getLatestBlock());
setTransactions(await api.getAllTransactions());
}
Expand All @@ -140,16 +143,18 @@ export const Dashboard = (): React.JSX.Element => {
useEffect(() => {
// periodically check balance
const interval = setInterval(async () => {
if (api) {
const balances = await api.getBalances();
const nonce = (await rpc.derive.balances.account(address)).accountNonce.toString();
const isReady = await rpc.isReady;

if (api && isReady && address !== '') {
const balances = await api.getBalances();
setBalance(balances.free);

const nonce = (await rpc.derive.balances.account(address)).accountNonce.toString();
setNonce(nonce);
}
}, 6000); // every 6 seconds
return () => clearInterval(interval);
}, [api, balance, setBalance]);
}, [api, balance, setBalance, nonce, setNonce]);

return (
<Container maxWidth="lg">
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "git+https://github.com/enjin/metamask-snap-enjin.git"
},
"source": {
"shasum": "aeoIrgQL2rdsXR6G7wJVF8c2UQiAnNnD/HWEmMjj1CM=",
"shasum": "WLixE4aGlEDckJjS6yuMVD7b7i6SX6z9Hn2WdFLnf8E=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down

0 comments on commit bdc72a0

Please sign in to comment.