From 0179f22fdfac0d018ae43d6df2cb6629f9592f70 Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Fri, 9 Feb 2024 03:20:04 -0300 Subject: [PATCH] fix issue with walletSelector calling wallet() when it isnt ready still --- package.json | 2 +- src/managers/wallet-manager.ts | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index bd9e6aa..e1642f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wpdas/naxios", - "version": "2.0.0", + "version": "2.0.1", "description": "Promise based NEAR Contract and NEAR Wallet client for browser", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/src/managers/wallet-manager.ts b/src/managers/wallet-manager.ts index 34fd53e..b60eed3 100644 --- a/src/managers/wallet-manager.ts +++ b/src/managers/wallet-manager.ts @@ -72,19 +72,21 @@ export class WalletManager { private async setupData() { // Initialize Wallet - const wallet = await this.walletSelector.wallet() - this.wallet = wallet + if (this.walletSelector) { + const wallet = await this.walletSelector.wallet() + this.wallet = wallet - const walletState = this.walletSelector.store.getState() - const accounts = walletState.accounts - this.accounts = accounts + const walletState = this.walletSelector.store.getState() + const accounts = walletState.accounts + this.accounts = accounts - // Set main account Id - this.accountId = accounts[0].accountId + // Set main account Id + this.accountId = accounts[0].accountId - // Others - this.recentlySignedInWallets = walletState.recentlySignedInWallets - this.selectedWalletId = walletState.selectedWalletId + // Others + this.recentlySignedInWallets = walletState.recentlySignedInWallets + this.selectedWalletId = walletState.selectedWalletId + } } /**