dkg 8.0.0a1__py3-none-any.whl → 8.0.0a2__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 +1 -1
- dkg/utils/rdf.py +1 -3
- dkg/utils/string_transformations.py +1 -0
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a2.dist-info}/METADATA +8 -7
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a2.dist-info}/RECORD +25 -24
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a2.dist-info}/LICENSE +0 -0
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a2.dist-info}/NOTICE +0 -0
- {dkg-8.0.0a1.dist-info → dkg-8.0.0a2.dist-info}/WHEEL +0 -0
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
|
|
@@ -59,6 +59,16 @@ class ParanetIncentivizationType(AutoStrEnumCapitalize):
|
|
59
59
|
NEUROWEB = auto()
|
60
60
|
|
61
61
|
|
62
|
+
class ParanetNodesAccessPolicy(IntEnum):
|
63
|
+
OPEN = 0
|
64
|
+
CURATED = 1
|
65
|
+
|
66
|
+
|
67
|
+
class ParanetMinersAccessPolicy(IntEnum):
|
68
|
+
OPEN = 0
|
69
|
+
CURATED = 1
|
70
|
+
|
71
|
+
|
62
72
|
@dataclass
|
63
73
|
class BaseIncentivesPoolParams:
|
64
74
|
def to_contract_args(self) -> dict:
|
dkg/exceptions.py
CHANGED
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)
|
dkg/paranet.py
CHANGED
@@ -21,7 +21,12 @@ from dataclasses import dataclass
|
|
21
21
|
from web3 import Web3
|
22
22
|
from web3.types import TxReceipt
|
23
23
|
|
24
|
-
from dkg.dataclasses import
|
24
|
+
from dkg.dataclasses import (
|
25
|
+
BaseIncentivesPoolParams,
|
26
|
+
ParanetIncentivizationType,
|
27
|
+
ParanetNodesAccessPolicy,
|
28
|
+
ParanetMinersAccessPolicy,
|
29
|
+
)
|
25
30
|
from dkg.manager import DefaultRequestManager
|
26
31
|
from dkg.method import Method
|
27
32
|
from dkg.module import Module
|
@@ -57,7 +62,12 @@ class Paranet(Module):
|
|
57
62
|
_register_paranet = Method(BlockchainRequest.register_paranet)
|
58
63
|
|
59
64
|
def create(
|
60
|
-
self,
|
65
|
+
self,
|
66
|
+
ual: UAL,
|
67
|
+
name: str,
|
68
|
+
description: str,
|
69
|
+
paranet_nodes_access_policy: ParanetNodesAccessPolicy,
|
70
|
+
paranet_miners_access_policy: ParanetMinersAccessPolicy,
|
61
71
|
) -> dict[str, str | HexStr | TxReceipt]:
|
62
72
|
parsed_ual = parse_ual(ual)
|
63
73
|
knowledge_asset_storage, knowledge_asset_token_id = (
|
@@ -70,6 +80,8 @@ class Paranet(Module):
|
|
70
80
|
knowledge_asset_token_id,
|
71
81
|
name,
|
72
82
|
description,
|
83
|
+
paranet_nodes_access_policy,
|
84
|
+
paranet_miners_access_policy,
|
73
85
|
)
|
74
86
|
|
75
87
|
return {
|
@@ -83,6 +95,328 @@ class Paranet(Module):
|
|
83
95
|
"operation": json.loads(Web3.to_json(receipt)),
|
84
96
|
}
|
85
97
|
|
98
|
+
_add_paranet_curated_nodes = Method(BlockchainRequest.add_paranet_curated_nodes)
|
99
|
+
|
100
|
+
def add_curated_nodes(
|
101
|
+
self, paranet_ual: UAL, identity_ids: list[int]
|
102
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
103
|
+
parsed_ual = parse_ual(paranet_ual)
|
104
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
105
|
+
parsed_ual["contract_address"],
|
106
|
+
parsed_ual["token_id"],
|
107
|
+
)
|
108
|
+
|
109
|
+
receipt = self._add_paranet_curated_nodes(
|
110
|
+
paranet_knowledge_asset_storage,
|
111
|
+
paranet_knowledge_asset_token_id,
|
112
|
+
identity_ids,
|
113
|
+
)
|
114
|
+
|
115
|
+
return {
|
116
|
+
"paranetUAL": paranet_ual,
|
117
|
+
"paranetId": Web3.to_hex(
|
118
|
+
Web3.solidity_keccak(
|
119
|
+
["address", "uint256"],
|
120
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
121
|
+
)
|
122
|
+
),
|
123
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
124
|
+
}
|
125
|
+
|
126
|
+
_remove_paranet_curated_nodes = Method(
|
127
|
+
BlockchainRequest.remove_paranet_curated_nodes
|
128
|
+
)
|
129
|
+
|
130
|
+
def remove_curated_nodes(
|
131
|
+
self, paranet_ual: UAL, identity_ids: list[int]
|
132
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
133
|
+
parsed_ual = parse_ual(paranet_ual)
|
134
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
135
|
+
parsed_ual["contract_address"],
|
136
|
+
parsed_ual["token_id"],
|
137
|
+
)
|
138
|
+
|
139
|
+
receipt = self._remove_paranet_curated_nodes(
|
140
|
+
paranet_knowledge_asset_storage,
|
141
|
+
paranet_knowledge_asset_token_id,
|
142
|
+
identity_ids,
|
143
|
+
)
|
144
|
+
|
145
|
+
return {
|
146
|
+
"paranetUAL": paranet_ual,
|
147
|
+
"paranetId": Web3.to_hex(
|
148
|
+
Web3.solidity_keccak(
|
149
|
+
["address", "uint256"],
|
150
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
151
|
+
)
|
152
|
+
),
|
153
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
154
|
+
}
|
155
|
+
|
156
|
+
_request_paranet_curated_node_access = Method(
|
157
|
+
BlockchainRequest.request_paranet_curated_node_access
|
158
|
+
)
|
159
|
+
|
160
|
+
def request_curated_node_access(
|
161
|
+
self, paranet_ual: UAL
|
162
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
163
|
+
parsed_ual = parse_ual(paranet_ual)
|
164
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
165
|
+
parsed_ual["contract_address"],
|
166
|
+
parsed_ual["token_id"],
|
167
|
+
)
|
168
|
+
|
169
|
+
receipt = self._request_paranet_curated_node_access(
|
170
|
+
paranet_knowledge_asset_storage,
|
171
|
+
paranet_knowledge_asset_token_id,
|
172
|
+
)
|
173
|
+
|
174
|
+
return {
|
175
|
+
"paranetUAL": paranet_ual,
|
176
|
+
"paranetId": Web3.to_hex(
|
177
|
+
Web3.solidity_keccak(
|
178
|
+
["address", "uint256"],
|
179
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
180
|
+
)
|
181
|
+
),
|
182
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
183
|
+
}
|
184
|
+
|
185
|
+
_approve_curated_node = Method(BlockchainRequest.approve_curated_node)
|
186
|
+
|
187
|
+
def approve_curated_node(
|
188
|
+
self, paranet_ual: UAL, identity_id: int
|
189
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
190
|
+
parsed_ual = parse_ual(paranet_ual)
|
191
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
192
|
+
parsed_ual["contract_address"],
|
193
|
+
parsed_ual["token_id"],
|
194
|
+
)
|
195
|
+
|
196
|
+
receipt = self._approve_curated_node(
|
197
|
+
paranet_knowledge_asset_storage,
|
198
|
+
paranet_knowledge_asset_token_id,
|
199
|
+
identity_id,
|
200
|
+
)
|
201
|
+
|
202
|
+
return {
|
203
|
+
"paranetUAL": paranet_ual,
|
204
|
+
"paranetId": Web3.to_hex(
|
205
|
+
Web3.solidity_keccak(
|
206
|
+
["address", "uint256"],
|
207
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
208
|
+
)
|
209
|
+
),
|
210
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
211
|
+
}
|
212
|
+
|
213
|
+
_reject_curated_node = Method(BlockchainRequest.reject_curated_node)
|
214
|
+
|
215
|
+
def reject_curated_node(
|
216
|
+
self, paranet_ual: UAL, identity_id: int
|
217
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
218
|
+
parsed_ual = parse_ual(paranet_ual)
|
219
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
220
|
+
parsed_ual["contract_address"],
|
221
|
+
parsed_ual["token_id"],
|
222
|
+
)
|
223
|
+
|
224
|
+
receipt = self._reject_curated_node(
|
225
|
+
paranet_knowledge_asset_storage,
|
226
|
+
paranet_knowledge_asset_token_id,
|
227
|
+
identity_id,
|
228
|
+
)
|
229
|
+
|
230
|
+
return {
|
231
|
+
"paranetUAL": paranet_ual,
|
232
|
+
"paranetId": Web3.to_hex(
|
233
|
+
Web3.solidity_keccak(
|
234
|
+
["address", "uint256"],
|
235
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
236
|
+
)
|
237
|
+
),
|
238
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
239
|
+
}
|
240
|
+
|
241
|
+
_get_curated_nodes = Method(BlockchainRequest.get_curated_nodes)
|
242
|
+
|
243
|
+
def get_curated_nodes(
|
244
|
+
self, paranet_ual: UAL
|
245
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
246
|
+
parsed_ual = parse_ual(paranet_ual)
|
247
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
248
|
+
parsed_ual["contract_address"],
|
249
|
+
parsed_ual["token_id"],
|
250
|
+
)
|
251
|
+
|
252
|
+
paranet_id = Web3.solidity_keccak(
|
253
|
+
["address", "uint256"],
|
254
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
255
|
+
)
|
256
|
+
|
257
|
+
return self._get_curated_nodes(paranet_id)
|
258
|
+
|
259
|
+
_add_paranet_curated_miners = Method(BlockchainRequest.add_paranet_curated_miners)
|
260
|
+
|
261
|
+
def add_curated_miners(
|
262
|
+
self, paranet_ual: UAL, miner_addresses: list[Address]
|
263
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
264
|
+
parsed_ual = parse_ual(paranet_ual)
|
265
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
266
|
+
parsed_ual["contract_address"],
|
267
|
+
parsed_ual["token_id"],
|
268
|
+
)
|
269
|
+
|
270
|
+
receipt = self._add_paranet_curated_miners(
|
271
|
+
paranet_knowledge_asset_storage,
|
272
|
+
paranet_knowledge_asset_token_id,
|
273
|
+
miner_addresses,
|
274
|
+
)
|
275
|
+
|
276
|
+
return {
|
277
|
+
"paranetUAL": paranet_ual,
|
278
|
+
"paranetId": Web3.to_hex(
|
279
|
+
Web3.solidity_keccak(
|
280
|
+
["address", "uint256"],
|
281
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
282
|
+
)
|
283
|
+
),
|
284
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
285
|
+
}
|
286
|
+
|
287
|
+
_remove_paranet_curated_miners = Method(
|
288
|
+
BlockchainRequest.remove_paranet_curated_miners
|
289
|
+
)
|
290
|
+
|
291
|
+
def remove_curated_miners(
|
292
|
+
self, paranet_ual: UAL, miner_addresses: list[Address]
|
293
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
294
|
+
parsed_ual = parse_ual(paranet_ual)
|
295
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
296
|
+
parsed_ual["contract_address"],
|
297
|
+
parsed_ual["token_id"],
|
298
|
+
)
|
299
|
+
|
300
|
+
receipt = self._remove_paranet_curated_miners(
|
301
|
+
paranet_knowledge_asset_storage,
|
302
|
+
paranet_knowledge_asset_token_id,
|
303
|
+
miner_addresses,
|
304
|
+
)
|
305
|
+
|
306
|
+
return {
|
307
|
+
"paranetUAL": paranet_ual,
|
308
|
+
"paranetId": Web3.to_hex(
|
309
|
+
Web3.solidity_keccak(
|
310
|
+
["address", "uint256"],
|
311
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
312
|
+
)
|
313
|
+
),
|
314
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
315
|
+
}
|
316
|
+
|
317
|
+
_request_paranet_curated_miner_access = Method(
|
318
|
+
BlockchainRequest.request_paranet_curated_miner_access
|
319
|
+
)
|
320
|
+
|
321
|
+
def request_curated_miner_access(
|
322
|
+
self, paranet_ual: UAL
|
323
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
324
|
+
parsed_ual = parse_ual(paranet_ual)
|
325
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
326
|
+
parsed_ual["contract_address"],
|
327
|
+
parsed_ual["token_id"],
|
328
|
+
)
|
329
|
+
|
330
|
+
receipt = self._request_paranet_curated_miner_access(
|
331
|
+
paranet_knowledge_asset_storage,
|
332
|
+
paranet_knowledge_asset_token_id,
|
333
|
+
)
|
334
|
+
|
335
|
+
return {
|
336
|
+
"paranetUAL": paranet_ual,
|
337
|
+
"paranetId": Web3.to_hex(
|
338
|
+
Web3.solidity_keccak(
|
339
|
+
["address", "uint256"],
|
340
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
341
|
+
)
|
342
|
+
),
|
343
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
344
|
+
}
|
345
|
+
|
346
|
+
_approve_curated_miner = Method(BlockchainRequest.approve_curated_miner)
|
347
|
+
|
348
|
+
def approve_curated_miner(
|
349
|
+
self, paranet_ual: UAL, miner_address: Address
|
350
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
351
|
+
parsed_ual = parse_ual(paranet_ual)
|
352
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
353
|
+
parsed_ual["contract_address"],
|
354
|
+
parsed_ual["token_id"],
|
355
|
+
)
|
356
|
+
|
357
|
+
receipt = self._approve_curated_miner(
|
358
|
+
paranet_knowledge_asset_storage,
|
359
|
+
paranet_knowledge_asset_token_id,
|
360
|
+
miner_address,
|
361
|
+
)
|
362
|
+
|
363
|
+
return {
|
364
|
+
"paranetUAL": paranet_ual,
|
365
|
+
"paranetId": Web3.to_hex(
|
366
|
+
Web3.solidity_keccak(
|
367
|
+
["address", "uint256"],
|
368
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
369
|
+
)
|
370
|
+
),
|
371
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
372
|
+
}
|
373
|
+
|
374
|
+
_reject_curated_miner = Method(BlockchainRequest.reject_curated_miner)
|
375
|
+
|
376
|
+
def reject_curated_miner(
|
377
|
+
self, paranet_ual: UAL, miner_address: Address
|
378
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
379
|
+
parsed_ual = parse_ual(paranet_ual)
|
380
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
381
|
+
parsed_ual["contract_address"],
|
382
|
+
parsed_ual["token_id"],
|
383
|
+
)
|
384
|
+
|
385
|
+
receipt = self._reject_curated_miner(
|
386
|
+
paranet_knowledge_asset_storage,
|
387
|
+
paranet_knowledge_asset_token_id,
|
388
|
+
miner_address,
|
389
|
+
)
|
390
|
+
|
391
|
+
return {
|
392
|
+
"paranetUAL": paranet_ual,
|
393
|
+
"paranetId": Web3.to_hex(
|
394
|
+
Web3.solidity_keccak(
|
395
|
+
["address", "uint256"],
|
396
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
397
|
+
)
|
398
|
+
),
|
399
|
+
"operation": json.loads(Web3.to_json(receipt)),
|
400
|
+
}
|
401
|
+
|
402
|
+
_get_knowledge_miners = Method(BlockchainRequest.get_knowledge_miners)
|
403
|
+
|
404
|
+
def get_knowledge_miners(
|
405
|
+
self, paranet_ual: UAL
|
406
|
+
) -> dict[str, str | HexStr | TxReceipt]:
|
407
|
+
parsed_ual = parse_ual(paranet_ual)
|
408
|
+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
|
409
|
+
parsed_ual["contract_address"],
|
410
|
+
parsed_ual["token_id"],
|
411
|
+
)
|
412
|
+
|
413
|
+
paranet_id = Web3.solidity_keccak(
|
414
|
+
["address", "uint256"],
|
415
|
+
[paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id],
|
416
|
+
)
|
417
|
+
|
418
|
+
return self._get_knowledge_miners(paranet_id)
|
419
|
+
|
86
420
|
_deploy_neuro_incentives_pool = Method(
|
87
421
|
BlockchainRequest.deploy_neuro_incentives_pool
|
88
422
|
)
|
dkg/providers/blockchain.py
CHANGED
@@ -32,12 +32,13 @@ from dkg.exceptions import (
|
|
32
32
|
)
|
33
33
|
from dkg.types import URI, Address, DataHexStr, Environment, Wei
|
34
34
|
from eth_account.signers.local import LocalAccount
|
35
|
+
from eth_typing import ABI, ABIFunction
|
35
36
|
from web3 import Web3
|
36
37
|
from web3.contract import Contract
|
37
38
|
from web3.contract.contract import ContractFunction
|
38
39
|
from web3.logs import DISCARD
|
39
|
-
from web3.middleware import
|
40
|
-
from web3.types import
|
40
|
+
from web3.middleware import SignAndSendRawMiddlewareBuilder
|
41
|
+
from web3.types import TxReceipt
|
41
42
|
|
42
43
|
|
43
44
|
class BlockchainProvider:
|
@@ -206,8 +207,9 @@ class BlockchainProvider:
|
|
206
207
|
|
207
208
|
def set_account(self, private_key: DataHexStr):
|
208
209
|
self.account: LocalAccount = self.w3.eth.account.from_key(private_key)
|
209
|
-
self.w3.middleware_onion.
|
210
|
-
|
210
|
+
self.w3.middleware_onion.inject(
|
211
|
+
SignAndSendRawMiddlewareBuilder.build(private_key),
|
212
|
+
layer=0,
|
211
213
|
)
|
212
214
|
self.w3.eth.default_account = self.account.address
|
213
215
|
|
dkg/types/__init__.py
CHANGED
@@ -1,6 +1,18 @@
|
|
1
|
-
from .general import
|
2
|
-
|
3
|
-
|
1
|
+
from .general import (
|
2
|
+
AutoStrEnum,
|
3
|
+
AutoStrEnumCapitalize,
|
4
|
+
AutoStrEnumUpperCase,
|
5
|
+
) # NOQA: F401
|
6
|
+
from .blockchain import (
|
7
|
+
ABI,
|
8
|
+
ABIElement,
|
9
|
+
ABIError,
|
10
|
+
ABIEvent, # NOQA: F401
|
11
|
+
ABIFunction,
|
12
|
+
ABIParameter,
|
13
|
+
AgreementData,
|
14
|
+
Environment,
|
15
|
+
)
|
4
16
|
from .dkg_node import UAL # NOQA: F401
|
5
17
|
from .encoding import BytesLike, DataHexStr, HexStr # NOQA: F401
|
6
18
|
from .evm import Address, ChecksumAddress, Wei # NOQA: F401
|
dkg/types/general.py
CHANGED
@@ -17,28 +17,35 @@
|
|
17
17
|
|
18
18
|
from enum import Enum
|
19
19
|
|
20
|
+
|
20
21
|
class AutoStrEnum(str, Enum):
|
21
22
|
@staticmethod
|
22
|
-
def _generate_next_value_(
|
23
|
+
def _generate_next_value_(
|
24
|
+
name: str, start: int, count: int, last_values: list
|
25
|
+
) -> str:
|
23
26
|
return name.lower()
|
24
|
-
|
27
|
+
|
25
28
|
def __str__(self):
|
26
29
|
return str(self.value)
|
27
|
-
|
30
|
+
|
28
31
|
|
29
32
|
class AutoStrEnumCapitalize(str, Enum):
|
30
33
|
@staticmethod
|
31
|
-
def _generate_next_value_(
|
34
|
+
def _generate_next_value_(
|
35
|
+
name: str, start: int, count: int, last_values: list
|
36
|
+
) -> str:
|
32
37
|
return name.capitalize()
|
33
|
-
|
38
|
+
|
34
39
|
def __str__(self):
|
35
40
|
return str(self.value)
|
36
41
|
|
37
42
|
|
38
43
|
class AutoStrEnumUpperCase(str, Enum):
|
39
44
|
@staticmethod
|
40
|
-
def _generate_next_value_(
|
45
|
+
def _generate_next_value_(
|
46
|
+
name: str, start: int, count: int, last_values: list
|
47
|
+
) -> str:
|
41
48
|
return name
|
42
|
-
|
49
|
+
|
43
50
|
def __str__(self):
|
44
|
-
return str(self.value)
|
51
|
+
return str(self.value)
|
dkg/utils/blockchain_request.py
CHANGED
@@ -70,7 +70,7 @@ class BlockchainRequest:
|
|
70
70
|
allowance = ContractCall(
|
71
71
|
contract="Token",
|
72
72
|
function="allowance",
|
73
|
-
args={"owner": Address, "spender": Address}
|
73
|
+
args={"owner": Address, "spender": Address},
|
74
74
|
)
|
75
75
|
increase_allowance = ContractTransaction(
|
76
76
|
contract="Token",
|
@@ -148,6 +148,13 @@ class BlockchainRequest:
|
|
148
148
|
args={"assertionId": bytes | HexStr},
|
149
149
|
)
|
150
150
|
|
151
|
+
# Identity
|
152
|
+
get_identity_id = ContractCall(
|
153
|
+
contract="IdentityStorage",
|
154
|
+
function="getIdentityId",
|
155
|
+
args={"operational": Address},
|
156
|
+
)
|
157
|
+
|
151
158
|
# Paranets
|
152
159
|
register_paranet = ContractTransaction(
|
153
160
|
contract="Paranet",
|
@@ -157,8 +164,121 @@ class BlockchainRequest:
|
|
157
164
|
"paranetKATokenId": int,
|
158
165
|
"paranetName": str,
|
159
166
|
"paranetDescription": str,
|
167
|
+
"nodesAccessPolicy": int,
|
168
|
+
"minersAccessPolicy": int,
|
169
|
+
},
|
170
|
+
)
|
171
|
+
|
172
|
+
add_paranet_curated_nodes = ContractTransaction(
|
173
|
+
contract="Paranet",
|
174
|
+
function="addParanetCuratedNodes",
|
175
|
+
args={
|
176
|
+
"paranetKAStorageContract": Address,
|
177
|
+
"paranetKATokenId": int,
|
178
|
+
"identityIds": list[int],
|
179
|
+
},
|
180
|
+
)
|
181
|
+
|
182
|
+
remove_paranet_curated_nodes = ContractTransaction(
|
183
|
+
contract="Paranet",
|
184
|
+
function="removeParanetCuratedNodes",
|
185
|
+
args={
|
186
|
+
"paranetKAStorageContract": Address,
|
187
|
+
"paranetKATokenId": int,
|
188
|
+
"identityIds": list[int],
|
189
|
+
},
|
190
|
+
)
|
191
|
+
|
192
|
+
request_paranet_curated_node_access = ContractTransaction(
|
193
|
+
contract="Paranet",
|
194
|
+
function="requestParanetCuratedNodeAccess",
|
195
|
+
args={
|
196
|
+
"paranetKAStorageContract": Address,
|
197
|
+
"paranetKATokenId": int,
|
198
|
+
},
|
199
|
+
)
|
200
|
+
|
201
|
+
approve_curated_node = ContractTransaction(
|
202
|
+
contract="Paranet",
|
203
|
+
function="approveCuratedNode",
|
204
|
+
args={
|
205
|
+
"paranetKAStorageContract": Address,
|
206
|
+
"paranetKATokenId": int,
|
207
|
+
"identityId": int,
|
160
208
|
},
|
161
209
|
)
|
210
|
+
|
211
|
+
reject_curated_node = ContractTransaction(
|
212
|
+
contract="Paranet",
|
213
|
+
function="rejectCuratedNode",
|
214
|
+
args={
|
215
|
+
"paranetKAStorageContract": Address,
|
216
|
+
"paranetKATokenId": int,
|
217
|
+
"identityId": int,
|
218
|
+
},
|
219
|
+
)
|
220
|
+
|
221
|
+
get_curated_nodes = ContractCall(
|
222
|
+
contract="ParanetsRegistry",
|
223
|
+
function="getCuratedNodes",
|
224
|
+
args={"paranetId": HexStr},
|
225
|
+
)
|
226
|
+
|
227
|
+
add_paranet_curated_miners = ContractTransaction(
|
228
|
+
contract="Paranet",
|
229
|
+
function="addParanetCuratedMiners",
|
230
|
+
args={
|
231
|
+
"paranetKAStorageContract": Address,
|
232
|
+
"paranetKATokenId": int,
|
233
|
+
"minerAddresses": list[Address],
|
234
|
+
},
|
235
|
+
)
|
236
|
+
|
237
|
+
remove_paranet_curated_miners = ContractTransaction(
|
238
|
+
contract="Paranet",
|
239
|
+
function="removeParanetCuratedMiners",
|
240
|
+
args={
|
241
|
+
"paranetKAStorageContract": Address,
|
242
|
+
"paranetKATokenId": int,
|
243
|
+
"minerAddresses": list[Address],
|
244
|
+
},
|
245
|
+
)
|
246
|
+
|
247
|
+
request_paranet_curated_miner_access = ContractTransaction(
|
248
|
+
contract="Paranet",
|
249
|
+
function="requestParanetCuratedMinerAccess",
|
250
|
+
args={
|
251
|
+
"paranetKAStorageContract": Address,
|
252
|
+
"paranetKATokenId": int,
|
253
|
+
},
|
254
|
+
)
|
255
|
+
|
256
|
+
approve_curated_miner = ContractTransaction(
|
257
|
+
contract="Paranet",
|
258
|
+
function="approveCuratedMiner",
|
259
|
+
args={
|
260
|
+
"paranetKAStorageContract": Address,
|
261
|
+
"paranetKATokenId": int,
|
262
|
+
"minerAddress": Address,
|
263
|
+
},
|
264
|
+
)
|
265
|
+
|
266
|
+
reject_curated_miner = ContractTransaction(
|
267
|
+
contract="Paranet",
|
268
|
+
function="rejectCuratedMiner",
|
269
|
+
args={
|
270
|
+
"paranetKAStorageContract": Address,
|
271
|
+
"paranetKATokenId": int,
|
272
|
+
"minerAddress": Address,
|
273
|
+
},
|
274
|
+
)
|
275
|
+
|
276
|
+
get_knowledge_miners = ContractCall(
|
277
|
+
contract="ParanetsRegistry",
|
278
|
+
function="getKnowledgeMiners",
|
279
|
+
args={"paranetId": HexStr},
|
280
|
+
)
|
281
|
+
|
162
282
|
add_paranet_services = ContractTransaction(
|
163
283
|
contract="Paranet",
|
164
284
|
function="addParanetServices",
|
dkg/utils/merkle.py
CHANGED
dkg/utils/node_request.py
CHANGED
@@ -21,7 +21,7 @@ from typing import Any, Type
|
|
21
21
|
|
22
22
|
from dkg.dataclasses import BidSuggestionRange, HTTPRequestMethod
|
23
23
|
from dkg.exceptions import OperationFailed, OperationNotFinished
|
24
|
-
from dkg.types import
|
24
|
+
from dkg.types import AutoStrEnumUpperCase, UAL, Address, DataHexStr, NQuads
|
25
25
|
|
26
26
|
|
27
27
|
@dataclass
|
dkg/utils/rdf.py
CHANGED