Skip to content

Commit

Permalink
Fixed issue with wallet button menu showing and check if the offline …
Browse files Browse the repository at this point in the history
…signer returned exists to show an error
  • Loading branch information
Carson Aberle committed Jun 30, 2023
1 parent c73f9cf commit 05a1f56
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-jobs-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sei-js/react': patch
---

Fixed an issue when wallets don't connect and the UI hangs, fixed an issue where the WalletConnectButton menu shows after selecting a wallet
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const WalletSelectModal = ({ wallets: inputWallets }: WalletSelectModalProps) =>
}
}, [connectedWallet, connectionError]);

const closeModal = () => {
const closeModal = (e) => {
e.stopPropagation();
setConnectionError(undefined);
setShowConnectModal(false);
};
Expand Down
13 changes: 10 additions & 3 deletions packages/react/src/lib/provider/SeiWalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,25 @@ const SeiWalletProvider = ({ children, chainConfiguration, wallets, autoConnect
return;
}

await targetWallet.connect(chainConfiguration.chainId);
const fetchedOfflineSigner = await targetWallet.getOfflineSigner(chainConfiguration.chainId);

if (!fetchedOfflineSigner) {
setConnectionError(targetWallet.walletInfo.windowKey);
return;
}
const fetchedAccounts = await targetWallet.getAccounts(chainConfiguration.chainId);

if (fetchedAccounts.length > 0 && fetchedOfflineSigner) {
if (fetchedAccounts.length === 0) {
setConnectionError(targetWallet.walletInfo.windowKey);
return;
} else {
setShowConnectModal(false);
setOfflineSigner(fetchedOfflineSigner);
setAccounts(fetchedAccounts);
setConnectedWallet(targetWallet);
}
} catch (e) {
console.log('Error connecting to wallet', e);
console.error('Error connecting to wallet', e);
setConnectionError(targetWallet.walletInfo.windowKey);
return;
}
Expand Down

0 comments on commit 05a1f56

Please sign in to comment.