1
1
import { readdir , readFile } from "fs/promises" ;
2
2
import { parse , join } from "path" ;
3
3
4
- import { Chain } from "@wagmi/chains" ;
5
4
import { type Config , type ContractConfig , defineConfig } from "@wagmi/cli" ;
6
5
import { react , actions } from "@wagmi/cli/plugins" ;
7
6
import dotenv from "dotenv" ;
8
- import { type Abi } from "viem" ;
9
-
10
- import IArbitrableV2 from "@kleros/kleros-v2-contracts/artifacts/src/arbitration/interfaces/IArbitrableV2.sol/IArbitrableV2.json" assert { type : "json" } ;
11
- import IHomeGateway from "@kleros/kleros-v2-contracts/artifacts/src/gateway/interfaces/IHomeGateway.sol/IHomeGateway.json" assert { type : "json" } ;
7
+ import { type Chain } from "viem" ;
8
+ import { arbitrum , arbitrumSepolia , gnosis , gnosisChiado , mainnet , sepolia } from "viem/chains" ;
12
9
13
10
import { ArbitratorTypes , getArbitratorType } from "consts/arbitratorTypes" ;
14
11
15
- dotenv . config ( ) ;
16
-
17
- type ArtifactPartial = {
18
- abi : Abi ;
19
- } ;
12
+ import IArbitrableV2 from "../contracts/artifacts/src/arbitration/interfaces/IArbitrableV2.sol/IArbitrableV2.json" assert { type : "json" } ;
13
+ import * as devnetViem from "../contracts/dist/cjs/deployments/devnet.viem" ;
14
+ import * as mainnetViem from "../contracts/dist/cjs/deployments/mainnet.viem" ;
15
+ import * as testnetViem from "../contracts/dist/cjs/deployments/testnet.viem" ;
20
16
21
- const getAbi = ( artifact : any ) => {
22
- return ( artifact as ArtifactPartial ) . abi ;
23
- } ;
17
+ dotenv . config ( ) ;
24
18
25
19
const readArtifacts = async ( type : ArbitratorTypes , viemChainName : string , hardhatChainName ?: string ) => {
26
20
const artifactSuffix =
@@ -30,8 +24,16 @@ const readArtifacts = async (type: ArbitratorTypes, viemChainName: string, hardh
30
24
const vanillaArtifacts = [ "KlerosCore" , "DisputeKitClassic" , "SortitionModule" , "DisputeResolver" ] ;
31
25
const typeSpecificArtifacts = vanillaArtifacts . map ( ( artifact ) => `${ artifact } ${ artifactSuffix } ` ) ;
32
26
33
- const chains = await import ( "wagmi/chains" ) ;
34
- const chain = chains [ viemChainName ] as Chain ;
27
+ const chainMap : Record < string , Chain > = {
28
+ arbitrum,
29
+ arbitrumSepolia,
30
+ sepolia,
31
+ mainnet,
32
+ gnosisChiado,
33
+ gnosis,
34
+ } ;
35
+
36
+ const chain = chainMap [ viemChainName ] ;
35
37
if ( ! chain ) {
36
38
throw new Error ( `Viem chain ${ viemChainName } not found` ) ;
37
39
}
@@ -75,18 +77,22 @@ const getConfig = async (): Promise<Config> => {
75
77
76
78
let viemNetwork : string ;
77
79
let hardhatNetwork : string ;
80
+ let arbitratorContracts ;
78
81
switch ( deployment ) {
79
82
case "devnet" :
80
83
viemNetwork = "arbitrumSepolia" ;
81
84
hardhatNetwork = "arbitrumSepoliaDevnet" ;
85
+ arbitratorContracts = devnetViem ;
82
86
break ;
83
87
case "testnet" :
84
88
viemNetwork = "arbitrumSepolia" ;
85
89
hardhatNetwork = "arbitrumSepolia" ;
90
+ arbitratorContracts = testnetViem ;
86
91
break ;
87
92
case "mainnet" :
88
93
viemNetwork = "arbitrum" ;
89
94
hardhatNetwork = "arbitrum" ;
95
+ arbitratorContracts = mainnetViem ;
90
96
break ;
91
97
default :
92
98
throw new Error ( `Unknown deployment ${ deployment } ` ) ;
@@ -100,11 +106,11 @@ const getConfig = async (): Promise<Config> => {
100
106
...deploymentContracts ,
101
107
{
102
108
name : "IHomeGateway" ,
103
- abi : getAbi ( IHomeGateway ) ,
109
+ abi : arbitratorContracts . iHomeGatewayAbi ,
104
110
} ,
105
111
{
106
112
name : "IArbitrableV2" ,
107
- abi : getAbi ( IArbitrableV2 ) ,
113
+ abi : IArbitrableV2 . abi ,
108
114
} ,
109
115
] ,
110
116
plugins : [ react ( ) , actions ( ) ] ,
0 commit comments