Skip to content

Commit

Permalink
Catch registration failures (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
broody authored Apr 11, 2024
1 parent 9945851 commit 1378a10
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions packages/keychain/src/utils/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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<string> {
Expand Down

0 comments on commit 1378a10

Please sign in to comment.