forked from vlzhr/WavesDAO
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdao_deploy.py
More file actions
111 lines (75 loc) · 2.83 KB
/
dao_deploy.py
File metadata and controls
111 lines (75 loc) · 2.83 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import pywaves as pw
import random
import os
import re
import sys
NODE = "https://testnode1.wavesnodes.com"
CHAIN = "T"
def create_account():
pw.setNode(NODE, CHAIN)
seed = " ".join([random.choice(pw.wordList) for n in range(15)])
account = pw.Address(seed=seed)
return {
"seed": account.seed,
"address": account.address
}
def set_membership_address(script_text, address):
li = script_text.split("\n")
new_li = []
set_address_line = 'let mainContract = addressFromStringValue("' + \
address+'") # HERE TO SET MEMBERSHIP SMART CONTRACT ADDRESS'
set_address_line = 'let mainContract = addressFromStringValue("'+address+'") # HERE TO SET MEMBERSHIP SMART CONTRACT ADDRESS'
for line in li:
if not "# HERE TO SET MEMBERSHIP SMART CONTRACT ADDRESS" in line:
new_li.append(line)
else:
new_li.append(set_address_line)
return ("\n").join(new_li)
def read_scripts(membership_address=""):
dic = {
"mem": "dao-membership.ride",
"dis": "disruptive-grant.ride",
"web": "web3-grant.ride",
"int": "interhack-grant.ride",
}
keys = list(dic.keys())
for k in keys:
with open("smart-contracts/"+dic[k], encoding="utf-8") as f:
dic[k] = set_membership_address(f.read(), membership_address)
return dic
def deploy(seed1):
print(seed1)
pw.setNode(NODE, CHAIN)
a1 = pw.Address(seed=seed1)
balance = a1.balance()
print(balance)
if balance < 4*10**6:
raise("Top up the account balance using Waves Faucet")
accs = [create_account() for n in range(3)]
sponsor_amount = 10**6
print(accs)
for a in accs:
a1.sendWaves(pw.Address(a["address"]), sponsor_amount,
attachment="setting DAO", txFee=500000)
scripts = read_scripts(a1.address)
a1.setScript(scripts["mem"], txFee=1400000)
print("script #1 set")
pw.Address(seed=accs[0]["seed"]).setScript(scripts["dis"], txFee=1000000)
print("script #1 set")
pw.Address(seed=accs[1]["seed"]).setScript(scripts["web"], txFee=1000000)
print("script #2 set")
pw.Address(seed=accs[2]["seed"]).setScript(scripts["int"], txFee=1000000)
print("script #3 set")
out = "membership;{};{}".format(a1.address, a1.seed) + \
"\ndisruptive grants;{};{}".format(accs[0]["address"], accs[0]["seed"]) + \
"\nweb 3.0 grants;{};{}".format(accs[1]["address"], accs[1]["seed"]) + \
"\ninterhack grants;{};{}".format(
accs[2]["address"], accs[2]["seed"])
with open("credentials.csv", "w", encoding="utf-8") as f:
f.write(out)
print(out)
def main():
deploy(os.environ["SEED"])
seed1 = "chair hint artefact crumble improve note select myth case expire govern slam wedding hour manage"
if __name__ == "__main__":
main()