added a polls table in the admin page

This commit is contained in:
Yash Goyal
2024-03-25 06:45:06 +05:30
parent e38915e198
commit 0cb1e8cdad
3 changed files with 130 additions and 49 deletions

View File

@@ -23,7 +23,7 @@ const etherscanApiKey = process.env.ETHERSCAN_API_KEY || "DNXJA8RX2Q3VZ4URQIWP7Z
const config: HardhatUserConfig = {
solidity: {
version: "0.8.10",
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
@@ -43,10 +43,10 @@ const config: HardhatUserConfig = {
// View the networks that are pre-configured.
// If the network you are looking for is not here you can add new network settings
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`,
enabled: process.env.MAINNET_FORKING_ENABLED === "true",
},
// forking: {
// url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`,
// enabled: process.env.MAINNET_FORKING_ENABLED === "true",
// },
},
mainnet: {
url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`,

View File

@@ -48,30 +48,38 @@ export default function AdminPage() {
<div className="container mx-auto pt-10">
<div className="flex">
<div className="flex-1 text-2xl">Polls</div>
<button className="bg-primary px-3 py-2 rounded-lg" onClick={() => setOpenCreatePollModal(true)}>
<button
className="border border-slate-600 bg-primary px-3 py-2 rounded-lg font-bold"
onClick={() => setOpenCreatePollModal(true)}
>
Create Poll
</button>
</div>
{polls && polls.length !== 0 ? (
<div>
<div className="mb-2">
{polls.map((poll: any) => (
<div key={poll.id} className="bg-neutral text-neutral-content p-4 mt-4 rounded-lg">
<div className="text-xl font-bold">{poll.title}</div>
<div className="mt-2">
{poll.options.map((option: string, index: number) => (
<div key={index} className="flex items-center">
<input type="radio" name={poll.title} value={option} />
<label className="ml-2">{option}</label>
</div>
))}
</div>
</div>
))}
</div>
{/** paginator */}
<>
<table className="border-separate w-full mt-7 mb-4">
<thead>
<tr className="text-lg font-extralight">
<th className="border border-slate-600 bg-primary">Poll Name</th>
<th className="border border-slate-600 bg-primary">End Time</th>
<th className="border border-slate-600 bg-primary">Start Time</th>
<th className="border border-slate-600 bg-primary">Status</th>
</tr>
</thead>
<tbody>
{polls.map((poll: any) => (
<tr key={poll.id} className="pt-10 text-center">
<td>{poll.name}</td>
<td>{new Date(Number(poll.startTime) * 1000).toLocaleString()}</td>
<td>{new Date(Number(poll.endTime) * 1000).toLocaleString()}</td>
<td>Poll Open</td>
</tr>
))}
</tbody>
</table>
<Paginator currentPage={currentPage} totalPages={totalPages} setPageNumber={setCurrentPage} />
</div>
</>
) : (
<div>No polls found</div>
)}

View File

@@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
const deployedContracts = {
31337: {
ConstantInitialVoiceCreditProxy: {
address: "0x8f86403A4DE0BB5791fa46B8e795C547942fE4Cf",
address: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
abi: [
{
inputs: [
@@ -50,7 +50,7 @@ const deployedContracts = {
},
},
FreeForAllGatekeeper: {
address: "0x9d4454B023096f34B160D6B654540c56A1F81688",
address: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
abi: [
{
inputs: [],
@@ -92,7 +92,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
MACI: {
address: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
address: "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
abi: [
{
inputs: [
@@ -1055,7 +1055,7 @@ const deployedContracts = {
},
},
MessageProcessorFactory: {
address: "0xCD8a1C3ba11CF5ECfa6267617243239504a98d90",
address: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
abi: [
{
inputs: [],
@@ -1110,7 +1110,7 @@ const deployedContracts = {
},
},
PollFactory: {
address: "0xb7278A61aa25c888815aFC32Ad3cC52fF24fE575",
address: "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
abi: [
{
inputs: [],
@@ -1237,7 +1237,7 @@ const deployedContracts = {
},
},
PollManager: {
address: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc",
address: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
abi: [
{
inputs: [
@@ -1250,6 +1250,79 @@ const deployedContracts = {
stateMutability: "nonpayable",
type: "constructor",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "pollId",
type: "uint256",
},
{
indexed: true,
internalType: "address",
name: "creator",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "poll",
type: "address",
},
{
indexed: false,
internalType: "string",
name: "name",
type: "string",
},
{
indexed: false,
internalType: "string[]",
name: "options",
type: "string[]",
},
{
indexed: false,
internalType: "string",
name: "ipfsHash",
type: "string",
},
{
indexed: false,
internalType: "address",
name: "messageProcessor",
type: "address",
},
{
indexed: false,
internalType: "address",
name: "tally",
type: "address",
},
{
indexed: false,
internalType: "address",
name: "subsidy",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "startTime",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "endTime",
type: "uint256",
},
],
name: "PollCreated",
type: "event",
},
{
inputs: [],
name: "MESSAGE_DATA_LENGTH",
@@ -1336,11 +1409,6 @@ const deployedContracts = {
name: "ipfsHash",
type: "string",
},
{
internalType: "address",
name: "creator",
type: "address",
},
{
components: [
{
@@ -1368,6 +1436,11 @@ const deployedContracts = {
name: "pollContracts",
type: "tuple",
},
{
internalType: "uint256",
name: "startTime",
type: "uint256",
},
{
internalType: "uint256",
name: "endTime",
@@ -1429,11 +1502,6 @@ const deployedContracts = {
name: "ipfsHash",
type: "string",
},
{
internalType: "address",
name: "creator",
type: "address",
},
{
components: [
{
@@ -1461,6 +1529,11 @@ const deployedContracts = {
name: "pollContracts",
type: "tuple",
},
{
internalType: "uint256",
name: "startTime",
type: "uint256",
},
{
internalType: "uint256",
name: "endTime",
@@ -1664,7 +1737,7 @@ const deployedContracts = {
},
},
PoseidonT3: {
address: "0x809d550fca64d94Bd9F66E60752A544199cfAC3D",
address: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
abi: [
{
inputs: [
@@ -1689,7 +1762,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
PoseidonT4: {
address: "0x4c5859f0F772848b2D91F1D83E2Fe57935348029",
address: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
abi: [
{
inputs: [
@@ -1714,7 +1787,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
PoseidonT5: {
address: "0x1291Be112d480055DaFd8a610b7d1e203891C274",
address: "0x0165878A594ca255338adfa4d48449f69242Eb8F",
abi: [
{
inputs: [
@@ -1739,7 +1812,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
PoseidonT6: {
address: "0x5f3f1dBD7B74C6B46e8c44f98792A1dAf8d69154",
address: "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
abi: [
{
inputs: [
@@ -1764,7 +1837,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
SubsidyFactory: {
address: "0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3",
address: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
abi: [
{
inputs: [
@@ -1811,7 +1884,7 @@ const deployedContracts = {
},
},
TallyFactory: {
address: "0x82e01223d51Eb87e16A03E24687EDF0F294da6f1",
address: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
abi: [
{
inputs: [
@@ -1858,7 +1931,7 @@ const deployedContracts = {
},
},
TopupCredit: {
address: "0x36C02dA8a0983159322a80FFE9F24b1acfF8B570",
address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
abi: [
{
inputs: [],
@@ -2268,7 +2341,7 @@ const deployedContracts = {
},
},
Verifier: {
address: "0x5eb3Bc0a489C5A8288765d2336659EbCA68FCd00",
address: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
abi: [
{
inputs: [],
@@ -2430,7 +2503,7 @@ const deployedContracts = {
},
},
VkRegistry: {
address: "0xc351628EB244ec633d5f21fBD6621e1a683B1181",
address: "0x9A676e781A523b5d0C0e43731313A708CB607508",
abi: [
{
inputs: [],