From 867f656c92241cc9d52b924f601254e699d58e5d Mon Sep 17 00:00:00 2001 From: Lena Hierzi Date: Tue, 17 Oct 2023 18:57:11 +0100 Subject: [PATCH] feature: add alert when wallet is not connected --- example-frontend/pages/autoOffsetExactInETH.tsx | 4 ++++ example-frontend/pages/autoOffsetExactInToken.tsx | 4 ++++ example-frontend/pages/autoOffsetExactOutETH.tsx | 4 ++++ example-frontend/pages/autoOffsetExactOutToken.tsx | 4 ++++ example-frontend/pages/autoOffsetPoolToken.tsx | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/example-frontend/pages/autoOffsetExactInETH.tsx b/example-frontend/pages/autoOffsetExactInETH.tsx index 200ddc7..d69e76c 100644 --- a/example-frontend/pages/autoOffsetExactInETH.tsx +++ b/example-frontend/pages/autoOffsetExactInETH.tsx @@ -22,6 +22,10 @@ export default function AutoOffsetExactInETH() { ); // retire carbon credits using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), const offset = async () => { + if (!signer) { + alert("Please Connect your Wallet."); + } + try { const result = await offsetHelper.autoOffsetExactInETH(poolAddress, { value: amount, diff --git a/example-frontend/pages/autoOffsetExactInToken.tsx b/example-frontend/pages/autoOffsetExactInToken.tsx index d716b72..e501f8d 100644 --- a/example-frontend/pages/autoOffsetExactInToken.tsx +++ b/example-frontend/pages/autoOffsetExactInToken.tsx @@ -31,6 +31,10 @@ export default function AutoOffsetExactInToken() { signer || provider ); const offset = async () => { + if (!signer) { + alert("Please Connect your Wallet."); + } + try { // approve spending of deposited tokens await ( diff --git a/example-frontend/pages/autoOffsetExactOutETH.tsx b/example-frontend/pages/autoOffsetExactOutETH.tsx index 2f47eaa..891c218 100644 --- a/example-frontend/pages/autoOffsetExactOutETH.tsx +++ b/example-frontend/pages/autoOffsetExactOutETH.tsx @@ -21,6 +21,10 @@ export default function AutoOffsetExactOutETH() { signer || provider ); const offset = async () => { + if (!signer) { + alert("Please Connect your Wallet."); + } + try { // determine how much native tokens e.g., MATIC, token must be sent const amountOut = await offsetHelper.calculateNeededETHAmount( diff --git a/example-frontend/pages/autoOffsetExactOutToken.tsx b/example-frontend/pages/autoOffsetExactOutToken.tsx index 6cfa52d..ae7fce3 100644 --- a/example-frontend/pages/autoOffsetExactOutToken.tsx +++ b/example-frontend/pages/autoOffsetExactOutToken.tsx @@ -34,6 +34,10 @@ export default function AutoOffsetExactOutToken() { signer || provider ); const offset = async () => { + if (!signer) { + alert("Please Connect your Wallet."); + } + try { // determine how much of the ERC20 token must be sent const amountOut = await offsetHelper.calculateNeededTokenAmount( diff --git a/example-frontend/pages/autoOffsetPoolToken.tsx b/example-frontend/pages/autoOffsetPoolToken.tsx index 8db7300..2bd6bda 100644 --- a/example-frontend/pages/autoOffsetPoolToken.tsx +++ b/example-frontend/pages/autoOffsetPoolToken.tsx @@ -29,6 +29,10 @@ export default function AutoOffsetPoolToken() { ); const offset = async () => { + if (!signer) { + alert("Please Connect your Wallet."); + } + try { // approve spending of pool tokens await (await poolToken.approve(offsetHelper.address, amount)).wait();