Skip to content

Commit

Permalink
trigger youcall event WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
olivmath committed Sep 23, 2024
1 parent 8e522ba commit fa62a1b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
14 changes: 13 additions & 1 deletion smartcontracts/src/Counter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
pragma solidity ^0.8.18;

contract Counter {
error CustomError(string message, uint256 yourAmount);

event YourBalance(address caller, uint256 amount);
event YouCall(address caller, uint256 amount);

uint256 public number;

function setNumber(uint256 newNumber) public {
Expand All @@ -12,9 +17,16 @@ contract Counter {
number++;
}

error CustomError(string message, uint256 yourAmount);

function getError(uint256 yourAmount) public pure returns (string memory) {
revert CustomError("An error occurred", yourAmount);
}

function launchEvent() public payable {
emit YouCall(msg.sender, msg.value);
}

function youETHBalance() public {
emit YourBalance(msg.sender, address(this).balance);
}
}
25 changes: 19 additions & 6 deletions ui/app/debug/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
"use client";

import { DebugContracts } from "./_components/DebugContracts";
import type { NextPage } from "next";
import { getMetadata } from "~~/utils/fwt/getMetadata";

export const metadata = getMetadata({
title: "Debug Contracts",
description: "Debug your deployed 🏗 Fullstack Web3 Template contracts in an easy way",
});
import { useScaffoldWatchContractEvent } from "~~/hooks/scaffold-eth/useScaffoldWatchContractEvent";
import { notification } from "~~/utils/fwt/notification";

const Debug: NextPage = () => {
useScaffoldWatchContractEvent({
contractName: "Counter",
eventName: "YouCall",
onLogs: logs => {
logs.forEach(log => {
notification.info(
`Event YouCall triggered:
Caller: ${log.args.caller}
Amount: ${log.args.amount} wei`,
{ duration: 6000 }
);
});
},
});

return (
<>
<DebugContracts />
Expand Down

0 comments on commit fa62a1b

Please sign in to comment.