From 1378a10840408c13a5218abb094c584dcfd9c65c Mon Sep 17 00:00:00 2001 From: Yun Date: Thu, 11 Apr 2024 06:24:28 -1000 Subject: [PATCH] Catch registration failures (#263) --- packages/keychain/src/utils/account.ts | 46 +++++++++++++++----------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/keychain/src/utils/account.ts b/packages/keychain/src/utils/account.ts index bb9efe053..c680778f0 100644 --- a/packages/keychain/src/utils/account.ts +++ b/packages/keychain/src/utils/account.ts @@ -152,7 +152,10 @@ class Account extends BaseAccount { return; } - const classHash = await this.rpc.getClassHashAt(this.address, "latest"); + const classHash = await this.rpc.getClassHashAt( + this.address, + "latest", + ); Storage.update(this.selector, { classHash, }); @@ -270,30 +273,33 @@ class Account extends BaseAccount { const fee = BigInt(gasPrice) * gas; const maxFee = num.toHex(stark.estimatedFeeToMaxFee(fee)); - const signature = await this.webauthn - .signTransaction(calls, { + try { + const signature = await this.webauthn.signTransaction(calls, { maxFee, version, nonce, - }) - .catch((e) => { - console.error(e); }); - this.invokeFunction({ - contractAddress: this.address, - calldata: transaction.fromCallsToExecuteCalldata_cairo1(calls), - signature, - }, { - maxFee, - version, - nonce, - }) - - this.status = Status.REGISTERING; - Storage.update(this.selector, { - status: Status.REGISTERING, - }); + await this.invokeFunction( + { + contractAddress: this.address, + calldata: transaction.fromCallsToExecuteCalldata_cairo1(calls), + signature, + }, + { + maxFee, + version, + nonce, + }, + ); + + this.status = Status.REGISTERING; + Storage.update(this.selector, { + status: Status.REGISTERING, + }); + } catch (e) { + console.error(e); + } } async getNonce(blockIdentifier?: any): Promise {