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.
- dkg/asset.py +589 -683
- dkg/constants.py +102 -40
- dkg/data/interfaces/AskStorage.json +366 -0
- dkg/data/interfaces/Chronos.json +202 -0
- dkg/data/interfaces/Hub.json +294 -2
- dkg/data/interfaces/IdentityStorage.json +400 -0
- dkg/data/interfaces/KnowledgeCollection.json +610 -0
- dkg/data/interfaces/KnowledgeCollectionStorage.json +2312 -0
- dkg/data/interfaces/Paranet.json +656 -135
- dkg/data/interfaces/ParanetIncentivesPoolFactory.json +18 -7
- dkg/data/interfaces/ParanetKnowledgeMinersRegistry.json +20 -4
- dkg/data/interfaces/{ParanetNeurowebIncentivesPool.json → ParanetNeuroIncentivesPool.json} +27 -58
- dkg/data/interfaces/ParanetsRegistry.json +844 -36
- dkg/data/interfaces/Token.json +146 -17
- dkg/dataclasses.py +13 -4
- dkg/exceptions.py +1 -0
- dkg/graph.py +55 -24
- dkg/main.py +18 -2
- dkg/network.py +2 -2
- dkg/node.py +7 -0
- dkg/paranet.py +356 -111
- dkg/providers/blockchain.py +23 -24
- dkg/providers/node_http.py +6 -13
- dkg/services/input_service.py +183 -0
- dkg/services/node_service.py +164 -0
- dkg/types/__init__.py +15 -3
- dkg/types/general.py +15 -8
- dkg/utils/blockchain_request.py +188 -64
- dkg/utils/knowledge_asset_tools.py +5 -0
- dkg/utils/knowledge_collection_tools.py +236 -0
- dkg/utils/merkle.py +1 -1
- dkg/utils/node_request.py +33 -33
- dkg/utils/rdf.py +10 -6
- dkg/utils/string_transformations.py +1 -0
- {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/METADATA +36 -26
- dkg-8.0.0.dist-info/RECORD +56 -0
- {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/WHEEL +1 -1
- dkg/data/interfaces/AssertionStorage.json +0 -229
- dkg/data/interfaces/ContentAsset.json +0 -801
- dkg/data/interfaces/ContentAssetStorage.json +0 -782
- dkg/data/interfaces/ServiceAgreementStorageProxy.json +0 -1314
- dkg/data/interfaces/UnfinalizedStateStorage.json +0 -171
- dkg-1.1.2.dist-info/RECORD +0 -52
- {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/LICENSE +0 -0
- {dkg-1.1.2.dist-info → dkg-8.0.0.dist-info}/NOTICE +0 -0
dkg/data/interfaces/Token.json
CHANGED
@@ -15,6 +15,135 @@
|
|
15
15
|
"stateMutability": "nonpayable",
|
16
16
|
"type": "constructor"
|
17
17
|
},
|
18
|
+
{
|
19
|
+
"inputs": [],
|
20
|
+
"name": "AccessControlBadConfirmation",
|
21
|
+
"type": "error"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"inputs": [
|
25
|
+
{
|
26
|
+
"internalType": "address",
|
27
|
+
"name": "account",
|
28
|
+
"type": "address"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"internalType": "bytes32",
|
32
|
+
"name": "neededRole",
|
33
|
+
"type": "bytes32"
|
34
|
+
}
|
35
|
+
],
|
36
|
+
"name": "AccessControlUnauthorizedAccount",
|
37
|
+
"type": "error"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"inputs": [
|
41
|
+
{
|
42
|
+
"internalType": "address",
|
43
|
+
"name": "spender",
|
44
|
+
"type": "address"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"internalType": "uint256",
|
48
|
+
"name": "allowance",
|
49
|
+
"type": "uint256"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"internalType": "uint256",
|
53
|
+
"name": "needed",
|
54
|
+
"type": "uint256"
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"name": "ERC20InsufficientAllowance",
|
58
|
+
"type": "error"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"inputs": [
|
62
|
+
{
|
63
|
+
"internalType": "address",
|
64
|
+
"name": "sender",
|
65
|
+
"type": "address"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"internalType": "uint256",
|
69
|
+
"name": "balance",
|
70
|
+
"type": "uint256"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"internalType": "uint256",
|
74
|
+
"name": "needed",
|
75
|
+
"type": "uint256"
|
76
|
+
}
|
77
|
+
],
|
78
|
+
"name": "ERC20InsufficientBalance",
|
79
|
+
"type": "error"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"inputs": [
|
83
|
+
{
|
84
|
+
"internalType": "address",
|
85
|
+
"name": "approver",
|
86
|
+
"type": "address"
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"name": "ERC20InvalidApprover",
|
90
|
+
"type": "error"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"inputs": [
|
94
|
+
{
|
95
|
+
"internalType": "address",
|
96
|
+
"name": "receiver",
|
97
|
+
"type": "address"
|
98
|
+
}
|
99
|
+
],
|
100
|
+
"name": "ERC20InvalidReceiver",
|
101
|
+
"type": "error"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"inputs": [
|
105
|
+
{
|
106
|
+
"internalType": "address",
|
107
|
+
"name": "sender",
|
108
|
+
"type": "address"
|
109
|
+
}
|
110
|
+
],
|
111
|
+
"name": "ERC20InvalidSender",
|
112
|
+
"type": "error"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"inputs": [
|
116
|
+
{
|
117
|
+
"internalType": "address",
|
118
|
+
"name": "spender",
|
119
|
+
"type": "address"
|
120
|
+
}
|
121
|
+
],
|
122
|
+
"name": "ERC20InvalidSpender",
|
123
|
+
"type": "error"
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"inputs": [
|
127
|
+
{
|
128
|
+
"internalType": "address",
|
129
|
+
"name": "owner",
|
130
|
+
"type": "address"
|
131
|
+
}
|
132
|
+
],
|
133
|
+
"name": "OwnableInvalidOwner",
|
134
|
+
"type": "error"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"inputs": [
|
138
|
+
{
|
139
|
+
"internalType": "address",
|
140
|
+
"name": "account",
|
141
|
+
"type": "address"
|
142
|
+
}
|
143
|
+
],
|
144
|
+
"name": "OwnableUnauthorizedAccount",
|
145
|
+
"type": "error"
|
146
|
+
},
|
18
147
|
{
|
19
148
|
"anonymous": false,
|
20
149
|
"inputs": [
|
@@ -218,7 +347,7 @@
|
|
218
347
|
},
|
219
348
|
{
|
220
349
|
"internalType": "uint256",
|
221
|
-
"name": "
|
350
|
+
"name": "value",
|
222
351
|
"type": "uint256"
|
223
352
|
}
|
224
353
|
],
|
@@ -326,6 +455,19 @@
|
|
326
455
|
"stateMutability": "nonpayable",
|
327
456
|
"type": "function"
|
328
457
|
},
|
458
|
+
{
|
459
|
+
"inputs": [
|
460
|
+
{
|
461
|
+
"internalType": "address",
|
462
|
+
"name": "minter",
|
463
|
+
"type": "address"
|
464
|
+
}
|
465
|
+
],
|
466
|
+
"name": "grantRole",
|
467
|
+
"outputs": [],
|
468
|
+
"stateMutability": "nonpayable",
|
469
|
+
"type": "function"
|
470
|
+
},
|
329
471
|
{
|
330
472
|
"inputs": [
|
331
473
|
{
|
@@ -434,7 +576,7 @@
|
|
434
576
|
},
|
435
577
|
{
|
436
578
|
"internalType": "address",
|
437
|
-
"name": "
|
579
|
+
"name": "callerConfirmation",
|
438
580
|
"type": "address"
|
439
581
|
}
|
440
582
|
],
|
@@ -461,19 +603,6 @@
|
|
461
603
|
"stateMutability": "nonpayable",
|
462
604
|
"type": "function"
|
463
605
|
},
|
464
|
-
{
|
465
|
-
"inputs": [
|
466
|
-
{
|
467
|
-
"internalType": "address",
|
468
|
-
"name": "minter",
|
469
|
-
"type": "address"
|
470
|
-
}
|
471
|
-
],
|
472
|
-
"name": "setupRole",
|
473
|
-
"outputs": [],
|
474
|
-
"stateMutability": "nonpayable",
|
475
|
-
"type": "function"
|
476
|
-
},
|
477
606
|
{
|
478
607
|
"inputs": [
|
479
608
|
{
|
@@ -528,7 +657,7 @@
|
|
528
657
|
},
|
529
658
|
{
|
530
659
|
"internalType": "uint256",
|
531
|
-
"name": "
|
660
|
+
"name": "value",
|
532
661
|
"type": "uint256"
|
533
662
|
}
|
534
663
|
],
|
@@ -557,7 +686,7 @@
|
|
557
686
|
},
|
558
687
|
{
|
559
688
|
"internalType": "uint256",
|
560
|
-
"name": "
|
689
|
+
"name": "value",
|
561
690
|
"type": "uint256"
|
562
691
|
}
|
563
692
|
],
|
dkg/dataclasses.py
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
# under the License.
|
17
17
|
|
18
18
|
from dataclasses import dataclass
|
19
|
-
from enum import auto, Enum
|
19
|
+
from enum import auto, Enum, IntEnum
|
20
20
|
|
21
21
|
import pandas as pd
|
22
22
|
|
@@ -55,9 +55,18 @@ class KnowledgeAssetContentVisibility(AutoStrEnumUpperCase):
|
|
55
55
|
PRIVATE = auto()
|
56
56
|
|
57
57
|
|
58
|
-
class ParanetIncentivizationType(
|
59
|
-
NEUROWEB =
|
60
|
-
|
58
|
+
class ParanetIncentivizationType(AutoStrEnumCapitalize):
|
59
|
+
NEUROWEB = auto()
|
60
|
+
|
61
|
+
|
62
|
+
class ParanetNodesAccessPolicy(IntEnum):
|
63
|
+
OPEN = 0
|
64
|
+
CURATED = 1
|
65
|
+
|
66
|
+
|
67
|
+
class ParanetMinersAccessPolicy(IntEnum):
|
68
|
+
OPEN = 0
|
69
|
+
CURATED = 1
|
61
70
|
|
62
71
|
|
63
72
|
@dataclass
|
dkg/exceptions.py
CHANGED
dkg/graph.py
CHANGED
@@ -17,47 +17,78 @@
|
|
17
17
|
|
18
18
|
from rdflib.plugins.sparql.parser import parseQuery
|
19
19
|
|
20
|
-
|
21
|
-
from dkg.exceptions import OperationNotFinished
|
20
|
+
|
22
21
|
from dkg.manager import DefaultRequestManager
|
23
|
-
from dkg.method import Method
|
24
22
|
from dkg.module import Module
|
25
23
|
from dkg.types import NQuads
|
26
|
-
from dkg.
|
27
|
-
from dkg.
|
24
|
+
from dkg.services.node_service import NodeService
|
25
|
+
from dkg.services.input_service import InputService
|
26
|
+
from dkg.constants import Operations, Status
|
28
27
|
|
29
28
|
|
30
29
|
class Graph(Module):
|
31
|
-
def __init__(
|
30
|
+
def __init__(
|
31
|
+
self,
|
32
|
+
manager: DefaultRequestManager,
|
33
|
+
input_service: InputService,
|
34
|
+
node_service: NodeService,
|
35
|
+
):
|
32
36
|
self.manager = manager
|
33
|
-
|
34
|
-
|
35
|
-
_get_operation_result = Method(NodeRequest.get_operation_result)
|
37
|
+
self.input_service = input_service
|
38
|
+
self.node_service = node_service
|
36
39
|
|
37
40
|
def query(
|
38
41
|
self,
|
39
42
|
query: str,
|
40
|
-
|
43
|
+
options: dict = {},
|
41
44
|
) -> NQuads:
|
45
|
+
arguments = self.input_service.get_query_arguments(options)
|
46
|
+
|
47
|
+
max_number_of_retries = arguments.get("max_number_of_retries")
|
48
|
+
frequency = arguments.get("frequency")
|
49
|
+
paranet_ual = arguments.get("paranet_ual")
|
50
|
+
repository = arguments.get("repository")
|
51
|
+
|
42
52
|
parsed_query = parseQuery(query)
|
43
53
|
query_type = parsed_query[1].name.replace("Query", "").upper()
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
55
|
+
result = self.node_service.query(query, query_type, repository, paranet_ual)
|
56
|
+
operation_id = result.get("operationId")
|
57
|
+
operation_result = self.node_service.get_operation_result(
|
58
|
+
operation_id, Operations.QUERY.value, max_number_of_retries, frequency
|
59
|
+
)
|
49
60
|
|
50
61
|
return operation_result["data"]
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
) -> NodeResponseDict:
|
56
|
-
operation_result = self._get_operation_result(
|
57
|
-
operation_id=operation_id,
|
58
|
-
operation=operation,
|
59
|
-
)
|
63
|
+
def publish_finality(self, UAL, options=None):
|
64
|
+
if options is None:
|
65
|
+
options = {}
|
60
66
|
|
61
|
-
|
67
|
+
arguments = self.input_service.get_publish_finality_arguments(options)
|
68
|
+
max_number_of_retries = arguments.get("max_number_of_retries")
|
69
|
+
minimum_number_of_finalization_confirmations = arguments.get(
|
70
|
+
"minimum_number_of_finalization_confirmations"
|
71
|
+
)
|
72
|
+
frequency = arguments.get("frequency")
|
73
|
+
try:
|
74
|
+
finality_status_result = self.node_service.finality_status(
|
75
|
+
UAL,
|
76
|
+
minimum_number_of_finalization_confirmations,
|
77
|
+
max_number_of_retries,
|
78
|
+
frequency,
|
79
|
+
)
|
80
|
+
except Exception as e:
|
81
|
+
return {"status": Status.ERROR.value, "error": str(e)}
|
62
82
|
|
63
|
-
|
83
|
+
if finality_status_result >= minimum_number_of_finalization_confirmations:
|
84
|
+
return {
|
85
|
+
"status": Status.FINALIZED.value,
|
86
|
+
"numberOfConfirmations": finality_status_result,
|
87
|
+
"requiredConfirmations": minimum_number_of_finalization_confirmations,
|
88
|
+
}
|
89
|
+
else:
|
90
|
+
return {
|
91
|
+
"status": Status.NOT_FINALIZED.value,
|
92
|
+
"numberOfConfirmations": finality_status_result,
|
93
|
+
"requiredConfirmations": minimum_number_of_finalization_confirmations,
|
94
|
+
}
|
dkg/main.py
CHANGED
@@ -28,6 +28,8 @@ from dkg.paranet import Paranet
|
|
28
28
|
from dkg.providers import BlockchainProvider, NodeHTTPProvider
|
29
29
|
from dkg.types import UAL, Address, ChecksumAddress
|
30
30
|
from dkg.utils.ual import format_ual, parse_ual
|
31
|
+
from dkg.services.input_service import InputService
|
32
|
+
from dkg.services.node_service import NodeService
|
31
33
|
|
32
34
|
|
33
35
|
class DKG(Module):
|
@@ -54,18 +56,32 @@ class DKG(Module):
|
|
54
56
|
self,
|
55
57
|
node_provider: NodeHTTPProvider,
|
56
58
|
blockchain_provider: BlockchainProvider,
|
59
|
+
config: dict = {},
|
57
60
|
):
|
58
61
|
self.manager = DefaultRequestManager(node_provider, blockchain_provider)
|
62
|
+
|
63
|
+
self.initialize_services(self.manager, config)
|
64
|
+
|
59
65
|
modules = {
|
60
66
|
"assertion": Assertion(self.manager),
|
61
|
-
"asset": KnowledgeAsset(
|
67
|
+
"asset": KnowledgeAsset(
|
68
|
+
self.manager, self.input_service, self.node_service
|
69
|
+
),
|
62
70
|
"paranet": Paranet(self.manager),
|
63
71
|
"network": Network(self.manager),
|
64
72
|
"node": Node(self.manager),
|
65
|
-
"graph": Graph(self.manager),
|
73
|
+
"graph": Graph(self.manager, self.input_service, self.node_service),
|
66
74
|
}
|
67
75
|
self._attach_modules(modules)
|
68
76
|
|
77
|
+
# Backwards compatibility
|
78
|
+
self.graph.get = self.asset.get.__get__(self.asset)
|
79
|
+
self.graph.create = self.asset.create.__get__(self.asset)
|
80
|
+
|
81
|
+
def initialize_services(self, manager, config):
|
82
|
+
self.input_service = InputService(manager, config)
|
83
|
+
self.node_service = NodeService(manager)
|
84
|
+
|
69
85
|
@property
|
70
86
|
def node_provider(self) -> NodeHTTPProvider:
|
71
87
|
return self.manager.node_provider
|
dkg/network.py
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
-
from dkg.constants import
|
18
|
+
from dkg.constants import DefaultParameters
|
19
19
|
from dkg.dataclasses import BidSuggestionRange
|
20
20
|
from dkg.manager import DefaultRequestManager
|
21
21
|
from dkg.method import Method
|
@@ -50,7 +50,7 @@ class Network(Module):
|
|
50
50
|
size_in_bytes,
|
51
51
|
content_asset_storage_address,
|
52
52
|
public_assertion_id,
|
53
|
-
|
53
|
+
DefaultParameters.HASH_FUNCTION_ID.value,
|
54
54
|
range,
|
55
55
|
)
|
56
56
|
|
dkg/node.py
CHANGED
@@ -20,6 +20,8 @@ from dkg.manager import DefaultRequestManager
|
|
20
20
|
from dkg.method import Method
|
21
21
|
from dkg.module import Module
|
22
22
|
from dkg.utils.node_request import NodeRequest
|
23
|
+
from dkg.utils.blockchain_request import BlockchainRequest
|
24
|
+
from dkg.types import Address
|
23
25
|
|
24
26
|
|
25
27
|
class Node(Module):
|
@@ -31,3 +33,8 @@ class Node(Module):
|
|
31
33
|
@property
|
32
34
|
def info(self) -> NodeResponseDict:
|
33
35
|
return self._info()
|
36
|
+
|
37
|
+
_get_identity_id = Method(BlockchainRequest.get_identity_id)
|
38
|
+
|
39
|
+
def get_identity_id(self, operational: Address) -> int:
|
40
|
+
return self._get_identity_id(operational)
|