Skip to content

Commit

Permalink
refactor: mf-6329 rename $MATIC to $POL
Browse files Browse the repository at this point in the history
MF-6360
MF-6361
MF-6362
MF-6363
MF-6364
MF-6365
MF-6366
MF-6367
MF-6369
  • Loading branch information
swkatmask committed Oct 4, 2024
1 parent e129774 commit e115464
Show file tree
Hide file tree
Showing 74 changed files with 192 additions and 150 deletions.
2 changes: 1 addition & 1 deletion packages/mask/popups/components/TokenPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TokenPicker = memo(function TokenPicker({
const isSmartPay = !!useWallet()?.owner
const networks = useNetworks(NetworkPluginID.PLUGIN_EVM, true)
const filteredNetworks = useMemo(() => {
if (isSmartPay) return networks.filter((x) => x.chainId === ChainId.Matic && !x.isCustomized)
if (isSmartPay) return networks.filter((x) => x.chainId === ChainId.Polygon && !x.isCustomized)
return networks
}, [networks, isSmartPay])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const useStyles = makeStyles()((theme) => ({
const minGasPriceOfChain: ChainIdOptionalRecord<BigNumber.Value> = {
[ChainId.BSC]: pow10(9).multipliedBy(5),
[ChainId.Conflux]: pow10(9).multipliedBy(5),
[ChainId.Matic]: pow10(9).multipliedBy(30),
[ChainId.Polygon]: pow10(9).multipliedBy(30),
[ChainId.Astar]: pow10(9).multipliedBy(5), // 5 Gwei
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mask/popups/pages/Wallet/SelectWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const Component = memo(function SelectWallet() {
<Box pt={1} pb={9} px={2} display="flex" flexDirection="column" rowGap="6px">
{wallets
.filter((x) => {
if (x.owner && chainId !== ChainId.Matic) return false
if (x.owner && chainId !== ChainId.Polygon) return false
if (!isVerifyWalletFlow && !isSettingNFTAvatarFlow) return true
return !x.owner
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ interface WalletItemProps {
const WalletItem = memo(function WalletItem({ wallet }: WalletItemProps) {
const { classes } = useStyles({})
const { address, owner } = wallet
const chainId = owner ? ChainId.Matic : ChainId.Mainnet
const chainId = owner ? ChainId.Polygon : ChainId.Mainnet
const { data: balance = '0', isPending } = useBalance(NetworkPluginID.PLUGIN_EVM, {
account: address,
chainId,
Expand Down Expand Up @@ -166,7 +166,7 @@ const WalletItem = memo(function WalletItem({ wallet }: WalletItemProps) {
<FormattedBalance
value={balance}
decimals={18}
symbol={owner ? 'Matic' : 'ETH'}
symbol={owner ? 'Polygon' : 'ETH'}
formatter={formatBalance}
/>
</ProgressiveText>
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/popups/pages/Wallet/SwitchWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const SwitchWallet = memo(function SwitchWallet() {
<div className={classes.content}>
<List dense className={classes.list}>
{wallets.map((item) =>
item.owner && chainId !== ChainId.Matic ?
item.owner && chainId !== ChainId.Polygon ?
null
: <WalletItem
key={item.address}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const AssetsList = memo(function AssetsList() {
const onSwitch = useCallback(() => setAssetsIsExpand((x) => !x), [])
const isSmartPay = !!useWallet()?.owner
const filteredAssets = useMemo(() => {
if (isSmartPay) return assets.filter((x) => x.chainId === ChainId.Matic)
if (isSmartPay) return assets.filter((x) => x.chainId === ChainId.Polygon)
return assets
}, [assets, isSmartPay])

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Approval/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const base: Plugin.Shared.Definition = {
ChainId.Mainnet,
ChainId.BSC,
ChainId.Base,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.xDai,
ChainId.Fantom,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Avatar/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const PLUGIN_ID = PluginID.Avatar
export const PLUGIN_NAME = 'Avatar'
export const PLUGIN_DESCRIPTION = 'NFT Avatar'

export const SUPPORTED_CHAIN_IDS: ChainId[] = [ChainId.Mainnet, ChainId.Matic, ChainId.BSC]
export const SUPPORTED_CHAIN_IDS: ChainId[] = [ChainId.Mainnet, ChainId.Polygon, ChainId.BSC]

export const supportPluginIds = [NetworkPluginID.PLUGIN_EVM, NetworkPluginID.PLUGIN_FLOW, NetworkPluginID.PLUGIN_SOLANA]
2 changes: 1 addition & 1 deletion packages/plugins/Claim/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const base: Plugin.Shared.Definition = {
supportedChainIds: [
ChainId.Mainnet,
ChainId.BSC,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.xDai,
ChainId.Aurora,
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/Collectible/src/helpers/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const RULES = [
hosts: ['opensea.io'],
pathname: /^\/assets\/matic\/(0x[\dA-Fa-f]{40})\/(\d+)/,
pluginID: NetworkPluginID.PLUGIN_EVM,
chainId: ChainIdEVM.Matic,
chainId: ChainIdEVM.Polygon,
provider: SourceType.OpenSea,
},
{
Expand Down Expand Up @@ -64,7 +64,7 @@ const RULES = [
hosts: ['rarible.com', 'app.rarible.com'],
pathname: /^\/token\/polygon\/(0x[\dA-Fa-f]{40}):(\d+)/,
pluginID: NetworkPluginID.PLUGIN_EVM,
chainId: ChainIdEVM.Matic,
chainId: ChainIdEVM.Polygon,
provider: SourceType.Rarible,
},
{
Expand Down Expand Up @@ -130,7 +130,7 @@ const RULES = [
hosts: ['element.market', 'www.element.market'],
pathname: /^\/assets\/polygon\/(0x[\dA-Fa-f]{40})\/(\d+)/,
pluginID: NetworkPluginID.PLUGIN_EVM,
chainId: ChainIdEVM.Matic,
chainId: ChainIdEVM.Polygon,
provider: SourceType.Element,
},

Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/Collectible/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('getPayloadFromURL', () => {
give: 'https://opensea.io/assets/matic/0x2953399124f0cbb46d2cbacd8a89cf0599974963/37184720117030123527613878453157327379579715621769914641223890119352530249488',
expected: {
pluginID: NetworkPluginID.PLUGIN_EVM,
chainId: ChainIdEVM.Matic,
chainId: ChainIdEVM.Polygon,
address: '0x2953399124f0cbb46d2cbacd8a89cf0599974963',
tokenId: '37184720117030123527613878453157327379579715621769914641223890119352530249488',
provider: SourceType.OpenSea,
Expand All @@ -55,7 +55,7 @@ describe('getPayloadFromURL', () => {
give: 'https://rarible.com/token/polygon/0xa9a6a3626993d487d2dbda3173cf58ca1a9d9e9f:68268762474892781208201789517785975190627759693862686943836537749845164189472',
expected: {
pluginID: NetworkPluginID.PLUGIN_EVM,
chainId: ChainIdEVM.Matic,
chainId: ChainIdEVM.Polygon,
address: '0xa9a6a3626993d487d2dbda3173cf58ca1a9d9e9f',
tokenId: '68268762474892781208201789517785975190627759693862686943836537749845164189472',
provider: SourceType.Rarible,
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('getPayloadFromURL', () => {
give: 'https://www.element.market/assets/polygon/0xf3892ecb9802c4bd13a123d9d1041654583915e1/4937',
expected: {
pluginID: NetworkPluginID.PLUGIN_EVM,
chainId: ChainIdEVM.Matic,
chainId: ChainIdEVM.Polygon,
address: '0xf3892ecb9802c4bd13a123d9d1041654583915e1',
tokenId: '4937',
provider: SourceType.Element,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function ConnectionContent(props: ConnectionContentProps) {

const onDeployCallback = useCallback(() => {
return EVMWeb3.deploy?.('0x790116d0685eB197B886DAcAD9C247f785987A4a', undefined, {
chainId: ChainId.Matic,
chainId: ChainId.Polygon,
account: '0x790116d0685eB197B886DAcAD9C247f785987A4a',
})
}, [])
Expand All @@ -133,15 +133,15 @@ export function ConnectionContent(props: ConnectionContentProps) {
signature: '',
},
{
chainId: ChainId.Matic,
chainId: ChainId.Polygon,
account: '0x96ec3286a049b42133c3ddd26777051612bdf61f',
},
)
}, [])

const onChangeOwnerChange = useCallback(() => {
return EVMWeb3.changeOwner?.('0x66b57885E8E9D84742faBda0cE6E3496055b012d', {
chainId: ChainId.Matic,
chainId: ChainId.Polygon,
account: '0x96ec3286a049b42133c3ddd26777051612bdf61f',
})
}, [])
Expand All @@ -153,7 +153,7 @@ export function ConnectionContent(props: ConnectionContentProps) {
'0x31f42841c2db5173425b5223809cf3a38fede360',
'1',
{
chainId: ChainId.Matic,
chainId: ChainId.Polygon,
account: '0x66b57885E8E9D84742faBda0cE6E3496055b012d',
paymentToken: '0x2b9e7ccdf0f4e5b24757c1e1a80e311e34cb10c7',
},
Expand Down Expand Up @@ -521,7 +521,7 @@ export function ConnectionContent(props: ConnectionContentProps) {
switch (pluginID) {
case NetworkPluginID.PLUGIN_EVM:
await onSwitchChain(
chainId === ChainId.Mainnet ? ChainId.Matic : ChainId.Mainnet,
chainId === ChainId.Mainnet ? ChainId.Polygon : ChainId.Mainnet,
)
break
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/NextID/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const base: Plugin.Shared.Definition = {
supportedChainIds: [
ChainId.Mainnet,
ChainId.BSC,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.xDai,
ChainId.Aurora,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function RedPacketDialog(props: RedPacketDialogProps) {

const chainIds: ChainId[] = useMemo(() => {
if (currentTab === tabs.tokens) return base.enableRequirement.web3[NetworkPluginID.PLUGIN_EVM].supportedChainIds
return [ChainId.Mainnet, ChainId.BSC, ChainId.Matic]
return [ChainId.Mainnet, ChainId.BSC, ChainId.Polygon]
}, [currentTab === tabs.tokens])
const chainId = chainIds.includes(contextChainId) ? contextChainId : ChainId.Mainnet
if (process.env.NODE_ENV === 'development' && !chainIds.includes(contextChainId)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TokenIcon } from '@masknet/shared'
import { NetworkPluginID } from '@masknet/shared-base'
import { makeStyles } from '@masknet/theme'
import { useChainContext, useNetworkDescriptor } from '@masknet/web3-hooks-base'
import { useChainContext, useFungibleToken, useNetworkDescriptor } from '@masknet/web3-hooks-base'
import { FireflyRedPacketAPI, type RedPacketJSONPayload } from '@masknet/web3-providers/types'
import { formatBalance } from '@masknet/web3-shared-base'
import { ChainId, NETWORK_DESCRIPTORS } from '@masknet/web3-shared-evm'
Expand All @@ -10,6 +10,8 @@ import { format, fromUnixTime } from 'date-fns'
import { memo } from 'react'
import { RedPacketTrans, useRedPacketTrans } from '../locales/index.js'
import { RedPacketActionButton } from './RedPacketActionButton.js'
import { useRedpacketToken } from './hooks/useRedpacketToken.js'
import { useEverSeen } from '@masknet/shared-base-ui'

const DEFAULT_BACKGROUND = NETWORK_DESCRIPTORS.find((x) => x.chainId === ChainId.Mainnet)!.backgroundGradient!
const useStyles = makeStyles<{ listItemBackground?: string; listItemBackgroundIcon?: string }>()((
Expand Down Expand Up @@ -154,26 +156,32 @@ export const RedPacketInHistoryList = memo(function RedPacketInHistoryList(props
claim_amounts,
token_symbol,
token_logo,
chain_id,
redpacket_id,
redpacket_status,
claim_strategy,
share_from,
theme_id,
} = history
const [seen, redpacketRef] = useEverSeen()
const chainId = history.chain_id
const t = useRedPacketTrans()

const { account } = useChainContext<NetworkPluginID.PLUGIN_EVM>()
const networkDescriptor = useNetworkDescriptor(NetworkPluginID.PLUGIN_EVM, chain_id)
const networkDescriptor = useNetworkDescriptor(NetworkPluginID.PLUGIN_EVM, chainId)

const { classes, cx } = useStyles({
listItemBackground: networkDescriptor?.backgroundGradient,
listItemBackgroundIcon: networkDescriptor ? `url("${networkDescriptor.icon}")` : undefined,
})

// Only concern about MATIC token which has been renamed to POL
const { data: tokenAddress } = useRedpacketToken(chainId, history.trans_hash, seen && token_symbol === 'MATIC')
const { data: token } = useFungibleToken(NetworkPluginID.PLUGIN_EVM, tokenAddress, undefined, { chainId })
const tokenSymbol = token?.symbol ?? token_symbol

return (
<ListItem className={classes.root}>
<section className={classes.contentItem}>
<section className={classes.contentItem} ref={redpacketRef}>
<Box className={classes.box}>
<Box className={classes.content}>
<section className={classes.section}>
Expand Down Expand Up @@ -210,11 +218,11 @@ export const RedPacketInHistoryList = memo(function RedPacketInHistoryList(props
themeId={theme_id}
redpacketMsg={rp_msg}
tokenInfo={{
symbol: token_symbol,
symbol: tokenSymbol,
decimals: token_decimal,
amount: total_amounts,
}}
chainId={chain_id}
chainId={chainId}
totalAmount={total_amounts}
createdAt={create_time}
/>
Expand All @@ -239,15 +247,15 @@ export const RedPacketInHistoryList = memo(function RedPacketInHistoryList(props
significant: 2,
isPrecise: true,
}),
symbol: token_symbol,
symbol: tokenSymbol,
}}
/>
</Typography>
{token_logo ?
<TokenIcon
className={classes.icon}
address={''}
name={token_symbol}
name={tokenSymbol}
logoURL={token_logo}
/>
: null}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { NetworkPluginID } from '@masknet/shared-base'
import { useWeb3, useWeb3Connection } from '@masknet/web3-hooks-base'
import HappyRedPacketV4ABI from '@masknet/web3-contracts/abis/HappyRedPacketV4.json'

import type { ChainId } from '@masknet/web3-shared-evm'
import { useQuery } from '@tanstack/react-query'

/**
* Get redpacket token address from transaction logs
*/
export function useRedpacketToken(chainId: ChainId, hash: string, enabled?: boolean) {
const web3 = useWeb3(NetworkPluginID.PLUGIN_EVM, { chainId })
const web3Conn = useWeb3Connection(NetworkPluginID.PLUGIN_EVM, { chainId })

const inputs = HappyRedPacketV4ABI!.find((x) => x.name === 'CreationSuccess' && x.type === 'event')?.inputs
return useQuery({
enabled,
queryKey: ['redpacket', 'token', chainId, hash],
queryFn: async () => {
// CreationSuccess(uint256,bytes32,string,string,address,uint256,address,uint256,bool,uint256)
const TOPIC = '0x86af556fd7cfab9462285ad44f2d5913527c539ff549f74731ca9997ca534018'

const receipt = await web3Conn.getTransactionReceipt(hash)
if (!receipt || !inputs) return null
if (!web3) return
const log = receipt.logs.find((x) => x.topics[0] === TOPIC)
if (!log) return null

const result = web3.eth.abi.decodeLog(inputs, log.data, log?.topics)
return result.token_address
},
})
}
2 changes: 1 addition & 1 deletion packages/plugins/RedPacket/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const base = {
supportedChainIds: [
ChainId.Mainnet,
ChainId.BSC,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.Base,
ChainId.xDai,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Savings/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const base: Plugin.Shared.Definition = {
supportedChainIds: [
ChainId.Mainnet,
ChainId.BSC,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.xDai,
ChainId.Aurora,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Tips/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const base: Plugin.Shared.Definition = {
ChainId.Mainnet,
ChainId.BSC,
ChainId.Base,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.xDai,
ChainId.Aurora,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/Trader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const TRADER_WEB3_CONFIG = {
supportedChainIds: [
ChainId.Mainnet,
ChainId.BSC,
ChainId.Matic,
ChainId.Polygon,
ChainId.Arbitrum,
ChainId.xDai,
ChainId.Aurora,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const Web3ProfileGlobalInjection = memo(function Web3ProfileGlobalInjecti
: null}

{lensOpen && handle ?
<EVMWeb3ContextProvider chainId={ChainId.Matic}>
<EVMWeb3ContextProvider chainId={ChainId.Polygon}>
<FollowLensDialog handle={handle} onClose={closeLensDialog} />
</EVMWeb3ContextProvider>
: null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export function FollowLensDialog({ handle, onClose }: Props) {
<ChainBoundary
disableConnectWallet
expectedPluginID={pluginID}
expectedChainId={ChainId.Matic}
expectedChainId={ChainId.Polygon}
ActionButtonPromiseProps={{
variant: 'roundedContained',
className: classes.followAction,
Expand Down Expand Up @@ -427,7 +427,7 @@ export function FollowLensDialog({ handle, onClose }: Props) {
<WalletConnectedBoundary
offChain
hideRiskWarningConfirmed
expectedChainId={ChainId.Matic}
expectedChainId={ChainId.Polygon}
ActionButtonProps={{ variant: 'roundedContained' }}>
{tips ?
<Typography className={classes.tips}>{tips}</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const HandlerDescription = memo<HandlerDescriptionProps>(({ profiles, cur
onClick={() =>
SelectProviderModal.open({
requiredSupportPluginID: NetworkPluginID.PLUGIN_EVM,
requiredSupportChainIds: [ChainId.Matic],
requiredSupportChainIds: [ChainId.Polygon],
})
}>
{t.wallet_status_button_change()}
Expand Down
Loading

0 comments on commit e115464

Please sign in to comment.