@@ -12,29 +12,26 @@ import {
12
12
13
13
dotenv . config ( ) ;
14
14
15
+ type ContractConfigWithoutChainId = {
16
+ address : `0x${string } `;
17
+ abi : any [ ] ;
18
+ } ;
19
+
15
20
type ArbitratorContracts = {
16
21
default : {
17
22
contracts : {
18
- KlerosCore : {
19
- address : `0x${string } `;
20
- abi : any [ ] ;
21
- } ;
22
- SortitionModule : {
23
- address : `0x${string } `;
24
- abi : any [ ] ;
25
- } ;
26
- EvidenceModule : {
27
- address : `0x${string } `;
28
- abi : any [ ] ;
29
- } ;
30
- DisputeTemplateRegistry : {
31
- address : `0x${string } `;
32
- abi : any [ ] ;
33
- } ;
23
+ KlerosCore : ContractConfigWithoutChainId ;
24
+ KlerosCoreNeo : ContractConfigWithoutChainId ;
25
+ SortitionModule : ContractConfigWithoutChainId ;
26
+ SortitionModuleNeo : ContractConfigWithoutChainId ;
27
+ EvidenceModule : ContractConfigWithoutChainId ;
28
+ DisputeTemplateRegistry : ContractConfigWithoutChainId ;
34
29
} ;
35
30
} ;
36
31
} ;
37
32
33
+ type ContractNameSuffix = "" | "Neo" ;
34
+
38
35
const addArbitratorContract = ( {
39
36
results,
40
37
chain,
@@ -44,7 +41,7 @@ const addArbitratorContract = ({
44
41
results : ContractConfig [ ] ;
45
42
chain : Chain ;
46
43
name : string ;
47
- contract : { address : `0x${ string } ` ; abi : any [ ] } ;
44
+ contract : ContractConfigWithoutChainId ;
48
45
} ) => {
49
46
results . push ( {
50
47
name,
@@ -58,6 +55,7 @@ const addArbitratorContract = ({
58
55
const readArtifacts = async (
59
56
viemChainName : string ,
60
57
hardhatChainName : string ,
58
+ contractNameSuffix : ContractNameSuffix ,
61
59
arbitratorContracts : ArbitratorContracts
62
60
) => {
63
61
const chains = await import ( "wagmi/chains" ) ;
@@ -86,8 +84,14 @@ const readArtifacts = async (
86
84
}
87
85
}
88
86
89
- const { KlerosCore, SortitionModule, EvidenceModule, DisputeTemplateRegistry } =
90
- arbitratorContracts . default . contracts ;
87
+ const coreContractName = `KlerosCore${ contractNameSuffix } ` as keyof typeof arbitratorContracts . default . contracts ;
88
+ const { [ coreContractName ] : KlerosCore } = arbitratorContracts . default . contracts ;
89
+
90
+ const sortitionModuleContractName =
91
+ `SortitionModule${ contractNameSuffix } ` as keyof typeof arbitratorContracts . default . contracts ;
92
+ const { [ sortitionModuleContractName ] : SortitionModule } = arbitratorContracts . default . contracts ;
93
+
94
+ const { EvidenceModule, DisputeTemplateRegistry } = arbitratorContracts . default . contracts ;
91
95
92
96
const arbitratorContractConfigs = [
93
97
{ name : "KlerosCore" , contract : KlerosCore } ,
@@ -105,28 +109,32 @@ const getConfig = async (): Promise<Config> => {
105
109
const deployment = process . env . REACT_APP_DEPLOYMENT ?? "devnet" ;
106
110
let viemNetwork : string ;
107
111
let hardhatNetwork : string ;
112
+ let contractNameSuffix : ContractNameSuffix ;
108
113
let arbitratorContracts ;
109
114
switch ( deployment ) {
110
115
case "devnet" :
111
116
viemNetwork = "arbitrumSepolia" ;
112
117
hardhatNetwork = "arbitrumSepoliaDevnet" ;
118
+ contractNameSuffix = "" ;
113
119
arbitratorContracts = arbitratorDevnet ;
114
120
break ;
115
121
case "testnet" :
116
122
viemNetwork = "arbitrumSepolia" ;
117
123
hardhatNetwork = "arbitrumSepolia" ;
124
+ contractNameSuffix = "" ;
118
125
arbitratorContracts = arbitratorTestnet ;
119
126
break ;
120
127
case "mainnet" :
121
128
viemNetwork = "arbitrum" ;
122
129
hardhatNetwork = "arbitrum" ;
130
+ contractNameSuffix = "Neo" ;
123
131
arbitratorContracts = arbitratorMainnet ;
124
132
break ;
125
133
default :
126
134
throw new Error ( `Unknown deployment ${ deployment } ` ) ;
127
135
}
128
136
129
- const deploymentContracts = await readArtifacts ( viemNetwork , hardhatNetwork , arbitratorContracts ) ;
137
+ const deploymentContracts = await readArtifacts ( viemNetwork , hardhatNetwork , contractNameSuffix , arbitratorContracts ) ;
130
138
131
139
return {
132
140
out : "src/hooks/contracts/generated.ts" ,
0 commit comments