Skip to content
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

🌐 Dataverse preliminary spec #321

Merged
merged 14 commits into from
Oct 27, 2023
Merged
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
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions contracts/okp4-dataverse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[package]
authors = ["OKP4"]
edition = "2021"
name = "okp4-dataverse"
rust-version = "1.69"
version = "0.0.1"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false

[dependencies]
cosmwasm-schema.workspace = true
cosmwasm-std.workspace = true
cosmwasm-storage.workspace = true
cw-storage-plus.workspace = true
cw-utils.workspace = true
cw2.workspace = true
itertools = "0.11.0"
okp4-logic-bindings.workspace = true
okp4-objectarium-client.workspace = true
okp4-objectarium.workspace = true
schemars.workspace = true
serde.workspace = true
thiserror.workspace = true

[dev-dependencies]
cw-multi-test.workspace = true
url = "2.4.0"

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""
12 changes: 12 additions & 0 deletions contracts/okp4-dataverse/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tasks.generate_schema]
args = ["run", "--bin", "schema"]
command = "cargo"

[tasks.schema]
dependencies = ["generate_schema"]
script = '''
SCHEMA=$(find schema -type f -maxdepth 1 -name '*.json' -print0)
TITLE=$(jq -r .contract_name $SCHEMA)
jq --arg description "$(cat README.md)" '. + {description: $description}' $SCHEMA > $SCHEMA.tmp && mv $SCHEMA.tmp $SCHEMA
jq --arg title $TITLE '. + {title: $title}' $SCHEMA > $SCHEMA.tmp && mv $SCHEMA.tmp $SCHEMA
'''
15 changes: 15 additions & 0 deletions contracts/okp4-dataverse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Dataverse

## Overview

The `dataverse` smart contract is responsible for overseeing and managing the dataverse. The Dataverse is an ever-expanding universe that encompasses a wide range of digital resources. These include datasets, data processing algorithms, ML algorithm, storage resources, computational resources, identity management solutions, orchestration engines, oracles, and many other resources recorded on the blockchain.

Within the Dataverse, there are defined Zones where specific rules apply. Digital resources recognized within these Zones are the ones compatible with these rules, considering the associated consents. Hence the smart contract also provides mechanisms to manage these Zones, ensuring the implementation of precise governance rules.

## Instances

When the smart contract is instantiated, it creates a Dataverse instance. This instance is separated and isolated from any pre-existing ones, and as many dataverse instances as required can be created.

## Dependencies

Given its role and status, this smart contract serves as the primary access point for the OKP4 protocol to manage all on-chain stored resources. To fulfill its tasks, the smart contract relies on other smart contracts within the OKP4 ecosystem. Notably, it uses the `Cognitarium` smart contract for persisting the Dataverse representation in an ontological form and the `Law Stone` smart contract to establish governance rules.
11 changes: 11 additions & 0 deletions contracts/okp4-dataverse/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use cosmwasm_schema::write_api;

use okp4_dataverse::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: ExecuteMsg,
query: QueryMsg,
}
}

Check warning on line 11 in contracts/okp4-dataverse/src/bin/schema.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/bin/schema.rs#L5-L11

Added lines #L5 - L11 were not covered by tests
45 changes: 45 additions & 0 deletions contracts/okp4-dataverse/src/contract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult};
use cw2::set_contract_version;

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

// version info for migration info
const CONTRACT_NAME: &str = concat!("crates.io:", env!("CARGO_PKG_NAME"));
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut<'_>,
_env: Env,
_info: MessageInfo,
_msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Check warning on line 20 in contracts/okp4-dataverse/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/contract.rs#L20

Added line #L20 was not covered by tests

Err(StdError::generic_err("Not implemented").into())
}

Check warning on line 23 in contracts/okp4-dataverse/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/contract.rs#L22-L23

Added lines #L22 - L23 were not covered by tests

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
_deps: DepsMut<'_>,
_env: Env,
_info: MessageInfo,
_msg: ExecuteMsg,
) -> Result<Response, ContractError> {
Err(StdError::generic_err("Not implemented").into())
}

Check warning on line 33 in contracts/okp4-dataverse/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/contract.rs#L26-L33

Added lines #L26 - L33 were not covered by tests

pub mod execute {}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(_deps: Deps<'_>, _env: Env, _msg: QueryMsg) -> StdResult<Binary> {
Err(StdError::generic_err("Not implemented"))
}

Check warning on line 40 in contracts/okp4-dataverse/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/contract.rs#L38-L40

Added lines #L38 - L40 were not covered by tests

pub mod query {}

#[cfg(test)]
mod tests {}
8 changes: 8 additions & 0 deletions contracts/okp4-dataverse/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use cosmwasm_std::StdError;
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum ContractError {
#[error("{0}")]

Check warning on line 6 in contracts/okp4-dataverse/src/error.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/error.rs#L4-L6

Added lines #L4 - L6 were not covered by tests
Std(#[from] StdError),
}
18 changes: 18 additions & 0 deletions contracts/okp4-dataverse/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![forbid(unsafe_code)]
#![deny(
warnings,
rust_2018_idioms,
trivial_casts,
trivial_numeric_casts,
unused_lifetimes,
unused_import_braces,
unused_qualifications,
unused_qualifications
)]

pub mod contract;
mod error;
pub mod msg;
pub mod state;

pub use crate::error::ContractError;
Loading
Loading