dkg 1.1.2__py3-none-any.whl → 8.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. dkg/asset.py +589 -683
  2. dkg/constants.py +102 -40
  3. dkg/data/interfaces/AskStorage.json +366 -0
  4. dkg/data/interfaces/Chronos.json +202 -0
  5. dkg/data/interfaces/Hub.json +294 -2
  6. dkg/data/interfaces/IdentityStorage.json +400 -0
  7. dkg/data/interfaces/KnowledgeCollection.json +610 -0
  8. dkg/data/interfaces/KnowledgeCollectionStorage.json +2312 -0
  9. dkg/data/interfaces/Paranet.json +656 -135
  10. dkg/data/interfaces/ParanetIncentivesPoolFactory.json +18 -7
  11. dkg/data/interfaces/ParanetKnowledgeMinersRegistry.json +20 -4
  12. dkg/data/interfaces/{ParanetNeurowebIncentivesPool.json → ParanetNeuroIncentivesPool.json} +27 -58
  13. dkg/data/interfaces/ParanetsRegistry.json +844 -36
  14. dkg/data/interfaces/Token.json +146 -17
  15. dkg/dataclasses.py +13 -4
  16. dkg/exceptions.py +1 -0
  17. dkg/graph.py +55 -24
  18. dkg/main.py +18 -2
  19. dkg/network.py +2 -2
  20. dkg/node.py +7 -0
  21. dkg/paranet.py +356 -111
  22. dkg/providers/blockchain.py +23 -24
  23. dkg/providers/node_http.py +6 -13
  24. dkg/services/input_service.py +183 -0
  25. dkg/services/node_service.py +164 -0
  26. dkg/types/__init__.py +15 -3
  27. dkg/types/general.py +15 -8
  28. dkg/utils/blockchain_request.py +188 -64
  29. dkg/utils/knowledge_asset_tools.py +5 -0
  30. dkg/utils/knowledge_collection_tools.py +236 -0
  31. dkg/utils/merkle.py +1 -1
  32. dkg/utils/node_request.py +33 -33
  33. dkg/utils/rdf.py +10 -6
  34. dkg/utils/string_transformations.py +1 -0
  35. {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/METADATA +36 -26
  36. dkg-8.0.0.dist-info/RECORD +56 -0
  37. {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/WHEEL +1 -1
  38. dkg/data/interfaces/AssertionStorage.json +0 -229
  39. dkg/data/interfaces/ContentAsset.json +0 -801
  40. dkg/data/interfaces/ContentAssetStorage.json +0 -782
  41. dkg/data/interfaces/ServiceAgreementStorageProxy.json +0 -1314
  42. dkg/data/interfaces/UnfinalizedStateStorage.json +0 -171
  43. dkg-1.1.2.dist-info/RECORD +0 -52
  44. {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/LICENSE +0 -0
  45. {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/NOTICE +0 -0
dkg/paranet.py CHANGED
@@ -21,14 +21,18 @@ from dataclasses import dataclass
21
21
  from web3 import Web3
22
22
  from web3.types import TxReceipt
23
23
 
24
- from dkg.dataclasses import BaseIncentivesPoolParams, ParanetIncentivizationType
24
+ from dkg.dataclasses import (
25
+ BaseIncentivesPoolParams,
26
+ ParanetIncentivizationType,
27
+ ParanetNodesAccessPolicy,
28
+ ParanetMinersAccessPolicy,
29
+ )
25
30
  from dkg.manager import DefaultRequestManager
26
31
  from dkg.method import Method
27
32
  from dkg.module import Module
28
33
  from dkg.types import Address, UAL, HexStr
29
34
  from dkg.utils.blockchain_request import BlockchainRequest
30
35
  from dkg.utils.ual import parse_ual
31
- from dkg.constants import NEUROWEB_BLOCKCHAIN_PREFIX, INCENTIVE_POOL_NAME
32
36
 
33
37
 
34
38
  class Paranet(Module):
@@ -38,15 +42,10 @@ class Paranet(Module):
38
42
  operator_percentage: float
39
43
  voters_percentage: float
40
44
 
41
- def to_contract_args(self, incentive_type: ParanetIncentivizationType | None) -> dict:
45
+ def to_contract_args(self) -> dict:
42
46
  return {
43
47
  "tracToNeuroEmissionMultiplier": int(
44
- self.neuro_emission_multiplier
45
- * (
46
- 10**12
47
- if incentive_type == ParanetIncentivizationType.NEUROWEB
48
- else 10**18
49
- )
48
+ self.neuro_emission_multiplier * (10**12)
50
49
  ),
51
50
  "paranetOperatorRewardPercentage": int(self.operator_percentage * 100),
52
51
  "paranetIncentivizationProposalVotersRewardPercentage": int(
@@ -58,13 +57,17 @@ class Paranet(Module):
58
57
  self.manager = manager
59
58
  self.incentives_pools_deployment_functions = {
60
59
  ParanetIncentivizationType.NEUROWEB: self._deploy_neuro_incentives_pool,
61
- ParanetIncentivizationType.NEUROWEB_ERC20: self._deploy_neuro_incentives_pool,
62
60
  }
63
61
 
64
62
  _register_paranet = Method(BlockchainRequest.register_paranet)
65
63
 
66
64
  def create(
67
- self, ual: UAL, name: str, description: str
65
+ self,
66
+ ual: UAL,
67
+ name: str,
68
+ description: str,
69
+ paranet_nodes_access_policy: ParanetNodesAccessPolicy,
70
+ paranet_miners_access_policy: ParanetMinersAccessPolicy,
68
71
  ) -> dict[str, str | HexStr | TxReceipt]:
69
72
  parsed_ual = parse_ual(ual)
70
73
  knowledge_asset_storage, knowledge_asset_token_id = (
@@ -77,6 +80,8 @@ class Paranet(Module):
77
80
  knowledge_asset_token_id,
78
81
  name,
79
82
  description,
83
+ paranet_nodes_access_policy,
84
+ paranet_miners_access_policy,
80
85
  )
81
86
 
82
87
  return {
@@ -90,6 +95,328 @@ class Paranet(Module):
90
95
  "operation": json.loads(Web3.to_json(receipt)),
91
96
  }
92
97
 
98
+ _add_paranet_curated_nodes = Method(BlockchainRequest.add_paranet_curated_nodes)
99
+
100
+ def add_curated_nodes(
101
+ self, paranet_ual: UAL, identity_ids: list[int]
102
+ ) -> dict[str, str | HexStr | TxReceipt]:
103
+ parsed_ual = parse_ual(paranet_ual)
104
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
105
+ parsed_ual["contract_address"],
106
+ parsed_ual["token_id"],
107
+ )
108
+
109
+ receipt = self._add_paranet_curated_nodes(
110
+ paranet_knowledge_asset_storage,
111
+ paranet_knowledge_asset_token_id,
112
+ identity_ids,
113
+ )
114
+
115
+ return {
116
+ "paranetUAL": paranet_ual,
117
+ "paranetId": Web3.to_hex(
118
+ Web3.solidity_keccak(
119
+ ["address", "uint256"],
120
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
121
+ )
122
+ ),
123
+ "operation": json.loads(Web3.to_json(receipt)),
124
+ }
125
+
126
+ _remove_paranet_curated_nodes = Method(
127
+ BlockchainRequest.remove_paranet_curated_nodes
128
+ )
129
+
130
+ def remove_curated_nodes(
131
+ self, paranet_ual: UAL, identity_ids: list[int]
132
+ ) -> dict[str, str | HexStr | TxReceipt]:
133
+ parsed_ual = parse_ual(paranet_ual)
134
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
135
+ parsed_ual["contract_address"],
136
+ parsed_ual["token_id"],
137
+ )
138
+
139
+ receipt = self._remove_paranet_curated_nodes(
140
+ paranet_knowledge_asset_storage,
141
+ paranet_knowledge_asset_token_id,
142
+ identity_ids,
143
+ )
144
+
145
+ return {
146
+ "paranetUAL": paranet_ual,
147
+ "paranetId": Web3.to_hex(
148
+ Web3.solidity_keccak(
149
+ ["address", "uint256"],
150
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
151
+ )
152
+ ),
153
+ "operation": json.loads(Web3.to_json(receipt)),
154
+ }
155
+
156
+ _request_paranet_curated_node_access = Method(
157
+ BlockchainRequest.request_paranet_curated_node_access
158
+ )
159
+
160
+ def request_curated_node_access(
161
+ self, paranet_ual: UAL
162
+ ) -> dict[str, str | HexStr | TxReceipt]:
163
+ parsed_ual = parse_ual(paranet_ual)
164
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
165
+ parsed_ual["contract_address"],
166
+ parsed_ual["token_id"],
167
+ )
168
+
169
+ receipt = self._request_paranet_curated_node_access(
170
+ paranet_knowledge_asset_storage,
171
+ paranet_knowledge_asset_token_id,
172
+ )
173
+
174
+ return {
175
+ "paranetUAL": paranet_ual,
176
+ "paranetId": Web3.to_hex(
177
+ Web3.solidity_keccak(
178
+ ["address", "uint256"],
179
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
180
+ )
181
+ ),
182
+ "operation": json.loads(Web3.to_json(receipt)),
183
+ }
184
+
185
+ _approve_curated_node = Method(BlockchainRequest.approve_curated_node)
186
+
187
+ def approve_curated_node(
188
+ self, paranet_ual: UAL, identity_id: int
189
+ ) -> dict[str, str | HexStr | TxReceipt]:
190
+ parsed_ual = parse_ual(paranet_ual)
191
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
192
+ parsed_ual["contract_address"],
193
+ parsed_ual["token_id"],
194
+ )
195
+
196
+ receipt = self._approve_curated_node(
197
+ paranet_knowledge_asset_storage,
198
+ paranet_knowledge_asset_token_id,
199
+ identity_id,
200
+ )
201
+
202
+ return {
203
+ "paranetUAL": paranet_ual,
204
+ "paranetId": Web3.to_hex(
205
+ Web3.solidity_keccak(
206
+ ["address", "uint256"],
207
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
208
+ )
209
+ ),
210
+ "operation": json.loads(Web3.to_json(receipt)),
211
+ }
212
+
213
+ _reject_curated_node = Method(BlockchainRequest.reject_curated_node)
214
+
215
+ def reject_curated_node(
216
+ self, paranet_ual: UAL, identity_id: int
217
+ ) -> dict[str, str | HexStr | TxReceipt]:
218
+ parsed_ual = parse_ual(paranet_ual)
219
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
220
+ parsed_ual["contract_address"],
221
+ parsed_ual["token_id"],
222
+ )
223
+
224
+ receipt = self._reject_curated_node(
225
+ paranet_knowledge_asset_storage,
226
+ paranet_knowledge_asset_token_id,
227
+ identity_id,
228
+ )
229
+
230
+ return {
231
+ "paranetUAL": paranet_ual,
232
+ "paranetId": Web3.to_hex(
233
+ Web3.solidity_keccak(
234
+ ["address", "uint256"],
235
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
236
+ )
237
+ ),
238
+ "operation": json.loads(Web3.to_json(receipt)),
239
+ }
240
+
241
+ _get_curated_nodes = Method(BlockchainRequest.get_curated_nodes)
242
+
243
+ def get_curated_nodes(
244
+ self, paranet_ual: UAL
245
+ ) -> dict[str, str | HexStr | TxReceipt]:
246
+ parsed_ual = parse_ual(paranet_ual)
247
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
248
+ parsed_ual["contract_address"],
249
+ parsed_ual["token_id"],
250
+ )
251
+
252
+ paranet_id = Web3.solidity_keccak(
253
+ ["address", "uint256"],
254
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
255
+ )
256
+
257
+ return self._get_curated_nodes(paranet_id)
258
+
259
+ _add_paranet_curated_miners = Method(BlockchainRequest.add_paranet_curated_miners)
260
+
261
+ def add_curated_miners(
262
+ self, paranet_ual: UAL, miner_addresses: list[Address]
263
+ ) -> dict[str, str | HexStr | TxReceipt]:
264
+ parsed_ual = parse_ual(paranet_ual)
265
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
266
+ parsed_ual["contract_address"],
267
+ parsed_ual["token_id"],
268
+ )
269
+
270
+ receipt = self._add_paranet_curated_miners(
271
+ paranet_knowledge_asset_storage,
272
+ paranet_knowledge_asset_token_id,
273
+ miner_addresses,
274
+ )
275
+
276
+ return {
277
+ "paranetUAL": paranet_ual,
278
+ "paranetId": Web3.to_hex(
279
+ Web3.solidity_keccak(
280
+ ["address", "uint256"],
281
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
282
+ )
283
+ ),
284
+ "operation": json.loads(Web3.to_json(receipt)),
285
+ }
286
+
287
+ _remove_paranet_curated_miners = Method(
288
+ BlockchainRequest.remove_paranet_curated_miners
289
+ )
290
+
291
+ def remove_curated_miners(
292
+ self, paranet_ual: UAL, miner_addresses: list[Address]
293
+ ) -> dict[str, str | HexStr | TxReceipt]:
294
+ parsed_ual = parse_ual(paranet_ual)
295
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
296
+ parsed_ual["contract_address"],
297
+ parsed_ual["token_id"],
298
+ )
299
+
300
+ receipt = self._remove_paranet_curated_miners(
301
+ paranet_knowledge_asset_storage,
302
+ paranet_knowledge_asset_token_id,
303
+ miner_addresses,
304
+ )
305
+
306
+ return {
307
+ "paranetUAL": paranet_ual,
308
+ "paranetId": Web3.to_hex(
309
+ Web3.solidity_keccak(
310
+ ["address", "uint256"],
311
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
312
+ )
313
+ ),
314
+ "operation": json.loads(Web3.to_json(receipt)),
315
+ }
316
+
317
+ _request_paranet_curated_miner_access = Method(
318
+ BlockchainRequest.request_paranet_curated_miner_access
319
+ )
320
+
321
+ def request_curated_miner_access(
322
+ self, paranet_ual: UAL
323
+ ) -> dict[str, str | HexStr | TxReceipt]:
324
+ parsed_ual = parse_ual(paranet_ual)
325
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
326
+ parsed_ual["contract_address"],
327
+ parsed_ual["token_id"],
328
+ )
329
+
330
+ receipt = self._request_paranet_curated_miner_access(
331
+ paranet_knowledge_asset_storage,
332
+ paranet_knowledge_asset_token_id,
333
+ )
334
+
335
+ return {
336
+ "paranetUAL": paranet_ual,
337
+ "paranetId": Web3.to_hex(
338
+ Web3.solidity_keccak(
339
+ ["address", "uint256"],
340
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
341
+ )
342
+ ),
343
+ "operation": json.loads(Web3.to_json(receipt)),
344
+ }
345
+
346
+ _approve_curated_miner = Method(BlockchainRequest.approve_curated_miner)
347
+
348
+ def approve_curated_miner(
349
+ self, paranet_ual: UAL, miner_address: Address
350
+ ) -> dict[str, str | HexStr | TxReceipt]:
351
+ parsed_ual = parse_ual(paranet_ual)
352
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
353
+ parsed_ual["contract_address"],
354
+ parsed_ual["token_id"],
355
+ )
356
+
357
+ receipt = self._approve_curated_miner(
358
+ paranet_knowledge_asset_storage,
359
+ paranet_knowledge_asset_token_id,
360
+ miner_address,
361
+ )
362
+
363
+ return {
364
+ "paranetUAL": paranet_ual,
365
+ "paranetId": Web3.to_hex(
366
+ Web3.solidity_keccak(
367
+ ["address", "uint256"],
368
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
369
+ )
370
+ ),
371
+ "operation": json.loads(Web3.to_json(receipt)),
372
+ }
373
+
374
+ _reject_curated_miner = Method(BlockchainRequest.reject_curated_miner)
375
+
376
+ def reject_curated_miner(
377
+ self, paranet_ual: UAL, miner_address: Address
378
+ ) -> dict[str, str | HexStr | TxReceipt]:
379
+ parsed_ual = parse_ual(paranet_ual)
380
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
381
+ parsed_ual["contract_address"],
382
+ parsed_ual["token_id"],
383
+ )
384
+
385
+ receipt = self._reject_curated_miner(
386
+ paranet_knowledge_asset_storage,
387
+ paranet_knowledge_asset_token_id,
388
+ miner_address,
389
+ )
390
+
391
+ return {
392
+ "paranetUAL": paranet_ual,
393
+ "paranetId": Web3.to_hex(
394
+ Web3.solidity_keccak(
395
+ ["address", "uint256"],
396
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
397
+ )
398
+ ),
399
+ "operation": json.loads(Web3.to_json(receipt)),
400
+ }
401
+
402
+ _get_knowledge_miners = Method(BlockchainRequest.get_knowledge_miners)
403
+
404
+ def get_knowledge_miners(
405
+ self, paranet_ual: UAL
406
+ ) -> dict[str, str | HexStr | TxReceipt]:
407
+ parsed_ual = parse_ual(paranet_ual)
408
+ paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
409
+ parsed_ual["contract_address"],
410
+ parsed_ual["token_id"],
411
+ )
412
+
413
+ paranet_id = Web3.solidity_keccak(
414
+ ["address", "uint256"],
415
+ [paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
416
+ )
417
+
418
+ return self._get_knowledge_miners(paranet_id)
419
+
93
420
  _deploy_neuro_incentives_pool = Method(
94
421
  BlockchainRequest.deploy_neuro_incentives_pool
95
422
  )
@@ -98,7 +425,7 @@ class Paranet(Module):
98
425
  self,
99
426
  ual: UAL,
100
427
  incentives_pool_parameters: NeuroWebIncentivesPoolParams,
101
- incentives_type: ParanetIncentivizationType | None = None,
428
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
102
429
  ) -> dict[str, str | HexStr | TxReceipt]:
103
430
  deploy_incentives_pool_fn = self.incentives_pools_deployment_functions.get(
104
431
  incentives_type,
@@ -118,10 +445,9 @@ class Paranet(Module):
118
445
  )
119
446
 
120
447
  receipt: TxReceipt = deploy_incentives_pool_fn(
121
- incentives_type == ParanetIncentivizationType.NEUROWEB,
122
448
  knowledge_asset_storage,
123
449
  knowledge_asset_token_id,
124
- **incentives_pool_parameters.to_contract_args(incentives_type),
450
+ **incentives_pool_parameters.to_contract_args(),
125
451
  )
126
452
 
127
453
  events = self.manager.blockchain_provider.decode_logs_event(
@@ -145,7 +471,9 @@ class Paranet(Module):
145
471
  _get_incentives_pool_address = Method(BlockchainRequest.get_incentives_pool_address)
146
472
 
147
473
  def get_incentives_pool_address(
148
- self, ual: UAL, incentives_type: ParanetIncentivizationType | None = None
474
+ self,
475
+ ual: UAL,
476
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
149
477
  ) -> Address:
150
478
  parsed_ual = parse_ual(ual)
151
479
  knowledge_asset_storage, knowledge_asset_token_id = (
@@ -265,14 +593,8 @@ class Paranet(Module):
265
593
  self,
266
594
  ual: UAL,
267
595
  address: Address | None = None,
268
- incentives_type: ParanetIncentivizationType | None = None,
596
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
269
597
  ) -> bool:
270
- incentives_type = incentives_type or (
271
- ParanetIncentivizationType.NEUROWEB.value
272
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
273
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
274
- )
275
-
276
598
  return self._is_proposal_voter(
277
599
  contract=self._get_incentives_pool_contract(ual, incentives_type),
278
600
  addr=address or self.manager.blockchain_provider.account.address,
@@ -285,14 +607,8 @@ class Paranet(Module):
285
607
  def calculate_claimable_miner_reward_amount(
286
608
  self,
287
609
  ual: UAL,
288
- incentives_type: ParanetIncentivizationType | None = None,
610
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
289
611
  ) -> int:
290
- incentives_type = incentives_type or (
291
- ParanetIncentivizationType.NEUROWEB.value
292
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
293
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
294
- )
295
-
296
612
  return self._get_claimable_knowledge_miner_reward_amount(
297
613
  contract=self._get_incentives_pool_contract(ual, incentives_type)
298
614
  )
@@ -304,14 +620,8 @@ class Paranet(Module):
304
620
  def calculate_all_claimable_miner_rewards_amount(
305
621
  self,
306
622
  ual: UAL,
307
- incentives_type: ParanetIncentivizationType | None = None,
623
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
308
624
  ) -> int:
309
- incentives_type = incentives_type or (
310
- ParanetIncentivizationType.NEUROWEB.value
311
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
312
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
313
- )
314
-
315
625
  return self._get_claimable_all_knowledge_miners_reward_amount(
316
626
  contract=self._get_incentives_pool_contract(ual, incentives_type)
317
627
  )
@@ -323,14 +633,8 @@ class Paranet(Module):
323
633
  def claim_miner_reward(
324
634
  self,
325
635
  ual: UAL,
326
- incentives_type: None,
636
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
327
637
  ) -> dict[str, str | HexStr | TxReceipt]:
328
- incentives_type = incentives_type or (
329
- ParanetIncentivizationType.NEUROWEB.value
330
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
331
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
332
- )
333
-
334
638
  receipt: TxReceipt = self._claim_knowledge_miner_reward(
335
639
  contract=self._get_incentives_pool_contract(ual, incentives_type)
336
640
  )
@@ -359,14 +663,8 @@ class Paranet(Module):
359
663
  def calculate_claimable_operator_reward_amount(
360
664
  self,
361
665
  ual: UAL,
362
- incentives_type: ParanetIncentivizationType | None = None,
666
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
363
667
  ) -> int:
364
- incentives_type = incentives_type or (
365
- ParanetIncentivizationType.NEUROWEB.value
366
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
367
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
368
- )
369
-
370
668
  return self._get_claimable_paranet_operator_reward_amount(
371
669
  contract=self._get_incentives_pool_contract(ual, incentives_type)
372
670
  )
@@ -378,14 +676,8 @@ class Paranet(Module):
378
676
  def claim_operator_reward(
379
677
  self,
380
678
  ual: UAL,
381
- incentives_type: ParanetIncentivizationType | None = None,
679
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
382
680
  ) -> dict[str, str | HexStr | TxReceipt]:
383
- incentives_type = incentives_type or (
384
- ParanetIncentivizationType.NEUROWEB.value
385
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
386
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
387
- )
388
-
389
681
  receipt: TxReceipt = self._claim_paranet_operator_reward(
390
682
  contract=self._get_incentives_pool_contract(ual, incentives_type)
391
683
  )
@@ -414,14 +706,8 @@ class Paranet(Module):
414
706
  def calculate_claimable_voter_reward_amount(
415
707
  self,
416
708
  ual: UAL,
417
- incentives_type: ParanetIncentivizationType | None = None,
709
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
418
710
  ) -> int:
419
- incentives_type = incentives_type or (
420
- ParanetIncentivizationType.NEUROWEB.value
421
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
422
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
423
- )
424
-
425
711
  return self._get_claimable_proposal_voter_reward_amount(
426
712
  contract=self._get_incentives_pool_contract(ual, incentives_type)
427
713
  )
@@ -433,14 +719,8 @@ class Paranet(Module):
433
719
  def calculate_all_claimable_voters_reward_amount(
434
720
  self,
435
721
  ual: UAL,
436
- incentives_type: ParanetIncentivizationType | None = None,
722
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
437
723
  ) -> int:
438
- incentives_type = incentives_type or (
439
- ParanetIncentivizationType.NEUROWEB.value
440
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
441
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
442
- )
443
-
444
724
  return self._get_claimable_all_proposal_voters_reward_amount(
445
725
  contract=self._get_incentives_pool_contract(ual, incentives_type)
446
726
  )
@@ -452,14 +732,8 @@ class Paranet(Module):
452
732
  def claim_voter_reward(
453
733
  self,
454
734
  ual: UAL,
455
- incentives_type: ParanetIncentivizationType | None = None,
735
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
456
736
  ) -> dict[str, str | HexStr | TxReceipt]:
457
- incentives_type = incentives_type or (
458
- ParanetIncentivizationType.NEUROWEB.value
459
- if NEUROWEB_BLOCKCHAIN_PREFIX in ual
460
- else ParanetIncentivizationType.NEUROWEB_ERC20.value
461
- )
462
-
463
737
  receipt: TxReceipt = self._claim_incentivization_proposal_voter_reward(
464
738
  contract=self._get_incentives_pool_contract(ual, incentives_type)
465
739
  )
@@ -484,42 +758,13 @@ class Paranet(Module):
484
758
  _get_updating_knowledge_asset_states = Method(
485
759
  BlockchainRequest.get_updating_knowledge_asset_states
486
760
  )
487
- _process_updated_knowledge_asset_states_metadata = Method(
488
- BlockchainRequest.process_updated_knowledge_asset_states_metadata
489
- )
490
-
491
- def update_claimable_rewards(self, ual: UAL) -> dict[str, str | HexStr | TxReceipt]:
492
- parsed_ual = parse_ual(ual)
493
- knowledge_asset_storage, knowledge_asset_token_id = (
494
- parsed_ual["contract_address"],
495
- parsed_ual["token_id"],
496
- )
497
-
498
- paranet_id = Web3.solidity_keccak(
499
- ["address", "uint256"], [knowledge_asset_storage, knowledge_asset_token_id]
500
- )
501
-
502
- updating_states = self._get_updating_knowledge_asset_states(
503
- self.manager.blockchain_provider.account.address,
504
- paranet_id,
505
- )
506
- receipt: TxReceipt = self._process_updated_knowledge_asset_states_metadata(
507
- knowledge_asset_storage,
508
- knowledge_asset_token_id,
509
- 0,
510
- len(updating_states),
511
- )
512
-
513
- return {
514
- "paranetUAL": ual,
515
- "paranetId": paranet_id,
516
- "operation": json.loads(Web3.to_json(receipt)),
517
- }
518
761
 
519
762
  def _get_incentives_pool_contract(
520
- self, ual: UAL, incentives_type: ParanetIncentivizationType
763
+ self,
764
+ ual: UAL,
765
+ incentives_type: ParanetIncentivizationType = ParanetIncentivizationType.NEUROWEB,
521
766
  ) -> str | dict[str, str]:
522
- incentives_pool_name = INCENTIVE_POOL_NAME
767
+ incentives_pool_name = f"Paranet{str(incentives_type)}IncentivesPool"
523
768
  is_incentives_pool_cached = (
524
769
  incentives_pool_name in self.manager.blockchain_provider.contracts.keys()
525
770
  )