Skip to content

Commit 01ec4ec

Browse files
authored
[RELEASE] dkg.py v1.0.0 - Paranets (#28)
2 parents 0e967c6 + dc4d2db commit 01ec4ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4703
-8980
lines changed

README.md

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,6 @@ ___
2323
</p>
2424
</div>
2525

26-
</br>
27-
28-
> **Disclaimer: Beta Version**
29-
>
30-
> Welcome to the beta version of our client! This software is currently in the beta testing phase, which means it is not the final release version. As a beta version, it may still contain bugs, undergo frequent updates, and have limited features.
31-
Important Points to Note:
32-
33-
> **Use at Your Own Risk:** While we have made efforts to ensure the stability and reliability of the beta version, there is a possibility of encountering unexpected issues. Please use this software at your own risk.
34-
35-
> **Limited Support:** As this is a beta release, our support resources may be focused on addressing critical bugs and gathering feedback from users. Therefore, support for beta versions may be limited compared to our stable releases.
36-
37-
> **Feedback Appreciated:** Your feedback is invaluable to us. If you encounter any issues, have suggestions, or want to share your experiences with the beta version, please let us know. Your feedback will help us improve the software for the final release.
38-
39-
> **Not for Production Use:** The beta version is intended for testing and evaluation purposes only. It is not recommended for use in a production environment where stability and reliability are crucial.
40-
41-
</br>
42-
4326
<details open>
4427
<summary>
4528
<b>Table of Contents</b>
@@ -60,17 +43,6 @@ Important Points to Note:
6043
<li><a href="#installation">Installation</a></li>
6144
</ul>
6245
</li>
63-
<li>
64-
<a href="#📜-roadmap">📜 Roadmap</a>
65-
<ul>
66-
<li><a href="#1️⃣-pre-development-phase">1️⃣ Pre-development Phase</a></li>
67-
<li><a href="#2️⃣-development-phase">2️⃣ Development Phase</a></li>
68-
<li><a href="#3️⃣-documentation-phase">3️⃣ Documentation Phase</a></li>
69-
<li><a href="#4️⃣-pre-release-phase">4️⃣ Pre-release Phase</a></li>
70-
<li><a href="#5️⃣-release">5️⃣ Release</a></li>
71-
<li><a href="#6️⃣-post-release">6️⃣ Post-release</a></li>
72-
</ul>
73-
</li>
7446
<li><a href="#📄-license">📄 License</a></li>
7547
<li><a href="#🤝-contributing">🤝 Contributing</a></li>
7648
<li><a href="#❤️-thanks-to-all-contributors">❤️ Contributors</a></li>
@@ -221,117 +193,6 @@ python3 examples/demo.py
221193
<br/>
222194
<p align="right">(<a href="#readme-top">back to top</a>)</p>
223195

224-
## 📜 Roadmap
225-
226-
This roadmap outlines the goals for the first major release of the `dkg.py`. Each section represents a stage in the development process and the features we plan to implement.
227-
228-
<details open>
229-
<summary>
230-
231-
### 1️⃣ Pre-development Phase
232-
233-
</summary>
234-
235-
- [x] **Requirement Analysis and Planning**
236-
- [x] Define the project's scope
237-
- [x] Identify the core functionalities
238-
239-
- [x] **Design**
240-
- [x] Plan the library's architecture
241-
- [x] Establish coding standards
242-
243-
- [ ] **Setup Development Environment**
244-
- [x] Setup development, testing and production environments
245-
- [ ] Add pytest config
246-
- [ ] Add mypy config
247-
- [ ] Add tox config ?
248-
- [ ] Setup Continuous Integration (CI) and Continuous Deployment (CD) pipeline
249-
</details>
250-
251-
<details open>
252-
<summary>
253-
254-
### 2️⃣ Development Phase
255-
</summary>
256-
257-
| Feature | Status | Tests coverage |
258-
|:-:|:-:|:-:|
259-
| Get Allowance | 🟩 Completed ||
260-
| Set Allowance | 🟩 Completed ||
261-
| Increase Allowance | 🟩 Completed ||
262-
| Decrease Allowance | 🟩 Completed ||
263-
| Get Bid Suggestion | 🟩 Completed ||
264-
| Create | 🟩 Completed ||
265-
| Transfer | 🟩 Completed ||
266-
| Update | 🟩 Completed ||
267-
| Wait for finalization | 🟥 Not Started ||
268-
| Cancel update | 🟩 Completed ||
269-
| Burn | 🟩 Completed ||
270-
| Get | 🟩 Completed ||
271-
| Query | 🟩 Completed ||
272-
| Extend storing period | 🟩 Completed ||
273-
| Add tokens | 🟩 Completed ||
274-
| Add update tokens | 🟩 Completed ||
275-
| Get owner | 🟩 Completed ||
276-
| Experimental | 🟥 Not Started ||
277-
</details>
278-
279-
<details open>
280-
<summary>
281-
282-
### 3️⃣ Documentation Phase
283-
</summary>
284-
285-
- [ ] Write comprehensive documentation
286-
- [x] Provide examples and use-cases
287-
- [ ] Review and finalize documentation
288-
</details>
289-
290-
<details open>
291-
<summary>
292-
293-
### 4️⃣ Pre-release Phase
294-
</summary>
295-
296-
- [ ] **Beta Release**
297-
- [X] Release a beta version for testing
298-
- [ ] Gather and address feedback
299-
300-
- **Bug Fixes**
301-
- Identify and fix bugs
302-
303-
- [ ] **Final Testing and QA**
304-
- [ ] Perform comprehensive testing
305-
- [ ] Ensure the library meets quality standards
306-
</details>
307-
308-
<details open>
309-
<summary>
310-
311-
### 5️⃣ Release
312-
</summary>
313-
314-
- [ ] Merge the first version into the main branch
315-
- [ ] Release the v1.0.0 of the `dkg.py` library
316-
</details>
317-
318-
<details open>
319-
<summary>
320-
321-
### 6️⃣ Post-release
322-
</summary>
323-
324-
- Monitor for any issues
325-
- Plan for next versions based on user feedback and usage
326-
</details>
327-
328-
<br/>
329-
330-
**Note:** This roadmap is subject to changes. Each step will be accompanied by appropriate documentation, testing and code review to maintain the quality of the library.
331-
332-
<br/>
333-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
334-
335196
## 📄 License
336197

337198
Distributed under the Apache-2.0 License. See `LICENSE` file for more information.

dkg/asset.py

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
from dkg.utils.ual import format_ual, parse_ual
7070

7171

72-
class ContentAsset(Module):
72+
class KnowledgeAsset(Module):
7373
def __init__(self, manager: DefaultRequestManager):
7474
self.manager = manager
7575

@@ -196,6 +196,7 @@ def decrease_allowance(
196196

197197
_get_asset_storage_address = Method(BlockchainRequest.get_asset_storage_address)
198198
_create = Method(BlockchainRequest.create_asset)
199+
_mint_paranet_knowledge_asset = Method(BlockchainRequest.mint_knowledge_asset)
199200

200201
_get_bid_suggestion = Method(NodeRequest.bid_suggestion)
201202
_local_store = Method(NodeRequest.local_store)
@@ -208,6 +209,7 @@ def create(
208209
token_amount: Wei | None = None,
209210
immutable: bool = False,
210211
content_type: Literal["JSON-LD", "N-Quads"] = "JSON-LD",
212+
paranet_ual: UAL | None = None,
211213
) -> dict[str, UAL | HexStr | dict[str, dict[str, str] | TxReceipt]]:
212214
blockchain_id = self.manager.blockchain_provider.blockchain_id
213215
assertions = format_content(content, content_type)
@@ -242,20 +244,54 @@ def create(
242244
result = {"publicAssertionId": public_assertion_id, "operation": {}}
243245

244246
try:
245-
receipt: TxReceipt = self._create(
246-
{
247-
"assertionId": Web3.to_bytes(hexstr=public_assertion_id),
248-
"size": public_assertion_metadata["size"],
249-
"triplesNumber": public_assertion_metadata["triples_number"],
250-
"chunksNumber": public_assertion_metadata["chunks_number"],
251-
"tokenAmount": token_amount,
252-
"epochsNumber": epochs_number,
253-
"scoreFunctionId": DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[
254-
self.manager.blockchain_provider.environment
255-
][blockchain_id],
256-
"immutable_": immutable,
257-
}
258-
)
247+
if paranet_ual is None:
248+
receipt: TxReceipt = self._create(
249+
{
250+
"assertionId": Web3.to_bytes(hexstr=public_assertion_id),
251+
"size": public_assertion_metadata["size"],
252+
"triplesNumber": public_assertion_metadata["triples_number"],
253+
"chunksNumber": public_assertion_metadata["chunks_number"],
254+
"tokenAmount": token_amount,
255+
"epochsNumber": epochs_number,
256+
"scoreFunctionId": DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[
257+
self.manager.blockchain_provider.environment
258+
][blockchain_id],
259+
"immutable_": immutable,
260+
}
261+
)
262+
else:
263+
parsed_paranet_ual = parse_ual(paranet_ual)
264+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
265+
parsed_paranet_ual["contract_address"],
266+
parsed_paranet_ual["token_id"],
267+
)
268+
269+
receipt: TxReceipt = self._mint_paranet_knowledge_asset(
270+
paranet_knowledge_asset_storage,
271+
paranet_knowledge_asset_token_id,
272+
{
273+
"assertionId": Web3.to_bytes(hexstr=public_assertion_id),
274+
"size": public_assertion_metadata["size"],
275+
"triplesNumber": public_assertion_metadata["triples_number"],
276+
"chunksNumber": public_assertion_metadata["chunks_number"],
277+
"tokenAmount": token_amount,
278+
"epochsNumber": epochs_number,
279+
"scoreFunctionId": DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS[
280+
self.manager.blockchain_provider.environment
281+
][blockchain_id],
282+
"immutable_": immutable,
283+
},
284+
)
285+
286+
result["paranetId"] = Web3.to_hex(
287+
Web3.solidity_keccak(
288+
["address", "uint256"],
289+
[
290+
paranet_knowledge_asset_storage,
291+
paranet_knowledge_asset_token_id,
292+
],
293+
)
294+
)
259295
except ContractLogicError as err:
260296
if is_allowance_increased:
261297
self.decrease_allowance(token_amount)
@@ -280,7 +316,7 @@ def create(
280316
"tokenId": token_id,
281317
"assertionId": public_assertion_id,
282318
"assertion": assertions["public"],
283-
"storeType": StoreTypes.TRIPLE.value,
319+
"storeType": StoreTypes.TRIPLE,
284320
}
285321
]
286322

@@ -295,7 +331,7 @@ def create(
295331
sort_pairs=True,
296332
).root,
297333
"assertion": assertions["private"],
298-
"storeType": StoreTypes.TRIPLE.value,
334+
"storeType": StoreTypes.TRIPLE,
299335
}
300336
)
301337

@@ -325,6 +361,42 @@ def create(
325361

326362
return result
327363

364+
_submit_knowledge_asset = Method(BlockchainRequest.submit_knowledge_asset)
365+
366+
def submit_to_paranet(
367+
self, ual: UAL, paranet_ual: UAL
368+
) -> dict[str, UAL | Address | TxReceipt]:
369+
parsed_ual = parse_ual(ual)
370+
knowledge_asset_storage, knowledge_asset_token_id = (
371+
parsed_ual["contract_address"],
372+
parsed_ual["token_id"],
373+
)
374+
375+
parsed_paranet_ual = parse_ual(paranet_ual)
376+
paranet_knowledge_asset_storage, paranet_knowledge_asset_token_id = (
377+
parsed_paranet_ual["contract_address"],
378+
parsed_paranet_ual["token_id"],
379+
)
380+
381+
receipt: TxReceipt = self._submit_knowledge_asset(
382+
paranet_knowledge_asset_storage,
383+
paranet_knowledge_asset_token_id,
384+
knowledge_asset_storage,
385+
knowledge_asset_token_id,
386+
)
387+
388+
return {
389+
"UAL": ual,
390+
"paranetUAL": paranet_ual,
391+
"paranetId": Web3.to_hex(
392+
Web3.solidity_keccak(
393+
["address", "uint256"],
394+
[knowledge_asset_storage, knowledge_asset_token_id],
395+
)
396+
),
397+
"operation": json.loads(Web3.to_json(receipt)),
398+
}
399+
328400
_transfer = Method(BlockchainRequest.transfer_asset)
329401

330402
def transfer(
@@ -430,7 +502,7 @@ def update(
430502
"tokenId": token_id,
431503
"assertionId": public_assertion_id,
432504
"assertion": assertions["public"],
433-
"storeType": StoreTypes.PENDING.value,
505+
"storeType": StoreTypes.PENDING,
434506
}
435507
]
436508

@@ -445,7 +517,7 @@ def update(
445517
sort_pairs=True,
446518
).root,
447519
"assertion": assertions["private"],
448-
"storeType": StoreTypes.PENDING.value,
520+
"storeType": StoreTypes.PENDING,
449521
}
450522
)
451523

@@ -463,7 +535,7 @@ def update(
463535
operation_result = self.get_operation_result(operation_id, "update")
464536

465537
return {
466-
"UAL": format_ual(blockchain_id, content_asset_storage_address, token_id),
538+
"UAL": ual,
467539
"publicAssertionId": public_assertion_id,
468540
"operation": {
469541
"operationId": operation_id,

dkg/constants.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
"hub": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
3030
"rpc": "http://localhost:9545",
3131
},
32-
"otp:2043": {
33-
"hub": "0x7585a99C5C150a08f5CDeFD16465C6De8D41EbbD",
34-
"rpc": "http://parachain-alphanet-02.origin-trail.network:9933",
35-
},
3632
},
3733
"devnet": {
3834
"otp:2160": {
@@ -44,6 +40,10 @@
4440
"rpc": "https://rpc.chiadochain.net",
4541
"gas_price_oracle": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle",
4642
},
43+
"base:84532": {
44+
"hub": "0x6C861Cb69300C34DfeF674F7C00E734e840C29C0",
45+
"rpc": "https://sepolia.base.org",
46+
}
4747
},
4848
"testnet": {
4949
"otp:20430": {
@@ -55,6 +55,10 @@
5555
"rpc": "https://rpc.chiadochain.net",
5656
"gas_price_oracle": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle",
5757
},
58+
"base:84532": {
59+
"hub": "0x144eDa5cbf8926327cb2cceef168A121F0E4A299",
60+
"rpc": "https://sepolia.base.org",
61+
}
5862
},
5963
"mainnet": {
6064
"otp:2043": {

0 commit comments

Comments
 (0)