Skip to content

Commit

Permalink
Improve the WalletRegistry.getWalletPublicKey fn
Browse files Browse the repository at this point in the history
Skip retrying when the contract throws an error saying the wallet with
the given ID has not been registered. There is no need to retry this
request because the contract responds with the exact reason - the wallet
does not exist.
  • Loading branch information
r-czajkowski committed Jul 26, 2024
1 parent f364b70 commit 20f9087
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions typescript/src/lib/ethereum/wallet-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ChainIdentifier,
Chains,
} from "../contracts"
import { backoffRetrier, Hex } from "../utils"
import { backoffRetrier, Hex, skipRetryWhenMatched } from "../utils"
import { Event as EthersEvent } from "@ethersproject/contracts"
import { BigNumber } from "ethers"
import {
Expand Down Expand Up @@ -66,13 +66,16 @@ export class EthereumWalletRegistry
* @see {WalletRegistry#getWalletPublicKey}
*/
async getWalletPublicKey(walletID: Hex): Promise<Hex> {
const publicKey = await backoffRetrier<string>(this._totalRetryAttempts)(
async () => {
return await this._instance.getWalletPublicKey(
walletID.toPrefixedString()
)
}
)
const publicKey = await backoffRetrier<string>(
this._totalRetryAttempts,
undefined,
undefined,
skipRetryWhenMatched(["Wallet with the given ID has not been registered"])
)(async () => {
return await this._instance.getWalletPublicKey(
walletID.toPrefixedString()
)
})
return Hex.from(publicKey.substring(2))
}

Expand Down

0 comments on commit 20f9087

Please sign in to comment.