-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.py
More file actions
46 lines (38 loc) · 971 Bytes
/
build.py
File metadata and controls
46 lines (38 loc) · 971 Bytes
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
import os
import json
list = [
"Config",
"File",
"List",
"Node",
"PDP",
"Prove",
"Sector",
"Space",
"Dns"
]
for i in list:
source = "artifacts/contracts/{}.sol/{}.json".format(i, i)
abi = "build/{}.abi".format(i)
bin = "build/{}.bin".format(i)
go = "build/go/{}/{}.go".format(i, i)
os.makedirs(os.path.dirname(go), exist_ok=True)
with open(source, "r") as f:
if os.path.isfile(abi):
os.remove(abi)
if os.path.isfile(bin):
os.remove(bin)
if os.path.isfile(go):
os.remove(go)
data = json.load(f)
a = data["abi"]
w = open(abi, "w")
w.write(json.dumps(a))
w.close()
b = data["bytecode"]
w = open(bin, "w")
w.write(b)
w.close()
c = "abigen --bin=build/{}.bin --abi=build/{}.abi --pkg=store --out=build/go/{}/{}.go".format(
i, i, i, i)
os.system(c)