Skip to content

Commit

Permalink
Merge pull request #82 from anyone-protocol/leggo/phase-1/dev
Browse files Browse the repository at this point in the history
update error for locking tokens
  • Loading branch information
MarcoMandar committed Sep 26, 2024
2 parents 91a55b8 + 6d85690 commit d929c1a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
23 changes: 22 additions & 1 deletion composables/facilitator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,28 @@ export class Facilitator {
const to = await this.contract.getAddress();

const result = await this.signer.sendTransaction({ to, value });
await result.wait();

const maxRetries = 3;
const delay = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));

for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
await result.wait();
break;
} catch (error) {
if (attempt < maxRetries) {
this.logger.warn(
`Attempt ${attempt} failed, retrying in 2 seconds...`
);
await delay(2000);
} else {
throw new Error(
`Transaction confirmation failed after ${maxRetries} attempts`
);
}
}
}
const block = await result.getBlock();
const timestamp = block?.timestamp || Math.floor(Date.now() / 1000);
useFacilitatorStore().addPendingClaim(result.hash, timestamp);
Expand Down
2 changes: 1 addition & 1 deletion composables/registrator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class Registrator {
icon: 'i-heroicons-x-circle',
color: 'amber',
title: 'Error',
description: `Error redeem rewards: ${msg}`,
description: `Error locking rewards ${formatEther(registratorStore.currentLockSize || '0')} $ANYONE: ${msg}`,
});
} else {
toast.add({
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default defineNuxtConfig({
supportWalletPublicKeyBase64:
'K3jnSGVyHj4kSzgce3+k8gJsfHvUoQeJMNPO8CcsO2s=',
commitHash: process.env.NUXT_PUBLIC_COMMIT_HASH || 'dev',
version: '1.2.3',
version: '1.2.4',
},
},
plugins: [{ src: '~/plugins/vue-query.client.ts', mode: 'client' }],
Expand Down

0 comments on commit d929c1a

Please sign in to comment.