forked from taikoxyz/taiko-mono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwagmi.config.ts
60 lines (50 loc) · 1.82 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
import { StandardMerkleTree } from '@openzeppelin/merkle-tree';
import { defineConfig } from '@wagmi/cli'
import type { Abi, Address } from 'abitype'
import { existsSync, mkdirSync,readFileSync, writeFileSync } from 'fs'
import * as MainnetDeployment from '../nfts/deployments/snaefell/mainnet.json'
import * as LocalhostDeployment from '../nfts/deployments/snaefell/localhost.json'
import SnaefellToken from '../nfts/out/SnaefellToken.sol/SnaefellToken.json'
function generateNetworkWhitelist(network: string){
const tree = StandardMerkleTree.load(JSON.parse(
readFileSync(
`../nfts/data/snaefell/whitelist/${network}.json`,
'utf8')
))
const allocation = {}
for (const [_, [rawAddress, amount]] of tree.entries()) {
const address = rawAddress.toString().toLowerCase()
if (!allocation[address]){
allocation[address] = 0
}
allocation[address] += parseInt(amount)
}
writeFileSync(`./src/generated/whitelist/${network}.json`,
JSON.stringify({
...tree.dump(),
allocation
}, null, 2))
console.log(`Whitelist merkle root for network ${network}: ${tree.root}`)
}
function generateWhitelistJson() {
const whitelistDir = "./src/generated/whitelist";
if (!existsSync(whitelistDir)) {
mkdirSync(whitelistDir, { recursive: true });
}
generateNetworkWhitelist('mainnet')
// generateNetworkWhitelist('hardhat')
}
generateWhitelistJson();
export default defineConfig({
out: 'src/generated/abi/index.ts',
contracts: [
{
name: 'SnaefellToken',
address: {
167000: MainnetDeployment.SnaefellToken as Address,
31337: LocalhostDeployment.SnaefellToken as Address,
},
abi: SnaefellToken.abi as Abi,
}
],
})