Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Enable wallet before suggesting chain
Browse files Browse the repository at this point in the history
  • Loading branch information
besated committed Nov 28, 2022
1 parent de2b10c commit 551fbdc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/wallet/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { WalletConnect, WalletWindowKey } from './types';

declare global {
interface Window {
keplr: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
leap: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
keplr: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void; enable: (chainId) => void };
leap: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void; enable: (chainId) => void };
coin98: { cosmos: (chain) => Promise<any> };
falcon: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void; connect: (chainId) => void };
falcon: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void; enable: (chainId) => void };
}
}

Expand All @@ -16,14 +16,13 @@ export const connect = async (inputWallet: WalletWindowKey, chainId?: string, re

if (typeof window === 'undefined' || !window) return;

// Enable wallet before attempting to call any methods
await window[windowKey].enable(chainId);

if (inputWallet === 'keplr') {
await window.keplr.experimentalSuggestChain(getChainSuggest(chainId, restUrl, rpcUrl));
}

if (windowKey === 'falcon') {
await window.falcon.connect('atlantic-1');
}

const offlineSigner = await window[windowKey].getOfflineSigner(chainId);
const accounts = await offlineSigner.getAccounts();

Expand Down

0 comments on commit 551fbdc

Please sign in to comment.