Skip to content

Commit

Permalink
fix: Update useWallet logic to resolve type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolian committed Jan 27, 2025
1 parent 971c17c commit 8f76ad3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apps/rosen/app/_hooks/useWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,21 @@ export const WalletProvider = ({ children }: PropsWithChildren) => {
if (!selectedSource) return;

const name = localStorage.getItem('rosen:wallet:' + selectedSource.name);

if (!name) return;

const wallet = availableWallets[name as keyof typeof availableWallets];
const wallet = availableWallets[
name as keyof typeof availableWallets
] as Wallet;

if (!wallet || !wallet.isAvailable()) return;

if (Object.hasOwn(wallet, 'isConnected') && !(await wallet.isConnected())) return;
if ((await wallet.isConnected?.()) === false) return;

try {
await wallet.connect();

if (Object.hasOwn(wallet, 'switchChain')) {
await wallet.switchChain(selectedSource.name, true);
}
await wallet.switchChain?.(selectedSource.name, true);

setSelected(wallet);
} catch (error) {
Expand Down

0 comments on commit 8f76ad3

Please sign in to comment.