Skip to content

Commit

Permalink
Merge pull request #604 from tradingstrategy-ai/connect-wallet-bug
Browse files Browse the repository at this point in the history
Fix wallet connection bug
  • Loading branch information
kenkunz authored Oct 11, 2023
2 parents fc1f134 + 7fb03bb commit 81931c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/wallet/ConnectWallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
</div>
{:else}
<div class="wallet-options">
<WalletTile name="Browser Wallet" slug="browser-wallet" on:click={() => connectWallet('Injected')}>
<WalletTile name="Browser Wallet" slug="browser-wallet" on:click={() => connectWallet('injected')}>
Connect to your<br />
browser-based wallet
</WalletTile>
<WalletTile name="WalletConnect" slug="walletconnect" on:click={() => connectWallet('WalletConnect')}>
<WalletTile name="WalletConnect" slug="walletconnect" on:click={() => connectWallet('walletConnect')}>
Scan a QR code<br />
with your mobile wallet
</WalletTile>
Expand Down
10 changes: 4 additions & 6 deletions src/lib/wallet/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getRpcUrl({ id }: Chain) {
return http && { http };
}

export type ConnectorType = 'Injected' | 'WalletConnect';
export type ConnectorType = 'injected' | 'walletConnect';

type CommonWallet = {
name: string;
Expand Down Expand Up @@ -88,11 +88,9 @@ function initWalletClient(connectors: Connector[]) {
initialized = true;
}

function connectWallet(type: ConnectorType, chainId: MaybeNumber) {
return connect({
chainId,
connector: connectors.find((c) => c.constructor.name === `${type}Connector`)!
});
function connectWallet(type: ConnectorType, chainId: number | undefined) {
const connector = connectors.find((c) => c.id === type)!;
return connect({ chainId, connector });
}

export const wallet = { subscribe, connect: connectWallet, disconnect };

0 comments on commit 81931c3

Please sign in to comment.