diff --git a/tauri-app/src/lib/components/InputWalletConnect.svelte b/tauri-app/src/lib/components/InputWalletConnect.svelte index c0badc30e..45087e944 100644 --- a/tauri-app/src/lib/components/InputWalletConnect.svelte +++ b/tauri-app/src/lib/components/InputWalletConnect.svelte @@ -1,12 +1,17 @@
@@ -15,16 +20,13 @@ Only mobile wallets are supported in WalletConnect. -
+
- {walletconnectLabel} + {walletconnectLabel}
-
\ No newline at end of file +
diff --git a/tauri-app/src/lib/components/ModalConnect.svelte b/tauri-app/src/lib/components/ModalConnect.svelte new file mode 100644 index 000000000..846814d2e --- /dev/null +++ b/tauri-app/src/lib/components/ModalConnect.svelte @@ -0,0 +1,61 @@ + + +
+ +
+ + + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount} +
+ + +
+ {:else if selectedLedger} + +
+ +
+ {:else if selectedWalletconnect || $walletconnectAccount} + + {#if !$walletconnectAccount} +
+ +
+ {/if} + {/if} +
diff --git a/tauri-app/src/lib/components/ModalExecute.svelte b/tauri-app/src/lib/components/ModalExecute.svelte index 4708640ec..4ddb7906d 100644 --- a/tauri-app/src/lib/components/ModalExecute.svelte +++ b/tauri-app/src/lib/components/ModalExecute.svelte @@ -30,7 +30,7 @@ - {#if !selectedLedger && !selectedWalletconnect} + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount}
+ {#if !$walletconnectAccount} + + {/if} executeWalletconnect().finally(() => reset())} disabled={isSubmitting || !$walletconnectAccount} loading={isSubmitting}> {execButtonLabel} diff --git a/tauri-app/src/lib/components/Sidebar.svelte b/tauri-app/src/lib/components/Sidebar.svelte index 1e304519d..834f621a1 100644 --- a/tauri-app/src/lib/components/Sidebar.svelte +++ b/tauri-app/src/lib/components/Sidebar.svelte @@ -14,6 +14,7 @@ import ButtonDarkMode from '$lib/components/ButtonDarkMode.svelte'; import DropdownActiveNetwork from '$lib/components/DropdownActiveNetwork.svelte'; import DropdownActiveOrderbook from '$lib/components/DropdownActiveOrderbook.svelte'; + import ModalConnect from '$lib/components/ModalConnect.svelte'; export let hasRequiredSettings = false; @@ -76,6 +77,9 @@ + + + diff --git a/tauri-app/src/lib/stores/walletconnect.ts b/tauri-app/src/lib/stores/walletconnect.ts index 9774a2d6e..380696a58 100644 --- a/tauri-app/src/lib/stores/walletconnect.ts +++ b/tauri-app/src/lib/stores/walletconnect.ts @@ -34,7 +34,10 @@ Provider.init( "disconnect", ], showQrModal: true, - qrModalOptions: { themeMode: get(colorTheme) }, + qrModalOptions: { + themeMode: get(colorTheme), + enableExplorer: false + }, } ).then(async provider => { provider.on("connect", () => { @@ -46,14 +49,7 @@ Provider.init( provider.on("accountsChanged", (accounts) => { walletconnectAccount.set(accounts?.[0] ?? undefined); }); - provider.on("chainChanged", async (chainid) => { - // disconnect if networks from ui and wallet dont match - const network = get(activeNetwork); - if (!network || network['chain-id'] !== Number(chainid)) { - toasts.error("Please choose the same chain in your wallet") - await walletconnectDisconnect(); - } - }); + walletconnectProvider = provider; // disconnect if last session is still active @@ -61,7 +57,7 @@ Provider.init( await walletconnectDisconnect(); } }).catch(e => { - toasts.error("could not instantiate walletconnect service") + toasts.error("Could not instantiate Walletconnect modal") reportErrorToSentry(e); }); @@ -72,7 +68,7 @@ export async function walletconnectConnect() { walletconnectIsConnecting.set(true); const network = get(activeNetwork); if (network) { - const rpcMap: Record = {}; + const rpcMap: Record = {}; rpcMap[network['chain-id']] = network.rpc; try { await walletconnectProvider?.connect({ @@ -80,7 +76,7 @@ export async function walletconnectConnect() { rpcMap }) } catch { - toasts.error("canceled by user!") + toasts.error("Connection cancelled by user") } } else { toasts.error("Cannot find active network") @@ -90,18 +86,18 @@ export async function walletconnectConnect() { } export async function walletconnectDisconnect() { - walletconnectAccount.set(undefined); walletconnectIsDisconnecting.set(true); try { await walletconnectProvider?.disconnect(); - } catch(e) { + } catch (e) { reportErrorToSentry(e); } walletconnectIsDisconnecting.set(false); + walletconnectAccount.set(undefined); } // subscribe to networks and disconnect on network changes activeNetwork.subscribe(async () => await walletconnectDisconnect()); // set theme when changed by user -colorTheme.subscribe(v => (walletconnectProvider?.modal as WalletConnectModal)?.setTheme({themeMode: v})) \ No newline at end of file +colorTheme.subscribe(v => (walletconnectProvider?.modal as WalletConnectModal)?.setTheme({ themeMode: v })) \ No newline at end of file diff --git a/tauri-app/src/routes/settings/+page.svelte b/tauri-app/src/routes/settings/+page.svelte index 647b2ef5b..750841563 100644 --- a/tauri-app/src/routes/settings/+page.svelte +++ b/tauri-app/src/routes/settings/+page.svelte @@ -1,31 +1,15 @@ @@ -57,42 +41,4 @@ - - -
- -
- - - {#if !selectedLedger && !selectedWalletconnect} -
- - -
- {:else if selectedLedger} - - -
- -
- {:else if selectedWalletconnect} - - -
- -
- {/if} -
\ No newline at end of file + \ No newline at end of file