From 1976cfbb48e2ad6b4cde294eef631fb2d6f8d688 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Wed, 23 Mar 2022 22:42:02 +0800 Subject: [PATCH 01/23] chore: bump version to 2.6.0 --- package.json | 2 +- packages/mask/src/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d19558d2d2b..45489dd935e6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.5.0", + "version": "2.6.0", "private": true, "license": "AGPL-3.0-or-later", "scripts": { diff --git a/packages/mask/src/manifest.json b/packages/mask/src/manifest.json index 4e4379f5f14f..f436056eeecf 100644 --- a/packages/mask/src/manifest.json +++ b/packages/mask/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Mask Network", - "version": "2.5.0", + "version": "2.6.0", "manifest_version": 2, "permissions": ["storage", "downloads", "webNavigation", "activeTab"], "optional_permissions": ["", "notifications", "clipboardRead"], From 03200b8f320f80021373dc53e57af31f314a6cd2 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Thu, 24 Mar 2022 15:39:26 +0800 Subject: [PATCH 02/23] fix: missing builds (#5935) * fix: missing builds * fix: missing resolve --- packages/mask/.webpack/config.ts | 1 + packages/scripts/src/extension/normal.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/mask/.webpack/config.ts b/packages/mask/.webpack/config.ts index fdbace324f36..e5a143627592 100644 --- a/packages/mask/.webpack/config.ts +++ b/packages/mask/.webpack/config.ts @@ -70,6 +70,7 @@ export function createConfiguration(rawFlags: BuildFlags): Configuration { '@masknet/gun-utils': join(__dirname, '../../gun-utils/src/'), '@masknet/shared': join(__dirname, '../../shared/src/'), '@masknet/shared-base': join(__dirname, '../../shared-base/src/'), + '@masknet/shared-base-ui': join(__dirname, '../../shared-base-ui/src/'), '@masknet/theme': join(__dirname, '../../theme/src/'), '@masknet/icons': join(__dirname, '../../icons/index.ts'), '@masknet/web3-providers': join(__dirname, '../../web3-providers/src'), diff --git a/packages/scripts/src/extension/normal.ts b/packages/scripts/src/extension/normal.ts index 22c2ccdb8e22..2af02b00bdda 100644 --- a/packages/scripts/src/extension/normal.ts +++ b/packages/scripts/src/extension/normal.ts @@ -13,7 +13,10 @@ const presets = ['chromium', 'firefox', 'android', 'iOS', 'base'] as const const otherFlags = ['beta', 'insider', 'reproducible', 'profile', 'mv3', 'readonlyCache', 'progress'] as const export async function extension(f?: Function | ExtensionBuildArgs) { - await Promise.all([buildPolyfill(), buildInjectedScript(), buildMaskSDK(), buildGun()]) + await buildPolyfill() + await buildInjectedScript() + await buildGun() + await buildMaskSDK() if (typeof f === 'function') return awaitChildProcess(webpack('build')) return awaitChildProcess(webpack('build', f)) } From dfd3d776386cbaff79bcfc3562e7fbbb34138616 Mon Sep 17 00:00:00 2001 From: Lantt Date: Thu, 24 Mar 2022 18:44:49 +0800 Subject: [PATCH 03/23] fix: next id bugs (#5936) * fix: connect should give username * feat: should show verify dialog when click `to be verify` on popup * refactor: review feedback * fix: popup can not disconnect persona --- .../Personas/components/PersonaCard/Row.tsx | 11 ++++++-- .../Personas/components/PersonaCard/index.tsx | 11 ++++++-- .../Personas/components/PersonaLine/index.tsx | 8 +++--- packages/mask/shared-ui/locales/en-US.json | 1 + .../src/components/DataSource/useNextID.ts | 7 ++--- .../InjectedComponents/SetupGuide.tsx | 6 +++++ .../SetupGuide/VerifyNextID.tsx | 6 +++-- .../SetupGuide/WizardDialog.tsx | 2 +- .../background-script/IdentityService.ts | 24 +++++++++++++++++ .../background-script/SocialNetworkService.ts | 10 +++++-- .../Personas/PersonaSignRequest/index.tsx | 8 ++++-- .../Personas/components/ProfileList/index.tsx | 27 +++++++++++++------ 12 files changed, 95 insertions(+), 26 deletions(-) diff --git a/packages/dashboard/src/pages/Personas/components/PersonaCard/Row.tsx b/packages/dashboard/src/pages/Personas/components/PersonaCard/Row.tsx index a1d3248978e4..341f9d3f5f2e 100644 --- a/packages/dashboard/src/pages/Personas/components/PersonaCard/Row.tsx +++ b/packages/dashboard/src/pages/Personas/components/PersonaCard/Row.tsx @@ -88,7 +88,12 @@ export interface PersonaRowCardUIProps { profiles: ProfileInformation[] definedSocialNetworks: SocialNetwork[] publicKey: string - onConnect: (identifier: PersonaIdentifier, networkIdentifier: string, type?: 'local' | 'nextID') => void + onConnect: ( + identifier: PersonaIdentifier, + networkIdentifier: string, + type?: 'local' | 'nextID', + profile?: ProfileIdentifier, + ) => void onDisconnect: (identifier: ProfileIdentifier) => void onRename: (identifier: PersonaIdentifier, target: string, callback?: () => void) => Promise onDeleteBound: ( @@ -200,7 +205,9 @@ export const PersonaRowCardUI = memo((props) => { disableAdd={currentNetworkProfiles.length >= 5} isHideOperations={false} key={networkIdentifier} - onConnect={(type) => onConnect(identifier, networkIdentifier, type)} + onConnect={(type, profile) => + onConnect(identifier, networkIdentifier, type, profile) + } onDisconnect={onDisconnect} onDeleteBound={(profile: ProfileIdentifier) => { onDeleteBound(identifier, profile, networkIdentifier, NextIDAction.Delete) diff --git a/packages/dashboard/src/pages/Personas/components/PersonaCard/index.tsx b/packages/dashboard/src/pages/Personas/components/PersonaCard/index.tsx index f8fa8aef15a9..ad1badae8cb2 100644 --- a/packages/dashboard/src/pages/Personas/components/PersonaCard/index.tsx +++ b/packages/dashboard/src/pages/Personas/components/PersonaCard/index.tsx @@ -79,7 +79,12 @@ export const PersonaCard = memo((props) => { export interface PersonaCardUIProps extends PersonaCardProps { definedSocialNetworks: SocialNetwork[] - onConnect: (identifier: PersonaIdentifier, networkIdentifier: string, type?: 'local' | 'nextID') => void + onConnect: ( + identifier: PersonaIdentifier, + networkIdentifier: string, + type?: 'local' | 'nextID', + profile?: ProfileIdentifier, + ) => void onDisconnect: (identifier: ProfileIdentifier) => void verification?: NextIDPersonaBindings } @@ -121,7 +126,9 @@ export const PersonaCardUI = memo((props) => { proof={proof} isHideOperations key={networkIdentifier} - onConnect={(type) => onConnect(identifier, networkIdentifier, type)} + onConnect={(type, profile) => + onConnect(identifier, networkIdentifier, type, profile) + } onDisconnect={onDisconnect} profileIdentifiers={currentNetworkProfiles.map((x) => x.identifier)} networkIdentifier={networkIdentifier} diff --git a/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx b/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx index 2dd27e7fde5f..89ab6d457c13 100644 --- a/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx +++ b/packages/dashboard/src/pages/Personas/components/PersonaLine/index.tsx @@ -77,7 +77,7 @@ export const UnconnectedPersonaLine = memo(({ onCon export interface ConnectedPersonaLineProps { isHideOperations: boolean - onConnect: (type: 'nextID' | 'local') => void + onConnect: (type: 'nextID' | 'local', profile?: ProfileIdentifier) => void onDisconnect: (identifier: ProfileIdentifier) => void onDeleteBound?: (profile: ProfileIdentifier) => void profileIdentifiers: ProfileIdentifier[] @@ -108,10 +108,10 @@ export const ConnectedPersonaLine = memo( const handleUserIdClick = async (network: string, userId: string) => { await openProfilePage(network, userId) } - const handleProofIconClick = (e: MouseEvent, proof: BindingProof | undefined) => { + const handleProofIconClick = (e: MouseEvent, proof: BindingProof | undefined, profile: ProfileIdentifier) => { e.stopPropagation() if (!proof || !proof.is_valid) { - onConnect('nextID') + onConnect('nextID', profile) } } @@ -138,7 +138,7 @@ export const ConnectedPersonaLine = memo( {profile.network === EnhanceableSite.Twitter && ( handleProofIconClick(e, isProved)}> + onClick={(e: MouseEvent) => handleProofIconClick(e, isProved, profile)}> {proof.loading ? ( ) : isProved?.is_valid ? ( diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 9aac8c916855..b8342b4b448a 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -83,6 +83,7 @@ "setup_guide_connect_auto": "Connect", "setup_guide_connect_failed": "Re-Connect", "setup_guide_verify": "Verfiy", + "setup_guide_verify_should_change_profile": "Inconsistent Account", "setup_guide_verify_dismiss": "Don't show again.", "setup_guide_verify_checking": "Checking", "setup_guide_verify_post_not_found": "No verification post found", diff --git a/packages/mask/src/components/DataSource/useNextID.ts b/packages/mask/src/components/DataSource/useNextID.ts index 568cc85c39d4..9537838e36b9 100644 --- a/packages/mask/src/components/DataSource/useNextID.ts +++ b/packages/mask/src/components/DataSource/useNextID.ts @@ -22,11 +22,12 @@ export const usePersonaBoundPlatform = (personaPublicKey: string) => { let isOpenedVerifyDialog = false let isOpenedFromButton = false -const verifyPersona = (personaIdentifier?: PersonaIdentifier) => async () => { +const verifyPersona = (personaIdentifier?: PersonaIdentifier, username?: string) => async () => { if (!personaIdentifier) return currentSetupGuideStatus[activatedSocialNetworkUI.networkIdentifier].value = stringify({ status: SetupGuideStep.VerifyOnNextID, persona: personaIdentifier.toText(), + username, }) } @@ -107,7 +108,7 @@ export function useNextIDConnectStatus() { isOpenedVerifyDialog = true isOpenedFromButton = false return NextIDVerificationStatus.WaitingVerify - }, [username, enableNextID, lastStateRef.value, isOpenedVerifyDialog, currentPersonaIdentifier.value]) + }, [username, enableNextID, isOpenedVerifyDialog, currentPersonaIdentifier.value]) return { isVerified: VerificationStatus === NextIDVerificationStatus.Verified, @@ -119,7 +120,7 @@ export function useNextIDConnectStatus() { }, action: VerificationStatus === NextIDVerificationStatus.WaitingVerify - ? verifyPersona(personaConnectStatus.currentConnectedPersona?.identifier) + ? verifyPersona(personaConnectStatus.currentConnectedPersona?.identifier, lastState.username) : null, } } diff --git a/packages/mask/src/components/InjectedComponents/SetupGuide.tsx b/packages/mask/src/components/InjectedComponents/SetupGuide.tsx index b9d04a813f25..4122decacfec 100644 --- a/packages/mask/src/components/InjectedComponents/SetupGuide.tsx +++ b/packages/mask/src/components/InjectedComponents/SetupGuide.tsx @@ -71,6 +71,11 @@ function SetupGuideUI(props: SetupGuideUIProps) { lastState.username || (lastRecognized.identifier.isUnknown ? '' : lastRecognized.identifier.userId) const [username, setUsername] = useState(getUsername) + const disableVerify = + lastRecognized.identifier.isUnknown || !lastState.username + ? false + : lastRecognized.identifier.userId !== lastState.username + useEffect(() => { const handler = (val: SocialNetworkUI.CollectingCapabilities.IdentityResolved) => { if (username === '' && !val.identifier.isUnknown) setUsername(val.identifier.userId) @@ -259,6 +264,7 @@ function SetupGuideUI(props: SetupGuideUIProps) { onVerify={onVerify} onDone={onVerifyDone} onClose={onClose} + disableVerify={disableVerify} /> ) case SetupGuideStep.PinExtension: diff --git a/packages/mask/src/components/InjectedComponents/SetupGuide/VerifyNextID.tsx b/packages/mask/src/components/InjectedComponents/SetupGuide/VerifyNextID.tsx index 4e14d30fc99e..bb6b4cf019f4 100644 --- a/packages/mask/src/components/InjectedComponents/SetupGuide/VerifyNextID.tsx +++ b/packages/mask/src/components/InjectedComponents/SetupGuide/VerifyNextID.tsx @@ -17,6 +17,7 @@ interface VerifyNextIDProps extends Partial { personaIdentifier?: PersonaIdentifier network: string avatar?: string + disableVerify: boolean onUsernameChange?: (username: string) => void onVerify: () => Promise onDone?: () => void @@ -31,6 +32,7 @@ export const VerifyNextID = ({ onDone, onClose, network, + disableVerify, }: VerifyNextIDProps) => { const { t } = useI18N() @@ -86,13 +88,13 @@ export const VerifyNextID = ({ ({ overflow: 'hidden', }, button: { - width: 150, + minWidth: 150, height: 40, minHeight: 40, marginLeft: 0, diff --git a/packages/mask/src/extension/background-script/IdentityService.ts b/packages/mask/src/extension/background-script/IdentityService.ts index b8a22610b1b1..7117855f2157 100644 --- a/packages/mask/src/extension/background-script/IdentityService.ts +++ b/packages/mask/src/extension/background-script/IdentityService.ts @@ -23,6 +23,7 @@ import { ProfileInformation, PostIVIdentifier, RelationFavor, + NextIDAction, } from '@masknet/shared-base' import type { Persona, Profile } from '../../database/Persona/types' import { @@ -41,6 +42,7 @@ import { ProfileRecord, LinkedProfileDetails, RelationRecord, + detachProfileDB, } from '../../../background/database/persona/db' import { queryPersonasDB as queryPersonasFromIndexedDB, @@ -57,6 +59,7 @@ import { getCurrentPersonaIdentifier } from './SettingsService' import { MaskMessages } from '../../utils' import { first, orderBy } from 'lodash-unified' import { recover_ECDH_256k1_KeyPair_ByMnemonicWord } from '../../utils/mnemonic-code' +import { bindProof } from '@masknet/web3-providers' assertEnvironment(Environment.ManifestBackground) @@ -391,3 +394,24 @@ export async function queryPersonaByPrivateKey(privateKeyString: string) { return null } // #endregion + +export async function detachProfileWithNextID( + profile: ProfileIdentifier, + uuid: string, + personaPublicKey: string, + action: NextIDAction, + platform: string, + identity: string, + createdAt: string, + options?: { + walletSignature?: string + signature?: string + proofLocation?: string + }, +) { + await bindProof(uuid, personaPublicKey, NextIDAction.Delete, platform, identity, createdAt, { + signature: options?.signature, + }) + await detachProfileDB(profile) + MaskMessages.events.ownProofChanged.sendToAll(undefined) +} diff --git a/packages/mask/src/extension/background-script/SocialNetworkService.ts b/packages/mask/src/extension/background-script/SocialNetworkService.ts index 46b9a57e2633..bbdd64706fb2 100644 --- a/packages/mask/src/extension/background-script/SocialNetworkService.ts +++ b/packages/mask/src/extension/background-script/SocialNetworkService.ts @@ -5,7 +5,7 @@ import { requestSNSAdaptorPermission } from '../../social-network/utils/permissi import { currentSetupGuideStatus } from '../../settings/settings' import stringify from 'json-stable-stringify' import { SetupGuideStep } from '../../components/InjectedComponents/SetupGuide/types' -import type { PersonaIdentifier } from '@masknet/shared-base' +import type { PersonaIdentifier, ProfileIdentifier } from '@masknet/shared-base' import { delay } from '@dimensiondev/kit' export async function getDefinedSocialNetworkUIs() { @@ -15,7 +15,12 @@ export async function getDefinedSocialNetworkUIs() { } }) } -export async function connectSocialNetwork(identifier: PersonaIdentifier, network: string, type?: 'local' | 'nextID') { +export async function connectSocialNetwork( + identifier: PersonaIdentifier, + network: string, + type?: 'local' | 'nextID', + profile?: ProfileIdentifier, +) { const ui = await loadSocialNetworkUI(network) const home = ui.utils.getHomePage?.() if (!Flags.no_web_extension_dynamic_permission_request) { @@ -24,6 +29,7 @@ export async function connectSocialNetwork(identifier: PersonaIdentifier, networ currentSetupGuideStatus[network].value = stringify({ status: type === 'nextID' ? SetupGuideStep.VerifyOnNextID : SetupGuideStep.FindUsername, persona: identifier.toText(), + username: profile?.userId, }) await delay(100) home && browser.tabs.create({ active: true, url: home }) diff --git a/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx b/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx index b55204d6ac2b..8b0c92ab3b30 100644 --- a/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx @@ -6,6 +6,7 @@ import { useNavigate, useLocation } from 'react-router-dom' import { ECKeyIdentifier, Identifier, PopupRoutes } from '@masknet/shared-base' import { useMyPersonas } from '../../../../../components/DataSource/useMyPersonas' import type { Persona } from '../../../../../database' +import { delay } from '@dimensiondev/kit' const useStyles = makeStyles()(() => ({ container: { @@ -103,7 +104,7 @@ const PersonaSignRequest = memo(() => { } }, [personas, location.search]) - const onSign = () => { + const onSign = async () => { if (!requestID || !selected) return MaskMessages.events.personaSignRequest.sendToBackgroundPage({ requestID, @@ -112,12 +113,15 @@ const PersonaSignRequest = memo(() => { ECKeyIdentifier, ).unwrap(), }) + + await delay(200) window.close() } - const onCancel = () => { + const onCancel = async () => { if (!requestID) return MaskMessages.events.personaSignRequest.sendToBackgroundPage({ requestID }) + await delay(200) window.close() } diff --git a/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx b/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx index ff2d7edfb23f..d8a681ee92f9 100644 --- a/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx @@ -17,7 +17,7 @@ import { useAsyncFn, useAsyncRetry } from 'react-use' import Services from '../../../../../service' import { GrayMasks } from '@masknet/icons' import { DisconnectDialog } from '../DisconnectDialog' -import { bindProof, createPersonaPayload, queryExistedBindingByPersona } from '@masknet/web3-providers' +import { createPersonaPayload, queryExistedBindingByPersona } from '@masknet/web3-providers' import { delay } from '@dimensiondev/kit' import classNames from 'classnames' @@ -111,9 +111,14 @@ export const ProfileList = memo(() => { ) const [, onConnect] = useAsyncFn( - async (networkIdentifier: string) => { + async (networkIdentifier: string, type?: 'local' | 'nextID', profile?: ProfileIdentifier) => { if (currentPersona) { - await Services.SocialNetwork.connectSocialNetwork(currentPersona.identifier, networkIdentifier) + await Services.SocialNetwork.connectSocialNetwork( + currentPersona.identifier, + networkIdentifier, + type, + profile, + ) } }, [currentPersona], @@ -183,7 +188,9 @@ export const ProfileList = memo(() => { if (!signatureResult) return - await bindProof( + // workaround: should remove this service method + await Services.Identity.detachProfileWithNextID( + unbind.identifier, result.uuid, publicHexKey, NextIDAction.Delete, @@ -195,8 +202,6 @@ export const ProfileList = memo(() => { }, ) - await Services.Identity.detachProfile(unbind.identifier) - await delay(2000) setUnbind(null) refreshProfileList() @@ -234,7 +239,7 @@ interface MergedProfileInformation extends ProfileInformation { } export interface ProfileListUIProps { - onConnect: (networkIdentifier: string) => void + onConnect: (networkIdentifier: string, type?: 'local' | 'nextID', profile?: ProfileIdentifier) => void onDisconnect: ( identifier: ProfileIdentifier, is_valid?: boolean, @@ -296,7 +301,13 @@ export const ProfileListUI = memo( @{identifier.userId} {!is_valid && identifier.network === 'twitter.com' ? ( - + { + onConnect(identifier.network, 'nextID', identifier) + e.stopPropagation() + }}> {t('popups_persona_to_be_verified')} ) : null} From 03d40932f56dd80e6a939d87b4a360447e6a8671 Mon Sep 17 00:00:00 2001 From: Hancheng Zhou Date: Thu, 24 Mar 2022 21:40:44 +0800 Subject: [PATCH 04/23] fix: zora api (#5942) --- .../plugins/Collectible/SNSAdaptor/ArticleTab.tsx | 14 +++++--------- packages/web3-providers/src/zora/index.ts | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx index e6386237d1dc..becbc804961c 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx @@ -1,7 +1,7 @@ import { makeStyles } from '@masknet/theme' import { CollectibleTab } from './CollectibleTab' import { CollectibleState } from '../hooks/useCollectibleState' -import { AssetPlayer } from '@masknet/shared' +import { NFTCardStyledAssetPlayer } from '@masknet/shared' import { useMemo } from 'react' const useStyles = makeStyles()((theme) => ({ @@ -43,6 +43,9 @@ const useStyles = makeStyles()((theme) => ({ minWidth: 300, minHeight: 300, }, + imgWrapper: { + maxWidth: 300, + }, })) export interface ArticleTabProps {} @@ -57,14 +60,7 @@ export function ArticleTab(props: ArticleTabProps) { return (
- +
) diff --git a/packages/web3-providers/src/zora/index.ts b/packages/web3-providers/src/zora/index.ts index 00f041ef36cd..8bfcbcaf68c1 100644 --- a/packages/web3-providers/src/zora/index.ts +++ b/packages/web3-providers/src/zora/index.ts @@ -6,6 +6,7 @@ import { FungibleTokenDetailed, ERC721TokenDetailed, EthereumTokenType, + resolveIPFSLink, } from '@masknet/web3-shared-evm' import { NonFungibleTokenAPI } from '..' @@ -17,8 +18,14 @@ function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { return { is_verified: false, is_auction: asset.currentAuction !== null, - image_url: - asset.metadata.json.animation_url ?? asset.metadata.json.image_url ?? asset.metadata.json.image ?? '', + image_url: resolveIPFSLink( + ( + asset.metadata.json.image ?? + asset.metadata.json.animation_url ?? + asset.metadata.json.image_url ?? + '' + ).replace('ipfs://', ''), + ), asset_contract: { name: asset.tokenContract.name, description: '', @@ -49,7 +56,9 @@ function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { description: asset.metadata.json.description, name: asset.name ?? asset.metadata.json.name, collection_name: '', - animation_url: asset.metadata.json.animation_url, + animation_url: resolveIPFSLink( + (asset.metadata.json.image ?? asset.metadata.json.animation_url).replace('ipfs://', ''), + ), end_time: asset.currentAuction ? new Date(asset.currentAuction.expiresAt) : null, order_payment_tokens: [] as FungibleTokenDetailed[], offer_payment_tokens: [] as FungibleTokenDetailed[], From 627fb14941013085b01d379247683bdc68234254 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Thu, 24 Mar 2022 21:41:39 +0800 Subject: [PATCH 05/23] fix: bugfix for next id (#5934) * fix: bugfix for next id * fix: bugfix * fix: refactor detach profile with next dot id --- .../background/services/identity/index.ts | 2 +- .../services/identity/persona/sign.ts | 6 +- .../background-script/IdentityService.ts | 4 - .../Personas/PersonaSignRequest/index.tsx | 74 ++++++++++++++++--- .../Personas/components/ProfileList/index.tsx | 46 +++++------- .../src/extension/popups/pages/Wallet/type.ts | 4 + 6 files changed, 90 insertions(+), 46 deletions(-) diff --git a/packages/mask/background/services/identity/index.ts b/packages/mask/background/services/identity/index.ts index f7e4ace2daf0..0196cfdcbe81 100644 --- a/packages/mask/background/services/identity/index.ts +++ b/packages/mask/background/services/identity/index.ts @@ -1,3 +1,3 @@ export { createPersonaByPrivateKey } from './persona/create' -export { signWithPersona, type SignRequest, type SignRequestResult } from './persona/sign' +export { signWithPersona, type SignRequest, type SignRequestResult, generateSignResult } from './persona/sign' export { exportPersonaMnemonicWords, exportPersonaPrivateKey } from './persona/backup' diff --git a/packages/mask/background/services/identity/persona/sign.ts b/packages/mask/background/services/identity/persona/sign.ts index 035752da099d..0e148ffac86e 100644 --- a/packages/mask/background/services/identity/persona/sign.ts +++ b/packages/mask/background/services/identity/persona/sign.ts @@ -9,7 +9,7 @@ import { ECDSASignature, } from 'ethereumjs-util' import { MaskMessages } from '../../../../shared' -import { PersonaIdentifier, fromBase64URL, PopupRoutes } from '@masknet/shared-base' +import { PersonaIdentifier, fromBase64URL, PopupRoutes, ECKeyIdentifier } from '@masknet/shared-base' import { queryPersonasWithPrivateKey } from '../../../../background/database/persona/db' import { openPopupWindow } from '../../../../background/services/helper' import { delay } from '@dimensiondev/kit' @@ -49,6 +49,10 @@ export async function signWithPersona({ message, method, identifier }: SignReque }) }) const signer = await waitForApprove + return generateSignResult(signer, message) +} + +export async function generateSignResult(signer: ECKeyIdentifier, message: string) { const persona = (await queryPersonasWithPrivateKey()).find((x) => x.identifier.equals(signer)) if (!persona) throw new Error('Persona not found') diff --git a/packages/mask/src/extension/background-script/IdentityService.ts b/packages/mask/src/extension/background-script/IdentityService.ts index 7117855f2157..9668da327efb 100644 --- a/packages/mask/src/extension/background-script/IdentityService.ts +++ b/packages/mask/src/extension/background-script/IdentityService.ts @@ -42,7 +42,6 @@ import { ProfileRecord, LinkedProfileDetails, RelationRecord, - detachProfileDB, } from '../../../background/database/persona/db' import { queryPersonasDB as queryPersonasFromIndexedDB, @@ -396,10 +395,8 @@ export async function queryPersonaByPrivateKey(privateKeyString: string) { // #endregion export async function detachProfileWithNextID( - profile: ProfileIdentifier, uuid: string, personaPublicKey: string, - action: NextIDAction, platform: string, identity: string, createdAt: string, @@ -412,6 +409,5 @@ export async function detachProfileWithNextID( await bindProof(uuid, personaPublicKey, NextIDAction.Delete, platform, identity, createdAt, { signature: options?.signature, }) - await detachProfileDB(profile) MaskMessages.events.ownProofChanged.sendToAll(undefined) } diff --git a/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx b/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx index 8b0c92ab3b30..e2300aec7244 100644 --- a/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/PersonaSignRequest/index.tsx @@ -6,7 +6,10 @@ import { useNavigate, useLocation } from 'react-router-dom' import { ECKeyIdentifier, Identifier, PopupRoutes } from '@masknet/shared-base' import { useMyPersonas } from '../../../../../components/DataSource/useMyPersonas' import type { Persona } from '../../../../../database' -import { delay } from '@dimensiondev/kit' +import { PersonaContext } from '../hooks/usePersonaContext' +import { MethodAfterPersonaSign } from '../../Wallet/type' +import { useAsyncFn } from 'react-use' +import Services from '../../../../service' const useStyles = makeStyles()(() => ({ container: { @@ -86,7 +89,7 @@ const PersonaSignRequest = memo(() => { const [message, setMessage] = useState() const [selected, setSelected] = useState() const personas = useMyPersonas() - + const { currentPersona } = PersonaContext.useContainer() useEffect(() => { if (!personas.length) return const url = new URLSearchParams(location.search) @@ -104,25 +107,72 @@ const PersonaSignRequest = memo(() => { } }, [personas, location.search]) - const onSign = async () => { + const [, onSign] = useAsyncFn(async () => { + const url = new URLSearchParams(location.search) if (!requestID || !selected) return + const selectedPersona = Identifier.fromString( + selected.identifier.toText(), + ECKeyIdentifier, + ).unwrap() MaskMessages.events.personaSignRequest.sendToBackgroundPage({ requestID, - selectedPersona: Identifier.fromString( - selected.identifier.toText(), - ECKeyIdentifier, - ).unwrap(), + selectedPersona, }) - await delay(200) - window.close() - } + const method = url.get('method') as MethodAfterPersonaSign | undefined + + if (!method) { + window.close() + return + } + + // sign request from popup + switch (method) { + case MethodAfterPersonaSign.DISCONNECT_NEXT_ID: + if (!message) break + const signatureResult = await Services.Identity.generateSignResult(selectedPersona, message) + + const profileIdentifier = url.get('profileIdentifier') + const platform = url.get('platform') + const identity = url.get('identity') + const createdAt = url.get('createdAt') + const uuid = url.get('uuid') + + if ( + !signatureResult || + !profileIdentifier || + !platform || + !identity || + !createdAt || + !uuid || + !currentPersona?.publicHexKey + ) + break + await Services.Identity.detachProfileWithNextID( + uuid, + currentPersona.publicHexKey, + platform, + identity, + createdAt, + { + signature: signatureResult.signature.signature, + }, + ) + const profile = currentPersona.linkedProfiles.find((x) => x.identifier.toText() === profileIdentifier) + if (!profile) break + await Services.Identity.detachProfile(profile.identifier) + break + } + navigate(-1) + }, [location, selected, requestID, message, currentPersona]) const onCancel = async () => { if (!requestID) return + const url = new URLSearchParams(location.search) MaskMessages.events.personaSignRequest.sendToBackgroundPage({ requestID }) - await delay(200) - window.close() + const method = url.get('method') + if (!method) window.close() + navigate(-1) } return ( diff --git a/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx b/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx index d8a681ee92f9..e06e71a181e2 100644 --- a/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx +++ b/packages/mask/src/extension/popups/pages/Personas/components/ProfileList/index.tsx @@ -8,18 +8,21 @@ import { EnhanceableSite, NextIDAction, NextIDPlatform, + PopupRoutes, } from '@masknet/shared-base' import { compact } from 'lodash-unified' import { makeStyles } from '@masknet/theme' -import { useI18N, MaskMessages } from '../../../../../../utils' +import { useI18N } from '../../../../../../utils' import { PersonaContext } from '../../hooks/usePersonaContext' import { useAsyncFn, useAsyncRetry } from 'react-use' import Services from '../../../../../service' import { GrayMasks } from '@masknet/icons' import { DisconnectDialog } from '../DisconnectDialog' import { createPersonaPayload, queryExistedBindingByPersona } from '@masknet/web3-providers' -import { delay } from '@dimensiondev/kit' import classNames from 'classnames' +import { useNavigate } from 'react-router-dom' +import urlcat from 'urlcat' +import { MethodAfterPersonaSign } from '../../../Wallet/type' const useStyles = makeStyles()((theme) => ({ list: { @@ -97,6 +100,7 @@ export interface ProfileListProps {} export const ProfileList = memo(() => { const { currentPersona } = PersonaContext.useContainer() + const navigate = useNavigate() const [unbind, setUnbind] = useState<{ identifier: ProfileIdentifier identity?: string @@ -180,35 +184,21 @@ export const ProfileList = memo(() => { unbind.platform, ) if (!result) return - const signatureResult = await Services.Identity.signWithPersona({ - method: 'eth', - message: result.signPayload, - identifier: currentPersona.identifier.toText(), - }) - - if (!signatureResult) return - - // workaround: should remove this service method - await Services.Identity.detachProfileWithNextID( - unbind.identifier, - result.uuid, - publicHexKey, - NextIDAction.Delete, - unbind.platform, - unbind.identity, - result.createdAt, - { - signature: signatureResult.signature.signature, - }, + navigate( + urlcat(PopupRoutes.PersonaSignRequest, { + requestID: Math.random().toString().slice(3), + message: result.signPayload, + identifier: currentPersona.identifier.toText(), + method: MethodAfterPersonaSign.DISCONNECT_NEXT_ID, + profileIdentifier: unbind.identifier.toText(), + platform: unbind.platform, + identity: unbind.identity, + createdAt: result.createdAt, + uuid: result.uuid, + }), ) - - await delay(2000) - setUnbind(null) - refreshProfileList() } catch { console.log('Disconnect failed') - } finally { - MaskMessages.events.ownProofChanged.sendToAll(undefined) } }, [unbind, currentPersona?.identifier, refreshProfileList]) diff --git a/packages/mask/src/extension/popups/pages/Wallet/type.ts b/packages/mask/src/extension/popups/pages/Wallet/type.ts index 43f356aba4ee..0f0674e1b2c9 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/type.ts +++ b/packages/mask/src/extension/popups/pages/Wallet/type.ts @@ -9,3 +9,7 @@ export enum TransferAddressError { RESOLVE_FAILED = 'RESOLVE_FAILED', NETWORK_NOT_SUPPORT = 'NETWORK_NOT_SUPPORT', } + +export enum MethodAfterPersonaSign { + DISCONNECT_NEXT_ID = 'DISCONNECT_NEXT_ID', +} From 83ce1310c5dc6f7c627da4caf95e8032d4260b60 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Thu, 24 Mar 2022 22:12:49 +0800 Subject: [PATCH 06/23] fix: adjust maskicon position (#5943) --- .../src/social-network-adaptor/twitter.com/utils/selector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts index 7382fbb7032f..c6379837ba56 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts @@ -111,7 +111,7 @@ export const postEditorContentInPopupSelector: () => LiveSelector = () ) export const postEditorInPopupSelector: () => LiveSelector = () => querySelector( - '[aria-labelledby="modal-header"] > div:first-child > div:first-child > div:first-child > div:nth-child(3) > div:first-child [role="button"][aria-label]:nth-child(6)', + '[aria-labelledby="modal-header"] > div:first-child > div:first-child > div:first-child > div:nth-child(3) > div:first-child [role="button"][aria-label]:nth-child(7)', ) export const toolBoxInSideBarSelector: () => LiveSelector = () => querySelector('[role="banner"] [role="navigation"] > div') From 8a7bb018e8245c515f75a95ffbff5a13263494c1 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Thu, 24 Mar 2022 22:13:12 +0800 Subject: [PATCH 07/23] fix(twitter): search injected dom selector (#5944) --- .../src/social-network-adaptor/twitter.com/utils/selector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts index c6379837ba56..0107fc8fb024 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts @@ -267,7 +267,7 @@ export const searchProfileSetAvatarSelector = () => ? searchProfessionalButtonSelector() .closest(4) .querySelector('div > div:nth-child(2) >div > div:nth-child(2)') - : querySelector('[data-testid="ProfileBirthdate"]') + : querySelector('[data-testid^="ProfileBirthdate"]') .closest(5) .querySelector('div > div:nth-child(2) > div:nth-child(2)') // #endregion From 658b131dc52c9eac16c86bd6e6d8c4742aadc740 Mon Sep 17 00:00:00 2001 From: UncleBill Date: Thu, 24 Mar 2022 20:53:45 +0800 Subject: [PATCH 08/23] fix: sns share in ITO and PET (#5941) --- .../mask/src/plugins/ITO/SNSAdaptor/ITO.tsx | 2 +- .../plugins/ITO/SNSAdaptor/ShareDialog.tsx | 22 ++++++++++--------- .../src/plugins/ITO/SNSAdaptor/SwapGuide.tsx | 6 ++--- packages/mask/src/plugins/Pets/constants.ts | 4 +--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx index b63a868c8f53..d35d84c6d41a 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/ITO.tsx @@ -786,7 +786,7 @@ export function ITO(props: ITO_Props) { status={claimDialogStatus} total_remaining={total_remaining} payload={{ ...payload, qualification_address: qualificationAddress }} - shareSuccessLink={successShareText} + shareSuccessText={successShareText} isBuyer={isBuyer} exchangeTokens={exchange_tokens} open={openClaimDialog} diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/ShareDialog.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/ShareDialog.tsx index ec3c7ddf214e..432658ea1c99 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/ShareDialog.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/ShareDialog.tsx @@ -1,11 +1,12 @@ -import { useCallback } from 'react' -import { Box, Typography } from '@mui/material' import { makeStyles, useStylesExtends } from '@masknet/theme' -import { getAssetAsBlobURL, useI18N } from '../../../utils' -import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' -import { formatBalance, FungibleTokenDetailed } from '@masknet/web3-shared-evm' import { isZero } from '@masknet/web3-shared-base' +import { formatBalance, FungibleTokenDetailed } from '@masknet/web3-shared-evm' +import { Box, Typography } from '@mui/material' import type { BigNumber } from 'bignumber.js' +import { useCallback } from 'react' +import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' +import { activatedSocialNetworkUI } from '../../../social-network' +import { getAssetAsBlobURL, useI18N } from '../../../utils' const useStyles = makeStyles()((theme) => ({ shareWrapper: { @@ -53,7 +54,7 @@ const useStyles = makeStyles()((theme) => ({ })) export interface ShareDialogProps extends withClasses<'root'> { - shareSuccessLink: string | undefined + shareSuccessText: string | undefined token: FungibleTokenDetailed actualSwapAmount: BigNumber.Value poolName: string @@ -64,13 +65,14 @@ export function ShareDialog(props: ShareDialogProps) { const ShareBackground = getAssetAsBlobURL(new URL('../assets/share-background.jpg', import.meta.url)) const { t } = useI18N() const classes = useStylesExtends(useStyles(), {}) - const { token, actualSwapAmount, shareSuccessLink, onClose } = props + const { token, actualSwapAmount, shareSuccessText, onClose } = props const amount = formatBalance(actualSwapAmount, token.decimals) const onShareSuccess = useCallback(async () => { onClose() - window.open(shareSuccessLink, '_blank', 'noopener noreferrer') - }, [shareSuccessLink, onClose]) + if (!shareSuccessText) return + activatedSocialNetworkUI.utils.share?.(shareSuccessText) + }, [shareSuccessText, onClose]) return ( @@ -86,7 +88,7 @@ export function ShareDialog(props: ShareDialogProps) { {isZero(actualSwapAmount) ? t('plugin_ito_out_of_stock_hit') : t('plugin_ito_congratulations')} - {shareSuccessLink ? ( + {shareSuccessText ? ( , Omit { status: SwapStatus - shareSuccessLink: string | undefined + shareSuccessText: string | undefined total_remaining: BigNumber isBuyer: boolean retryPayload: () => void @@ -49,7 +49,7 @@ export function SwapGuide(props: SwapGuideProps) { isBuyer, open, retryPayload, - shareSuccessLink, + shareSuccessText, total_remaining, onUpdate, onClose, @@ -127,7 +127,7 @@ export function SwapGuide(props: SwapGuideProps) { case SwapStatus.Share: return ( Date: Thu, 24 Mar 2022 19:32:24 +0800 Subject: [PATCH 09/23] fix(kv): fetch with no-cors mode response opaque data (#5940) --- packages/web3-providers/src/kv/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web3-providers/src/kv/index.ts b/packages/web3-providers/src/kv/index.ts index f19115e85d02..612a9542ae41 100644 --- a/packages/web3-providers/src/kv/index.ts +++ b/packages/web3-providers/src/kv/index.ts @@ -14,7 +14,6 @@ export class JSON_Storage implements StorageAPI.Storage { }), { method: 'GET', - mode: 'no-cors', headers: { 'Content-Type': 'application/json', }, From e4cc6b8e0c4d8a022533f72502d1dbfb086376a3 Mon Sep 17 00:00:00 2001 From: lelenei <72531217+lelenei@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:17:55 +0800 Subject: [PATCH 10/23] fix: reply review (#5946) --- .../mask/src/components/CompositionDialog/Composition.tsx | 7 ++++++- .../twitter.com/injection/PostDialogHint.tsx | 2 +- .../social-network-adaptor/twitter.com/utils/selector.ts | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/mask/src/components/CompositionDialog/Composition.tsx b/packages/mask/src/components/CompositionDialog/Composition.tsx index 07561d218b9b..cd5a11b5b22c 100644 --- a/packages/mask/src/components/CompositionDialog/Composition.tsx +++ b/packages/mask/src/components/CompositionDialog/Composition.tsx @@ -46,7 +46,12 @@ export function Composition({ type = 'timeline', requireClipboardPermission }: P useEffect(() => { return MaskMessages.events.requestComposition.on(({ reason, open, content, options }) => { - if (reason !== 'reply' && (reason !== type || globalUIState.profiles.value.length <= 0)) return + if ( + (reason !== 'reply' && reason !== type) || + (reason === 'reply' && type === 'popup') || + globalUIState.profiles.value.length <= 0 + ) + return setOpen(open) setReason(reason) if (content) UI.current?.setMessage(content) diff --git a/packages/mask/src/social-network-adaptor/twitter.com/injection/PostDialogHint.tsx b/packages/mask/src/social-network-adaptor/twitter.com/injection/PostDialogHint.tsx index 37b1836affa3..2eb6d896327d 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/injection/PostDialogHint.tsx +++ b/packages/mask/src/social-network-adaptor/twitter.com/injection/PostDialogHint.tsx @@ -4,7 +4,6 @@ import { isReplyPageSelector, postEditorInPopupSelector, searchReplyToolbarSelec import { createReactRootShadowed } from '../../../utils/shadow-root/renderInShadowRoot' import { PostDialogHint } from '../../../components/InjectedComponents/PostDialogHint' import { MaskMessages } from '../../../utils/messages' -import { hasEditor, isCompose } from '../utils/postBox' import { startWatch } from '../../../utils/watcher' import { makeStyles, MaskColorVar } from '@masknet/theme' import { alpha } from '@mui/material' @@ -12,6 +11,7 @@ import { twitterBase } from '../base' import { sayHelloShowed } from '../../../settings/settings' import { makeTypedMessageText } from '@masknet/typed-message' import { useI18N } from '../../../utils' +import { hasEditor, isCompose } from '../utils/postBox' const useStyles = makeStyles()((theme) => ({ iconButton: { diff --git a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts index 0107fc8fb024..24879f196c21 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts @@ -110,9 +110,7 @@ export const postEditorContentInPopupSelector: () => LiveSelector = () '[aria-labelledby="modal-header"] > div:first-child > div:first-child > div:first-child > div:nth-child(3)', ) export const postEditorInPopupSelector: () => LiveSelector = () => - querySelector( - '[aria-labelledby="modal-header"] > div:first-child > div:first-child > div:first-child > div:nth-child(3) > div:first-child [role="button"][aria-label]:nth-child(7)', - ) + querySelector('[aria-labelledby="modal-header"] div[data-testid="toolBar"] div[data-testid="geoButton"]') export const toolBoxInSideBarSelector: () => LiveSelector = () => querySelector('[role="banner"] [role="navigation"] > div') export const sideBarProfileSelector: () => LiveSelector = () => From ef4d94dadd59d3de826d5d6323d5da368a960f8b Mon Sep 17 00:00:00 2001 From: Jack Works Date: Fri, 25 Mar 2022 00:41:16 +0800 Subject: [PATCH 11/23] fix: plugin wrapper (#5947) --- .../CompositionDialog/CompositionUI.tsx | 5 +- .../CompositionDialog/PluginEntryRender.tsx | 9 ++-- .../CompositionDialog/TypedMessageEditor.tsx | 47 +++++++++---------- packages/mask/src/components/shared/Image.tsx | 5 +- .../plugins/ITO/SNSAdaptor/RegionSelect.tsx | 16 ++++--- .../mask/src/plugins/MaskPluginWrapper.tsx | 18 ++++++- .../twitter.com/utils/selector.ts | 2 +- .../src/utils/createInjectHooksRenderer.tsx | 12 +++-- 8 files changed, 67 insertions(+), 47 deletions(-) diff --git a/packages/mask/src/components/CompositionDialog/CompositionUI.tsx b/packages/mask/src/components/CompositionDialog/CompositionUI.tsx index 18bb65e04ecd..7da4567a6222 100644 --- a/packages/mask/src/components/CompositionDialog/CompositionUI.tsx +++ b/packages/mask/src/components/CompositionDialog/CompositionUI.tsx @@ -106,8 +106,7 @@ export const CompositionDialogUI = forwardRef( }) }, []) - useImperativeHandle( - ref, + const refItem = useMemo( (): CompositionRef => ({ setMessage: (msg) => { if (Editor.current) Editor.current.value = msg @@ -119,6 +118,8 @@ export const CompositionDialogUI = forwardRef( [reset], ) + useImperativeHandle(ref, () => refItem, [refItem]) + const context = useMemo( (): CompositionContext => ({ attachMetadata: (meta, data) => Editor.current?.attachMetadata(meta, data), diff --git a/packages/mask/src/components/CompositionDialog/PluginEntryRender.tsx b/packages/mask/src/components/CompositionDialog/PluginEntryRender.tsx index 5d9e55775a7a..5db488b0ef98 100644 --- a/packages/mask/src/components/CompositionDialog/PluginEntryRender.tsx +++ b/packages/mask/src/components/CompositionDialog/PluginEntryRender.tsx @@ -12,7 +12,7 @@ import { RedPacketPluginID } from '../../plugins/RedPacket/constants' import { ITO_PluginID } from '../../plugins/ITO/constants' import { ClickableChip } from '../shared/SelectRecipients/ClickableChip' import { makeStyles } from '@masknet/theme' -import { useCallback, useState, useRef, forwardRef, memo, useImperativeHandle } from 'react' +import { useCallback, useState, useRef, forwardRef, memo, useImperativeHandle, useMemo } from 'react' import { useChainId } from '@masknet/web3-shared-evm' import { Trans } from 'react-i18next' const useStyles = makeStyles()({ @@ -60,8 +60,7 @@ export const PluginEntryRender = memo( function useSetPluginEntryRenderRef(ref: React.ForwardedRef) { const pluginRefs = useRef>({}) - useImperativeHandle( - ref, + const refItem: PluginEntryRenderRef = useMemo( () => ({ openPlugin: function openPlugin(id: string, tryTimes = 4) { const ref = pluginRefs.current[id] @@ -74,13 +73,15 @@ function useSetPluginEntryRenderRef(ref: React.ForwardedRef refItem, [refItem]) const trackPluginRef = (pluginID: string) => (ref: PluginRef | null) => { pluginRefs.current = { ...pluginRefs.current, [pluginID]: ref } } return [trackPluginRef] } function useSetPluginRef(ref: React.ForwardedRef, onClick: () => void) { - useImperativeHandle(ref, () => ({ open: onClick }), [onClick]) + const refItem = useMemo(() => ({ open: onClick }), [onClick]) + useImperativeHandle(ref, () => refItem, [refItem]) } type PluginRef = { open(): void } diff --git a/packages/mask/src/components/CompositionDialog/TypedMessageEditor.tsx b/packages/mask/src/components/CompositionDialog/TypedMessageEditor.tsx index d8c2b2541e77..0e1f0d9da9f5 100644 --- a/packages/mask/src/components/CompositionDialog/TypedMessageEditor.tsx +++ b/packages/mask/src/components/CompositionDialog/TypedMessageEditor.tsx @@ -8,7 +8,7 @@ import { } from '@masknet/typed-message' import { makeStyles } from '@masknet/theme' import { InputBase, Alert, Button } from '@mui/material' -import { useCallback, useImperativeHandle, useState, useRef, forwardRef, memo } from 'react' +import { useCallback, useImperativeHandle, useState, useRef, forwardRef, memo, useMemo } from 'react' import { useI18N } from '../../utils' import { BadgeRenderer } from './BadgeRenderer' @@ -81,30 +81,27 @@ export const TypedMessageEditor = memo( }, [setMessage], ) - useImperativeHandle( - ref, - (): TypedMessageEditorRef => { - return { - get estimatedLength() { - // TODO: we should count metadata into the estimated size - if (isTypedMessageText(currentValue.current)) return currentValue.current.content.length - return 0 - }, - get value() { - return currentValue.current - }, - set value(val) { - setMessage(val) - }, - reset: () => setMessage(emptyMessage), - attachMetadata(meta, data) { - setMessage(editTypedMessageMeta(currentValue.current, (map) => map.set(meta, data))) - }, - dropMetadata: deleteMetaID, - } - }, - [setMessage, deleteMetaID], - ) + const refItem = useMemo((): TypedMessageEditorRef => { + return { + get estimatedLength() { + // TODO: we should count metadata into the estimated size + if (isTypedMessageText(currentValue.current)) return currentValue.current.content.length + return 0 + }, + get value() { + return currentValue.current + }, + set value(val) { + setMessage(val) + }, + reset: () => setMessage(emptyMessage), + attachMetadata(meta, data) { + setMessage(editTypedMessageMeta(currentValue.current, (map) => map.set(meta, data))) + }, + dropMetadata: deleteMetaID, + } + }, [setMessage, deleteMetaID]) + useImperativeHandle(ref, () => refItem, [refItem]) if (!isTypedMessageText(value)) { const reset = () => setAsText('') diff --git a/packages/mask/src/components/shared/Image.tsx b/packages/mask/src/components/shared/Image.tsx index 00da7a77d999..38e79eb2aedf 100644 --- a/packages/mask/src/components/shared/Image.tsx +++ b/packages/mask/src/components/shared/Image.tsx @@ -1,4 +1,4 @@ -import { useRef, useEffect, forwardRef, useImperativeHandle, useState } from 'react' +import { useRef, useEffect, forwardRef, useImperativeHandle, useState, useMemo } from 'react' import { useAsync } from 'react-use' import Services from '../../extension/service' import { Skeleton, SkeletonProps } from '@mui/material' @@ -78,7 +78,8 @@ export const Image = forwardRef(function Image(props, outg const url: string | undefined = blobURL || (typeof src === 'string' ? src : undefined) useEffect(() => void (url && onURL?.(url)), [onURL, url]) - useImperativeHandle(outgoingRef, () => ({ canvas: canvasRef.current, img: imgRef.current }), []) + const outgoingRefItem = useMemo(() => ({ canvas: canvasRef.current, img: imgRef.current }), []) + useImperativeHandle(outgoingRef, () => outgoingRefItem, [outgoingRefItem]) // TODO: handle image loading error const { loading, error, value } = useAsync( diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/RegionSelect.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/RegionSelect.tsx index b53d0080d8f9..780fe7f27453 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/RegionSelect.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/RegionSelect.tsx @@ -1,4 +1,4 @@ -import { useState, useRef, useCallback, forwardRef, useImperativeHandle } from 'react' +import { useState, useRef, useCallback, forwardRef, useImperativeHandle, useMemo } from 'react' import type { InputBaseComponentProps } from '@mui/material' import { makeStyles } from '@masknet/theme' import { useDebounce } from 'react-use' @@ -80,11 +80,15 @@ export const RegionSelect = forwardRef(({ value = [], onRegionChange, ...props } }, []) const [minPopoverWidth, setMinPopoverWidth] = useState(0) - useImperativeHandle(ref, () => ({ - focus: () => { - displayRef.current?.focus() - }, - })) + const refItem = useMemo( + () => ({ + focus: () => { + displayRef.current?.focus() + }, + }), + [], + ) + useImperativeHandle(ref, () => refItem, [refItem]) const [filterText, setFilterText] = useState('') const [filteredRegions, setFilteredRegions] = useState(allRegions) diff --git a/packages/mask/src/plugins/MaskPluginWrapper.tsx b/packages/mask/src/plugins/MaskPluginWrapper.tsx index e193ca16bf5c..a029e4439a42 100644 --- a/packages/mask/src/plugins/MaskPluginWrapper.tsx +++ b/packages/mask/src/plugins/MaskPluginWrapper.tsx @@ -7,7 +7,13 @@ import { isTwitter } from '../social-network-adaptor/twitter.com/base' import { usePersonaConnectStatus } from '../components/DataSource/usePersonaConnectStatus' import { useI18N } from '../utils' import { Box } from '@mui/system' -import { usePluginI18NField, PluginI18NFieldRender, PluginWrapperComponent, Plugin } from '@masknet/plugin-infra' +import { + usePluginI18NField, + PluginI18NFieldRender, + PluginWrapperComponent, + Plugin, + PluginWrapperMethods, +} from '@masknet/plugin-infra' interface PluginWrapperProps extends React.PropsWithChildren<{}> { title: string @@ -137,7 +143,15 @@ export const MaskPostExtraPluginWrapper: PluginWrapperComponent(false) const [title, setTitle] = useState(undefined) - useImperativeHandle(ref, () => ({ setWidth, setWrap: setOpen, setWrapperName: setTitle }), []) + const refItem = useMemo((): PluginWrapperMethods => { + return { + setWidth, + setWrap: setOpen, + setWrapperName: setTitle, + } + }, []) + + useImperativeHandle(ref, () => refItem, [refItem]) if (!open) return <>{props.children} return ( diff --git a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts index 24879f196c21..398d94890015 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts @@ -155,7 +155,7 @@ export const bioPageUserNickNameSelector = () => .map((x) => x.parentElement?.parentElement?.previousElementSibling) .querySelector('div[dir]') export const bioPageUserIDSelector = (selector: () => LiveSelector) => - selector().map((x) => (x.parentElement?.nextElementSibling as HTMLElement).innerText.replace('@', '')) + selector().map((x) => (x.parentElement?.nextElementSibling as HTMLElement)?.innerText?.replace('@', '')) export const floatingBioCardSelector = () => querySelector( '[style~="left:"] a[role=link] > div:first-child > div:first-child > div:first-child[dir="auto"]', diff --git a/packages/plugin-infra/src/utils/createInjectHooksRenderer.tsx b/packages/plugin-infra/src/utils/createInjectHooksRenderer.tsx index 5264eb6cfa97..2da5547361b3 100644 --- a/packages/plugin-infra/src/utils/createInjectHooksRenderer.tsx +++ b/packages/plugin-infra/src/utils/createInjectHooksRenderer.tsx @@ -3,7 +3,7 @@ import { ErrorBoundary } from '@masknet/shared-base-ui' import { ShadowRootIsolation } from '@masknet/theme' import type { Plugin } from '../types' import { usePluginI18NField, PluginWrapperComponent, PluginWrapperMethods } from '../hooks' -import { emptyPluginWrapperMethods, PluginWrapperMethodsContext } from '../hooks/usePluginWrapper' +import { PluginWrapperMethodsContext } from '../hooks/usePluginWrapper' type Inject = Plugin.InjectUI type Raw = Plugin.InjectUIRaw @@ -18,10 +18,12 @@ export function createInjectHooksRenderer(null) if (PluginWrapperComponent) { return ( - (ref === r ? void 0 : setRef(ref))}> - - {element} - + + {ref ? ( + + {element} + + ) : null} ) } From 0b3adefff0d1e4b08aaa79de4a77631b2039b103 Mon Sep 17 00:00:00 2001 From: unclebill Date: Fri, 25 Mar 2022 01:12:05 +0800 Subject: [PATCH 12/23] fix(zora): check ipfs before resolving --- packages/web3-providers/src/zora/index.ts | 18 +++++++----------- packages/web3-shared/evm/pipes/index.ts | 1 + 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/web3-providers/src/zora/index.ts b/packages/web3-providers/src/zora/index.ts index 8bfcbcaf68c1..216507182eed 100644 --- a/packages/web3-providers/src/zora/index.ts +++ b/packages/web3-providers/src/zora/index.ts @@ -14,18 +14,16 @@ import type { ZoraToken, ZoraHistory, ZoraBid, ZoraAsk } from './types' import { getAssetQuery, getTokenHistoryQuery, getBidsQuery, getAsksQuery } from './queries' import { ZORA_MAINNET_GRAPHQL_URL } from './constants' +const isIpfs = (url: string) => url?.startsWith('ipfs://') + function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { + const image_url = + asset.metadata.json.image ?? asset.metadata.json.animation_url ?? asset.metadata.json.image_url ?? '' + const animation_url = asset.metadata.json.image ?? asset.metadata.json.animation_url ?? '' return { is_verified: false, is_auction: asset.currentAuction !== null, - image_url: resolveIPFSLink( - ( - asset.metadata.json.image ?? - asset.metadata.json.animation_url ?? - asset.metadata.json.image_url ?? - '' - ).replace('ipfs://', ''), - ), + image_url: isIpfs(image_url) ? resolveIPFSLink(image_url.replace(/^ipfs:\/\//, '')) : image_url, asset_contract: { name: asset.tokenContract.name, description: '', @@ -56,9 +54,7 @@ function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { description: asset.metadata.json.description, name: asset.name ?? asset.metadata.json.name, collection_name: '', - animation_url: resolveIPFSLink( - (asset.metadata.json.image ?? asset.metadata.json.animation_url).replace('ipfs://', ''), - ), + animation_url: isIpfs(animation_url) ? resolveIPFSLink(animation_url.replace(/^ipfs:\/\//, '')) : animation_url, end_time: asset.currentAuction ? new Date(asset.currentAuction.expiresAt) : null, order_payment_tokens: [] as FungibleTokenDetailed[], offer_payment_tokens: [] as FungibleTokenDetailed[], diff --git a/packages/web3-shared/evm/pipes/index.ts b/packages/web3-shared/evm/pipes/index.ts index 4125068846c5..e8292c875438 100644 --- a/packages/web3-shared/evm/pipes/index.ts +++ b/packages/web3-shared/evm/pipes/index.ts @@ -174,6 +174,7 @@ export function resolveBlockLinkOnExplorer(chainId: ChainId, block: string): str return urlcat(resolveLinkOnExplorer(chainId), '/block/:block', { block }) } +// TODO check ipfs inside before resolving export function resolveIPFSLink(ipfs: string): string { return urlcat('https://coldcdn.com/api/cdn/mipfsygtms/ipfs/:ipfs', { ipfs }) } From c031cb9bff28266cc9979053c19538daa456988a Mon Sep 17 00:00:00 2001 From: UncleBill Date: Fri, 25 Mar 2022 11:53:59 +0800 Subject: [PATCH 13/23] fix(zora): check ipfs before resolving (#5949) * fix(zora): check ipfs before resolving * fix: check ipfs in resolver Co-authored-by: zhouhanseng --- packages/mask/src/plugins/EVM/hooks/useAsset.ts | 6 ++---- packages/web3-providers/src/NFTScan/index.ts | 6 +++--- packages/web3-providers/src/rarible/index.ts | 12 ++++++------ packages/web3-providers/src/zora/index.ts | 8 +++----- packages/web3-shared/evm/pipes/index.ts | 9 +++------ 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/packages/mask/src/plugins/EVM/hooks/useAsset.ts b/packages/mask/src/plugins/EVM/hooks/useAsset.ts index d0f179ff29d3..fbca7176d93e 100644 --- a/packages/mask/src/plugins/EVM/hooks/useAsset.ts +++ b/packages/mask/src/plugins/EVM/hooks/useAsset.ts @@ -6,7 +6,7 @@ import { useAccount, useChainId, useTokenConstants, - resolveIPFSLink, + resolveIPFSLinkFromURL, } from '@masknet/web3-shared-evm' import { EVM_RPC } from '../messages' import { resolveAvatarLinkOnCurrentProvider } from '../../Collectible/pipes' @@ -20,9 +20,7 @@ export function useAsset(address: string, tokenId: string, provider: NonFungible const asset = await EVM_RPC.getAsset({ address, tokenId, chainId, provider }) return { ...asset, - image_url: asset?.image_url?.startsWith('ipfs://') - ? resolveIPFSLink(asset.image_url.replace('ipfs://', '')) - : asset?.image_url, + image_url: resolveIPFSLinkFromURL(asset?.image_url ?? ''), isOrderWeth: isSameAddress(asset?.desktopOrder?.payment_token ?? '', WNATIVE_ADDRESS) ?? false, isCollectionWeth: asset?.collection?.payment_tokens?.some(currySameAddress(WNATIVE_ADDRESS)) ?? false, isOwner: asset?.top_ownerships.some((item) => isSameAddress(item.owner.address, account)) ?? false, diff --git a/packages/web3-providers/src/NFTScan/index.ts b/packages/web3-providers/src/NFTScan/index.ts index e9306f1eb700..fc96ac0fee3e 100644 --- a/packages/web3-providers/src/NFTScan/index.ts +++ b/packages/web3-providers/src/NFTScan/index.ts @@ -3,7 +3,7 @@ import { createERC721ContractDetailed, createERC721Token, ERC721TokenDetailed, - resolveResourceLink, + resolveIPFSLinkFromURL, ERC721ContractDetailed, } from '@masknet/web3-shared-evm' import addSeconds from 'date-fns/addSeconds' @@ -66,7 +66,7 @@ function createERC721TokenAsset(asset: NFTScanAsset) { { name: payload?.name ?? asset.nft_name ?? asset.nft_platform_name ?? '', description: payload?.description ?? '', - mediaUrl: resolveResourceLink(asset.nft_cover ?? asset.nft_content_uri ?? payload.image ?? ''), + mediaUrl: resolveIPFSLinkFromURL(asset.nft_cover ?? asset.nft_content_uri ?? payload.image ?? ''), owner: asset.nft_holder ?? '', }, asset.token_id, @@ -155,7 +155,7 @@ export class NFTScanAPI implements NonFungibleTokenAPI.Provider { info: { name: t.nft_name, description: t.nft_detail, - mediaUrl: resolveResourceLink(t.nft_cover ?? t.nft_content_uri ?? ''), + mediaUrl: resolveIPFSLinkFromURL(t.nft_cover ?? t.nft_content_uri ?? ''), tokenURI: t.nft_token_uri, }, })) diff --git a/packages/web3-providers/src/rarible/index.ts b/packages/web3-providers/src/rarible/index.ts index 8e2195e5cae1..efeeb09258a5 100644 --- a/packages/web3-providers/src/rarible/index.ts +++ b/packages/web3-providers/src/rarible/index.ts @@ -6,7 +6,7 @@ import { ERC721TokenDetailed, EthereumTokenType, FungibleTokenDetailed, - resolveResourceLink, + resolveIPFSLinkFromURL, } from '@masknet/web3-shared-evm' import { Ownership, @@ -51,7 +51,7 @@ function createERC721TokenFromAsset( tokenId: string, asset?: RaribleNFTItemMapResponse, ): ERC721TokenDetailed { - const imageURL = resolveResourceLink(asset?.meta?.image?.url.ORIGINAL ?? asset?.meta?.image?.url.PREVIEW ?? '') + const imageURL = resolveIPFSLinkFromURL(asset?.meta?.image?.url.ORIGINAL ?? asset?.meta?.image?.url.PREVIEW ?? '') return { contractDetailed: { type: EthereumTokenType.ERC721, @@ -64,7 +64,7 @@ function createERC721TokenFromAsset( name: asset?.meta?.name ?? '', description: asset?.meta?.description ?? '', mediaUrl: - resolveResourceLink( + resolveIPFSLinkFromURL( asset?.meta?.animation?.url.ORIGINAL ?? asset?.meta?.animation?.url.PREVIEW ?? '', ) || imageURL, imageURL, @@ -81,7 +81,7 @@ function createNFTAsset(asset: RaribleNFTItemMapResponse, chainId: ChainId): Non is_verified: false, is_auction: false, token_address: asset.contract, - image_url: resolveResourceLink(asset?.meta?.image?.url.ORIGINAL ?? ''), + image_url: resolveIPFSLinkFromURL(asset?.meta?.image?.url.ORIGINAL ?? ''), asset_contract: null, owner: owner ? { @@ -214,7 +214,7 @@ export class RaribleAPI implements NonFungibleTokenAPI.Provider { maker_account: { user: { username: ownerInfo?.name ?? '' }, address: ownerInfo?.id ?? '', - profile_img_url: resolveResourceLink(ownerInfo?.image ?? ''), + profile_img_url: resolveIPFSLinkFromURL(ownerInfo?.image ?? ''), link: `${resolveRaribleUserNetwork(chainId as number)}${ownerInfo?.id ?? ''}`, }, } @@ -245,7 +245,7 @@ export class RaribleAPI implements NonFungibleTokenAPI.Provider { maker_account: { user: { username: ownerInfo?.name ?? '' }, address: ownerInfo?.id ?? '', - profile_img_url: resolveResourceLink(ownerInfo?.image ?? ''), + profile_img_url: resolveIPFSLinkFromURL(ownerInfo?.image ?? ''), link: `${resolveRaribleUserNetwork(chainId as number)}${ownerInfo?.id ?? ''}`, }, } diff --git a/packages/web3-providers/src/zora/index.ts b/packages/web3-providers/src/zora/index.ts index 216507182eed..53f908fddbb0 100644 --- a/packages/web3-providers/src/zora/index.ts +++ b/packages/web3-providers/src/zora/index.ts @@ -6,7 +6,7 @@ import { FungibleTokenDetailed, ERC721TokenDetailed, EthereumTokenType, - resolveIPFSLink, + resolveIPFSLinkFromURL, } from '@masknet/web3-shared-evm' import { NonFungibleTokenAPI } from '..' @@ -14,8 +14,6 @@ import type { ZoraToken, ZoraHistory, ZoraBid, ZoraAsk } from './types' import { getAssetQuery, getTokenHistoryQuery, getBidsQuery, getAsksQuery } from './queries' import { ZORA_MAINNET_GRAPHQL_URL } from './constants' -const isIpfs = (url: string) => url?.startsWith('ipfs://') - function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { const image_url = asset.metadata.json.image ?? asset.metadata.json.animation_url ?? asset.metadata.json.image_url ?? '' @@ -23,7 +21,7 @@ function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { return { is_verified: false, is_auction: asset.currentAuction !== null, - image_url: isIpfs(image_url) ? resolveIPFSLink(image_url.replace(/^ipfs:\/\//, '')) : image_url, + image_url: resolveIPFSLinkFromURL(image_url), asset_contract: { name: asset.tokenContract.name, description: '', @@ -54,7 +52,7 @@ function createNFTAsset(asset: ZoraToken): NonFungibleTokenAPI.Asset { description: asset.metadata.json.description, name: asset.name ?? asset.metadata.json.name, collection_name: '', - animation_url: isIpfs(animation_url) ? resolveIPFSLink(animation_url.replace(/^ipfs:\/\//, '')) : animation_url, + animation_url: resolveIPFSLinkFromURL(animation_url), end_time: asset.currentAuction ? new Date(asset.currentAuction.expiresAt) : null, order_payment_tokens: [] as FungibleTokenDetailed[], offer_payment_tokens: [] as FungibleTokenDetailed[], diff --git a/packages/web3-shared/evm/pipes/index.ts b/packages/web3-shared/evm/pipes/index.ts index e8292c875438..9e247a3caf95 100644 --- a/packages/web3-shared/evm/pipes/index.ts +++ b/packages/web3-shared/evm/pipes/index.ts @@ -179,12 +179,9 @@ export function resolveIPFSLink(ipfs: string): string { return urlcat('https://coldcdn.com/api/cdn/mipfsygtms/ipfs/:ipfs', { ipfs }) } -export function resolveResourceLink(originLink: string): string { - if (!originLink) return '' - if (originLink.startsWith('http') || originLink.startsWith('data')) return originLink - if (originLink.startsWith('ipfs://ipfs/')) return resolveIPFSLink(originLink.replace(/^ipfs:\/\/ipfs\//, '')) - if (originLink.startsWith('ipfs://')) return resolveIPFSLink(decodeURIComponent(originLink).replace('ipfs://', '')) - return resolveIPFSLink(originLink) +export function resolveIPFSLinkFromURL(url: string): string { + if (!url.startsWith('ipfs://')) return url + return resolveIPFSLink(url.replace(/^ipfs:\/\/(ipfs\/)?/, '')) } export function resolveDomainLink(domain?: string) { From 2b79d6ed1834f1e8c65c0fda0576270fd657f5b6 Mon Sep 17 00:00:00 2001 From: Jack Works Date: Fri, 25 Mar 2022 13:29:06 +0800 Subject: [PATCH 14/23] fix: line break (#5950) * fix: line break * Update packages/typed-message/dom/Renderer/utils/renderText.tsx Co-authored-by: UncleBill Co-authored-by: UncleBill --- .../dom/Renderer/utils/renderText.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/typed-message/dom/Renderer/utils/renderText.tsx b/packages/typed-message/dom/Renderer/utils/renderText.tsx index e6277d213eec..c02793d2d2a8 100644 --- a/packages/typed-message/dom/Renderer/utils/renderText.tsx +++ b/packages/typed-message/dom/Renderer/utils/renderText.tsx @@ -34,12 +34,28 @@ export const RenderLinkFragment = memo(function RenderLink( }) function parseText(string: string, Text: NonNullable) { - const links = parseLink(string).flatMap((x, index) => { + const links = parseLink(string).flatMap((x) => { if (x.type === 'text') { - return x.content.split(/(\n)/g).map((x) => (x === '\n' && index !== 0 ?
: )) + return sliceString(x.content).map((x) => (x === '\n' ?
: )) } if (x.category === 'normal' && !x.content.match(/^https?:\/\//gi)) x.content = 'http://' + x.content return }) return links } + +function sliceString(x: string): string[] { + const result: string[] = [] + + let pos = 0 + let index = x.indexOf('\n') + + if (index === -1) return [x] + while (index !== -1) { + result.push(x.slice(pos, index), '\n') + pos = index + 1 + index = x.indexOf('\n', pos) + } + result.push(x.slice(pos)) + return result.filter(Boolean) +} From aad24fae9f040a3615fafd140ae5713217756e7e Mon Sep 17 00:00:00 2001 From: Hancheng Zhou Date: Fri, 25 Mar 2022 15:22:10 +0800 Subject: [PATCH 15/23] fix(mobile): no media viewer (#5925) --- .../Collectible/SNSAdaptor/ArticleTab.tsx | 8 +- .../NFTCardStyledAssetPlayer/index.tsx | 4 +- packages/web3-constants/evm/coingecko.json | 6 +- .../web3-constants/evm/coinmarketcap.json | 3 +- packages/web3-constants/evm/debank.json | 3 +- packages/web3-constants/evm/ethereum.json | 6 +- packages/web3-constants/evm/ito.json | 9 +- .../web3-constants/evm/nft-red-packet.json | 6 +- packages/web3-constants/evm/red-packet.json | 6 +- packages/web3-constants/evm/rpc.json | 6 +- .../evm/token-asset-base-url.json | 3 +- packages/web3-constants/evm/token-list.json | 3 +- packages/web3-constants/evm/token.json | 141 +++++---------- packages/web3-constants/evm/trader.json | 165 ++++++------------ packages/web3-constants/evm/zerion.json | 6 +- 15 files changed, 130 insertions(+), 245 deletions(-) diff --git a/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx b/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx index becbc804961c..de18a192d279 100644 --- a/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx +++ b/packages/mask/src/plugins/Collectible/SNSAdaptor/ArticleTab.tsx @@ -2,6 +2,7 @@ import { makeStyles } from '@masknet/theme' import { CollectibleTab } from './CollectibleTab' import { CollectibleState } from '../hooks/useCollectibleState' import { NFTCardStyledAssetPlayer } from '@masknet/shared' +import { hasNativeAPI } from '../../../../shared/native-rpc' import { useMemo } from 'react' const useStyles = makeStyles()((theme) => ({ @@ -56,11 +57,14 @@ export function ArticleTab(props: ArticleTabProps) { return useMemo(() => { if (!asset.value) return null - const resourceUrl = asset.value.animation_url || asset.value.image_url + const resourceUrl = hasNativeAPI + ? asset.value.image_url || asset.value.animation_url + : asset.value.animation_url || asset.value.image_url return (
- + {/* Todo: Migrate `hasNativeAPI` to `@masknet/shared` to use it in directly. */} +
) diff --git a/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx b/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx index 7a4a6b1d65fe..2aeb6adc0757 100644 --- a/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx +++ b/packages/shared/src/UI/components/NFTCardStyledAssetPlayer/index.tsx @@ -41,6 +41,7 @@ interface Props extends withClasses<'loadingFailImage' | 'iframe' | 'wrapper' | fallbackImage?: URL fallbackResourceLoader?: JSX.Element renderOrder?: number + isNative?: boolean setERC721TokenName?: (name: string) => void setSourceType?: (type: string) => void } @@ -49,6 +50,7 @@ export function NFTCardStyledAssetPlayer(props: Props) { chainId = ChainId.Mainnet, contractAddress = '', tokenId = '', + isNative = false, fallbackImage, fallbackResourceLoader, url, @@ -69,7 +71,7 @@ export function NFTCardStyledAssetPlayer(props: Props) { ? new URL('./nft_token_fallback_dark.png', import.meta.url) : new URL('./nft_token_fallback.png', import.meta.url) - return isImageToken ? ( + return isImageToken || isNative ? (
Date: Fri, 25 Mar 2022 15:59:16 +0800 Subject: [PATCH 16/23] fix: revert constants (#5957) --- packages/web3-constants/evm/coingecko.json | 6 +- .../web3-constants/evm/coinmarketcap.json | 3 +- packages/web3-constants/evm/debank.json | 3 +- packages/web3-constants/evm/ethereum.json | 6 +- packages/web3-constants/evm/ito.json | 9 +- .../web3-constants/evm/nft-red-packet.json | 6 +- packages/web3-constants/evm/red-packet.json | 6 +- packages/web3-constants/evm/rpc.json | 6 +- .../evm/token-asset-base-url.json | 3 +- packages/web3-constants/evm/token-list.json | 3 +- packages/web3-constants/evm/token.json | 141 ++++++++++----- packages/web3-constants/evm/trader.json | 165 ++++++++++++------ packages/web3-constants/evm/zerion.json | 6 +- 13 files changed, 242 insertions(+), 121 deletions(-) diff --git a/packages/web3-constants/evm/coingecko.json b/packages/web3-constants/evm/coingecko.json index 6f3add83afa9..20dbb8910035 100644 --- a/packages/web3-constants/evm/coingecko.json +++ b/packages/web3-constants/evm/coingecko.json @@ -17,7 +17,8 @@ "Celo": "celo", "Fantom": "fantom", "Aurora": "aurora", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "COIN_ID": { "Mainnet": "ethereum", @@ -37,6 +38,7 @@ "Celo": "celo", "Fantom": "fantom", "Aurora": "ethereum", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "conflux-token" } } diff --git a/packages/web3-constants/evm/coinmarketcap.json b/packages/web3-constants/evm/coinmarketcap.json index ffd32861a9a2..44f07aaa4b88 100644 --- a/packages/web3-constants/evm/coinmarketcap.json +++ b/packages/web3-constants/evm/coinmarketcap.json @@ -17,6 +17,7 @@ "Celo": "5567", "Fantom": "3513", "Aurora": "1313161554", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" } } diff --git a/packages/web3-constants/evm/debank.json b/packages/web3-constants/evm/debank.json index 070df0c683df..f4ba365239c1 100644 --- a/packages/web3-constants/evm/debank.json +++ b/packages/web3-constants/evm/debank.json @@ -17,6 +17,7 @@ "Celo": "celo", "Fantom": "ftm", "Aurora": "aurora", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" } } diff --git a/packages/web3-constants/evm/ethereum.json b/packages/web3-constants/evm/ethereum.json index f4ca94106031..4e4fefb89d3b 100644 --- a/packages/web3-constants/evm/ethereum.json +++ b/packages/web3-constants/evm/ethereum.json @@ -17,7 +17,8 @@ "Celo": "0x8e28F1d64ceD52b9A09aB1AA3071Aa3c05802d1F", "Fantom": "0xc119574d5fb333f5ac018658d4d8b5035e16bf39", "Aurora": "0xC119574D5Fb333F5AC018658D4d8b5035E16bf39", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MULTICALL_ADDRESS": { "Mainnet": "0x1F98415757620B543A52E61c46B32eB19261F984", @@ -37,7 +38,8 @@ "Celo": "0x072453AdEC16cFC7FB6Af1517c3f25407180cccC", "Fantom": "0x913975af2Bb8a6Be4100D7dc5e9765B77F6A5d6c", "Aurora": "0x6cc1b1058F9153358278C35E0b2D382f1585854B", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "0x19f179d7e0d7d9f9d5386afff64271d98a91615b" }, "ENS_REGISTRAR_ADDRESS": { "Mainnet": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", diff --git a/packages/web3-constants/evm/ito.json b/packages/web3-constants/evm/ito.json index f0cbea49edfb..f15c7c3a47e6 100644 --- a/packages/web3-constants/evm/ito.json +++ b/packages/web3-constants/evm/ito.json @@ -57,7 +57,8 @@ "Celo": "0xaA5bfd7355637eA7405CB194a55303e821c4c569", "Fantom": "0x981be454a930479d92C91a0092D204b64845A5D6", "Aurora": "0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77", - "Aurora_Testnet": "0xdcA6F476EebCDE8FE8b072e3fC80dBC28dC209b3" + "Aurora_Testnet": "0xdcA6F476EebCDE8FE8b072e3fC80dBC28dC209b3", + "Conflux": "0x066804d9123bf2609ed4a4a40b1177a9c5a9ed51" }, "ITO2_CONTRACT_CREATION_BLOCK_HEIGHT": { "Mainnet": 12766513, @@ -77,7 +78,8 @@ "Celo": 10278776, "Fantom": 25071597, "Aurora": 57350598, - "Aurora_Testnet": 77919102 + "Aurora_Testnet": 77919102, + "Conflux": 37722805 }, "DEFAULT_QUALIFICATION_ADDRESS": { "Mainnet": "0x81b6ae377e360dcad63611846a2516f4ba8c88ac", @@ -117,7 +119,8 @@ "Celo": "0x2cB220F925E603A04BEE05F210252120deBA29d7", "Fantom": "0x83D6b366f21e413f214EB077D5378478e71a5eD2", "Aurora": "0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "0x05ee315e407c21a594f807d61d6cc11306d1f149" }, "SUBGRAPH_URL": { "Mainnet": "https://api.thegraph.com/subgraphs/name/dimensiondev/mask-ito-mainnet", diff --git a/packages/web3-constants/evm/nft-red-packet.json b/packages/web3-constants/evm/nft-red-packet.json index 14f892ec49c5..b0457542eee0 100644 --- a/packages/web3-constants/evm/nft-red-packet.json +++ b/packages/web3-constants/evm/nft-red-packet.json @@ -17,7 +17,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x05ee315E407C21a594f807D61d6CC11306D1F149", - "Aurora_Testnet": "0x97369fEE7db34E0BfE47861f2ec44b4378d13eB4" + "Aurora_Testnet": "0x97369fEE7db34E0BfE47861f2ec44b4378d13eB4", + "Conflux": "0x5b966f3a32db9c180843bcb40267a66b73e4f022" }, "SUBGRAPH_URL": { "Mainnet": "https://api.thegraph.com/subgraphs/name/dimensiondev/mask-nft-red-packet-mainnet", @@ -37,6 +38,7 @@ "Celo": "", "Fantom": "", "Aurora": "https://api.thegraph.com/subgraphs/name/dimensiondev/mask-nft-red-packet-aurora", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" } } diff --git a/packages/web3-constants/evm/red-packet.json b/packages/web3-constants/evm/red-packet.json index d587717e2cd6..f88e4a77a16d 100644 --- a/packages/web3-constants/evm/red-packet.json +++ b/packages/web3-constants/evm/red-packet.json @@ -77,7 +77,8 @@ "Celo": "0xAb7B1bE4233A04e5C43a810E75657ECED8E5463B", "Fantom": "0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98", "Aurora": "0x19f179D7e0D7d9F9d5386afFF64271D98A91615B", - "Aurora_Testnet": "0xdB93cCd481012bB5D1E2c8d0aF7C5f2940c00fdC" + "Aurora_Testnet": "0xdB93cCd481012bB5D1E2c8d0aF7C5f2940c00fdC", + "Conflux": "0x96c7d011cdfd467f551605f0f5fce279f86f4186" }, "HAPPY_RED_PACKET_ADDRESS_V4_BLOCK_HEIGHT": { "Mainnet": 12939427, @@ -97,7 +98,8 @@ "Celo": 10413552, "Fantom": 25112473, "Aurora": 57552338, - "Aurora_Testnet": 77918765 + "Aurora_Testnet": 77918765, + "Conflux": 37670572 }, "SUBGRAPH_URL": { "Mainnet": "https://api.thegraph.com/subgraphs/name/dimensiondev/mask-red-packet-mainnet", diff --git a/packages/web3-constants/evm/rpc.json b/packages/web3-constants/evm/rpc.json index 54cfb9185c13..5bd061c414bb 100644 --- a/packages/web3-constants/evm/rpc.json +++ b/packages/web3-constants/evm/rpc.json @@ -59,7 +59,8 @@ "Celo": ["https://forno.celo.org"], "Fantom": ["https://rpc.ftm.tools/"], "Aurora": ["https://mainnet.aurora.dev"], - "Aurora_Testnet": ["https://testnet.aurora.dev"] + "Aurora_Testnet": ["https://testnet.aurora.dev"], + "Conflux": ["https://evm.confluxrpc.com"] }, "RPC_WEIGHTS": { "Mainnet": [0, 1, 2, 3, 4], @@ -79,6 +80,7 @@ "Celo": [0, 0, 0, 0, 0], "Fantom": [0, 0, 0, 0, 0], "Aurora": [0, 0, 0, 0, 0], - "Aurora_Testnet": [0, 0, 0, 0, 0] + "Aurora_Testnet": [0, 0, 0, 0, 0], + "Conflux": [0, 0, 0, 0, 0] } } diff --git a/packages/web3-constants/evm/token-asset-base-url.json b/packages/web3-constants/evm/token-asset-base-url.json index 994c1a1189ae..79acb11afe4d 100644 --- a/packages/web3-constants/evm/token-asset-base-url.json +++ b/packages/web3-constants/evm/token-asset-base-url.json @@ -47,6 +47,7 @@ "Celo": [], "Fantom": [], "Aurora": [], - "Aurora_Testnet": [] + "Aurora_Testnet": [], + "Conflux": [] } } diff --git a/packages/web3-constants/evm/token-list.json b/packages/web3-constants/evm/token-list.json index 76b7b8870aee..15193e2a83fb 100644 --- a/packages/web3-constants/evm/token-list.json +++ b/packages/web3-constants/evm/token-list.json @@ -17,6 +17,7 @@ "Celo": ["https://tokens.r2d2.to/latest/42220/tokens.json"], "Fantom": ["https://tokens.r2d2.to/latest/250/tokens.json"], "Aurora": ["https://tokens.r2d2.to/latest/1313161554/tokens.json"], - "Aurora_Testnet": [] + "Aurora_Testnet": [], + "Conflux": ["https://tokens.r2d2.to/latest/1030/tokens.json"] } } diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index f6fe2360d0d4..df67190f8364 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -17,7 +17,8 @@ "Celo": "0x471EcE3750Da237f93B8E339c536989b8978a438", "Fantom": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83", "Aurora": "0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "USDC_ADDRESS": { "Mainnet": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", @@ -37,7 +38,8 @@ "Celo": "0x2A3684e9Dc20B857375EA04235F2F7edBe818FA7", "Fantom": "0x04068da6c83afcfa0e13ba15a6696662335d5b75", "Aurora": "0xb12bfca5a55806aaf64e99521918a4bf0fc40802", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "USDT_ADDRESS": { "Mainnet": "0xdAC17F958D2ee523a2206206994597C13D831ec7", @@ -57,7 +59,8 @@ "Celo": "0xb020d981420744f6b0fedd22bb67cd37ce18a1d5", "Fantom": "", "Aurora": "0x4988a896b1227218e4a686fde5eabdcabd91571f", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "HUSD_ADDRESS": { "Mainnet": "0xdf574c24545e5ffecb9a659c229253d4111d87e1", @@ -77,7 +80,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BUSD_ADDRESS": { "Mainnet": "0x4fabb145d64652a948d72533023f6e7a623c7c53", @@ -97,7 +101,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "COMP_ADDRESS": { "Mainnet": "0xc00e94Cb662C3520282E6f5717214004A7f26888", @@ -117,7 +122,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "EASY_ADDRESS": { "Mainnet": "", @@ -137,7 +143,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MKR_ADDRESS": { "Mainnet": "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2", @@ -157,7 +164,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MASK_ADDRESS": { "Mainnet": "0x69af81e73A73B40adF4f3d4223Cd9b1ECE623074", @@ -177,7 +185,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MSKA_ADDRESS": { "Mainnet": "", @@ -197,7 +206,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MSKB_ADDRESS": { "Mainnet": "", @@ -217,7 +227,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MSKC_ADDRESS": { "Mainnet": "", @@ -237,7 +248,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MSKD_ADDRESS": { "Mainnet": "", @@ -257,7 +269,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MSKE_ADDRESS": { "Mainnet": "", @@ -277,7 +290,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "DAI_ADDRESS": { "Mainnet": "0x6B175474E89094C44Da98b954EedeAC495271d0F", @@ -297,7 +311,8 @@ "Celo": "", "Fantom": "0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E", "Aurora": "0xe3520349f477a5f6eb06107066048508498a291b", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "AMPL_ADDRESS": { "Mainnet": "0xD46bA6D942050d489DBd938a2C909A5d5039A161", @@ -317,7 +332,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "OKB_ADDRESS": { "Mainnet": "0x75231F58b43240C9718Dd58B4967c5114342a86c", @@ -337,7 +353,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UST_ADDRESS": { "Mainnet": "0xa47c8bf37f92aBed4A126BDA807A7b7498661acD", @@ -357,7 +374,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "eUSDC_ADDRESS": { "Mainnet": "", @@ -377,7 +395,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "eUSDT_ADDRESS": { "Mainnet": "", @@ -397,7 +416,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "fUSDT_ADDRESS": { "Mainnet": "", @@ -417,7 +437,8 @@ "Celo": "", "Fantom": "0x049d68029688eAbF473097a2fC38ef61633A3C7A", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "eDAI_ADDRESS": { "Mainnet": "", @@ -437,7 +458,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNITOKEN_ADDRESS": { "Mainnet": "", @@ -457,7 +479,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TT01_ADDRESS": { "Mainnet": "", @@ -477,7 +500,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TT02_ADDRESS": { "Mainnet": "", @@ -497,7 +521,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "QUICK_ADDRESS": { "Mainnet": "", @@ -517,7 +542,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WANNA_ADDRESS": { "Mainnet": "", @@ -537,7 +563,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x7faA64Faf54750a2E3eE621166635fEAF406Ab22", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WBTC_ADDRESS": { "Mainnet": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", @@ -557,7 +584,8 @@ "Celo": "0xBe50a3013A1c94768A1ABb78c3cB79AB28fc1aCE", "Fantom": "0x321162Cd933E2Be498Cd2267a90534A804051b11", "Aurora": "0xf4eb217ba2454613b15dbdea6e5f22276410e89e", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "IGG_ADDRESS": { "Mainnet": "", @@ -577,7 +605,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "OM_ADDRESS": { "Mainnet": "", @@ -597,7 +626,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SUSHI_ADDRESS": { "Mainnet": "0x6B3595068778DD592e39A122f4f5a5cF09C90fE2", @@ -617,7 +647,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "YAM_ADDRESS": { "Mainnet": "0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16", @@ -637,7 +668,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "RUNE_ADDRESS": { "Mainnet": "0x3155BA85D5F96b2d030a4966AF206230e46849cb", @@ -657,7 +689,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "YFI_ADDRESS": { "Mainnet": "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e", @@ -677,7 +710,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "sUSD_ADDRESS": { "Mainnet": "0x57ab1ec28d129707052df4df418d58a2d46d5f51", @@ -697,7 +731,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BTCB_ADDRESS": { "Mainnet": "", @@ -717,7 +752,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "CAKE_ADDRESS": { "Mainnet": "", @@ -737,7 +773,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "maUSDC_ADDRESS": { "Mainnet": "", @@ -757,7 +794,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "stETH_ADDRESS": { "Mainnet": "0xDFe66B14D37C77F4E9b180cEb433d1b164f0281D", @@ -777,7 +815,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "NFTX_ADDRESS": { "Mainnet": "0x87d73E916D7057945c9BcD8cdd94e42A6F47f776", @@ -797,7 +836,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "cUSD_ADDRESS": { "Mainnet": "", @@ -817,7 +857,8 @@ "Celo": "0x765de816845861e75a25fca122bb6898b8b1282a", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "cEUR_ADDRESS": { "Mainnet": "", @@ -837,7 +878,8 @@ "Celo": "0x765de816845861e75a25fca122bb6898b8b1282a", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "xTRI_ADDRESS": { "Mainnet": "", @@ -857,7 +899,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x802119e4e253D5C19aA06A5d567C5a41596D6803", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "JOE_ADDRESS": { "Mainnet": "", @@ -877,7 +920,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PNG_ADDRESS": { "Mainnet": "", @@ -897,7 +941,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "ETHER_ADDRESS": { "Mainnet": "", @@ -917,7 +962,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "NATIVE_TOKEN_ADDRESS": { "Mainnet": "0x0000000000000000000000000000000000000000", @@ -937,6 +983,7 @@ "Celo": "0x471ece3750da237f93b8e339c536989b8978a438", "Fantom": "0x0000000000000000000000000000000000000000", "Aurora": "0x0000000000000000000000000000000000000000", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "0x0000000000000000000000000000000000000000" } } diff --git a/packages/web3-constants/evm/trader.json b/packages/web3-constants/evm/trader.json index be8dcb28d3fb..e8cac04eca46 100644 --- a/packages/web3-constants/evm/trader.json +++ b/packages/web3-constants/evm/trader.json @@ -17,7 +17,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V2_FACTORY_ADDRESS": { "Mainnet": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", @@ -37,7 +38,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V2_THEGRAPH": { "Mainnet": "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2", @@ -57,7 +59,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V2_INIT_CODE_HASH": { "Mainnet": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", @@ -77,7 +80,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_SWAP_ROUTER_ADDRESS": { "Mainnet": "0xe592427a0aece92de3edee1f18e0157c05861564", @@ -97,7 +101,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V3_FACTORY_ADDRESS": { "Mainnet": "0x1F98431c8aD98523631AE4a59f267346ea31F984", @@ -117,7 +122,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V3_QUOTER_ADDRESS": { "Mainnet": "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6", @@ -137,7 +143,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V3_THEGRAPH": { "Mainnet": "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3", @@ -157,7 +164,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "UNISWAP_V3_INIT_CODE_HASH": { "Mainnet": "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54", @@ -177,7 +185,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SUSHISWAP_ROUTER_ADDRESS": { "Mainnet": "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F", @@ -197,7 +206,8 @@ "Celo": "0x1421bDe4B10e8dd459b3BCb598810B1337D56842", "Fantom": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", "Aurora": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SUSHISWAP_FACTORY_ADDRESS": { "Mainnet": "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac", @@ -217,7 +227,8 @@ "Celo": "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", "Fantom": "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SUSHISWAP_THEGRAPH": { "Mainnet": "https://api.thegraph.com/subgraphs/name/zippoxer/sushiswap-subgraph-fork", @@ -237,7 +248,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SUSHISWAP_INIT_CODE_HASH": { "Mainnet": "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", @@ -257,7 +269,8 @@ "Celo": "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", "Fantom": "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SASHIMISWAP_ROUTER_ADDRESS": { "Mainnet": "0xe4fe6a45f354e845f954cddee6084603cedb9410", @@ -277,7 +290,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SASHIMISWAP_FACTORY_ADDRESS": { "Mainnet": "0xF028F723ED1D0fE01cC59973C49298AA95c57472", @@ -297,7 +311,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SASHIMISWAP_THEGRAPH": { "Mainnet": "https://api.thegraph.com/subgraphs/name/sashimiproject/sashimi", @@ -317,7 +332,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "SASHIMISWAP_INIT_CODE_HASH": { "Mainnet": "0xb465bbe4edb8c9b0da8ff0b2b36ce0065de9fcd5a33f32c6856ea821779c8b72", @@ -337,7 +353,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "QUICKSWAP_ROUTER_ADDRESS": { "Mainnet": "", @@ -357,7 +374,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "QUICKSWAP_FACTORY_ADDRESS": { "Mainnet": "", @@ -377,7 +395,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "QUICKSWAP_THEGRAPH": { "Mainnet": "", @@ -397,7 +416,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "QUICKSWAP_INIT_CODE_HASH": { "Mainnet": "", @@ -417,7 +437,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANCAKESWAP_ROUTER_ADDRESS": { "Mainnet": "", @@ -437,7 +458,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANCAKESWAP_FACTORY_ADDRESS": { "Mainnet": "", @@ -457,7 +479,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANCAKESWAP_THEGRAPH": { "Mainnet": "", @@ -477,7 +500,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANCAKESWAP_INIT_CODE_HASH": { "Mainnet": "", @@ -497,7 +521,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BALANCER_ETH_ADDRESS": { "Mainnet": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", @@ -517,7 +542,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BALANCER_EXCHANGE_PROXY_ADDRESS": { "Mainnet": "0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21", @@ -537,7 +563,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BALANCER_POOLS_URL": { "Mainnet": "https://ipfs.fleek.co/ipns/balancer-bucket.storage.fleek.co/balancer-exchange/pools", @@ -557,7 +584,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "DODO_ETH_ADDRESS": { "Mainnet": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", @@ -577,7 +605,8 @@ "Celo": "", "Fantom": "", "Aurora": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "DODO_EXCHANGE_PROXY_ADDRESS": { "Mainnet": "0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149", @@ -597,7 +626,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BANCOR_ETH_ADDRESS": { "Mainnet": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", @@ -617,7 +647,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "BANCOR_EXCHANGE_PROXY_ADDRESS": { "Mainnet": "0x2F9EC37d6CcFFf1caB21733BdaDEdE11c823cCB0", @@ -637,7 +668,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRADERJOE_ROUTER_ADDRESS": { "Mainnet": "", @@ -657,7 +689,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRADERJOE_FACTORY_ADDRESS": { "Mainnet": "", @@ -677,7 +710,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRADERJOE_THEGRAPH": { "Mainnet": "https://api.thegraph.com/subgraphs/name/traderjoe-xyz/exchange", @@ -697,7 +731,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRADERJOE_INIT_CODE_HASH": { "Mainnet": "", @@ -717,7 +752,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "OPENOCEAN_ETH_ADDRESS": { "Mainnet": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", @@ -737,7 +773,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "OPENOCEAN_EXCHANGE_PROXY_ADDRESS": { "Mainnet": "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64", @@ -757,7 +794,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANGOLIN_ROUTER_ADDRESS": { "Mainnet": "", @@ -777,7 +815,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANGOLIN_FACTORY_ADDRESS": { "Mainnet": "", @@ -797,7 +836,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANGOLIN_THEGRAPH": { "Mainnet": "", @@ -817,7 +857,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "PANGOLIN_INIT_CODE_HASH": { "Mainnet": "", @@ -837,7 +878,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WANNASWAP_ROUTER_V2_ADDRESS": { "Mainnet": "", @@ -857,7 +899,8 @@ "Celo": "", "Fantom": "", "Aurora": "0xa3a1eF5Ae6561572023363862e238aFA84C72ef5", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WANNASWAP_ROUTER_ADDRESS": { "Mainnet": "", @@ -877,7 +920,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x8f1E0Cf0f9f269Bc977C38635E560aa5b0E63323", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WANNASWAP_FACTORY_ADDRESS": { "Mainnet": "", @@ -897,7 +941,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x7928D4FeA7b2c90C732c10aFF59cf403f0C38246", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WANNASWAP_THEGRAPH": { "Mainnet": "", @@ -917,7 +962,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "WANNASWAP_INIT_CODE_HASH": { "Mainnet": "", @@ -937,7 +983,8 @@ "Celo": "", "Fantom": "", "Aurora": "0xa06b8b0642cf6a9298322d0c8ac3c68c291ca24dc66245cf23aa2abc33b57e21", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRISOLARIS_ROUTER_ADDRESS": { "Mainnet": "", @@ -957,7 +1004,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x2CB45Edb4517d5947aFdE3BEAbF95A582506858B", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRISOLARIS_FACTORY_ADDRESS": { "Mainnet": "", @@ -977,7 +1025,8 @@ "Celo": "", "Fantom": "", "Aurora": "0xc66F594268041dB60507F00703b152492fb176E7", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRISOLARIS_THEGRAPH": { "Mainnet": "", @@ -997,7 +1046,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRISOLARIS_INIT_CODE_HASH": { "Mainnet": "", @@ -1017,7 +1067,8 @@ "Celo": "", "Fantom": "", "Aurora": "0x754e1d90e536e4c1df81b7f030f47b4ca80c87120e145c294f098c83a6cb5ace", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MDEX_ROUTER_ADDRESS": { "Mainnet": "0x74119c3bca85bEA0538A62319a79b4a372590B47", @@ -1037,7 +1088,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MDEX_FACTORY_ADDRESS": { "Mainnet": "0x7DAe51BD3E3376B8c7c4900E9107f12Be3AF1bA8", @@ -1057,7 +1109,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MDEX_THEGRAPH": { "Mainnet": "", @@ -1077,7 +1130,8 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "MDEX_INIT_CODE_HASH": { "Mainnet": "0x8ecc069c645df696f2ca5116ab459c5c2889f299e73c1b208aaa3cdd7d110b16", @@ -1097,6 +1151,7 @@ "Celo": "", "Fantom": "", "Aurora": "", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" } } diff --git a/packages/web3-constants/evm/zerion.json b/packages/web3-constants/evm/zerion.json index e0d70150b37f..7ccce157682d 100644 --- a/packages/web3-constants/evm/zerion.json +++ b/packages/web3-constants/evm/zerion.json @@ -17,7 +17,8 @@ "Celo": "celo-assets", "Fantom": "fantom-assets", "Aurora": "aurora-assets", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" }, "TRANSACTIONS_SCOPE_NAME": { "Mainnet": "transactions", @@ -37,6 +38,7 @@ "Celo": "celo-transactions", "Fantom": "fantom-transactions", "Aurora": "aurora-transactions", - "Aurora_Testnet": "" + "Aurora_Testnet": "", + "Conflux": "" } } From 1c5c249136ee29b32f3cb456966c5db425aa270a Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Fri, 25 Mar 2022 22:33:16 +0800 Subject: [PATCH 17/23] fix: persona db overwrite bug (#5964) --- packages/mask/background/services/crypto/decryption.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/mask/background/services/crypto/decryption.ts b/packages/mask/background/services/crypto/decryption.ts index 3ef71f695f44..f12ea89391f3 100644 --- a/packages/mask/background/services/crypto/decryption.ts +++ b/packages/mask/background/services/crypto/decryption.ts @@ -23,6 +23,7 @@ import { } from '@masknet/shared-base' import type { TypedMessage } from '@masknet/typed-message' import { noop } from 'lodash-unified' +import { queryProfileDB, queryPersonaDB } from '../../database/persona/db' import { createProfileWithPersona, decryptByLocalKey, @@ -225,6 +226,12 @@ async function storeAuthorPublicKey( if (pub.algr !== EC_KeyCurveEnum.secp256k1) { throw new Error('TODO: support other curves') } + + // if privateKey, we should possibly not recreate it + const profile = await queryProfileDB(payloadAuthor) + const persona = profile?.linkedPersona ? await queryPersonaDB(profile.linkedPersona) : undefined + if (persona?.privateKey) return + return createProfileWithPersona( payloadAuthor, { connectionConfirmState: 'confirmed' }, From 20df11ce3da99062b82d7b8b69619dcbc3c86bb0 Mon Sep 17 00:00:00 2001 From: Lantt Date: Fri, 25 Mar 2022 22:34:39 +0800 Subject: [PATCH 18/23] fix: hyper proxy r2d2 route not work on cloudflare (#5955) * fix: workaround, change hyper proxy url * fix: nftscan api * chore: remove debug code * fix: nftscan api Co-authored-by: zhouhanseng --- packages/web3-providers/src/NFTScan/index.ts | 6 ++++-- packages/web3-shared/base/src/proxy/index.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/web3-providers/src/NFTScan/index.ts b/packages/web3-providers/src/NFTScan/index.ts index fc96ac0fee3e..e1dc4b639600 100644 --- a/packages/web3-providers/src/NFTScan/index.ts +++ b/packages/web3-providers/src/NFTScan/index.ts @@ -66,7 +66,9 @@ function createERC721TokenAsset(asset: NFTScanAsset) { { name: payload?.name ?? asset.nft_name ?? asset.nft_platform_name ?? '', description: payload?.description ?? '', - mediaUrl: resolveIPFSLinkFromURL(asset.nft_cover ?? asset.nft_content_uri ?? payload.image ?? ''), + mediaUrl: resolveIPFSLinkFromURL( + JSON.parse(asset.nft_json ?? '{}').image ?? asset.nft_content_uri ?? payload.image ?? '', + ), owner: asset.nft_holder ?? '', }, asset.token_id, @@ -155,7 +157,7 @@ export class NFTScanAPI implements NonFungibleTokenAPI.Provider { info: { name: t.nft_name, description: t.nft_detail, - mediaUrl: resolveIPFSLinkFromURL(t.nft_cover ?? t.nft_content_uri ?? ''), + mediaUrl: resolveIPFSLinkFromURL(JSON.parse(t.nft_json ?? '{}').image ?? t.nft_content_uri ?? ''), tokenURI: t.nft_token_uri, }, })) diff --git a/packages/web3-shared/base/src/proxy/index.ts b/packages/web3-shared/base/src/proxy/index.ts index 74b4ded352f8..85ff04bdecf9 100644 --- a/packages/web3-shared/base/src/proxy/index.ts +++ b/packages/web3-shared/base/src/proxy/index.ts @@ -160,7 +160,7 @@ export class ProviderProxy { const SOCKET_POINT = // workaround, should create a stage env for QA testing process.env.NODE_ENV === 'production' && process.env.channel === 'stable' - ? 'wss://hyper-proxy.r2d2.to' + ? 'wss://hyper-proxy-production.mask-reverse-proxy.workers.dev' : 'wss://hyper-proxy-development.mask-reverse-proxy.workers.dev' enum SocketState { From d2b29bf4377cfdd45b150ac6b7a92bd2c92ec127 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Fri, 25 Mar 2022 22:46:10 +0800 Subject: [PATCH 19/23] fix: bsc to bnb (#5965) --- .../src/plugins/EVM/UI/Web3State/getAssetsFn.ts | 17 ++--------------- packages/mask/src/plugins/Wallet/apis/debank.ts | 7 ++++++- packages/plugins/CyberConnect/src/base.tsx | 1 + packages/web3-providers/src/debank/index.ts | 8 +++++++- packages/web3-shared/evm/assets/chains.json | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts b/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts index 79e99824cf38..69f40729cae1 100644 --- a/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts +++ b/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts @@ -38,7 +38,6 @@ export const getFungibleAssetsFn = async (address: string, providerType: string, network: Web3Plugin.NetworkDescriptor, pagination?: Pagination) => { const chainId = context.chainId.getCurrentValue() const wallet = context.wallets.getCurrentValue().find((x) => isSameAddress(x.address, address)) - const socket = await context.providerSocket const networks = PLUGIN_NETWORKS const trustedTokens = uniqBy( context.erc20Tokens @@ -51,19 +50,7 @@ export const getFungibleAssetsFn = createExternalProvider(context.request, context.getSendOverrides, context.getRequestOptions), ) const { BALANCE_CHECKER_ADDRESS } = getEthereumConstants(chainId) - const socketId = `mask.fetchFungibleTokenAsset_${address}` - let dataFromProvider = await socket.sendAsync>({ - id: socketId, - method: 'mask.fetchFungibleTokenAsset', - params: { - address: address, - pageSize: 10000, - }, - }) - if (!dataFromProvider.length) { - // @ts-ignore getAssetList Asset[] - dataFromProvider = await context.getAssetsList(address, FungibleAssetProvider.DEBANK) - } + const dataFromProvider = await context.getAssetsList(address, FungibleAssetProvider.DEBANK) const assetsFromProvider: Web3Plugin.Asset[] = dataFromProvider.map((x) => ({ id: x.token.address, chainId: x.token.chainId, @@ -108,7 +95,7 @@ export const getFungibleAssetsFn = const assetFromChain = balanceList.map( (balance, idx): Web3Plugin.Asset => ({ id: trustedTokens[idx].address, - chainId: chainId, + chainId, token: { ...trustedTokens[idx], id: trustedTokens[idx].address, diff --git a/packages/mask/src/plugins/Wallet/apis/debank.ts b/packages/mask/src/plugins/Wallet/apis/debank.ts index 47144aed6f31..e72fdc67de63 100644 --- a/packages/mask/src/plugins/Wallet/apis/debank.ts +++ b/packages/mask/src/plugins/Wallet/apis/debank.ts @@ -17,7 +17,12 @@ export async function getAssetsList(address: string) { `${DEBANK_OPEN_API}/v1/user/token_list?is_all=true&has_balance=true&id=${address.toLowerCase()}`, ) try { - return ((await response.json()) ?? []) as WalletTokenRecord[] + const records = ((await response.json()) ?? []) as WalletTokenRecord[] + return records.map((x) => ({ + ...x, + id: x.id === 'bsc' ? 'bnb' : x.id, + chain: x.chain === 'bsc' ? 'bnb' : x.chain, + })) } catch { return [] } diff --git a/packages/plugins/CyberConnect/src/base.tsx b/packages/plugins/CyberConnect/src/base.tsx index f299ed33c3aa..4d9b8121ffd9 100644 --- a/packages/plugins/CyberConnect/src/base.tsx +++ b/packages/plugins/CyberConnect/src/base.tsx @@ -2,6 +2,7 @@ import { Plugin, NetworkPluginID } from '@masknet/plugin-infra' import { ChainId } from '@masknet/web3-shared-evm' import { CYBERCONNECT_PLUGIN_ID } from './constants' import { CyberConnectIcon } from './assets/CyberConnectIcon' + export const base: Plugin.Shared.Definition = { ID: CYBERCONNECT_PLUGIN_ID, icon: , diff --git a/packages/web3-providers/src/debank/index.ts b/packages/web3-providers/src/debank/index.ts index aec25c572722..80c860c77f17 100644 --- a/packages/web3-providers/src/debank/index.ts +++ b/packages/web3-providers/src/debank/index.ts @@ -14,7 +14,13 @@ export async function getAssetListFromDebank(address: string) { ) try { const result = ((await response.json()) ?? []) as WalletTokenRecord[] - return formatAssets(result) + return formatAssets( + result.map((x) => ({ + ...x, + id: x.id === 'bsc' ? 'bnb' : x.id, + chain: x.chain === 'bsc' ? 'bnb' : x.chain, + })), + ) } catch { return [] } diff --git a/packages/web3-shared/evm/assets/chains.json b/packages/web3-shared/evm/assets/chains.json index 4f3e7530cc3a..7e8b9f9c89d7 100644 --- a/packages/web3-shared/evm/assets/chains.json +++ b/packages/web3-shared/evm/assets/chains.json @@ -151,7 +151,7 @@ "chainId": 97, "fullName": "Binance", "shortName": "bnbt", - "chain": "BSC", + "chain": "BNB Chain", "network": "chapel", "networkId": 97, "nativeCurrency": { From 7e3b31393ac10df0f353fc060b125a12c7be3eac Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Fri, 25 Mar 2022 23:47:08 +0800 Subject: [PATCH 20/23] fix: persona db override (#5966) --- packages/mask/background/services/crypto/decryption.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/mask/background/services/crypto/decryption.ts b/packages/mask/background/services/crypto/decryption.ts index f12ea89391f3..046c4daa8d44 100644 --- a/packages/mask/background/services/crypto/decryption.ts +++ b/packages/mask/background/services/crypto/decryption.ts @@ -16,6 +16,8 @@ import { } from '@masknet/encryption' import { AESCryptoKey, + ECKeyIdentifierFromJsonWebKey, + EC_JsonWebKey, EC_Public_JsonWebKey, IdentifierMap, PostIVIdentifier, @@ -232,6 +234,10 @@ async function storeAuthorPublicKey( const persona = profile?.linkedPersona ? await queryPersonaDB(profile.linkedPersona) : undefined if (persona?.privateKey) return + const key = (await crypto.subtle.exportKey('jwk', pub.key)) as EC_JsonWebKey + const otherPersona = await queryPersonaDB(ECKeyIdentifierFromJsonWebKey(key)) + if (otherPersona?.privateKey) return + return createProfileWithPersona( payloadAuthor, { connectionConfirmState: 'confirmed' }, From 42a3f94cac7ba703bced8a55d60f163e9a4be504 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:56:07 +0800 Subject: [PATCH 21/23] fix: twitter image (#5967) * fix: twitter image payload & avatar * fix: lint error --- packages/injected-script/main/EventListenerPatch/capture.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/injected-script/main/EventListenerPatch/capture.ts b/packages/injected-script/main/EventListenerPatch/capture.ts index 796d1e8f9341..9ddec65f8fc2 100644 --- a/packages/injected-script/main/EventListenerPatch/capture.ts +++ b/packages/injected-script/main/EventListenerPatch/capture.ts @@ -81,7 +81,7 @@ export function dispatchEventRaw( overwrites: Partial = {}, ) { let currentTarget: null | Node | Document = target - const event = getMockedEvent(eventBase, () => currentTarget!, overwrites) + const event = getMockedEvent(eventBase, () => (isTwitter() ? target! : currentTarget!), overwrites) // Note: in firefox, "event" is "Opaque". Displayed as an empty object. const type = eventBase.type if (!CapturingEvents.has(type)) return warn("[@masknet/injected-script] Trying to send event didn't captured.") From e93648b63cfd305be2df06334c44e65aae084bfe Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:57:21 +0800 Subject: [PATCH 22/23] fix: ito entrance (#5968) --- packages/mask/src/components/shared/ApplicationBoard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mask/src/components/shared/ApplicationBoard.tsx b/packages/mask/src/components/shared/ApplicationBoard.tsx index d1bcd990e35b..6df629f5fb51 100644 --- a/packages/mask/src/components/shared/ApplicationBoard.tsx +++ b/packages/mask/src/components/shared/ApplicationBoard.tsx @@ -234,7 +234,7 @@ export function ApplicationBoard({ secondEntries, secondEntryChainTabs }: MaskAp // Todo: remove this after refactor applicationBoard const isITOSupportedChain = - ITO_Definition.enableRequirement.web3![NetworkPluginID.PLUGIN_EVM]?.supportedChainIds?.includes(currentChainId) + ITO_Definition.enableRequirement.web3![currentPluginId]?.supportedChainIds?.includes(currentChainId) const firstLevelEntries: MaskAppEntry[] = [ createEntry( From 896b5ca5f1ea6e877fa7c2e1cdd960ce9e64e7e3 Mon Sep 17 00:00:00 2001 From: nuanyang233 Date: Sat, 26 Mar 2022 02:01:40 +0800 Subject: [PATCH 23/23] chore: prettier --- docs/rfc/000-TypedMessage-binary-format.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rfc/000-TypedMessage-binary-format.md b/docs/rfc/000-TypedMessage-binary-format.md index 1e5597753156..c1808057d7d7 100644 --- a/docs/rfc/000-TypedMessage-binary-format.md +++ b/docs/rfc/000-TypedMessage-binary-format.md @@ -62,7 +62,7 @@ type TypedMessageBase = [ type: TypedMessageTypeEnum | String, version: Integer, metadata: Map | Nil, - ...rest: Array + ...rest: Array, ] enum TypedMessageTypeEnum { Tuple = 0,