Skip to content

V8 - Paranets & Cleanup #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: v8/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PRIVATE_KEY=
PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ install:
poetry install
pre-commit install

run-demo:
demo:
python3 examples/demo.py

async-demo:
python3 examples/async_demo.py

paranets-demo:
python3 examples/paranets_demo.py

async-paranets-demo:
python3 examples/async_paranets_demo.py

ruff:
ruff check --fix
ruff format
Expand All @@ -15,4 +24,8 @@ help:
@echo "Available commands:"
@echo " install - Install dependencies and set up pre-commit hooks"
@echo " ruff - Format code and fix linting issues using ruff"
@echo " run-demo - Run /examples/demo.py file"
@echo " demo - Run /examples/demo.py file"
@echo " async-demo - Run /examples/async_demo.py file"
@echo " paranet-demo - Run /examples/paranet_demo.py file"
@echo " async-paranet-demo - Run /examples/async_paranet_demo.py file"

45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
<a href="#🚀-getting-started">🚀 Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#library-installation">Library Installation</a></li>
<li><a href="#installation-for-developers">Installation for developers</a></li>
</ul>
</li>
<li><a href="#📄-license">📄 License</a></li>
Expand Down Expand Up @@ -172,21 +173,49 @@ In order to use in the local environment, make sure to [run the local DKG networ

<br/>

### Installation
### Library Installation

Create virtual environment (you can choose any existing folder this command will create configurations and virtual env for python):
Run the command to install dkg.py library using pip:

```bash
pip install dkg
```

pip x:

```bash
pipx install dkg
```

or poetry:

```bash
poetry add dkg
```

<br/>

More information about the library can be found in the [documentation](https://docs.origintrail.io/dkg-v8-current-version/v8-dkg-sdk/dkg-v8-py-client).

---

<br/>

### Installation for developers

Create a virtual environment (you can choose any existing folder). This command will create configurations and virtual env for python:

```bash
python3 -m venv /path/to/folder
```

Inside of previously generated folder you will find activate script in bin folder and run it:
Inside of previously generated folder you will find the 'activate' script in bin folder. Run it:

```bash
source /path/to/folder/bin/activate
```

Install dependencies and configure pre-commit hooks:
Install dependencies and configure pre-commit hooks for linting and formatting:

```bash
make install
Expand All @@ -198,6 +227,12 @@ Now you can run a demo example file (you need to have the local DKG network runn
make run-demo
```

or an async demo example file:

```bash
make run-async-demo
```

<br/>
<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
65 changes: 0 additions & 65 deletions dkg/assertion.py

This file was deleted.

5 changes: 5 additions & 0 deletions dkg/clients/async_dkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from dkg.providers.blockchain.async_blockchain import AsyncBlockchainProvider
from dkg.providers.node.async_node_http import AsyncNodeHTTPProvider
from dkg.services.node_services.async_node_service import AsyncNodeService
from dkg.modules.paranet.async_paranet import AsyncParanet
from dkg.services.blockchain_services.async_blockchain_service import (
AsyncBlockchainService,
)
Expand All @@ -38,6 +39,7 @@ class AsyncDKG(AsyncModule):
asset: AsyncKnowledgeAsset
node: AsyncNode
graph: AsyncGraph
paranet: AsyncParanet

def __init__(
self,
Expand All @@ -58,6 +60,9 @@ def __init__(
),
"node": AsyncNode(self.manager, self.node_service),
"graph": AsyncGraph(self.manager, self.input_service, self.node_service),
"paranet": AsyncParanet(
self.manager, self.input_service, self.blockchain_service
),
}
self._attach_modules(modules)

Expand Down
10 changes: 3 additions & 7 deletions dkg/clients/dkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

from functools import wraps

from dkg.assertion import Assertion
from dkg.modules.asset.asset import KnowledgeAsset
from dkg.modules.graph.graph import Graph
from dkg.managers.manager import DefaultRequestManager
from dkg.modules.module import Module
from dkg.modules.network.network import Network
from dkg.modules.node.node import Node
from dkg.modules.paranet.paranet import Paranet
from dkg.providers import BlockchainProvider, NodeHTTPProvider
Expand All @@ -34,10 +32,8 @@


class DKG(Module):
assertion: Assertion
asset: KnowledgeAsset
paranet: Paranet
network: Network
node: Node
graph: Graph

Expand All @@ -52,15 +48,15 @@ def __init__(
self.initialize_services(config)

modules = {
"assertion": Assertion(self.manager),
"asset": KnowledgeAsset(
self.manager,
self.input_service,
self.node_service,
self.blockchain_service,
),
"paranet": Paranet(self.manager),
"network": Network(self.manager),
"paranet": Paranet(
self.manager, self.input_service, self.blockchain_service
),
"node": Node(self.manager),
"graph": Graph(self.manager, self.input_service, self.node_service),
}
Expand Down
46 changes: 21 additions & 25 deletions dkg/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum, auto
from enum import Enum, auto, StrEnum
from dkg.types import AutoStrEnumUpperCase

# Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -55,33 +55,32 @@ class DefaultParameters(Enum):
GAS_LIMIT_MULTIPLIER: int = 1
PARANET_UAL: None = None
GET_SUBJECT_UAL: bool = False
REPOSITORY: str = "dkg"


class OutputTypes(Enum):
NQUADS: str = "N-QUADS"
JSONLD: str = "JSON-LD"
class OutputTypes(StrEnum):
NQUADS = "N-QUADS"
JSONLD = "JSON-LD"


class Environments(Enum):
DEVELOPMENT: str = "development"
DEVNET: str = "devnet"
TESTNET: str = "testnet"
MAINNET: str = "mainnet"
class Environments(StrEnum):
DEVELOPMENT = "development"
DEVNET = "devnet"
TESTNET = "testnet"
MAINNET = "mainnet"


class BlockchainIds(Enum):
HARDHAT_1: str = "hardhat1:31337"
HARDHAT_2: str = "hardhat2:31337"
BASE_DEVNET: str = "base:84532"
GNOSIS_DEVNET: str = "gnosis:10200"
NEUROWEB_DEVNET: str = "otp:2160"
BASE_TESTNET: str = "base:84532"
GNOSIS_TESTNET: str = "gnosis:10200"
NEUROWEB_TESTNET: str = "otp:20430"
BASE_MAINNET: str = "base:8453"
GNOSIS_MAINNET: str = "gnosis:100"
NEUROWEB_MAINNET: str = "otp:2043"
class BlockchainIds(StrEnum):
HARDHAT_1 = "hardhat1:31337"
HARDHAT_2 = "hardhat2:31337"
BASE_DEVNET = "base:84532"
GNOSIS_DEVNET = "gnosis:10200"
NEUROWEB_DEVNET = "otp:2160"
BASE_TESTNET = "base:84532"
GNOSIS_TESTNET = "gnosis:10200"
NEUROWEB_TESTNET = "otp:20430"
BASE_MAINNET = "base:8453"
GNOSIS_MAINNET = "gnosis:100"
NEUROWEB_MAINNET = "otp:2043"


class OperationStatuses(str, Enum):
Expand Down Expand Up @@ -157,9 +156,6 @@ class OperationStatuses(str, Enum):
},
}

PRIVATE_HISTORICAL_REPOSITORY = "privateHistory"
PRIVATE_CURRENT_REPOSITORY = "privateCurrent"


class Operations(Enum):
PUBLISH = "publish"
Expand Down
39 changes: 39 additions & 0 deletions dkg/data/interfaces/KnowledgeCollection.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,45 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paranetKnowledgeCollectionsRegistry",
"outputs": [
{
"internalType": "contract ParanetKnowledgeCollectionsRegistry",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paranetKnowledgeMinersRegistry",
"outputs": [
{
"internalType": "contract ParanetKnowledgeMinersRegistry",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paranetsRegistry",
"outputs": [
{
"internalType": "contract ParanetsRegistry",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paymasterManager",
Expand Down
Loading