Skip to content

Commit

Permalink
add chainId, operator and recipientDeposit
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Feb 2, 2023
1 parent 568df9f commit e48b345
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
30 changes: 27 additions & 3 deletions contracts/tasks/fetchRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ async function mergeRecipientTally({

async function getRoundInfo(
roundContract: Contract,
ethers: any
ethers: any,
operator: string
): Promise<Round> {
console.log('Fetching round data...')
const round: any = { address: roundContract.address }
Expand Down Expand Up @@ -216,6 +217,21 @@ async function getRoundInfo(
.catch(toUndefined)

round.recipientRegistryAddress = await roundContract.recipientRegistry()
try {
const recipientRegistry = await ethers.getContractAt(
'OptimisticRecipientRegistry',
round.recipientRegistryAddress
)
round.recipientDepositAmount = await recipientRegistry
.baseDeposit()
.then(toString)
} catch {
// ignore error - non optimistic recipient registry does not have deposit
}

round.operator = operator
const providerNetwork = await ethers.provider.getNetwork()
round.chainId = providerNetwork.chainId

console.log('Round', round)
return round
Expand All @@ -227,6 +243,7 @@ async function getRoundInfo(
task('fetch-round', 'Fetch round data')
.addParam('roundAddress', 'Funding round contract address')
.addParam('outputDir', 'Output directory')
.addParam('operator', 'Funding round operator, e.g. ETHColombia')
.addOptionalParam(
'startBlock',
'First block to process from the recipient registry contract',
Expand All @@ -247,7 +264,14 @@ task('fetch-round', 'Fetch round data')
)
.setAction(
async (
{ roundAddress, outputDir, startBlock, endBlock, blocksPerBatch },
{
roundAddress,
outputDir,
startBlock,
endBlock,
blocksPerBatch,
operator,
},
{ ethers, network, config }
) => {
console.log('Processing on ', network.name)
Expand All @@ -270,7 +294,7 @@ task('fetch-round', 'Fetch round data')
'FundingRound',
roundAddress
)
const round = await getRoundInfo(roundContract, ethers)
const round = await getRoundInfo(roundContract, ethers, operator)
const recipientRegistry = new Contract(
round.recipientRegistryAddress,
getRecipientAddressAbi,
Expand Down
7 changes: 7 additions & 0 deletions contracts/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ export interface Token {
decimals: number
}

/**
* Round interface
* recipientDeposit is optional for non-optimistic recipient registries
*/
export interface Round {
chainId: number
operator: string
address: string
userRegistryAddress: string
recipientRegistryAddress: string
recipientDepositAmount?: string
maciAddress: string
contributorCount: number
totalSpent: string
Expand Down

0 comments on commit e48b345

Please sign in to comment.