Skip to content

Commit

Permalink
Merge pull request #13 from gnosischain/fix/shutter-timer-error-handling
Browse files Browse the repository at this point in the history
Fix shutter timer error handling
  • Loading branch information
verkhohliad authored Aug 15, 2024
2 parents 872ea5f + 5fb65e6 commit 4a597ac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ concurrency:

env:
VITE_WALLET_CONNECT_PROJECT_ID: ${{ secrets.VITE_WALLET_CONNECT_PROJECT_ID }}
VITE_THE_GRAPH_API_KEY: ${{ secrets.VITE_THE_GRAPH_API_KEY }}

jobs:
deploy:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/prod_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrency:

env:
VITE_WALLET_CONNECT_PROJECT_ID: ${{ secrets.VITE_WALLET_CONNECT_PROJECT_ID }}
VITE_THE_GRAPH_API_KEY: ${{ secrets.VITE_THE_GRAPH_API_KEY }}

jobs:
deploy:
Expand Down
5 changes: 3 additions & 2 deletions src/shared/ShutterTimer/ShutterTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ShutterTimer = () => {

if (!match) {
setTimeDifference(0);
setCurrentEpoch(getEpoch(chain.genesisTime) + 1);
setCurrentEpoch(currentEpoch + 1);
clearInterval(interval);
return;
}
Expand All @@ -73,7 +73,8 @@ export const ShutterTimer = () => {
className="my-4"
aria-label="Loading..."
size="lg"
value={100 - timeDifference}
value={timeDifference}
formatOptions={{ style: "unit", unit: "second" }}
color="warning"
showValueLabel={true}
/>
Expand Down
25 changes: 15 additions & 10 deletions src/shared/ShutterTimer/useGetShutterValidatorIndexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,24 @@ export const useGetShutterValidatorIndexes = (chainId: number) => {
let newLastBlock = lastBlockNumber;

const indexes = logs?.reduce((acc, log) => {
const validatorIndex = extractValidatorIndex(log.message);
const subscriptionStatus = extractSubscriptionStatus(log.message);
try {
const validatorIndex = extractValidatorIndex(log.message);
const subscriptionStatus = extractSubscriptionStatus(log.message);

if (subscriptionStatus) {
acc.add(validatorIndex);
} else {
currentIndexes = currentIndexes.filter((index) => index !== validatorIndex);
acc.delete(validatorIndex);
}
if (subscriptionStatus) {
acc.add(validatorIndex);
} else {
currentIndexes = currentIndexes.filter((index) => index !== validatorIndex);
acc.delete(validatorIndex);
}

newLastBlock = Number(log.blockNumber);
newLastBlock = Number(log.blockNumber);

return acc;
return acc;
} catch (err) {
console.error('Failed to extract validator index from log', err);
return acc;
}
}, new Set<number>());

if (indexes && newLastBlock > lastBlockNumber) {
Expand Down

0 comments on commit 4a597ac

Please sign in to comment.