diff --git a/Cargo.lock b/Cargo.lock index 86306f6c..f33654a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,6 +738,27 @@ dependencies = [ "thiserror", ] +[[package]] +name = "okp4-dataverse" +version = "0.0.1" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-multi-test", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw2 1.1.0", + "itertools 0.11.0", + "okp4-logic-bindings", + "okp4-objectarium", + "okp4-objectarium-client", + "schemars", + "serde", + "thiserror", + "url", +] + [[package]] name = "okp4-law-stone" version = "3.0.0" diff --git a/contracts/okp4-dataverse/Cargo.toml b/contracts/okp4-dataverse/Cargo.toml new file mode 100644 index 00000000..97a84be9 --- /dev/null +++ b/contracts/okp4-dataverse/Cargo.toml @@ -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 +""" diff --git a/contracts/okp4-dataverse/Makefile.toml b/contracts/okp4-dataverse/Makefile.toml new file mode 100644 index 00000000..944012e8 --- /dev/null +++ b/contracts/okp4-dataverse/Makefile.toml @@ -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 +''' diff --git a/contracts/okp4-dataverse/README.md b/contracts/okp4-dataverse/README.md new file mode 100644 index 00000000..02ac9e9d --- /dev/null +++ b/contracts/okp4-dataverse/README.md @@ -0,0 +1,3 @@ +# Dataverse + +## Overview diff --git a/contracts/okp4-dataverse/src/bin/schema.rs b/contracts/okp4-dataverse/src/bin/schema.rs new file mode 100644 index 00000000..49846a5c --- /dev/null +++ b/contracts/okp4-dataverse/src/bin/schema.rs @@ -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, + } +} diff --git a/contracts/okp4-dataverse/src/contract.rs b/contracts/okp4-dataverse/src/contract.rs new file mode 100644 index 00000000..833897fe --- /dev/null +++ b/contracts/okp4-dataverse/src/contract.rs @@ -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 { + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + + Err(StdError::generic_err("Not implemented").into()) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + _deps: DepsMut<'_>, + _env: Env, + _info: MessageInfo, + _msg: ExecuteMsg, +) -> Result { + Err(StdError::generic_err("Not implemented").into()) +} + +pub mod execute {} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(_deps: Deps<'_>, _env: Env, _msg: QueryMsg) -> StdResult { + Err(StdError::generic_err("Not implemented").into()) +} + +pub mod query {} + +#[cfg(test)] +mod tests {} diff --git a/contracts/okp4-dataverse/src/error.rs b/contracts/okp4-dataverse/src/error.rs new file mode 100644 index 00000000..7155f592 --- /dev/null +++ b/contracts/okp4-dataverse/src/error.rs @@ -0,0 +1,8 @@ +use cosmwasm_std::StdError; +use thiserror::Error; + +#[derive(Error, Debug, PartialEq)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), +} diff --git a/contracts/okp4-dataverse/src/lib.rs b/contracts/okp4-dataverse/src/lib.rs new file mode 100644 index 00000000..14159c9a --- /dev/null +++ b/contracts/okp4-dataverse/src/lib.rs @@ -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; diff --git a/contracts/okp4-dataverse/src/msg.rs b/contracts/okp4-dataverse/src/msg.rs new file mode 100644 index 00000000..35ae3a80 --- /dev/null +++ b/contracts/okp4-dataverse/src/msg.rs @@ -0,0 +1,28 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; +#[allow(unused_imports)] +use okp4_logic_bindings::AskResponse; + +/// Instantiate message +#[cw_serde] +pub struct InstantiateMsg { + /// A name to give to the dataverse instantiated. + pub name: String, +} + +/// Execute messages +#[cw_serde] +pub enum ExecuteMsg { + Foo, +} + +/// Query messages +#[cw_serde] +#[derive(QueryResponses)] +pub enum QueryMsg { + #[returns(FooResponse)] + Foo, +} + +/// # QueryResponses +#[cw_serde] +pub struct FooResponse {} diff --git a/contracts/okp4-dataverse/src/state.rs b/contracts/okp4-dataverse/src/state.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/contracts/okp4-dataverse/src/state.rs @@ -0,0 +1 @@ +