dkg 8.0.3__py3-none-any.whl → 8.0.12__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/constants.py +12 -21
- dkg/modules/asset/asset.py +1 -0
- dkg/modules/asset/async_asset.py +1 -0
- dkg/modules/graph/async_graph.py +1 -0
- dkg/modules/graph/graph.py +1 -0
- dkg/providers/blockchain/async_blockchain.py +2 -3
- dkg/providers/blockchain/base_blockchain.py +16 -17
- dkg/providers/blockchain/blockchain.py +2 -3
- dkg/types/blockchain.py +1 -1
- dkg/utils/knowledge_collection_tools.py +22 -2
- {dkg-8.0.3.dist-info → dkg-8.0.12.dist-info}/METADATA +2 -2
- {dkg-8.0.3.dist-info → dkg-8.0.12.dist-info}/RECORD +15 -15
- {dkg-8.0.3.dist-info → dkg-8.0.12.dist-info}/WHEEL +1 -1
- {dkg-8.0.3.dist-info → dkg-8.0.12.dist-info}/LICENSE +0 -0
- {dkg-8.0.3.dist-info → dkg-8.0.12.dist-info}/NOTICE +0 -0
dkg/constants.py
CHANGED
@@ -35,6 +35,18 @@ CHUNK_BYTE_SIZE = 32
|
|
35
35
|
|
36
36
|
MAX_FILE_SIZE = 10000000
|
37
37
|
|
38
|
+
ESCAPE_MAP = {
|
39
|
+
"\a": r"\a",
|
40
|
+
"\b": r"\b",
|
41
|
+
"\f": r"\f",
|
42
|
+
"\n": r"\n",
|
43
|
+
"\r": r"\r",
|
44
|
+
"\t": r"\t",
|
45
|
+
"\v": r"\v",
|
46
|
+
'"': r"\"",
|
47
|
+
"'": r"'",
|
48
|
+
}
|
49
|
+
|
38
50
|
|
39
51
|
class DefaultParameters(Enum):
|
40
52
|
ENVIRONMENT: str = "mainnet"
|
@@ -63,19 +75,9 @@ class OutputTypes(Enum):
|
|
63
75
|
JSONLD: str = "JSON-LD"
|
64
76
|
|
65
77
|
|
66
|
-
class Environments(Enum):
|
67
|
-
DEVELOPMENT: str = "development"
|
68
|
-
DEVNET: str = "devnet"
|
69
|
-
TESTNET: str = "testnet"
|
70
|
-
MAINNET: str = "mainnet"
|
71
|
-
|
72
|
-
|
73
78
|
class BlockchainIds(Enum):
|
74
79
|
HARDHAT_1: str = "hardhat1:31337"
|
75
80
|
HARDHAT_2: str = "hardhat2:31337"
|
76
|
-
BASE_DEVNET: str = "base:84532"
|
77
|
-
GNOSIS_DEVNET: str = "gnosis:10200"
|
78
|
-
NEUROWEB_DEVNET: str = "otp:2160"
|
79
81
|
BASE_TESTNET: str = "base:84532"
|
80
82
|
GNOSIS_TESTNET: str = "gnosis:10200"
|
81
83
|
NEUROWEB_TESTNET: str = "otp:20430"
|
@@ -102,12 +104,6 @@ BLOCKCHAINS = {
|
|
102
104
|
"rpc": "http://localhost:9545",
|
103
105
|
},
|
104
106
|
},
|
105
|
-
"devnet": {
|
106
|
-
"base:84532": {
|
107
|
-
"hub": "0xE043daF4cC8ae2c720ef95fc82574a37a429c40A",
|
108
|
-
"rpc": "https://sepolia.base.org",
|
109
|
-
}
|
110
|
-
},
|
111
107
|
"testnet": {
|
112
108
|
"base:84532": {
|
113
109
|
"hub": "0xf21CE8f8b01548D97DCFb36869f1ccB0814a4e05",
|
@@ -140,11 +136,6 @@ BLOCKCHAINS = {
|
|
140
136
|
|
141
137
|
DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS = {
|
142
138
|
"development": {"hardhat1:31337": 2, "hardhat2:31337": 2, "otp:2043": 2},
|
143
|
-
"devnet": {
|
144
|
-
"otp:2160": 2,
|
145
|
-
"gnosis:10200": 2,
|
146
|
-
"base:84532": 2,
|
147
|
-
},
|
148
139
|
"testnet": {
|
149
140
|
"otp:20430": 2,
|
150
141
|
"gnosis:10200": 2,
|
dkg/modules/asset/asset.py
CHANGED
@@ -209,6 +209,7 @@ class KnowledgeAsset(Module):
|
|
209
209
|
blockchain_id = self.manager.blockchain_provider.blockchain_id
|
210
210
|
|
211
211
|
dataset = {}
|
212
|
+
content = kc_tools.escape_literal_dict(content)
|
212
213
|
public_content = dataset.get("public")
|
213
214
|
private_content = dataset.get("private")
|
214
215
|
if isinstance(content, str):
|
dkg/modules/asset/async_asset.py
CHANGED
@@ -240,6 +240,7 @@ class AsyncKnowledgeAsset(AsyncModule):
|
|
240
240
|
blockchain_id = self.manager.blockchain_provider.blockchain_id
|
241
241
|
|
242
242
|
dataset = {}
|
243
|
+
content = kc_tools.escape_literal_dict(content)
|
243
244
|
public_content = dataset.get("public")
|
244
245
|
private_content = dataset.get("private")
|
245
246
|
if isinstance(content, str):
|
dkg/modules/graph/async_graph.py
CHANGED
dkg/modules/graph/graph.py
CHANGED
@@ -27,7 +27,7 @@ from dkg.exceptions import (
|
|
27
27
|
AccountMissing,
|
28
28
|
NetworkNotSupported,
|
29
29
|
)
|
30
|
-
from dkg.types import URI, Address,
|
30
|
+
from dkg.types import URI, Address, Wei
|
31
31
|
from web3.contract import Contract
|
32
32
|
from web3.contract.contract import ContractFunction
|
33
33
|
from web3.types import TxReceipt
|
@@ -39,13 +39,12 @@ from dkg.providers.blockchain.base_blockchain import BaseBlockchainProvider
|
|
39
39
|
class AsyncBlockchainProvider(BaseBlockchainProvider):
|
40
40
|
def __init__(
|
41
41
|
self,
|
42
|
-
environment: Environment,
|
43
42
|
blockchain_id: str,
|
44
43
|
rpc_uri: URI | None = None,
|
45
44
|
gas_price: Wei | None = None,
|
46
45
|
verify: bool = True,
|
47
46
|
):
|
48
|
-
super().__init__(
|
47
|
+
super().__init__(blockchain_id, rpc_uri, gas_price)
|
49
48
|
|
50
49
|
ssl_context = None if verify else False
|
51
50
|
self.w3 = AsyncWeb3(
|
@@ -8,7 +8,7 @@ from dkg.exceptions import (
|
|
8
8
|
EnvironmentNotSupported,
|
9
9
|
RPCURINotDefined,
|
10
10
|
)
|
11
|
-
from dkg.types import URI, DataHexStr,
|
11
|
+
from dkg.types import URI, DataHexStr, Wei
|
12
12
|
from eth_account.signers.local import LocalAccount
|
13
13
|
from eth_typing import ABI, ABIFunction
|
14
14
|
from web3.logs import DISCARD
|
@@ -21,27 +21,26 @@ class BaseBlockchainProvider:
|
|
21
21
|
|
22
22
|
def __init__(
|
23
23
|
self,
|
24
|
-
environment: Environment,
|
25
24
|
blockchain_id: str,
|
26
25
|
rpc_uri: URI | None = None,
|
27
26
|
gas_price: Wei | None = None,
|
28
27
|
):
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
self.environment = None
|
29
|
+
for env_name, chains_in_env in BLOCKCHAINS.items():
|
30
|
+
if blockchain_id in chains_in_env:
|
31
|
+
self.environment = env_name
|
32
|
+
break
|
33
|
+
|
34
|
+
if self.environment is None:
|
35
|
+
raise EnvironmentNotSupported(
|
36
|
+
f"Could not derive environment for blockchain_id: {blockchain_id}. "
|
37
|
+
"Ensure it's defined in BLOCKCHAINS constant."
|
38
|
+
)
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
].get("rpc", None)
|
40
|
+
self.blockchain_id = blockchain_id
|
41
|
+
self.rpc_uri = rpc_uri or BLOCKCHAINS[self.environment][self.blockchain_id].get(
|
42
|
+
"rpc", None
|
43
|
+
)
|
45
44
|
|
46
45
|
if self.rpc_uri is None:
|
47
46
|
raise RPCURINotDefined(
|
@@ -26,7 +26,7 @@ from dkg.exceptions import (
|
|
26
26
|
AccountMissing,
|
27
27
|
NetworkNotSupported,
|
28
28
|
)
|
29
|
-
from dkg.types import URI, Address,
|
29
|
+
from dkg.types import URI, Address, Wei
|
30
30
|
from web3 import Web3
|
31
31
|
from web3.contract import Contract
|
32
32
|
from web3.contract.contract import ContractFunction
|
@@ -37,13 +37,12 @@ from dkg.providers.blockchain.base_blockchain import BaseBlockchainProvider
|
|
37
37
|
class BlockchainProvider(BaseBlockchainProvider):
|
38
38
|
def __init__(
|
39
39
|
self,
|
40
|
-
environment: Environment,
|
41
40
|
blockchain_id: str,
|
42
41
|
rpc_uri: URI | None = None,
|
43
42
|
gas_price: Wei | None = None,
|
44
43
|
verify: bool = True,
|
45
44
|
):
|
46
|
-
super().__init__(
|
45
|
+
super().__init__(blockchain_id, rpc_uri, gas_price)
|
47
46
|
|
48
47
|
self.w3 = Web3(
|
49
48
|
Web3.HTTPProvider(self.rpc_uri, request_kwargs={"verify": verify})
|
dkg/types/blockchain.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
from typing import Literal
|
2
|
+
import codecs
|
2
3
|
from dkg.constants import CHUNK_BYTE_SIZE
|
3
4
|
from dkg.exceptions import DatasetInputFormatNotSupported, InvalidDataset
|
4
5
|
from dkg.types import JSONLD, NQuads
|
5
6
|
from pyld import jsonld
|
6
|
-
from dkg.constants import DEFAULT_RDF_FORMAT, DEFAULT_CANON_ALGORITHM
|
7
|
+
from dkg.constants import DEFAULT_RDF_FORMAT, DEFAULT_CANON_ALGORITHM, ESCAPE_MAP
|
7
8
|
from rdflib import Graph, BNode, URIRef, Literal as RDFLiteral
|
8
9
|
from uuid import uuid4
|
9
10
|
from web3 import Web3
|
@@ -96,7 +97,9 @@ def split_into_chunks(quads, chunk_size_bytes=32):
|
|
96
97
|
while start < len(encoded_bytes):
|
97
98
|
end = min(start + chunk_size_bytes, len(encoded_bytes))
|
98
99
|
chunk = encoded_bytes[start:end]
|
99
|
-
chunks.append(
|
100
|
+
chunks.append(
|
101
|
+
codecs.decode(chunk, "utf-8", errors="replace")
|
102
|
+
) # Decode bytes back to string
|
100
103
|
start = end
|
101
104
|
|
102
105
|
return chunks
|
@@ -246,3 +249,20 @@ def solidity_packed_sha256(types: list[str], values: list) -> str:
|
|
246
249
|
sha256_hash = hashlib.sha256(packed_data).hexdigest()
|
247
250
|
|
248
251
|
return f"0x{sha256_hash}"
|
252
|
+
|
253
|
+
|
254
|
+
def escape_literal_string(s):
|
255
|
+
for char, replacement in ESCAPE_MAP.items():
|
256
|
+
s = s.replace(char, replacement)
|
257
|
+
return s
|
258
|
+
|
259
|
+
|
260
|
+
def escape_literal_dict(obj):
|
261
|
+
if isinstance(obj, dict):
|
262
|
+
return {k: escape_literal_dict(v) for k, v in obj.items()}
|
263
|
+
elif isinstance(obj, list):
|
264
|
+
return [escape_literal_dict(i) for i in obj]
|
265
|
+
elif isinstance(obj, str):
|
266
|
+
return escape_literal_string(s=obj)
|
267
|
+
else:
|
268
|
+
return obj
|
@@ -3,7 +3,7 @@ dkg/assertion.py,sha256=-KIVT3LHlOHegGg68_KceC5O2r8B_povbofRjmLguVQ,2507
|
|
3
3
|
dkg/clients/__init__.py,sha256=qKQ8TIbst7UZpJEpEJOZslgEX5EB0PU_H7cwk5-UDso,84
|
4
4
|
dkg/clients/async_dkg.py,sha256=PM0suu8BFUhhS8_K_zoPTxKEXn5J1AFCwyB-JP-hLmc,4013
|
5
5
|
dkg/clients/dkg.py,sha256=QTLm5nfeW0gx_t2e8JMO5gcIJaPvmy1L7ZOy7dSfhkc,3786
|
6
|
-
dkg/constants.py,sha256=
|
6
|
+
dkg/constants.py,sha256=PBX3AEK0bBeiG7sHBY65cZllo74q-H8hclqNbl4fj90,4776
|
7
7
|
dkg/data/interfaces/AskStorage.json,sha256=hHWq3e0Kx8Cs3PKD4HL2xYRQ8DXRTxTL06QXqFyqlns,6773
|
8
8
|
dkg/data/interfaces/Chronos.json,sha256=aIpCUgJ8omHidyt0GPkj02COT1LW8Tu66qDm7iquQJk,3595
|
9
9
|
dkg/data/interfaces/Hub.json,sha256=ZcaePz10ff2Vm7VP-vWP63xLOuE0EE8jNruWvWmMjLw,12611
|
@@ -24,12 +24,12 @@ dkg/managers/manager.py,sha256=2fGwzppJR33d3VPRHgZIvlBbcrb5P99_J7BdfaaOSYM,2640
|
|
24
24
|
dkg/method.py,sha256=HG_mI6CXxKznLAN561G2Gqtijm3eliHV6vPxAvz-dGs,5521
|
25
25
|
dkg/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
26
|
dkg/modules/asset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
-
dkg/modules/asset/asset.py,sha256=
|
28
|
-
dkg/modules/asset/async_asset.py,sha256=
|
27
|
+
dkg/modules/asset/asset.py,sha256=IplLU6Rz2rJlCYpfQbPPl4JFvlieU7Vx5-TvoFifB_E,27675
|
28
|
+
dkg/modules/asset/async_asset.py,sha256=92YL0JqQ5vXeJbWd3MBIwwYqEX6Y2ksghnED76hrrzs,28260
|
29
29
|
dkg/modules/async_module.py,sha256=iw4DEU8tUvm0CXErQ1LZ8qGcNMQJmvGhu0poHjoKPaI,2629
|
30
30
|
dkg/modules/graph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
|
-
dkg/modules/graph/async_graph.py,sha256=
|
32
|
-
dkg/modules/graph/graph.py,sha256=
|
31
|
+
dkg/modules/graph/async_graph.py,sha256=4YNTvnRdeuIV2xjr8-MT8h8zVoW6GfTKVc2AwGvsNuY,4196
|
32
|
+
dkg/modules/graph/graph.py,sha256=o73WXIvKBzkbpnva_RdpQLQwEGlRIl38hxrypL1YnjE,3293
|
33
33
|
dkg/modules/module.py,sha256=_lK4iFgThXNSD_dhM6ZgDrDJdxsRjZgIHGQLLXzOW4s,2575
|
34
34
|
dkg/modules/network/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
dkg/modules/network/network.py,sha256=a5P9bjbiBVyOaz_Pwycx1IljhgHsE4DM9n2faCIeZtc,2191
|
@@ -40,9 +40,9 @@ dkg/modules/paranet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
40
40
|
dkg/modules/paranet/paranet.py,sha256=YulI-sP65sOlBYyUVbA008JByvy-bqnOnWt7vXsf5Kk,26959
|
41
41
|
dkg/providers/__init__.py,sha256=mOHuyl44mpuLnXv920CJ1lsbSTlxNLCwK4xXeQsfv3s,251
|
42
42
|
dkg/providers/blockchain/__init__.py,sha256=Vg5XQ9Fw5m0CQvpMTH5atgPIKKcnknX9peShsmOOtGg,158
|
43
|
-
dkg/providers/blockchain/async_blockchain.py,sha256=
|
44
|
-
dkg/providers/blockchain/base_blockchain.py,sha256=
|
45
|
-
dkg/providers/blockchain/blockchain.py,sha256
|
43
|
+
dkg/providers/blockchain/async_blockchain.py,sha256=GpMTGKhsqB_m2f6InUAwiRJNisKQErgVSot869TnTV0,8706
|
44
|
+
dkg/providers/blockchain/base_blockchain.py,sha256=AW3PlcgfEthvHxxCcv0USXtnOmIixnjK9rg-HpfHuxA,3591
|
45
|
+
dkg/providers/blockchain/blockchain.py,sha256=-CoUpc1lRLiVpCWmYVI7dUOn_goreSqSkz0DZq66GAI,7846
|
46
46
|
dkg/providers/node/__init__.py,sha256=Nx2m3bbwDa4y0gAR1WUKhxmw36F-TscKaZj1CKqlEF4,148
|
47
47
|
dkg/providers/node/async_node_http.py,sha256=dBge8pS9Pnk8N4TTgKeewmWWJnSOgU48rQVbm5ZKKsc,2804
|
48
48
|
dkg/providers/node/base_node_http.py,sha256=CCkVwyr_iQKCbknVmEpUDXZlQb8C-Z5ndqQdW-fQR0E,763
|
@@ -56,7 +56,7 @@ dkg/services/node_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
56
56
|
dkg/services/node_services/async_node_service.py,sha256=AGwpEIbL6HbqcL1Y8FjIwNynQyvvhQaBZdwZtu9X-BQ,5478
|
57
57
|
dkg/services/node_services/node_service.py,sha256=gqCm-PXB0dWwqWw6OxD3AZ3oiS-z6dhxG_l4LDXv3OA,4811
|
58
58
|
dkg/types/__init__.py,sha256=YewW48fOBq-FtecY12Tlr_0vGDuNc2uzpIiM-WERzBU,704
|
59
|
-
dkg/types/blockchain.py,sha256=
|
59
|
+
dkg/types/blockchain.py,sha256=T-A7PEa7v99RuCcmwzkOubQPJG4TXZHHjCgYr09lM7U,1672
|
60
60
|
dkg/types/dkg_node.py,sha256=uGjaYUO4D55sHJrL_3aOL3Nul3RlAo_aL4HLoSrQxr0,838
|
61
61
|
dkg/types/encoding.py,sha256=gOtt9XLoxs6TE7rOCrAx-aCOdsDdaTVn3bxu9HPavxc,915
|
62
62
|
dkg/types/evm.py,sha256=gN2hSq4MQzobWE3YAiTZPcv5b65AVyUEQut8hWPnx68,971
|
@@ -68,15 +68,15 @@ dkg/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
68
|
dkg/utils/blockchain_request.py,sha256=CMz3sNRhfmYirm0-VUK2HTpbRfgc1gtG2SoPIuRYKb0,12446
|
69
69
|
dkg/utils/decorators.py,sha256=uUh0xI9wv1gE6JF44eYEfUPGSFEBLR6Ua5D9Dhc3s10,1566
|
70
70
|
dkg/utils/knowledge_asset_tools.py,sha256=uehOshzaYg03hDU8RSIV_k2mNaASVgqyyErzj6GwBxw,81
|
71
|
-
dkg/utils/knowledge_collection_tools.py,sha256=
|
71
|
+
dkg/utils/knowledge_collection_tools.py,sha256=hPCFcIdyWDCgfbo5uPQizvfin0hHvEElAYpvKYVDIBs,7951
|
72
72
|
dkg/utils/merkle.py,sha256=924kloBAnCXydteVtWMj_QLP5CRJf2GbHMZ-lbIK0KE,5141
|
73
73
|
dkg/utils/metadata.py,sha256=483OroYwGNfZ_cCXfH3-xUrZgiR4mjjo9iU_Ie5RYRs,1658
|
74
74
|
dkg/utils/node_request.py,sha256=wppF8Xf0RkuAAcURcYgyjGAdMsXm0L5YEem8wFGE2g8,6517
|
75
75
|
dkg/utils/rdf.py,sha256=AvlcxZEeP58UbaGGvPX_ss69O-tgTXOJ9y9COZqVgkw,2973
|
76
76
|
dkg/utils/string_transformations.py,sha256=eR51fVwTF9QKxEqXo9_1Bfw_k8iQajdXD6rKuTvhs70,972
|
77
77
|
dkg/utils/ual.py,sha256=g7PFyS4Sbwjmwkq-eB20uRULEC2wlPGZr31BVQjs5OQ,1569
|
78
|
-
dkg-8.0.
|
79
|
-
dkg-8.0.
|
80
|
-
dkg-8.0.
|
81
|
-
dkg-8.0.
|
82
|
-
dkg-8.0.
|
78
|
+
dkg-8.0.12.dist-info/LICENSE,sha256=Dr70w2zcW8-jrPGlpTTTlJPL8lR4j2zpDD32tdEFgjY,11375
|
79
|
+
dkg-8.0.12.dist-info/METADATA,sha256=qoW7Du0ik1jwQC-qkG3nBQgZQLMoRtUrh4FMJXLJzcQ,10821
|
80
|
+
dkg-8.0.12.dist-info/NOTICE,sha256=Rk5toFR2ZqPwVZ3P_P4wE6U1xCnWR9KD3rNBqfPY7h8,368
|
81
|
+
dkg-8.0.12.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
82
|
+
dkg-8.0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|