From 007af1f6250dd01cbf6a55fe6c2419ba7425f462 Mon Sep 17 00:00:00 2001 From: john Date: Wed, 26 Jun 2024 15:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复已知问题 --- .env.development | 4 +-- .env.test | 4 +-- src/components/Header.tsx | 46 ++------------------------------- src/contract/abi/RedDevils.json | 32 ++++++++++------------- src/contract/utils.ts | 15 +---------- src/i18n/translation/cn.json | 9 ++++--- src/i18n/translation/de.json | 9 ++++--- src/i18n/translation/en.json | 13 +++++----- src/i18n/translation/jp.json | 9 ++++--- src/i18n/translation/tw.json | 9 ++++--- src/pages/AssetRecord.tsx | 18 ++++++------- src/pages/Home.tsx | 42 ++++++++++++++++++------------ src/pages/InvitationList.tsx | 7 +++-- src/pages/LevelUp.tsx | 2 +- src/server/api.ts | 16 +++++++++++- src/server/module.d.ts | 5 ++-- src/utils/index.ts | 4 +-- src/utils/wallet.ts | 26 ++++++++++++++++--- 18 files changed, 130 insertions(+), 140 deletions(-) diff --git a/.env.development b/.env.development index 30e40ec..39143b7 100644 --- a/.env.development +++ b/.env.development @@ -1,12 +1,12 @@ ### # @LastEditors: John # @Date: 2024-06-18 10:12:21 - # @LastEditTime: 2024-06-24 18:25:07 + # @LastEditTime: 2024-06-25 14:04:33 # @Author: John ### VITE_BASE_URL=http://192.168.10.167:5173/ VITE_BASE_API_URL=/dev VITE_PARTICIPATE_CHAIN_ID=97 -VITE_PURCHASED_CONTRACT_ADDRESS=0xD70762bf8682b68bd0cbbBC0cdeC81db4f00AEc6 +VITE_PURCHASED_CONTRACT_ADDRESS=0x7aAe4f2CA23482B58D6f9e8d1fBb5e413e7013c8 VITE_NETWORK_USDT_ADDRESS=0xf9A18B7FC8Eb118f8Ad59fBD6eb1A181eaCb4E63 VITE_CHECK_TRANSACTION_DETAILS_URL=https://testnet.bscscan.com/ \ No newline at end of file diff --git a/.env.test b/.env.test index 14c4a7f..1c1e5f6 100644 --- a/.env.test +++ b/.env.test @@ -1,12 +1,12 @@ ### # @LastEditors: John # @Date: 2024-06-24 18:38:45 - # @LastEditTime: 2024-06-24 18:41:05 + # @LastEditTime: 2024-06-25 14:04:37 # @Author: John ### VITE_BASE_URL=http://wwwtest.exgo.pro VITE_BASE_API_URL=http://wwwtest.exgo.pro VITE_PARTICIPATE_CHAIN_ID=97 -VITE_PURCHASED_CONTRACT_ADDRESS=0xD70762bf8682b68bd0cbbBC0cdeC81db4f00AEc6 +VITE_PURCHASED_CONTRACT_ADDRESS=0x7aAe4f2CA23482B58D6f9e8d1fBb5e413e7013c8 VITE_NETWORK_USDT_ADDRESS=0xf9A18B7FC8Eb118f8Ad59fBD6eb1A181eaCb4E63 VITE_CHECK_TRANSACTION_DETAILS_URL=https://testnet.bscscan.com/ \ No newline at end of file diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 46b6b50..fc89403 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,7 +1,7 @@ /* * @LastEditors: John * @Date: 2024-06-18 15:16:31 - * @LastEditTime: 2024-06-19 18:30:52 + * @LastEditTime: 2024-06-26 14:49:22 * @Author: John */ import Picker, { @@ -42,7 +42,7 @@ export default function () { case "/levelup": return t("级别提升"); case "/assetrecord": - return t("资产记录"); + return t("收益记录"); case "/airdroprecord": return t("RMOB记录"); case "/invitationlist": @@ -118,48 +118,6 @@ export default function () { )} - {/* - { - setLangPickVisble(false); - }} - value={langPickValue} - onConfirm={(v) => { - setLangPickValue(v); - // console.log("Current lang:", v[0]); - switch (v[0]) { - case Lang.en: - i18n.changeLanguage(Lang.en); - UpdateLang(Lang.en); - break; - case Lang.cn: - i18n.changeLanguage(Lang.cn); - UpdateLang(Lang.cn); - break; - case Lang.tw: - i18n.changeLanguage(Lang.tw); - UpdateLang(Lang.tw); - break; - case Lang.jp: - i18n.changeLanguage(Lang.jp); - UpdateLang(Lang.jp); - break; - case Lang.de: - i18n.changeLanguage(Lang.de); - UpdateLang(Lang.de); - break; - default: - break; - } - - // console.log("i18n lang:", i18n.language); - }} - confirmText={t("确定")} - cancelText={t("取消")} - /> */} ); } diff --git a/src/contract/abi/RedDevils.json b/src/contract/abi/RedDevils.json index 3c1f3f3..bc66142 100644 --- a/src/contract/abi/RedDevils.json +++ b/src/contract/abi/RedDevils.json @@ -73,6 +73,12 @@ "internalType": "uint256", "name": "orderId", "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paymentType", + "type": "uint256" } ], "name": "BuySuccess", @@ -365,25 +371,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "string", - "name": "source", - "type": "string" - } - ], - "name": "stringToBytes32", - "outputs": [ - { - "internalType": "bytes32", - "name": "result", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, { "inputs": [], "name": "tokenIndex", @@ -453,5 +440,12 @@ ], "stateMutability": "view", "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" } ] diff --git a/src/contract/utils.ts b/src/contract/utils.ts index 1897d3b..54010b0 100644 --- a/src/contract/utils.ts +++ b/src/contract/utils.ts @@ -1,7 +1,7 @@ /* * @LastEditors: John * @Date: 2024-06-19 15:48:57 - * @LastEditTime: 2024-06-24 18:25:44 + * @LastEditTime: 2024-06-25 15:28:36 * @Author: John */ import { config } from "@/components/WalletProvider"; @@ -285,19 +285,6 @@ export async function receiveByContract( return new Promise(async (reslove, reject) => { try { - const balance = await getBalance(); - if (balance < amount) { - console.log("用户代币余额不足"); - reject(new BaseError(i18next.t("余额不足"))); - return; - } - - console.log("当前要授权的U:", amount); - let approvedU = await getApproveUsdt(); - if (approvedU < amount) { - await authorizedU(amount); - } - console.log("参数:", amount, paymentTime, orderID, hashStr); estimateGas(config, { to: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS, diff --git a/src/i18n/translation/cn.json b/src/i18n/translation/cn.json index dc31a7c..a6e2f62 100644 --- a/src/i18n/translation/cn.json +++ b/src/i18n/translation/cn.json @@ -3,7 +3,7 @@ "红魔NFT": "红魔NFT", "铸造 NFT": "铸造 NFT", "级别提升": "级别提升", - "资产记录": "资产记录", + "收益记录": "收益记录", "RMOB记录": "RMOB记录", "直推列表": "直推列表", "返回": "返回", @@ -16,10 +16,10 @@ "邀请铸造": "邀请铸造", "团队社长": "团队社长", "邀请空投": "邀请空投", - "代币": "代币", + "收益": "收益", "Min结束后按照规则进行空投。": "Min结束后按照规则进行空投。", "铸造 NFT 获得代币空投": "铸造 NFT 获得代币空投", - "资产金额 = 已领取 + 待处理": "资产金额 = 已领取 + 待处理", + "总收益= 已领取 + 待领取": "总收益= 已领取 + 待领取", "邀请": "邀请", "邀请链接": "邀请链接", "普通会员每邀请铸造一个NFT可获得一份空投福利;推荐铸造20个NFT的可升级为会长;团队中拥有20位会长可升级为基金会社长;邀请越多级别越高福利越多。": "普通会员每邀请铸造一个NFT可获得一份空投福利;推荐铸造20个NFT的可升级为会长;团队中拥有20位会长可升级为基金会社长;邀请越多级别越高福利越多。", @@ -102,5 +102,6 @@ "升级成功,返回首页查看": "升级成功,返回首页查看", "无级别提升": "无级别提升", "没有更多数据了": "没有更多数据了", - "升级中": "升级中" + "升级中": "升级中", + "无等级": "无等级" } diff --git a/src/i18n/translation/de.json b/src/i18n/translation/de.json index d096217..6b59716 100644 --- a/src/i18n/translation/de.json +++ b/src/i18n/translation/de.json @@ -3,7 +3,7 @@ "红魔NFT": "Der Rote Teufel NFT", "铸造 NFT": "NFT Prägen", "级别提升": "Stufenaufstieg", - "资产记录": "Vermögensaufzeichnung", + "收益记录": "Ergebnisrekord", "RMOB记录": "RMOB Aufzeichnung", "直推列表": "Direktempfehlungsliste", "返回": "Zurück", @@ -16,10 +16,10 @@ "邀请铸造": "Prägen einladen", "团队社长": "Teamleiter", "邀请空投": "Airdrop einladen", - "代币": "Token", + "收益": "Einkommen", "Min结束后按照规则进行空投。": "Airdrop nach dem Ende des Min gemäß den Regeln.", "铸造 NFT 获得代币空投": "Token-Airdrop durch NFT-Prägung erhalten", - "资产金额 = 已领取 + 待处理": "Vermögenswert = Empfang + Ausstehend", + "总收益= 已领取 + 待领取": "Gesamtumsatz = Empfang + Abzuholen", "邀请": "Einladen", "邀请链接": "Einladungslink", "普通会员每邀请铸造一个NFT可获得一份空投福利;推荐铸造20个NFT的可升级为会长;团队中拥有20位会长可升级为基金会社长;邀请越多级别越高福利越多。": "Normale Mitglieder erhalten für jede Einladung zur Prägung eines NFTs einen Airdrop-Bonus; 20 empfohlene Prägungen führen zum Aufstieg zum Vorsitzenden; 20 Vorsitzende im Team ermöglichen den Aufstieg zum Fundmanager; je mehr Einladungen, desto höher das Level und die Belohnungen.", @@ -102,5 +102,6 @@ "升级成功,返回首页查看": "Upgrade erfolgreich abgeschlossen, zurück zur Startseite zur Ansicht.", "无级别提升": "Beförderung ohne Rang", "没有更多数据了": "Keine weiteren Daten", - "升级中": "Wird aktualisiert" + "升级中": "Wird aktualisiert", + "无等级": "Keine Bewertung" } diff --git a/src/i18n/translation/en.json b/src/i18n/translation/en.json index 0635896..dab5061 100644 --- a/src/i18n/translation/en.json +++ b/src/i18n/translation/en.json @@ -3,7 +3,7 @@ "红魔NFT": "Red Devils NFT", "铸造 NFT": "Mint NFT", "级别提升": "Level Up", - "资产记录": "Asset Records", + "收益记录": "Revenue Record", "RMOB记录": "RMOB Records", "直推列表": "Direct Referral List", "返回": "Back", @@ -16,10 +16,10 @@ "邀请铸造": "Invite to Mint", "团队社长": "Team Leader", "邀请空投": "Invite Airdrop", - "代币": "Token", + "收益": "Income", "Min结束后按照规则进行空投。": "Airdrop will follow the rules after Min ends.", "铸造 NFT 获得代币空投": "Mint NFT for Token Airdrop", - "资产金额 = 已领取 + 待处理": "Asset Amount = Claimed + Pending", + "总收益= 已领取 + 待领取": "Total Revenue = Claimed + Pending", "邀请": "Invite", "邀请链接": "Invite Link", "普通会员每邀请铸造一个NFT可获得一份空投福利;推荐铸造20个NFT的可升级为会长;团队中拥有20位会长可升级为基金会社长;邀请越多级别越高福利越多。": "Regular members get an airdrop for each NFT minted through their invite; recommending 20 NFTs upgrades to Leader; having 20 Leaders in the team upgrades to Foundation Leader; more invites lead to higher levels and more benefits.", @@ -36,7 +36,7 @@ "当前MINT价格:": "Current MINT Price:", "价格说明:": "Price Explanation:", "{{value1}} USDT起,每增加 {{value2}} 名普通会员,NFT价格上涨 {{value3}},既:前 {{value2}} 名价格为 {{value1}} USDT/枚,value4 名价格为{{value1}}u+{{value1}}u*{{value3}}={{value5}} USDT/枚,以此类推。": "Starting at {{value1}} USDT, the NFT price increases by {{value3}} for every {{value2}} new members: first {{value2}} at {{value1}} USDT each, {{value4}} at {{value1}}u+{{value1}}u*{{value3}}={{value5}} USDT each, and so on.", - "授权USDT": "Authorize USDT", + "授权USDT": "Approve USDT", "当前级别": "Current Level", "普通活跃": "Active Member", "提升级别": "Upgrade Level", @@ -96,11 +96,12 @@ "正在授权USDT": "Authorizing USDT", "购买中": "Purchasing", "领取中": "Processing", - "MINT Nft 获取邀请链接": "MINT Nft invite link", + "MINT Nft 获取邀请链接": "Mint NFT to get invitation link", "链接钱包获取邀请链接": "Link your wallet to get the invitation link.", "正在获取已授权金额": "Currently retrieving authorized amount.", "升级成功,返回首页查看": "Upgrade successful, return to homepage to view.", "无级别提升": "Promotion without rank", "没有更多数据了": "No more data", - "升级中": "Upgrading" + "升级中": "Upgrading", + "无等级": "No Grade" } diff --git a/src/i18n/translation/jp.json b/src/i18n/translation/jp.json index 0bc0d49..3cb88d7 100644 --- a/src/i18n/translation/jp.json +++ b/src/i18n/translation/jp.json @@ -3,7 +3,7 @@ "红魔NFT": "紅魔NFT", "铸造 NFT": "NFT 鋳造", "级别提升": "レベルアップ", - "资产记录": "資産記録", + "收益记录": "収益実績", "RMOB记录": "RMOB記録", "直推列表": "ダイレクト推薦リスト", "返回": "戻る", @@ -16,10 +16,10 @@ "邀请铸造": "鋳造を招待", "团队社长": "チームリーダー", "邀请空投": "エアドロップ招待", - "代币": "トークン", + "收益": "所得", "Min结束后按照规则进行空投。": "Min終了後、ルールに従ってエアドロップを行います。", "铸造 NFT 获得代币空投": "NFTを鋳造してトークンエアドロップを獲得", - "资产金额 = 已领取 + 待处理": "資産額 = 受領済み + 処理中", + "总收益= 已领取 + 待领取": "総収入 = 受領済み + 回収対象", "邀请": "招待", "邀请链接": "招待リンク", "普通会员每邀请铸造一个NFT可获得一份空投福利;推荐铸造20个NFT的可升级为会长;团队中拥有20位会长可升级为基金会社长;邀请越多级别越高福利越多。": "一般会員はNFT鋳造の招待ごとにエアドロップを獲得;20個のNFTを鋳造することでリーダーに昇格;チーム内に20人のリーダーがいるとファンドリーダーに昇格;招待が多いほどレベルが上がり、特典が増える。", @@ -102,5 +102,6 @@ "升级成功,返回首页查看": "アップグレードが成功しました。ホームページに戻って確認してください。", "无级别提升": "階級なしの昇進", "没有更多数据了": "これ以上のデータはありません", - "升级中": "アップグレード中" + "升级中": "アップグレード中", + "无等级": "グレードなし" } diff --git a/src/i18n/translation/tw.json b/src/i18n/translation/tw.json index 6da5c0b..c52a940 100644 --- a/src/i18n/translation/tw.json +++ b/src/i18n/translation/tw.json @@ -3,7 +3,7 @@ "红魔NFT": "紅魔NFT", "铸造 NFT": "鑄造 NFT", "级别提升": "級別提升", - "资产记录": "資產記錄", + "收益记录": "收益記錄", "RMOB记录": "RMOB記錄", "直推列表": "直推列表", "返回": "返回", @@ -16,10 +16,10 @@ "邀请铸造": "邀請鑄造", "团队社长": "團隊社長", "邀请空投": "邀請空投", - "代币": "代幣", + "收益": "收益", "Min结束后按照规则进行空投。": "Min結束後按照規則進行空投。", "铸造 NFT 获得代币空投": "鑄造 NFT 獲得代幣空投", - "资产金额 = 已领取 + 待处理": "資產金額 = 已領取 + 待處理", + "总收益= 已领取 + 待领取": "總收益 = 已領取 + 待領取", "邀请": "邀請", "邀请链接": "邀請鏈接", "普通会员每邀请铸造一个NFT可获得一份空投福利;推荐铸造20个NFT的可升级为会长;团队中拥有20位会长可升级为基金会社长;邀请越多级别越高福利越多。": "普通會員每邀請鑄造一個NFT可獲得一份空投福利;推薦鑄造20個NFT的可升級為會長;團隊中擁有20位會長可升級為基金會社長;邀請越多級別越高福利越多。", @@ -102,5 +102,6 @@ "升级成功,返回首页查看": "升級成功,返回首頁查看。", "无级别提升": "無級別提升", "没有更多数据了": "沒有更多數據了", - "升级中": "升級中" + "升级中": "升級中", + "无等级": "無等級" } diff --git a/src/pages/AssetRecord.tsx b/src/pages/AssetRecord.tsx index 3fdf1ee..86ae499 100644 --- a/src/pages/AssetRecord.tsx +++ b/src/pages/AssetRecord.tsx @@ -1,7 +1,7 @@ /* * @LastEditors: John * @Date: 2024-06-18 17:57:13 - * @LastEditTime: 2024-06-24 10:44:10 + * @LastEditTime: 2024-06-25 16:17:20 * @Author: John */ import Tabs from "antd-mobile/es/components/tabs"; @@ -20,7 +20,7 @@ export default function () { const { t } = useTranslation(); const coinId = useMemo(() => getUrlQueryParam("id"), []); const coinName = useMemo(() => getUrlQueryParam("name"), []); - const currentType = useRef<1 | 2>(1); + const currentType = useRef<1 | 2>(2); const [issueRecords, setIssueRecords] = useState([]); const [receiveRecord, setReceiveRecord] = useState( [] @@ -31,7 +31,7 @@ export default function () { const hasMore = useRef(true); useEffect(() => { return () => {}; - }, [coinId]); + }, []); async function getRecord() { return new Promise(async (reslove) => { @@ -47,7 +47,7 @@ export default function () { type: currentType.current, pageNum: pageNum.current, pageSize, - ...(conditions.current && currentType.current == 1 + ...(conditions.current && currentType.current == 2 ? { status: conditions.current } : {}), }, @@ -57,7 +57,7 @@ export default function () { if (data.data.records.length < pageSize) hasMore.current = false; - if (currentType.current == 1) { + if (currentType.current == 2) { setIssueRecords([...issueRecords, ...data?.data.records]); } else { setReceiveRecord([...receiveRecord, ...data?.data.records]); @@ -67,9 +67,9 @@ export default function () { } function resetPaging() { - if (currentType.current == 1) { + if (currentType.current == 2) { setIssueRecords([]); - } else if (currentType.current == 2) { + } else if (currentType.current == 1) { setReceiveRecord([]); } pageNum.current = 0; @@ -82,10 +82,10 @@ export default function () { className={cn(classes.AssetRecord)} onChange={(key) => { if (parseInt(key) == 1) { - currentType.current = 1; + currentType.current = 2; resetPaging(); } else { - currentType.current = 2; + currentType.current = 1; resetPaging(); } }} diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index baac00e..9916ba4 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -10,9 +10,8 @@ import usdtBg from "@/assets/usdt_bg.svg"; import RMOB_logo from "@/assets/RMOB_logo.svg"; import IconFont from "@/components/iconfont"; import { BaseError, useAccount } from "wagmi"; -import { disconnect } from "wagmi/actions"; import { config } from "@/components/WalletProvider"; -import { useNavigate } from "react-router-dom"; +import { createSearchParams, useNavigate } from "react-router-dom"; import { Button, Dialog, Empty, Toast } from "antd-mobile"; import { loginOut } from "@/utils/wallet"; import { api_claim_income, api_get_homepage_user_data } from "@/server/api"; @@ -21,7 +20,7 @@ import { UrlQueryParamsKey } from "@/constants"; import { receiveByContract } from "@/contract/utils"; import usePollingCheckBuyStatus from "@/hook/usePollingCheckBuyStatus"; import { ToastHandler } from "antd-mobile/es/components/toast"; - +import { disconnect, getAccount } from "@wagmi/core"; export default function () { const { Token, UpdateToken } = useUserStore(); const { open } = useWeb3Modal(); @@ -34,14 +33,17 @@ export default function () { const userInviteLink = useMemo( () => - `${import.meta.env.VITE_BASE_URL}?${UrlQueryParamsKey.INVITE_CODE}=${ + `${import.meta.env.VITE_BASE_URL}#/?${UrlQueryParamsKey.INVITE_CODE}=${ userData?.invitationCode || "" }`, [userData] ); const receiveLoadingToast = useRef(); - const { transcationStatus, startPollingCheckBuyStatus,stopPollingCheckBuyStatus } = - usePollingCheckBuyStatus("NORMAL"); + const { + transcationStatus, + startPollingCheckBuyStatus, + stopPollingCheckBuyStatus, + } = usePollingCheckBuyStatus("NORMAL"); useEffect(() => { getHomeData(); @@ -51,7 +53,7 @@ export default function () { useEffect(() => { if (transcationStatus == "success") { receiveLoadingToast.current?.close(); - stopPollingCheckBuyStatus() + stopPollingCheckBuyStatus(); Dialog.alert({ content: `${t("领取成功,前往钱包查看")}`, confirmText: "OK", @@ -84,8 +86,9 @@ export default function () {
{shortenString(address, 6, 4)} { - disconnect(config); + onClick={async () => { + const { connector } = getAccount(config); + await disconnect(config, { connector }); loginOut(); }} name="tuichu" @@ -103,7 +106,7 @@ export default function () { name="tongdun" className={classes.userinfo_top_right_btns_icon} /> - {t("普通非活跃")} + {t("无等级")} )} {userData.level == 1 && ( @@ -112,7 +115,12 @@ export default function () { name="jindun" className={classes.userinfo_top_right_btns_icon} /> - {t("普通活跃")} + {userData.active === 0 && ( + {t("普通非活跃")} + )} + {userData.active === 1 && ( + {t("普通活跃")} + )} )} {userData.level == 2 && ( @@ -199,7 +207,7 @@ export default function () { className={tabIndex == 1 ? classes.nftToken_tab_active : ""} onClick={() => setTabIndex(1)} > - {t("代币")} + {t("收益")} @@ -211,7 +219,7 @@ export default function () { {userData?.nftId ? (
- # ${userData?.nftId} + # {userData?.nftId} { navigate("/mint"); @@ -266,7 +274,7 @@ export default function () { {tabIndex == 1 && (
- {t("资产金额 = 已领取 + 待处理")} + {t("总收益= 已领取 + 待领取")}
    @@ -410,7 +418,7 @@ function ReceiveCom({ onReceive, }: { tokenName: string; - tokenNum: string; + tokenNum: number; toReceive: number; onAssetRec: () => void; onReceive: () => void; @@ -433,7 +441,7 @@ function ReceiveCom({ onAssetRec(); }} > - {t("资产记录")}{" "} + {t("收益记录")}{" "}
@@ -441,7 +449,7 @@ function ReceiveCom({
{t("待领取")} - {toReceive} + {tokenNum + toReceive}