From c5f81f0bb9a495387696dc7be94c9a579188ac32 Mon Sep 17 00:00:00 2001 From: bluecco Date: Wed, 10 Jan 2024 13:28:47 +0100 Subject: [PATCH 1/3] fix: implement argent mobile connector isPreauthorized method --- src/connectors/argentMobile/index.ts | 3 +++ src/connectors/argentMobile/modal/starknet/adapter.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/connectors/argentMobile/index.ts b/src/connectors/argentMobile/index.ts index 65f5d0c..7c0b328 100644 --- a/src/connectors/argentMobile/index.ts +++ b/src/connectors/argentMobile/index.ts @@ -45,6 +45,9 @@ export class ArgentMobileConnector extends Connector { } async ready(): Promise { + // check if session is valid and retrieve the wallet + // if no sessions, it will show the login modal + await this.ensureWallet() if (!this._wallet) { return false } diff --git a/src/connectors/argentMobile/modal/starknet/adapter.ts b/src/connectors/argentMobile/modal/starknet/adapter.ts index d0fb6f1..7fb3be2 100644 --- a/src/connectors/argentMobile/modal/starknet/adapter.ts +++ b/src/connectors/argentMobile/modal/starknet/adapter.ts @@ -127,7 +127,12 @@ export class StarknetAdapter } async isPreauthorized(): Promise { - throw new Error("Not implemented: .isPreauthorized()") + // check if wc session is valid, if so, return true + const session = this.client.session.getAll().find(this.isValidSession) + if (session) { + return true + } + return false } on: ConnectedStarknetWindowObject["on"] = (event, handleEvent) => { From 4cc71576c5d266c40872c1db45eecdde757fd0a4 Mon Sep 17 00:00:00 2001 From: bluecco Date: Mon, 15 Jan 2024 09:41:57 +0100 Subject: [PATCH 2/3] chore: refactor argent mobile isPreauthorized --- src/connectors/argentMobile/modal/starknet/adapter.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/connectors/argentMobile/modal/starknet/adapter.ts b/src/connectors/argentMobile/modal/starknet/adapter.ts index 7fb3be2..e1a784d 100644 --- a/src/connectors/argentMobile/modal/starknet/adapter.ts +++ b/src/connectors/argentMobile/modal/starknet/adapter.ts @@ -128,11 +128,7 @@ export class StarknetAdapter async isPreauthorized(): Promise { // check if wc session is valid, if so, return true - const session = this.client.session.getAll().find(this.isValidSession) - if (session) { - return true - } - return false + return !!this.client.session.getAll().find(this.isValidSession) } on: ConnectedStarknetWindowObject["on"] = (event, handleEvent) => { From 51862784b7b0a8ee6178fe512ab1918681bf6ec9 Mon Sep 17 00:00:00 2001 From: bluecco Date: Mon, 15 Jan 2024 10:00:21 +0100 Subject: [PATCH 3/3] chore: refactor argent mobile isPreauthorized --- src/connectors/argentMobile/modal/starknet/adapter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectors/argentMobile/modal/starknet/adapter.ts b/src/connectors/argentMobile/modal/starknet/adapter.ts index e1a784d..66709de 100644 --- a/src/connectors/argentMobile/modal/starknet/adapter.ts +++ b/src/connectors/argentMobile/modal/starknet/adapter.ts @@ -128,7 +128,7 @@ export class StarknetAdapter async isPreauthorized(): Promise { // check if wc session is valid, if so, return true - return !!this.client.session.getAll().find(this.isValidSession) + return Boolean(this.client.session.getAll().find(this.isValidSession)) } on: ConnectedStarknetWindowObject["on"] = (event, handleEvent) => {