From c01b931bf06885ea83888d80f1574c0eacd5aae1 Mon Sep 17 00:00:00 2001 From: enitrat Date: Thu, 31 Oct 2024 16:28:19 +0700 Subject: [PATCH] feat: throw errors for unsupported wallet methods --- packages/kakarot/src/kakarot.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/kakarot/src/kakarot.ts b/packages/kakarot/src/kakarot.ts index 7bef3b30..0921e6dd 100644 --- a/packages/kakarot/src/kakarot.ts +++ b/packages/kakarot/src/kakarot.ts @@ -369,19 +369,25 @@ export class KakarotConnector extends Connector { return requestedAccounts.map((x: string) => getAddress(x)); } case "wallet_addStarknetChain": - return false; + throw new Error( + "wallet_addStarknetChain not implemented for Kakarot connectors", + ); case "wallet_watchAsset": - return false; + throw new Error( + "wallet_watchAsset not implemented for Kakarot connectors", + ); case "wallet_switchStarknetChain": { if (!params) throw new Error("Params are missing"); const { chainId } = params as SwitchStarknetChainParameters; - this.switchChain(BigInt(chainId)); + await this.switchChain(BigInt(chainId)); return true; } case "wallet_addDeclareTransaction": { - return false; + throw new Error( + "wallet_addDeclareTransaction not implemented for Kakarot connectors", + ); } case "wallet_addInvokeTransaction": { if (!params) throw new Error("Params are missing"); @@ -421,7 +427,9 @@ export class KakarotConnector extends Connector { // method: "eth_signTypedData_v4", // params: [accounts[0], domain, message, primaryType, types], // }); - return false; + throw new Error( + "wallet_signTypedData not implemented for Kakarot connectors", + ); } default: throw new Error("Unknown request type");