Skip to content

Commit

Permalink
feature: add alert when wallet is not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
Lena Hierzi committed Oct 17, 2023
1 parent 735f7f3 commit 867f656
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example-frontend/pages/autoOffsetExactInETH.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions example-frontend/pages/autoOffsetExactInToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 4 additions & 0 deletions example-frontend/pages/autoOffsetExactOutETH.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions example-frontend/pages/autoOffsetExactOutToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions example-frontend/pages/autoOffsetPoolToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 867f656

Please sign in to comment.