Skip to content

Commit 20f9087

Browse files
committed
Improve the WalletRegistry.getWalletPublicKey fn
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.
1 parent f364b70 commit 20f9087

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

typescript/src/lib/ethereum/wallet-registry.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ChainIdentifier,
99
Chains,
1010
} from "../contracts"
11-
import { backoffRetrier, Hex } from "../utils"
11+
import { backoffRetrier, Hex, skipRetryWhenMatched } from "../utils"
1212
import { Event as EthersEvent } from "@ethersproject/contracts"
1313
import { BigNumber } from "ethers"
1414
import {
@@ -66,13 +66,16 @@ export class EthereumWalletRegistry
6666
* @see {WalletRegistry#getWalletPublicKey}
6767
*/
6868
async getWalletPublicKey(walletID: Hex): Promise<Hex> {
69-
const publicKey = await backoffRetrier<string>(this._totalRetryAttempts)(
70-
async () => {
71-
return await this._instance.getWalletPublicKey(
72-
walletID.toPrefixedString()
73-
)
74-
}
75-
)
69+
const publicKey = await backoffRetrier<string>(
70+
this._totalRetryAttempts,
71+
undefined,
72+
undefined,
73+
skipRetryWhenMatched(["Wallet with the given ID has not been registered"])
74+
)(async () => {
75+
return await this._instance.getWalletPublicKey(
76+
walletID.toPrefixedString()
77+
)
78+
})
7679
return Hex.from(publicKey.substring(2))
7780
}
7881

0 commit comments

Comments
 (0)