Skip to content

Commit 8a7d3ab

Browse files
authored
Add closing epoch startBlock and poi info (#21)
1 parent 2ee3c30 commit 8a7d3ab

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

src/dispute.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { BigNumber } from 'ethers'
55
import { getEpoch, Dispute, GraphNetwork } from './model'
66
import { Environment } from './env'
77
import { toGRT } from './utils'
8+
import { EthereumBlock } from './poi'
89

910
function styleBoolean(value: boolean) {
1011
return value ? chalk.greenBright(value) : chalk.redBright(value)
@@ -37,7 +38,9 @@ function styleClosedAtEpoch(
3738
networkSettings: GraphNetwork,
3839
) {
3940
if (isDisputeOlderThanTwoThawingPeriods(closedAtEpoch, networkSettings)) {
40-
return chalk.redBright(closedAtEpoch)
41+
return (
42+
chalk.redBright(closedAtEpoch) + chalk.gray(` (${'dispute is too old'})`)
43+
)
4144
}
4245
return chalk.cyanBright(closedAtEpoch)
4346
}
@@ -77,7 +80,7 @@ export const populateEntry = async (
7780
])
7881

7982
// Reference POI
80-
const [lastBlock, prevBlock] = await Promise.all([
83+
const [lastBlock, prevBlock]: EthereumBlock[] = await Promise.all([
8184
provider.getBlock(lastEpoch.startBlock),
8285
provider.getBlock(prevEpoch.startBlock),
8386
])
@@ -118,8 +121,8 @@ export const populateEntry = async (
118121
),
119122
[chalk.bold('SubgraphDeployment')]: {
120123
id:
121-
chalk.cyanBright(`${subgraphDeployment.bytes32} `) +
122-
chalk.gray(`(${subgraphDeployment.ipfsHash})`),
124+
chalk.cyanBright(subgraphDeployment.bytes32) +
125+
chalk.gray(` (${subgraphDeployment.ipfsHash})`),
123126
},
124127
[chalk.bold('Economics')]: {
125128
indexerSlashableStake: chalk.greenBright(`${slashableStake} GRT`),
@@ -129,13 +132,18 @@ export const populateEntry = async (
129132
id: chalk.cyanBright(dispute.allocation.id),
130133
createdAtEpoch: chalk.cyanBright(dispute.allocation.createdAtEpoch),
131134
createdAtBlock: chalk.cyanBright(dispute.allocation.createdAtBlockHash),
132-
closedAtEpoch: styleClosedAtEpoch(
133-
dispute.allocation.closedAtEpoch,
134-
networkSettings,
135-
),
135+
closedAtEpoch: {
136+
id: styleClosedAtEpoch(
137+
dispute.allocation.closedAtEpoch,
138+
networkSettings,
139+
),
140+
startBlock:
141+
chalk.cyanBright(lastBlock.hash) +
142+
chalk.gray(` (#${lastBlock.number})`),
143+
},
136144
closedAtBlock:
137-
chalk.cyanBright(`${dispute.allocation.closedAtBlockHash} `) +
138-
chalk.gray(`(#${dispute.allocation.closedAtBlockNumber})`),
145+
chalk.cyanBright(dispute.allocation.closedAtBlockHash) +
146+
chalk.gray(` (#${dispute.allocation.closedAtBlockNumber})`),
139147
},
140148
[chalk.bold('POI')]: {
141149
submitted: chalk.cyanBright(dispute.allocation.poi),
@@ -145,6 +153,12 @@ export const populateEntry = async (
145153
prevPoi.proof === dispute.allocation.poi,
146154
)
147155
: chalk.redBright('Not-Found'),
156+
previousEpochPOI: hasProof
157+
? chalk.cyanBright(prevPoi.proof)
158+
: chalk.gray('Not-Found'),
159+
lastEpochPOI: hasProof
160+
? chalk.cyanBright(lastPoi.proof)
161+
: chalk.gray('Not-Found'),
148162
},
149163
}
150164

0 commit comments

Comments
 (0)