Skip to content

Commit

Permalink
chore(approveLock): remove promise.race
Browse files Browse the repository at this point in the history
  • Loading branch information
D4mph1r committed Sep 12, 2024
1 parent 87ece38 commit bd306ba
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/handler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export async function listenEvents(
return;
}
const approvalFn = async () => {
const approveLockRace = async () => {
const approveLockTx = async () => {
const [nonce, release] = await fetchNonce();
const [releaseStorage, storage] = await fetchStorage();
log.info(`Using nonce: ${nonce}`);
Expand All @@ -151,17 +151,7 @@ export async function listenEvents(
};

try {
const tx = await Promise.race([
approveLockRace(),
setTimeout(20 * 1000),
]);
//@ts-ignore
if (!tx?.status)
throw new Error(
tx
? `Approve Failed ${tx.status}`
: "Timeout after 20 Seconds Approve failed",
);
const tx = await approveLockTx();
return tx;
} catch (err) {
const err_ = err as unknown as { shortMessage: string };
Expand Down Expand Up @@ -248,15 +238,12 @@ export async function listenStakeEvents(
}

const approvalFn = async () => {
const approveStakeRace = async () =>
const approveStakeTx = async () =>
await (
await deps.storage.approveStake(stakerAddress, signatures)
).wait();
try {
const tx = await Promise.race([
approveStakeRace(),
setTimeout(10 * 1000),
]);
const tx = await approveStakeTx();

// @ts-ignore
if (!tx?.status) {
Expand Down

0 comments on commit bd306ba

Please sign in to comment.