From 3f581e17d29337a8d31c69db047a4e1435d1585f Mon Sep 17 00:00:00 2001 From: highonhopium Date: Thu, 4 Apr 2024 20:32:49 +0100 Subject: [PATCH 1/4] telegram in sidebar --- tauri-app/src/lib/components/IconTelegram.svelte | 12 ++++++++++++ tauri-app/src/lib/components/Sidebar.svelte | 7 +++++++ 2 files changed, 19 insertions(+) create mode 100644 tauri-app/src/lib/components/IconTelegram.svelte diff --git a/tauri-app/src/lib/components/IconTelegram.svelte b/tauri-app/src/lib/components/IconTelegram.svelte new file mode 100644 index 000000000..84f346783 --- /dev/null +++ b/tauri-app/src/lib/components/IconTelegram.svelte @@ -0,0 +1,12 @@ + diff --git a/tauri-app/src/lib/components/Sidebar.svelte b/tauri-app/src/lib/components/Sidebar.svelte index 1e304519d..37d796e3f 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 IconTelegram from '$lib/components/IconTelegram.svelte'; export let hasRequiredSettings = false; @@ -89,6 +90,12 @@ + + + + + + From 6b4adcfedb51ccd359e0901d7ddb398334d08ca7 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Thu, 4 Apr 2024 23:02:01 +0000 Subject: [PATCH 2/4] init --- .../lib/components/InputLedgerWallet.svelte | 103 ++++++++++-------- .../lib/components/InputWalletConnect.svelte | 30 +++-- .../src/lib/components/ModalConnect.svelte | 19 ++-- .../src/lib/components/ModalExecute.svelte | 16 +-- tauri-app/src/lib/stores/wallets.ts | 14 +-- 5 files changed, 97 insertions(+), 85 deletions(-) diff --git a/tauri-app/src/lib/components/InputLedgerWallet.svelte b/tauri-app/src/lib/components/InputLedgerWallet.svelte index a6acc711f..e6b5062cc 100644 --- a/tauri-app/src/lib/components/InputLedgerWallet.svelte +++ b/tauri-app/src/lib/components/InputLedgerWallet.svelte @@ -1,12 +1,15 @@ @@ -52,45 +61,43 @@ -
-
-
- + + {#if $ledgerWalletAddress} + + {:else} + CONNECT + {/if} + + {#if $ledgerWalletAddress} + + DISCONNECT + + {:else} +
+ -
- -
+ Derivation Index
- {#if !isWalletAddressValid && walletAddress.length > 0} - Invalid Address - {/if} - The address of your Ledger wallet. -
-
- - Derivation Index -
+ {/if}
\ No newline at end of file diff --git a/tauri-app/src/lib/components/InputWalletConnect.svelte b/tauri-app/src/lib/components/InputWalletConnect.svelte index c0badc30e..96b402f49 100644 --- a/tauri-app/src/lib/components/InputWalletConnect.svelte +++ b/tauri-app/src/lib/components/InputWalletConnect.svelte @@ -2,11 +2,9 @@ import IconWarning from "$lib/components/IconWarning.svelte"; import { Alert } from "flowbite-svelte"; import ButtonLoading from "./ButtonLoading.svelte"; - import { walletconnectConnect, walletconnectIsDisconnecting, walletconnectAccount, walletconnectIsConnecting } from '$lib/stores/walletconnect'; - - $: walletconnectLabel = $walletconnectAccount - ? `${$walletconnectAccount.slice(0, 5)}...${$walletconnectAccount.slice(-5)} (click to disconnect)` - : "CONNECT" + import { walletconnectConnect, walletconnectIsDisconnecting, walletconnectAccount, walletconnectIsConnecting, walletconnectDisconnect } from '$lib/stores/walletconnect'; + import Hash from '$lib/components/Hash.svelte'; + import { HashType } from '$lib/types/hash';
@@ -15,16 +13,32 @@ Only mobile wallets are supported in WalletConnect. -
+
- {walletconnectLabel} + {#if $walletconnectAccount} + + {:else} + CONNECT + {/if} + {#if $walletconnectAccount} + + DISCONNECT + + {/if}
\ No newline at end of file diff --git a/tauri-app/src/lib/components/ModalConnect.svelte b/tauri-app/src/lib/components/ModalConnect.svelte index 4b0045b5f..dd324a25b 100644 --- a/tauri-app/src/lib/components/ModalConnect.svelte +++ b/tauri-app/src/lib/components/ModalConnect.svelte @@ -1,7 +1,7 @@
- +
- {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount} + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount && !$ledgerWalletAddress}
- {:else if selectedLedger} - + {:else if selectedLedger || $ledgerWalletAddress} +
diff --git a/tauri-app/src/lib/components/ModalExecute.svelte b/tauri-app/src/lib/components/ModalExecute.svelte index 4ddb7906d..343380c27 100644 --- a/tauri-app/src/lib/components/ModalExecute.svelte +++ b/tauri-app/src/lib/components/ModalExecute.svelte @@ -1,11 +1,10 @@ - {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount} + {#if !selectedLedger && !selectedWalletconnect && !$walletconnectAccount && !$ledgerWalletAddress}
{/if}
- {:else if selectedLedger} - - + {:else if selectedLedger || $ledgerWalletAddress} +
- executeLedger().finally(() => reset())} disabled={isSubmitting || !$ledgerWalletAddress || isNil($ledgerWalletDerivationIndex) || isNil($ledgerWalletDerivationIndex)} loading={isSubmitting}> + executeLedger().finally(() => reset())} disabled={isSubmitting || !$ledgerWalletAddress} loading={isSubmitting}> {execButtonLabel}
{:else if selectedWalletconnect || $walletconnectAccount} -
{#if !$walletconnectAccount} diff --git a/tauri-app/src/lib/stores/wallets.ts b/tauri-app/src/lib/stores/wallets.ts index bf370dd17..fbb75bf4c 100644 --- a/tauri-app/src/lib/stores/wallets.ts +++ b/tauri-app/src/lib/stores/wallets.ts @@ -1,19 +1,17 @@ -import { cachedWritableInt } from "$lib/storesGeneric/cachedWritableStore"; -import { validatedStringStore } from "$lib/storesGeneric/settingStore"; import { derived } from "svelte/store"; -import { isAddress } from "viem"; import { walletconnectAccount } from "$lib/stores/walletconnect" +import { writable } from "@square/svelte-store"; + +export const ledgerWalletAddress = writable(undefined); +export const ledgerWalletDerivationIndex = writable(0); -export const ledgerWalletAddress = validatedStringStore("settings.walletAddress", "", isAddress); -export const ledgerWalletDerivationIndex = cachedWritableInt("settings.walletDerivationIndex", 0); export const walletAddressMatchesOrBlank = derived( [ledgerWalletAddress, walletconnectAccount], - ([$walletAddress, $walletconnectAccount]) => { + ([$ledgerWalletAddress, $walletconnectAccount]) => { return (otherAddress: string) => { const otherAddressLowercase = otherAddress.toLowerCase(); - return $walletAddress.value.toLowerCase() === otherAddressLowercase + return $ledgerWalletAddress?.toLowerCase() === otherAddressLowercase || $walletconnectAccount?.toLowerCase() === otherAddressLowercase - || $walletAddress.value === ""; } } ); From 8c3c6e54f6beb1057abdc1738241545e3e04ff66 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Thu, 4 Apr 2024 23:20:38 +0000 Subject: [PATCH 3/4] update --- .../lib/components/InputLedgerWallet.svelte | 22 ++++++++++--------- .../lib/components/InputWalletConnect.svelte | 10 +++++++-- .../src/lib/components/ModalConnect.svelte | 2 +- tauri-app/src/lib/stores/walletconnect.ts | 4 +--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tauri-app/src/lib/components/InputLedgerWallet.svelte b/tauri-app/src/lib/components/InputLedgerWallet.svelte index e6b5062cc..c4e3b9b96 100644 --- a/tauri-app/src/lib/components/InputLedgerWallet.svelte +++ b/tauri-app/src/lib/components/InputLedgerWallet.svelte @@ -29,16 +29,18 @@ ledgerWalletDerivationIndex.set(derivationIndex); } - async function getAddress() { - isConnecting = true; - try { - const res: string = await getAddressFromLedger(derivationIndex); - ledgerWalletAddress.set(res) - } catch (e) { - reportErrorToSentry(e); - toasts.error(`Ledger error: ${e as string}`); + async function ledgerConnect() { + if (!$ledgerWalletAddress) { + isConnecting = true; + try { + const res: string = await getAddressFromLedger(derivationIndex); + ledgerWalletAddress.set(res) + } catch (e) { + reportErrorToSentry(e); + toasts.error(`Ledger error: ${e as string}`); + } + isConnecting = false; } - isConnecting = false; } function ledgerDisconnect() { @@ -68,7 +70,7 @@ size="lg" pill loading={isConnecting} - on:click={getAddress} + on:click={ledgerConnect} > {#if $ledgerWalletAddress} diff --git a/tauri-app/src/lib/components/InputWalletConnect.svelte b/tauri-app/src/lib/components/InputWalletConnect.svelte index 96b402f49..70a04fdc2 100644 --- a/tauri-app/src/lib/components/InputWalletConnect.svelte +++ b/tauri-app/src/lib/components/InputWalletConnect.svelte @@ -2,9 +2,15 @@ import IconWarning from "$lib/components/IconWarning.svelte"; import { Alert } from "flowbite-svelte"; import ButtonLoading from "./ButtonLoading.svelte"; - import { walletconnectConnect, walletconnectIsDisconnecting, walletconnectAccount, walletconnectIsConnecting, walletconnectDisconnect } from '$lib/stores/walletconnect'; import Hash from '$lib/components/Hash.svelte'; import { HashType } from '$lib/types/hash'; + import { + walletconnectConnect, + walletconnectAccount, + walletconnectDisconnect, + walletconnectIsConnecting, + walletconnectIsDisconnecting, + } from '$lib/stores/walletconnect';
@@ -31,7 +37,7 @@ {#if $walletconnectAccount}
- +
diff --git a/tauri-app/src/lib/stores/walletconnect.ts b/tauri-app/src/lib/stores/walletconnect.ts index f2d66f32c..39d953c73 100644 --- a/tauri-app/src/lib/stores/walletconnect.ts +++ b/tauri-app/src/lib/stores/walletconnect.ts @@ -66,9 +66,7 @@ Provider.init( }); export async function walletconnectConnect() { - if (walletconnectProvider?.accounts?.length) { - await walletconnectDisconnect(); - } else { + if (!walletconnectProvider?.accounts?.length) { walletconnectIsConnecting.set(true); const network = get(activeNetwork); if (network) { From 5d670b85b423dc16cdbcd5487a1465cf51ebcd45 Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Fri, 5 Apr 2024 00:50:49 +0000 Subject: [PATCH 4/4] fix top connect modal z index --- tauri-app/src/lib/components/Hash.svelte | 2 +- tauri-app/src/lib/components/InputLedgerWallet.svelte | 8 ++++---- tauri-app/src/lib/components/ModalConnect.svelte | 4 ++-- tauri-app/src/lib/components/ModalExecute.svelte | 4 ++-- tauri-app/src/lib/components/Sidebar.svelte | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tauri-app/src/lib/components/Hash.svelte b/tauri-app/src/lib/components/Hash.svelte index 9d35ff0a8..d5a8bbce6 100644 --- a/tauri-app/src/lib/components/Hash.svelte +++ b/tauri-app/src/lib/components/Hash.svelte @@ -34,7 +34,7 @@ {#if shorten} - +
{#if type === HashType.Wallet } diff --git a/tauri-app/src/lib/components/InputLedgerWallet.svelte b/tauri-app/src/lib/components/InputLedgerWallet.svelte index c4e3b9b96..5f09f31ee 100644 --- a/tauri-app/src/lib/components/InputLedgerWallet.svelte +++ b/tauri-app/src/lib/components/InputLedgerWallet.svelte @@ -65,7 +65,7 @@
{:else} - CONNECT + Connect {/if} {#if $ledgerWalletAddress} @@ -87,13 +87,13 @@ loading={isDisconnecting} on:click={ledgerDisconnect} > - DISCONNECT + Disconnect {:else}
{:else if selectedLedger || $ledgerWalletAddress} -
+
{:else if selectedWalletconnect || $walletconnectAccount} {#if !$walletconnectAccount} -
+
{/if} diff --git a/tauri-app/src/lib/components/ModalExecute.svelte b/tauri-app/src/lib/components/ModalExecute.svelte index 343380c27..5f5ff5d20 100644 --- a/tauri-app/src/lib/components/ModalExecute.svelte +++ b/tauri-app/src/lib/components/ModalExecute.svelte @@ -52,7 +52,7 @@
{:else if selectedLedger || $ledgerWalletAddress} -
+
executeLedger().finally(() => reset())} disabled={isSubmitting || !$ledgerWalletAddress} loading={isSubmitting}> {execButtonLabel} @@ -60,7 +60,7 @@
{:else if selectedWalletconnect || $walletconnectAccount} -
+
{#if !$walletconnectAccount} {/if} diff --git a/tauri-app/src/lib/components/Sidebar.svelte b/tauri-app/src/lib/components/Sidebar.svelte index 834f621a1..c5c8fc7eb 100644 --- a/tauri-app/src/lib/components/Sidebar.svelte +++ b/tauri-app/src/lib/components/Sidebar.svelte @@ -23,7 +23,7 @@ : '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'; - +
@@ -94,7 +94,7 @@ - +