From 91ff05788ac7ff48decfcb276ec08c05fee018d3 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Thu, 4 Apr 2024 15:59:47 +0000 Subject: [PATCH 1/6] init --- .../src/lib/components/ModalExecute.svelte | 8 ++- tauri-app/src/lib/components/Sidebar.svelte | 60 +++++++++++++++++++ tauri-app/src/lib/stores/walletconnect.ts | 2 +- tauri-app/src/routes/settings/+page.svelte | 58 +----------------- 4 files changed, 68 insertions(+), 60 deletions(-) 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..fc6c7786c 100644 --- a/tauri-app/src/lib/components/Sidebar.svelte +++ b/tauri-app/src/lib/components/Sidebar.svelte @@ -14,12 +14,33 @@ import ButtonDarkMode from '$lib/components/ButtonDarkMode.svelte'; import DropdownActiveNetwork from '$lib/components/DropdownActiveNetwork.svelte'; import DropdownActiveOrderbook from '$lib/components/DropdownActiveOrderbook.svelte'; + import { Button, Modal } from 'flowbite-svelte'; + import InputLedgerWallet from '$lib/components/InputLedgerWallet.svelte'; + import { ledgerWalletDerivationIndex, ledgerWalletAddress } from '$lib/stores/wallets'; + import InputWalletConnect from '$lib/components/InputWalletConnect.svelte'; + import IconLedger from '$lib/components/IconLedger.svelte'; + import IconWalletConnect from '$lib/components/IconWalletConnect.svelte'; + import { walletconnectAccount } from '$lib/stores/walletconnect'; export let hasRequiredSettings = false; $: nonActiveClass = !hasRequiredSettings ? 'flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white/25 ' : 'flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-200 dark:hover:bg-gray-600'; + + let open = false; + let selectedLedger = false; + let selectedWalletconnect = false; + + $: walletconnectLabel = $walletconnectAccount + ? `${$walletconnectAccount.slice(0, 5)}...${$walletconnectAccount.slice(-5)}` + : "Connect to Wallet" + + function reset() { + open = false; + selectedLedger = false; + selectedWalletconnect = false; + } @@ -50,6 +71,11 @@ >
+ +
+ +
+
+ + + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount} +
+ + +
+ {:else if selectedLedger} + +
+ +
+ {:else if selectedWalletconnect || $walletconnectAccount} + + {#if !$walletconnectAccount} +
+ +
+ {/if} + {/if} +
\ No newline at end of file diff --git a/tauri-app/src/lib/stores/walletconnect.ts b/tauri-app/src/lib/stores/walletconnect.ts index 9774a2d6e..f2d66f32c 100644 --- a/tauri-app/src/lib/stores/walletconnect.ts +++ b/tauri-app/src/lib/stores/walletconnect.ts @@ -90,7 +90,6 @@ export async function walletconnectConnect() { } export async function walletconnectDisconnect() { - walletconnectAccount.set(undefined); walletconnectIsDisconnecting.set(true); try { await walletconnectProvider?.disconnect(); @@ -98,6 +97,7 @@ export async function walletconnectDisconnect() { reportErrorToSentry(e); } walletconnectIsDisconnecting.set(false); + walletconnectAccount.set(undefined); } // subscribe to networks and disconnect on network changes 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 From eb60708a69cad596c5082940a05e5bdd03b0fae8 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Thu, 4 Apr 2024 16:11:59 +0000 Subject: [PATCH 2/6] update --- .../src/lib/components/ModalConnect.svelte | 53 +++++++++++++++++++ tauri-app/src/lib/components/Sidebar.svelte | 50 ++--------------- 2 files changed, 56 insertions(+), 47 deletions(-) create mode 100644 tauri-app/src/lib/components/ModalConnect.svelte diff --git a/tauri-app/src/lib/components/ModalConnect.svelte b/tauri-app/src/lib/components/ModalConnect.svelte new file mode 100644 index 000000000..9ffdb247e --- /dev/null +++ b/tauri-app/src/lib/components/ModalConnect.svelte @@ -0,0 +1,53 @@ + + + + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount} +
+ + +
+ {:else if selectedLedger} + +
+ +
+ {:else if selectedWalletconnect || $walletconnectAccount} + + {#if !$walletconnectAccount} +
+ +
+ {/if} + {/if} +
\ No newline at end of file diff --git a/tauri-app/src/lib/components/Sidebar.svelte b/tauri-app/src/lib/components/Sidebar.svelte index fc6c7786c..6d03d52c5 100644 --- a/tauri-app/src/lib/components/Sidebar.svelte +++ b/tauri-app/src/lib/components/Sidebar.svelte @@ -14,13 +14,9 @@ import ButtonDarkMode from '$lib/components/ButtonDarkMode.svelte'; import DropdownActiveNetwork from '$lib/components/DropdownActiveNetwork.svelte'; import DropdownActiveOrderbook from '$lib/components/DropdownActiveOrderbook.svelte'; - import { Button, Modal } from 'flowbite-svelte'; - import InputLedgerWallet from '$lib/components/InputLedgerWallet.svelte'; - import { ledgerWalletDerivationIndex, ledgerWalletAddress } from '$lib/stores/wallets'; - import InputWalletConnect from '$lib/components/InputWalletConnect.svelte'; - import IconLedger from '$lib/components/IconLedger.svelte'; - import IconWalletConnect from '$lib/components/IconWalletConnect.svelte'; + import { Button } from 'flowbite-svelte'; import { walletconnectAccount } from '$lib/stores/walletconnect'; + import ModalConnect from '$lib/components/ModalConnect.svelte'; export let hasRequiredSettings = false; @@ -29,18 +25,10 @@ : 'flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-200 dark:hover:bg-gray-600'; let open = false; - let selectedLedger = false; - let selectedWalletconnect = false; $: walletconnectLabel = $walletconnectAccount ? `${$walletconnectAccount.slice(0, 5)}...${$walletconnectAccount.slice(-5)}` : "Connect to Wallet" - - function reset() { - open = false; - selectedLedger = false; - selectedWalletconnect = false; - } @@ -122,36 +110,4 @@ - - {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount} -
- - -
- {:else if selectedLedger} - -
- -
- {:else if selectedWalletconnect || $walletconnectAccount} - - {#if !$walletconnectAccount} -
- -
- {/if} - {/if} -
\ No newline at end of file + \ No newline at end of file From e9393fdad523ca4b8e7b65e908d524ca5fffbb34 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Thu, 4 Apr 2024 16:50:39 +0000 Subject: [PATCH 3/6] update --- tauri-app/src/lib/components/ModalConnect.svelte | 10 +++++++++- tauri-app/src/lib/components/Sidebar.svelte | 16 ++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/tauri-app/src/lib/components/ModalConnect.svelte b/tauri-app/src/lib/components/ModalConnect.svelte index 9ffdb247e..4b0045b5f 100644 --- a/tauri-app/src/lib/components/ModalConnect.svelte +++ b/tauri-app/src/lib/components/ModalConnect.svelte @@ -7,10 +7,14 @@ import IconWalletConnect from '$lib/components/IconWalletConnect.svelte'; import { walletconnectAccount } from '$lib/stores/walletconnect'; - export let open = false; + let open = false; let selectedLedger = false; let selectedWalletconnect = false; + $: walletconnectLabel = $walletconnectAccount + ? `${$walletconnectAccount.slice(0, 5)}...${$walletconnectAccount.slice(-5)}` + : "Connect to Wallet" + function reset() { open = false; selectedLedger = false; @@ -18,6 +22,10 @@ } +
+ +
+ {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount}
diff --git a/tauri-app/src/lib/components/Sidebar.svelte b/tauri-app/src/lib/components/Sidebar.svelte index 6d03d52c5..9eb6d5f79 100644 --- a/tauri-app/src/lib/components/Sidebar.svelte +++ b/tauri-app/src/lib/components/Sidebar.svelte @@ -14,8 +14,6 @@ import ButtonDarkMode from '$lib/components/ButtonDarkMode.svelte'; import DropdownActiveNetwork from '$lib/components/DropdownActiveNetwork.svelte'; import DropdownActiveOrderbook from '$lib/components/DropdownActiveOrderbook.svelte'; - import { Button } from 'flowbite-svelte'; - import { walletconnectAccount } from '$lib/stores/walletconnect'; import ModalConnect from '$lib/components/ModalConnect.svelte'; export let hasRequiredSettings = false; @@ -23,12 +21,6 @@ $: nonActiveClass = !hasRequiredSettings ? 'flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white/25 ' : 'flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-200 dark:hover:bg-gray-600'; - - let open = false; - - $: walletconnectLabel = $walletconnectAccount - ? `${$walletconnectAccount.slice(0, 5)}...${$walletconnectAccount.slice(-5)}` - : "Connect to Wallet" @@ -60,9 +52,7 @@
-
- -
+
- - - \ No newline at end of file + \ No newline at end of file From 603f4d5f3adf8024f1d9bd4ba274be85aceeb932 Mon Sep 17 00:00:00 2001 From: highonhopium Date: Thu, 4 Apr 2024 19:25:33 +0100 Subject: [PATCH 4/6] tweaks --- .../lib/components/InputWalletConnect.svelte | 26 ++++++++++--------- tauri-app/src/lib/components/Sidebar.svelte | 8 +++--- tauri-app/src/lib/stores/walletconnect.ts | 24 +++++++---------- 3 files changed, 28 insertions(+), 30 deletions(-) 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/Sidebar.svelte b/tauri-app/src/lib/components/Sidebar.svelte index 9eb6d5f79..834f621a1 100644 --- a/tauri-app/src/lib/components/Sidebar.svelte +++ b/tauri-app/src/lib/components/Sidebar.svelte @@ -51,9 +51,6 @@ > - - - + + + @@ -98,4 +98,4 @@ - \ No newline at end of file + diff --git a/tauri-app/src/lib/stores/walletconnect.ts b/tauri-app/src/lib/stores/walletconnect.ts index f2d66f32c..2ad10ded9 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("Cuuld 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") @@ -93,7 +89,7 @@ export async function walletconnectDisconnect() { walletconnectIsDisconnecting.set(true); try { await walletconnectProvider?.disconnect(); - } catch(e) { + } catch (e) { reportErrorToSentry(e); } walletconnectIsDisconnecting.set(false); @@ -104,4 +100,4 @@ export async function walletconnectDisconnect() { 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 From a1651c5fcfb7ab4517ee13448f60ffaa30ddff5a Mon Sep 17 00:00:00 2001 From: highonhopium Date: Thu, 4 Apr 2024 20:03:01 +0100 Subject: [PATCH 5/6] connect button colour --- .../src/lib/components/ModalConnect.svelte | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tauri-app/src/lib/components/ModalConnect.svelte b/tauri-app/src/lib/components/ModalConnect.svelte index 4b0045b5f..846814d2e 100644 --- a/tauri-app/src/lib/components/ModalConnect.svelte +++ b/tauri-app/src/lib/components/ModalConnect.svelte @@ -13,7 +13,7 @@ $: walletconnectLabel = $walletconnectAccount ? `${$walletconnectAccount.slice(0, 5)}...${$walletconnectAccount.slice(-5)}` - : "Connect to Wallet" + : 'Connect to Wallet'; function reset() { open = false; @@ -22,20 +22,20 @@ } -
- +
+
- + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount}
- - +
{:else if selectedWalletconnect || $walletconnectAccount} {#if !$walletconnectAccount}
- +
{/if} {/if} -
\ No newline at end of file +
From 4c673b6d39081853741f188ededf6657d6d668bb Mon Sep 17 00:00:00 2001 From: David Meister Date: Fri, 5 Apr 2024 09:44:32 +0400 Subject: [PATCH 6/6] Update tauri-app/src/lib/stores/walletconnect.ts --- tauri-app/src/lib/stores/walletconnect.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tauri-app/src/lib/stores/walletconnect.ts b/tauri-app/src/lib/stores/walletconnect.ts index 2ad10ded9..380696a58 100644 --- a/tauri-app/src/lib/stores/walletconnect.ts +++ b/tauri-app/src/lib/stores/walletconnect.ts @@ -57,7 +57,7 @@ Provider.init( await walletconnectDisconnect(); } }).catch(e => { - toasts.error("Cuuld not instantiate Walletconnect modal") + toasts.error("Could not instantiate Walletconnect modal") reportErrorToSentry(e); });