Skip to content

Commit

Permalink
[Release] Hotfix 2.21.1 => 2.21.2 (patch) (#9894)
Browse files Browse the repository at this point in the history
* chore: bump version 2.21.2

* fix: connection context config chain (#9899)

* feat: wc v1 bridge url (#9901)

* fix: format method (#9902)

* fix: format method

* fix: replace others to evm methods

* refactor: code style

---------

Co-authored-by: guanbinrui <guanbinrui@dimension.im>

* fix: transfer gas option in dashboard (#9904)

* fix: token list dependency (#9905)

* refactor: turn off i18n updating (#9907)

* fix: fetch headers for twitter api (#9910)

* feat: simple hash collections by wallets for hotfix (#9917)

* feat(trending): simple hash activity list (#9870)

* chore: simple hash resolve blur token

* feat: simple hash collections by wallets

* chore: more SimpleHash adoption (#9920)

* chore: more simple hash adaption

* fix: token transaction confirm dialog ui

* refactor: code style

---------

Co-authored-by: guanbinrui <52657989+guanbinrui@users.noreply.github.com>

* Revert "refactor: turn off i18n updating (#9907)"

This reverts commit 5e6407e.

* chore: prevent invalid i18n hot update (#9831)

* chore: prevent invalid i18n hot update

* chore: prevent invalid i18n hot update

* feat: choose ERC721 collections (#9924)

* feat: choose erc-721 collections

* refactor: add schema type for hub options

* chore: comment

* refactor: update comment

---------

Co-authored-by: guanbinrui <52657989+guanbinrui@users.noreply.github.com>

---------

Co-authored-by: Hancheng Zhou <z308114274@gmail.com>
Co-authored-by: nuanyang233 <nuanyang233@gmail.com>
Co-authored-by: lelenei <72531217+lelenei@users.noreply.github.com>
Co-authored-by: Jack Works <jackworks@protonmail.com>
  • Loading branch information
5 people committed Jun 26, 2023
1 parent 99ad92d commit b010c54
Show file tree
Hide file tree
Showing 42 changed files with 354 additions and 153 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.21.1",
"version": "2.21.2",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export const TransferERC721 = memo(() => {
const handleSelectNFT = async () => {
const contract = await selectNFTContract({
pluginID: NetworkPluginID.PLUGIN_EVM,
schemaType: SchemaType.ERC721,
chainId,
})
if (contract && defaultToken && !isSameAddress(contract.address, defaultToken.address)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard/src/pages/Wallets/hooks/useGasConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useState } from 'react'
import { toHex } from 'web3-utils'
import { BigNumber } from 'bignumber.js'
import { chainResolver } from '@masknet/web3-shared-evm'
import { chainResolver, formatWeiToGwei } from '@masknet/web3-shared-evm'
import { useRemoteControlledDialog } from '@masknet/shared-base-ui'
import { WalletMessages } from '@masknet/plugin-wallet'
import { useChainContext, useGasOptions, useGasPrice } from '@masknet/web3-hooks-base'
Expand Down Expand Up @@ -38,7 +38,7 @@ export const useGasConfig = (gasLimit: number, minGasLimit: number) => {
if (evt.gasPrice) setCustomGasPrice(evt.gasPrice)
if (evt.gasOption) setGasOption(evt.gasOption)
if (evt.gasLimit) setGasLimit_(evt.gasLimit)
if (evt.maxFee) setMaxFee(evt.maxFee)
if (evt.maxFee) setMaxFee(formatWeiToGwei(evt.maxFee))
})
}, [])

Expand Down
10 changes: 4 additions & 6 deletions packages/flags/src/flags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const prodOnly = process.env.NODE_ENV === 'production'
const insiderOnly = process.env.channel === 'insider' || devOnly
const betaOrInsiderOnly = insiderOnly || process.env.channel === 'beta'

// TODO: In future, we can turn this object into a Proxy to receive flags from remote

export const flags = {
isolated_dashboard_bridge_enabled: false,
mask_SDK_ready: betaOrInsiderOnly,
Expand Down Expand Up @@ -39,7 +37,6 @@ export const flags = {

using_emoji_flag: true,

i18nTranslationHotUpdate: true,
sandboxedPluginRuntime: false,

/** The earliest version for the sentry to watch events and exceptions. */
Expand All @@ -52,9 +49,10 @@ export const flags = {
sentry_async_transaction_enabled: devOnly,

// wallet connect
wc_mode: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
wc_relay_url: 'wss://relay.walletconnect.com',
wc_project_id: '8f1769933420afe8873860925fcca14f',
wc_v1_bridge_url: 'https://bridge.walletconnect.org',
wc_v2_relay_url: 'wss://relay.walletconnect.com',
wc_v2_project_id: '8f1769933420afe8873860925fcca14f',
wc_v2_mode: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
wc_v1_enabled: true,
wc_v2_enabled: betaOrInsiderOnly,
} as const
Expand Down
44 changes: 32 additions & 12 deletions packages/mask/background/services/helper/i18n-cache-query.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Flags } from '@masknet/flags'
import list from './i18n-cache-query-list.js'

export type Bundle = [namespace: string, lang: string, json: object]
export type Bundle = [namespace: string, lang: string, json: Record<string, string>]
export async function queryRemoteI18NBundle(lang: string): Promise<Bundle[]> {
if (!Flags.i18nTranslationHotUpdate) return []
// skip fetching in development. if you need to debug this, please comment this code.
if (process.env.NODE_ENV === 'development') return []

Expand All @@ -12,25 +10,47 @@ export async function queryRemoteI18NBundle(lang: string): Promise<Bundle[]> {

const responses = updateLang === 'en-US' ? fetchEnglishBundle() : fetchTranslatedBundle(lang)
const results = await Promise.allSettled(responses)
return results.filter((x): x is PromiseFulfilledResult<Bundle> => x.status === 'fulfilled').map((x) => x.value)
return results
.filter((x): x is PromiseFulfilledResult<Bundle | null> => x.status === 'fulfilled')
.map((x) => x.value!)
.filter(Boolean)
}

const I18N_LOCALES_HOST = 'https://maskbook.pages.dev/'

function fetchTranslatedBundle(lang: string) {
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle> => {
const path = url.replace('%locale%', lang)
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
return [namespace, lang, await response.json()]
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
try {
const path = url.replace('%locale%', lang)
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
const json = await response.json()
if (!isValidTranslation(json)) return null
return [namespace, lang, json]
} catch {
return null
}
})
}
function fetchEnglishBundle() {
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle> => {
const path = url.replace('%locale%', 'en-US')
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
return [namespace, 'en-US', await response.json()]
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
try {
const path = url.replace('%locale%', 'en-US')
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
const json = await response.json()
if (!isValidTranslation(json)) return null
return [namespace, 'en-US', json]
} catch {
return null
}
})
}
function isValidTranslation(obj: unknown): obj is Record<string, string> {
if (typeof obj !== 'object' || obj === null) return false
for (const key in obj) {
if (typeof (obj as any)[key] !== 'string') return false
}
return true
}

const fetchOption = {
credentials: 'omit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ import {
type Account,
} from '@masknet/shared-base'
import { makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
import { NextIDProof, Others, Web3 } from '@masknet/web3-providers'
import { NextIDProof, Web3 } from '@masknet/web3-providers'
import { isSameAddress } from '@masknet/web3-shared-base'
import { useReverseAddress, useWallets } from '@masknet/web3-hooks-base'
import { type ChainId, EthereumMethodType, providerResolver, ProviderType } from '@masknet/web3-shared-evm'
import {
type ChainId,
EthereumMethodType,
providerResolver,
ProviderType,
formatDomainName,
} from '@masknet/web3-shared-evm'
import { SignSteps, Steps } from '../../../../../components/shared/VerifyWallet/Steps.js'
import Services from '../../../../service.js'
import { PersonaContext } from '../hooks/usePersonaContext.js'
Expand Down Expand Up @@ -61,7 +67,7 @@ const VerifyWallet = memo(() => {
}, [wallet.account, currentPersona?.identifier.publicKeyAsHex])

const walletName = () => {
if (domain) return Others.formatDomainName(domain)
if (domain) return formatDomainName(domain)
if (wallet.providerType !== ProviderType.MaskWallet)
return `${providerResolver.providerName(wallet.providerType)} Wallet`
return wallets.find((x) => isSameAddress(x.address, wallet.account))?.name ?? 'Wallet'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useLocation, useNavigate } from 'react-router-dom'
import { makeStyles } from '@masknet/theme'
import {
DepositPaymaster,
formatDomainName,
formatGweiToWei,
formatWeiToEther,
isNativeTokenAddress,
Expand Down Expand Up @@ -41,7 +42,7 @@ import {
ZERO,
} from '@masknet/web3-shared-base'
import { Icons } from '@masknet/icons'
import { Others, Web3 } from '@masknet/web3-providers'
import { Web3 } from '@masknet/web3-providers'
import { useTitle } from '../../../hook/useTitle.js'
import { useUnconfirmedRequest } from '../hooks/useUnConfirmedRequest.js'
import { useI18N } from '../../../../../utils/index.js'
Expand Down Expand Up @@ -370,15 +371,7 @@ const ContractInteraction = memo(() => {
if (!request?.paymentToken || isNativeTokenAddress(request.paymentToken)) return result
if (!currencyRatio) return ZERO
return new BigNumber(toFixed(result.multipliedBy(currencyRatio), 0))
}, [
gas,
isSupport1559,
gasPriceEIP1559,
gasPricePriorEIP1559,
Others.isNativeTokenAddress,
request?.paymentToken,
currencyRatio,
])
}, [gas, isSupport1559, gasPriceEIP1559, gasPricePriorEIP1559, request?.paymentToken, currencyRatio])

const gasFeeUSD = useMemo(() => {
if (!gasFee || gasFee.isZero()) return '0'
Expand All @@ -403,9 +396,7 @@ const ContractInteraction = memo(() => {
<main className={classes.container}>
<div className={classes.info} style={{ marginBottom: 20 }}>
<Typography className={classes.title}>{typeName}</Typography>
{domain ? (
<Typography className={classes.domain}>{Others.formatDomainName(domain)}</Typography>
) : null}
{domain ? <Typography className={classes.domain}>{formatDomainName(domain)}</Typography> : null}
<Typography className={classes.secondary} style={{ wordBreak: 'break-all' }}>
{to}
{request?.formatterTransaction?.type === TransactionDescriptorType.INTERACTION &&
Expand Down Expand Up @@ -454,13 +445,13 @@ const ContractInteraction = memo(() => {
<FormattedBalance
value={gasFee}
decimals={
request?.paymentToken && !Others.isNativeTokenAddress(request?.paymentToken)
request?.paymentToken && !isNativeTokenAddress(request?.paymentToken)
? maskToken?.decimals
: nativeToken?.decimals
}
significant={4}
symbol={
request?.paymentToken && !Others.isNativeTokenAddress(request?.paymentToken)
request?.paymentToken && !isNativeTokenAddress(request?.paymentToken)
? maskToken?.symbol
: nativeToken?.symbol
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { makeStyles } from '@masknet/theme'
import { Icons } from '@masknet/icons'
import { ListItem, ListItemText, Typography } from '@mui/material'
import { FormattedAddress } from '@masknet/shared'
import { Others } from '@masknet/web3-providers'
import { useReverseAddress } from '@masknet/web3-hooks-base'
import { CopyIconButton } from '../../../components/CopyIconButton/index.js'
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'

const useStyles = makeStyles()({
item: {
Expand Down Expand Up @@ -63,12 +63,10 @@ export const WalletItem = memo<WalletItemProps>(({ wallet, onClick, isSelected }
<div>
<Typography className={classes.name}>
<Typography component="span"> {wallet.name}</Typography>
{domain ? (
<Typography component="span">{Others.formatDomainName(domain)}</Typography>
) : null}
{domain ? <Typography component="span">{formatDomainName(domain)}</Typography> : null}
</Typography>
<Typography className={classes.address}>
<FormattedAddress address={wallet.address} size={12} formatter={Others.formatAddress} />
<FormattedAddress address={wallet.address} size={12} formatter={formatEthereumAddress} />
<CopyIconButton className={classes.copy} text={wallet.address} />
</Typography>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { memo, useCallback } from 'react'
import { useHover } from 'react-use'
import { useNavigate } from 'react-router-dom'
import { makeStyles } from '@masknet/theme'
import { formatEthereumAddress } from '@masknet/web3-shared-evm'
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'
import { NetworkPluginID, PopupRoutes, type Wallet } from '@masknet/shared-base'
import { useReverseAddress } from '@masknet/web3-hooks-base'
import { Icons } from '@masknet/icons'
import { ListItem, ListItemText, Typography } from '@mui/material'
import { FormattedAddress } from '@masknet/shared'
import { Others } from '@masknet/web3-providers'
import { WalletContext } from '../hooks/useWalletContext.js'
import { CopyIconButton } from '../../../components/CopyIconButton/index.js'

Expand Down Expand Up @@ -100,7 +99,7 @@ export const WalletItem = memo<WalletItemProps>(({ wallet, onClick, isSelected }
{wallet.name}
{domain ? (
<Typography component="span" className={classes.domain}>
({Others.formatDomainName(domain)})
({formatDomainName(domain)})
</Typography>
) : null}
{isHovering ? <Icons.Edit className={classes.edit} onClick={handleRename} /> : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { memo } from 'react'
import { MenuItem, Typography } from '@mui/material'
import { FormattedAddress } from '@masknet/shared'
import { NetworkPluginID } from '@masknet/shared-base'
import { formatEthereumAddress } from '@masknet/web3-shared-evm'
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'
import { makeStyles } from '@masknet/theme'
import { useReverseAddress, useWeb3Others } from '@masknet/web3-hooks-base'
import { useReverseAddress } from '@masknet/web3-hooks-base'

const useStyles = makeStyles()({
menuItem: {
Expand Down Expand Up @@ -37,7 +37,6 @@ export interface AccountItemProps {

export const AccountItem = memo<AccountItemProps>(({ account, onClick }) => {
const { classes } = useStyles()
const Others = useWeb3Others()
const { data: domain } = useReverseAddress(NetworkPluginID.PLUGIN_EVM, account.address)

return (
Expand All @@ -46,7 +45,7 @@ export const AccountItem = memo<AccountItemProps>(({ account, onClick }) => {
{account.name}
{domain ? (
<Typography component="span" className={classes.domain}>
{Others.formatDomainName(domain)}
{formatDomainName(domain)}
</Typography>
) : null}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
useMaskTokenAddress,
} from '@masknet/web3-hooks-base'
import { useGasLimit, useTokenTransferCallback } from '@masknet/web3-hooks-evm'
import { Others, Web3 } from '@masknet/web3-providers'
import { Web3 } from '@masknet/web3-providers'
import { StyledInput } from '../../../components/StyledInput/index.js'
import { AccountItem } from './AccountItem.js'
import { TransferAddressError } from '../type.js'
Expand Down Expand Up @@ -339,7 +339,7 @@ export const Transfer1559 = memo<Transfer1559Props>(({ selectedAsset, openAssetM
}

// The input is ens domain but the binding address cannot be found
if (Others.isValidDomain(address) && (resolveDomainError || !registeredAddress)) {
if (isValidDomain(address) && (resolveDomainError || !registeredAddress)) {
setAddressTip({
type: TransferAddressError.RESOLVE_FAILED,
message: t('wallet_transfer_error_no_address_has_been_set_name'),
Expand Down Expand Up @@ -370,7 +370,7 @@ export const Transfer1559 = memo<Transfer1559Props>(({ selectedAsset, openAssetM
message: t('wallet_transfer_error_is_contract_address'),
})
}
}, [address, pluginID, registeredAddress, methods.clearErrors, wallet?.address, resolveDomainError, Others])
}, [address, pluginID, registeredAddress, methods.clearErrors, wallet?.address, resolveDomainError])
// #endregion

// #region Get min gas limit with amount and recipient address
Expand Down Expand Up @@ -469,7 +469,7 @@ export const Transfer1559 = memo<Transfer1559Props>(({ selectedAsset, openAssetM
const transferAmount = rightShift(data.amount || '0', selectedAsset?.decimals).toFixed()

// If input address is ens domain, use registeredAddress to transfer
if (Others.isValidDomain(data.address)) {
if (isValidDomain(data.address)) {
await transferCallback(transferAmount, registeredAddress, {
maxFeePerGas: toHex(formatGweiToWei(data.maxFeePerGas).toFixed(0)),
maxPriorityFeePerGas: toHex(formatGweiToWei(data.maxPriorityFeePerGas).toFixed(0)),
Expand All @@ -484,7 +484,7 @@ export const Transfer1559 = memo<Transfer1559Props>(({ selectedAsset, openAssetM
gas: data.gasLimit,
})
},
[selectedAsset, transferCallback, registeredAddress, Others],
[selectedAsset, transferCallback, registeredAddress],
)

const handleCancel = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ import {
TransactionDescriptorType,
TransactionStatusType,
} from '@masknet/web3-shared-base'
import type { ChainId, Transaction, TransactionParameter } from '@masknet/web3-shared-evm'
import {
formatDomainName,
type ChainId,
type Transaction,
type TransactionParameter,
formatEthereumAddress,
} from '@masknet/web3-shared-evm'
import { useReverseAddress } from '@masknet/web3-hooks-base'
import { Others } from '@masknet/web3-providers'
import formatDateTime from 'date-fns/format'
import { useI18N } from '../../../../../../utils/index.js'

Expand Down Expand Up @@ -93,7 +98,7 @@ export const ActivityListItem = memo<ActivityListItemProps>(
{transaction.createdAt ? `${formatDateTime(transaction.createdAt, 'MMM dd')}. ` : null}
{toAddress
? t('popups_wallet_activity_to_address', {
address: Others.formatDomainName(domain) || Others.formatAddress(toAddress, 4),
address: domain ? formatDomainName(domain) : formatEthereumAddress(toAddress, 4),
})
: null}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
type TransactionDescriptor,
TransactionDescriptorType,
} from '@masknet/web3-shared-base'
import { Others } from '@masknet/web3-providers'
import { useChainContext, useWeb3State } from '@masknet/web3-hooks-base'
import { isNativeTokenAddress } from '@masknet/web3-shared-evm'
import { explorerResolver, isNativeTokenAddress } from '@masknet/web3-shared-evm'
import type { ChainId, Transaction, TransactionParameter } from '@masknet/web3-shared-evm'
import { EMPTY_LIST, PopupRoutes, NetworkPluginID } from '@masknet/shared-base'
import { WalletContext } from '../../hooks/useWalletContext.js'
Expand Down Expand Up @@ -90,7 +89,7 @@ export const ActivityList = memo<ActivityListProps>(({ tokenAddress }) => {
<ActivityListUI
dataSource={dataSource}
chainId={chainId}
formatterTransactionLink={Others.explorerResolver.transactionLink}
formatterTransactionLink={explorerResolver.transactionLink}
/>
)
})
Expand Down

0 comments on commit b010c54

Please sign in to comment.