|
4 | 4 | Usage: |
5 | 5 | algorealm.py poem |
6 | 6 | algorealm.py dynasty [--test] |
| 7 | + algorealm.py longevity (--crown | --sceptre) [--test] |
| 8 | + algorealm.py braveness (--crown | --sceptre) [--test] |
7 | 9 | algorealm.py claim-majesty (--crown | --sceptre) <majesty-name> <microalgos> [--test] |
8 | 10 | algorealm.py claim-card |
9 | 11 | algorealm.py buy-order <microalgos> [--notify] |
|
14 | 16 | Commands: |
15 | 17 | poem AlgoRealm's poem. |
16 | 18 | dynasty Print the glorious dynasty of AlgoRealm's Majesties. |
| 19 | + longevity Print AlgoRealm's Majesties longevity. |
| 20 | + braveness Print AlgoRealm's Majesties braveness. |
17 | 21 | claim-majesty Claim the Crown of Entropy or the Sceptre of Proof, become Majesty of Algorand. |
18 | 22 | claim-card Brake the spell and claim the AlgoRealm Card by AlgoWorld. |
19 | 23 | buy-order Place an order for the AlgoRealm Card. |
|
35 | 39 | from algosdk.v2client.algod import AlgodClient |
36 | 40 | from algosdk.v2client.indexer import IndexerClient |
37 | 41 | from docopt import docopt |
| 42 | +from prettytable import PrettyTable |
38 | 43 |
|
39 | 44 | import actions |
40 | 45 | import query |
@@ -135,60 +140,96 @@ def main(): |
135 | 140 | algod_client = build_algod_client(test=args["--test"]) |
136 | 141 | indexer_client = build_indexer_client(test=args["--test"]) |
137 | 142 |
|
| 143 | + if args["--test"]: |
| 144 | + crown_nft_id = TEST_CROWN_ID |
| 145 | + sceptre_nft_id = TEST_SCEPTRE_ID |
| 146 | + algorealm_app_id = TEST_ALGOREALM_APP_ID |
| 147 | + algorealm_contract = TEST_ALGOREALM_LAW_BYTECODE |
| 148 | + algorealm_first_round = TEST_ALGOREALM_FIRST_BLOCK |
| 149 | + else: |
| 150 | + crown_nft_id = CROWN_ID |
| 151 | + sceptre_nft_id = SCEPTRE_ID |
| 152 | + algorealm_app_id = ALGOREALM_APP_ID |
| 153 | + algorealm_contract = ALGOREALM_LAW_BYTECODE |
| 154 | + algorealm_first_round = ALGOREALM_FIRST_BLOCK |
| 155 | + |
138 | 156 | # CLI |
139 | 157 | if args["dynasty"]: |
140 | | - if args["--test"]: |
141 | | - algorealm_app_id = TEST_ALGOREALM_APP_ID |
142 | | - algorealm_first_round = TEST_ALGOREALM_FIRST_BLOCK |
| 158 | + claims = query.claims_history( |
| 159 | + client=indexer_client, |
| 160 | + algorealm_app_id=algorealm_app_id, |
| 161 | + algorealm_first_round=algorealm_first_round, |
| 162 | + ) |
| 163 | + |
| 164 | + print("\t\t\t\t*** DYNASTY ***\n") |
| 165 | + return print(*["\n", *query.dynasty(claims)]) |
| 166 | + |
| 167 | + if args["longevity"]: |
| 168 | + claims = query.claims_history( |
| 169 | + client=indexer_client, |
| 170 | + algorealm_app_id=algorealm_app_id, |
| 171 | + algorealm_first_round=algorealm_first_round, |
| 172 | + ) |
| 173 | + latest_block = algod_client.status()["last-round"] |
| 174 | + |
| 175 | + if args["--crown"]: |
| 176 | + majesty_title = "👑 RANDOMIC" |
| 177 | + claim_select = "Crown" |
143 | 178 | else: |
144 | | - algorealm_app_id = ALGOREALM_APP_ID |
145 | | - algorealm_first_round = ALGOREALM_FIRST_BLOCK |
146 | | - print( |
147 | | - r""" |
148 | | - *** DYNASTY *** |
149 | | - """ |
| 179 | + majesty_title = "🪄 VERIFIABLE" |
| 180 | + claim_select = "Sceptre" |
| 181 | + |
| 182 | + majesty_longevity = query.longevity(claims, latest_block, claim_select) |
| 183 | + |
| 184 | + longevity_table = PrettyTable() |
| 185 | + longevity_table.field_names = ["Majesty Name", "Longevity (blocks)"] |
| 186 | + longevity_table.add_rows( |
| 187 | + [[claim["name"], claim["longevity"]] for claim in majesty_longevity] |
150 | 188 | ) |
151 | | - return print( |
152 | | - *[ |
153 | | - "\n", |
154 | | - *query.history( |
155 | | - client=indexer_client, |
156 | | - algorealm_app_id=algorealm_app_id, |
157 | | - algorealm_first_round=algorealm_first_round, |
158 | | - ), |
159 | | - ] |
| 189 | + |
| 190 | + print(f"\t\t*** {majesty_title} MAJESTY LONGEVITY ***\n") |
| 191 | + return print(longevity_table) |
| 192 | + |
| 193 | + if args["braveness"]: |
| 194 | + claims = query.claims_history( |
| 195 | + client=indexer_client, |
| 196 | + algorealm_app_id=algorealm_app_id, |
| 197 | + algorealm_first_round=algorealm_first_round, |
160 | 198 | ) |
161 | 199 |
|
| 200 | + if args["--crown"]: |
| 201 | + majesty_title = "👑 RANDOMIC" |
| 202 | + claim_select = "Crown" |
| 203 | + else: |
| 204 | + majesty_title = "🪄 VERIFIABLE" |
| 205 | + claim_select = "Sceptre" |
| 206 | + |
| 207 | + majesty_braveness = query.braveness(claims, claim_select) |
| 208 | + |
| 209 | + braveness_table = PrettyTable() |
| 210 | + braveness_table.field_names = ["Majesty Name", "Braveness"] |
| 211 | + braveness_table.add_rows( |
| 212 | + [[claim["name"], claim["braveness"]] for claim in majesty_braveness] |
| 213 | + ) |
| 214 | + |
| 215 | + print(f"\t\t*** {majesty_title} MAJESTY BRAVENESS ***\n") |
| 216 | + return print(braveness_table) |
| 217 | + |
162 | 218 | if args["claim-majesty"]: |
163 | 219 | majesty_name = args["<majesty-name>"] |
164 | 220 |
|
165 | | - if args["--test"]: |
166 | | - algorealm_first_round = TEST_ALGOREALM_FIRST_BLOCK |
167 | | - algorealm_contract = TEST_ALGOREALM_LAW_BYTECODE |
168 | | - algorealm_app_id = TEST_ALGOREALM_APP_ID |
169 | | - else: |
170 | | - algorealm_first_round = ALGOREALM_FIRST_BLOCK |
171 | | - algorealm_contract = ALGOREALM_LAW_BYTECODE |
172 | | - algorealm_app_id = ALGOREALM_APP_ID |
173 | | - |
174 | 221 | if args["--crown"]: |
175 | 222 | proclaim = ( |
176 | 223 | f"\n👑 Glory to {majesty_name}, the Randomic Majesty of Algorand! 🎉\n" |
177 | 224 | ) |
178 | 225 | claim_select = "Crown" |
179 | | - if args["--test"]: |
180 | | - nft_id = TEST_CROWN_ID |
181 | | - else: |
182 | | - nft_id = CROWN_ID |
| 226 | + nft_id = crown_nft_id |
183 | 227 | else: |
184 | 228 | proclaim = ( |
185 | 229 | f"\n🪄 Glory to {majesty_name}, the Verifiable Majesty of Algorand! 🎉\n" |
186 | 230 | ) |
187 | 231 | claim_select = "Sceptre" |
188 | | - if args["--test"]: |
189 | | - nft_id = TEST_SCEPTRE_ID |
190 | | - else: |
191 | | - nft_id = SCEPTRE_ID |
| 232 | + nft_id = sceptre_nft_id |
192 | 233 |
|
193 | 234 | user = actions.get_user() |
194 | 235 | algorealm_law = actions.get_contract_account(algorealm_contract) |
|
0 commit comments