@@ -16,6 +16,7 @@ import {
16
16
SortitionModuleUniversity ,
17
17
TransactionBatcher ,
18
18
KlerosCoreSnapshotProxy ,
19
+ EvidenceModule ,
19
20
} from "../../typechain-types" ;
20
21
21
22
export const Cores = {
@@ -26,6 +27,44 @@ export const Cores = {
26
27
27
28
export type Core = ( typeof Cores ) [ keyof typeof Cores ] ;
28
29
30
+ export const getContractNames = ( coreType : Core ) => {
31
+ const coreSpecificNames = {
32
+ [ Cores . NEO ] : {
33
+ core : "KlerosCoreNeo" ,
34
+ sortition : "SortitionModuleNeo" ,
35
+ disputeKitClassic : "DisputeKitClassicNeo" ,
36
+ disputeResolver : "DisputeResolverNeo" ,
37
+ } ,
38
+ [ Cores . BASE ] : {
39
+ core : "KlerosCore" ,
40
+ sortition : "SortitionModule" ,
41
+ disputeKitClassic : "DisputeKitClassic" ,
42
+ disputeResolver : "DisputeResolver" ,
43
+ } ,
44
+ [ Cores . UNIVERSITY ] : {
45
+ core : "KlerosCoreUniversity" ,
46
+ sortition : "SortitionModuleUniversity" ,
47
+ disputeKitClassic : "DisputeKitClassicUniversity" ,
48
+ disputeResolver : "DisputeResolverUniversity" ,
49
+ } ,
50
+ } ;
51
+
52
+ if ( ! ( coreType in coreSpecificNames ) ) throw new Error ( "Invalid core type, must be one of BASE, NEO, or UNIVERSITY" ) ;
53
+
54
+ return {
55
+ ...coreSpecificNames [ coreType ] ,
56
+ evidence : "EvidenceModule" ,
57
+ disputeTemplateRegistry : "DisputeTemplateRegistry" ,
58
+ policyRegistry : "PolicyRegistry" ,
59
+ batcher : "TransactionBatcher" ,
60
+ chainlinkRng : "ChainlinkRNG" ,
61
+ randomizerRng : "RandomizerRNG" ,
62
+ blockHashRNG : "BlockHashRNG" ,
63
+ pnk : "PNK" ,
64
+ snapshotProxy : "KlerosCoreSnapshotProxy" ,
65
+ } ;
66
+ } ;
67
+
29
68
export const getContracts = async ( hre : HardhatRuntimeEnvironment , coreType : Core ) => {
30
69
const { ethers } = hre ;
31
70
let core : KlerosCore | KlerosCoreNeo | KlerosCoreUniversity ;
@@ -34,40 +73,46 @@ export const getContracts = async (hre: HardhatRuntimeEnvironment, coreType: Cor
34
73
let disputeResolver : DisputeResolver ;
35
74
switch ( coreType ) {
36
75
case Cores . NEO :
37
- core = await ethers . getContract < KlerosCoreNeo > ( "KlerosCoreNeo" ) ;
38
- sortition = await ethers . getContract < SortitionModuleNeo > ( "SortitionModuleNeo" ) ;
39
- disputeKitClassic = await ethers . getContract < DisputeKitClassic > ( "DisputeKitClassicNeo" ) ;
40
- disputeResolver = await ethers . getContract < DisputeResolver > ( "DisputeResolverNeo" ) ;
76
+ core = await ethers . getContract < KlerosCoreNeo > ( getContractNames ( coreType ) . core ) ;
77
+ sortition = await ethers . getContract < SortitionModuleNeo > ( getContractNames ( coreType ) . sortition ) ;
78
+ disputeKitClassic = await ethers . getContract < DisputeKitClassic > ( getContractNames ( coreType ) . disputeKitClassic ) ;
79
+ disputeResolver = await ethers . getContract < DisputeResolver > ( getContractNames ( coreType ) . disputeResolver ) ;
41
80
break ;
42
81
case Cores . BASE :
43
- core = await ethers . getContract < KlerosCore > ( "KlerosCore" ) ;
44
- sortition = await ethers . getContract < SortitionModule > ( "SortitionModule" ) ;
45
- disputeKitClassic = await ethers . getContract < DisputeKitClassic > ( "DisputeKitClassic" ) ;
46
- disputeResolver = await ethers . getContract < DisputeResolver > ( "DisputeResolver" ) ;
82
+ core = await ethers . getContract < KlerosCore > ( getContractNames ( coreType ) . core ) ;
83
+ sortition = await ethers . getContract < SortitionModule > ( getContractNames ( coreType ) . sortition ) ;
84
+ disputeKitClassic = await ethers . getContract < DisputeKitClassic > ( getContractNames ( coreType ) . disputeKitClassic ) ;
85
+ disputeResolver = await ethers . getContract < DisputeResolver > ( getContractNames ( coreType ) . disputeResolver ) ;
47
86
break ;
48
87
case Cores . UNIVERSITY :
49
- core = await ethers . getContract < KlerosCoreUniversity > ( "KlerosCoreUniversity" ) ;
50
- sortition = await ethers . getContract < SortitionModuleUniversity > ( "SortitionModuleUniversity" ) ;
51
- disputeKitClassic = await ethers . getContract < DisputeKitClassic > ( "DisputeKitClassicUniversity" ) ;
52
- disputeResolver = await ethers . getContract < DisputeResolver > ( "DisputeResolverUniversity" ) ;
88
+ core = await ethers . getContract < KlerosCoreUniversity > ( getContractNames ( coreType ) . core ) ;
89
+ sortition = await ethers . getContract < SortitionModuleUniversity > ( getContractNames ( coreType ) . sortition ) ;
90
+ disputeKitClassic = await ethers . getContract < DisputeKitClassic > ( getContractNames ( coreType ) . disputeKitClassic ) ;
91
+ disputeResolver = await ethers . getContract < DisputeResolver > ( getContractNames ( coreType ) . disputeResolver ) ;
53
92
break ;
54
93
default :
55
94
throw new Error ( "Invalid core type, must be one of BASE, NEO, or UNIVERSITY" ) ;
56
95
}
57
- const disputeTemplateRegistry = await ethers . getContract < DisputeTemplateRegistry > ( "DisputeTemplateRegistry" ) ;
58
- const policyRegistry = await ethers . getContract < PolicyRegistry > ( "PolicyRegistry" ) ;
59
- const batcher = await ethers . getContract < TransactionBatcher > ( "TransactionBatcher" ) ;
60
- const chainlinkRng = await ethers . getContractOrNull < ChainlinkRNG > ( "ChainlinkRNG" ) ;
61
- const randomizerRng = await ethers . getContractOrNull < RandomizerRNG > ( "RandomizerRNG" ) ;
62
- const blockHashRNG = await ethers . getContractOrNull < BlockHashRNG > ( "BlockHashRNG" ) ;
63
- const pnk = await ethers . getContract < PNK > ( "PNK" ) ;
64
- const snapshotProxy = await ethers . getContractOrNull < KlerosCoreSnapshotProxy > ( "KlerosCoreSnapshotProxy" ) ;
96
+ const disputeTemplateRegistry = await ethers . getContract < DisputeTemplateRegistry > (
97
+ getContractNames ( coreType ) . disputeTemplateRegistry
98
+ ) ;
99
+ const evidence = await ethers . getContract < EvidenceModule > ( getContractNames ( coreType ) . evidence ) ;
100
+ const policyRegistry = await ethers . getContract < PolicyRegistry > ( getContractNames ( coreType ) . policyRegistry ) ;
101
+ const batcher = await ethers . getContract < TransactionBatcher > ( getContractNames ( coreType ) . batcher ) ;
102
+ const chainlinkRng = await ethers . getContractOrNull < ChainlinkRNG > ( getContractNames ( coreType ) . chainlinkRng ) ;
103
+ const randomizerRng = await ethers . getContractOrNull < RandomizerRNG > ( getContractNames ( coreType ) . randomizerRng ) ;
104
+ const blockHashRNG = await ethers . getContractOrNull < BlockHashRNG > ( getContractNames ( coreType ) . blockHashRNG ) ;
105
+ const pnk = await ethers . getContract < PNK > ( getContractNames ( coreType ) . pnk ) ;
106
+ const snapshotProxy = await ethers . getContractOrNull < KlerosCoreSnapshotProxy > (
107
+ getContractNames ( coreType ) . snapshotProxy
108
+ ) ;
65
109
return {
66
110
core,
67
111
sortition,
68
112
disputeKitClassic,
69
113
disputeResolver,
70
114
disputeTemplateRegistry,
115
+ evidence,
71
116
policyRegistry,
72
117
chainlinkRng,
73
118
randomizerRng,
@@ -77,3 +122,25 @@ export const getContracts = async (hre: HardhatRuntimeEnvironment, coreType: Cor
77
122
snapshotProxy,
78
123
} ;
79
124
} ;
125
+
126
+ export const getContractsFromNetwork = async ( hre : HardhatRuntimeEnvironment ) => {
127
+ const { network } = hre ;
128
+ if ( network . name === "arbitrumSepoliaDevnet" || network . name === "arbitrumSepolia" ) {
129
+ return getContracts ( hre , Cores . BASE ) ;
130
+ } else if ( network . name === "arbitrum" ) {
131
+ return getContracts ( hre , Cores . NEO ) ;
132
+ } else {
133
+ throw new Error ( "Invalid network" ) ;
134
+ }
135
+ } ;
136
+
137
+ export const getContractNamesFromNetwork = async ( hre : HardhatRuntimeEnvironment ) => {
138
+ const { network } = hre ;
139
+ if ( network . name === "arbitrumSepoliaDevnet" || network . name === "arbitrumSepolia" ) {
140
+ return getContractNames ( Cores . BASE ) ;
141
+ } else if ( network . name === "arbitrum" ) {
142
+ return getContractNames ( Cores . NEO ) ;
143
+ } else {
144
+ throw new Error ( "Invalid network" ) ;
145
+ }
146
+ } ;
0 commit comments