From 49b13d8f5aa8f2eee375cb8c54ea46f2f46b2076 Mon Sep 17 00:00:00 2001 From: asimaranov Date: Thu, 23 May 2024 17:05:30 +0300 Subject: [PATCH 1/2] Fixes for shim connect --- packages/sdk/src/transaction/AuroSigner.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/transaction/AuroSigner.ts b/packages/sdk/src/transaction/AuroSigner.ts index 40a6d99b..fe7d38c5 100644 --- a/packages/sdk/src/transaction/AuroSigner.ts +++ b/packages/sdk/src/transaction/AuroSigner.ts @@ -7,9 +7,16 @@ import { Signer } from "./InMemorySigner"; @injectable() export class AuroSigner extends AppChainModule implements Signer { public async sign(message: Field[]): Promise { + try { const response = await (window as any).mina.signFields({ message: message.map((field) => field.toString()), }); return Signature.fromBase58(response.signature); - } + } catch (e: any) { + if (e.code == 1001) { + await (window as any).mina.requestAccounts(); + return await this.sign(message); + } + throw e; + }} } From 57558bb7d03cabd5073c1f000a5c0ac0897e19a4 Mon Sep 17 00:00:00 2001 From: asimaranov Date: Thu, 23 May 2024 17:17:15 +0300 Subject: [PATCH 2/2] Added support for undefined error --- packages/sdk/src/transaction/AuroSigner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/src/transaction/AuroSigner.ts b/packages/sdk/src/transaction/AuroSigner.ts index fe7d38c5..d01dd351 100644 --- a/packages/sdk/src/transaction/AuroSigner.ts +++ b/packages/sdk/src/transaction/AuroSigner.ts @@ -13,7 +13,7 @@ export class AuroSigner extends AppChainModule implements Signer { }); return Signature.fromBase58(response.signature); } catch (e: any) { - if (e.code == 1001) { + if (e?.code == 1001) { await (window as any).mina.requestAccounts(); return await this.sign(message); }