Skip to content

Commit

Permalink
Merge pull request #14 from sector-3/fetch-dao-priorities-from-contract
Browse files Browse the repository at this point in the history
feat: fetch priorities from dao contract (#6)
  • Loading branch information
aahna-ashina authored Feb 15, 2023
2 parents cf8aebc + a1b1456 commit 3d27535
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
46 changes: 46 additions & 0 deletions abis/Sector3DAO.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,38 @@
}],
"stateMutability": "nonpayable",
"type": "constructor"
}, {
"inputs": [{
"internalType": "string",
"name": "title",
"type": "string"
}, {
"internalType": "address",
"name": "rewardToken",
"type": "address"
}, {
"internalType": "uint16",
"name": "epochDurationInDays",
"type": "uint16"
}, {
"internalType": "uint256",
"name": "epochBudget",
"type": "uint256"
}],
"name": "deployPriority",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "getPriorityCount",
"outputs": [{
"internalType": "uint16",
"name": "",
"type": "uint16"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "name",
Expand All @@ -31,6 +63,20 @@
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"name": "priorities",
"outputs": [{
"internalType": "contract Sector3DAOPriority",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "purpose",
Expand Down
28 changes: 25 additions & 3 deletions src/pages/daos/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import Head from 'next/head'
import Image from 'next/image'
import { Inter } from '@next/font/google'
import styles from '@/styles/Home.module.css'
import { configureChains, goerli, createClient, readContracts, Address } from '@wagmi/core'
import { configureChains, goerli, createClient, readContract, readContracts, Address } from '@wagmi/core'
import { publicProvider } from '@wagmi/core/providers/public'
import Sector3DAO from '../../../abis/Sector3DAO.json'
import Sector3DAOPriority from '../../../abis/Sector3DAOPriority.json'
import { useState } from 'react'
import { ethers } from 'ethers'
import Link from 'next/link'

Expand Down Expand Up @@ -107,13 +106,36 @@ export async function getStaticProps(context: any) {
{
...daoContract,
functionName: 'purpose'
},
{
...daoContract,
functionName: 'getPriorityCount'
}
]
})
console.log('daoData:', daoData)

let priorityAddresses: any[] = []

const priorityCount: Number = Number(daoData[2])
console.log('priorityCount:', priorityCount)
let priorityIndex = 0;
while (priorityIndex < priorityCount) {
console.log('priorityIndex:', priorityIndex)

const priorityData = await readContract({
address: address,
abi: Sector3DAO.abi,
functionName: 'priorities',
args: [priorityIndex]
})
console.log('priorityData:', priorityData)
priorityAddresses[priorityIndex] = priorityData

priorityIndex++
}

let priorities = []
const priorityAddresses: Address[] = [ '0xcfed46a9DADDcbEEC23FF8Ef99cFF6A572c36DbE', '0x2B8810457595f7c2DCd0F24ac953236CAa07e5B8']
for (const priorityAddress of priorityAddresses) {
console.log('priorityAddress:', priorityAddress)

Expand Down

0 comments on commit 3d27535

Please sign in to comment.