dkg 8.0.0a1__py3-none-any.whl → 8.0.0a3__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 +131 -13
- dkg/constants.py +3 -7
- dkg/data/interfaces/ContentAsset.json +15 -119
- dkg/data/interfaces/ContentAssetStorage.json +0 -76
- dkg/data/interfaces/Hub.json +2 -2
- dkg/data/interfaces/IdentityStorage.json +342 -0
- dkg/data/interfaces/Paranet.json +721 -16
- dkg/data/interfaces/ParanetsRegistry.json +771 -33
- dkg/dataclasses.py +11 -1
- dkg/exceptions.py +1 -0
- dkg/node.py +7 -0
- dkg/paranet.py +336 -2
- dkg/providers/blockchain.py +6 -4
- dkg/types/__init__.py +15 -3
- dkg/types/general.py +15 -8
- dkg/utils/blockchain_request.py +121 -1
- dkg/utils/merkle.py +1 -1
- dkg/utils/node_request.py +2 -1
- dkg/utils/rdf.py +1 -3
- dkg/utils/string_transformations.py +1 -0
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a3.dist-info}/METADATA +8 -7
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a3.dist-info}/RECORD +25 -24
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a3.dist-info}/LICENSE +0 -0
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a3.dist-info}/NOTICE +0 -0
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a3.dist-info}/WHEEL +0 -0
dkg/asset.py
CHANGED
@@ -360,6 +360,135 @@ class KnowledgeAsset(Module):
|
|
360
360
|
}
|
361
361
|
|
362
362
|
return result
|
363
|
+
|
364
|
+
|
365
|
+
def local_store(
|
366
|
+
self,
|
367
|
+
content: dict[Literal["public", "private"], JSONLD],
|
368
|
+
epochs_number: int,
|
369
|
+
token_amount: Wei | None = None,
|
370
|
+
immutable: bool = False,
|
371
|
+
content_type: Literal["JSON-LD", "N-Quads"] = "JSON-LD",
|
372
|
+
paranet_ual: UAL | None = None,
|
373
|
+
) -> dict[str, UAL | HexStr | dict[str, dict[str, str] | TxReceipt]]:
|
374
|
+
blockchain_id = self.manager.blockchain_provider.blockchain_id
|
375
|
+
assertions = format_content(content, content_type)
|
376
|
+
|
377
|
+
public_assertion_id = MerkleTree(
|
378
|
+
hash_assertion_with_indexes(assertions["public"]),
|
379
|
+
sort_pairs=True,
|
380
|
+
).root
|
381
|
+
public_assertion_metadata = generate_assertion_metadata(assertions["public"])
|
382
|
+
|
383
|
+
content_asset_storage_address = self._get_asset_storage_address(
|
384
|
+
"ContentAssetStorage"
|
385
|
+
)
|
386
|
+
|
387
|
+
if token_amount is None:
|
388
|
+
token_amount = int(
|
389
|
+
self._get_bid_suggestion(
|
390
|
+
blockchain_id,
|
391
|
+
epochs_number,
|
392
|
+
public_assertion_metadata["size"],
|
393
|
+
content_asset_storage_address,
|
394
|
+
public_assertion_id,
|
395
|
+
DEFAULT_HASH_FUNCTION_ID,
|
396
|
+
token_amount or BidSuggestionRange.LOW,
|
397
|
+
)["bidSuggestion"]
|
398
|
+
)
|
399
|
+
|
400
|
+
current_allowance = self.get_current_allowance()
|
401
|
+
if is_allowance_increased := current_allowance < token_amount:
|
402
|
+
self.increase_allowance(token_amount)
|
403
|
+
|
404
|
+
result = {"publicAssertionId": public_assertion_id, "operation": {}}
|
405
|
+
|
406
|
+
try:
|
407
|
+
receipt: TxReceipt = self._create(
|
408
|
+
{
|
409
|
+
"assertionId": Web3.to_bytes(hexstr=public_assertion_id),
|
410
|
+
"size": public_assertion_metadata["size"],
|
411
|
+
"triplesNumber": public_assertion_metadata["triples_number"],
|
412
|
+
"chunksNumber": public_assertion_metadata["chunks_number"],
|
413
|
+
"tokenAmount": token_amount,
|
414
|
+
"epochsNumber": epochs_number,
|
415
|
+
"scoreFunctionId": DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[
|
416
|
+
self.manager.blockchain_provider.environment
|
417
|
+
][blockchain_id],
|
418
|
+
"immutable_": immutable,
|
419
|
+
}
|
420
|
+
)
|
421
|
+
except ContractLogicError as err:
|
422
|
+
if is_allowance_increased:
|
423
|
+
self.decrease_allowance(token_amount)
|
424
|
+
raise err
|
425
|
+
|
426
|
+
events = self.manager.blockchain_provider.decode_logs_event(
|
427
|
+
receipt,
|
428
|
+
"ContentAsset",
|
429
|
+
"AssetMinted",
|
430
|
+
)
|
431
|
+
token_id = events[0].args["tokenId"]
|
432
|
+
|
433
|
+
result["UAL"] = format_ual(
|
434
|
+
blockchain_id, content_asset_storage_address, token_id
|
435
|
+
)
|
436
|
+
result["operation"]["mintKnowledgeAsset"] = json.loads(Web3.to_json(receipt))
|
437
|
+
|
438
|
+
assertions_list = [
|
439
|
+
{
|
440
|
+
"blockchain": blockchain_id,
|
441
|
+
"contract": content_asset_storage_address,
|
442
|
+
"tokenId": token_id,
|
443
|
+
"assertionId": public_assertion_id,
|
444
|
+
"assertion": assertions["public"],
|
445
|
+
"storeType": StoreTypes.TRIPLE_PARANET,
|
446
|
+
"paranetUAL": paranet_ual,
|
447
|
+
}
|
448
|
+
]
|
449
|
+
|
450
|
+
if content.get("private", None):
|
451
|
+
assertions_list.append(
|
452
|
+
{
|
453
|
+
"blockchain": blockchain_id,
|
454
|
+
"contract": content_asset_storage_address,
|
455
|
+
"tokenId": token_id,
|
456
|
+
"assertionId": MerkleTree(
|
457
|
+
hash_assertion_with_indexes(assertions["private"]),
|
458
|
+
sort_pairs=True,
|
459
|
+
).root,
|
460
|
+
"assertion": assertions["private"],
|
461
|
+
"storeType": StoreTypes.TRIPLE_PARANET,
|
462
|
+
"paranetUAL": paranet_ual,
|
463
|
+
}
|
464
|
+
)
|
465
|
+
|
466
|
+
operation_id = self._local_store(assertions_list)["operationId"]
|
467
|
+
operation_result = self.get_operation_result(operation_id, "local-store")
|
468
|
+
|
469
|
+
result["operation"]["localStore"] = {
|
470
|
+
"operationId": operation_id,
|
471
|
+
"status": operation_result["status"],
|
472
|
+
}
|
473
|
+
|
474
|
+
if operation_result["status"] == OperationStatus.COMPLETED:
|
475
|
+
parsed_paranet_ual = parse_ual(paranet_ual)
|
476
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
477
|
+
parsed_paranet_ual["contract_address"],
|
478
|
+
parsed_paranet_ual["token_id"],
|
479
|
+
)
|
480
|
+
|
481
|
+
receipt: TxReceipt = self._submit_knowledge_asset(
|
482
|
+
paranet_knowledge_asset_storage,
|
483
|
+
paranet_knowledge_asset_token_id,
|
484
|
+
content_asset_storage_address,
|
485
|
+
token_id,
|
486
|
+
)
|
487
|
+
|
488
|
+
result["operation"]["submitToParanet"] = json.loads(Web3.to_json(receipt))
|
489
|
+
|
490
|
+
return result
|
491
|
+
|
363
492
|
|
364
493
|
_submit_knowledge_asset = Method(BlockchainRequest.submit_knowledge_asset)
|
365
494
|
|
@@ -452,24 +581,13 @@ class KnowledgeAsset(Module):
|
|
452
581
|
|
453
582
|
token_id = parse_ual(ual)["token_id"]
|
454
583
|
|
455
|
-
def handle_latest_state(token_id: int) -> tuple[HexStr, bool]:
|
456
|
-
unfinalized_state = Web3.to_hex(self._get_unfinalized_state(token_id))
|
457
|
-
|
458
|
-
if unfinalized_state and unfinalized_state != HASH_ZERO:
|
459
|
-
return unfinalized_state, False
|
460
|
-
else:
|
461
|
-
return handle_latest_finalized_state(token_id)
|
462
|
-
|
463
584
|
def handle_latest_finalized_state(token_id: int) -> tuple[HexStr, bool]:
|
464
585
|
return Web3.to_hex(self._get_latest_assertion_id(token_id)), True
|
465
586
|
|
466
587
|
is_state_finalized = False
|
467
588
|
|
468
589
|
match state:
|
469
|
-
case KnowledgeAssetEnumStates.LATEST:
|
470
|
-
public_assertion_id, is_state_finalized = handle_latest_state(token_id)
|
471
|
-
|
472
|
-
case KnowledgeAssetEnumStates.LATEST_FINALIZED:
|
590
|
+
case KnowledgeAssetEnumStates.LATEST | KnowledgeAssetEnumStates.LATEST_FINALIZED:
|
473
591
|
public_assertion_id, is_state_finalized = handle_latest_finalized_state(
|
474
592
|
token_id
|
475
593
|
)
|
@@ -701,7 +819,7 @@ class KnowledgeAsset(Module):
|
|
701
819
|
"UAL": ual,
|
702
820
|
"operation": json.loads(Web3.to_json(receipt)),
|
703
821
|
}
|
704
|
-
|
822
|
+
|
705
823
|
_get_block = Method(BlockchainRequest.get_block)
|
706
824
|
|
707
825
|
_get_service_agreement_data = Method(BlockchainRequest.get_service_agreement_data)
|
dkg/constants.py
CHANGED
@@ -21,11 +21,11 @@ PRIVATE_ASSERTION_PREDICATE = (
|
|
21
21
|
|
22
22
|
BLOCKCHAINS = {
|
23
23
|
"development": {
|
24
|
-
"hardhat1:31337":
|
24
|
+
"hardhat1:31337": {
|
25
25
|
"hub": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
26
26
|
"rpc": "http://localhost:8545",
|
27
27
|
},
|
28
|
-
"hardhat2:31337":
|
28
|
+
"hardhat2:31337": {
|
29
29
|
"hub": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
30
30
|
"rpc": "http://localhost:9545",
|
31
31
|
},
|
@@ -47,11 +47,7 @@ BLOCKCHAINS = {
|
|
47
47
|
|
48
48
|
DEFAULT_HASH_FUNCTION_ID = 1
|
49
49
|
DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS = {
|
50
|
-
"development": {
|
51
|
-
"hardhat1:31337": 2,
|
52
|
-
"hardhat2:31337": 2,
|
53
|
-
"otp:2043": 2
|
54
|
-
},
|
50
|
+
"development": {"hardhat1:31337": 2, "hardhat2:31337": 2, "otp:2043": 2},
|
55
51
|
"devnet": {
|
56
52
|
"otp:2160": 2,
|
57
53
|
"gnosis:10200": 2,
|
@@ -352,7 +352,7 @@
|
|
352
352
|
"type": "uint256"
|
353
353
|
}
|
354
354
|
],
|
355
|
-
"name": "
|
355
|
+
"name": "clearOldCommitsMetadata",
|
356
356
|
"outputs": [],
|
357
357
|
"stateMutability": "nonpayable",
|
358
358
|
"type": "function"
|
@@ -421,79 +421,7 @@
|
|
421
421
|
}
|
422
422
|
],
|
423
423
|
"name": "createAsset",
|
424
|
-
"outputs": [
|
425
|
-
{
|
426
|
-
"internalType": "uint256",
|
427
|
-
"name": "",
|
428
|
-
"type": "uint256"
|
429
|
-
}
|
430
|
-
],
|
431
|
-
"stateMutability": "nonpayable",
|
432
|
-
"type": "function"
|
433
|
-
},
|
434
|
-
{
|
435
|
-
"inputs": [
|
436
|
-
{
|
437
|
-
"internalType": "address",
|
438
|
-
"name": "originalSender",
|
439
|
-
"type": "address"
|
440
|
-
},
|
441
|
-
{
|
442
|
-
"components": [
|
443
|
-
{
|
444
|
-
"internalType": "bytes32",
|
445
|
-
"name": "assertionId",
|
446
|
-
"type": "bytes32"
|
447
|
-
},
|
448
|
-
{
|
449
|
-
"internalType": "uint128",
|
450
|
-
"name": "size",
|
451
|
-
"type": "uint128"
|
452
|
-
},
|
453
|
-
{
|
454
|
-
"internalType": "uint32",
|
455
|
-
"name": "triplesNumber",
|
456
|
-
"type": "uint32"
|
457
|
-
},
|
458
|
-
{
|
459
|
-
"internalType": "uint96",
|
460
|
-
"name": "chunksNumber",
|
461
|
-
"type": "uint96"
|
462
|
-
},
|
463
|
-
{
|
464
|
-
"internalType": "uint16",
|
465
|
-
"name": "epochsNumber",
|
466
|
-
"type": "uint16"
|
467
|
-
},
|
468
|
-
{
|
469
|
-
"internalType": "uint96",
|
470
|
-
"name": "tokenAmount",
|
471
|
-
"type": "uint96"
|
472
|
-
},
|
473
|
-
{
|
474
|
-
"internalType": "uint8",
|
475
|
-
"name": "scoreFunctionId",
|
476
|
-
"type": "uint8"
|
477
|
-
},
|
478
|
-
{
|
479
|
-
"internalType": "bool",
|
480
|
-
"name": "immutable_",
|
481
|
-
"type": "bool"
|
482
|
-
}
|
483
|
-
],
|
484
|
-
"internalType": "struct ContentAssetStructs.AssetInputArgs",
|
485
|
-
"name": "args",
|
486
|
-
"type": "tuple"
|
487
|
-
}
|
488
|
-
],
|
489
|
-
"name": "createAssetFromContract",
|
490
|
-
"outputs": [
|
491
|
-
{
|
492
|
-
"internalType": "uint256",
|
493
|
-
"name": "",
|
494
|
-
"type": "uint256"
|
495
|
-
}
|
496
|
-
],
|
424
|
+
"outputs": [],
|
497
425
|
"stateMutability": "nonpayable",
|
498
426
|
"type": "function"
|
499
427
|
},
|
@@ -541,13 +469,7 @@
|
|
541
469
|
}
|
542
470
|
],
|
543
471
|
"name": "createAssetWithVariables",
|
544
|
-
"outputs": [
|
545
|
-
{
|
546
|
-
"internalType": "uint256",
|
547
|
-
"name": "",
|
548
|
-
"type": "uint256"
|
549
|
-
}
|
550
|
-
],
|
472
|
+
"outputs": [],
|
551
473
|
"stateMutability": "nonpayable",
|
552
474
|
"type": "function"
|
553
475
|
},
|
@@ -592,7 +514,7 @@
|
|
592
514
|
"name": "hub",
|
593
515
|
"outputs": [
|
594
516
|
{
|
595
|
-
"internalType": "contract
|
517
|
+
"internalType": "contract Hub",
|
596
518
|
"name": "",
|
597
519
|
"type": "address"
|
598
520
|
}
|
@@ -671,36 +593,10 @@
|
|
671
593
|
},
|
672
594
|
{
|
673
595
|
"inputs": [],
|
674
|
-
"name": "
|
675
|
-
"outputs": [
|
676
|
-
{
|
677
|
-
"internalType": "contract ParanetKnowledgeAssetsRegistry",
|
678
|
-
"name": "",
|
679
|
-
"type": "address"
|
680
|
-
}
|
681
|
-
],
|
682
|
-
"stateMutability": "view",
|
683
|
-
"type": "function"
|
684
|
-
},
|
685
|
-
{
|
686
|
-
"inputs": [],
|
687
|
-
"name": "paranetKnowledgeMinersRegistry",
|
688
|
-
"outputs": [
|
689
|
-
{
|
690
|
-
"internalType": "contract ParanetKnowledgeMinersRegistry",
|
691
|
-
"name": "",
|
692
|
-
"type": "address"
|
693
|
-
}
|
694
|
-
],
|
695
|
-
"stateMutability": "view",
|
696
|
-
"type": "function"
|
697
|
-
},
|
698
|
-
{
|
699
|
-
"inputs": [],
|
700
|
-
"name": "paranetsRegistry",
|
596
|
+
"name": "serviceAgreementStorageProxy",
|
701
597
|
"outputs": [
|
702
598
|
{
|
703
|
-
"internalType": "contract
|
599
|
+
"internalType": "contract ServiceAgreementStorageProxy",
|
704
600
|
"name": "",
|
705
601
|
"type": "address"
|
706
602
|
}
|
@@ -710,10 +606,10 @@
|
|
710
606
|
},
|
711
607
|
{
|
712
608
|
"inputs": [],
|
713
|
-
"name": "
|
609
|
+
"name": "serviceAgreementV1",
|
714
610
|
"outputs": [
|
715
611
|
{
|
716
|
-
"internalType": "contract
|
612
|
+
"internalType": "contract ServiceAgreementV1",
|
717
613
|
"name": "",
|
718
614
|
"type": "address"
|
719
615
|
}
|
@@ -722,16 +618,16 @@
|
|
722
618
|
"type": "function"
|
723
619
|
},
|
724
620
|
{
|
725
|
-
"inputs": [
|
726
|
-
"name": "serviceAgreementV1",
|
727
|
-
"outputs": [
|
621
|
+
"inputs": [
|
728
622
|
{
|
729
|
-
"internalType": "
|
730
|
-
"name": "",
|
731
|
-
"type": "
|
623
|
+
"internalType": "bool",
|
624
|
+
"name": "_flag",
|
625
|
+
"type": "bool"
|
732
626
|
}
|
733
627
|
],
|
734
|
-
"
|
628
|
+
"name": "setOldMetadataClearingFlag",
|
629
|
+
"outputs": [],
|
630
|
+
"stateMutability": "nonpayable",
|
735
631
|
"type": "function"
|
736
632
|
},
|
737
633
|
{
|
@@ -10,11 +10,6 @@
|
|
10
10
|
"stateMutability": "nonpayable",
|
11
11
|
"type": "constructor"
|
12
12
|
},
|
13
|
-
{
|
14
|
-
"inputs": [],
|
15
|
-
"name": "NoMintedAssets",
|
16
|
-
"type": "error"
|
17
|
-
},
|
18
13
|
{
|
19
14
|
"anonymous": false,
|
20
15
|
"inputs": [
|
@@ -65,38 +60,6 @@
|
|
65
60
|
"name": "ApprovalForAll",
|
66
61
|
"type": "event"
|
67
62
|
},
|
68
|
-
{
|
69
|
-
"anonymous": false,
|
70
|
-
"inputs": [
|
71
|
-
{
|
72
|
-
"indexed": false,
|
73
|
-
"internalType": "uint256",
|
74
|
-
"name": "_fromTokenId",
|
75
|
-
"type": "uint256"
|
76
|
-
},
|
77
|
-
{
|
78
|
-
"indexed": false,
|
79
|
-
"internalType": "uint256",
|
80
|
-
"name": "_toTokenId",
|
81
|
-
"type": "uint256"
|
82
|
-
}
|
83
|
-
],
|
84
|
-
"name": "BatchMetadataUpdate",
|
85
|
-
"type": "event"
|
86
|
-
},
|
87
|
-
{
|
88
|
-
"anonymous": false,
|
89
|
-
"inputs": [
|
90
|
-
{
|
91
|
-
"indexed": false,
|
92
|
-
"internalType": "uint256",
|
93
|
-
"name": "_tokenId",
|
94
|
-
"type": "uint256"
|
95
|
-
}
|
96
|
-
],
|
97
|
-
"name": "MetadataUpdate",
|
98
|
-
"type": "event"
|
99
|
-
},
|
100
63
|
{
|
101
64
|
"anonymous": false,
|
102
65
|
"inputs": [
|
@@ -475,19 +438,6 @@
|
|
475
438
|
"stateMutability": "view",
|
476
439
|
"type": "function"
|
477
440
|
},
|
478
|
-
{
|
479
|
-
"inputs": [],
|
480
|
-
"name": "lastTokenId",
|
481
|
-
"outputs": [
|
482
|
-
{
|
483
|
-
"internalType": "uint256",
|
484
|
-
"name": "",
|
485
|
-
"type": "uint256"
|
486
|
-
}
|
487
|
-
],
|
488
|
-
"stateMutability": "view",
|
489
|
-
"type": "function"
|
490
|
-
},
|
491
441
|
{
|
492
442
|
"inputs": [
|
493
443
|
{
|
@@ -648,19 +598,6 @@
|
|
648
598
|
"stateMutability": "nonpayable",
|
649
599
|
"type": "function"
|
650
600
|
},
|
651
|
-
{
|
652
|
-
"inputs": [
|
653
|
-
{
|
654
|
-
"internalType": "string",
|
655
|
-
"name": "baseURI",
|
656
|
-
"type": "string"
|
657
|
-
}
|
658
|
-
],
|
659
|
-
"name": "setBaseURI",
|
660
|
-
"outputs": [],
|
661
|
-
"stateMutability": "nonpayable",
|
662
|
-
"type": "function"
|
663
|
-
},
|
664
601
|
{
|
665
602
|
"inputs": [
|
666
603
|
{
|
@@ -711,19 +648,6 @@
|
|
711
648
|
"stateMutability": "view",
|
712
649
|
"type": "function"
|
713
650
|
},
|
714
|
-
{
|
715
|
-
"inputs": [],
|
716
|
-
"name": "tokenBaseURI",
|
717
|
-
"outputs": [
|
718
|
-
{
|
719
|
-
"internalType": "string",
|
720
|
-
"name": "",
|
721
|
-
"type": "string"
|
722
|
-
}
|
723
|
-
],
|
724
|
-
"stateMutability": "view",
|
725
|
-
"type": "function"
|
726
|
-
},
|
727
651
|
{
|
728
652
|
"inputs": [
|
729
653
|
{
|
dkg/data/interfaces/Hub.json
CHANGED
@@ -111,7 +111,7 @@
|
|
111
111
|
"type": "address"
|
112
112
|
}
|
113
113
|
],
|
114
|
-
"internalType": "struct
|
114
|
+
"internalType": "struct UnorderedNamedContractDynamicSetLib.Contract[]",
|
115
115
|
"name": "",
|
116
116
|
"type": "tuple[]"
|
117
117
|
}
|
@@ -136,7 +136,7 @@
|
|
136
136
|
"type": "address"
|
137
137
|
}
|
138
138
|
],
|
139
|
-
"internalType": "struct
|
139
|
+
"internalType": "struct UnorderedNamedContractDynamicSetLib.Contract[]",
|
140
140
|
"name": "",
|
141
141
|
"type": "tuple[]"
|
142
142
|
}
|