diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 238a8b5587cc..c97cf8862f06 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -358,13 +358,15 @@ "plugin_red_packet_hint": "You can withdraw the remaining balance 24 hours after the Lucky Drop is sent.", "plugin_red_packet_token": "Token", "plugin_red_packet_message_label": "Title", - "plugin_red_packet_create_with_token": "Creating Lucky Drop with {{symbol}}", + "plugin_red_packet_create": "Create a Lucky Drop", + "plugin_red_packet_create_with_token": "Create a Lucky Drop with {{amount}} {{symbol}}", "plugin_red_packet_history_duration": "Time: {{startTime}} ~ {{endTime}} (UTC+8)", "plugin_red_packet_history_total_amount": "Total Amount: {{amount}} {{symbol}}", "plugin_red_packet_history_total_claimed_amount": "Total: {{claimedAmount}}/{{amount}} {{symbol}}", "plugin_red_packet_history_claimed": "Claimed: {{claimedShares}}/{{shares}} Share", "plugin_red_packet_history_split_mode": "Split Mode: {{mode}}", "plugin_red_packet_history_send": "Send", + "plugin_nft_red_packet_create": "Create an NFT Lucky Drop", "plugin_red_packet_nft_account_name": "Wallet account", "plugin_red_packet_nft_attached_message": "Attached Message", "plugin_red_packet_nft_total_amount": "Total Amount", @@ -535,6 +537,7 @@ "plugin_ito_region_ban": "This Pool is banned by its creator at your region", "plugin_ito_next": "Next", "plugin_ito_back": "Back", + "plugin_ito_transaction_dialog_summary_with_no_token": "Create an ITO.", "plugin_ito_transaction_dialog_summary": "Create an ITO with {{amount}} {{symbol}}.", "plugin_ito_swap": "Swap", "plugin_ito_send_tip": "You can find your ITOs in the Past tab.", diff --git a/packages/mask/shared-ui/locales/ja-JP.json b/packages/mask/shared-ui/locales/ja-JP.json index 87488e9583c5..6278ba3a1e6f 100644 --- a/packages/mask/shared-ui/locales/ja-JP.json +++ b/packages/mask/shared-ui/locales/ja-JP.json @@ -163,7 +163,7 @@ "plugin_red_packet_refunding_for": "{{balance}} {{symbol}} の投げ銭を払い戻し中", "plugin_red_packet_amount_per_share": "1株当たりの金額", "plugin_red_packet_send_symbol": "{{symbol}} を送る", - "plugin_red_packet_create_with_token": "{{symbol}} で投げ銭を作成する", + "plugin_red_packet_create_with_token": "{{amount}} {{symbol}} で投げ銭を作成する", "plugin_gitcoin_readme": "このサービスを利用するにあたり、寄付金額の 5% が Gitcoin grants development fund に寄付されます", "plugin_gitcoin_select_a_token": "トークンを選択する", "plugin_gitcoin_enter_an_amount": "量を決める", diff --git a/packages/mask/shared-ui/locales/ko-KR.json b/packages/mask/shared-ui/locales/ko-KR.json index 605c497aa87e..ee5612e3883d 100644 --- a/packages/mask/shared-ui/locales/ko-KR.json +++ b/packages/mask/shared-ui/locales/ko-KR.json @@ -314,7 +314,7 @@ "plugin_red_packet_hint": "레드 패킷이 공유된 후 24시간 후에 나머지 잔액을 인출할 수 있습니다.", "plugin_red_packet_token": "토큰", "plugin_red_packet_message_label": "제목", - "plugin_red_packet_create_with_token": "{{symbol}} 으로 빨간 백 만드는 중", + "plugin_red_packet_create_with_token": "{{amount}} {{symbol}} 으로 빨간 백 만드는 중", "plugin_red_packet_history_duration": "시간: {{startTime}} ~ {{endTime}} (UTC+8)", "plugin_red_packet_history_total_amount": "총액: {{amount}} {{symbol}}", "plugin_red_packet_history_total_claimed_amount": "전체: {{claimedAmount}}/{{amount}} {{symbol}}", diff --git a/packages/mask/shared-ui/locales/qya-AA.json b/packages/mask/shared-ui/locales/qya-AA.json index 138f4b8e176c..f85d7436e727 100644 --- a/packages/mask/shared-ui/locales/qya-AA.json +++ b/packages/mask/shared-ui/locales/qya-AA.json @@ -358,7 +358,7 @@ "plugin_red_packet_hint": "crwdns4771:0crwdne4771:0", "plugin_red_packet_token": "crwdns4773:0crwdne4773:0", "plugin_red_packet_message_label": "crwdns8157:0crwdne8157:0", - "plugin_red_packet_create_with_token": "crwdns4775:0{{symbol}}crwdne4775:0", + "plugin_red_packet_create_with_token": "crwdns4775:0{{amount}} {{symbol}}crwdne4775:0", "plugin_red_packet_history_duration": "crwdns4777:0{{startTime}}crwdnd4777:0{{endTime}}crwdne4777:0", "plugin_red_packet_history_total_amount": "crwdns4779:0{{amount}}crwdnd4779:0{{symbol}}crwdne4779:0", "plugin_red_packet_history_total_claimed_amount": "crwdns4781:0{{claimedAmount}}crwdnd4781:0{{amount}}crwdnd4781:0{{symbol}}crwdne4781:0", diff --git a/packages/mask/shared-ui/locales/zh-CN.json b/packages/mask/shared-ui/locales/zh-CN.json index cdacba72d114..9721aa728801 100644 --- a/packages/mask/shared-ui/locales/zh-CN.json +++ b/packages/mask/shared-ui/locales/zh-CN.json @@ -353,7 +353,7 @@ "plugin_red_packet_hint": "你可以在红包发送的24小时后提取红包余额。", "plugin_red_packet_token": "代币", "plugin_red_packet_message_label": "标题", - "plugin_red_packet_create_with_token": "使用 {{symbol}} 创建红包", + "plugin_red_packet_create_with_token": "使用 {{amount}} {{symbol}} 创建红包", "plugin_red_packet_history_duration": "时间: {{startTime}} ~ {{endTime}} (UTC+8)", "plugin_red_packet_history_total_amount": "总额: {{amount}} {{symbol}}", "plugin_red_packet_history_total_claimed_amount": "总额: {{claimedAmount}}/{{amount}} {{symbol}}", diff --git a/packages/mask/shared-ui/locales/zh-TW.json b/packages/mask/shared-ui/locales/zh-TW.json index 7a5c2512295a..fea4dc44b50b 100644 --- a/packages/mask/shared-ui/locales/zh-TW.json +++ b/packages/mask/shared-ui/locales/zh-TW.json @@ -282,7 +282,7 @@ "plugin_red_packet_back": "返回", "plugin_red_packet_token": "代幣", "plugin_red_packet_message_label": "標題", - "plugin_red_packet_create_with_token": "使用 {{symbol}} 建立紅包", + "plugin_red_packet_create_with_token": "使用 {{amount}} {{symbol}} 建立紅包", "plugin_red_packet_history_duration": "時間: {{startTime}} ~ {{endTime}} (UTC+8)", "plugin_red_packet_history_total_amount": "總額: {{amount}} {{symbol}}", "plugin_red_packet_history_total_claimed_amount": "總共: {{claimedAmount}}/{{amount}} {{symbol}}", diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx index 22d4a72d4b76..acfbd73ea910 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/RedPacketDialog.tsx @@ -209,9 +209,8 @@ export default function RedPacketDialog(props: RedPacketDialogProps) { open: true, state: createState, summary: t('plugin_red_packet_create_with_token', { - symbol: `${formatBalance(createSettings?.total, createSettings?.token?.decimals)} ${ - createSettings?.token.symbol - }`, + amount: formatBalance(createSettings?.total, createSettings?.token?.decimals), + symbol: createSettings?.token.symbol, }), }) }, [createState /* update tx dialog only if state changed */]) diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx index a1b1dbfb00bd..605a8b0f8608 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/TransactionDescription.tsx @@ -1,7 +1,10 @@ import type { TransactionReceipt } from 'web3-core' +import { first, last } from 'lodash-unified' import { + ChainId, useNativeTokenDetailed, EthereumRpcType, + useChainId, formatBalance, NativeTokenDetailed, ERC20TokenDetailed, @@ -10,7 +13,7 @@ import { } from '@masknet/web3-shared-evm' import { pow10 } from '@masknet/web3-shared-base' import type Services from '../../../../extension/service' -import { first, last } from 'lodash-unified' +import { getContractMethodDescription } from './contractMethodDescription' function getTokenAmountDescription(amount = '0', tokenDetailed?: FungibleTokenDetailed, negative?: boolean) { const symbol = negative ? '- ' : '' @@ -22,6 +25,7 @@ function getTokenAmountDescription(amount = '0', tokenDetailed?: FungibleTokenDe } function getTransactionDescription( + chainId: ChainId, nativeTokenDetailed?: NativeTokenDetailed | ERC20TokenDetailed, tokenDetailed?: ERC20TokenDetailed, computedPayload?: UnboxPromise> | null, @@ -73,15 +77,22 @@ function getTransactionDescription( const amountOut = formatBalance(computedPayload.parameters.amountOutMin, tokenDetailed?.decimals, 2) return `Swap ${amountIn} ${nativeTokenDetailed?.symbol} for ${amountOut} ${tokenDetailed?.symbol}` default: - return `${computedPayload.name ?? 'Contract Interaction'} ${ - computedPayload._tx.value - ? getTokenAmountDescription( - computedPayload._tx.value as string | undefined, - nativeTokenDetailed, - true, - ) - : '' - }` + const description = getContractMethodDescription( + { name: computedPayload.name ?? '', chainId, address: computedPayload._tx.to ?? '' }, + computedPayload, + ) + return ( + description ?? + `${computedPayload.name ?? 'Contract Interaction'} ${ + computedPayload._tx.value + ? getTokenAmountDescription( + computedPayload._tx.value as string | undefined, + nativeTokenDetailed, + true, + ) + : '' + }` + ) } case EthereumRpcType.CONTRACT_DEPLOYMENT: return `Contract Deployment ${getTokenAmountDescription( @@ -105,6 +116,7 @@ export interface RecentTransactionDescriptionProps { } export function RecentTransactionDescription(props: RecentTransactionDescriptionProps) { + const chainId = useChainId() const { hash, computedPayload } = props const { loading: getNativeTokenLoading, value: nativeTokenDetailed } = useNativeTokenDetailed() let inputTokenAddress: string | undefined = '' @@ -139,6 +151,7 @@ export function RecentTransactionDescription(props: RecentTransactionDescription return !getNativeTokenLoading && !getERC20TokenLoading && !getInputERC20TokenLoading ? ( {getTransactionDescription( + chainId, inputTokenAddress ? inputTokenDetailed : nativeTokenDetailed, tokenDetailed, computedPayload, diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getITO_Description.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getITO_Description.tsx new file mode 100644 index 000000000000..e0c98a3d90b3 --- /dev/null +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getITO_Description.tsx @@ -0,0 +1,43 @@ +import { getITOConstants, isSameAddress, useERC20TokenDetailed, formatBalance } from '@masknet/web3-shared-evm' +import { useI18N } from '../../../../../utils' +import type { ContractMethodInfo, ComputedPayload } from '../type' + +export function getITO_Description({ name, address, chainId }: ContractMethodInfo, computedPayload: ComputedPayload) { + const { ITO2_CONTRACT_ADDRESS } = getITOConstants(chainId) + if (!isSameAddress(address, ITO2_CONTRACT_ADDRESS)) return undefined + + switch (name) { + case 'fill_pool': + return ( + + ) + default: + return undefined + } +} + +interface FillPoolDescriptionProps { + tokenAddress: string + tokenAmount: string +} + +function FillPoolDescription(props: FillPoolDescriptionProps) { + const { tokenAddress, tokenAmount } = props + + const { value: token } = useERC20TokenDetailed(tokenAddress) + const { t } = useI18N() + + return ( + + {token && tokenAddress + ? t('plugin_ito_transaction_dialog_summary', { + amount: formatBalance(tokenAmount, token.decimals), + symbol: token.symbol, + }) + : t('plugin_ito_transaction_dialog_summary_with_no_token')} + + ) +} diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getNFTRedpacketDescription.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getNFTRedpacketDescription.tsx new file mode 100644 index 000000000000..efb6071bb0ff --- /dev/null +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getNFTRedpacketDescription.tsx @@ -0,0 +1,19 @@ +import { getNftRedPacketConstants, isSameAddress } from '@masknet/web3-shared-evm' +import { i18n } from '../../../../../../shared-ui/locales_legacy' +import type { ContractMethodInfo, ComputedPayload } from '../type' + +export function getNFTRedpacketDescription( + { name, address, chainId }: ContractMethodInfo, + computedPayload: ComputedPayload, +) { + const { RED_PACKET_NFT_ADDRESS } = getNftRedPacketConstants(chainId) + + if (!isSameAddress(address, RED_PACKET_NFT_ADDRESS)) return undefined + + switch (name) { + case 'create_red_packet': + return i18n.t('plugin_nft_red_packet_create') + default: + return undefined + } +} diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getRedpacketDescription.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getRedpacketDescription.tsx new file mode 100644 index 000000000000..205141462a99 --- /dev/null +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/getRedpacketDescription.tsx @@ -0,0 +1,56 @@ +import { + getRedPacketConstants, + isSameAddress, + useERC20TokenDetailed, + formatBalance, + isNativeTokenAddress, + useNativeTokenDetailed, +} from '@masknet/web3-shared-evm' +import { useI18N } from '../../../../../utils' +import type { ContractMethodInfo, ComputedPayload } from '../type' + +export function getRedpacketDescription( + { name, address, chainId }: ContractMethodInfo, + computedPayload: ComputedPayload, +) { + const { HAPPY_RED_PACKET_ADDRESS_V4 } = getRedPacketConstants(chainId) + + if (!isSameAddress(address, HAPPY_RED_PACKET_ADDRESS_V4)) return undefined + + switch (name) { + case 'create_red_packet': + return ( + + ) + default: + return undefined + } +} + +interface CreateRedpacketDescriptionProps { + tokenAddress: string + tokenAmount: string +} + +export function CreateRedpacketDescription(props: CreateRedpacketDescriptionProps) { + const { tokenAddress, tokenAmount } = props + const { t } = useI18N() + + const { value: nativeToken } = useNativeTokenDetailed() + const { value: tokenDetailed } = useERC20TokenDetailed(tokenAddress) + const token = isNativeTokenAddress(tokenAddress) ? nativeToken : tokenDetailed + + return ( + + {token && tokenAddress + ? t('plugin_red_packet_create_with_token', { + amount: formatBalance(tokenAmount, token.decimals), + symbol: token.symbol, + }) + : t('plugin_red_packet_create')} + + ) +} diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/index.ts b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/index.ts new file mode 100644 index 000000000000..0406de6a2bb3 --- /dev/null +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/contractMethodDescription/index.ts @@ -0,0 +1,12 @@ +import { getRedpacketDescription } from './getRedpacketDescription' +import { getITO_Description } from './getITO_Description' +import { getNFTRedpacketDescription } from './getNFTRedpacketDescription' +import type { ContractMethodInfo, ComputedPayload } from '../type' + +export function getContractMethodDescription(contractMethodInfo: ContractMethodInfo, computedPayload: ComputedPayload) { + return ( + getRedpacketDescription(contractMethodInfo, computedPayload) ?? + getITO_Description(contractMethodInfo, computedPayload) ?? + getNFTRedpacketDescription(contractMethodInfo, computedPayload) + ) +} diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/type.ts b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/type.ts new file mode 100644 index 000000000000..f476681a539c --- /dev/null +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/WalletStatusDialog/type.ts @@ -0,0 +1,10 @@ +import type { ChainId } from '@masknet/web3-shared-evm' +import type Services from '../../../../extension/service' + +export interface ContractMethodInfo { + name: string + address: string + chainId: ChainId +} + +export type ComputedPayload = UnboxPromise>