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

Commit 5973cd1

Browse files
author
Carson Aberle
committed
Adjusted connection for falcon and coin98, added connect function to types
1 parent ede70d5 commit 5973cd1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/wallet/connection.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@ declare global {
66
keplr: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
77
leap: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
88
coin98: { cosmos: (chain) => Promise<any> };
9-
falcon: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
9+
falcon: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void; connect: (chainId) => void };
1010
}
1111
}
1212

1313
export const connect = async (inputWallet: WalletWindowKey, chainId?: string, restUrl?: string, rpcUrl?: string): Promise<WalletConnect | undefined> => {
14-
const windowKey = inputWallet === 'coin98' ? 'keplr' : inputWallet;
14+
try {
15+
const windowKey = inputWallet === 'coin98' ? 'keplr' : inputWallet;
1516

16-
await window[windowKey].experimentalSuggestChain(getChainSuggest(chainId, restUrl, rpcUrl));
17+
if (typeof window === 'undefined' || !window) return;
1718

18-
if (typeof window === 'undefined' || !window) return;
19+
if (inputWallet === 'keplr') {
20+
await window.keplr.experimentalSuggestChain(getChainSuggest(chainId, restUrl, rpcUrl));
21+
}
1922

20-
const offlineSigner = await window[windowKey].getOfflineSigner(chainId);
21-
const accounts = await offlineSigner.getAccounts();
23+
if (windowKey === 'falcon') {
24+
await window.falcon.connect('atlantic-1');
25+
}
2226

23-
return { offlineSigner, accounts };
27+
const offlineSigner = await window[windowKey].getOfflineSigner(chainId);
28+
const accounts = await offlineSigner.getAccounts();
29+
30+
return { offlineSigner, accounts };
31+
} catch (e) {
32+
console.log('err', e);
33+
}
2434
};

0 commit comments

Comments
 (0)