Skip to content

Commit

Permalink
fix(nonce-manager): change nonce management logic
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Sep 10, 2024
1 parent dff78cb commit 850bbb8
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,13 @@ export async function configDeps(
const storageSigner = new NonceManager(
new Wallet(secrets.evmWallet.privateKey, storageProvider),
);
const nonce = { n: await storageSigner.getNonce(), used: false };
let nonce = await storageSigner.getNonce();
const lock = new Mutex();

const fetchNonce = async () => {
const release = await lock.acquire();
if (nonce.used) {
nonce.n = nonce.n + 1;
nonce.used = false;
return [nonce.n, release] as const;
}
nonce.used = true;
return [nonce.n, release] as const;
nonce += 1;
return [nonce, release] as const;
};

const storage = BridgeStorage__factory.connect(
Expand Down

0 comments on commit 850bbb8

Please sign in to comment.