dkg 0.1.0b1__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 (62) hide show
  1. dkg/__init__.py +3 -0
  2. dkg/asset.py +781 -0
  3. dkg/constants.py +39 -0
  4. dkg/data/interfaces/Assertion.json +131 -0
  5. dkg/data/interfaces/AssertionStorage.json +229 -0
  6. dkg/data/interfaces/CommitManagerV1.json +534 -0
  7. dkg/data/interfaces/CommitManagerV1U1.json +720 -0
  8. dkg/data/interfaces/ContentAsset.json +671 -0
  9. dkg/data/interfaces/ContentAssetStorage.json +706 -0
  10. dkg/data/interfaces/HashingProxy.json +227 -0
  11. dkg/data/interfaces/Hub.json +356 -0
  12. dkg/data/interfaces/Identity.json +193 -0
  13. dkg/data/interfaces/IdentityStorage.json +342 -0
  14. dkg/data/interfaces/ParametersStorage.json +468 -0
  15. dkg/data/interfaces/Profile.json +292 -0
  16. dkg/data/interfaces/ProfileStorage.json +596 -0
  17. dkg/data/interfaces/ProofManagerV1.json +525 -0
  18. dkg/data/interfaces/ProofManagerV1U1.json +546 -0
  19. dkg/data/interfaces/ScoringProxy.json +242 -0
  20. dkg/data/interfaces/ServiceAgreementStorageProxy.json +1299 -0
  21. dkg/data/interfaces/ServiceAgreementStorageV1.json +901 -0
  22. dkg/data/interfaces/ServiceAgreementStorageV1U1.json +1097 -0
  23. dkg/data/interfaces/ServiceAgreementV1.json +741 -0
  24. dkg/data/interfaces/ShardingTable.json +268 -0
  25. dkg/data/interfaces/ShardingTableStorage.json +317 -0
  26. dkg/data/interfaces/Staking.json +456 -0
  27. dkg/data/interfaces/StakingStorage.json +407 -0
  28. dkg/data/interfaces/Token.json +544 -0
  29. dkg/data/interfaces/UnfinalizedStateStorage.json +171 -0
  30. dkg/data/interfaces/WhitelistStorage.json +124 -0
  31. dkg/dataclasses.py +45 -0
  32. dkg/exceptions.py +161 -0
  33. dkg/graph.py +63 -0
  34. dkg/main.py +74 -0
  35. dkg/manager.py +64 -0
  36. dkg/method.py +131 -0
  37. dkg/module.py +63 -0
  38. dkg/node.py +54 -0
  39. dkg/providers/__init__.py +2 -0
  40. dkg/providers/blockchain.py +181 -0
  41. dkg/providers/node_http.py +62 -0
  42. dkg/types/__init__.py +8 -0
  43. dkg/types/blockchain.py +58 -0
  44. dkg/types/dkg_node.py +20 -0
  45. dkg/types/encoding.py +22 -0
  46. dkg/types/evm.py +25 -0
  47. dkg/types/generics.py +21 -0
  48. dkg/types/network.py +20 -0
  49. dkg/types/rdf.py +21 -0
  50. dkg/utils/__init__.py +0 -0
  51. dkg/utils/blockchain_request.py +159 -0
  52. dkg/utils/decorators.py +46 -0
  53. dkg/utils/merkle.py +173 -0
  54. dkg/utils/metadata.py +50 -0
  55. dkg/utils/node_request.py +197 -0
  56. dkg/utils/rdf.py +51 -0
  57. dkg/utils/string_transformations.py +22 -0
  58. dkg/utils/ual.py +41 -0
  59. dkg-0.1.0b1.dist-info/LICENSE +202 -0
  60. dkg-0.1.0b1.dist-info/METADATA +453 -0
  61. dkg-0.1.0b1.dist-info/RECORD +62 -0
  62. dkg-0.1.0b1.dist-info/WHEEL +4 -0
dkg/module.py ADDED
@@ -0,0 +1,63 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from dataclasses import asdict
19
+ from typing import Any, Callable, Sequence
20
+
21
+ from dkg.exceptions import ValidationError
22
+ from dkg.manager import DefaultRequestManager
23
+ from dkg.method import Method
24
+ from dkg.types import TReturn
25
+
26
+
27
+ class Module:
28
+ manager: DefaultRequestManager
29
+
30
+ def retrieve_caller_fn(
31
+ self, method: Method[Callable[..., TReturn]]
32
+ ) -> Callable[..., TReturn]:
33
+ def caller(*args: Any, **kwargs: Any) -> TReturn:
34
+ processed_args = method.process_args(*args, **kwargs)
35
+ request_params = asdict(method.action)
36
+ request_params.update(processed_args)
37
+ return self.manager.blocking_request(type(method.action), request_params)
38
+
39
+ return caller
40
+
41
+ def _attach_modules(self, module_definitions: dict[str, Any]) -> None:
42
+ for module_name, module_info in module_definitions.items():
43
+ module_info_is_list_like = isinstance(module_info, Sequence)
44
+
45
+ module = module_info[0] if module_info_is_list_like else module_info
46
+
47
+ if hasattr(self, module_name):
48
+ raise AttributeError(
49
+ f"Cannot set {self} module named '{module_name}'. "
50
+ " The dkg object already has an attribute with that name"
51
+ )
52
+
53
+ setattr(self, module_name, module)
54
+
55
+ if module_info_is_list_like:
56
+ if len(module_info) == 2:
57
+ submodule_definitions = module_info[1]
58
+ module: "Module" = getattr(self, module_name)
59
+ module._attach_modules(submodule_definitions)
60
+ elif len(module_info) != 1:
61
+ raise ValidationError(
62
+ "Module definitions can only have 1 or 2 elements."
63
+ )
dkg/node.py ADDED
@@ -0,0 +1,54 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from dkg.dataclasses import NodeResponseDict
19
+ from dkg.manager import DefaultRequestManager
20
+ from dkg.method import Method
21
+ from dkg.module import Module
22
+ from dkg.types import Address, DataHexStr
23
+ from dkg.utils.node_request import NodeRequest
24
+
25
+
26
+ class Node(Module):
27
+ def __init__(self, manager: DefaultRequestManager):
28
+ self.manager = manager
29
+
30
+ _info = Method(NodeRequest.info)
31
+
32
+ @property
33
+ def info(self) -> NodeResponseDict:
34
+ return self._info()
35
+
36
+ _get_bid_suggestion = Method(NodeRequest.bid_suggestion)
37
+
38
+ def get_bid_suggestion(
39
+ self,
40
+ blockchain: str,
41
+ epochs_num: int,
42
+ assertion_size: int,
43
+ content_asset_storage_address: Address,
44
+ first_assertion_id: DataHexStr,
45
+ hash_function_id: int,
46
+ ) -> NodeResponseDict:
47
+ return self._get_bid_suggestion(
48
+ blockchain,
49
+ epochs_num,
50
+ assertion_size,
51
+ content_asset_storage_address,
52
+ first_assertion_id,
53
+ hash_function_id,
54
+ )
@@ -0,0 +1,2 @@
1
+ from .blockchain import BlockchainProvider # NOQA
2
+ from .node_http import NodeHTTPProvider # NOQA
@@ -0,0 +1,181 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ import json
19
+ from collections import namedtuple
20
+ from pathlib import Path
21
+ from typing import Any, Type
22
+
23
+ from dkg.exceptions import AccountMissing, NetworkNotSupported
24
+ from dkg.types import URI, Address, DataHexStr, Wei
25
+ from eth_account.signers.local import LocalAccount
26
+ from web3 import Web3
27
+ from web3.contract import Contract
28
+ from web3.contract.contract import ContractFunction
29
+ from web3.logs import DISCARD
30
+ from web3.middleware import construct_sign_and_send_raw_middleware
31
+ from web3.types import ABI, ABIFunction, TxReceipt
32
+ from dkg.constants import BLOCKCHAINS
33
+
34
+
35
+ class BlockchainProvider:
36
+ CONTRACTS_METADATA_DIR = Path(__file__).parents[1] / "data/interfaces"
37
+
38
+ GAS_BUFFER = 1.2 # 20% gas buffer for estimateGas()
39
+
40
+ def __init__(
41
+ self,
42
+ rpc_uri: URI,
43
+ private_key: DataHexStr | None = None,
44
+ verify: bool = True,
45
+ ):
46
+ self.w3 = Web3(Web3.HTTPProvider(rpc_uri, request_kwargs={"verify": verify}))
47
+
48
+ if (chain_id := self.w3.eth.chain_id) not in BLOCKCHAINS.keys():
49
+ raise NetworkNotSupported(
50
+ f"Network with chain ID {chain_id} isn't supported!"
51
+ )
52
+ hub_address: Address = BLOCKCHAINS[chain_id]["hubAddress"]
53
+
54
+ self.abi = self._load_abi()
55
+ self.output_named_tuples = self._generate_output_named_tuples()
56
+ self.contracts: dict[str, Contract] = {
57
+ "Hub": self.w3.eth.contract(
58
+ address=hub_address,
59
+ abi=self.abi["Hub"],
60
+ )
61
+ }
62
+ self._init_contracts()
63
+
64
+ if private_key is not None:
65
+ self.set_account(private_key)
66
+
67
+ def make_json_rpc_request(self, endpoint: str, args: dict[str, Any] = {}) -> Any:
68
+ web3_method = getattr(self.w3.eth, endpoint)
69
+
70
+ if callable(web3_method):
71
+ return web3_method(**args)
72
+ else:
73
+ return web3_method
74
+
75
+ def call_function(
76
+ self,
77
+ contract: str,
78
+ function: str,
79
+ args: dict[str, Any] = {},
80
+ state_changing: bool = False,
81
+ gas_price: Wei | None = None,
82
+ gas_limit: Wei | None = None,
83
+ ) -> TxReceipt | Any:
84
+ contract_instance = self.contracts[contract]
85
+ contract_function: ContractFunction = getattr(
86
+ contract_instance.functions, function
87
+ )
88
+
89
+ if not state_changing:
90
+ result = contract_function(**args).call()
91
+ if function in (output_named_tuples := self.output_named_tuples[contract]):
92
+ result = output_named_tuples[function](*result)
93
+ return result
94
+ else:
95
+ if not hasattr(self, "account"):
96
+ raise AccountMissing(
97
+ "State-changing transactions can be performed only with specified "
98
+ "account."
99
+ )
100
+
101
+ nonce = self.w3.eth.get_transaction_count(self.w3.eth.default_account)
102
+ gas_price = gas_price if gas_price is not None else self.w3.eth.gas_price
103
+
104
+ options = {"nonce": nonce, "gasPrice": gas_price}
105
+ gas_estimate = contract_function(**args).estimate_gas(options)
106
+
107
+ if gas_limit is None:
108
+ options["gas"] = int(gas_estimate * self.GAS_BUFFER)
109
+ else:
110
+ options["gas"] = gas_limit
111
+
112
+ tx_hash = contract_function(**args).transact(options)
113
+ tx_receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
114
+
115
+ return tx_receipt
116
+
117
+ def decode_logs_event(
118
+ self, receipt: TxReceipt, contract_name: str, event_name: str
119
+ ) -> Any:
120
+ return (
121
+ self.contracts[contract_name]
122
+ .events[event_name]()
123
+ .process_receipt(receipt, errors=DISCARD)
124
+ )
125
+
126
+ def set_account(self, private_key: DataHexStr):
127
+ self.account: LocalAccount = self.w3.eth.account.from_key(private_key)
128
+ self.w3.middleware_onion.add(
129
+ construct_sign_and_send_raw_middleware(self.account)
130
+ )
131
+ self.w3.eth.default_account = self.account.address
132
+
133
+ def _init_contracts(self):
134
+ for contract in self.abi.keys():
135
+ if contract == "Hub":
136
+ continue
137
+
138
+ self.contracts[contract] = self.w3.eth.contract(
139
+ address=(
140
+ self.contracts["Hub"]
141
+ .functions.getContractAddress(
142
+ contract if contract != "ERC20Token" else "Token"
143
+ )
144
+ .call()
145
+ if not contract.endswith("AssetStorage")
146
+ else self.contracts["Hub"]
147
+ .functions.getAssetStorageAddress(contract)
148
+ .call()
149
+ ),
150
+ abi=self.abi[contract],
151
+ )
152
+
153
+ def _generate_output_named_tuples(self) -> dict[str, dict[str, Type[tuple]]]:
154
+ def generate_output_namedtuple(function_abi: ABIFunction) -> Type[tuple] | None:
155
+ output_names = [output["name"] for output in function_abi["outputs"]]
156
+ if all(name != "" for name in output_names):
157
+ return namedtuple(f"{function_abi['name']}Result", output_names)
158
+ return None
159
+
160
+ output_named_tuples = {}
161
+ for contract_name, contract_abi in self.abi.items():
162
+ output_named_tuples[contract_name] = {}
163
+ for item in contract_abi:
164
+ if (item["type"] != "function") or not item["outputs"]:
165
+ continue
166
+ elif item["name"] in output_named_tuples[contract_name]:
167
+ continue
168
+ named_tuple = generate_output_namedtuple(item)
169
+ if named_tuple is not None:
170
+ output_named_tuples[contract_name][item["name"]] = named_tuple
171
+
172
+ return output_named_tuples
173
+
174
+ def _load_abi(self) -> ABI:
175
+ abi = {}
176
+
177
+ for contract_metadata in self.CONTRACTS_METADATA_DIR.glob("*.json"):
178
+ with open(contract_metadata, "r") as metadata_json:
179
+ abi[contract_metadata.stem] = json.load(metadata_json)
180
+
181
+ return abi
@@ -0,0 +1,62 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import Any
19
+
20
+ import requests
21
+ from dkg.dataclasses import HTTPRequestMethod, NodeResponseDict
22
+ from dkg.exceptions import HTTPRequestMethodNotSupported, NodeRequestError
23
+ from dkg.types import URI
24
+ from requests import Response
25
+
26
+
27
+ class NodeHTTPProvider:
28
+ def __init__(self, endpoint_uri: URI | str):
29
+ self.endpoint_uri = URI(endpoint_uri)
30
+
31
+ def make_request(
32
+ self,
33
+ method: HTTPRequestMethod,
34
+ path: str,
35
+ params: dict[str, Any] = {},
36
+ data: dict[str, Any] = {},
37
+ ) -> Response:
38
+ request_func = getattr(self, method.name.lower())
39
+
40
+ match method:
41
+ case HTTPRequestMethod.GET:
42
+ return request_func(path, params)
43
+ case HTTPRequestMethod.POST:
44
+ return request_func(path, data)
45
+ case HTTPRequestMethod():
46
+ raise HTTPRequestMethodNotSupported(
47
+ f"{method.name} method isn't supported"
48
+ )
49
+
50
+ def get(self, path: str, params: dict[str, Any] = {}) -> NodeResponseDict:
51
+ try:
52
+ response = requests.get(f"{self.endpoint_uri}/{path}", params=params)
53
+ return NodeResponseDict(response.json())
54
+ except requests.exceptions.HTTPError as err:
55
+ raise NodeRequestError(err)
56
+
57
+ def post(self, path: str, data: dict[str, Any] = {}) -> NodeResponseDict:
58
+ try:
59
+ response = requests.post(f"{self.endpoint_uri}/{path}", json=data)
60
+ return NodeResponseDict(response.json())
61
+ except requests.exceptions.HTTPError as err:
62
+ raise NodeRequestError(err)
dkg/types/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ from .blockchain import (ABI, ABIElement, ABIError, ABIEvent, # NOQA: F401
2
+ ABIFunction, ABIParameter, AgreementData)
3
+ from .dkg_node import UAL # NOQA: F401
4
+ from .encoding import BytesLike, DataHexStr, HexStr # NOQA: F401
5
+ from .evm import Address, ChecksumAddress, Wei # NOQA: F401
6
+ from .generics import TFunc, TReturn # NOQA: F401
7
+ from .network import URI # NOQA: F401
8
+ from .rdf import JSONLD, NQuads # NOQA: F401
@@ -0,0 +1,58 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import NamedTuple, TypedDict
19
+
20
+
21
+ class ABIParameter(TypedDict, total=False):
22
+ name: str
23
+ type: str
24
+ indexed: bool | None # Only used in event inputs
25
+ components: list["ABIParameter"] | None # Used for tuple types
26
+
27
+
28
+ class ABICommon(TypedDict, total=False):
29
+ type: str
30
+ name: str | None
31
+ inputs: list[ABIParameter]
32
+
33
+
34
+ class ABIFunction(ABICommon):
35
+ outputs: list[ABIParameter]
36
+ stateMutability: str
37
+
38
+
39
+ class ABIEvent(ABICommon):
40
+ anonymous: bool
41
+
42
+
43
+ class ABIError(TypedDict):
44
+ type: str
45
+ name: str
46
+ inputs: list[ABIParameter]
47
+
48
+
49
+ ABIElement = ABIFunction | ABIEvent | ABIError
50
+ ABI = list[ABIElement]
51
+
52
+
53
+ class AgreementData(NamedTuple):
54
+ startTime: int
55
+ epochsNumber: int
56
+ epochLength: int
57
+ tokensInfo: list[int]
58
+ scoreFunctionIdAndProofWindowOffsetPerc: list[int]
dkg/types/dkg_node.py ADDED
@@ -0,0 +1,20 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import NewType
19
+
20
+ UAL = NewType("UAL", str)
dkg/types/encoding.py ADDED
@@ -0,0 +1,22 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import NewType
19
+
20
+ HexStr = NewType("HexStr", str)
21
+ DataHexStr = NewType("DataHexStr", str)
22
+ BytesLike = bytes | DataHexStr
dkg/types/evm.py ADDED
@@ -0,0 +1,25 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import NewType
19
+
20
+ from .encoding import DataHexStr
21
+
22
+ Address = NewType("Address", DataHexStr)
23
+ ChecksumAddress = NewType("ChecksumAddress", DataHexStr)
24
+
25
+ Wei = NewType("Wei", int)
dkg/types/generics.py ADDED
@@ -0,0 +1,21 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import Any, Callable, TypeVar
19
+
20
+ TFunc = TypeVar("TFunc", bound=Callable[..., Any])
21
+ TReturn = TypeVar("TReturn")
dkg/types/network.py ADDED
@@ -0,0 +1,20 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import NewType
19
+
20
+ URI = NewType("URI", str)
dkg/types/rdf.py ADDED
@@ -0,0 +1,21 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from typing import Any
19
+
20
+ JSONLD = dict[str, Any]
21
+ NQuads = list[str]
dkg/utils/__init__.py ADDED
File without changes