Skip to content

Commit

Permalink
fix: wallet issues (#10496)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBill committed Aug 19, 2023
1 parent 0816e61 commit 0bffdee
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 48 deletions.
6 changes: 3 additions & 3 deletions packages/dashboard/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@
"welcome_request_to_collect": "Allow us to collect your usage information to help us make improvements.",
"welcome_to_use_mask_network": "Welcome to use Mask Network",
"create_step": "Step {{step}}/{{totalSteps}}",
"persona_create_title": "Create New MASK identity",
"persona_create_title": "Create New MASK Identity",
"persona_create_tips": "Create your persona to get started",
"data_recovery_title": "Recover your data",
"data_recovery_description": "Please select the appropriate method to restore your personal data.",
"data_recovery_description": "12-word recovery phrase are used to recovery your persona data.",
"data_recovery_email": "Email",
"data_recovery_email_code": "Email verification code",
"data_recovery_mobile": "Mobile",
Expand All @@ -450,7 +450,7 @@
"switch_other_accounts": "Switch other accounts",
"file_reselect": "Reselect",
"mobile_number": "Mobile number",
"persona_phrase_title": "Your Recovery phrase",
"persona_phrase_title": "Persona Recovery Phrase",
"persona_phrase_tips": "Please select the correct method to restore the backup.",
"persona_phrase_copy_description": "The mnemonic has been copied, please keep it in a safe place.",
"persona_phrase_create_tips": "Never share 12-word secret recovery phrase with anyone!",
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/shared-ui/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@
"plugin_wallet_choose_network": "Choose Network",
"plugin_disabled_tip": "You need to open the DAPP to view the specific content.",
"management_network": "Management network",
"network_management_add_network": "Add a network",
"network_management_add_network": "Add Network",
"network_name": "Network Name",
"rpc_url": "RPC URL",
"chain_id": "Chain ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useBalance, useReverseAddress, useWallets } from '@masknet/web3-hooks-base'
import { Icons } from '@masknet/icons'
import { ChainId, formatEthereumAddress } from '@masknet/web3-shared-evm'
import { FormattedBalance } from '@masknet/shared'
import { FormattedBalance, ProgressiveText } from '@masknet/shared'
import { ExplorerResolver } from '@masknet/web3-providers'
import { formatBalance } from '@masknet/web3-shared-base'
import { useI18N } from '../../../../../utils/index.js'
Expand Down Expand Up @@ -126,6 +126,51 @@ const useStyles = makeStyles()((theme) => ({
},
}))

interface WalletItemProps {
wallet: Wallet
}

const WalletItem = memo(function WalletItem({ wallet }: WalletItemProps) {
const { classes } = useStyles()
const { address, owner } = wallet
const { data: balance = '0', isLoading } = useBalance(NetworkPluginID.PLUGIN_EVM, {
account: address,
chainId: owner ? ChainId.Matic : ChainId.Mainnet,
})
const theme = useTheme()

const { data: domain } = useReverseAddress(NetworkPluginID.PLUGIN_EVM, address)

return (
<Box className={classes.addWalletWrapper}>
{owner ? <Icons.SmartPay size={30} /> : <Icons.ETH size={30} />}
<div>
<Typography className={classes.subTitle}>
{domain || formatEthereumAddress(address, 4)}{' '}
<Link
underline="none"
target="_blank"
rel="noopener noreferrer"
href={ExplorerResolver.addressLink(ChainId.Mainnet, address)}
marginLeft="4px"
width={16}
height={16}>
<Icons.LinkOut size={16} color={theme.palette.maskColor.main} />
</Link>
</Typography>
<ProgressiveText loading={isLoading} className={classes.description} fontSize={12} skeletonWidth={50}>
<FormattedBalance
value={balance}
decimals={18}
symbol={owner ? 'Matic' : 'ETH'}
formatter={formatBalance}
/>
</ProgressiveText>
</div>
</Box>
)
})

const SetPaymentPassword = memo(function SetPaymentPassword() {
const { t } = useI18N()
const { classes } = useStyles()
Expand Down Expand Up @@ -302,45 +347,4 @@ const SetPaymentPassword = memo(function SetPaymentPassword() {
</Box>
)
})

interface WalletItemProps {
wallet: Wallet
}

function WalletItem({ wallet }: WalletItemProps) {
const { classes } = useStyles()
const { address, owner } = wallet
const { data: balance = '0' } = useBalance(NetworkPluginID.PLUGIN_EVM, {
account: address,
chainId: ChainId.Mainnet,
})
const theme = useTheme()

const { data: domain } = useReverseAddress(NetworkPluginID.PLUGIN_EVM, address)

return (
<Box className={classes.addWalletWrapper}>
{owner ? <Icons.SmartPay size={30} /> : <Icons.ETH size={30} />}
<div>
<Typography className={classes.subTitle}>
{domain || formatEthereumAddress(address, 4)}{' '}
<Link
underline="none"
target="_blank"
rel="noopener noreferrer"
href={ExplorerResolver.addressLink(ChainId.Mainnet, address)}
marginLeft="4px"
width={16}
height={16}>
<Icons.LinkOut size={16} color={theme.palette.maskColor.main} />
</Link>
</Typography>
<Typography className={classes.description} fontSize={12}>
<FormattedBalance value={balance} decimals={18} symbol="ETH" formatter={formatBalance} />
</Typography>
</div>
</Box>
)
}

export default SetPaymentPassword
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const useStyles = makeStyles()((theme) => {
fontSize: 14,
fontWeight: 700,
color: theme.palette.maskColor.second,
textTransform: 'capitalize',
},
value: {
fontSize: 14,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ActionButton, MaskColors, makeStyles } from '@masknet/theme'
import { useAccount, useNativeToken, useNativeTokenPrice } from '@masknet/web3-hooks-base'
import { ChainbaseHistory, ExplorerResolver, Web3 } from '@masknet/web3-providers'
import { chainbase } from '@masknet/web3-providers/helpers'
import { TransactionStatusType, formatBalance, trimZero } from '@masknet/web3-shared-base'
import { TransactionStatusType, formatBalance, isSameAddress, trimZero } from '@masknet/web3-shared-base'
import {
formatHash,
formatWeiToEther,
Expand Down Expand Up @@ -206,7 +206,7 @@ export const TransactionDetail = memo(function TransactionDetail() {
}
const status = tx ? chainbase.normalizeTxStatus(tx.status) : transactionState?.status!
const statusPending = status === undefined && loadingTx
const isOut = transaction.from === account
const isOut = isSameAddress(transaction.from, account)
const link = transactionId ? ExplorerResolver.transactionLink(chainId!, transactionId) : undefined

const gasUsedPercent = tx ? (tx.gas_used * 100) / tx.gas : 0
Expand Down

0 comments on commit 0bffdee

Please sign in to comment.