Skip to content

Commit bcb63c1

Browse files
committed
feat: add wagmi type generation to interface package
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
1 parent d14870e commit bcb63c1

File tree

5 files changed

+562
-3
lines changed

5 files changed

+562
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,6 @@ tx-builder-*.json
8181
**/ignition/deployments/*-hardhat/
8282
**/ignition/deployments/*-31337/
8383
**/ignition/deployments/*-1337/
84+
85+
# wagmi generated types
86+
wagmi/

packages/interfaces/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
".": {
1212
"default": "./dist/src/index.js",
1313
"types": "./dist/src/index.d.ts"
14+
},
15+
"./wagmi": {
16+
"default": "./dist/wagmi/generated.js",
17+
"types": "./dist/wagmi/generated.d.ts"
1418
}
1519
},
1620
"files": [
@@ -29,7 +33,7 @@
2933
"lint:sol": "solhint --fix --noPrompt --noPoster 'contracts/**/*.sol'; prettier -w --cache --log-level warn 'contracts/**/*.sol'",
3034
"lint:json": "prettier -w --cache --log-level warn '**/*.json'",
3135
"format": "prettier -w --cache --log-level warn '**/*.{js,ts,cjs,mjs,jsx,tsx,json,md,yaml,yml}'",
32-
"build": "hardhat compile && tsc",
36+
"build": "hardhat compile && wagmi generate && tsc",
3337
"build:clean": "pnpm clean && pnpm build",
3438
"watch": "tsc --watch",
3539
"prepublishOnly": "pnpm run build"
@@ -39,11 +43,13 @@
3943
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
4044
"@openzeppelin/contracts": "3.4.1",
4145
"@openzeppelin/contracts-upgradeable": "3.4.2",
46+
"@wagmi/cli": "^2.3.1",
4247
"ethers": "6.13.7",
4348
"hardhat": "^2.24.0",
4449
"markdownlint-cli": "^0.45.0",
4550
"prettier": "^3.5.3",
4651
"prettier-plugin-solidity": "^2.0.0",
47-
"solhint": "5.1.0"
52+
"solhint": "5.1.0",
53+
"viem": "^2.31.7"
4854
}
4955
}

packages/interfaces/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"compilerOptions": {
44
"outDir": "dist"
55
},
6-
"include": ["hardhat.config.ts", "src/**/*.ts", "types/**/*.ts"]
6+
"include": ["hardhat.config.ts", "src/**/*.ts", "types/**/*.ts", "wagmi/**/*.ts"]
77
}

packages/interfaces/wagmi.config.mts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { defineConfig, type Config } from '@wagmi/cli'
2+
import { Abi } from 'viem'
3+
4+
import GraphToken from './artifacts/contracts/contracts/token/IGraphToken.sol/IGraphToken.json'
5+
import L2GNS from './artifacts/contracts/toolshed/IGNSToolshed.sol/IGNSToolshed.json'
6+
import L2Curation from './artifacts/contracts/toolshed/IL2CurationToolshed.sol/IL2CurationToolshed.json'
7+
import HorizonStaking from './artifacts/contracts/toolshed/IHorizonStakingToolshed.sol/IHorizonStakingToolshed.json'
8+
import EpochManager from './artifacts/contracts/toolshed/IEpochManagerToolshed.sol/IEpochManagerToolshed.json'
9+
import RewardsManager from './artifacts/contracts/toolshed/IRewardsManagerToolshed.sol/IRewardsManagerToolshed.json'
10+
import L2GraphTokenGateway from './artifacts/contracts/contracts/l2/gateway/IL2GraphTokenGateway.sol/IL2GraphTokenGateway.json'
11+
12+
// Only generate wagmi types for contracts that are used by the Explorer
13+
export default defineConfig({
14+
out: 'wagmi/generated.ts',
15+
contracts: [
16+
{
17+
name: 'L2GNS',
18+
abi: L2GNS.abi as Abi,
19+
},
20+
{
21+
name: 'L2Curation',
22+
abi: L2Curation.abi as Abi,
23+
},
24+
{
25+
name: 'L2GraphToken',
26+
abi: GraphToken.abi as Abi,
27+
},
28+
{
29+
name: 'HorizonStaking',
30+
abi: HorizonStaking.abi as Abi,
31+
},
32+
{
33+
name: 'EpochManager',
34+
abi: EpochManager.abi as Abi,
35+
},
36+
{
37+
name: 'RewardsManager',
38+
abi: RewardsManager.abi as Abi,
39+
},
40+
{
41+
name: 'L2GraphTokenGateway',
42+
abi: L2GraphTokenGateway.abi as Abi,
43+
},
44+
],
45+
plugins: []
46+
}) as Config

0 commit comments

Comments
 (0)