-
Notifications
You must be signed in to change notification settings - Fork 156
/
wagmi.config.ts
94 lines (81 loc) · 2.25 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
import { defineConfig } from '@wagmi/cli';
import { foundry } from '@wagmi/cli/plugins';
import { readdirSync, readFileSync } from 'fs';
type ContractNames =
| 'DropMetadataRenderer'
| 'EditionMetadataRenderer'
| 'FactoryUpgradeGate'
| 'ERC721Drop'
| 'ZoraNFTCreatorProxy'
| 'ZoraNFTCreatorV1';
type Address = `0x${string}`;
const contractFilesToInclude: ContractNames[] = [
'DropMetadataRenderer',
'FactoryUpgradeGate',
'EditionMetadataRenderer',
'ERC721Drop',
'ZoraNFTCreatorProxy',
'ZoraNFTCreatorV1'
];
type Addresses = {
[key in ContractNames]?: {
[chainId: number]: Address;
};
};
const getAddresses = () => {
const addresses: Addresses = {};
const addressesFiles = readdirSync('./addresses');
const addAddress = (
contractName: ContractNames,
chainId: number,
address: Address
) => {
if (!addresses[contractName]) {
addresses[contractName] = {};
}
addresses[contractName]![chainId] = address;
};
for (const addressesFile of addressesFiles) {
const jsonAddress = JSON.parse(
readFileSync(`./addresses/${addressesFile}`, 'utf-8')
) as {
DROP_METADATA_RENDERER: Address;
EDITION_METADATA_RENDERER: Address;
ERC721DROP_IMPL: Address;
FACTORY_UPGRADE_GATE: Address;
ZORA_NFT_CREATOR_PROXY: Address;
ZORA_NFT_CREATOR_V1_IMPL: Address;
};
const chainId = parseInt(addressesFile.split('.')[0]);
// addAddress(
// "DropMetadataRenderer",
// chainId,
// jsonAddress.DROP_METADATA_RENDERER
// );
// addAddress(
// "EditionMetadataRenderer",
// chainId,
// jsonAddress.EDITION_METADATA_RENDERER
// );
// addAddress("ERC721Drop", chainId, jsonAddress.ERC721DROP_IMPL);
// addAddress("FactoryUpgradeGate", chainId, jsonAddress.FACTORY_UPGRADE_GATE);
addAddress(
'ZoraNFTCreatorV1',
chainId,
jsonAddress.ZORA_NFT_CREATOR_PROXY
);
// addAddress("ZoraNFTCreatorV1", chainId, jsonAddress.ZORA_NFT_CREATOR_V1_IMPL);
}
return addresses;
};
export default defineConfig({
out: 'package/wagmiGenerated.ts',
plugins: [
foundry({
deployments: getAddresses(),
include: contractFilesToInclude.map(
(contractName) => `${contractName}.json`
)
})
]
});