forked from bender-labs/wrap-tz-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata.py
193 lines (181 loc) · 7.17 KB
/
metadata.py
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import fire
import json
from src.ligo import LigoView
class Views(object):
def multi_asset(self, destination):
views = LigoView("./ligo/fa2/multi_asset/views.mligo")
get_balance = views.compile(
"get_balance", "nat", "get_balance as defined in tzip-12"
)
total_supply = views.compile(
"total_supply", "nat", "get_total supply as defined in tzip-12"
)
is_operator = views.compile(
"is_operator", "bool", "is_operator as defined in tzip-12"
)
token_metadata = views.compile(
"token_metadata",
"(pair nat (map string bytes))",
"token_metadata as defined in tzip-12",
)
meta = {
"interfaces": ["TZIP-012", "TZIP-016", "TZIP-021"],
"name": "Wrap protocol FA2 tokens",
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"license": {"name": "MIT"},
"permissions": {
"operator": "owner-or-operator-transfer",
"receiver": "owner-no-hook",
"sender": "owner-no-hook",
"custom": {"tag": "PAUSABLE_TOKENS"},
},
"views": [get_balance, total_supply, is_operator, token_metadata],
}
with open(destination, "w") as outfile:
json.dump(meta, outfile, indent=4)
def nft(self, destination):
views = LigoView("./ligo/fa2/nft/views.mligo")
get_balance = views.compile(
"get_balance", "nat", "get_balance as defined in tzip-12"
)
total_supply = views.compile(
"total_supply", "nat", "get_total supply as defined in tzip-12"
)
is_operator = views.compile(
"is_operator", "bool", "is_operator as defined in tzip-12"
)
token_metadata = views.compile(
"token_metadata",
"(pair nat (map string bytes))",
"token_metadata as defined in tzip-12",
)
meta = {
"interfaces": ["TZIP-012", "TZIP-016"],
"name": "Wrap protocol NFT token",
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"license": {"name": "MIT"},
"permissions": {
"operator": "owner-or-operator-transfer",
"receiver": "owner-no-hook",
"sender": "owner-no-hook",
"custom": {"tag": "PAUSABLE_TOKENS"},
},
"views": [get_balance, is_operator, token_metadata, total_supply],
}
with open(destination, "w") as outfile:
json.dump(meta, outfile, indent=4)
def quorum(self, destination):
metadata = {
"name": "Wrap protocol quorum contract",
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"interfaces": ["TZIP-016"],
"license": {"name": "MIT"},
}
with open(destination, "w") as outfile:
json.dump(metadata, outfile, indent=4)
def minter(self, destination):
views = LigoView("./ligo/minter/views.mligo")
get_token_reward = views.compile(
"get_token_reward", "nat", "get pending tokens fees"
)
get_tez_reward = views.compile(
"get_tez_reward", "mutez", "get pending tez fees"
)
metadata = {
"name": "Wrap protocol minter contract",
"interfaces": ["TZIP-016"],
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"license": {"name": "MIT"},
"views": [get_token_reward, get_tez_reward],
}
with open(destination, "w") as outfile:
json.dump(metadata, outfile, indent=4)
def governance_token(self, destination):
views = LigoView("./ligo/fa2/governance/views.mligo")
all_tokens = views.compile(
"all_tokens", "list(nat)", "all_tokens as defined in tzip-12"
)
get_balance = views.compile(
"get_balance", "nat", "get_balance as defined in tzip-12"
)
total_supply = views.compile(
"total_supply", "nat", "get_total supply as defined in tzip-12"
)
is_operator = views.compile(
"is_operator", "bool", "is_operator as defined in tzip-12"
)
token_metadata = views.compile(
"token_metadata",
"(pair nat (map string bytes))",
"token_metadata as defined in tzip-12",
)
distributed = views.compile(
"tokens_distributed",
"How many governance tokens have already been distributed",
)
meta = {
"interfaces": ["TZIP-012", "TZIP-016", "TZIP-021"],
"name": "Wrap protocol governance token",
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"license": {"name": "MIT"},
"permissions": {
"operator": "owner-or-operator-transfer",
"receiver": "owner-no-hook",
"sender": "owner-no-hook",
"custom": {"tag": "PAUSABLE_TOKENS"},
},
"views": [
all_tokens,
get_balance,
total_supply,
is_operator,
token_metadata,
distributed,
],
}
with open(destination, "w") as outfile:
json.dump(meta, outfile, indent=4)
def staking(self, destination):
views = LigoView("./ligo/staking/views.mligo")
get_earned = views.compile(
"get_earned",
"nat",
description="Get claimable reward for address",
pure=False,
)
get_balance = views.compile(
"get_balance", "nat", "Get staked balance for address"
)
total_supply = views.compile("total_supply", "nat", "Get total staked")
meta = {
"interfaces": ["TZIP-016"],
"name": "Wrap staking contract",
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"license": {"name": "MIT"},
"views": [get_earned, get_balance, total_supply],
}
with open(destination, "w") as outfile:
json.dump(meta, outfile, indent=4)
def stacking(self, destination):
views = LigoView("./ligo/stacking/views.mligo")
get_earned = views.compile(
"get_earned",
description="Get claimable reward for address",
pure=False,
)
get_balance = views.compile(
"get_balance", description="Get staked balance for address"
)
total_supply = views.compile("total_supply", description="Get total staked")
get_stakes = views.compile("get_stakes", description="Get stakes for user", pure=False)
meta = {
"interfaces": ["TZIP-016"],
"name": "Wrap stacking contract",
"homepage": "https://github.com/bender-labs/wrap-tz-contracts",
"license": {"name": "MIT"},
"views": [get_earned, get_balance, total_supply, get_stakes],
}
with open(destination, "w") as outfile:
json.dump(meta, outfile, indent=4)
if __name__ == "__main__":
fire.Fire(Views)