-
Notifications
You must be signed in to change notification settings - Fork 316
feat: mask import next id stage 2 #5663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a747839
feat: nextid infrua
Lanttcat d8bd0e4
refactor: divide the setup guide page
Lanttcat 3886742
fix: setup guide type
Lanttcat 12eaf2e
feat: happy path for bind persona and twitter
Lanttcat d1d38d7
feat: should open verify dialog when open twitter if user not connect…
Lanttcat dcd1167
feat: improve ui for verify next id in find username step
Lanttcat 449f98c
feat: user can close dialog
Lanttcat 73b1734
refactor: feedback
Lanttcat 28240e6
chore: merge develop
Lanttcat e92a6cf
refactor: collect verification post
Lanttcat 137c803
chore: add notice to use next id service
Lanttcat 90a9415
fix: should to pin step after verfiy
Lanttcat d430525
feat: move next id to web3 provider
Lanttcat 019b24c
fix: type on nect id config
Lanttcat 01c5d69
refactor: tip semantic
Lanttcat 9769e4e
feat: add not show again
Lanttcat 8424edc
refactor: review feedback
Lanttcat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -117,6 +117,7 @@ | |
| "juicebox", | ||
| "kdfparams", | ||
| "keccak", | ||
| "keybase", | ||
| "kitts", | ||
| "kred", | ||
| "labelledby", | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { compressSecp256k1Point, decompressSecp256k1Key, PersonaIdentifier, toHex } from '@masknet/shared-base' | ||
|
|
||
| export function convertPersonaHexPublicKey(persona: PersonaIdentifier) { | ||
| const key256 = decompressSecp256k1Key(persona.compressedPoint.replace(/\|/g, '/')) | ||
| if (!key256.x || !key256.y) return | ||
| const arr = compressSecp256k1Point(key256.x, key256.y) | ||
|
|
||
| return `0x${toHex(arr)}` | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { useAsync, useAsyncRetry } from 'react-use' | ||
| import type { NextIDPlatform } from '@masknet/shared-base' | ||
| import Services from '../../extension/service' | ||
| import { useMemo, useState } from 'react' | ||
| import { activatedSocialNetworkUI } from '../../social-network' | ||
| import { usePersonaConnectStatus } from './usePersonaConnectStatus' | ||
| import { currentSetupGuideStatus, dismissVerifyNextID } from '../../settings/settings' | ||
| import stringify from 'json-stable-stringify' | ||
| import { SetupGuideStep } from '../InjectedComponents/SetupGuide/types' | ||
| import type { SetupGuideCrossContextStatus } from '../../settings/types' | ||
| import { useLastRecognizedIdentity } from './useActivatedUI' | ||
| import { useValueRef } from '@masknet/shared' | ||
| import { queryExistedBindingByPersona, queryExistedBindingByPlatform, queryIsBound } from '@masknet/web3-providers' | ||
|
|
||
| export const usePersonaBoundPlatform = (personaPublicKey: string) => { | ||
| useAsyncRetry(() => { | ||
| return queryExistedBindingByPersona(personaPublicKey) | ||
| }, [personaPublicKey]) | ||
| } | ||
|
|
||
| let isOpenedVerifyDialog = false | ||
|
|
||
| export const useNextIDBoundByPlatform = (platform: NextIDPlatform, identity: string) => { | ||
| useAsyncRetry(() => { | ||
| return queryExistedBindingByPlatform(platform, identity) | ||
| }, [platform, identity]) | ||
| } | ||
|
|
||
| export function useNextIDConnectStatus() { | ||
| const ui = activatedSocialNetworkUI | ||
| const [enableNextID] = useState(ui.configuration.nextIDConfig?.enable) | ||
| const personaConnectStatus = usePersonaConnectStatus() | ||
| const lastStateRef = currentSetupGuideStatus[ui.networkIdentifier] | ||
| const lastState_ = useValueRef(lastStateRef) | ||
| const lastState = useMemo<SetupGuideCrossContextStatus>(() => { | ||
| try { | ||
| return JSON.parse(lastState_) | ||
| } catch { | ||
| return {} | ||
| } | ||
| }, [lastState_]) | ||
|
|
||
| const lastRecognized = useLastRecognizedIdentity() | ||
| const [username] = useState( | ||
| lastState.username || (lastRecognized.identifier.isUnknown ? '' : lastRecognized.identifier.userId), | ||
| ) | ||
|
|
||
| const { value: isVerified = false } = useAsync(async () => { | ||
| if (isOpenedVerifyDialog) return true | ||
| if (!enableNextID || !username || !personaConnectStatus.connected) return true | ||
|
|
||
| const currentPersona = await Services.Settings.getCurrentPersona() | ||
| if (!currentPersona?.publicHexKey) return true | ||
|
|
||
| if (dismissVerifyNextID[ui.networkIdentifier].value[`${username}_${currentPersona.identifier.toText()}`]) | ||
| return true | ||
|
|
||
| const platform = ui.configuration.nextIDConfig?.platform as NextIDPlatform | undefined | ||
| if (!platform) return true | ||
|
|
||
| const isBound = await queryIsBound(currentPersona.publicHexKey, platform, username) | ||
| if (isBound) return true | ||
|
|
||
| currentSetupGuideStatus[ui.networkIdentifier].value = stringify({ | ||
| status: SetupGuideStep.VerifyOnNextID, | ||
| persona: currentPersona?.identifier.toText(), | ||
| }) | ||
| isOpenedVerifyDialog = true | ||
| return false | ||
| }, [username, enableNextID, lastStateRef.value]) | ||
|
|
||
| return isVerified | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this alias?