-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwagmi.config.ts
95 lines (87 loc) · 2.21 KB
/
wagmi.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import fs from 'node:fs'
import url from 'node:url'
import path from 'node:path'
import { defineConfig, type Plugin } from '@wagmi/cli'
import { foundry, etherscan, actions, react, type FoundryConfig } from '@wagmi/cli/plugins'
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const ENABLE_ETHERSCAN = false
/**
* docs: https://beta.wagmi.sh
* Runs forge build then generates a single typescript file containing all ABIs
* Usage:
* ```sh
* bun wagmi generate path/to/write/to.ts
* ```
*/
const [, outDir] = process.argv.slice(2)
export default defineConfig([
{
out: outDir ? path.join(outDir, 'abi.ts') : path.join(__dirname, 'generated', 'abi.ts'),
plugins: [
foundryPlugin({
build: true,
clean: true,
rebuild: true
}),
etherscanPlugin()
]
},
{
out: outDir ? path.join(outDir, 'actions.ts') : path.join(__dirname, 'generated', 'actions.ts'),
plugins: [foundryPlugin(), actions()]
},
{
out: outDir ? path.join(outDir, 'react.ts') : path.join(__dirname, 'generated', 'hooks.ts'),
plugins: [foundryPlugin(), react()]
}
])
function foundryPlugin(forgeConfig?: FoundryConfig['forge']): Plugin {
const artifacts = fs
.readdirSync(path.join(__dirname, 'src'))
.filter((item) => item.startsWith('EFP'))
.map((item) => `${item}/**`)
return foundry({
artifacts: 'out/',
include: artifacts,
project: __dirname,
forge: { build: true, clean: false, rebuild: false, ...forgeConfig }
})
}
/**
* Only Sepolia for now
*/
function etherscanPlugin(): Plugin {
if (!ENABLE_ETHERSCAN) {
return () => {}
}
return etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 11_155_111,
contracts: [
{
name: 'EFPAccountMetadata',
address: '0x_PLACEHOLDER'
},
{
name: 'EFPListManager',
address: '0x_PLACEHOLDER'
},
{
name: 'ListMetadata',
address: '0x_PLACEHOLDER'
},
{
name: 'ListRecords',
address: '0x_PLACEHOLDER'
},
{
name: 'EFPListRecords',
address: '0x_PLACEHOLDER'
},
{
name: 'EFPListRegistry',
address: '0x_PLACEHOLDER'
}
]
})
}