Skip to content

Commit

Permalink
Merge pull request #916 from rainlanguage/2024-10-04-walletconnect-fix
Browse files Browse the repository at this point in the history
Add priority chain id list to wallet connect function
  • Loading branch information
thedavidmeister authored Oct 4, 2024
2 parents 279f252 + 90874f5 commit ef9deef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tauri-app/src/lib/components/InputWalletConnect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
walletconnectIsConnecting,
walletconnectIsDisconnecting,
} from '$lib/stores/walletconnect';
export let priorityChainIds: number[] = [];
</script>

<div>
Expand All @@ -26,7 +28,7 @@
size="lg"
pill
loading={$walletconnectIsDisconnecting || $walletconnectIsConnecting}
on:click={walletconnectConnect}
on:click={() => walletconnectConnect(priorityChainIds)}
>
{#if $walletconnectAccount}
<Hash type={HashType.Wallet} value={$walletconnectAccount} />
Expand Down
2 changes: 1 addition & 1 deletion tauri-app/src/lib/components/ModalExecute.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</ButtonLoading>
</div>
{:else if selectedWalletconnect || $walletconnectAccount}
<InputWalletConnect />
<InputWalletConnect priorityChainIds={chainId ? [chainId] : []} />
<div
class={!$walletconnectAccount
? 'flex items-center justify-between space-x-4'
Expand Down
4 changes: 2 additions & 2 deletions tauri-app/src/lib/stores/walletconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Provider.init({
reportErrorToSentry(e);
});

export async function walletconnectConnect() {
export async function walletconnectConnect(priorityChainIds: number[]) {
if (!walletconnectProvider?.accounts?.length) {
walletconnectIsConnecting.set(true);
const rpcMap: Record<string, string> = {};
Expand All @@ -78,7 +78,7 @@ export async function walletconnectConnect() {
}
try {
await walletconnectProvider?.connect({
optionalChains: chains,
optionalChains: [...new Set([...priorityChainIds, ...chains])],
rpcMap,
});
} catch (e) {
Expand Down

0 comments on commit ef9deef

Please sign in to comment.