diff --git a/.env b/.env deleted file mode 100644 index 4f04924..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_WEB3_PROJECT_ID=23adf8ac254cc9f7de8064d0a5f495a8 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4961939..85e9651 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "@craco/craco": "^7.1.0", "@reduxjs/toolkit": "^2.0.1", - "@tanstack/react-query": "^5.17.19", + "@tanstack/react-query": "5.17.19", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -33,15 +33,16 @@ "react-scripts": "5.0.1", "react-svg": "^16.1.32", "sass": "^1.70.0", - "viem": "^2.4.0", - "wagmi": "^2.3.1", + "viem": "2.4.0", + "wagmi": "2.3.1", "web-vitals": "^2.1.4" }, "devDependencies": { + "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", "@types/react-grid-layout": "^1.3.5", "@types/react-router-bootstrap": "^0.26.6", "gh-pages": "^6.1.1", - "typescript": "^5.3.3" + "typescript": "5.3.3" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 56629bf..497e627 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "@craco/craco": "^7.1.0", "@reduxjs/toolkit": "^2.0.1", - "@tanstack/react-query": "^5.17.19", + "@tanstack/react-query": "5.17.19", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -29,8 +29,8 @@ "react-scripts": "5.0.1", "react-svg": "^16.1.32", "sass": "^1.70.0", - "viem": "^2.4.0", - "wagmi": "^2.3.1", + "viem": "2.4.0", + "wagmi": "2.3.1", "web-vitals": "^2.1.4" }, "scripts": { @@ -60,10 +60,11 @@ ] }, "devDependencies": { + "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", "@types/react-grid-layout": "^1.3.5", "@types/react-router-bootstrap": "^0.26.6", "gh-pages": "^6.1.1", - "typescript": "^5.3.3" + "typescript": "5.3.3" }, "overrides": { "react-scripts": { diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index d14e86a..d28271e 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -36,7 +36,19 @@ "copied_button": "Copied", "referral_balance": { "header": "Affiliate statistic", - "balance": "Balance: {{count}} PetCoins" + "balance": "Balance: {{count}} PetCoins", + "withdraw_button": { + "withdraw": "Withdraw", + "confirming": "Confirming...", + "error": { + "label": "Error: {{error}}" + } + } + } + }, + "web3": { + "error": { + "User rejected the request.": "User rejected the request" } }, "tokenomics": { diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 870261c..cbf4714 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -24,7 +24,19 @@ "copied_button": "Скопировано", "referral_balance": { "header": "Партнерская статистика", - "balance": "Баланс: {{count}} PetCoins" + "balance": "Баланс: {{count}} PetCoins", + "withdraw_button": { + "withdraw": "Вывод средств", + "confirming": "Подтверждение...", + "error": { + "label": "Ошибка: {{error}}" + } + } + } + }, + "web3": { + "error": { + "User rejected the request.": "Пользователь отклонил запрос" } }, "tokenomics": { diff --git a/src/components/common/web3/WithdrawButton.tsx b/src/components/common/web3/WithdrawButton.tsx new file mode 100644 index 0000000..2cb6f10 --- /dev/null +++ b/src/components/common/web3/WithdrawButton.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { + type BaseError, + useSendTransaction, +} from 'wagmi'; +import { parseEther } from 'viem'; +import Button from 'react-bootstrap/Button'; + +export default function WithdrawButton({ withdrawSum }: { withdrawSum: number }) { + const { t } = useTranslation(); + const { + error, + isPending, + sendTransaction, + } = useSendTransaction(); + + async function withdraw() { + sendTransaction({ + to: process.env.REACT_APP_WEB3_WALLET_BASE_ADDRESS as `0x${string}`, + value: parseEther(String(withdrawSum)), + }); + } + + return ( + <> + + {error && ( +
{t('ref_program.referral_balance.header')}
+{t('ref_program.referral_balance.header')}
{t('ref_program.referral_balance.balance', { count: referralBalance })}
+{process.env.REACT_APP_WEB3_PROJECT_ID}
+{process.env.REACT_APP_WEB3_WALLET_BASE_ADDRESS}