From 9ac568131463aa2bbffe471b5892e8288349728d Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Sat, 27 Apr 2024 11:01:16 +0200 Subject: [PATCH] enhancement: persist verification state for dapp (#2357) * create persisted dapps store * add verified icon to dapp list * add migrations * add verification icon to edit + details drawer * add comment + fix profile version * PR fixes * update migrations --------- Co-authored-by: Tuditi <45079109+Tuditi@users.noreply.github.com> --- .../dapp-config/components/DappCard.svelte | 28 +++-- .../components/EditSelectionDrawer.svelte | 16 +-- .../views/ConnectedDappsDrawer.svelte | 4 +- .../views/DappDetailsDrawer.svelte | 12 +-- .../wallet-connect/actions/connectToDapp.ts | 11 +- .../actions/removeAllDisconnectedDapps.ts | 11 +- .../wallet-connect/actions/removeDapp.ts | 4 +- .../handlers/onSessionRequest.handler.ts | 5 +- .../auxiliary/wallet-connect/stores/index.ts | 1 + .../stores/persisted-dapp-namespaces.store.ts | 60 +---------- .../stores/persisted-dapps.store.ts | 101 ++++++++++++++++++ .../constants/profile-version.constant.ts | 4 +- .../alpha/alpha-profile-migration-15-to-16.ts | 20 ++++ .../alpha/alpha-profile-migration-map.ts | 2 + .../prod/prod-profile-migration-8-to-9.ts | 20 ++++ .../prod/prod-profile-migration-map.ts | 2 + 16 files changed, 202 insertions(+), 99 deletions(-) create mode 100644 packages/shared/src/lib/auxiliary/wallet-connect/stores/persisted-dapps.store.ts create mode 100644 packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-15-to-16.ts create mode 100644 packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-8-to-9.ts diff --git a/packages/desktop/views/dashboard/drawers/dapp-config/components/DappCard.svelte b/packages/desktop/views/dashboard/drawers/dapp-config/components/DappCard.svelte index f08022df16..0ecea8e1ae 100644 --- a/packages/desktop/views/dashboard/drawers/dapp-config/components/DappCard.svelte +++ b/packages/desktop/views/dashboard/drawers/dapp-config/components/DappCard.svelte @@ -1,18 +1,23 @@ {/if}
- + {dapp.metadata?.name ?? localize('general.unknown')} - {#if dapp.metadata?.url} - - {dapp.metadata?.url} - - {/if} +
+ {#if verifiedState} + + {/if} + {#if dapp.metadata?.url} + + {dapp.metadata?.url} + + {/if} +
diff --git a/packages/desktop/views/dashboard/drawers/dapp-config/components/EditSelectionDrawer.svelte b/packages/desktop/views/dashboard/drawers/dapp-config/components/EditSelectionDrawer.svelte index e49508dc8a..ec54918b88 100644 --- a/packages/desktop/views/dashboard/drawers/dapp-config/components/EditSelectionDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/dapp-config/components/EditSelectionDrawer.svelte @@ -4,10 +4,10 @@ import { localize } from '@core/i18n' import { Router } from '@core/router' import { - getPersistedDappNamespacesForDapp, updateSupportedDappNamespacesForDapp, selectedDapp, sessionProposal, + getPersistedDapp, } from '@auxiliary/wallet-connect/stores' import { onMount } from 'svelte' import { buildSupportedNamespacesFromSelections } from '@auxiliary/wallet-connect/actions' @@ -21,9 +21,7 @@ export let disableContinue: boolean $: dappMetadata = $selectedDapp?.metadata ?? ($sessionProposal?.params.proposer.metadata as IDappMetadata) - $: persistedSupportedNamespaces = dappMetadata - ? getPersistedDappNamespacesForDapp(dappMetadata.url)?.supported - : undefined + $: persistedDapp = dappMetadata ? getPersistedDapp(dappMetadata.url) : undefined $: requiredNamespaces = $selectedDapp?.session?.requiredNamespaces ?? $sessionProposal?.params.requiredNamespaces ?? {} $: optionalNamespaces = @@ -34,7 +32,7 @@ selections, requiredNamespaces, optionalNamespaces, - persistedSupportedNamespaces + persistedDapp?.namespaces.supported ) updateSupportedDappNamespacesForDapp(dappMetadata.url, updatedNamespace) if ($selectedDapp?.session) { @@ -56,11 +54,15 @@
- +
- +
diff --git a/packages/desktop/views/dashboard/drawers/dapp-config/views/ConnectedDappsDrawer.svelte b/packages/desktop/views/dashboard/drawers/dapp-config/views/ConnectedDappsDrawer.svelte index 5db0622e91..d2e4df094b 100644 --- a/packages/desktop/views/dashboard/drawers/dapp-config/views/ConnectedDappsDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/dapp-config/views/ConnectedDappsDrawer.svelte @@ -1,5 +1,5 @@