Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/plugin-infra/src/web3/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ const PluginWeb3Context = createContext<Web3Context<NetworkPluginID>>(EMPTY_OBJE

const PluginsWeb3Context = createContext<Record<NetworkPluginID, Web3Helper.Web3State<NetworkPluginID>>>(null!)

export function PluginIDContextProvider({ value, children }: React.ProviderProps<NetworkPluginID>) {
return <PluginIDContext.Provider value={value}>{children}</PluginIDContext.Provider>
}

export function PluginWeb3ContextProvider<T extends NetworkPluginID>({
pluginID,
value,
children,
}: { pluginID: T } & React.ProviderProps<Web3Context<T>>) {
return <PluginWeb3Context.Provider value={EMPTY_OBJECT} />
return <PluginWeb3Context.Provider value={value} children={children} />
}

export function PluginsWeb3ContextProvider<T extends NetworkPluginID>({
Expand All @@ -30,7 +36,7 @@ export function PluginsWeb3ContextProvider<T extends NetworkPluginID>({
return (
<PluginIDContext.Provider value={pluginID}>
<PluginsWeb3Context.Provider value={value}>
<PluginWeb3Context.Provider value={EMPTY_OBJECT}>{children}</PluginWeb3Context.Provider>
<PluginWeb3Context.Provider value={EMPTY_OBJECT} children={children} />
</PluginsWeb3Context.Provider>
</PluginIDContext.Provider>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
useBlockNumber,
useBlockTimestamp,
useChainId,
useCurrentWeb3NetworkChainId,
useCurrentWeb3NetworkPluginID,
useNetworkType,
useProviderType,
useWeb3Connection,
useWeb3Hub,
useWeb3State,
Expand Down Expand Up @@ -49,7 +52,6 @@ const useStyles = makeStyles()({
})

export function ConsoleContent(props: ConsoleContentProps) {
const { onClose } = props
const { classes } = useStyles()
const { NATIVE_TOKEN_ADDRESS } = useTokenConstants()
const pluginID = useCurrentWeb3NetworkPluginID()
Expand All @@ -58,6 +60,9 @@ export function ConsoleContent(props: ConsoleContentProps) {
const hub = useWeb3Hub()
const account = useAccount()
const chainId = useChainId()
const networkType = useNetworkType()
const providerType = useProviderType()
const chainIdContext = useCurrentWeb3NetworkChainId()
const { value: balance = '0' } = useBalance()
const { value: blockNumber = 0 } = useBlockNumber()
const { value: blockTimestamp = 0 } = useBlockTimestamp()
Expand Down Expand Up @@ -156,6 +161,46 @@ export function ConsoleContent(props: ConsoleContentProps) {
<section className={classes.container}>
<Table size="small">
<TableBody>
<TableRow>
<TableCell>
<Typography variant="body2" whiteSpace="nowrap">
ChainId
</Typography>
</TableCell>
<TableCell>
<Typography variant="body2">{chainId}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Typography variant="body2" whiteSpace="nowrap">
PluginID
</Typography>
</TableCell>
<TableCell>
<Typography variant="body2">{pluginID}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Typography variant="body2" whiteSpace="nowrap">
Network Type
</Typography>
</TableCell>
<TableCell>
<Typography variant="body2">{networkType}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Typography variant="body2" whiteSpace="nowrap">
Provider Type
</Typography>
</TableCell>
<TableCell>
<Typography variant="body2">{providerType}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Typography variant="body2" whiteSpace="nowrap">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { InjectedDialog } from '@masknet/shared'
import { DialogContent } from '@mui/material'
import { ChainId } from '@masknet/web3-shared-evm'
import { NetworkPluginID } from '@masknet/web3-shared-base'
import { PluginIDContextProvider, PluginWeb3ContextProvider } from '@masknet/plugin-infra/web3'
import { ConsoleContent } from './ConsoleContent'
import { useRemoteControlledDialog } from '../../../../../shared-base-ui/src/hooks'
import { PluginDebuggerMessages } from '../../messages'
Expand All @@ -11,7 +14,15 @@ export function ConsoleDialog(props: ConsoleDialogProps) {
return (
<InjectedDialog title="Debugger" fullWidth open={open} onClose={closeDialog}>
<DialogContent>
<ConsoleContent onClose={closeDialog} />
<PluginIDContextProvider value={NetworkPluginID.PLUGIN_EVM}>
<PluginWeb3ContextProvider
pluginID={NetworkPluginID.PLUGIN_EVM}
value={{
chainId: ChainId.Matic,
}}>
<ConsoleContent onClose={closeDialog} />
</PluginWeb3ContextProvider>
</PluginIDContextProvider>
</DialogContent>
</InjectedDialog>
)
Expand Down