1
- import { arbitrum , arbitrumSepolia } from "viem/chains" ;
1
+ import { type PublicClient , type WalletClient , getContract } from "viem" ;
2
+ import { type ContractConfig , type DeploymentName , deployments , getAddress } from "./utils" ;
2
3
import {
3
4
klerosCoreConfig as devnetCoreConfig ,
4
5
sortitionModuleConfig as devnetSortitionConfig ,
@@ -46,35 +47,19 @@ import {
46
47
pnkConfig as mainnetPnkConfig ,
47
48
klerosCoreSnapshotProxyConfig as mainnetSnapshotProxyConfig ,
48
49
} from "./mainnet.viem" ;
49
- import { type PublicClient , type WalletClient , getContract } from "viem" ;
50
-
51
- const deployments = {
52
- devnet : {
53
- chainId : arbitrumSepolia . id ,
54
- } ,
55
- university : {
56
- chainId : arbitrumSepolia . id ,
57
- } ,
58
- testnet : {
59
- chainId : arbitrumSepolia . id ,
60
- } ,
61
- mainnetNeo : {
62
- chainId : arbitrum . id ,
63
- } ,
64
- } as const ;
65
-
66
- type DeploymentName = keyof typeof deployments ;
67
-
68
- type ContractConfig = {
69
- address : Record < number , `0x${string } `> ;
70
- abi : readonly any [ ] ;
71
- } ;
72
50
73
51
type ContractInstance = {
74
52
address : `0x${string } `;
75
53
abi : readonly any [ ] ;
76
54
} ;
77
55
56
+ function getContractConfig ( { config, chainId } : { config : ContractConfig ; chainId : number } ) : ContractInstance {
57
+ return {
58
+ address : getAddress ( config , chainId ) ,
59
+ abi : config . abi ,
60
+ } ;
61
+ }
62
+
78
63
type ContractInstances = {
79
64
klerosCore : ContractInstance ;
80
65
sortition : ContractInstance ;
@@ -91,19 +76,6 @@ type ContractInstances = {
91
76
klerosCoreSnapshotProxy : ContractInstance ;
92
77
} ;
93
78
94
- function getAddress ( config : ContractConfig , chainId : number ) : `0x${string } ` {
95
- const address = config . address [ chainId ] ;
96
- if ( ! address ) throw new Error ( `No address found for chainId ${ chainId } ` ) ;
97
- return address ;
98
- }
99
-
100
- function getContractConfig ( { config, chainId } : { config : ContractConfig ; chainId : number } ) : ContractInstance {
101
- return {
102
- address : getAddress ( config , chainId ) ,
103
- abi : config . abi ,
104
- } ;
105
- }
106
-
107
79
function getCommonConfigs ( {
108
80
chainId,
109
81
configs,
0 commit comments