Skip to content

Commit b010c54

Browse files
guanbinruizhouhansengnuanyang233leleneiJack-Works
authored
[Release] Hotfix 2.21.1 => 2.21.2 (patch) (#9894)
* 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> --------- Co-authored-by: Hancheng Zhou <[email protected]> Co-authored-by: nuanyang233 <[email protected]> Co-authored-by: lelenei <[email protected]> Co-authored-by: Jack Works <[email protected]>
1 parent 99ad92d commit b010c54

File tree

42 files changed

+354
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+354
-153
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"yarn": ">=999.0.0",
99
"npm": ">=999.0.0"
1010
},
11-
"version": "2.21.1",
11+
"version": "2.21.2",
1212
"private": true,
1313
"license": "AGPL-3.0-or-later",
1414
"scripts": {

packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC721.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export const TransferERC721 = memo(() => {
171171
const handleSelectNFT = async () => {
172172
const contract = await selectNFTContract({
173173
pluginID: NetworkPluginID.PLUGIN_EVM,
174+
schemaType: SchemaType.ERC721,
174175
chainId,
175176
})
176177
if (contract && defaultToken && !isSameAddress(contract.address, defaultToken.address)) {

packages/dashboard/src/pages/Wallets/hooks/useGasConfig.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useMemo, useState } from 'react'
22
import { toHex } from 'web3-utils'
33
import { BigNumber } from 'bignumber.js'
4-
import { chainResolver } from '@masknet/web3-shared-evm'
4+
import { chainResolver, formatWeiToGwei } from '@masknet/web3-shared-evm'
55
import { useRemoteControlledDialog } from '@masknet/shared-base-ui'
66
import { WalletMessages } from '@masknet/plugin-wallet'
77
import { useChainContext, useGasOptions, useGasPrice } from '@masknet/web3-hooks-base'
@@ -38,7 +38,7 @@ export const useGasConfig = (gasLimit: number, minGasLimit: number) => {
3838
if (evt.gasPrice) setCustomGasPrice(evt.gasPrice)
3939
if (evt.gasOption) setGasOption(evt.gasOption)
4040
if (evt.gasLimit) setGasLimit_(evt.gasLimit)
41-
if (evt.maxFee) setMaxFee(evt.maxFee)
41+
if (evt.maxFee) setMaxFee(formatWeiToGwei(evt.maxFee))
4242
})
4343
}, [])
4444

packages/flags/src/flags/index.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const prodOnly = process.env.NODE_ENV === 'production'
33
const insiderOnly = process.env.channel === 'insider' || devOnly
44
const betaOrInsiderOnly = insiderOnly || process.env.channel === 'beta'
55

6-
// TODO: In future, we can turn this object into a Proxy to receive flags from remote
7-
86
export const flags = {
97
isolated_dashboard_bridge_enabled: false,
108
mask_SDK_ready: betaOrInsiderOnly,
@@ -39,7 +37,6 @@ export const flags = {
3937

4038
using_emoji_flag: true,
4139

42-
i18nTranslationHotUpdate: true,
4340
sandboxedPluginRuntime: false,
4441

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

5451
// wallet connect
55-
wc_mode: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
56-
wc_relay_url: 'wss://relay.walletconnect.com',
57-
wc_project_id: '8f1769933420afe8873860925fcca14f',
52+
wc_v1_bridge_url: 'https://bridge.walletconnect.org',
53+
wc_v2_relay_url: 'wss://relay.walletconnect.com',
54+
wc_v2_project_id: '8f1769933420afe8873860925fcca14f',
55+
wc_v2_mode: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
5856
wc_v1_enabled: true,
5957
wc_v2_enabled: betaOrInsiderOnly,
6058
} as const

packages/mask/background/services/helper/i18n-cache-query.ts

+32-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { Flags } from '@masknet/flags'
21
import list from './i18n-cache-query-list.js'
32

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

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

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

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

2021
function fetchTranslatedBundle(lang: string) {
21-
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle> => {
22-
const path = url.replace('%locale%', lang)
23-
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
24-
return [namespace, lang, await response.json()]
22+
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
23+
try {
24+
const path = url.replace('%locale%', lang)
25+
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
26+
const json = await response.json()
27+
if (!isValidTranslation(json)) return null
28+
return [namespace, lang, json]
29+
} catch {
30+
return null
31+
}
2532
})
2633
}
2734
function fetchEnglishBundle() {
28-
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle> => {
29-
const path = url.replace('%locale%', 'en-US')
30-
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
31-
return [namespace, 'en-US', await response.json()]
35+
return Object.entries(list).map(async ([url, namespace]): Promise<Bundle | null> => {
36+
try {
37+
const path = url.replace('%locale%', 'en-US')
38+
const response = await fetch(I18N_LOCALES_HOST + path, fetchOption)
39+
const json = await response.json()
40+
if (!isValidTranslation(json)) return null
41+
return [namespace, 'en-US', json]
42+
} catch {
43+
return null
44+
}
3245
})
3346
}
47+
function isValidTranslation(obj: unknown): obj is Record<string, string> {
48+
if (typeof obj !== 'object' || obj === null) return false
49+
for (const key in obj) {
50+
if (typeof (obj as any)[key] !== 'string') return false
51+
}
52+
return true
53+
}
3454

3555
const fetchOption = {
3656
credentials: 'omit',

packages/mask/src/extension/popups/pages/Personas/VerifyWallet/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ import {
1111
type Account,
1212
} from '@masknet/shared-base'
1313
import { makeStyles, usePopupCustomSnackbar } from '@masknet/theme'
14-
import { NextIDProof, Others, Web3 } from '@masknet/web3-providers'
14+
import { NextIDProof, Web3 } from '@masknet/web3-providers'
1515
import { isSameAddress } from '@masknet/web3-shared-base'
1616
import { useReverseAddress, useWallets } from '@masknet/web3-hooks-base'
17-
import { type ChainId, EthereumMethodType, providerResolver, ProviderType } from '@masknet/web3-shared-evm'
17+
import {
18+
type ChainId,
19+
EthereumMethodType,
20+
providerResolver,
21+
ProviderType,
22+
formatDomainName,
23+
} from '@masknet/web3-shared-evm'
1824
import { SignSteps, Steps } from '../../../../../components/shared/VerifyWallet/Steps.js'
1925
import Services from '../../../../service.js'
2026
import { PersonaContext } from '../hooks/usePersonaContext.js'
@@ -61,7 +67,7 @@ const VerifyWallet = memo(() => {
6167
}, [wallet.account, currentPersona?.identifier.publicKeyAsHex])
6268

6369
const walletName = () => {
64-
if (domain) return Others.formatDomainName(domain)
70+
if (domain) return formatDomainName(domain)
6571
if (wallet.providerType !== ProviderType.MaskWallet)
6672
return `${providerResolver.providerName(wallet.providerType)} Wallet`
6773
return wallets.find((x) => isSameAddress(x.address, wallet.account))?.name ?? 'Wallet'

packages/mask/src/extension/popups/pages/Wallet/ContractInteraction/index.tsx

+6-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useLocation, useNavigate } from 'react-router-dom'
88
import { makeStyles } from '@masknet/theme'
99
import {
1010
DepositPaymaster,
11+
formatDomainName,
1112
formatGweiToWei,
1213
formatWeiToEther,
1314
isNativeTokenAddress,
@@ -41,7 +42,7 @@ import {
4142
ZERO,
4243
} from '@masknet/web3-shared-base'
4344
import { Icons } from '@masknet/icons'
44-
import { Others, Web3 } from '@masknet/web3-providers'
45+
import { Web3 } from '@masknet/web3-providers'
4546
import { useTitle } from '../../../hook/useTitle.js'
4647
import { useUnconfirmedRequest } from '../hooks/useUnConfirmedRequest.js'
4748
import { useI18N } from '../../../../../utils/index.js'
@@ -370,15 +371,7 @@ const ContractInteraction = memo(() => {
370371
if (!request?.paymentToken || isNativeTokenAddress(request.paymentToken)) return result
371372
if (!currencyRatio) return ZERO
372373
return new BigNumber(toFixed(result.multipliedBy(currencyRatio), 0))
373-
}, [
374-
gas,
375-
isSupport1559,
376-
gasPriceEIP1559,
377-
gasPricePriorEIP1559,
378-
Others.isNativeTokenAddress,
379-
request?.paymentToken,
380-
currencyRatio,
381-
])
374+
}, [gas, isSupport1559, gasPriceEIP1559, gasPricePriorEIP1559, request?.paymentToken, currencyRatio])
382375

383376
const gasFeeUSD = useMemo(() => {
384377
if (!gasFee || gasFee.isZero()) return '0'
@@ -403,9 +396,7 @@ const ContractInteraction = memo(() => {
403396
<main className={classes.container}>
404397
<div className={classes.info} style={{ marginBottom: 20 }}>
405398
<Typography className={classes.title}>{typeName}</Typography>
406-
{domain ? (
407-
<Typography className={classes.domain}>{Others.formatDomainName(domain)}</Typography>
408-
) : null}
399+
{domain ? <Typography className={classes.domain}>{formatDomainName(domain)}</Typography> : null}
409400
<Typography className={classes.secondary} style={{ wordBreak: 'break-all' }}>
410401
{to}
411402
{request?.formatterTransaction?.type === TransactionDescriptorType.INTERACTION &&
@@ -454,13 +445,13 @@ const ContractInteraction = memo(() => {
454445
<FormattedBalance
455446
value={gasFee}
456447
decimals={
457-
request?.paymentToken && !Others.isNativeTokenAddress(request?.paymentToken)
448+
request?.paymentToken && !isNativeTokenAddress(request?.paymentToken)
458449
? maskToken?.decimals
459450
: nativeToken?.decimals
460451
}
461452
significant={4}
462453
symbol={
463-
request?.paymentToken && !Others.isNativeTokenAddress(request?.paymentToken)
454+
request?.paymentToken && !isNativeTokenAddress(request?.paymentToken)
464455
? maskToken?.symbol
465456
: nativeToken?.symbol
466457
}

packages/mask/src/extension/popups/pages/Wallet/SelectWallet/WalletItem.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { makeStyles } from '@masknet/theme'
44
import { Icons } from '@masknet/icons'
55
import { ListItem, ListItemText, Typography } from '@mui/material'
66
import { FormattedAddress } from '@masknet/shared'
7-
import { Others } from '@masknet/web3-providers'
87
import { useReverseAddress } from '@masknet/web3-hooks-base'
98
import { CopyIconButton } from '../../../components/CopyIconButton/index.js'
9+
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'
1010

1111
const useStyles = makeStyles()({
1212
item: {
@@ -63,12 +63,10 @@ export const WalletItem = memo<WalletItemProps>(({ wallet, onClick, isSelected }
6363
<div>
6464
<Typography className={classes.name}>
6565
<Typography component="span"> {wallet.name}</Typography>
66-
{domain ? (
67-
<Typography component="span">{Others.formatDomainName(domain)}</Typography>
68-
) : null}
66+
{domain ? <Typography component="span">{formatDomainName(domain)}</Typography> : null}
6967
</Typography>
7068
<Typography className={classes.address}>
71-
<FormattedAddress address={wallet.address} size={12} formatter={Others.formatAddress} />
69+
<FormattedAddress address={wallet.address} size={12} formatter={formatEthereumAddress} />
7270
<CopyIconButton className={classes.copy} text={wallet.address} />
7371
</Typography>
7472
</div>

packages/mask/src/extension/popups/pages/Wallet/SwitchWallet/WalletItem.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { memo, useCallback } from 'react'
22
import { useHover } from 'react-use'
33
import { useNavigate } from 'react-router-dom'
44
import { makeStyles } from '@masknet/theme'
5-
import { formatEthereumAddress } from '@masknet/web3-shared-evm'
5+
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'
66
import { NetworkPluginID, PopupRoutes, type Wallet } from '@masknet/shared-base'
77
import { useReverseAddress } from '@masknet/web3-hooks-base'
88
import { Icons } from '@masknet/icons'
99
import { ListItem, ListItemText, Typography } from '@mui/material'
1010
import { FormattedAddress } from '@masknet/shared'
11-
import { Others } from '@masknet/web3-providers'
1211
import { WalletContext } from '../hooks/useWalletContext.js'
1312
import { CopyIconButton } from '../../../components/CopyIconButton/index.js'
1413

@@ -100,7 +99,7 @@ export const WalletItem = memo<WalletItemProps>(({ wallet, onClick, isSelected }
10099
{wallet.name}
101100
{domain ? (
102101
<Typography component="span" className={classes.domain}>
103-
({Others.formatDomainName(domain)})
102+
({formatDomainName(domain)})
104103
</Typography>
105104
) : null}
106105
{isHovering ? <Icons.Edit className={classes.edit} onClick={handleRename} /> : null}

packages/mask/src/extension/popups/pages/Wallet/Transfer/AccountItem.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { memo } from 'react'
22
import { MenuItem, Typography } from '@mui/material'
33
import { FormattedAddress } from '@masknet/shared'
44
import { NetworkPluginID } from '@masknet/shared-base'
5-
import { formatEthereumAddress } from '@masknet/web3-shared-evm'
5+
import { formatDomainName, formatEthereumAddress } from '@masknet/web3-shared-evm'
66
import { makeStyles } from '@masknet/theme'
7-
import { useReverseAddress, useWeb3Others } from '@masknet/web3-hooks-base'
7+
import { useReverseAddress } from '@masknet/web3-hooks-base'
88

99
const useStyles = makeStyles()({
1010
menuItem: {
@@ -37,7 +37,6 @@ export interface AccountItemProps {
3737

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

4342
return (
@@ -46,7 +45,7 @@ export const AccountItem = memo<AccountItemProps>(({ account, onClick }) => {
4645
{account.name}
4746
{domain ? (
4847
<Typography component="span" className={classes.domain}>
49-
{Others.formatDomainName(domain)}
48+
{formatDomainName(domain)}
5049
</Typography>
5150
) : null}
5251
</Typography>

packages/mask/src/extension/popups/pages/Wallet/Transfer/Transfer1559.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import {
5858
useMaskTokenAddress,
5959
} from '@masknet/web3-hooks-base'
6060
import { useGasLimit, useTokenTransferCallback } from '@masknet/web3-hooks-evm'
61-
import { Others, Web3 } from '@masknet/web3-providers'
61+
import { Web3 } from '@masknet/web3-providers'
6262
import { StyledInput } from '../../../components/StyledInput/index.js'
6363
import { AccountItem } from './AccountItem.js'
6464
import { TransferAddressError } from '../type.js'
@@ -339,7 +339,7 @@ export const Transfer1559 = memo<Transfer1559Props>(({ selectedAsset, openAssetM
339339
}
340340

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

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

471471
// If input address is ens domain, use registeredAddress to transfer
472-
if (Others.isValidDomain(data.address)) {
472+
if (isValidDomain(data.address)) {
473473
await transferCallback(transferAmount, registeredAddress, {
474474
maxFeePerGas: toHex(formatGweiToWei(data.maxFeePerGas).toFixed(0)),
475475
maxPriorityFeePerGas: toHex(formatGweiToWei(data.maxPriorityFeePerGas).toFixed(0)),
@@ -484,7 +484,7 @@ export const Transfer1559 = memo<Transfer1559Props>(({ selectedAsset, openAssetM
484484
gas: data.gasLimit,
485485
})
486486
},
487-
[selectedAsset, transferCallback, registeredAddress, Others],
487+
[selectedAsset, transferCallback, registeredAddress],
488488
)
489489

490490
const handleCancel = useCallback(() => {

packages/mask/src/extension/popups/pages/Wallet/components/ActivityList/ActivityListItem.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import {
99
TransactionDescriptorType,
1010
TransactionStatusType,
1111
} from '@masknet/web3-shared-base'
12-
import type { ChainId, Transaction, TransactionParameter } from '@masknet/web3-shared-evm'
12+
import {
13+
formatDomainName,
14+
type ChainId,
15+
type Transaction,
16+
type TransactionParameter,
17+
formatEthereumAddress,
18+
} from '@masknet/web3-shared-evm'
1319
import { useReverseAddress } from '@masknet/web3-hooks-base'
14-
import { Others } from '@masknet/web3-providers'
1520
import formatDateTime from 'date-fns/format'
1621
import { useI18N } from '../../../../../../utils/index.js'
1722

@@ -93,7 +98,7 @@ export const ActivityListItem = memo<ActivityListItemProps>(
9398
{transaction.createdAt ? `${formatDateTime(transaction.createdAt, 'MMM dd')}. ` : null}
9499
{toAddress
95100
? t('popups_wallet_activity_to_address', {
96-
address: Others.formatDomainName(domain) || Others.formatAddress(toAddress, 4),
101+
address: domain ? formatDomainName(domain) : formatEthereumAddress(toAddress, 4),
97102
})
98103
: null}
99104
</Typography>

packages/mask/src/extension/popups/pages/Wallet/components/ActivityList/index.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import {
1111
type TransactionDescriptor,
1212
TransactionDescriptorType,
1313
} from '@masknet/web3-shared-base'
14-
import { Others } from '@masknet/web3-providers'
1514
import { useChainContext, useWeb3State } from '@masknet/web3-hooks-base'
16-
import { isNativeTokenAddress } from '@masknet/web3-shared-evm'
15+
import { explorerResolver, isNativeTokenAddress } from '@masknet/web3-shared-evm'
1716
import type { ChainId, Transaction, TransactionParameter } from '@masknet/web3-shared-evm'
1817
import { EMPTY_LIST, PopupRoutes, NetworkPluginID } from '@masknet/shared-base'
1918
import { WalletContext } from '../../hooks/useWalletContext.js'
@@ -90,7 +89,7 @@ export const ActivityList = memo<ActivityListProps>(({ tokenAddress }) => {
9089
<ActivityListUI
9190
dataSource={dataSource}
9291
chainId={chainId}
93-
formatterTransactionLink={Others.explorerResolver.transactionLink}
92+
formatterTransactionLink={explorerResolver.transactionLink}
9493
/>
9594
)
9695
})

0 commit comments

Comments
 (0)