forked from Scaffold-Stark/scaffold-stark-2
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b83a327
commit db029a8
Showing
39 changed files
with
1,645 additions
and
179 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use client"; | ||
|
||
import type { NextPage } from "next"; | ||
import { StakeContractInteraction } from "~~/components/stake/StakeContractInteraction"; | ||
import { useDeployedContractInfo } from "~~/hooks/scaffold-stark"; | ||
|
||
const StakerUI: NextPage = () => { | ||
const { data: StakerContract } = useDeployedContractInfo("Staker"); | ||
|
||
return ( | ||
<StakeContractInteraction | ||
key={StakerContract?.address} | ||
address={StakerContract?.address} | ||
/> | ||
); | ||
}; | ||
|
||
export default StakerUI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { NextPage } from "next"; | ||
import { useScaffoldEventHistory } from "~~/hooks/scaffold-stark/useScaffoldEventHistory"; | ||
import { Address } from "~~/components/scaffold-stark"; | ||
import { formatEther } from "ethers"; | ||
|
||
interface StakeEvent { | ||
args: { | ||
sender: string; | ||
amount: bigint; | ||
}; | ||
} | ||
const Staking: NextPage = () => { | ||
// @ts-ignore | ||
const { data: stakeEvents, isLoading } = useScaffoldEventHistory<StakeEvent>({ | ||
contractName: "Staker", | ||
eventName: "contracts::Staker::Staker::Stake", | ||
watch: true, | ||
fromBlock: 0n, | ||
}); | ||
console.log(stakeEvents); | ||
|
||
if (isLoading) | ||
return ( | ||
<div className="flex justify-center items-center mt-10"> | ||
<span className="loading loading-spinner loading-lg"></span> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="flex items-center flex-col flex-grow pt-10 text-neutral"> | ||
<div className="px-5"> | ||
<h1 className="text-center mb-3"> | ||
<span className="block text-2xl font-bold">All Staking Events</span> | ||
</h1> | ||
</div> | ||
<div className="overflow-x-auto border border-secondary"> | ||
<table className="table table-zebra w-full"> | ||
<thead> | ||
<tr> | ||
<th className="bg-secondary text-white">From</th> | ||
<th className="bg-secondary text-white">Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{!stakeEvents || stakeEvents.length === 0 ? ( | ||
<tr> | ||
<td colSpan={3} className="text-center"> | ||
No events found | ||
</td> | ||
</tr> | ||
) : ( | ||
stakeEvents?.map((event: StakeEvent, index) => { | ||
return ( | ||
<tr key={index}> | ||
<td> | ||
<Address address={`0x${event.args.sender}`} /> | ||
</td> | ||
<td> | ||
{event.args.amount && | ||
formatEther(BigInt(event.args.amount))}{" "} | ||
ETH | ||
</td> | ||
</tr> | ||
); | ||
}) | ||
)} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Staking; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.