11import hre from "hardhat" ;
22import { getBytes } from "ethers" ;
3- import { DisputeKitShutter , SortitionModule , SortitionModuleNeo } from "../typechain-types" ;
3+ import { DisputeKitGatedShutter , DisputeKitShutter , SortitionModule , SortitionModuleNeo } from "../typechain-types" ;
44import { decrypt } from "./shutter" ;
55import env from "./utils/env" ;
66import loggerFactory from "./utils/logger" ;
77import { Cores , getContracts as getContractsForCoreType } from "./utils/contracts" ;
88
99const SUBGRAPH_URL = env . require ( "SUBGRAPH_URL" ) ;
1010const CORE_TYPE = env . optional ( "CORE_TYPE" , "base" ) ;
11+ const DISPUTES_TO_SKIP = env
12+ . optional ( "DISPUTES_TO_SKIP" , "" )
13+ . split ( "," )
14+ . map ( ( s ) => s . trim ( ) ) ;
1115
1216const loggerOptions = env . optionalNoDefault ( "LOGTAIL_TOKEN_KEEPER_BOT" )
1317 ? {
@@ -23,15 +27,6 @@ const loggerOptions = env.optionalNoDefault("LOGTAIL_TOKEN_KEEPER_BOT")
2327 } ;
2428const logger = loggerFactory . createLogger ( loggerOptions ) ;
2529
26- const getContracts = async ( ) => {
27- const coreType = Cores [ CORE_TYPE . toUpperCase ( ) as keyof typeof Cores ] ;
28- if ( coreType === Cores . UNIVERSITY ) {
29- throw new Error ( "University is not supported yet" ) ;
30- }
31- const contracts = await getContractsForCoreType ( hre , coreType ) ;
32- return { ...contracts , sortition : contracts . sortition as SortitionModule | SortitionModuleNeo } ;
33- } ;
34-
3530/**
3631 * Decodes a message string into its component parts
3732 * @param message The message to decode
@@ -77,7 +72,9 @@ type DisputeVotes = {
7772 } ;
7873} ;
7974
80- const getShutterDisputesToReveal = async ( disputeKitShutter : DisputeKitShutter ) : Promise < DisputeVotes [ ] > => {
75+ const getShutterDisputesToReveal = async (
76+ disputeKitShutter : DisputeKitShutter | DisputeKitGatedShutter
77+ ) : Promise < DisputeVotes [ ] > => {
8178 const { gql, request } = await import ( "graphql-request" ) ; // workaround for ESM import
8279 const query = gql `
8380 query DisputeToAutoReveal($shutterDisputeKit: Bytes) {
@@ -191,7 +188,10 @@ const getShutterDisputesToReveal = async (disputeKitShutter: DisputeKitShutter):
191188 return filteredDisputeVotes ;
192189} ;
193190
194- export const shutterAutoReveal = async ( disputeKitShutter : DisputeKitShutter | null , disputesToSkip : string [ ] ) => {
191+ export const shutterAutoReveal = async (
192+ disputeKitShutter : DisputeKitShutter | DisputeKitGatedShutter | null ,
193+ disputesToSkip : string [ ]
194+ ) => {
195195 if ( ! disputeKitShutter ) {
196196 logger . debug ( "No Shutter dispute kit found, skipping auto-reveal" ) ;
197197 return [ ] ;
@@ -307,10 +307,20 @@ export const shutterAutoReveal = async (disputeKitShutter: DisputeKitShutter | n
307307 }
308308} ;
309309
310+ const getContracts = async ( ) => {
311+ const coreType = Cores [ CORE_TYPE . toUpperCase ( ) as keyof typeof Cores ] ;
312+ if ( coreType === Cores . UNIVERSITY ) {
313+ throw new Error ( "University is not supported yet" ) ;
314+ }
315+ const contracts = await getContractsForCoreType ( hre , coreType ) ;
316+ return { ...contracts , sortition : contracts . sortition as SortitionModule | SortitionModuleNeo } ;
317+ } ;
318+
310319async function main ( ) {
311320 logger . debug ( "Starting..." ) ;
312- const { disputeKitShutter } = await getContracts ( ) ;
313- await shutterAutoReveal ( disputeKitShutter , [ "44" , "45" , "51" , "54" ] ) ;
321+ const { disputeKitShutter, disputeKitGatedShutter } = await getContracts ( ) ;
322+ await shutterAutoReveal ( disputeKitShutter , DISPUTES_TO_SKIP ) ;
323+ await shutterAutoReveal ( disputeKitGatedShutter , DISPUTES_TO_SKIP ) ;
314324}
315325
316326if ( require . main === module ) {
0 commit comments