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

Commit

Permalink
Adjusted connection for falcon and coin98, added connect function to …
Browse files Browse the repository at this point in the history
…types
  • Loading branch information
Carson Aberle committed Nov 21, 2022
1 parent ede70d5 commit 5973cd1
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/wallet/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@ declare global {
keplr: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
leap: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
coin98: { cosmos: (chain) => Promise<any> };
falcon: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void };
falcon: { getOfflineSigner: (string) => Promise<any>; experimentalSuggestChain: (object) => void; connect: (chainId) => void };
}
}

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

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

if (typeof window === 'undefined' || !window) return;
if (inputWallet === 'keplr') {
await window.keplr.experimentalSuggestChain(getChainSuggest(chainId, restUrl, rpcUrl));
}

const offlineSigner = await window[windowKey].getOfflineSigner(chainId);
const accounts = await offlineSigner.getAccounts();
if (windowKey === 'falcon') {
await window.falcon.connect('atlantic-1');
}

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

return { offlineSigner, accounts };
} catch (e) {
console.log('err', e);
}
};

0 comments on commit 5973cd1

Please sign in to comment.