Skip to content

Commit

Permalink
fix: type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
guanbinrui committed Nov 22, 2023
1 parent 8139e39 commit e6ada49
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions packages/mask/src/extension/popups/pages/Swap/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect, useMemo } from 'react'
import { SiteAdaptorContextRef } from '@masknet/plugin-infra/dom'
import { AllProviderTradeContext } from '@masknet/plugin-trader'
import { Typography } from '@mui/material'
import { Appearance } from '@masknet/public-api'
import { SharedContextProvider, SwapPageModals } from '@masknet/shared'
import { openWindow } from '@masknet/shared-base-ui'
import { SharedContextProvider, SwapPageModals } from '@masknet/shared'
import { applyMaskColorVars, makeStyles } from '@masknet/theme'
import { ChainContextProvider, DefaultWeb3ContextProvider } from '@masknet/web3-hooks-base'
import { Typography } from '@mui/material'
import { useEffect, useMemo } from 'react'
import { TwitterAdaptor } from '../../../../../shared/site-adaptors/implementations/twitter.com.js'
import { useI18N } from '../../../../utils/index.js'
import { NetworkSelector } from '../../components/NetworkSelector/index.js'
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function SwapPage() {

useEffect(() => {
SiteAdaptorContextRef.value = {
...SiteAdaptorContextRef.value,
...SiteAdaptorContextRef.value!,
share(text) {
const url = TwitterAdaptor.getShareLinkURL!(text)
const width = 700
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/src/site-adaptor-infra/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export async function activateSiteAdaptorUIInner(ui_deferred: SiteAdaptorUI.Defe
Services.Settings.setPluginMinimalModeEnabled(id, enabled)
},
...createPartialSharedUIContext(id, def, signal),
...SiteAdaptorContextRef.value,
...SiteAdaptorContextRef.value!,
}
},
Services.Settings.getPluginMinimalModeEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function CardDialogContent(props: CardDialogContentProps) {
personas={personas}
identity={lastRecognized}
currentPersonaIdentifier={currentIdentifier}
openDashboard={openDashboard?.openDashboard}
openDashboard={context?.openDashboard}
handlerPosition="top-right"
customHint
directTo={PluginID.Avatar}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/NextID/src/hooks/usePersonaSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function usePersonaSign(message?: string, currentIdentifier?: ECKeyIdenti
return useAsyncFn(async () => {
if (!message || !currentIdentifier) return
try {
return await signWithPersona?.signWithPersona?.(SignType.Message, message, currentIdentifier)
return await context?.signWithPersona?.(SignType.Message, message, currentIdentifier)
} catch {
return
}
}, [message, currentIdentifier, signWithPersona?.signWithPersona])
}, [message, currentIdentifier, context?.signWithPersona])
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ export function RedPacket(props: RedPacketProps) {
name: `$${token?.symbol}`,
}),
title: t.lucky_drop(),
share,
share: context?.share,
})
}, [JSON.stringify(token), redPacketContract, payload.rpid, account, share])
}, [JSON.stringify(token), redPacketContract, payload.rpid, account, context?.share])

const onClaimOrRefund = useCallback(async () => {
let hash: string | undefined
Expand Down Expand Up @@ -268,7 +268,7 @@ export function RedPacket(props: RedPacketProps) {
const handleShare = useCallback(() => {
if (!shareText) return
context?.share?.(shareText)
}, [shareText, share])
}, [shareText, context?.share])

const outdated =
listOfStatus.includes(RedPacketStatus.empty) || (!canRefund && listOfStatus.includes(RedPacketStatus.expired))
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/RedPacket/src/SiteAdaptor/RedPacketNft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ export function RedPacketNft({ payload }: RedPacketNftProps) {
name: '',
}),
title: t.lucky_drop(),
share,
share: context?.share,
})
}, [nftRedPacketContract, payload.id, account, share, Hub])
}, [nftRedPacketContract, payload.id, account, context?.share, Hub])

const claim = useCallback(async () => {
const hash = await claimCallback()
Expand Down
18 changes: 9 additions & 9 deletions packages/web3-providers/src/Lens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class LensAPI {
options: {
token: string
followModule?: FollowModuleTypedData
fetcher: <T>(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<T>
fetcher?: <T>(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<T>
},
) {
if (!profileId) return
Expand All @@ -356,7 +356,7 @@ export class LensAPI {
followModule = `followModule: { profileFollowModule: { profileId: "${options.followModule.profileFollowModule.profileId}" } }`
}

const { data } = await options.fetcher<{ data: { follow: LensBaseAPI.Broadcast } }>(LENS_ROOT_API, {
const response = await options.fetcher?.<{ data: { follow: LensBaseAPI.Broadcast } }>(LENS_ROOT_API, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -380,19 +380,19 @@ export class LensAPI {
}),
})

return data.follow
return response?.data.follow
}

async unfollow(
profileId: string,
options: {
token: string
fetcher: <T>(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<T>
fetcher?: <T>(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<T>
},
) {
if (!profileId) return

const { data } = await options.fetcher<{ data: { unfollow: LensBaseAPI.Broadcast } }>(LENS_ROOT_API, {
const response = await options.fetcher?.<{ data: { unfollow: LensBaseAPI.Broadcast } }>(LENS_ROOT_API, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -416,7 +416,7 @@ export class LensAPI {
}),
})

return data.unfollow
return response?.data.unfollow
}

async createFollowTypedData(
Expand Down Expand Up @@ -540,11 +540,11 @@ export class LensAPI {
signature: string,
options?: {
token: string
fetcher: <T>(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<T>
fetcher?: <T>(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<T>
},
) {
if (!id || !options?.token || !signature) return
const { data } = await options.fetcher<{ data: { broadcastOnchain: LensBaseAPI.Broadcast } }>(LENS_ROOT_API, {
const response = await options.fetcher?.<{ data: { broadcastOnchain: LensBaseAPI.Broadcast } }>(LENS_ROOT_API, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -573,7 +573,7 @@ export class LensAPI {
}),
})

return data.broadcastOnchain
return response?.data.broadcastOnchain
}

async queryApprovedModuleAllowanceAmount(
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers/src/Web3/EVM/state/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Message extends MessageState<MessageRequest, MessageResponse> {
PopupsHistory.push(urlcat(PopupRoutes.Wallet, fromState))
} else {
// open the popups window and wait for approval from the user.
await SiteAdaptorContextRef.value.openPopupWindow(route, {
await SiteAdaptorContextRef.value?.openPopupWindow(route, {
source: location.origin,
...fromState,
})
Expand Down

0 comments on commit e6ada49

Please sign in to comment.