Skip to content

Commit

Permalink
[Release] Hotfix 2.24.1 => 2.24.2 (patch) (#11339)
Browse files Browse the repository at this point in the history
* chore: bump version to 2.24.2

* fix: nfts in red packet might be transfered (#11337)

* feat: mf-5990 add x1 chain (#11330)

* fix: x1 testnet (#11341)

* fix: x1 testnet (#11346)

* fix: capitalize

* fix: enable tips on X1 Testnet

* fix: set network type to x1 testnet (#11349)

---------

Co-authored-by: UncleBill <billbill290@gmail.com>
  • Loading branch information
guanbinrui and UncleBill committed Feb 2, 2024
1 parent 27c6ddc commit 3331d63
Show file tree
Hide file tree
Showing 24 changed files with 172 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.24.1",
"version": "2.24.2",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
Expand Up @@ -99,7 +99,11 @@ const AssetItem = memo(function AssetItem({ asset, onItemClick, ...rest }: Asset
const providerURL = network?.isCustomized ? network.rpcUrl : undefined
const [seen, ref] = useEverSeen<HTMLLIElement>()
// Debank might not provide asset from current custom network
const tryRpc = (!asset.balance || isZero(asset.balance)) && network?.isCustomized && seen
// TODO Temporarily get X1 Testnet balance via rpc
const tryRpc =
(!asset.balance || isZero(asset.balance)) &&
(network?.isCustomized || network?.chainId === ChainId.X1_Testnet) &&
seen
const { data: rpcBalance, isPending } = useFungibleTokenBalance(
NetworkPluginID.PLUGIN_EVM,
asset.address,
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/shared-ui/locales/ja-JP.json
Expand Up @@ -583,7 +583,7 @@
"plugin_infra_descriptor_token_revoke_fail": "トークンコントラクトの取り消しに失敗しました。",
"plugin_infra_descriptor_token_approve_title": "トークンのロック解除",
"plugin_infra_descriptor_token_approve": "{{- tokenAmountDescription}} のロックを解除",
"plugin_infra_descriptor_token_approve_success": "{{- tokenAmountDescription}} のロックを解除しました",
"plugin_infra_descriptor_token_approve_success": "{{- symbol}} のロックを解除しました",
"plugin_infra_descriptor_token_revoke_but_set_positive_cap": " {{spender}}の{{- tokenAmountDescription}} を承認しました。トークンを取り消したい場合は、カスタム支出上限金額を 0 にしてからもう一度お試しください。",
"plugin_infra_descriptor_token_approve_but_set_zero_cap": "{{symbol}} は正常に承認されませんでした。支出上限を 0 に設定せず、もう一度お試しください。",
"plugin_infra_descriptor_token_fail": "トークンコントラクトのロック解除に失敗しました。",
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/shared-ui/locales/ko-KR.json
Expand Up @@ -567,7 +567,7 @@
"plugin_infra_descriptor_token_revoke_fail": "토큰 컨트렉트 승인 취소 실패",
"plugin_infra_descriptor_token_approve_title": "토큰 언락",
"plugin_infra_descriptor_token_approve": "{{- tokenAmountDescription}} 언락",
"plugin_infra_descriptor_token_approve_success": "{{- tokenAmountDescription}} 언락 성공",
"plugin_infra_descriptor_token_approve_success": "{{- symbol}} 언락 성공",
"plugin_infra_descriptor_token_revoke_but_set_positive_cap": "{{spender}} 에 대해 {{- tokenAmountDescription}} 을(를) 승인했습니다. 해당 토큰을 취소하려면 맞춤형 지출 한도 금액을 0으로 유지한 후 다시 시도하세요.",
"plugin_infra_descriptor_token_approve_but_set_zero_cap": "{{symbol}} 승인하지 않습니다. 지출 한도 0으로 설치하지 마시고 다시 시도하세요.",
"plugin_infra_descriptor_token_fail": "토큰 컨트렉트 언락 실패",
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/shared-ui/locales/qya-AA.json
Expand Up @@ -583,7 +583,7 @@
"plugin_infra_descriptor_token_revoke_fail": "crwdns18420:0crwdne18420:0",
"plugin_infra_descriptor_token_approve_title": "crwdns18422:0crwdne18422:0",
"plugin_infra_descriptor_token_approve": "crwdns18424:0{{- tokenAmountDescription}}crwdne18424:0",
"plugin_infra_descriptor_token_approve_success": "crwdns18426:0{{- tokenAmountDescription}}crwdne18426:0",
"plugin_infra_descriptor_token_approve_success": "crwdns18426:0{{- symbol}}crwdne18426:0",
"plugin_infra_descriptor_token_revoke_but_set_positive_cap": "crwdns20007:0{{- tokenAmountDescription}}crwdnd20007:0{{spender}}crwdne20007:0",
"plugin_infra_descriptor_token_approve_but_set_zero_cap": "crwdns20009:0{{symbol}}crwdne20009:0",
"plugin_infra_descriptor_token_fail": "crwdns18428:0crwdne18428:0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/shared-ui/locales/zh-CN.json
Expand Up @@ -582,7 +582,7 @@
"plugin_infra_descriptor_token_revoke_fail": "撤销代币授权失败。",
"plugin_infra_descriptor_token_approve_title": "解锁代币",
"plugin_infra_descriptor_token_approve": "解锁 {{tokenAmountDescription}}",
"plugin_infra_descriptor_token_approve_success": "解锁 {{tokenAmountDescription}} 成功",
"plugin_infra_descriptor_token_approve_success": "解锁 {{- symbol}} 成功",
"plugin_infra_descriptor_token_revoke_but_set_positive_cap": "您已经授权了{{spender}} 的 {{- tokenAmountDescription}} 。如果您想要撤销该Token,请将自定义支出上限保持为 0 并再试一次。",
"plugin_infra_descriptor_token_approve_but_set_zero_cap": "您没有成功授权 {{symbol}} 。请不要设置支出上限为 0,然后再试一次。",
"plugin_infra_descriptor_token_fail": "解锁代币合约失败。",
Expand Down
26 changes: 19 additions & 7 deletions packages/plugins/RedPacket/src/SiteAdaptor/RedPacketNft.tsx
@@ -1,5 +1,12 @@
import { useCallback, useEffect, useMemo } from 'react'
import { makeStyles, ActionButton, parseColor, ShadowRootTooltip, useDetectOverflow } from '@masknet/theme'
import {
makeStyles,
ActionButton,
parseColor,
ShadowRootTooltip,
useDetectOverflow,
useCustomSnackbar,
} from '@masknet/theme'
import { signMessage, type ChainId } from '@masknet/web3-shared-evm'
import { type RedPacketNftJSONPayload } from '@masknet/web3-providers/types'
import { Card, Typography, Button, Box } from '@mui/material'
Expand Down Expand Up @@ -312,13 +319,18 @@ export function RedPacketNft({ payload }: RedPacketNftProps) {
})
}, [nftRedPacketContract, payload.id, account, Hub])

const { showSnackbar } = useCustomSnackbar()
const claim = useCallback(async () => {
const hash = await claimCallback()
await checkResult()
if (typeof hash === 'string') {
retryAvailability()
} else if (hash instanceof Error) {
showSnackbar(hash.message, {
variant: 'error',
})
}
}, [claimCallback, retryAvailability])
}, [claimCallback, retryAvailability, showSnackbar])

if (availabilityError) return <ReloadStatus message={t.go_wrong()} onRetry={retryAvailability} />

Expand Down Expand Up @@ -412,7 +424,7 @@ export function RedPacketNft({ payload }: RedPacketNftProps) {
isClaiming={isClaiming}
claimed={availability.isClaimed}
onShare={onShare}
claim={claim}
onClaim={claim}
/>
)}
</div>
Expand All @@ -422,12 +434,12 @@ export function RedPacketNft({ payload }: RedPacketNftProps) {
interface OperationFooterProps {
claimed: boolean
isClaiming: boolean
onShare(): void
claim(): Promise<void>
chainId: ChainId
onShare(): void
onClaim(): Promise<void>
}

function OperationFooter({ claimed, onShare, chainId, claim, isClaiming }: OperationFooterProps) {
function OperationFooter({ claimed, chainId, isClaiming, onClaim, onShare }: OperationFooterProps) {
const { classes } = useStyles({ claimed, outdated: false })
const t = useRedPacketTrans()

Expand Down Expand Up @@ -460,7 +472,7 @@ function OperationFooter({ claimed, onShare, chainId, claim, isClaiming }: Opera
variant="roundedDark"
loading={isClaiming}
disabled={isClaiming}
onClick={claim}
onClick={onClaim}
className={classes.button}
fullWidth>
{isClaiming ? t.claiming() : t.claim()}
Expand Down
Expand Up @@ -11,13 +11,14 @@ const EXTRA_GAS_PER_NFT = 335
export function useClaimNftRedpacketCallback(id: string, totalAmount: number | undefined, signedMsg: string) {
const { account, chainId } = useChainContext<NetworkPluginID.PLUGIN_EVM>()
const nftRedPacketContract = useNftRedPacketContract(chainId)
return useAsyncFn(async () => {
return useAsyncFn(async (): Promise<string | undefined | Error> => {
if (!nftRedPacketContract || !id || !signedMsg || !account || !totalAmount) return

const transaction = nftRedPacketContract.methods.claim(id, signedMsg, account)
const estimatedGas = await transaction.estimateGas({ from: account })
const tx = await new ContractTransaction(nftRedPacketContract).fillAll(transaction, {
from: account,
gas: toFixed((await transaction.estimateGas({ from: account })) + EXTRA_GAS_PER_NFT * totalAmount),
gas: toFixed(estimatedGas + EXTRA_GAS_PER_NFT * totalAmount),
chainId,
})
return EVMWeb3.sendTransaction(tx, { chainId })
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/RedPacket/src/base.ts
Expand Up @@ -35,6 +35,7 @@ export const base: Plugin.Shared.Definition = {
ChainId.Conflux,
ChainId.Astar,
ChainId.Scroll,
ChainId.X1_Testnet,
],
},
[NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] },
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/Tips/src/base.ts
Expand Up @@ -35,6 +35,7 @@ export const base: Plugin.Shared.Definition = {
ChainId.Astar,
ChainId.Scroll,
ChainId.Optimism,
ChainId.X1_Testnet,
],
},
[NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] },
Expand Down
Expand Up @@ -61,6 +61,8 @@ export function getEVMAvailableTraderProviders(networkType?: NetworkType) {
case NetworkType.Conflux:
case NetworkType.Moonbeam:
case NetworkType.CustomNetwork:
case NetworkType.X1:
case NetworkType.X1_Testnet:
console.error('To be implement network:', networkType)
return EMPTY_LIST
default:
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/Trader/src/providers/ZeroX.ts
Expand Up @@ -50,6 +50,8 @@ function getNativeTokenLabel(networkType: NetworkType) {
case NetworkType.Scroll:
case NetworkType.Moonbeam:
case NetworkType.CustomNetwork:
case NetworkType.X1:
case NetworkType.X1_Testnet:
return ZRX_NATIVE_TOKEN_ADDRESS
default:
safeUnreachable(networkType)
Expand Down
8 changes: 6 additions & 2 deletions packages/web3-constants/evm/ethereum.json
Expand Up @@ -19,7 +19,9 @@
"Fantom": "0xc119574d5fb333f5ac018658d4d8b5035e16bf39",
"Aurora": "0xC119574D5Fb333F5AC018658D4d8b5035E16bf39",
"Astar": "0xf5056B96ab242C566002852d0b98ce0BcDf1af51",
"Scroll": "0xbC7d98985966f56A66B0cB5F23d865676dc2ac84"
"Scroll": "0xbC7d98985966f56A66B0cB5F23d865676dc2ac84",
"X1": "0x8A42F70047a99298822dD1dbA34b454fc49913F2",
"X1_Testnet": "0x8A42F70047a99298822dD1dbA34b454fc49913F2"
},
"MULTICALL_ADDRESS": {
"Mainnet": "0x1F98415757620B543A52E61c46B32eB19261F984",
Expand All @@ -44,7 +46,9 @@
"Aurora": "0x6cc1b1058F9153358278C35E0b2D382f1585854B",
"Conflux": "0x19f179d7e0d7d9f9d5386afff64271d98a91615b",
"Astar": "0x1410304B91a280ad083196B0B50e9d8df749d860",
"Scroll": "0x20Ee232E34B87061fE3ba0DB738A3531A3e915BF"
"Scroll": "0x20Ee232E34B87061fE3ba0DB738A3531A3e915BF",
"X1": "0xF8935Df67cAB7BfcA9532D1Ac2088C5c39b995b5",
"X1_Testnet": "0xF8935Df67cAB7BfcA9532D1Ac2088C5c39b995b5"
},
"ENS_REGISTRAR_ADDRESS": {
"Mainnet": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
Expand Down
8 changes: 6 additions & 2 deletions packages/web3-constants/evm/nft-red-packet.json
Expand Up @@ -13,7 +13,9 @@
"Aurora_Testnet": "0x97369fEE7db34E0BfE47861f2ec44b4378d13eB4",
"Conflux": "0x5b966f3a32db9c180843bcb40267a66b73e4f022",
"Astar": "0xc3e62b2CC70439C32a381Bfc056aCEd1d7162cef",
"Scroll": "0x727F8030964CCEC6B0E344399c8d8E2B4C837351"
"Scroll": "0x727F8030964CCEC6B0E344399c8d8E2B4C837351",
"X1": "0xd81c16d71432d7df04575ffe9fed76f837fea0cc",
"X1_Testnet": "0xd81c16d71432d7df04575ffe9fed76f837fea0cc"
},
"NFT_RED_PACKET_ADDRESS_BLOCK_HEIGHT": {
"Mainnet": 13229711,
Expand Down Expand Up @@ -41,6 +43,8 @@
"Aurora_Testnet": 0,
"Conflux": 0,
"Astar": 0,
"Scroll": 96705
"Scroll": 96705,
"X1": 0,
"X1_Testnet": 7319723
}
}
8 changes: 6 additions & 2 deletions packages/web3-constants/evm/red-packet.json
Expand Up @@ -36,7 +36,9 @@
"Aurora_Testnet": "0xdB93cCd481012bB5D1E2c8d0aF7C5f2940c00fdC",
"Conflux": "0x96c7d011cdfd467f551605f0f5fce279f86f4186",
"Astar": "0x2cF46Db820e279c5fBF778367D49d9C931D54524",
"Scroll": "0x16f61cb37169523635B6761f3C946892fb3c18fB"
"Scroll": "0x16f61cb37169523635B6761f3C946892fb3c18fB",
"X1": "0x977baB5f7e2cEd0C91fDA890Ed1DBDfD3Ee9AE81",
"X1_Testnet": "0x977baB5f7e2cEd0C91fDA890Ed1DBDfD3Ee9AE81"
},
"HAPPY_RED_PACKET_ADDRESS_V4_BLOCK_HEIGHT": {
"Mainnet": 12939427,
Expand Down Expand Up @@ -64,6 +66,8 @@
"Aurora_Testnet": 77918765,
"Conflux": 37670572,
"Astar": 910985,
"Scroll": 96705
"Scroll": 96705,
"X1": 0,
"X1_Testnet": 7320220
}
}
12 changes: 9 additions & 3 deletions packages/web3-constants/evm/rpc.json
Expand Up @@ -70,7 +70,9 @@
"Aurora_Testnet": ["https://testnet.aurora.dev"],
"Conflux": ["https://evm.confluxrpc.com"],
"Astar": ["https://astar.api.onfinality.io/public"],
"Scroll": ["https://rpc.scroll.io"]
"Scroll": ["https://rpc.scroll.io"],
"X1": ["https://rpc.x1.tech"],
"X1_Testnet": ["https://testrpc.x1.tech"]
},
"RPC_URLS_OFFICIAL": {
"Mainnet": ["https://mainnet.infura.io/v3/d65858b010d249419cf8687eca12b094"],
Expand Down Expand Up @@ -98,7 +100,9 @@
"Aurora_Testnet": ["https://testnet.aurora.dev/"],
"Conflux": ["https://evm.confluxrpc.com"],
"Astar": ["https://rpc.astar.network:8545"],
"Scroll": ["https://rpc.scroll.io"]
"Scroll": ["https://rpc.scroll.io"],
"X1": ["https://rpc.x1.tech"],
"X1_Testnet": ["https://testrpc.x1.tech"]
},
"RPC_WEIGHTS": {
"Mainnet": [0, 1, 2, 3, 4],
Expand Down Expand Up @@ -126,6 +130,8 @@
"Aurora_Testnet": [0, 0, 0, 0, 0],
"Conflux": [0, 0, 0, 0, 0],
"Astar": [0, 0, 0, 0, 0],
"Scroll": [0, 0, 0, 0, 0]
"Scroll": [0, 0, 0, 0, 0],
"X1": [0, 0, 0, 0, 0],
"X1_Testnet": [0, 0, 0, 0, 0]
}
}
4 changes: 3 additions & 1 deletion packages/web3-constants/evm/token-list.json
Expand Up @@ -25,6 +25,8 @@
"Aurora_Testnet": [],
"Conflux": ["https://tokens.r2d2.to/latest/1030/tokens.json"],
"Astar": ["https://tokens.r2d2.to/latest/592/tokens.json"],
"Scroll": ["https://tokens.r2d2.to/latest/534352/tokens.json"]
"Scroll": ["https://tokens.r2d2.to/latest/534352/tokens.json"],
"X1": ["https://tokens.r2d2.to/latest/196/tokens.json"],
"X1_Testnet": ["https://tokens.r2d2.to/latest/195/tokens.json"]
}
}
16 changes: 12 additions & 4 deletions packages/web3-constants/evm/token.json
Expand Up @@ -23,7 +23,9 @@
"Fantom": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83",
"Aurora": "0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB",
"Astar": "0xaeaaf0e2c81af264101b9129c00f4440ccf0f720",
"Scroll": "0x5300000000000000000000000000000000000004"
"Scroll": "0x5300000000000000000000000000000000000004",
"X1": "0x049a970485cf54904a6da1e1cea2ac18c9b8fb9f",
"X1_Testnet": "0x049a970485cf54904a6da1e1cea2ac18c9b8fb9f"
},
"LDO_stETH_ADDRESS": {
"Mainnet": "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
Expand Down Expand Up @@ -53,7 +55,9 @@
"Fantom": "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
"Aurora": "0xb12bfca5a55806aaf64e99521918a4bf0fc40802",
"Astar": "0x6a2d262D56735DbA19Dd70682B39F6bE9a931D98",
"Scroll": "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4"
"Scroll": "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
"X1": "0x2e1cba4a9f6e69d27e65046fc93b873b05f79a39",
"X1_Testnet": "0x2e1cba4a9f6e69d27e65046fc93b873b05f79a39"
},
"USDT_ADDRESS": {
"Mainnet": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
Expand All @@ -68,7 +72,9 @@
"Celo": "0xb020d981420744f6b0fedd22bb67cd37ce18a1d5",
"Aurora": "0x4988a896b1227218e4a686fde5eabdcabd91571f",
"Astar": "0x3795C36e7D12A8c252A20C5a7B455f7c57b60283",
"Scroll": "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df"
"Scroll": "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df",
"X1": "0xb81fe42de28e7452088b77f3eb9685487734e088",
"X1_Testnet": "0xb81fe42de28e7452088b77f3eb9685487734e088"
},
"aUSDT_ADDRESS": {
"Mainnet": "0x71fc860F7D3A592A4a98740e39dB31d25db65ae8",
Expand Down Expand Up @@ -309,7 +315,9 @@
"Aurora_Testnet": "0x0000000000000000000000000000000000000000",
"Conflux": "0x0000000000000000000000000000000000000000",
"Astar": "0x0000000000000000000000000000000000000000",
"Scroll": "0x0000000000000000000000000000000000000000"
"Scroll": "0x0000000000000000000000000000000000000000",
"X1": "0x0000000000000000000000000000000000000000",
"X1_Testnet": "0x0000000000000000000000000000000000000000"
},
"WETH_ADDRESS": {
"Mainnet": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
Expand Down
Binary file added packages/web3-shared/evm/src/assets/x1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions packages/web3-shared/evm/src/constants/chains.json
Expand Up @@ -674,6 +674,54 @@
}
]
},
{
"chainId": 196,
"type": "X1",
"name": "X1",
"fullName": "X1",
"network": "testnet",
"shortName": "x1",
"features": [],
"nativeCurrency": {
"chainId": 196,
"name": "OKB",
"symbol": "OKB",
"decimals": 18,
"logoURL": "https://static.okx.com/cdn/wallet/logo/okb.png?x-oss-process=image/format,webp/ignore-error,1"
},
"infoURL": "https://www.okx.com/web3",
"explorers": [
{
"name": "X1 explorer",
"url": "https://www.okx.com/explorer/x1",
"standard": "EIP3091"
}
]
},
{
"chainId": 195,
"type": "X1",
"name": "X1 Testnet",
"fullName": "X1 Testnet",
"network": "mainnet",
"shortName": "x1",
"features": [],
"nativeCurrency": {
"chainId": 195,
"name": "OKB",
"symbol": "OKB",
"decimals": 18,
"logoURL": "https://static.okx.com/cdn/wallet/logo/okb.png?x-oss-process=image/format,webp/ignore-error,1"
},
"infoURL": "https://www.okx.com/web3",
"explorers": [
{
"name": "X1 explorer",
"url": "https://www.okx.com/explorer/x1-test",
"standard": "EIP3091"
}
]
},
{
"chainId": 25,
"name": "Cronos",
Expand Down

0 comments on commit 3331d63

Please sign in to comment.