-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
16 changed files
with
202 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/shared/src/lib/auxiliary/wallet-connect/stores/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './connected-dapps.store' | ||
export * from './wallet-client.store' | ||
export * from './persisted-dapps.store' | ||
export * from './persisted-dapp-namespaces.store' | ||
export * from './selected-dapp.store' | ||
export * from './session-proposal.store' |
60 changes: 2 additions & 58 deletions
60
packages/shared/src/lib/auxiliary/wallet-connect/stores/persisted-dapp-namespaces.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,11 @@ | ||
import { persistent } from '@core/utils/store' | ||
import { Writable, get } from 'svelte/store' | ||
import { SupportedNamespaces } from '../types' | ||
import { getActiveProfile } from '@core/profile/stores' | ||
import { ProposalTypes } from '@walletconnect/types' | ||
import { Writable } from 'svelte/store' | ||
import { IPersistedNamespaces } from '../interface' | ||
|
||
interface IPersistedNamespacesStore { | ||
[profileId: string]: { | ||
[dappOriginUrl: string]: IPersistedNamespaces | ||
} | ||
} | ||
|
||
// Keeping this store for for backwards compatibility for 1.0.1 | ||
export const persistedDappNamespaces: Writable<IPersistedNamespacesStore> = persistent('persistedDappNamespaces', {}) | ||
|
||
export function getPersistedDappNamespacesForDapp(dappOriginUrl: string): IPersistedNamespaces | undefined { | ||
const profileId = getActiveProfile()?.id | ||
return get(persistedDappNamespaces)?.[profileId]?.[dappOriginUrl] | ||
} | ||
|
||
export function persistDappNamespacesForDapp( | ||
dappOriginUrl: string, | ||
supported: SupportedNamespaces, | ||
required: ProposalTypes.RequiredNamespaces, | ||
optional: ProposalTypes.OptionalNamespaces | ||
): void { | ||
const profileId = getActiveProfile()?.id | ||
|
||
return persistedDappNamespaces.update((state) => { | ||
if (!state[profileId]) { | ||
state[profileId] = {} | ||
} | ||
state[profileId][dappOriginUrl] = { supported, required, optional } | ||
|
||
return state | ||
}) | ||
} | ||
|
||
export function updateSupportedDappNamespacesForDapp(dappOriginUrl: string, supported: SupportedNamespaces): void { | ||
const profileId = getActiveProfile()?.id | ||
|
||
return persistedDappNamespaces.update((state) => { | ||
const persistedNamespaces = state?.[profileId]?.[dappOriginUrl] | ||
|
||
if (!persistedNamespaces) { | ||
return state | ||
} | ||
|
||
state[profileId][dappOriginUrl] = { | ||
...persistedNamespaces, | ||
supported: { ...persistedNamespaces.supported, ...supported }, | ||
} | ||
return state | ||
}) | ||
} | ||
|
||
export function removeDappNamespacesForDapp(dappOriginUrl: string): void { | ||
const profileId = getActiveProfile()?.id | ||
|
||
return persistedDappNamespaces.update((state) => { | ||
if (!state[profileId]) { | ||
return state | ||
} | ||
delete state[profileId][dappOriginUrl] | ||
return state | ||
}) | ||
} |
Oops, something went wrong.