dkg 0.1.0b5__py3-none-any.whl → 1.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.
- dkg/asset.py +182 -70
- dkg/constants.py +39 -6
- dkg/data/interfaces/ContentAsset.json +133 -3
- dkg/data/interfaces/Paranet.json +821 -0
- dkg/data/interfaces/{Identity.json → ParanetIncentivesPoolFactory.json} +67 -86
- dkg/data/interfaces/ParanetKnowledgeMinersRegistry.json +919 -0
- dkg/data/interfaces/ParanetNeurowebIncentivesPool.json +1102 -0
- dkg/data/interfaces/{ServiceAgreementStorageV1.json → ParanetsRegistry.json} +331 -360
- dkg/dataclasses.py +28 -8
- dkg/main.py +6 -3
- dkg/method.py +55 -39
- dkg/module.py +1 -0
- dkg/network.py +20 -10
- dkg/paranet.py +477 -0
- dkg/providers/blockchain.py +83 -60
- dkg/types/__init__.py +1 -0
- dkg/types/general.py +44 -0
- dkg/utils/blockchain_request.py +149 -4
- dkg/utils/node_request.py +77 -80
- {dkg-0.1.0b5.dist-info → dkg-1.0.0.dist-info}/METADATA +6 -144
- dkg-1.0.0.dist-info/NOTICE +9 -0
- dkg-1.0.0.dist-info/RECORD +52 -0
- {dkg-0.1.0b5.dist-info → dkg-1.0.0.dist-info}/WHEEL +1 -1
- dkg/data/interfaces/Assertion.json +0 -157
- dkg/data/interfaces/CommitManagerV1.json +0 -549
- dkg/data/interfaces/CommitManagerV1U1.json +0 -735
- dkg/data/interfaces/HashingProxy.json +0 -253
- dkg/data/interfaces/IdentityStorage.json +0 -342
- dkg/data/interfaces/ParametersStorage.json +0 -487
- dkg/data/interfaces/Profile.json +0 -318
- dkg/data/interfaces/ProfileStorage.json +0 -596
- dkg/data/interfaces/ProofManagerV1.json +0 -540
- dkg/data/interfaces/ProofManagerV1U1.json +0 -561
- dkg/data/interfaces/ScoringProxy.json +0 -268
- dkg/data/interfaces/ServiceAgreementStorageV1U1.json +0 -1097
- dkg/data/interfaces/ServiceAgreementV1.json +0 -745
- dkg/data/interfaces/ShardingTable.json +0 -294
- dkg/data/interfaces/ShardingTableStorage.json +0 -317
- dkg/data/interfaces/Staking.json +0 -482
- dkg/data/interfaces/StakingStorage.json +0 -407
- dkg/data/interfaces/WhitelistStorage.json +0 -124
- dkg-0.1.0b5.dist-info/RECORD +0 -64
- {dkg-0.1.0b5.dist-info → dkg-1.0.0.dist-info}/LICENSE +0 -0
dkg/asset.py
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
+
import json
|
18
19
|
import math
|
19
20
|
import re
|
20
21
|
from typing import Literal, Type
|
@@ -23,17 +24,29 @@ from pyld import jsonld
|
|
23
24
|
from web3 import Web3
|
24
25
|
from web3.constants import ADDRESS_ZERO, HASH_ZERO
|
25
26
|
from web3.exceptions import ContractLogicError
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
from web3.types import TxReceipt
|
28
|
+
|
29
|
+
from dkg.constants import (
|
30
|
+
DEFAULT_HASH_FUNCTION_ID,
|
31
|
+
DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS,
|
32
|
+
PRIVATE_ASSERTION_PREDICATE,
|
33
|
+
PRIVATE_CURRENT_REPOSITORY,
|
34
|
+
PRIVATE_HISTORICAL_REPOSITORY,
|
35
|
+
)
|
36
|
+
from dkg.dataclasses import (
|
37
|
+
BidSuggestionRange,
|
38
|
+
KnowledgeAssetContentVisibility,
|
39
|
+
KnowledgeAssetEnumStates,
|
40
|
+
NodeResponseDict,
|
41
|
+
)
|
42
|
+
from dkg.exceptions import (
|
43
|
+
DatasetOutputFormatNotSupported,
|
44
|
+
InvalidKnowledgeAsset,
|
45
|
+
InvalidStateOption,
|
46
|
+
InvalidTokenAmount,
|
47
|
+
MissingKnowledgeAssetState,
|
48
|
+
OperationNotFinished,
|
49
|
+
)
|
37
50
|
from dkg.manager import DefaultRequestManager
|
38
51
|
from dkg.method import Method
|
39
52
|
from dkg.module import Module
|
@@ -41,15 +54,22 @@ from dkg.types import JSONLD, UAL, Address, AgreementData, HexStr, Wei
|
|
41
54
|
from dkg.utils.blockchain_request import BlockchainRequest
|
42
55
|
from dkg.utils.decorators import retry
|
43
56
|
from dkg.utils.merkle import MerkleTree, hash_assertion_with_indexes
|
44
|
-
from dkg.utils.metadata import (
|
45
|
-
|
46
|
-
|
47
|
-
|
57
|
+
from dkg.utils.metadata import (
|
58
|
+
generate_agreement_id,
|
59
|
+
generate_assertion_metadata,
|
60
|
+
generate_keyword,
|
61
|
+
)
|
62
|
+
from dkg.utils.node_request import (
|
63
|
+
NodeRequest,
|
64
|
+
OperationStatus,
|
65
|
+
StoreTypes,
|
66
|
+
validate_operation_status,
|
67
|
+
)
|
48
68
|
from dkg.utils.rdf import format_content, normalize_dataset
|
49
69
|
from dkg.utils.ual import format_ual, parse_ual
|
50
70
|
|
51
71
|
|
52
|
-
class
|
72
|
+
class KnowledgeAsset(Module):
|
53
73
|
def __init__(self, manager: DefaultRequestManager):
|
54
74
|
self.manager = manager
|
55
75
|
|
@@ -176,6 +196,7 @@ class ContentAsset(Module):
|
|
176
196
|
|
177
197
|
_get_asset_storage_address = Method(BlockchainRequest.get_asset_storage_address)
|
178
198
|
_create = Method(BlockchainRequest.create_asset)
|
199
|
+
_mint_paranet_knowledge_asset = Method(BlockchainRequest.mint_knowledge_asset)
|
179
200
|
|
180
201
|
_get_bid_suggestion = Method(NodeRequest.bid_suggestion)
|
181
202
|
_local_store = Method(NodeRequest.local_store)
|
@@ -188,7 +209,8 @@ class ContentAsset(Module):
|
|
188
209
|
token_amount: Wei | None = None,
|
189
210
|
immutable: bool = False,
|
190
211
|
content_type: Literal["JSON-LD", "N-Quads"] = "JSON-LD",
|
191
|
-
|
212
|
+
paranet_ual: UAL | None = None,
|
213
|
+
) -> dict[str, UAL | HexStr | dict[str, dict[str, str] | TxReceipt]]:
|
192
214
|
blockchain_id = self.manager.blockchain_provider.blockchain_id
|
193
215
|
assertions = format_content(content, content_type)
|
194
216
|
|
@@ -211,6 +233,7 @@ class ContentAsset(Module):
|
|
211
233
|
content_asset_storage_address,
|
212
234
|
public_assertion_id,
|
213
235
|
DEFAULT_HASH_FUNCTION_ID,
|
236
|
+
token_amount or BidSuggestionRange.LOW,
|
214
237
|
)["bidSuggestion"]
|
215
238
|
)
|
216
239
|
|
@@ -218,19 +241,57 @@ class ContentAsset(Module):
|
|
218
241
|
if is_allowance_increased := current_allowance < token_amount:
|
219
242
|
self.increase_allowance(token_amount)
|
220
243
|
|
244
|
+
result = {"publicAssertionId": public_assertion_id, "operation": {}}
|
245
|
+
|
221
246
|
try:
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
247
|
+
if paranet_ual is None:
|
248
|
+
receipt: TxReceipt = self._create(
|
249
|
+
{
|
250
|
+
"assertionId": Web3.to_bytes(hexstr=public_assertion_id),
|
251
|
+
"size": public_assertion_metadata["size"],
|
252
|
+
"triplesNumber": public_assertion_metadata["triples_number"],
|
253
|
+
"chunksNumber": public_assertion_metadata["chunks_number"],
|
254
|
+
"tokenAmount": token_amount,
|
255
|
+
"epochsNumber": epochs_number,
|
256
|
+
"scoreFunctionId": DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[
|
257
|
+
self.manager.blockchain_provider.environment
|
258
|
+
][blockchain_id],
|
259
|
+
"immutable_": immutable,
|
260
|
+
}
|
261
|
+
)
|
262
|
+
else:
|
263
|
+
parsed_paranet_ual = parse_ual(paranet_ual)
|
264
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
265
|
+
parsed_paranet_ual["contract_address"],
|
266
|
+
parsed_paranet_ual["token_id"],
|
267
|
+
)
|
268
|
+
|
269
|
+
receipt: TxReceipt = self._mint_paranet_knowledge_asset(
|
270
|
+
paranet_knowledge_asset_storage,
|
271
|
+
paranet_knowledge_asset_token_id,
|
272
|
+
{
|
273
|
+
"assertionId": Web3.to_bytes(hexstr=public_assertion_id),
|
274
|
+
"size": public_assertion_metadata["size"],
|
275
|
+
"triplesNumber": public_assertion_metadata["triples_number"],
|
276
|
+
"chunksNumber": public_assertion_metadata["chunks_number"],
|
277
|
+
"tokenAmount": token_amount,
|
278
|
+
"epochsNumber": epochs_number,
|
279
|
+
"scoreFunctionId": DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[
|
280
|
+
self.manager.blockchain_provider.environment
|
281
|
+
][blockchain_id],
|
282
|
+
"immutable_": immutable,
|
283
|
+
},
|
284
|
+
)
|
285
|
+
|
286
|
+
result["paranetId"] = Web3.to_hex(
|
287
|
+
Web3.solidity_keccak(
|
288
|
+
["address", "uint256"],
|
289
|
+
[
|
290
|
+
paranet_knowledge_asset_storage,
|
291
|
+
paranet_knowledge_asset_token_id,
|
292
|
+
],
|
293
|
+
)
|
294
|
+
)
|
234
295
|
except ContractLogicError as err:
|
235
296
|
if is_allowance_increased:
|
236
297
|
self.decrease_allowance(token_amount)
|
@@ -243,6 +304,11 @@ class ContentAsset(Module):
|
|
243
304
|
)
|
244
305
|
token_id = events[0].args["tokenId"]
|
245
306
|
|
307
|
+
result["UAL"] = format_ual(
|
308
|
+
blockchain_id, content_asset_storage_address, token_id
|
309
|
+
)
|
310
|
+
result["operation"]["mintKnowledgeAsset"] = json.loads(Web3.to_json(receipt))
|
311
|
+
|
246
312
|
assertions_list = [
|
247
313
|
{
|
248
314
|
"blockchain": blockchain_id,
|
@@ -250,7 +316,7 @@ class ContentAsset(Module):
|
|
250
316
|
"tokenId": token_id,
|
251
317
|
"assertionId": public_assertion_id,
|
252
318
|
"assertion": assertions["public"],
|
253
|
-
"storeType": StoreTypes.TRIPLE
|
319
|
+
"storeType": StoreTypes.TRIPLE,
|
254
320
|
}
|
255
321
|
]
|
256
322
|
|
@@ -265,13 +331,10 @@ class ContentAsset(Module):
|
|
265
331
|
sort_pairs=True,
|
266
332
|
).root,
|
267
333
|
"assertion": assertions["private"],
|
268
|
-
"storeType": StoreTypes.TRIPLE
|
334
|
+
"storeType": StoreTypes.TRIPLE,
|
269
335
|
}
|
270
336
|
)
|
271
337
|
|
272
|
-
operation_id = self._local_store(assertions_list)["operationId"]
|
273
|
-
self.get_operation_result(operation_id, "local-store")
|
274
|
-
|
275
338
|
operation_id = self._publish(
|
276
339
|
public_assertion_id,
|
277
340
|
assertions["public"],
|
@@ -282,13 +345,56 @@ class ContentAsset(Module):
|
|
282
345
|
)["operationId"]
|
283
346
|
operation_result = self.get_operation_result(operation_id, "publish")
|
284
347
|
|
285
|
-
|
286
|
-
"
|
287
|
-
"
|
288
|
-
|
348
|
+
result["operation"]["publish"] = {
|
349
|
+
"operationId": operation_id,
|
350
|
+
"status": operation_result["status"],
|
351
|
+
}
|
352
|
+
|
353
|
+
if operation_result["status"] == OperationStatus.COMPLETED:
|
354
|
+
operation_id = self._local_store(assertions_list)["operationId"]
|
355
|
+
operation_result = self.get_operation_result(operation_id, "local-store")
|
356
|
+
|
357
|
+
result["operation"]["localStore"] = {
|
289
358
|
"operationId": operation_id,
|
290
359
|
"status": operation_result["status"],
|
291
|
-
}
|
360
|
+
}
|
361
|
+
|
362
|
+
return result
|
363
|
+
|
364
|
+
_submit_knowledge_asset = Method(BlockchainRequest.submit_knowledge_asset)
|
365
|
+
|
366
|
+
def submit_to_paranet(
|
367
|
+
self, ual: UAL, paranet_ual: UAL
|
368
|
+
) -> dict[str, UAL | Address | TxReceipt]:
|
369
|
+
parsed_ual = parse_ual(ual)
|
370
|
+
knowledge_asset_storage, knowledge_asset_token_id = (
|
371
|
+
parsed_ual["contract_address"],
|
372
|
+
parsed_ual["token_id"],
|
373
|
+
)
|
374
|
+
|
375
|
+
parsed_paranet_ual = parse_ual(paranet_ual)
|
376
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
377
|
+
parsed_paranet_ual["contract_address"],
|
378
|
+
parsed_paranet_ual["token_id"],
|
379
|
+
)
|
380
|
+
|
381
|
+
receipt: TxReceipt = self._submit_knowledge_asset(
|
382
|
+
paranet_knowledge_asset_storage,
|
383
|
+
paranet_knowledge_asset_token_id,
|
384
|
+
knowledge_asset_storage,
|
385
|
+
knowledge_asset_token_id,
|
386
|
+
)
|
387
|
+
|
388
|
+
return {
|
389
|
+
"UAL": ual,
|
390
|
+
"paranetUAL": paranet_ual,
|
391
|
+
"paranetId": Web3.to_hex(
|
392
|
+
Web3.solidity_keccak(
|
393
|
+
["address", "uint256"],
|
394
|
+
[knowledge_asset_storage, knowledge_asset_token_id],
|
395
|
+
)
|
396
|
+
),
|
397
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
292
398
|
}
|
293
399
|
|
294
400
|
_transfer = Method(BlockchainRequest.transfer_asset)
|
@@ -297,10 +403,10 @@ class ContentAsset(Module):
|
|
297
403
|
self,
|
298
404
|
ual: UAL,
|
299
405
|
new_owner: Address,
|
300
|
-
) -> dict[str, UAL | Address |
|
406
|
+
) -> dict[str, UAL | Address | TxReceipt]:
|
301
407
|
token_id = parse_ual(ual)["token_id"]
|
302
408
|
|
303
|
-
self._transfer(
|
409
|
+
receipt: TxReceipt = self._transfer(
|
304
410
|
self.manager.blockchain_provider.account,
|
305
411
|
new_owner,
|
306
412
|
token_id,
|
@@ -309,7 +415,7 @@ class ContentAsset(Module):
|
|
309
415
|
return {
|
310
416
|
"UAL": ual,
|
311
417
|
"owner": new_owner,
|
312
|
-
"operation":
|
418
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
313
419
|
}
|
314
420
|
|
315
421
|
_update = Method(NodeRequest.update)
|
@@ -325,7 +431,7 @@ class ContentAsset(Module):
|
|
325
431
|
content: dict[Literal["public", "private"], JSONLD],
|
326
432
|
token_amount: Wei | None = None,
|
327
433
|
content_type: Literal["JSON-LD", "N-Quads"] = "JSON-LD",
|
328
|
-
) -> dict[str, HexStr | dict[str, str]]:
|
434
|
+
) -> dict[str, UAL | HexStr | dict[str, str]]:
|
329
435
|
parsed_ual = parse_ual(ual)
|
330
436
|
blockchain_id, content_asset_storage_address, token_id = (
|
331
437
|
parsed_ual["blockchain"],
|
@@ -364,6 +470,7 @@ class ContentAsset(Module):
|
|
364
470
|
content_asset_storage_address,
|
365
471
|
public_assertion_id,
|
366
472
|
DEFAULT_HASH_FUNCTION_ID,
|
473
|
+
token_amount or BidSuggestionRange.LOW,
|
367
474
|
)["bidSuggestion"]
|
368
475
|
)
|
369
476
|
|
@@ -395,7 +502,7 @@ class ContentAsset(Module):
|
|
395
502
|
"tokenId": token_id,
|
396
503
|
"assertionId": public_assertion_id,
|
397
504
|
"assertion": assertions["public"],
|
398
|
-
"storeType": StoreTypes.PENDING
|
505
|
+
"storeType": StoreTypes.PENDING,
|
399
506
|
}
|
400
507
|
]
|
401
508
|
|
@@ -410,7 +517,7 @@ class ContentAsset(Module):
|
|
410
517
|
sort_pairs=True,
|
411
518
|
).root,
|
412
519
|
"assertion": assertions["private"],
|
413
|
-
"storeType": StoreTypes.PENDING
|
520
|
+
"storeType": StoreTypes.PENDING,
|
414
521
|
}
|
415
522
|
)
|
416
523
|
|
@@ -428,7 +535,7 @@ class ContentAsset(Module):
|
|
428
535
|
operation_result = self.get_operation_result(operation_id, "update")
|
429
536
|
|
430
537
|
return {
|
431
|
-
"UAL":
|
538
|
+
"UAL": ual,
|
432
539
|
"publicAssertionId": public_assertion_id,
|
433
540
|
"operation": {
|
434
541
|
"operationId": operation_id,
|
@@ -438,24 +545,24 @@ class ContentAsset(Module):
|
|
438
545
|
|
439
546
|
_cancel_update = Method(BlockchainRequest.cancel_asset_state_update)
|
440
547
|
|
441
|
-
def cancel_update(self, ual: UAL) -> dict[str, UAL |
|
548
|
+
def cancel_update(self, ual: UAL) -> dict[str, UAL | TxReceipt]:
|
442
549
|
token_id = parse_ual(ual)["token_id"]
|
443
550
|
|
444
|
-
self._cancel_update(token_id)
|
551
|
+
receipt: TxReceipt = self._cancel_update(token_id)
|
445
552
|
|
446
553
|
return {
|
447
554
|
"UAL": ual,
|
448
|
-
"operation":
|
555
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
449
556
|
}
|
450
557
|
|
451
558
|
_burn_asset = Method(BlockchainRequest.burn_asset)
|
452
559
|
|
453
|
-
def burn(self, ual: UAL) -> dict[str, UAL |
|
560
|
+
def burn(self, ual: UAL) -> dict[str, UAL | TxReceipt]:
|
454
561
|
token_id = parse_ual(ual)["token_id"]
|
455
562
|
|
456
|
-
self._burn_asset(token_id)
|
563
|
+
receipt: TxReceipt = self._burn_asset(token_id)
|
457
564
|
|
458
|
-
return {"UAL": ual, "operation":
|
565
|
+
return {"UAL": ual, "operation": json.loads(Web3.to_json(receipt))}
|
459
566
|
|
460
567
|
_get_assertion_ids = Method(BlockchainRequest.get_assertion_ids)
|
461
568
|
_get_latest_assertion_id = Method(BlockchainRequest.get_latest_assertion_id)
|
@@ -467,11 +574,11 @@ class ContentAsset(Module):
|
|
467
574
|
def get(
|
468
575
|
self,
|
469
576
|
ual: UAL,
|
470
|
-
state: str | HexStr | int = KnowledgeAssetEnumStates.LATEST
|
471
|
-
content_visibility: str = KnowledgeAssetContentVisibility.ALL
|
577
|
+
state: str | HexStr | int = KnowledgeAssetEnumStates.LATEST,
|
578
|
+
content_visibility: str = KnowledgeAssetContentVisibility.ALL,
|
472
579
|
output_format: Literal["JSON-LD", "N-Quads"] = "JSON-LD",
|
473
580
|
validate: bool = True,
|
474
|
-
) -> dict[str, HexStr | list[JSONLD] | dict[str, str]]:
|
581
|
+
) -> dict[str, UAL | HexStr | list[JSONLD] | dict[str, str]]:
|
475
582
|
state = (
|
476
583
|
state.upper()
|
477
584
|
if (isinstance(state, str) and not re.match(r"^0x[a-fA-F0-9]{64}$", state))
|
@@ -496,10 +603,10 @@ class ContentAsset(Module):
|
|
496
603
|
is_state_finalized = False
|
497
604
|
|
498
605
|
match state:
|
499
|
-
case KnowledgeAssetEnumStates.LATEST
|
606
|
+
case KnowledgeAssetEnumStates.LATEST:
|
500
607
|
public_assertion_id, is_state_finalized = handle_latest_state(token_id)
|
501
608
|
|
502
|
-
case KnowledgeAssetEnumStates.LATEST_FINALIZED
|
609
|
+
case KnowledgeAssetEnumStates.LATEST_FINALIZED:
|
503
610
|
public_assertion_id, is_state_finalized = handle_latest_finalized_state(
|
504
611
|
token_id
|
505
612
|
)
|
@@ -560,7 +667,7 @@ class ContentAsset(Module):
|
|
560
667
|
)
|
561
668
|
|
562
669
|
result = {"operation": {}}
|
563
|
-
if content_visibility != KnowledgeAssetContentVisibility.PRIVATE
|
670
|
+
if content_visibility != KnowledgeAssetContentVisibility.PRIVATE:
|
564
671
|
formatted_public_assertion = public_assertion
|
565
672
|
|
566
673
|
match output_format:
|
@@ -577,7 +684,7 @@ class ContentAsset(Module):
|
|
577
684
|
f"{output_format} isn't supported!"
|
578
685
|
)
|
579
686
|
|
580
|
-
if content_visibility == KnowledgeAssetContentVisibility.PUBLIC
|
687
|
+
if content_visibility == KnowledgeAssetContentVisibility.PUBLIC:
|
581
688
|
result = {
|
582
689
|
**result,
|
583
690
|
"asertion": formatted_public_assertion,
|
@@ -594,7 +701,7 @@ class ContentAsset(Module):
|
|
594
701
|
"status": get_public_operation_result["status"],
|
595
702
|
}
|
596
703
|
|
597
|
-
if content_visibility != KnowledgeAssetContentVisibility.PUBLIC
|
704
|
+
if content_visibility != KnowledgeAssetContentVisibility.PUBLIC:
|
598
705
|
private_assertion_link_triples = list(
|
599
706
|
filter(
|
600
707
|
lambda element: PRIVATE_ASSERTION_PREDICATE in element,
|
@@ -670,7 +777,7 @@ class ContentAsset(Module):
|
|
670
777
|
f"{output_format} isn't supported!"
|
671
778
|
)
|
672
779
|
|
673
|
-
if content_visibility == KnowledgeAssetContentVisibility
|
780
|
+
if content_visibility == KnowledgeAssetContentVisibility:
|
674
781
|
result = {
|
675
782
|
**result,
|
676
783
|
"assertion": formatted_private_assertion,
|
@@ -697,7 +804,7 @@ class ContentAsset(Module):
|
|
697
804
|
ual: UAL,
|
698
805
|
additional_epochs: int,
|
699
806
|
token_amount: Wei | None = None,
|
700
|
-
) -> dict[str, UAL |
|
807
|
+
) -> dict[str, UAL | TxReceipt]:
|
701
808
|
parsed_ual = parse_ual(ual)
|
702
809
|
blockchain_id, content_asset_storage_address, token_id = (
|
703
810
|
parsed_ual["blockchain"],
|
@@ -719,14 +826,17 @@ class ContentAsset(Module):
|
|
719
826
|
content_asset_storage_address,
|
720
827
|
latest_finalized_state,
|
721
828
|
DEFAULT_HASH_FUNCTION_ID,
|
829
|
+
token_amount or BidSuggestionRange.LOW,
|
722
830
|
)["bidSuggestion"]
|
723
831
|
)
|
724
832
|
|
725
|
-
self._extend_storing_period(
|
833
|
+
receipt: TxReceipt = self._extend_storing_period(
|
834
|
+
token_id, additional_epochs, token_amount
|
835
|
+
)
|
726
836
|
|
727
837
|
return {
|
728
838
|
"UAL": ual,
|
729
|
-
"operation":
|
839
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
730
840
|
}
|
731
841
|
|
732
842
|
_get_assertion_size = Method(BlockchainRequest.get_assertion_size)
|
@@ -736,7 +846,7 @@ class ContentAsset(Module):
|
|
736
846
|
self,
|
737
847
|
ual: UAL,
|
738
848
|
token_amount: Wei | None = None,
|
739
|
-
) -> dict[str, UAL |
|
849
|
+
) -> dict[str, UAL | TxReceipt]:
|
740
850
|
parsed_ual = parse_ual(ual)
|
741
851
|
blockchain_id, content_asset_storage_address, token_id = (
|
742
852
|
parsed_ual["blockchain"],
|
@@ -772,6 +882,7 @@ class ContentAsset(Module):
|
|
772
882
|
content_asset_storage_address,
|
773
883
|
latest_finalized_state,
|
774
884
|
DEFAULT_HASH_FUNCTION_ID,
|
885
|
+
token_amount or BidSuggestionRange.LOW,
|
775
886
|
)["bidSuggestion"]
|
776
887
|
) - sum(agreement_data.tokensInfo)
|
777
888
|
|
@@ -782,11 +893,11 @@ class ContentAsset(Module):
|
|
782
893
|
"more tokens!"
|
783
894
|
)
|
784
895
|
|
785
|
-
self._add_tokens(token_id, token_amount)
|
896
|
+
receipt: TxReceipt = self._add_tokens(token_id, token_amount)
|
786
897
|
|
787
898
|
return {
|
788
899
|
"UAL": ual,
|
789
|
-
"operation":
|
900
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
790
901
|
}
|
791
902
|
|
792
903
|
_add_update_tokens = Method(BlockchainRequest.increase_asset_update_token_amount)
|
@@ -795,7 +906,7 @@ class ContentAsset(Module):
|
|
795
906
|
self,
|
796
907
|
ual: UAL,
|
797
908
|
token_amount: Wei | None = None,
|
798
|
-
) -> dict[str, UAL |
|
909
|
+
) -> dict[str, UAL | TxReceipt]:
|
799
910
|
parsed_ual = parse_ual(ual)
|
800
911
|
blockchain_id, content_asset_storage_address, token_id = (
|
801
912
|
parsed_ual["blockchain"],
|
@@ -829,6 +940,7 @@ class ContentAsset(Module):
|
|
829
940
|
content_asset_storage_address,
|
830
941
|
unfinalized_state,
|
831
942
|
DEFAULT_HASH_FUNCTION_ID,
|
943
|
+
token_amount or BidSuggestionRange.LOW,
|
832
944
|
)["bidSuggestion"]
|
833
945
|
) - sum(agreement_data.tokensInfo)
|
834
946
|
|
@@ -839,11 +951,11 @@ class ContentAsset(Module):
|
|
839
951
|
"more update tokens!"
|
840
952
|
)
|
841
953
|
|
842
|
-
self._add_update_tokens(token_id, token_amount)
|
954
|
+
receipt: TxReceipt = self._add_update_tokens(token_id, token_amount)
|
843
955
|
|
844
956
|
return {
|
845
957
|
"UAL": ual,
|
846
|
-
"operation":
|
958
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
847
959
|
}
|
848
960
|
|
849
961
|
def get_owner(self, ual: UAL) -> Address:
|
dkg/constants.py
CHANGED
@@ -29,10 +29,6 @@ BLOCKCHAINS = {
|
|
29
29
|
"hub": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
30
30
|
"rpc": "http://localhost:9545",
|
31
31
|
},
|
32
|
-
"otp:2043": {
|
33
|
-
"hub": "0x7585a99C5C150a08f5CDeFD16465C6De8D41EbbD",
|
34
|
-
"rpc": "http://parachain-alphanet-02.origin-trail.network:9933",
|
35
|
-
},
|
36
32
|
},
|
37
33
|
"devnet": {
|
38
34
|
"otp:2160": {
|
@@ -44,6 +40,10 @@ BLOCKCHAINS = {
|
|
44
40
|
"rpc": "https://rpc.chiadochain.net",
|
45
41
|
"gas_price_oracle": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle",
|
46
42
|
},
|
43
|
+
"base:84532": {
|
44
|
+
"hub": "0x6C861Cb69300C34DfeF674F7C00E734e840C29C0",
|
45
|
+
"rpc": "https://sepolia.base.org",
|
46
|
+
}
|
47
47
|
},
|
48
48
|
"testnet": {
|
49
49
|
"otp:20430": {
|
@@ -55,19 +55,52 @@ BLOCKCHAINS = {
|
|
55
55
|
"rpc": "https://rpc.chiadochain.net",
|
56
56
|
"gas_price_oracle": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle",
|
57
57
|
},
|
58
|
+
"base:84532": {
|
59
|
+
"hub": "0x144eDa5cbf8926327cb2cceef168A121F0E4A299",
|
60
|
+
"rpc": "https://sepolia.base.org",
|
61
|
+
}
|
58
62
|
},
|
59
63
|
"mainnet": {
|
60
64
|
"otp:2043": {
|
61
65
|
"hub": "0x5fA7916c48Fe6D5F1738d12Ad234b78c90B4cAdA",
|
62
66
|
"rpc": "https://astrosat-parachain-rpc.origin-trail.network",
|
63
67
|
},
|
68
|
+
"gnosis:100": {
|
69
|
+
"hub": "0xbEF14fc04F870c2dD65c13Df4faB6ba01A9c746b",
|
70
|
+
"rpc": "https://rpc.gnosischain.com/",
|
71
|
+
"gas_price_oracle": [
|
72
|
+
"https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice",
|
73
|
+
"https://blockscout.com/xdai/mainnet/api/v1/gas-price-oracle",
|
74
|
+
],
|
75
|
+
}
|
64
76
|
},
|
65
77
|
}
|
66
78
|
|
67
|
-
DEFAULT_GAS_PRICE_GWEI =
|
79
|
+
DEFAULT_GAS_PRICE_GWEI = {
|
80
|
+
"gnosis": 20,
|
81
|
+
"otp": 1,
|
82
|
+
}
|
68
83
|
|
69
84
|
DEFAULT_HASH_FUNCTION_ID = 1
|
70
|
-
|
85
|
+
DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS = {
|
86
|
+
"development": {
|
87
|
+
"hardhat1:31337": 2,
|
88
|
+
"hardhat2:31337": 2,
|
89
|
+
"otp:2043": 2
|
90
|
+
},
|
91
|
+
"devnet": {
|
92
|
+
"otp:2160": 2,
|
93
|
+
"gnosis:10200": 2,
|
94
|
+
},
|
95
|
+
"testnet": {
|
96
|
+
"otp:20430": 2,
|
97
|
+
"gnosis:10200": 2,
|
98
|
+
},
|
99
|
+
"mainnet": {
|
100
|
+
"otp:2043": 2,
|
101
|
+
"gnosis:100": 2,
|
102
|
+
},
|
103
|
+
}
|
71
104
|
|
72
105
|
PRIVATE_HISTORICAL_REPOSITORY = "privateHistory"
|
73
106
|
PRIVATE_CURRENT_REPOSITORY = "privateCurrent"
|