11import { readdir , readFile } from "fs/promises" ;
22import { parse , join } from "path" ;
33
4- import { Chain } from "@wagmi/chains" ;
54import { type Config , type ContractConfig , defineConfig } from "@wagmi/cli" ;
65import { react , actions } from "@wagmi/cli/plugins" ;
76import 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" ;
129
1310import { ArbitratorTypes , getArbitratorType } from "consts/arbitratorTypes" ;
1411
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" ;
2016
21- const getAbi = ( artifact : any ) => {
22- return ( artifact as ArtifactPartial ) . abi ;
23- } ;
17+ dotenv . config ( ) ;
2418
2519const readArtifacts = async ( type : ArbitratorTypes , viemChainName : string , hardhatChainName ?: string ) => {
2620 const artifactSuffix =
@@ -30,8 +24,16 @@ const readArtifacts = async (type: ArbitratorTypes, viemChainName: string, hardh
3024 const vanillaArtifacts = [ "KlerosCore" , "DisputeKitClassic" , "SortitionModule" , "DisputeResolver" ] ;
3125 const typeSpecificArtifacts = vanillaArtifacts . map ( ( artifact ) => `${ artifact } ${ artifactSuffix } ` ) ;
3226
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 ] ;
3537 if ( ! chain ) {
3638 throw new Error ( `Viem chain ${ viemChainName } not found` ) ;
3739 }
@@ -75,18 +77,22 @@ const getConfig = async (): Promise<Config> => {
7577
7678 let viemNetwork : string ;
7779 let hardhatNetwork : string ;
80+ let arbitratorContracts ;
7881 switch ( deployment ) {
7982 case "devnet" :
8083 viemNetwork = "arbitrumSepolia" ;
8184 hardhatNetwork = "arbitrumSepoliaDevnet" ;
85+ arbitratorContracts = devnetViem ;
8286 break ;
8387 case "testnet" :
8488 viemNetwork = "arbitrumSepolia" ;
8589 hardhatNetwork = "arbitrumSepolia" ;
90+ arbitratorContracts = testnetViem ;
8691 break ;
8792 case "mainnet" :
8893 viemNetwork = "arbitrum" ;
8994 hardhatNetwork = "arbitrum" ;
95+ arbitratorContracts = mainnetViem ;
9096 break ;
9197 default :
9298 throw new Error ( `Unknown deployment ${ deployment } ` ) ;
@@ -100,11 +106,11 @@ const getConfig = async (): Promise<Config> => {
100106 ...deploymentContracts ,
101107 {
102108 name : "IHomeGateway" ,
103- abi : getAbi ( IHomeGateway ) ,
109+ abi : arbitratorContracts . iHomeGatewayAbi ,
104110 } ,
105111 {
106112 name : "IArbitrableV2" ,
107- abi : getAbi ( IArbitrableV2 ) ,
113+ abi : IArbitrableV2 . abi ,
108114 } ,
109115 ] ,
110116 plugins : [ react ( ) , actions ( ) ] ,
0 commit comments