Skip to content

Commit

Permalink
fix: bugfix for deploy dialog logic (#8404)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuanyang233 committed Jan 5, 2023
1 parent 34f3f3e commit fe7f45d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export async function getCurrentPersonaIdentifier(): Promise<PersonaIdentifier |
if (personas[0]) currentPersonaIdentifier.value = personas[0].toText()
return personas[0]
}
export async function setCurrentPersonaIdentifier(x: PersonaIdentifier) {
export async function setCurrentPersonaIdentifier(x?: PersonaIdentifier) {
await currentPersonaIdentifier.readyPromise
currentPersonaIdentifier.value = x.toText()
currentPersonaIdentifier.value = x?.toText() ?? ''
MaskMessages.events.ownPersonaChanged.sendToAll(undefined)
}
export async function getPluginMinimalModeEnabled(id: string): Promise<BooleanPreference> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ const Logout = memo(() => {
}
}, [])

const [{ loading }, onLogout] = useAsyncFn(async () => {
const [{ loading, error }, onLogout] = useAsyncFn(async () => {
if (!selectedPersona) return
await Services.Identity.logoutPersona(selectedPersona.identifier)
const currentPersona = await Services.Settings.getCurrentPersonaIdentifier()
if (!currentPersona) {
const lastCreatedPersona = await Services.Identity.queryLastPersonaCreated()
if (lastCreatedPersona) await Services.Settings.setCurrentPersonaIdentifier(lastCreatedPersona)
await Services.Settings.setCurrentPersonaIdentifier(lastCreatedPersona)
}
navigate(PopupRoutes.Personas, { replace: true })
}, [selectedPersona, history])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Icons } from '@masknet/icons'
import { useLastRecognizedIdentity } from '@masknet/plugin-infra/content-script'
import { useCurrentPersonaInformation, useLastRecognizedIdentity } from '@masknet/plugin-infra/content-script'
import { InjectedDialog } from '@masknet/shared'
import type { PersonaInformation } from '@masknet/shared-base'
import { useRemoteControlledDialog } from '@masknet/shared-base-ui'
import { makeStyles } from '@masknet/theme'
import { useWallets } from '@masknet/web3-hooks-base'
import { SmartPayFunder } from '@masknet/web3-providers'
import type { Wallet } from '@masknet/web3-shared-base'
import { isSameAddress, Wallet } from '@masknet/web3-shared-base'
import { DialogContent, CircularProgress } from '@mui/material'
import { Box } from '@mui/system'
import { useMemo, useState } from 'react'
Expand Down Expand Up @@ -42,6 +42,7 @@ export function RouterDialog() {
const { pathname } = useLocation()
const navigate = useNavigate()
const wallets = useWallets()
const currentPersona = useCurrentPersonaInformation()
const [hasAccounts, setHasAccounts] = useState(false)
const [signer, setSigner] = useState<
| {
Expand Down Expand Up @@ -90,6 +91,16 @@ export function RouterDialog() {
return navigate(RoutePaths.InEligibility)
}, [isVerified, wallets, hasAccounts])

useUpdateEffect(() => {
if (
(signer?.signPersona &&
currentPersona?.identifier.publicKeyAsHex !== signer.signPersona.identifier.publicKeyAsHex) ||
(signer?.signWallet && !wallets.some((x) => isSameAddress(x.address, signer.signWallet?.address)))
) {
closeDialog()
}
}, [currentPersona, signer, wallets])

return (
<InjectedDialog
open={open}
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-constants/evm/smart-pay.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"Gorli": "",
"BSC": "",
"BSCT": "",
"Matic": "1000000000000000000",
"Matic": "5000000000000000000",
"Mumbai": "5000000000000000000",
"Arbitrum": "",
"Arbitrum_Rinkeby": "",
Expand Down
5 changes: 2 additions & 3 deletions packages/web3-providers/src/NextID/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import {
NextIDPlatform,
toBase64,
} from '@masknet/shared-base'
import { PROOF_BASE_URL_DEV, PROOF_BASE_URL_PROD, RELATION_SERVICE_URL } from './constants.js'
import { PROOF_BASE_URL_PROD, RELATION_SERVICE_URL } from './constants.js'
import type { NextIDBaseAPI } from '../entry-types.js'
import { fetchJSON, fetchR2D2 } from '../entry-helpers.js'
import { staleNextIDCached } from './helpers.js'
import { fetchSquashed } from '../helpers/fetchSquashed.js'
import { fetch } from '../helpers/fetch.js'

const BASE_URL =
process.env.channel === 'stable' && process.env.NODE_ENV === 'production' ? PROOF_BASE_URL_PROD : PROOF_BASE_URL_DEV
const BASE_URL = PROOF_BASE_URL_PROD

interface CreatePayloadBody {
action: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ export class SmartPayAccountAPI implements AbstractAccountAPI.Provider<NetworkPl
owner,
create2Factory.deriveUntil(contractWallet.initCode, MAX_ACCOUNT_LENGTH),
),
this.getAccountsFromChainbase(chainId, owner),
// this.getAccountsFromChainbase(chainId, owner),
])

return allSettled
.flatMap((x) => (x.status === 'fulfilled' ? x.value : []))
.map((y) => ({
Expand Down

0 comments on commit fe7f45d

Please sign in to comment.