From 45125a100f0dc1944e462a92180be28072cea983 Mon Sep 17 00:00:00 2001 From: Norbert Bodziony Date: Tue, 14 Jun 2022 15:49:51 +0200 Subject: [PATCH] CR refactor --- packages/nightly/src/lib/nightly.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/packages/nightly/src/lib/nightly.ts b/packages/nightly/src/lib/nightly.ts index 855292692..10dd4838a 100644 --- a/packages/nightly/src/lib/nightly.ts +++ b/packages/nightly/src/lib/nightly.ts @@ -40,22 +40,12 @@ const isInstalled = () => { return waitFor(() => !!window.nightly!.near!).catch(() => false); }; const Nightly: WalletBehaviourFactory = async ({ - metadata, store, logger, provider, }) => { const _state = await setupNightlyState(store); - const currentState = store.getState(); - if (currentState.selectedWalletId === "nightly") { - try { - // eager connect to the wallet - await _state.wallet.connect(undefined, true); - } catch { - // ignore - } - } const getAccounts = async () => { if (!_state || _state.wallet.account.accountId === "") { return []; @@ -68,19 +58,12 @@ const Nightly: WalletBehaviourFactory = async ({ return { // nightly does not support delegating signing right now async signIn() { - // If wallet does not exist user will be redirected to download page - if (!_state) { - window.location.href = metadata.downloadUrl; - throw new Error("Redirecting to download"); - } const existingAccount = _state.wallet.account.accountId; if (existingAccount) { - const nearAccount: Account = { - accountId: _state.wallet.account.accountId, - }; - return [nearAccount]; + return await getAccounts(); } + await _state.wallet.connect(); return await getAccounts();