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
1 change: 1 addition & 0 deletions packages/maskbook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@dimensiondev/stego-js": "=0.11.1-20201027083223-8ab41be",
"@ethersproject/address": "^5.0.4",
"@ethersproject/contracts": "^5.0.4",
"@ethersproject/abi": "^5.4.0",
"@ethersproject/networks": "^5.0.4",
"@ethersproject/providers": "^5.0.9",
"@ethersproject/solidity": "^5.0.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/maskbook/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@
"plugin_wallet_on_connect_in_firefox": "Connect",
"plugin_wallet_return_mobile_wallet_options": "Return to Mobile Wallet Options",
"plugin_wallet_view_qr_code": "View QR Code",
"plugin_wallet_switch_network": "Swtich to {{network}}",
"plugin_wallet_switch_network_under_going": "Switching to {{network}}…",
"plugin_wallet_not_availabe_on": "Not available on {{network}}.",
"plugin_wallet_switch_network": "Swtich to {{network}} Network",
"plugin_wallet_switch_network_under_going": "Switching to {{network}} Network……",
"plugin_wallet_not_availabe_on": "Not available on {{network}} Network.",
"plugin_wallet_connect_wallet": "Connect Wallet",
"plugin_wallet_connect_wallet_tip": "No wallet found.",
"plugin_wallet_settings_portfolio_data_source_primary": "Portfolio Data Source",
Expand Down Expand Up @@ -571,7 +571,7 @@
"plugin_ito_list_total": "Total: ",
"plugin_ito_list_table_type": "Type",
"plugin_ito_list_table_price": "Swap Ratio",
"plugin_ito_no_claimable_token": "You have no token claimable.",
"plugin_ito_no_claimable_token": "Your wallet address does not have any tokens that can be claimed.",
"plugin_ito_list_table_sold": "Swapped",
"plugin_ito_list_table_got": "Balance",
"plugin_ito_list_button_send": "Send",
Expand Down
51 changes: 31 additions & 20 deletions packages/maskbook/src/components/shared/AbstractTab.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { makeStyles } from '@material-ui/core/styles'
import { Theme, Tabs, Tab, Box, BoxProps, Paper } from '@material-ui/core'
import { useStylesExtends } from '../custom-ui-helper'

const useStyles = makeStyles((theme: Theme) => ({
tab: {
Expand All @@ -12,50 +13,60 @@ const useStyles = makeStyles((theme: Theme) => ({

interface TabPanelProps extends BoxProps {
id?: string
label: string
label: string | React.ReactNode
}

export interface AbstractTabProps {
tabs: Omit<TabPanelProps, 'height' | 'minHeight'>[]
state: readonly [number, (next: number) => void]
export interface AbstractTabProps extends withClasses<'tab' | 'tabs' | 'tabPanel' | 'indicator'> {
tabs: (Omit<TabPanelProps, 'height' | 'minHeight'> & { cb?: () => void })[]
state?: readonly [number, (next: number) => void]
index?: number
margin?: true | 'top' | 'bottom'
height?: number | string
hasOnlyOneChild?: boolean
}

export default function AbstractTab({ tabs, state, height = 200 }: AbstractTabProps) {
const classes = useStyles()
const [value, setValue] = state
export default function AbstractTab(props: AbstractTabProps) {
const { tabs, state, index, height = 200, hasOnlyOneChild = false } = props
const classes = useStylesExtends(useStyles(), props)
const [value, setValue] = state ?? [undefined, undefined]
const tabIndicatorStyle = tabs.length ? { width: 100 / tabs.length + '%' } : undefined

return (
<>
<Paper square elevation={0}>
<Tabs
value={value}
className={classes.tabs}
classes={{
indicator: classes.indicator,
}}
value={index ? index : value ? value : 0}
TabIndicatorProps={{ style: tabIndicatorStyle }}
variant="fullWidth"
indicatorColor="primary"
textColor="primary"
onChange={(_: React.SyntheticEvent, newValue: number) => setValue(newValue)}>
{tabs.map((tab) => (
onChange={(_: React.SyntheticEvent, newValue: number) => setValue?.(newValue)}>
{tabs.map((tab, i) => (
<Tab
className={classes.tab}
onClick={tab.cb}
label={tab.label}
key={tab.label}
key={i}
data-testid={`${tab.id?.toLowerCase()}_tab`}
/>
))}
</Tabs>
</Paper>
<Box
className={classes.tabPanel}
role="tabpanel"
{...tabs.find((_, index) => index === value)}
sx={{
height: height,
minHeight: height,
}}
/>
{!hasOnlyOneChild ? (
<Box
className={classes.tabPanel}
role="tabpanel"
{...tabs.find((_, index) => index === value)}
sx={{
height: height,
minHeight: height,
}}
/>
) : null}
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ export async function signTransaction(config: TransactionConfig, overrides?: Sen
}

export async function getPastLogs(config: PastLogsOptions, overrides?: SendOverrides) {
return request<Log[]>(
{
method: EthereumMethodType.ETH_GET_LOGS,
params: [config],
},
overrides,
return new Promise<Log[]>((resolve, reject) =>
request<Log[]>(
{
method: EthereumMethodType.ETH_GET_LOGS,
params: [config],
},
overrides,
)
.then((result) => resolve(result))
.catch(() => resolve([])),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface SendOverrides {
chainId?: ChainId
account?: string
providerType?: ProviderType
rpc?: string
}

/**
Expand All @@ -35,6 +36,7 @@ export async function INTERNAL_send(
chainId = currentChainIdSettings.value,
account = currentAccountSettings.value,
providerType = currentProviderSettings.value,
rpc,
}: SendOverrides = {},
) {
if (process.env.NODE_ENV === 'development' && debugModeSetting.value) {
Expand Down Expand Up @@ -156,7 +158,18 @@ export async function INTERNAL_send(
await sendTransaction()
break
default:
provider.send(payload, callback)
if (rpc) {
fetch(rpc, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch((error: Error) => callback(error))
.then(async (res) => {
if (res) callback(null, (await res.json()) as JsonRpcResponse)
})
} else {
provider.send(payload, callback)
}
break
}
} catch (error) {
Expand Down
Loading