diff --git a/.gitignore b/.gitignore index 48b3822..b83f62d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ target/ artifacts packages/*/schema -contracts/*/schema diff --git a/Cargo.lock b/Cargo.lock index 1327a77..2e420fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -508,13 +508,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b81b8c4647f13be38baea7345885fcd97cffe8ad4e0454a43f975be9609127ed" dependencies = [ "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "schemars", "serde", "thiserror", ] +[[package]] +name = "cw-multi-test" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f9a8ab7c3c29ec93cb7a39ce4b14a05e053153b4a17ef7cf2246af1b7c087e" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus 0.13.4", + "cw-utils 0.13.4", + "derivative", + "itertools", + "prost", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw-multi-test" version = "0.14.0" @@ -524,7 +543,7 @@ dependencies = [ "anyhow", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "derivative", "itertools", @@ -534,6 +553,17 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-storage-plus" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + [[package]] name = "cw-storage-plus" version = "0.14.0" @@ -564,7 +594,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "414b91f3d7a619bb26c835119d7095804596a1382ddc1d184c33c1d2c17f6c5e" dependencies = [ "cosmwasm-std", - "cw2", + "cw2 0.14.0", "schemars", "semver", "serde", @@ -588,11 +618,11 @@ version = "0.14.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "cw1", "cw1-whitelist", - "cw2", + "cw2 0.14.0", "cyber-std 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "semver", @@ -608,11 +638,11 @@ dependencies = [ "assert_matches", "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus", + "cw-multi-test 0.14.0", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "cw1", - "cw2", + "cw2 0.14.0", "cyber-std 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "derivative", "schemars", @@ -620,6 +650,18 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw2" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus 0.13.4", + "schemars", + "serde", +] + [[package]] name = "cw2" version = "0.14.0" @@ -627,7 +669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa74c324af8e3506fd8d50759a265bead3f87402e413c840042af5d2808463d6" dependencies = [ "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "schemars", "serde", ] @@ -651,9 +693,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e39bf97c985a50f2e340833137b3f14999f58708c4ca9928cd8f87d530c4109c" dependencies = [ "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", - "cw2", + "cw2 0.14.0", "cw20", "schemars", "semver", @@ -679,10 +721,10 @@ version = "0.14.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus", + "cw-multi-test 0.14.0", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", - "cw2", + "cw2 0.14.0", "cw20", "cw20-base", "cw3", @@ -698,10 +740,10 @@ version = "0.14.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus", + "cw-multi-test 0.14.0", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", - "cw2", + "cw2 0.14.0", "cw3", "cw3-fixed-multisig", "cw4", @@ -719,7 +761,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95dcc5320bdee5475aadfe7ebce70be5d98040bf91b44b7c22d3acd0c133c329" dependencies = [ "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "schemars", "serde", ] @@ -732,9 +774,9 @@ checksum = "93204a7aa587466636d001b21831c4b4ac87fccd40c7b39f78ad95dee452309e" dependencies = [ "cosmwasm-std", "cw-controllers", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", - "cw2", + "cw2 0.14.0", "cw4", "schemars", "serde", @@ -786,8 +828,8 @@ version = "0.2.2" dependencies = [ "anyhow", "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus", + "cw-multi-test 0.14.0", + "cw-storage-plus 0.14.0", "cyber-std 0.2.2", "schemars", "serde", @@ -1030,7 +1072,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "cw20", "cw20-base", @@ -1046,7 +1088,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "cw20", "cw20-base", @@ -1062,7 +1104,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "cw20", "cw20-base", @@ -1078,7 +1120,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", + "cw-storage-plus 0.14.0", "cw-utils 0.14.0", "cw20", "cw20-base", @@ -1221,6 +1263,111 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "hub-channels" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.13.4", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "hub-contracts" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.13.4", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "hub-libs" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.13.4", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "hub-networks" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.13.4", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "hub-protocols" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.13.4", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "hub-skills" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.14.0", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "hub-tokens" +version = "0.1.0" +dependencies = [ + "cid", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test 0.13.4", + "cw-storage-plus 0.13.4", + "cw2 0.13.4", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "ibc-reflect" version = "0.0.0" @@ -1229,7 +1376,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-storage", "cosmwasm-vm", - "cw-multi-test", + "cw-multi-test 0.14.0", "cyber-std 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "serde", @@ -1243,7 +1390,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-storage", "cosmwasm-vm", - "cw-multi-test", + "cw-multi-test 0.14.0", "cyber-std 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "serde", @@ -1687,7 +1834,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-storage", "cosmwasm-vm", - "cw-multi-test", + "cw-multi-test 0.14.0", "cyber-std 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "serde", diff --git a/Cargo.toml b/Cargo.toml index ccf8c5f..9d64095 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,30 @@ incremental = false codegen-units = 1 incremental = false +[profile.release.package.hub-channels] +codegen-units = 1 +incremental = false + +[profile.release.package.hub-contracts] +codegen-units = 1 +incremental = false + +[profile.release.package.hub-networks] +codegen-units = 1 +incremental = false + +[profile.release.package.hub-protocols] +codegen-units = 1 +incremental = false + +[profile.release.package.hub-skills] +codegen-units = 1 +incremental = false + +[profile.release.package.hub-tokens] +codegen-units = 1 +incremental = false + [profile.release] rpath = false lto = true diff --git a/contracts/cw-cyb-channels/examples/schema.rs b/contracts/cw-cyb-channels/examples/schema.rs deleted file mode 100644 index 237e888..0000000 --- a/contracts/cw-cyb-channels/examples/schema.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw_cyb_channels::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); -} diff --git a/contracts/cw-cyb-contract/examples/schema.rs b/contracts/cw-cyb-contract/examples/schema.rs deleted file mode 100644 index 1522f1b..0000000 --- a/contracts/cw-cyb-contract/examples/schema.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw_cyb_contract::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); -} diff --git a/contracts/cw-cyb-endpoints/Cargo.toml b/contracts/cw-cyb-endpoints/Cargo.toml deleted file mode 100644 index 148d075..0000000 --- a/contracts/cw-cyb-endpoints/Cargo.toml +++ /dev/null @@ -1,53 +0,0 @@ -[package] -name = "cw-cyb-endpoints" -version = "0.1.0" -authors = ["Bloqhub"] -edition = "2018" - -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] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - -[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.6 -""" - -[dependencies] -cosmwasm-std = { version = "1.0.0", features = ["iterator", "abort"] } -cw-storage-plus = { version = "0.13.4" } -cw2 = { version = "0.13.4" } -schemars = "0.8.10" -serde = { version = "1.0.140", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.31" } -cid = { version = "0.8.0" } - -[dev-dependencies] -cosmwasm-schema = "1.0.0" -cw-multi-test = "0.13.2" diff --git a/contracts/cw-cyb-endpoints/examples/schema.rs b/contracts/cw-cyb-endpoints/examples/schema.rs deleted file mode 100644 index 9942cb2..0000000 --- a/contracts/cw-cyb-endpoints/examples/schema.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw_cyb_endpoints::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); -} diff --git a/contracts/cw-cyb-endpoints/src/msg.rs b/contracts/cw-cyb-endpoints/src/msg.rs deleted file mode 100644 index 0b8face..0000000 --- a/contracts/cw-cyb-endpoints/src/msg.rs +++ /dev/null @@ -1,55 +0,0 @@ -use crate::state::{Entry}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct InstantiateMsg { - pub owner: Option, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub enum ExecuteMsg { - NewEntry { - data_type: String, - protocol: String, - chain_id: String, - url: String, - particle: Option, - }, - UpdateEntry { - id: u64, - data_type: String, - protocol: String, - chain_id: String, - url: String, - particle: Option, - }, - DeleteEntry { - id: u64, - }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - GetItems { - start_after: Option, - limit: Option, - }, -} - -// Tokens -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct EntryResponse { - pub id: u64, - pub data_type: String, - pub protocol: u64, - pub chain_id: String, - pub url: String, - pub particle: String, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct ListResponse { - pub entries: Vec, -} diff --git a/contracts/cw-cyb-endpoints/src/query.rs b/contracts/cw-cyb-endpoints/src/query.rs deleted file mode 100644 index e4548dd..0000000 --- a/contracts/cw-cyb-endpoints/src/query.rs +++ /dev/null @@ -1,161 +0,0 @@ -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, -}; - -use cw_storage_plus::Bound; -use std::ops::Add; - - -use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, CONFIG, ENTRY_SEQ, LIST}; -use crate::validating::{validate_particle,validate_by_basic_rule,validate_url}; - -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 20; - - -pub fn execute_create_new_item( - deps: DepsMut, - info: MessageInfo, - data_type: String, - protocol: String, - chain_id: String, - url: String, - particle: Option, -) -> Result { - let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { - return Err(ContractError::Unauthorized {}); - } - - - - let validate_url_result = validate_url(url.clone()); - let validate_particle = validate_particle(particle.clone()); - let validate_data_type = validate_by_basic_rule(data_type.clone(), "data-type".to_string()); - let validate_protocol = validate_by_basic_rule(protocol.clone(), "protocol".to_string()); - let validate_chainid = validate_by_basic_rule(chain_id.clone(), "chain_id".to_string()); - - if validate_particle.is_err() { - return validate_particle; - } - if validate_data_type.is_err() { - return validate_data_type; - } - if validate_url_result.is_err() { - return validate_url_result; - } - if validate_protocol.is_err() { - return validate_protocol; - } - if validate_chainid.is_err() { - return validate_chainid; - } - - - - - let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; - - let new_entry = Entry { - id, - data_type, - protocol, - chain_id, - url, - particle: particle.unwrap_or("".to_string()).to_string(), - }; - LIST.save(deps.storage, id, &new_entry)?; - Ok(Response::new() - .add_attribute("method", "execute_create_new_item") - .add_attribute("new_entry_id", id.to_string())) -} - -pub fn execute_update_item( - deps: DepsMut, - info: MessageInfo, - id: u64, - data_type: String, - protocol: String, - chain_id: String, - url: String, - particle: Option, -) -> Result { - let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { - return Err(ContractError::Unauthorized {}); - } - - let validate_url_result = validate_url(url.clone()); - let validate_particle = validate_particle(particle.clone()); - let validate_data_typer = validate_by_basic_rule(data_type.clone(), "data-type".to_string()); - let validate_protocol = validate_by_basic_rule(protocol.clone(), "protocol".to_string()); - let validate_chainid = validate_by_basic_rule(chain_id.clone(), "chain_id".to_string()); - - if validate_particle.is_err() { - return validate_particle; - } - if validate_data_typer.is_err() { - return validate_data_typer; - } - if validate_url_result.is_err() { - return validate_url_result; - } - if validate_protocol.is_err() { - return validate_protocol; - } - if validate_chainid.is_err() { - return validate_chainid; - } - - - - let entry = LIST.load(deps.storage, id)?; - let updated_entry = Entry { - id, - data_type, - protocol, - chain_id, - url, - particle: particle.unwrap_or("".to_string()).to_string(), - }; - LIST.save(deps.storage, id, &updated_entry)?; - Ok(Response::new() - .add_attribute("method", "execute_update_item") - .add_attribute("updated_entry_id", id.to_string())) -} - -pub fn execute_delete_entry( - deps: DepsMut, - info: MessageInfo, - id: u64, -) -> Result { - let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { - return Err(ContractError::Unauthorized {}); - } - - LIST.remove(deps.storage, id); - Ok(Response::new() - .add_attribute("method", "execute_delete_entry") - .add_attribute("deleted_entry_id", id.to_string())) -} - - - - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - let entries: StdResult> = LIST - .range(deps.storage, start, None, Order::Ascending) - .take(limit) - .collect(); - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/cw-cyb-heroes/Cargo.toml b/contracts/cw-cyb-heroes/Cargo.toml deleted file mode 100644 index d60ba1b..0000000 --- a/contracts/cw-cyb-heroes/Cargo.toml +++ /dev/null @@ -1,53 +0,0 @@ -[package] -name = "cw-cyb-heroes" -version = "0.1.0" -authors = ["Bloqhub"] -edition = "2018" - -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] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - -[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.6 -""" - -[dependencies] -cosmwasm-std = { version = "1.0.0", features = ["iterator", "abort"] } -cw-storage-plus = { version = "0.14.0" } -cw2 = { version = "0.13.4" } -schemars = "0.8.10" -serde = { version = "1.0.140", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.31" } -cid = { version = "0.8.0" } - -[dev-dependencies] -cosmwasm-schema = "1.0.0" -cw-multi-test = "0.13.2" diff --git a/contracts/cw-cyb-heroes/src/contract.rs b/contracts/cw-cyb-heroes/src/contract.rs deleted file mode 100644 index 49063f5..0000000 --- a/contracts/cw-cyb-heroes/src/contract.rs +++ /dev/null @@ -1,77 +0,0 @@ -use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, -}; -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; - -use cw2::set_contract_version; - -use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor -use crate::state::{Config, CONFIG, ENTRY_SEQ}; - -//@TODO git version iteract -const CONTRACT_NAME: &str = "cw-heroes"; -const CONTRACT_VERSION: &str = "1.0.0"; - -#[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)?; - - let owner = msg - .owner - .and_then(|addr_string| deps.api.addr_validate(addr_string.as_str()).ok()) - .unwrap_or(info.sender); - - let config = Config { - owner: owner.clone(), - }; - CONFIG.save(deps.storage, &config)?; - - ENTRY_SEQ.save(deps.storage, &0u64)?; - - Ok(Response::new() - .add_attribute("method", "instantiate") - .add_attribute("owner", owner)) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::NewEntry { - address, - chain_id, - particle, - } => execute_create_new_item(deps, info, address, chain_id,particle), - ExecuteMsg::UpdateEntry { - id, - address, - chain_id, - particle, - } => execute_update_item(deps, info, id, address, chain_id, particle), - ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), - } -} - - - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::GetItems { start_after, limit, id, owner } => { - to_binary(&query_list(deps, start_after, limit, id, owner)?) - } - } -} \ No newline at end of file diff --git a/contracts/cw-cyb-heroes/src/query.rs b/contracts/cw-cyb-heroes/src/query.rs deleted file mode 100644 index ee06be5..0000000 --- a/contracts/cw-cyb-heroes/src/query.rs +++ /dev/null @@ -1,175 +0,0 @@ -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, Addr, -}; - -// use cw_storage_plus::Bound; -use std::ops::Add; - -use crate::validating::{validate_by_basic_rule,validate_ipfs_cid}; -use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, ENTRY_SEQ, items}; - -const MAX_LIMIT: u32 = 50; -const DEFAULT_LIMIT: u32 = 30; - -pub fn uniq_key_by_owner(owner: Addr, id: u64) -> (Addr, u64) { - (owner.clone(), id.clone()) -} - -pub fn execute_create_new_item( - deps: DepsMut, - info: MessageInfo, - address: String, - chain_id: String, - particle: Option, -) -> Result { - - if !particle.as_ref().is_none() { - let validate_particle = validate_ipfs_cid(particle.clone().unwrap(),"particle".to_string()); - if validate_particle.is_err() { - return validate_particle; - } - } - - - let validate_address = validate_by_basic_rule(address.clone(), "address".to_string()); - let validate_chain_id = validate_by_basic_rule(chain_id.clone(), "chain_id".to_string()); - - if validate_address.is_err() { - return validate_address; - } - if validate_chain_id.is_err() { - return validate_chain_id; - } - - - - - let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; - - let new_entry = Entry { - id, - address, - chain_id, - owner: info.sender, - particle: particle.unwrap_or("".to_string()) - }; - - - items().save(deps.storage, id, &new_entry)?; - Ok(Response::new() - .add_attribute("method", "execute_create_new_item") - .add_attribute("new_entry_id", id.to_string())) -} - -pub fn execute_update_item( - deps: DepsMut, - info: MessageInfo, - id: u64, - address: Option, - chain_id: Option, - particle: Option, -) -> Result { - // let owner = CONFIG.load(deps.storage)?.owner; - // if info.sender != owner { - // return Err(ContractError::Unauthorized {}); - // } - - if !particle.as_ref().is_none() { - let validate_particle = validate_ipfs_cid(particle.clone().unwrap(),"particle".to_string()); - if validate_particle.is_err() { - return validate_particle; - } - } - - let validate_address = validate_by_basic_rule(address.clone().unwrap(), "address".to_string()); - let validate_chain_id = validate_by_basic_rule(chain_id.clone().unwrap(), "chain_id".to_string()); - - if validate_address.is_err() { - return validate_address; - } - if validate_chain_id.is_err() { - return validate_chain_id; - } - - - let entry = items().load(deps.storage, id)?; - - if entry.owner != info.sender { - return Err(ContractError::Unauthorized {}); - } - - - let updated_entry = Entry { - id, - address: address.unwrap_or(entry.address), - chain_id: chain_id.unwrap_or(entry.chain_id), - owner: entry.owner, - particle: particle.unwrap_or("".to_string()), - }; - items().save(deps.storage, id, &updated_entry)?; - Ok(Response::new() - .add_attribute("method", "execute_update_item") - .add_attribute("updated_entry_id", id.to_string())) -} - -pub fn execute_delete_entry( - deps: DepsMut, - info: MessageInfo, - id: u64, -) -> Result { - // let owner = CONFIG.load(deps.storage)?.owner; - // if info.sender != owner { - // return Err(ContractError::Unauthorized {}); - // } - - // let key = uniq_key_by_owner(info.sender, id); - let entry = items().load(deps.storage, id)?; - - if entry.owner != info.sender { - return Err(ContractError::Unauthorized {}); - } - - let _result = items().remove(deps.storage, id); - - - Ok(Response::new() - .add_attribute("method", "execute_delete_entry") - .add_attribute("deleted_entry_id", id.to_string())) -} - - - - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option, id: Option, owner: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - - - - let entries: StdResult> = items() - .idx - .owner - .prefix(owner.clone().unwrap_or(Addr::unchecked("")).to_string()) - .range( - deps.storage, - None, - // Some(Bound::exclusive(( - // owner.clone().unwrap().to_string(), - // // start_after.unwrap() - // // owner.clone().unwrap().to_string(), - // // start_after.unwrap_or_default(), - // ))), - None, - Order::Ascending, - ) - .take(limit) - .collect(); - - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/cw-cyb-heroes/src/state.rs b/contracts/cw-cyb-heroes/src/state.rs deleted file mode 100644 index 4eef657..0000000 --- a/contracts/cw-cyb-heroes/src/state.rs +++ /dev/null @@ -1,54 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Addr; -use cw_storage_plus::{Item, UniqueIndex, IndexList, IndexedMap, Index, MultiIndex}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct Config { - pub owner: Addr, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct Entry { - pub id: u64, - pub address: String, - pub chain_id: String, - pub owner: Addr, - pub particle: String, -} - - -pub const CONFIG: Item = Item::new("config"); -pub const ENTRY_SEQ: Item = Item::new("entry_seq"); - - - -pub struct EntryIndexes<'a> { - pub id: UniqueIndex<'a, u64, Entry>, - pub owner: MultiIndex<'a, String, Entry, String>, - -} - -impl<'a> IndexList for EntryIndexes<'a> { - fn get_indexes(&'_ self) -> Box> + '_> { - let v: Vec<&dyn Index> = vec![&self.owner, &self.id]; - Box::new(v.into_iter()) - } -} - -pub fn items<'a>() -> IndexedMap<'a, u64, Entry, EntryIndexes<'a>> { - let indexes = EntryIndexes { - owner: MultiIndex::new( - |d| (d.owner.clone().to_string()), - "list", - "list_owner" - ), - id: UniqueIndex::new( - |d| (d.id.clone()), - "list_id" - ), - - }; - IndexedMap::new("list", indexes) -} \ No newline at end of file diff --git a/contracts/cw-cyb-heroes/src/tests.rs b/contracts/cw-cyb-heroes/src/tests.rs deleted file mode 100644 index 8673de9..0000000 --- a/contracts/cw-cyb-heroes/src/tests.rs +++ /dev/null @@ -1,214 +0,0 @@ - - -#[cfg(test)] -mod tests { - // use super::*; - // use cosmwasm_std::{Uint64}; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{attr, from_binary, Addr}; - // use std::convert::TryFrom; - use std::vec::Vec; - use crate::state::{Entry, CONFIG, Config}; - use crate::msg::{ ListResponse, QueryMsg, InstantiateMsg, ExecuteMsg}; - // use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; - use crate::contract::{query, execute, instantiate}; - - #[test] - fn proper_initialization() { - let mut deps = mock_dependencies(); - //no owner specified in the instantiation message - let msg = InstantiateMsg { owner: None }; - let env = mock_env(); - let info = mock_info("creator", &[]); - - let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // it worked, let's query the state - let state = CONFIG.load(&deps.storage).unwrap(); - assert_eq!( - state, - Config { - owner: Addr::unchecked("creator".to_string()), - } - ); - //specifying an owner address in the instantiation message - let msg = InstantiateMsg { - owner: Some("specified_owner".to_string()), - }; - - let res = instantiate(deps.as_mut(), env, info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // it worked, let's query the state - let state = CONFIG.load(&deps.storage).unwrap(); - assert_eq!( - state, - Config { - owner: Addr::unchecked("specified_owner".to_string()), - } - ); - } - - #[test] - fn create_update_delete_entry() { - let mut deps = mock_dependencies(); - let env = mock_env(); - let info = mock_info("creator", &[]); - let msg = InstantiateMsg { owner: None }; - - let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_eq!(0, res.messages.len()); - - let msg = ExecuteMsg::NewEntry { - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), - }; - - let res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_eq!( - res.attributes, - vec![ - attr("method", "execute_create_new_item"), - attr("new_entry_id", "1") - ] - ); - - let msg = ExecuteMsg::NewEntry { - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), - }; - - let res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_eq!( - res.attributes, - vec![ - attr("method", "execute_create_new_item"), - attr("new_entry_id", "2") - ] - ); - - // Query the list of entries - let res = query( - deps.as_ref(), - env.clone(), - QueryMsg::GetItems { - start_after: None, - limit: None, - id: None, - // owner: None, - owner: Some(Addr::unchecked("creator")), - }, - ) - .unwrap(); - let list: ListResponse = from_binary(&res).unwrap(); - assert_eq!( - Vec::from([ - Entry { - id: 1, - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), - owner: cosmwasm_std::Addr::unchecked("creator"), - }, - Entry { - id: 2, - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), - owner: cosmwasm_std::Addr::unchecked("creator"), - } - ]), - list.entries - ); - - // Update entry - let message = ExecuteMsg::UpdateEntry { - id: 1, - address: Some("testchain-1".to_string()), - chain_id: Some("testchain-1".to_string()), - particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), - }; - - let res = execute(deps.as_mut(), env.clone(), info.clone(), message).unwrap(); - assert_eq!( - res.attributes, - vec![ - attr("method", "execute_update_item"), - attr("updated_entry_id", "1") - ] - ); - - - - // Query the list of entries - let res = query( - deps.as_ref(), - env.clone(), - QueryMsg::GetItems { - start_after: None, - limit: None, - id: None, - owner: Some(Addr::unchecked("creator")), - }, - ) - .unwrap(); - let list: ListResponse = from_binary(&res).unwrap(); - assert_eq!( - Vec::from([ - Entry { - id: 1, - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), - owner: cosmwasm_std::Addr::unchecked("creator"), - }, - Entry { - id: 2, - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), - owner: cosmwasm_std::Addr::unchecked("creator"), - } - ]), - list.entries - ); - - //Delete Entry - let message = ExecuteMsg::DeleteEntry { id: 1 }; - - let res = execute(deps.as_mut(), env.clone(), info, message).unwrap(); - assert_eq!( - res.attributes, - vec![ - attr("method", "execute_delete_entry"), - attr("deleted_entry_id", "1") - ] - ); - // Query the list of entries - let res = query( - deps.as_ref(), - env, - QueryMsg::GetItems { - start_after: None, - id: None, - owner: Some(Addr::unchecked("creator")), - limit: None, - }, - ) - .unwrap(); - let list: ListResponse = from_binary(&res).unwrap(); - assert_eq!( - Vec::from([Entry { - id: 2, - address: "testchain-1".to_string(), - chain_id: "testchain-1".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), - owner: cosmwasm_std::Addr::unchecked("creator"), - }]), - list.entries - ); - } -} diff --git a/contracts/cw-cyb-network/src/error.rs b/contracts/cw-cyb-network/src/error.rs deleted file mode 100644 index 4d32a11..0000000 --- a/contracts/cw-cyb-network/src/error.rs +++ /dev/null @@ -1,17 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("IncorrectInputData val: {val:?}")] - IncorrectInputData {val: String }, - - #[error("Custom Error val: {val:?}")] - CustomError { val: String }, -} diff --git a/contracts/cw-cyb-network/src/lib.rs b/contracts/cw-cyb-network/src/lib.rs deleted file mode 100644 index b085561..0000000 --- a/contracts/cw-cyb-network/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod query; -pub mod state; -pub mod validating; -mod tests; - -pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-network/src/validating.rs b/contracts/cw-cyb-network/src/validating.rs deleted file mode 100644 index 6fb8473..0000000 --- a/contracts/cw-cyb-network/src/validating.rs +++ /dev/null @@ -1,98 +0,0 @@ -use cid::{Cid, Version}; -use std::str::FromStr; -use crate::error::ContractError; -use cosmwasm_std::{ - Response, -}; - -/** - * Baseic rule /[a-z0-9-]/ - */ -pub fn validate_by_basic_rule( - val: String, - field_name: String, -) -> Result { - - for byte in val.as_bytes().iter() { - // - && 0-9 && a-z - if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field field {}. Allowed expression /[a-z0-9-]/", field_name).to_string()}); - } - } - - Ok(Response::default()) -} - -pub fn validate_datatype( - val: String -) -> Result { - - for byte in val.as_bytes().iter() { - // - && 0-9 && a-z - if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { - return Err(ContractError::IncorrectInputData {val: "Incorrect data-type. a-z0-9- allowed".to_string()}); - } - } - - Ok(Response::default()) -} - -pub fn validate_url( - val: String -) -> Result { - - for byte in val.as_bytes().iter() { - // : / . - _ 0-9 a-z A-Z - if (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { - return Err(ContractError::IncorrectInputData {val: "Incorrect data-type. a-z0-9- allowed".to_string()}); - } - } - - Ok(Response::default()) -} - - -// pub fn validate_particle( -// particle: Option -// ) -> Result { -// // let defaultValue=""; - -// return validate_ipfs_cid(particle.unwrap()) -// // let particle_value:Cid; -// // let try_particle = Cid::from_str(&particle.unwrap().clone()); -// // if try_particle.is_ok() { -// // particle_value = try_particle.unwrap(); - -// // if particle_value.version() != Version::V0 { - -// // return Err(ContractError::IncorrectInputData {val: "Incorrect particle".to_string()}); - -// // } -// // } else { -// // return Err(ContractError::IncorrectInputData {val: "Incorrect particle".to_string()}); -// // } -// // Ok(Response::default()) -// } - -pub fn validate_ipfs_cid( - particle: String -) -> Result { - - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { - - return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); - - } - } else { - return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); - } - Ok(Response::default()) - -} - - diff --git a/contracts/cw-cyb-protocols/Cargo.toml b/contracts/cw-cyb-protocols/Cargo.toml deleted file mode 100644 index 0fa4f8b..0000000 --- a/contracts/cw-cyb-protocols/Cargo.toml +++ /dev/null @@ -1,53 +0,0 @@ -[package] -name = "cw-cyb-protocols" -version = "0.1.0" -authors = ["Bloqhub"] -edition = "2018" - -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] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - -[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.6 -""" - -[dependencies] -cosmwasm-std = { version = "1.0.0", features = ["iterator", "abort"] } -cw-storage-plus = { version = "0.13.4" } -cw2 = { version = "0.13.4" } -schemars = "0.8.10" -serde = { version = "1.0.140", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.31" } -cid = { version = "0.8.0" } - -[dev-dependencies] -cosmwasm-schema = "1.0.0" -cw-multi-test = "0.13.2" diff --git a/contracts/cw-cyb-protocols/examples/schema.rs b/contracts/cw-cyb-protocols/examples/schema.rs deleted file mode 100644 index 81fbbe9..0000000 --- a/contracts/cw-cyb-protocols/examples/schema.rs +++ /dev/null @@ -1,17 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw_cyb_protocols::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); -} diff --git a/contracts/cw-cyb-protocols/src/contract.rs b/contracts/cw-cyb-protocols/src/contract.rs deleted file mode 100644 index 4f6ce51..0000000 --- a/contracts/cw-cyb-protocols/src/contract.rs +++ /dev/null @@ -1,75 +0,0 @@ -use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, -}; -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; - -use cw2::set_contract_version; - -use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor -use crate::state::{Config, CONFIG, ENTRY_SEQ}; - -//@TODO git version iteract -const CONTRACT_NAME: &str = "cw-protocols"; -const CONTRACT_VERSION: &str = "1.0.0"; - -#[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)?; - - let owner = msg - .owner - .and_then(|addr_string| deps.api.addr_validate(addr_string.as_str()).ok()) - .unwrap_or(info.sender); - - let config = Config { - owner: owner.clone(), - }; - CONFIG.save(deps.storage, &config)?; - - ENTRY_SEQ.save(deps.storage, &0u64)?; - - Ok(Response::new() - .add_attribute("method", "instantiate") - .add_attribute("owner", owner)) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::NewEntry { - data_type, - particle, - } => execute_create_new_item(deps, info, data_type, particle), - ExecuteMsg::UpdateEntry { - id, - data_type, - particle, - } => execute_update_item(deps, info, id, data_type, particle), - ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), - } -} - - - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::GetItems { start_after, limit } => { - to_binary(&query_list(deps, start_after, limit)?) - } - } -} \ No newline at end of file diff --git a/contracts/cw-cyb-protocols/src/error.rs b/contracts/cw-cyb-protocols/src/error.rs deleted file mode 100644 index 4d32a11..0000000 --- a/contracts/cw-cyb-protocols/src/error.rs +++ /dev/null @@ -1,17 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("IncorrectInputData val: {val:?}")] - IncorrectInputData {val: String }, - - #[error("Custom Error val: {val:?}")] - CustomError { val: String }, -} diff --git a/contracts/cw-cyb-protocols/src/lib.rs b/contracts/cw-cyb-protocols/src/lib.rs deleted file mode 100644 index b085561..0000000 --- a/contracts/cw-cyb-protocols/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod query; -pub mod state; -pub mod validating; -mod tests; - -pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-skills/src/contract.rs b/contracts/cw-cyb-skills/src/contract.rs deleted file mode 100644 index c8e7686..0000000 --- a/contracts/cw-cyb-skills/src/contract.rs +++ /dev/null @@ -1,79 +0,0 @@ -use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, -}; -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; - -use cw2::set_contract_version; - -use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor -use crate::state::{Config, CONFIG, ENTRY_SEQ}; - -//@TODO git version iteract -const CONTRACT_NAME: &str = "cw-skills"; -const CONTRACT_VERSION: &str = "1.0.0"; - -#[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)?; - - let owner = msg - .owner - .and_then(|addr_string| deps.api.addr_validate(addr_string.as_str()).ok()) - .unwrap_or(info.sender); - - let config = Config { - owner: owner.clone(), - }; - CONFIG.save(deps.storage, &config)?; - - ENTRY_SEQ.save(deps.storage, &0u64)?; - - Ok(Response::new() - .add_attribute("method", "instantiate") - .add_attribute("owner", owner)) -} - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn execute( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::NewEntry { - neuron, - protocol, - endpoint, - particle, - } => execute_create_new_item(deps, info, neuron, protocol,endpoint,particle), - ExecuteMsg::UpdateEntry { - id, - neuron, - protocol, - endpoint, - particle, - } => execute_update_item(deps, info, id, neuron, protocol, endpoint, particle), - ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), - } -} - - - -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::GetItems { start_after, limit, protocol, owner } => { - to_binary(&query_list(deps, start_after, limit, protocol, owner)?) - } - } -} \ No newline at end of file diff --git a/contracts/cw-cyb-skills/src/error.rs b/contracts/cw-cyb-skills/src/error.rs deleted file mode 100644 index 4d32a11..0000000 --- a/contracts/cw-cyb-skills/src/error.rs +++ /dev/null @@ -1,17 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("IncorrectInputData val: {val:?}")] - IncorrectInputData {val: String }, - - #[error("Custom Error val: {val:?}")] - CustomError { val: String }, -} diff --git a/contracts/cw-cyb-skills/src/lib.rs b/contracts/cw-cyb-skills/src/lib.rs deleted file mode 100644 index b085561..0000000 --- a/contracts/cw-cyb-skills/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod query; -pub mod state; -pub mod validating; -mod tests; - -pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-tokens/.cargo/config b/contracts/cw-cyb-tokens/.cargo/config deleted file mode 100644 index 336b618..0000000 --- a/contracts/cw-cyb-tokens/.cargo/config +++ /dev/null @@ -1,4 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -unit-test = "test --lib" -schema = "run --example schema" diff --git a/contracts/cw-cyb-tokens/Cargo.lock b/contracts/cw-cyb-tokens/Cargo.lock deleted file mode 100644 index bd9ed11..0000000 --- a/contracts/cw-cyb-tokens/Cargo.lock +++ /dev/null @@ -1,778 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "0.7.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "base64ct" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdca834647821e0b13d9539a8634eb62d3501b6b6c2cec1722786ee6671b851" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b3de4a0c5e67e16066a0715723abd91edc2f9001d09c46e1dca929351e130e" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const-oid" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" - -[[package]] -name = "cosmwasm-crypto" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" -dependencies = [ - "digest", - "ed25519-zebra", - "k256", - "rand_core 0.6.3", - "thiserror", -] - -[[package]] -name = "cosmwasm-derive" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" -dependencies = [ - "syn", -] - -[[package]] -name = "cosmwasm-schema" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772e80bbad231a47a2068812b723a1ff81dd4a0d56c9391ac748177bea3a61da" -dependencies = [ - "schemars", - "serde_json", -] - -[[package]] -name = "cosmwasm-std" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" -dependencies = [ - "base64", - "cosmwasm-crypto", - "cosmwasm-derive", - "forward_ref", - "schemars", - "serde", - "serde-json-wasm", - "thiserror", - "uint", -] - -[[package]] -name = "cosmwasm-storage" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d18403b07304d15d304dad11040d45bbcaf78d603b4be3fb5e2685c16f9229b5" -dependencies = [ - "cosmwasm-std", - "serde", -] - -[[package]] -name = "cpufeatures" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" -dependencies = [ - "libc", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-bigint" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" -dependencies = [ - "byteorder", - "digest", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "cw-cyb-tokens" -version = "0.1.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cw-multi-test", - "cw-storage-plus", - "cw2", - "regex", - "schemars", - "semver", - "serde", - "thiserror", -] - -[[package]] -name = "cw-multi-test" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f9a8ab7c3c29ec93cb7a39ce4b14a05e053153b4a17ef7cf2246af1b7c087e" -dependencies = [ - "anyhow", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus", - "cw-utils", - "derivative", - "itertools", - "prost", - "schemars", - "serde", - "thiserror", -] - -[[package]] -name = "cw-storage-plus" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648b1507290bbc03a8d88463d7cd9b04b1fa0155e5eef366c4fa052b9caaac7a" -dependencies = [ - "cosmwasm-std", - "schemars", - "serde", -] - -[[package]] -name = "cw-utils" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbaecb78c8e8abfd6b4258c7f4fbeb5c49a5e45ee4d910d3240ee8e1d714e1b" -dependencies = [ - "cosmwasm-std", - "schemars", - "serde", - "thiserror", -] - -[[package]] -name = "cw2" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" -dependencies = [ - "cosmwasm-std", - "cw-storage-plus", - "schemars", - "serde", -] - -[[package]] -name = "der" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" -dependencies = [ - "const-oid", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "dyn-clone" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d07a982d1fb29db01e5a59b1918e03da4df7297eaeee7686ac45542fd4e59c8" - -[[package]] -name = "ecdsa" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "ed25519-zebra" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69" -dependencies = [ - "curve25519-dalek", - "hex", - "rand_core 0.6.3", - "serde", - "sha2", - "thiserror", - "zeroize", -] - -[[package]] -name = "either" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" - -[[package]] -name = "elliptic-curve" -version = "0.11.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "ff", - "generic-array", - "group", - "rand_core 0.6.3", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "ff" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" -dependencies = [ - "rand_core 0.6.3", - "subtle", -] - -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - -[[package]] -name = "generic-array" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "group" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" -dependencies = [ - "ff", - "rand_core 0.6.3", - "subtle", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac", - "digest", -] - -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" - -[[package]] -name = "k256" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sec1", - "sha2", -] - -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "pkcs8" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" -dependencies = [ - "der", - "spki", - "zeroize", -] - -[[package]] -name = "proc-macro2" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "quote" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.7", -] - -[[package]] -name = "regex" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" - -[[package]] -name = "rfc6979" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" -dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", -] - -[[package]] -name = "ryu" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" - -[[package]] -name = "schemars" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1847b767a3d62d95cbf3d8a9f0e421cf57a0d8aa4f411d4b16525afb0284d4ed" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4d7e1b012cb3d9129567661a63755ea4b8a7386d339dc945ae187e403c6743" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn", -] - -[[package]] -name = "sec1" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" -dependencies = [ - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "semver" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" - -[[package]] -name = "serde" -version = "1.0.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-json-wasm" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_derive_internals" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer", - "cfg-if", - "cpufeatures", - "digest", - "opaque-debug", -] - -[[package]] -name = "signature" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" -dependencies = [ - "digest", - "rand_core 0.6.3", -] - -[[package]] -name = "spki" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "typenum" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "uint" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicode-ident" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "zeroize" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" diff --git a/contracts/cw-cyb-tokens/src/error.rs b/contracts/cw-cyb-tokens/src/error.rs deleted file mode 100644 index 4d32a11..0000000 --- a/contracts/cw-cyb-tokens/src/error.rs +++ /dev/null @@ -1,17 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Unauthorized")] - Unauthorized {}, - - #[error("IncorrectInputData val: {val:?}")] - IncorrectInputData {val: String }, - - #[error("Custom Error val: {val:?}")] - CustomError { val: String }, -} diff --git a/contracts/cw-cyb-tokens/src/lib.rs b/contracts/cw-cyb-tokens/src/lib.rs deleted file mode 100644 index b085561..0000000 --- a/contracts/cw-cyb-tokens/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod contract; -mod error; -pub mod msg; -pub mod query; -pub mod state; -pub mod validating; -mod tests; - -pub use crate::error::ContractError; diff --git a/contracts/cw1-subkeys/schema/admin_list_response.json b/contracts/cw1-subkeys/schema/admin_list_response.json new file mode 100644 index 0000000..bc20467 --- /dev/null +++ b/contracts/cw1-subkeys/schema/admin_list_response.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AdminListResponse", + "type": "object", + "required": [ + "admins", + "mutable" + ], + "properties": { + "admins": { + "type": "array", + "items": { + "type": "string" + } + }, + "mutable": { + "type": "boolean" + } + } +} diff --git a/contracts/cw1-subkeys/schema/all_allowances_response.json b/contracts/cw1-subkeys/schema/all_allowances_response.json new file mode 100644 index 0000000..287b750 --- /dev/null +++ b/contracts/cw1-subkeys/schema/all_allowances_response.json @@ -0,0 +1,120 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllAllowancesResponse", + "type": "object", + "required": [ + "allowances" + ], + "properties": { + "allowances": { + "type": "array", + "items": { + "$ref": "#/definitions/AllowanceInfo" + } + } + }, + "definitions": { + "AllowanceInfo": { + "type": "object", + "required": [ + "balance", + "expires", + "spender" + ], + "properties": { + "balance": { + "$ref": "#/definitions/NativeBalance" + }, + "expires": { + "$ref": "#/definitions/Expiration" + }, + "spender": { + "type": "string" + } + } + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "NativeBalance": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/cw1-subkeys/schema/allowance.json b/contracts/cw1-subkeys/schema/allowance.json new file mode 100644 index 0000000..2a8fb26 --- /dev/null +++ b/contracts/cw1-subkeys/schema/allowance.json @@ -0,0 +1,102 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Allowance", + "type": "object", + "required": [ + "balance", + "expires" + ], + "properties": { + "balance": { + "$ref": "#/definitions/NativeBalance" + }, + "expires": { + "$ref": "#/definitions/Expiration" + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "NativeBalance": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/cw1-subkeys/schema/execute_msg.json b/contracts/cw1-subkeys/schema/execute_msg.json new file mode 100644 index 0000000..d1f8872 --- /dev/null +++ b/contracts/cw1-subkeys/schema/execute_msg.json @@ -0,0 +1,700 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "description": "Execute requests the contract to re-dispatch all these messages with the contract's address as sender. Every implementation has it's own logic to determine in", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + } + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Freeze will make a mutable contract immutable, must be called by an admin", + "type": "object", + "required": [ + "freeze" + ], + "properties": { + "freeze": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "UpdateAdmins will change the admin set of the contract, must be called by an existing admin, and only works if the contract is mutable", + "type": "object", + "required": [ + "update_admins" + ], + "properties": { + "update_admins": { + "type": "object", + "required": [ + "admins" + ], + "properties": { + "admins": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Add an allowance to a given subkey (subkey must not be admin)", + "type": "object", + "required": [ + "increase_allowance" + ], + "properties": { + "increase_allowance": { + "type": "object", + "required": [ + "amount", + "spender" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "spender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Decreases an allowance for a given subkey (subkey must not be admin)", + "type": "object", + "required": [ + "decrease_allowance" + ], + "properties": { + "decrease_allowance": { + "type": "object", + "required": [ + "amount", + "spender" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "spender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "set_permissions" + ], + "properties": { + "set_permissions": { + "type": "object", + "required": [ + "permissions", + "spender" + ], + "properties": { + "permissions": { + "$ref": "#/definitions/Permissions" + }, + "spender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + } + ] + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Permissions": { + "type": "object", + "required": [ + "delegate", + "redelegate", + "undelegate", + "withdraw" + ], + "properties": { + "delegate": { + "type": "boolean" + }, + "redelegate": { + "type": "boolean" + }, + "undelegate": { + "type": "boolean" + }, + "withdraw": { + "type": "boolean" + } + } + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw1-subkeys/schema/instantiate_msg.json b/contracts/cw1-subkeys/schema/instantiate_msg.json new file mode 100644 index 0000000..fdcd684 --- /dev/null +++ b/contracts/cw1-subkeys/schema/instantiate_msg.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "admins", + "mutable" + ], + "properties": { + "admins": { + "type": "array", + "items": { + "type": "string" + } + }, + "mutable": { + "type": "boolean" + } + } +} diff --git a/contracts/cw1-subkeys/schema/query_msg.json b/contracts/cw1-subkeys/schema/query_msg.json new file mode 100644 index 0000000..1fc41ea --- /dev/null +++ b/contracts/cw1-subkeys/schema/query_msg.json @@ -0,0 +1,602 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Shows all admins and whether or not it is mutable Returns cw1-whitelist::AdminListResponse", + "type": "object", + "required": [ + "admin_list" + ], + "properties": { + "admin_list": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Get the current allowance for the given subkey (how much it can spend) Returns crate::state::Allowance", + "type": "object", + "required": [ + "allowance" + ], + "properties": { + "allowance": { + "type": "object", + "required": [ + "spender" + ], + "properties": { + "spender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get the current permissions for the given subkey (how much it can spend) Returns PermissionsInfo", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "permissions": { + "type": "object", + "required": [ + "spender" + ], + "properties": { + "spender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Checks permissions of the caller on this proxy. If CanExecute returns true then a call to `Execute` with the same message, before any further state changes, should also succeed.", + "type": "object", + "required": [ + "can_execute" + ], + "properties": { + "can_execute": { + "type": "object", + "required": [ + "msg", + "sender" + ], + "properties": { + "msg": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + }, + "sender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Gets all Allowances for this contract Returns AllAllowancesResponse", + "type": "object", + "required": [ + "all_allowances" + ], + "properties": { + "all_allowances": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Gets all Permissions for this contract Returns AllPermissionsResponse", + "type": "object", + "required": [ + "all_permissions" + ], + "properties": { + "all_permissions": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + } + ] + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw1-whitelist/schema/admin_list_response.json b/contracts/cw1-whitelist/schema/admin_list_response.json new file mode 100644 index 0000000..bc20467 --- /dev/null +++ b/contracts/cw1-whitelist/schema/admin_list_response.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AdminListResponse", + "type": "object", + "required": [ + "admins", + "mutable" + ], + "properties": { + "admins": { + "type": "array", + "items": { + "type": "string" + } + }, + "mutable": { + "type": "boolean" + } + } +} diff --git a/contracts/cw1-whitelist/schema/execute_msg.json b/contracts/cw1-whitelist/schema/execute_msg.json new file mode 100644 index 0000000..50ca31e --- /dev/null +++ b/contracts/cw1-whitelist/schema/execute_msg.json @@ -0,0 +1,525 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "description": "Execute requests the contract to re-dispatch all these messages with the contract's address as sender. Every implementation has it's own logic to determine in", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + } + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Freeze will make a mutable contract immutable, must be called by an admin", + "type": "object", + "required": [ + "freeze" + ], + "properties": { + "freeze": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "UpdateAdmins will change the admin set of the contract, must be called by an existing admin, and only works if the contract is mutable", + "type": "object", + "required": [ + "update_admins" + ], + "properties": { + "update_admins": { + "type": "object", + "required": [ + "admins" + ], + "properties": { + "admins": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + } + ] + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw1-whitelist/schema/instantiate_msg.json b/contracts/cw1-whitelist/schema/instantiate_msg.json new file mode 100644 index 0000000..fdcd684 --- /dev/null +++ b/contracts/cw1-whitelist/schema/instantiate_msg.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "admins", + "mutable" + ], + "properties": { + "admins": { + "type": "array", + "items": { + "type": "string" + } + }, + "mutable": { + "type": "boolean" + } + } +} diff --git a/contracts/cw1-whitelist/schema/query_msg.json b/contracts/cw1-whitelist/schema/query_msg.json new file mode 100644 index 0000000..7ce7782 --- /dev/null +++ b/contracts/cw1-whitelist/schema/query_msg.json @@ -0,0 +1,502 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Shows all admins and whether or not it is mutable", + "type": "object", + "required": [ + "admin_list" + ], + "properties": { + "admin_list": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Checks permissions of the caller on this proxy. If CanExecute returns true then a call to `Execute` with the same message, before any further state changes, should also succeed.", + "type": "object", + "required": [ + "can_execute" + ], + "properties": { + "can_execute": { + "type": "object", + "required": [ + "msg", + "sender" + ], + "properties": { + "msg": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + }, + "sender": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + } + ] + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw3-fixed-multisig/schema/execute_msg.json b/contracts/cw3-fixed-multisig/schema/execute_msg.json new file mode 100644 index 0000000..3c29a4f --- /dev/null +++ b/contracts/cw3-fixed-multisig/schema/execute_msg.json @@ -0,0 +1,642 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "propose" + ], + "properties": { + "propose": { + "type": "object", + "required": [ + "description", + "msgs", + "title" + ], + "properties": { + "description": { + "type": "string" + }, + "latest": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + } + }, + "title": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/Vote" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "close" + ], + "properties": { + "close": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + } + ] + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "Vote": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw3-fixed-multisig/schema/instantiate_msg.json b/contracts/cw3-fixed-multisig/schema/instantiate_msg.json new file mode 100644 index 0000000..6525213 --- /dev/null +++ b/contracts/cw3-fixed-multisig/schema/instantiate_msg.json @@ -0,0 +1,155 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "max_voting_period", + "threshold", + "voters" + ], + "properties": { + "max_voting_period": { + "$ref": "#/definitions/Duration" + }, + "threshold": { + "$ref": "#/definitions/Threshold" + }, + "voters": { + "type": "array", + "items": { + "$ref": "#/definitions/Voter" + } + } + }, + "definitions": { + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "Duration": { + "description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined", + "oneOf": [ + { + "type": "object", + "required": [ + "height" + ], + "properties": { + "height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "Time in seconds", + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + ] + }, + "Threshold": { + "description": "This defines the different ways tallies can happen.\n\nThe total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation). See also `ThresholdResponse` in the cw3 spec.", + "oneOf": [ + { + "description": "Declares that a fixed weight of Yes votes is needed to pass. See `ThresholdResponse.AbsoluteCount` in the cw3 spec for details.", + "type": "object", + "required": [ + "absolute_count" + ], + "properties": { + "absolute_count": { + "type": "object", + "required": [ + "weight" + ], + "properties": { + "weight": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Declares a percentage of the total weight that must cast Yes votes in order for a proposal to pass. See `ThresholdResponse.AbsolutePercentage` in the cw3 spec for details.", + "type": "object", + "required": [ + "absolute_percentage" + ], + "properties": { + "absolute_percentage": { + "type": "object", + "required": [ + "percentage" + ], + "properties": { + "percentage": { + "$ref": "#/definitions/Decimal" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Declares a `quorum` of the total votes that must participate in the election in order for the vote to be considered at all. See `ThresholdResponse.ThresholdQuorum` in the cw3 spec for details.", + "type": "object", + "required": [ + "threshold_quorum" + ], + "properties": { + "threshold_quorum": { + "type": "object", + "required": [ + "quorum", + "threshold" + ], + "properties": { + "quorum": { + "$ref": "#/definitions/Decimal" + }, + "threshold": { + "$ref": "#/definitions/Decimal" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Voter": { + "type": "object", + "required": [ + "addr", + "weight" + ], + "properties": { + "addr": { + "type": "string" + }, + "weight": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + } +} diff --git a/contracts/cw3-fixed-multisig/schema/query_msg.json b/contracts/cw3-fixed-multisig/schema/query_msg.json new file mode 100644 index 0000000..42aea71 --- /dev/null +++ b/contracts/cw3-fixed-multisig/schema/query_msg.json @@ -0,0 +1,218 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Return ThresholdResponse", + "type": "object", + "required": [ + "threshold" + ], + "properties": { + "threshold": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Returns ProposalResponse", + "type": "object", + "required": [ + "proposal" + ], + "properties": { + "proposal": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns ProposalListResponse", + "type": "object", + "required": [ + "list_proposals" + ], + "properties": { + "list_proposals": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns ProposalListResponse", + "type": "object", + "required": [ + "reverse_proposals" + ], + "properties": { + "reverse_proposals": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_before": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoteResponse", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "voter" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "voter": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoteListResponse", + "type": "object", + "required": [ + "list_votes" + ], + "properties": { + "list_votes": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoterInfo", + "type": "object", + "required": [ + "voter" + ], + "properties": { + "voter": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoterListResponse", + "type": "object", + "required": [ + "list_voters" + ], + "properties": { + "list_voters": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw3-flex-multisig/schema/execute_msg.json b/contracts/cw3-flex-multisig/schema/execute_msg.json new file mode 100644 index 0000000..62a3118 --- /dev/null +++ b/contracts/cw3-flex-multisig/schema/execute_msg.json @@ -0,0 +1,698 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "propose" + ], + "properties": { + "propose": { + "type": "object", + "required": [ + "description", + "msgs", + "title" + ], + "properties": { + "description": { + "type": "string" + }, + "latest": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_Empty" + } + }, + "title": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/Vote" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "close" + ], + "properties": { + "close": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Handles update hook messages from the group contract", + "type": "object", + "required": [ + "member_changed_hook" + ], + "properties": { + "member_changed_hook": { + "$ref": "#/definitions/MemberChangedHookMsg" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + } + ] + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "MemberChangedHookMsg": { + "description": "MemberChangedHookMsg should be de/serialized under `MemberChangedHook()` variant in a ExecuteMsg. This contains a list of all diffs on the given transaction.", + "type": "object", + "required": [ + "diffs" + ], + "properties": { + "diffs": { + "type": "array", + "items": { + "$ref": "#/definitions/MemberDiff" + } + } + } + }, + "MemberDiff": { + "description": "MemberDiff shows the old and new states for a given cw4 member They cannot both be None. old = None, new = Some -> Insert old = Some, new = Some -> Update old = Some, new = None -> Delete", + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "string" + }, + "new": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "old": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "Vote": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw3-flex-multisig/schema/instantiate_msg.json b/contracts/cw3-flex-multisig/schema/instantiate_msg.json new file mode 100644 index 0000000..f28f601 --- /dev/null +++ b/contracts/cw3-flex-multisig/schema/instantiate_msg.json @@ -0,0 +1,173 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "group_addr", + "max_voting_period", + "threshold" + ], + "properties": { + "executor": { + "anyOf": [ + { + "$ref": "#/definitions/Executor" + }, + { + "type": "null" + } + ] + }, + "group_addr": { + "type": "string" + }, + "max_voting_period": { + "$ref": "#/definitions/Duration" + }, + "threshold": { + "$ref": "#/definitions/Threshold" + } + }, + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "Duration": { + "description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined", + "oneOf": [ + { + "type": "object", + "required": [ + "height" + ], + "properties": { + "height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "Time in seconds", + "type": "object", + "required": [ + "time" + ], + "properties": { + "time": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + ] + }, + "Executor": { + "description": "Defines who is able to execute proposals once passed", + "oneOf": [ + { + "type": "string", + "enum": [ + "Member" + ] + }, + { + "description": "Only the given address", + "type": "object", + "required": [ + "Only" + ], + "properties": { + "Only": { + "$ref": "#/definitions/Addr" + } + }, + "additionalProperties": false + } + ] + }, + "Threshold": { + "description": "This defines the different ways tallies can happen.\n\nThe total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation). See also `ThresholdResponse` in the cw3 spec.", + "oneOf": [ + { + "description": "Declares that a fixed weight of Yes votes is needed to pass. See `ThresholdResponse.AbsoluteCount` in the cw3 spec for details.", + "type": "object", + "required": [ + "absolute_count" + ], + "properties": { + "absolute_count": { + "type": "object", + "required": [ + "weight" + ], + "properties": { + "weight": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Declares a percentage of the total weight that must cast Yes votes in order for a proposal to pass. See `ThresholdResponse.AbsolutePercentage` in the cw3 spec for details.", + "type": "object", + "required": [ + "absolute_percentage" + ], + "properties": { + "absolute_percentage": { + "type": "object", + "required": [ + "percentage" + ], + "properties": { + "percentage": { + "$ref": "#/definitions/Decimal" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Declares a `quorum` of the total votes that must participate in the election in order for the vote to be considered at all. See `ThresholdResponse.ThresholdQuorum` in the cw3 spec for details.", + "type": "object", + "required": [ + "threshold_quorum" + ], + "properties": { + "threshold_quorum": { + "type": "object", + "required": [ + "quorum", + "threshold" + ], + "properties": { + "quorum": { + "$ref": "#/definitions/Decimal" + }, + "threshold": { + "$ref": "#/definitions/Decimal" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/cw3-flex-multisig/schema/query_msg.json b/contracts/cw3-flex-multisig/schema/query_msg.json new file mode 100644 index 0000000..42aea71 --- /dev/null +++ b/contracts/cw3-flex-multisig/schema/query_msg.json @@ -0,0 +1,218 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Return ThresholdResponse", + "type": "object", + "required": [ + "threshold" + ], + "properties": { + "threshold": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Returns ProposalResponse", + "type": "object", + "required": [ + "proposal" + ], + "properties": { + "proposal": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns ProposalListResponse", + "type": "object", + "required": [ + "list_proposals" + ], + "properties": { + "list_proposals": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns ProposalListResponse", + "type": "object", + "required": [ + "reverse_proposals" + ], + "properties": { + "reverse_proposals": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_before": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoteResponse", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "voter" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "voter": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoteListResponse", + "type": "object", + "required": [ + "list_votes" + ], + "properties": { + "list_votes": { + "type": "object", + "required": [ + "proposal_id" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoterInfo", + "type": "object", + "required": [ + "voter" + ], + "properties": { + "voter": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns VoterListResponse", + "type": "object", + "required": [ + "list_voters" + ], + "properties": { + "list_voters": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-channels/.cargo/config b/contracts/hub-channels/.cargo/config similarity index 100% rename from contracts/cw-cyb-channels/.cargo/config rename to contracts/hub-channels/.cargo/config diff --git a/contracts/cw-cyb-tokens/Cargo.toml b/contracts/hub-channels/Cargo.toml similarity index 86% rename from contracts/cw-cyb-tokens/Cargo.toml rename to contracts/hub-channels/Cargo.toml index 4081acc..55d79e6 100644 --- a/contracts/cw-cyb-tokens/Cargo.toml +++ b/contracts/hub-channels/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cw-cyb-tokens" +name = "hub-channels" version = "0.1.0" authors = ["Bloqhub"] edition = "2018" @@ -15,17 +15,6 @@ exclude = [ [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] diff --git a/contracts/cw-cyb-skills/examples/schema.rs b/contracts/hub-channels/examples/schema.rs similarity index 87% rename from contracts/cw-cyb-skills/examples/schema.rs rename to contracts/hub-channels/examples/schema.rs index 8917677..d5ad876 100644 --- a/contracts/cw-cyb-skills/examples/schema.rs +++ b/contracts/hub-channels/examples/schema.rs @@ -3,7 +3,7 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use cw_cyb_skills::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use hub_channels::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/hub-channels/schema/execute_msg.json b/contracts/hub-channels/schema/execute_msg.json new file mode 100644 index 0000000..0a86b8e --- /dev/null +++ b/contracts/hub-channels/schema/execute_msg.json @@ -0,0 +1,156 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "active", + "destination_chain_id", + "destination_channel_id", + "explorer_url", + "source_chain_id", + "source_channel_id" + ], + "properties": { + "active": { + "type": "string" + }, + "destination_chain_id": { + "type": "string" + }, + "destination_channel_id": { + "type": "string" + }, + "explorer_url": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "source_chain_id": { + "type": "string" + }, + "source_channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "active", + "id" + ], + "properties": { + "active": { + "type": "string" + }, + "destination_chain_id": { + "type": [ + "string", + "null" + ] + }, + "destination_channel_id": { + "type": [ + "string", + "null" + ] + }, + "explorer_url": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "source_chain_id": { + "type": [ + "string", + "null" + ] + }, + "source_channel_id": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-channels/schema/instantiate_msg.json b/contracts/hub-channels/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-channels/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-channels/schema/query_msg.json b/contracts/hub-channels/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-channels/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-channels/src/contract.rs b/contracts/hub-channels/src/contract.rs similarity index 53% rename from contracts/cw-cyb-channels/src/contract.rs rename to contracts/hub-channels/src/contract.rs index c0e78a5..1faff6b 100644 --- a/contracts/cw-cyb-channels/src/contract.rs +++ b/contracts/hub-channels/src/contract.rs @@ -1,20 +1,19 @@ use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary, }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; - -use cw2::set_contract_version; +use cw2::{get_contract_version, set_contract_version}; use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list}; use crate::state::{Config, CONFIG, ENTRY_SEQ}; //@TODO git version iteract -const CONTRACT_NAME: &str = "cw-channels"; -const CONTRACT_VERSION: &str = "1.0.0"; +const CONTRACT_NAME: &str = "hub-channels"; +const CONTRACT_VERSION: &str = "0.1.0"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( @@ -31,7 +30,7 @@ pub fn instantiate( .unwrap_or(info.sender); let config = Config { - owner: owner.clone(), + owner: Some(owner.clone()), }; CONFIG.save(deps.storage, &config)?; @@ -45,42 +44,56 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::NewEntry { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::CreateEntry { + active, source_chain_id, destination_chain_id, source_channel_id, destination_channel_id, explorer_url, - token, particle - } => execute_create_new_item(deps, info, source_chain_id,destination_chain_id,source_channel_id, destination_channel_id, explorer_url, token, particle), + } => execute_create_entry(deps, info, active, source_chain_id, destination_chain_id, source_channel_id, destination_channel_id, explorer_url, particle), ExecuteMsg::UpdateEntry { id, + active, source_chain_id, destination_chain_id, source_channel_id, destination_channel_id, explorer_url, - token, particle, - } => execute_update_item(deps, info, id, source_chain_id,destination_chain_id,source_channel_id, destination_channel_id, explorer_url, token, particle), + } => execute_update_entry(deps, info, id, Some(active), source_chain_id, destination_chain_id, source_channel_id, destination_channel_id, explorer_url, particle), ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), } } - - #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetItems { start_after, limit } => { + QueryMsg::GetEntries { start_after, limit } => { to_binary(&query_list(deps, start_after, limit)?) } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + + Ok(Response::default()) } \ No newline at end of file diff --git a/contracts/cw-cyb-contract/src/error.rs b/contracts/hub-channels/src/error.rs similarity index 73% rename from contracts/cw-cyb-contract/src/error.rs rename to contracts/hub-channels/src/error.rs index 4d32a11..863e417 100644 --- a/contracts/cw-cyb-contract/src/error.rs +++ b/contracts/hub-channels/src/error.rs @@ -14,4 +14,7 @@ pub enum ContractError { #[error("Custom Error val: {val:?}")] CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, } diff --git a/contracts/cw-cyb-channels/src/query.rs b/contracts/hub-channels/src/execute.rs similarity index 73% rename from contracts/cw-cyb-channels/src/query.rs rename to contracts/hub-channels/src/execute.rs index b2bd432..56d0976 100644 --- a/contracts/cw-cyb-channels/src/query.rs +++ b/contracts/hub-channels/src/execute.rs @@ -1,36 +1,52 @@ -// use regex::Regex; -// use cosmwasm_std::{Uint64}; - -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, -}; - -use cw_storage_plus::Bound; use std::ops::Add; +use cosmwasm_std::{attr, DepsMut, Env, MessageInfo, Response, StdResult}; -use crate::validating::{validate_by_basic_rule,validate_ipfs_cid,validate_url,validate_by_basic_uppercase_rule}; use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, CONFIG, ENTRY_SEQ, LIST}; +use crate::state::{CONFIG, Entry, ENTRY_SEQ, LIST}; +use crate::validating::{validate_by_basic_rule, validate_ipfs_cid, validate_url}; + +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } + + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 20; + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} -pub fn execute_create_new_item( +pub fn execute_create_entry( deps: DepsMut, info: MessageInfo, + active: String, source_chain_id: String, destination_chain_id: String, source_channel_id: String, destination_channel_id: String, explorer_url: String, - token: String, particle: Option ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -40,15 +56,12 @@ pub fn execute_create_new_item( return validate_particle; } } - let validate_source_chain_id = validate_by_basic_rule(source_chain_id.clone(), "source_chain_id".to_string()); let validate_destination_chain_id = validate_by_basic_rule(destination_chain_id.clone(), "destination_chain_id".to_string()); let validate_source_channel_id = validate_by_basic_rule(source_channel_id.clone(), "source_channel_id".to_string()); let validate_destination_channel_id = validate_by_basic_rule(destination_channel_id.clone(), "destination_channel_id".to_string()); - let validate_explorer_url = validate_url(explorer_url.clone(), "explorer_url".to_string()); - let validate_token = validate_by_basic_uppercase_rule(token.clone(), "token".to_string()); if validate_source_chain_id.is_err() { return validate_source_chain_id; @@ -65,44 +78,44 @@ pub fn execute_create_new_item( if validate_explorer_url.is_err() { return validate_explorer_url; } - if validate_token.is_err() { - return validate_token; - } - - let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; let new_entry = Entry { id, + active, source_chain_id, destination_chain_id, source_channel_id, destination_channel_id, explorer_url, - token, particle: particle.unwrap_or("".to_string()), }; + LIST.save(deps.storage, id, &new_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_create_new_item") + .add_attribute("method", "execute_create_entry") .add_attribute("new_entry_id", id.to_string())) } -pub fn execute_update_item( +pub fn execute_update_entry( deps: DepsMut, info: MessageInfo, id: u64, + active: Option, source_chain_id: Option, destination_chain_id: Option, source_channel_id: Option, destination_channel_id: Option, explorer_url: Option, - token: Option, particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -117,9 +130,7 @@ pub fn execute_update_item( let validate_destination_chain_id = validate_by_basic_rule(destination_chain_id.clone().unwrap(), "destination_chain_id".to_string()); let validate_source_channel_id = validate_by_basic_rule(source_channel_id.clone().unwrap(), "source_channel_id".to_string()); let validate_destination_channel_id = validate_by_basic_rule(destination_channel_id.clone().unwrap(), "destination_channel_id".to_string()); - let validate_explorer_url = validate_url(explorer_url.clone().unwrap(), "explorer_url".to_string()); - let validate_token = validate_by_basic_uppercase_rule(token.clone().unwrap(), "token".to_string()); if validate_source_chain_id.is_err() { return validate_source_chain_id; @@ -136,25 +147,23 @@ pub fn execute_update_item( if validate_explorer_url.is_err() { return validate_explorer_url; } - if validate_token.is_err() { - return validate_token; - } - let entry = LIST.load(deps.storage, id)?; let updated_entry = Entry { id, + active: active.unwrap_or(entry.active), source_chain_id: source_chain_id.unwrap_or(entry.source_chain_id), destination_chain_id: destination_chain_id.unwrap_or(entry.destination_chain_id), source_channel_id: source_channel_id.unwrap_or(entry.source_channel_id), destination_channel_id: destination_channel_id.unwrap_or(entry.destination_channel_id), explorer_url: explorer_url.unwrap_or(entry.explorer_url), - token: token.unwrap_or(entry.token), particle: particle.unwrap_or("".to_string()), }; + LIST.save(deps.storage, id, &updated_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_update_item") + .add_attribute("method", "execute_update_entry") .add_attribute("updated_entry_id", id.to_string())) } @@ -164,39 +173,16 @@ pub fn execute_delete_entry( id: u64, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } LIST.remove(deps.storage, id); + Ok(Response::new() .add_attribute("method", "execute_delete_entry") .add_attribute("deleted_entry_id", id.to_string())) } - - - -// fn query_entry(deps: Deps, id: u64) -> StdResult { -// let entry = LIST.load(deps.storage, id)?; -// Ok(EntryResponse { -// id: entry.id, -// description: entry.description, -// status: entry.status, -// priority: entry.priority, -// }) -// } - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - let entries: StdResult> = LIST - .range(deps.storage, start, None, Order::Ascending) - .take(limit) - .collect(); - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/cw-cyb-channels/src/lib.rs b/contracts/hub-channels/src/lib.rs similarity index 81% rename from contracts/cw-cyb-channels/src/lib.rs rename to contracts/hub-channels/src/lib.rs index b085561..0a43c7c 100644 --- a/contracts/cw-cyb-channels/src/lib.rs +++ b/contracts/hub-channels/src/lib.rs @@ -1,9 +1,10 @@ pub mod contract; mod error; pub mod msg; -pub mod query; +pub mod execute; pub mod state; pub mod validating; mod tests; +mod query; pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-channels/src/msg.rs b/contracts/hub-channels/src/msg.rs similarity index 84% rename from contracts/cw-cyb-channels/src/msg.rs rename to contracts/hub-channels/src/msg.rs index 4abd4a9..39a0e67 100644 --- a/contracts/cw-cyb-channels/src/msg.rs +++ b/contracts/hub-channels/src/msg.rs @@ -10,23 +10,26 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + CreateEntry { + active: String, source_chain_id: String, destination_chain_id: String, source_channel_id: String, destination_channel_id: String, explorer_url: String, - token: String, particle: Option, }, UpdateEntry { id: u64, + active: String, source_chain_id: Option, destination_chain_id: Option, source_channel_id: Option, destination_channel_id: Option, explorer_url: Option, - token: Option, particle: Option, }, DeleteEntry { @@ -37,22 +40,25 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, limit: Option, }, + GetEntry { id: u64 } } +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { pub id: u64, + pub active: String, pub source_chain_id: String, pub destination_chain_id: String, pub source_channel_id: String, pub destination_channel_id: String, pub explorer_url: String, - pub token: String, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] diff --git a/contracts/hub-channels/src/query.rs b/contracts/hub-channels/src/query.rs new file mode 100644 index 0000000..24c7301 --- /dev/null +++ b/contracts/hub-channels/src/query.rs @@ -0,0 +1,37 @@ +use cosmwasm_std::{Deps, Order, StdResult}; +use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::LIST; + +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 20; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = LIST.load(deps.storage, id)?; + + Ok(EntryResponse { + id: entry.id, + active: entry.active, + source_chain_id: entry.source_chain_id, + destination_chain_id: entry.destination_chain_id, + source_channel_id: entry.source_channel_id, + destination_channel_id: entry.destination_channel_id, + explorer_url: entry.explorer_url + }) +} + +pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let entries: StdResult> = LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} \ No newline at end of file diff --git a/contracts/cw-cyb-channels/src/state.rs b/contracts/hub-channels/src/state.rs similarity index 93% rename from contracts/cw-cyb-channels/src/state.rs rename to contracts/hub-channels/src/state.rs index d179b97..3452140 100644 --- a/contracts/cw-cyb-channels/src/state.rs +++ b/contracts/hub-channels/src/state.rs @@ -7,22 +7,21 @@ use cw_storage_plus::{Item, Map}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Entry { pub id: u64, + pub active: String, pub source_chain_id: String, pub destination_chain_id: String, pub source_channel_id: String, pub destination_channel_id: String, pub explorer_url: String, - pub token: String, pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); pub const LIST: Map = Map::new("list"); diff --git a/contracts/cw-cyb-channels/src/tests.rs b/contracts/hub-channels/src/tests.rs similarity index 88% rename from contracts/cw-cyb-channels/src/tests.rs rename to contracts/hub-channels/src/tests.rs index 0451c84..7d9aed0 100644 --- a/contracts/cw-cyb-channels/src/tests.rs +++ b/contracts/hub-channels/src/tests.rs @@ -2,14 +2,11 @@ #[cfg(test)] mod tests { - // use super::*; - // use cosmwasm_std::{Uint64}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{attr, from_binary, Addr}; use std::vec::Vec; use crate::state::{Entry, CONFIG, Config}; use crate::msg::{ ListResponse, QueryMsg, InstantiateMsg, ExecuteMsg}; - // use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::contract::{query, execute, instantiate}; #[test] @@ -28,7 +25,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -44,7 +41,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -59,13 +56,13 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { + active: "active".to_string(), source_chain_id: "bostrom-1".to_string(), destination_chain_id: "cosmos-1".to_string(), source_channel_id: "channel-256".to_string(), destination_channel_id: "channel-1".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -73,18 +70,18 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { + active: "active".to_string(), source_chain_id: "bostrom-2".to_string(), destination_chain_id: "cosmos-2".to_string(), source_channel_id: "channel-2".to_string(), destination_channel_id: "channel-2".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -92,7 +89,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -101,7 +98,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -112,22 +109,22 @@ mod tests { Vec::from([ Entry { id: 1, + active: "active".to_string(), source_chain_id: "bostrom-1".to_string(), destination_chain_id: "cosmos-1".to_string(), source_channel_id: "channel-256".to_string(), destination_channel_id: "channel-1".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }, Entry { id: 2, + active: "active".to_string(), source_chain_id: "bostrom-2".to_string(), destination_chain_id: "cosmos-2".to_string(), source_channel_id: "channel-2".to_string(), destination_channel_id: "channel-2".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), } ]), @@ -137,12 +134,12 @@ mod tests { // Update entry let message = ExecuteMsg::UpdateEntry { id: 1, + active: "active".to_string(), source_chain_id: Some("bostrom-1".to_string()), destination_chain_id: Some("cosmos-1".to_string()), source_channel_id: Some("channel-256".to_string()), destination_channel_id: Some("channel-1".to_string()), explorer_url: Some("https://explorer.com/{hash}".to_string()), - token: Some("DEM2".to_string()), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -150,18 +147,16 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); - - // Query the list of entries let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -172,22 +167,22 @@ mod tests { Vec::from([ Entry { id: 1, + active: "active".to_string(), source_chain_id: "bostrom-1".to_string(), destination_chain_id: "cosmos-1".to_string(), source_channel_id: "channel-256".to_string(), destination_channel_id: "channel-1".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }, Entry { id: 2, + active: "active".to_string(), source_chain_id: "bostrom-2".to_string(), destination_chain_id: "cosmos-2".to_string(), source_channel_id: "channel-2".to_string(), destination_channel_id: "channel-2".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), } ]), @@ -209,7 +204,7 @@ mod tests { let res = query( deps.as_ref(), env, - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -219,12 +214,12 @@ mod tests { assert_eq!( Vec::from([Entry { id: 2, + active: "active".to_string(), source_chain_id: "bostrom-2".to_string(), destination_chain_id: "cosmos-2".to_string(), source_channel_id: "channel-2".to_string(), destination_channel_id: "channel-2".to_string(), explorer_url: "https://explorer.com/{hash}".to_string(), - token: "DEM2".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }]), list.entries diff --git a/contracts/cw-cyb-channels/src/validating.rs b/contracts/hub-channels/src/validating.rs similarity index 83% rename from contracts/cw-cyb-channels/src/validating.rs rename to contracts/hub-channels/src/validating.rs index f60918f..f62fd80 100644 --- a/contracts/cw-cyb-channels/src/validating.rs +++ b/contracts/hub-channels/src/validating.rs @@ -5,14 +5,13 @@ use cosmwasm_std::{ Response, }; -/** - * Baseic rule /[a-z0-9-]/ +/* + * Basic rule /[a-z0-9-]/ */ pub fn validate_by_basic_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -23,14 +22,13 @@ pub fn validate_by_basic_rule( Ok(Response::default()) } -/** - * Baseic rule /[A-Z0-9]/ +/* + * Basic rule /[A-Z0-9]/ */ pub fn validate_by_basic_uppercase_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // 0-9 && A-Z if (*byte < 48 || *byte > 57) && (*byte < 65 || *byte > 90) { @@ -44,7 +42,6 @@ pub fn validate_by_basic_uppercase_rule( pub fn validate_datatype( val: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -59,7 +56,6 @@ pub fn validate_url( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // } { : / . - _ 0-9 a-z A-Z if (*byte != 125) && (*byte != 123) && (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { @@ -76,22 +72,20 @@ pub fn validate_url( pub fn validate_ipfs_cid( particle: String ) -> Result { + let particle_value:Cid; + let try_particle = Cid::from_str(&particle.clone()); + if try_particle.is_ok() { + particle_value = try_particle.unwrap(); - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { + if particle_value.version() != Version::V0 { - return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); - - } - } else { return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); - } - Ok(Response::default()) + } + } else { + return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); + } + Ok(Response::default()) } diff --git a/contracts/cw-cyb-contract/.cargo/config b/contracts/hub-contracts/.cargo/config similarity index 100% rename from contracts/cw-cyb-contract/.cargo/config rename to contracts/hub-contracts/.cargo/config diff --git a/contracts/cw-cyb-network/Cargo.toml b/contracts/hub-contracts/Cargo.toml similarity index 86% rename from contracts/cw-cyb-network/Cargo.toml rename to contracts/hub-contracts/Cargo.toml index 4cc3a14..7b7b91f 100644 --- a/contracts/cw-cyb-network/Cargo.toml +++ b/contracts/hub-contracts/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cw-cyb-network" +name = "hub-contracts" version = "0.1.0" authors = ["Bloqhub"] edition = "2018" @@ -15,17 +15,6 @@ exclude = [ [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] diff --git a/contracts/cw-cyb-tokens/examples/schema.rs b/contracts/hub-contracts/examples/schema.rs similarity index 87% rename from contracts/cw-cyb-tokens/examples/schema.rs rename to contracts/hub-contracts/examples/schema.rs index ed93f31..eef2b64 100644 --- a/contracts/cw-cyb-tokens/examples/schema.rs +++ b/contracts/hub-contracts/examples/schema.rs @@ -3,7 +3,7 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use cw_cyb_tokens::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use hub_contracts::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/hub-contracts/schema/execute_msg.json b/contracts/hub-contracts/schema/execute_msg.json new file mode 100644 index 0000000..5e6d165 --- /dev/null +++ b/contracts/hub-contracts/schema/execute_msg.json @@ -0,0 +1,148 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "address", + "chain_id", + "execute_cid", + "query_cid", + "version" + ], + "properties": { + "address": { + "type": "string" + }, + "chain_id": { + "type": "string" + }, + "execute_cid": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "query_cid": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "address": { + "type": [ + "string", + "null" + ] + }, + "chain_id": { + "type": [ + "string", + "null" + ] + }, + "execute_cid": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "query_cid": { + "type": [ + "string", + "null" + ] + }, + "version": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-contracts/schema/instantiate_msg.json b/contracts/hub-contracts/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-contracts/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-contracts/schema/query_msg.json b/contracts/hub-contracts/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-contracts/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-contract/src/contract.rs b/contracts/hub-contracts/src/contract.rs similarity index 54% rename from contracts/cw-cyb-contract/src/contract.rs rename to contracts/hub-contracts/src/contract.rs index 4d598b8..110f41c 100644 --- a/contracts/cw-cyb-contract/src/contract.rs +++ b/contracts/hub-contracts/src/contract.rs @@ -1,20 +1,19 @@ use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary, }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; - -use cw2::set_contract_version; +use cw2::{get_contract_version, set_contract_version}; use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list}; use crate::state::{Config, CONFIG, ENTRY_SEQ}; //@TODO git version iteract -const CONTRACT_NAME: &str = "cw-contract"; -const CONTRACT_VERSION: &str = "1.0.0"; +const CONTRACT_NAME: &str = "hub-contracts"; +const CONTRACT_VERSION: &str = "0.1.0"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( @@ -31,7 +30,7 @@ pub fn instantiate( .unwrap_or(info.sender); let config = Config { - owner: owner.clone(), + owner: Some(owner.clone()), }; CONFIG.save(deps.storage, &config)?; @@ -45,19 +44,20 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::NewEntry { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::CreateEntry { address, query_cid, execute_cid, version, chain_id, particle, - } => execute_create_new_item(deps, info,address,query_cid,execute_cid,version,chain_id, particle), + } => execute_create_entry(deps, info, address, query_cid, execute_cid, version, chain_id, particle), ExecuteMsg::UpdateEntry { id, address, @@ -66,18 +66,31 @@ pub fn execute( version, chain_id, particle, - } => execute_update_item(deps, info, id, address,query_cid,execute_cid,version,chain_id, particle), + } => execute_update_entry(deps, info, id, address, query_cid, execute_cid, version, chain_id, particle), ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), } } - - #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetItems { start_after, limit } => { + QueryMsg::GetEntries { start_after, limit } => { to_binary(&query_list(deps, start_after, limit)?) } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + + Ok(Response::default()) } \ No newline at end of file diff --git a/contracts/cw-cyb-endpoints/src/error.rs b/contracts/hub-contracts/src/error.rs similarity index 73% rename from contracts/cw-cyb-endpoints/src/error.rs rename to contracts/hub-contracts/src/error.rs index 4d32a11..863e417 100644 --- a/contracts/cw-cyb-endpoints/src/error.rs +++ b/contracts/hub-contracts/src/error.rs @@ -14,4 +14,7 @@ pub enum ContractError { #[error("Custom Error val: {val:?}")] CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, } diff --git a/contracts/cw-cyb-contract/src/query.rs b/contracts/hub-contracts/src/execute.rs similarity index 75% rename from contracts/cw-cyb-contract/src/query.rs rename to contracts/hub-contracts/src/execute.rs index 8eb0fff..6684c8d 100644 --- a/contracts/cw-cyb-contract/src/query.rs +++ b/contracts/hub-contracts/src/execute.rs @@ -1,20 +1,37 @@ -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, -}; - -use cw_storage_plus::Bound; use std::ops::Add; -use crate::validating::{validate_by_basic_rule,validate_ipfs_cid,validate_url}; +use cosmwasm_std::{attr, DepsMut, Env, MessageInfo, Response, StdResult}; + use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, CONFIG, ENTRY_SEQ, LIST}; +use crate::state::{CONFIG, Entry, ENTRY_SEQ, LIST}; +use crate::validating::{validate_by_basic_rule, validate_ipfs_cid, validate_url}; -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 20; +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } -pub fn execute_create_new_item( + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; + + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} + +pub fn execute_create_entry( deps: DepsMut, info: MessageInfo, address: String, @@ -25,7 +42,10 @@ pub fn execute_create_new_item( particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -35,7 +55,6 @@ pub fn execute_create_new_item( return validate_particle; } } - let validate_address = validate_by_basic_rule(address.clone(), "address".to_string()); let validate_query_cid = validate_ipfs_cid(query_cid.clone(), "query_cid".to_string()); @@ -59,8 +78,6 @@ pub fn execute_create_new_item( return validate_chain_id; } - - let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; let new_entry = Entry { @@ -72,13 +89,15 @@ pub fn execute_create_new_item( chain_id, particle: particle.unwrap_or("".to_string()), }; + LIST.save(deps.storage, id, &new_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_create_new_item") + .add_attribute("method", "execute_create_entry") .add_attribute("new_entry_id", id.to_string())) } -pub fn execute_update_item( +pub fn execute_update_entry( deps: DepsMut, info: MessageInfo, id: u64, @@ -90,7 +109,10 @@ pub fn execute_update_item( particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -100,7 +122,6 @@ pub fn execute_update_item( return validate_particle; } } - let validate_address = validate_by_basic_rule(address.clone().unwrap(), "address".to_string()); let validate_query_cid = validate_ipfs_cid(query_cid.clone().unwrap(), "query_cid".to_string()); @@ -124,8 +145,6 @@ pub fn execute_update_item( return validate_chain_id; } - - let entry = LIST.load(deps.storage, id)?; let updated_entry = Entry { id, @@ -138,8 +157,9 @@ pub fn execute_update_item( }; LIST.save(deps.storage, id, &updated_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_update_item") + .add_attribute("method", "execute_update_entry") .add_attribute("updated_entry_id", id.to_string())) } @@ -149,29 +169,16 @@ pub fn execute_delete_entry( id: u64, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } LIST.remove(deps.storage, id); + Ok(Response::new() .add_attribute("method", "execute_delete_entry") .add_attribute("deleted_entry_id", id.to_string())) } - - - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - let entries: StdResult> = LIST - .range(deps.storage, start, None, Order::Ascending) - .take(limit) - .collect(); - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/cw-cyb-contract/src/lib.rs b/contracts/hub-contracts/src/lib.rs similarity index 81% rename from contracts/cw-cyb-contract/src/lib.rs rename to contracts/hub-contracts/src/lib.rs index b085561..0a43c7c 100644 --- a/contracts/cw-cyb-contract/src/lib.rs +++ b/contracts/hub-contracts/src/lib.rs @@ -1,9 +1,10 @@ pub mod contract; mod error; pub mod msg; -pub mod query; +pub mod execute; pub mod state; pub mod validating; mod tests; +mod query; pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-contract/src/msg.rs b/contracts/hub-contracts/src/msg.rs similarity index 86% rename from contracts/cw-cyb-contract/src/msg.rs rename to contracts/hub-contracts/src/msg.rs index 40c1696..0f9d8d6 100644 --- a/contracts/cw-cyb-contract/src/msg.rs +++ b/contracts/hub-contracts/src/msg.rs @@ -1,5 +1,4 @@ use crate::state::{Entry}; -// use cosmwasm_std::{Uint64}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -10,7 +9,10 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + CreateEntry { address: String, query_cid: String, execute_cid: String, @@ -35,12 +37,15 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, limit: Option, }, + GetEntry { id: u64 } } +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { diff --git a/contracts/hub-contracts/src/query.rs b/contracts/hub-contracts/src/query.rs new file mode 100644 index 0000000..012604b --- /dev/null +++ b/contracts/hub-contracts/src/query.rs @@ -0,0 +1,37 @@ +use cosmwasm_std::{Deps, Order, StdResult}; +use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::LIST; + +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 20; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = LIST.load(deps.storage, id)?; + + Ok(EntryResponse { + id: entry.id, + address: entry.address, + query_cid: entry.query_cid, + execute_cid: entry.execute_cid, + version: entry.version, + chain_id: entry.chain_id, + particle: entry.particle + }) +} + +pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let entries: StdResult> = LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} \ No newline at end of file diff --git a/contracts/cw-cyb-contract/src/state.rs b/contracts/hub-contracts/src/state.rs similarity index 95% rename from contracts/cw-cyb-contract/src/state.rs rename to contracts/hub-contracts/src/state.rs index 540331e..2765e3d 100644 --- a/contracts/cw-cyb-contract/src/state.rs +++ b/contracts/hub-contracts/src/state.rs @@ -7,7 +7,7 @@ use cw_storage_plus::{Item, Map}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -21,7 +21,6 @@ pub struct Entry { pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); pub const LIST: Map = Map::new("list"); diff --git a/contracts/cw-cyb-contract/src/tests.rs b/contracts/hub-contracts/src/tests.rs similarity index 94% rename from contracts/cw-cyb-contract/src/tests.rs rename to contracts/hub-contracts/src/tests.rs index e5e09a4..fea41f6 100644 --- a/contracts/cw-cyb-contract/src/tests.rs +++ b/contracts/hub-contracts/src/tests.rs @@ -28,7 +28,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -44,7 +44,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -59,7 +59,7 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), query_cid: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), execute_cid: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), @@ -72,12 +72,12 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), query_cid: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), execute_cid: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), @@ -90,7 +90,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -99,7 +99,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -145,7 +145,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); @@ -156,7 +156,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -202,7 +202,7 @@ mod tests { let res = query( deps.as_ref(), env, - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, diff --git a/contracts/cw-cyb-contract/src/validating.rs b/contracts/hub-contracts/src/validating.rs similarity index 82% rename from contracts/cw-cyb-contract/src/validating.rs rename to contracts/hub-contracts/src/validating.rs index f18cd97..85f4207 100644 --- a/contracts/cw-cyb-contract/src/validating.rs +++ b/contracts/hub-contracts/src/validating.rs @@ -5,14 +5,13 @@ use cosmwasm_std::{ Response, }; -/** - * Baseic rule /[a-z0-9-]/ +/* + * Basic rule /[a-z0-9-]/ */ pub fn validate_by_basic_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -23,14 +22,13 @@ pub fn validate_by_basic_rule( Ok(Response::default()) } -/** - * Baseic rule /[A-Z0-9]/ +/* + * Basic rule /[A-Z0-9]/ */ pub fn validate_by_basic_uppercase_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // 0-9 && A-Z if (*byte < 48 || *byte > 57) && (*byte < 65 || *byte > 90) { @@ -44,7 +42,6 @@ pub fn validate_by_basic_uppercase_rule( pub fn validate_datatype( val: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -59,7 +56,6 @@ pub fn validate_url( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // = & } { : / . - _ 0-9 a-z A-Z if (*byte != 61) && (*byte != 38) && (*byte != 125) && (*byte != 123) && (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { @@ -77,20 +73,19 @@ pub fn validate_ipfs_cid( particle: String, field_name: String, ) -> Result { + let particle_value:Cid; + let try_particle = Cid::from_str(&particle.clone()); + if try_particle.is_ok() { + particle_value = try_particle.unwrap(); - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); - } - } else { + if particle_value.version() != Version::V0 { return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); } - Ok(Response::default()) + } else { + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); + } + Ok(Response::default()) } diff --git a/contracts/cw-cyb-endpoints/.cargo/config b/contracts/hub-libs/.cargo/config similarity index 100% rename from contracts/cw-cyb-endpoints/.cargo/config rename to contracts/hub-libs/.cargo/config diff --git a/contracts/hub-libs/Cargo.toml b/contracts/hub-libs/Cargo.toml new file mode 100644 index 0000000..1b4cdcb --- /dev/null +++ b/contracts/hub-libs/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "hub-libs" +version = "0.1.0" +authors = ["master"] +edition = "2018" + +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"] + +[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.6 +""" + +[dependencies] +cosmwasm-std = { version = "1.0.0", features = ["iterator", "abort"] } +cw-storage-plus = { version = "0.13.4" } +cw2 = { version = "0.13.4" } +schemars = "0.8.10" +serde = { version = "1.0.140", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.31" } +cid = { version = "0.8.0" } + +[dev-dependencies] +cosmwasm-schema = "1.0.0" +cw-multi-test = "0.13.2" diff --git a/contracts/cw-cyb-heroes/examples/schema.rs b/contracts/hub-libs/examples/schema.rs similarity index 87% rename from contracts/cw-cyb-heroes/examples/schema.rs rename to contracts/hub-libs/examples/schema.rs index d0c03c0..0e6f579 100644 --- a/contracts/cw-cyb-heroes/examples/schema.rs +++ b/contracts/hub-libs/examples/schema.rs @@ -3,7 +3,7 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use cw_cyb_heroes::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use hub_libs::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/hub-libs/schema/execute_msg.json b/contracts/hub-libs/schema/execute_msg.json new file mode 100644 index 0000000..6f8a5c2 --- /dev/null +++ b/contracts/hub-libs/schema/execute_msg.json @@ -0,0 +1,136 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "address", + "chain_id", + "init_particle", + "version" + ], + "properties": { + "address": { + "type": "string" + }, + "chain_id": { + "type": "string" + }, + "init_particle": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "version": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "address", + "id" + ], + "properties": { + "address": { + "type": "string" + }, + "chain_id": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "init_particle": { + "type": [ + "string", + "null" + ] + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "version": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-libs/schema/instantiate_msg.json b/contracts/hub-libs/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-libs/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-libs/schema/query_msg.json b/contracts/hub-libs/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-libs/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-libs/src/contract.rs b/contracts/hub-libs/src/contract.rs new file mode 100644 index 0000000..f416c48 --- /dev/null +++ b/contracts/hub-libs/src/contract.rs @@ -0,0 +1,94 @@ +use cosmwasm_std::{ + Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary, +}; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cw2::{get_contract_version, set_contract_version}; + +use crate::error::ContractError; +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list}; +use crate::state::{Config, CONFIG, ENTRY_SEQ}; + +//@TODO git version iteract +const CONTRACT_NAME: &str = "hub-libs"; +const CONTRACT_VERSION: &str = "0.1.0"; + +#[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)?; + + let owner = msg + .owner + .and_then(|addr_string| deps.api.addr_validate(addr_string.as_str()).ok()) + .unwrap_or(info.sender); + + let config = Config { + owner: Some(owner.clone()), + }; + CONFIG.save(deps.storage, &config)?; + + ENTRY_SEQ.save(deps.storage, &0u64)?; + + Ok(Response::new() + .add_attribute("method", "instantiate") + .add_attribute("owner", owner)) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::CreateEntry { + address, + init_particle, + version, + chain_id, + particle, + } => execute_create_entry(deps, info, address, init_particle, version, chain_id, particle), + ExecuteMsg::UpdateEntry { + id, + address, + init_particle, + version, + chain_id, + particle, + } => execute_update_entry(deps, info, id, Some(address), init_particle, version, chain_id, particle), + ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), + } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetEntries { start_after, limit } => { + to_binary(&query_list(deps, start_after, limit)?) + } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } + } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + + Ok(Response::default()) +} \ No newline at end of file diff --git a/contracts/cw-cyb-heroes/src/error.rs b/contracts/hub-libs/src/error.rs similarity index 73% rename from contracts/cw-cyb-heroes/src/error.rs rename to contracts/hub-libs/src/error.rs index 4d32a11..863e417 100644 --- a/contracts/cw-cyb-heroes/src/error.rs +++ b/contracts/hub-libs/src/error.rs @@ -14,4 +14,7 @@ pub enum ContractError { #[error("Custom Error val: {val:?}")] CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, } diff --git a/contracts/hub-libs/src/execute.rs b/contracts/hub-libs/src/execute.rs new file mode 100644 index 0000000..93dba09 --- /dev/null +++ b/contracts/hub-libs/src/execute.rs @@ -0,0 +1,172 @@ +use std::ops::Add; + +use cosmwasm_std::{attr, DepsMut, Env, MessageInfo, Response, StdResult}; + +use crate::error::ContractError; +use crate::state::{CONFIG, Entry, ENTRY_SEQ, LIST}; +use crate::validating::{validate_by_basic_rule, validate_ipfs_cid, validate_url}; + +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } + + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } + + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; + + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} + +pub fn execute_create_entry( + deps: DepsMut, + info: MessageInfo, + address: String, + init_particle: String, + version: String, + chain_id: String, + particle: Option, +) -> Result { + let owner = CONFIG.load(deps.storage)?.owner; + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { + return Err(ContractError::Unauthorized {}); + } + + if !particle.as_ref().is_none() { + let validate_particle = validate_ipfs_cid(particle.clone().unwrap(),"particle".to_string()); + if validate_particle.is_err() { + return validate_particle; + } + } + + let validate_address = validate_by_basic_rule(address.clone(), "address".to_string()); + let validate_init_particle = validate_ipfs_cid(init_particle.clone(), "init_particle".to_string()); + let validate_version = validate_url(version.clone(), "version".to_string()); + let validate_chain_id = validate_url(chain_id.clone(), "chain_id".to_string()); + + if validate_address.is_err() { + return validate_address; + } + if validate_init_particle.is_err() { + return validate_init_particle; + } + if validate_version.is_err() { + return validate_version; + } + if validate_chain_id.is_err() { + return validate_chain_id; + } + + let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; + + let new_entry = Entry { + id, + address, + init_particle, + version, + chain_id, + particle: particle.unwrap_or("".to_string()), + }; + + LIST.save(deps.storage, id, &new_entry)?; + + Ok(Response::new() + .add_attribute("method", "execute_create_entry") + .add_attribute("new_entry_id", id.to_string())) +} + +pub fn execute_update_entry( + deps: DepsMut, + info: MessageInfo, + id: u64, + address: Option, + init_particle: Option, + version: Option, + chain_id: Option, + particle: Option, +) -> Result { + let owner = CONFIG.load(deps.storage)?.owner; + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { + return Err(ContractError::Unauthorized {}); + } + + if !particle.as_ref().is_none() { + let validate_particle = validate_ipfs_cid(particle.clone().unwrap(),"particle".to_string()); + if validate_particle.is_err() { + return validate_particle; + } + } + + let validate_address = validate_by_basic_rule(address.clone().unwrap(), "address".to_string()); + let validate_init_particle = validate_ipfs_cid(init_particle.clone().unwrap(), "init_particle".to_string()); + let validate_version = validate_url(version.clone().unwrap(), "version".to_string()); + let validate_chain_id = validate_url(chain_id.clone().unwrap(), "chain_id".to_string()); + + if validate_address.is_err() { + return validate_address; + } + if validate_init_particle.is_err() { + return validate_init_particle; + } + if validate_version.is_err() { + return validate_version; + } + if validate_chain_id.is_err() { + return validate_chain_id; + } + + let entry = LIST.load(deps.storage, id)?; + let updated_entry = Entry { + id, + address: address.unwrap_or(entry.address), + init_particle: init_particle.unwrap_or(entry.init_particle), + version: version.unwrap_or(entry.version), + chain_id: chain_id.unwrap_or(entry.chain_id), + particle: particle.unwrap_or("".to_string()), + }; + + LIST.save(deps.storage, id, &updated_entry)?; + + Ok(Response::new() + .add_attribute("method", "execute_update_entry") + .add_attribute("updated_entry_id", id.to_string())) +} + +pub fn execute_delete_entry( + deps: DepsMut, + info: MessageInfo, + id: u64, +) -> Result { + let owner = CONFIG.load(deps.storage)?.owner; + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { + return Err(ContractError::Unauthorized {}); + } + + LIST.remove(deps.storage, id); + + Ok(Response::new() + .add_attribute("method", "execute_delete_entry") + .add_attribute("deleted_entry_id", id.to_string())) +} diff --git a/contracts/cw-cyb-endpoints/src/lib.rs b/contracts/hub-libs/src/lib.rs similarity index 81% rename from contracts/cw-cyb-endpoints/src/lib.rs rename to contracts/hub-libs/src/lib.rs index b085561..0a43c7c 100644 --- a/contracts/cw-cyb-endpoints/src/lib.rs +++ b/contracts/hub-libs/src/lib.rs @@ -1,9 +1,10 @@ pub mod contract; mod error; pub mod msg; -pub mod query; +pub mod execute; pub mod state; pub mod validating; mod tests; +mod query; pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-heroes/src/msg.rs b/contracts/hub-libs/src/msg.rs similarity index 71% rename from contracts/cw-cyb-heroes/src/msg.rs rename to contracts/hub-libs/src/msg.rs index a155ab3..dc27d41 100644 --- a/contracts/cw-cyb-heroes/src/msg.rs +++ b/contracts/hub-libs/src/msg.rs @@ -1,10 +1,6 @@ use crate::state::{Entry}; -use cosmwasm_std::{Uint64}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{ - Addr, -}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { @@ -13,14 +9,21 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + CreateEntry { address: String, + init_particle: String, + version: String, chain_id: String, particle: Option, }, UpdateEntry { id: u64, - address: Option, + address: String, + init_particle: Option, + version: Option, chain_id: Option, particle: Option, }, @@ -32,21 +35,23 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, - owner: Option, - id: Option, limit: Option, }, + GetEntry { id: u64 } } -// Tokens +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { pub id: u64, pub address: String, + pub init_particle: String, + pub version: String, pub chain_id: String, - // pub owner: String, pub particle: String, } diff --git a/contracts/hub-libs/src/query.rs b/contracts/hub-libs/src/query.rs new file mode 100644 index 0000000..8f2e414 --- /dev/null +++ b/contracts/hub-libs/src/query.rs @@ -0,0 +1,36 @@ +use cosmwasm_std::{Deps, Order, StdResult}; +use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::LIST; + +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 20; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = LIST.load(deps.storage, id)?; + + Ok(EntryResponse { + id: entry.id, + address: entry.address, + init_particle: entry.init_particle, + version: entry.version, + chain_id: entry.chain_id, + particle: entry.particle + }) +} + +pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let entries: StdResult> = LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} \ No newline at end of file diff --git a/contracts/cw-cyb-endpoints/src/state.rs b/contracts/hub-libs/src/state.rs similarity index 79% rename from contracts/cw-cyb-endpoints/src/state.rs rename to contracts/hub-libs/src/state.rs index bec6a75..2d88b79 100644 --- a/contracts/cw-cyb-endpoints/src/state.rs +++ b/contracts/hub-libs/src/state.rs @@ -1,25 +1,25 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +// use cosmwasm_std::{Uint64}; use cosmwasm_std::Addr; use cw_storage_plus::{Item, Map}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Entry { pub id: u64, - pub data_type: String, - pub particle: String, - pub protocol: String, + pub address: String, + pub init_particle: String, + pub version: String, pub chain_id: String, - pub url: String, + pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); pub const LIST: Map = Map::new("list"); diff --git a/contracts/cw-cyb-endpoints/src/tests.rs b/contracts/hub-libs/src/tests.rs similarity index 65% rename from contracts/cw-cyb-endpoints/src/tests.rs rename to contracts/hub-libs/src/tests.rs index 0447121..c9910da 100644 --- a/contracts/cw-cyb-endpoints/src/tests.rs +++ b/contracts/hub-libs/src/tests.rs @@ -28,7 +28,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -44,7 +44,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -59,36 +59,36 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + let msg = ExecuteMsg::CreateEntry { + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), + particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()) }; let res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + let msg = ExecuteMsg::CreateEntry { + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), + particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()) }; let res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -97,7 +97,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -108,19 +108,19 @@ mod tests { Vec::from([ Entry { id: 1, - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string() }, Entry { id: 2, - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string() } ]), list.entries @@ -129,19 +129,18 @@ mod tests { // Update entry let message = ExecuteMsg::UpdateEntry { id: 1, - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), - chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), - //None + address: Some("bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z3".to_string()), + init_particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), + version: Some("v=1&s=2&j=3".to_string()), + chain_id: Some("test-1".to_string()), + particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()) }; let res = execute(deps.as_mut(), env.clone(), info.clone(), message).unwrap(); assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); @@ -152,7 +151,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -163,19 +162,19 @@ mod tests { Vec::from([ Entry { id: 1, - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z3".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string() }, Entry { id: 2, - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string() } ]), list.entries @@ -196,7 +195,7 @@ mod tests { let res = query( deps.as_ref(), env, - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -206,11 +205,11 @@ mod tests { assert_eq!( Vec::from([Entry { id: 2, - data_type: "rpc".to_string(), - protocol: "rpc-http-api".to_string(), + address: "bostrom1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq7ha2z2".to_string(), + init_particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + version: "v=1&s=2&j=3".to_string(), chain_id: "test-1".to_string(), - url: "https://cyb.ai".to_string(), - particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string() }]), list.entries ); diff --git a/contracts/cw-cyb-heroes/src/validating.rs b/contracts/hub-libs/src/validating.rs similarity index 58% rename from contracts/cw-cyb-heroes/src/validating.rs rename to contracts/hub-libs/src/validating.rs index 06a0815..85f4207 100644 --- a/contracts/cw-cyb-heroes/src/validating.rs +++ b/contracts/hub-libs/src/validating.rs @@ -1,19 +1,17 @@ use cid::{Cid, Version}; -use cosmwasm_std::{Uint64}; use std::str::FromStr; use crate::error::ContractError; use cosmwasm_std::{ Response, }; -/** - * Baseic rule /[a-z0-9-]/ +/* + * Basic rule /[a-z0-9-]/ */ pub fn validate_by_basic_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -24,18 +22,17 @@ pub fn validate_by_basic_rule( Ok(Response::default()) } -/** - * Baseic rule /[A-Z0-9]/ +/* + * Basic rule /[A-Z0-9]/ */ pub fn validate_by_basic_uppercase_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // 0-9 && A-Z if (*byte < 48 || *byte > 57) && (*byte < 65 || *byte > 90) { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field field {}. Allowed expression /[a-z0-9-]/", field_name).to_string()}); + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed expression /[a-z0-9-]/", field_name).to_string()}); } } @@ -45,7 +42,6 @@ pub fn validate_by_basic_uppercase_rule( pub fn validate_datatype( val: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -60,29 +56,16 @@ pub fn validate_url( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // = & } { : / . - _ 0-9 a-z A-Z - if (*byte != 61) && (*byte != 38) && (*byte != 125) && (*byte != 123) && (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only url", field_name).to_string()}); - } + if (*byte != 61) && (*byte != 38) && (*byte != 125) && (*byte != 123) && (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only url", field_name).to_string()}); + } } Ok(Response::default()) } -pub fn validate_by_int_range( - from: Uint64, - to: Uint64, - field: Uint64, - field_name: String, -) -> Result { - // let intField=Uint64::from(field); - if field < from || field > to { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Out from range", field_name).to_string()}); - } - Ok(Response::default()) -} @@ -90,20 +73,19 @@ pub fn validate_ipfs_cid( particle: String, field_name: String, ) -> Result { + let particle_value:Cid; + let try_particle = Cid::from_str(&particle.clone()); + if try_particle.is_ok() { + particle_value = try_particle.unwrap(); - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); - } - } else { + if particle_value.version() != Version::V0 { return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); } - Ok(Response::default()) + } else { + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); + } + Ok(Response::default()) } diff --git a/contracts/cw-cyb-heroes/.cargo/config b/contracts/hub-networks/.cargo/config similarity index 100% rename from contracts/cw-cyb-heroes/.cargo/config rename to contracts/hub-networks/.cargo/config diff --git a/contracts/cw-cyb-channels/Cargo.toml b/contracts/hub-networks/Cargo.toml similarity index 86% rename from contracts/cw-cyb-channels/Cargo.toml rename to contracts/hub-networks/Cargo.toml index 2fc974d..dab20bb 100644 --- a/contracts/cw-cyb-channels/Cargo.toml +++ b/contracts/hub-networks/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cw-cyb-channels" +name = "hub-networks" version = "0.1.0" authors = ["Bloqhub"] edition = "2018" @@ -15,17 +15,6 @@ exclude = [ [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] diff --git a/contracts/cw-cyb-network/examples/schema.rs b/contracts/hub-networks/examples/schema.rs similarity index 87% rename from contracts/cw-cyb-network/examples/schema.rs rename to contracts/hub-networks/examples/schema.rs index 119ffd0..8910958 100644 --- a/contracts/cw-cyb-network/examples/schema.rs +++ b/contracts/hub-networks/examples/schema.rs @@ -3,7 +3,7 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use cw_cyb_network::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use hub_networks::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/hub-networks/schema/execute_msg.json b/contracts/hub-networks/schema/execute_msg.json new file mode 100644 index 0000000..f3974cc --- /dev/null +++ b/contracts/hub-networks/schema/execute_msg.json @@ -0,0 +1,168 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "chain_id", + "genesis_hash", + "logo", + "name", + "prefix", + "protocol", + "unbonding_period" + ], + "properties": { + "chain_id": { + "type": "string" + }, + "genesis_hash": { + "type": "string" + }, + "logo": { + "type": "string" + }, + "name": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "prefix": { + "type": "string" + }, + "protocol": { + "type": "string" + }, + "unbonding_period": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "chain_id": { + "type": [ + "string", + "null" + ] + }, + "genesis_hash": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "logo": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": [ + "string", + "null" + ] + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "prefix": { + "type": [ + "string", + "null" + ] + }, + "protocol": { + "type": [ + "string", + "null" + ] + }, + "unbonding_period": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-networks/schema/instantiate_msg.json b/contracts/hub-networks/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-networks/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-networks/schema/query_msg.json b/contracts/hub-networks/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-networks/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-network/src/contract.rs b/contracts/hub-networks/src/contract.rs similarity index 51% rename from contracts/cw-cyb-network/src/contract.rs rename to contracts/hub-networks/src/contract.rs index c78c1dd..17aa1fb 100644 --- a/contracts/cw-cyb-network/src/contract.rs +++ b/contracts/hub-networks/src/contract.rs @@ -1,20 +1,19 @@ use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary, }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; - -use cw2::set_contract_version; +use cw2::{get_contract_version, set_contract_version}; use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list}; use crate::state::{Config, CONFIG, ENTRY_SEQ}; //@TODO git version iteract -const CONTRACT_NAME: &str = "cw-network"; -const CONTRACT_VERSION: &str = "1.0.0"; +const CONTRACT_NAME: &str = "hub-networks"; +const CONTRACT_VERSION: &str = "0.1.0"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( @@ -31,7 +30,7 @@ pub fn instantiate( .unwrap_or(info.sender); let config = Config { - owner: owner.clone(), + owner: Some(owner.clone()), }; CONFIG.save(deps.storage, &config)?; @@ -45,41 +44,57 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::NewEntry { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::CreateEntry { name, chain_id, + prefix, genesis_hash, protocol, - // unbonding_period, + unbonding_period, logo, particle, - } => execute_create_new_item(deps, info,name,chain_id,genesis_hash, protocol, logo, particle), + } => execute_create_entry(deps, info, name, chain_id, prefix, genesis_hash, protocol, unbonding_period, logo, particle), ExecuteMsg::UpdateEntry { id, name, chain_id, + prefix, genesis_hash, protocol, - // unbonding_period, + unbonding_period, logo, particle, - } => execute_update_item(deps, info, id, name,chain_id,genesis_hash,protocol,logo,particle), + } => execute_update_entry(deps, info, id, name, chain_id, prefix, genesis_hash, protocol, unbonding_period, logo, particle), ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), } } - - #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetItems { start_after, limit } => { + QueryMsg::GetEntries { start_after, limit } => { to_binary(&query_list(deps, start_after, limit)?) } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + + Ok(Response::default()) } \ No newline at end of file diff --git a/contracts/cw-cyb-channels/src/error.rs b/contracts/hub-networks/src/error.rs similarity index 73% rename from contracts/cw-cyb-channels/src/error.rs rename to contracts/hub-networks/src/error.rs index 4d32a11..863e417 100644 --- a/contracts/cw-cyb-channels/src/error.rs +++ b/contracts/hub-networks/src/error.rs @@ -14,4 +14,7 @@ pub enum ContractError { #[error("Custom Error val: {val:?}")] CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, } diff --git a/contracts/cw-cyb-network/src/query.rs b/contracts/hub-networks/src/execute.rs similarity index 54% rename from contracts/cw-cyb-network/src/query.rs rename to contracts/hub-networks/src/execute.rs index c57ea02..b2e341e 100644 --- a/contracts/cw-cyb-network/src/query.rs +++ b/contracts/hub-networks/src/execute.rs @@ -1,36 +1,53 @@ -use cid::{Cid, Version}; -use std::str::FromStr; - -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, -}; -use crate::validating::{validate_by_basic_rule,validate_ipfs_cid}; - -use cw_storage_plus::Bound; use std::ops::Add; +use cosmwasm_std::{attr, DepsMut, Env, MessageInfo, Response, StdResult}; use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, CONFIG, ENTRY_SEQ, LIST}; +use crate::state::{CONFIG, Entry, ENTRY_SEQ, LIST}; +use crate::validating::{validate_by_basic_rule, validate_ipfs_cid, validate_period}; + +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 20; + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } + + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} -pub fn execute_create_new_item( +pub fn execute_create_entry( deps: DepsMut, info: MessageInfo, name: String, chain_id: String, + prefix: String, genesis_hash: String, protocol: String, - // unbonding_period: String, + unbonding_period: String, logo: String, particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -45,20 +62,19 @@ pub fn execute_create_new_item( return validate_particle; } } - - + let validate_chainid = validate_by_basic_rule(chain_id.clone(), "chain-id".to_string()); + let validate_prefix = validate_by_basic_rule(prefix.clone(), "prefix".to_string()); let validate_genesishash = validate_by_basic_rule(genesis_hash.clone(), "genesis_hash".to_string()); let validate_name = validate_by_basic_rule(name.clone(), "name".to_string()); let validate_protocol = validate_by_basic_rule(protocol.clone(), "protocol".to_string()); - - + let validate_unbonding_period = validate_period(unbonding_period.clone(), "protocol".to_string()); if validate_chainid.is_err() { return validate_chainid; } - if validate_chainid.is_err() { - return validate_chainid; + if validate_prefix.is_err() { + return validate_prefix; } if validate_genesishash.is_err() { return validate_genesishash; @@ -69,41 +85,47 @@ pub fn execute_create_new_item( if validate_protocol.is_err() { return validate_protocol; } - - + if validate_unbonding_period.is_err() { + return validate_protocol; + } let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; - //FIXME + let new_entry = Entry { id, name, chain_id, + prefix, genesis_hash, protocol, - // unbonding_period, + unbonding_period, logo, particle: particle.unwrap_or("".to_string()), }; LIST.save(deps.storage, id, &new_entry)?; Ok(Response::new() - .add_attribute("method", "execute_create_new_item") + .add_attribute("method", "execute_create_entry") .add_attribute("new_entry_id", id.to_string())) } -pub fn execute_update_item( +pub fn execute_update_entry( deps: DepsMut, info: MessageInfo, id: u64, name: Option, chain_id: Option, + prefix: Option, genesis_hash: Option, protocol: Option, - // unbonding_period: Option, + unbonding_period: Option, logo: Option, particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -118,14 +140,13 @@ pub fn execute_update_item( return validate_particle; } } - - + let validate_chainid = validate_by_basic_rule(chain_id.as_ref().unwrap().clone(), "chain-id".to_string()); + let validate_prefix = validate_by_basic_rule(prefix.as_ref().unwrap().clone(), "prefix".to_string()); let validate_genesishash = validate_by_basic_rule(genesis_hash.as_ref().unwrap().clone(), "genesis_hash".to_string()); let validate_name = validate_by_basic_rule(name.as_ref().unwrap().clone(), "name".to_string()); let validate_protocol = validate_by_basic_rule(protocol.as_ref().unwrap().clone(), "protocol".to_string()); - - + let validate_unbonding_period = validate_period(unbonding_period.as_ref().unwrap().clone(), "protocol".to_string()); if validate_chainid.is_err() { return validate_chainid; @@ -133,6 +154,9 @@ pub fn execute_update_item( if validate_chainid.is_err() { return validate_chainid; } + if validate_prefix.is_err() { + return validate_prefix; + } if validate_genesishash.is_err() { return validate_genesishash; } @@ -142,71 +166,27 @@ pub fn execute_update_item( if validate_protocol.is_err() { return validate_protocol; } - - //////// - - // if !logo.as_ref().is_none() { - // let particle:Cid; - // let try_particle = Cid::from_str(&logo.as_ref().unwrap().clone()); - // if try_particle.is_ok() { - // particle = try_particle.unwrap(); - // if particle.version() != Version::V0 { - // return Err(ContractError::IncorrectInputData {val: "Incorrect Logo".to_string()}); - // } - // } else { - // return Err(ContractError::IncorrectInputData {val: "Incorrect Logo".to_string()}); - // } - // } - - // for byte in chain_id.as_ref().unwrap().as_bytes().iter() { - // // - && 0-9 && a-z - // if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { - // return Err(ContractError::IncorrectInputData {val: "Incorrect Chain-id. a-z0-9- allowed".to_string()}); - // } - // } - - // for byte in genesis_hash.as_ref().unwrap().as_bytes().iter() { - // // - && 0-9 && a-z - // if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { - // return Err(ContractError::IncorrectInputData {val: "Incorrect Genesis_hash. a-z0-9- allowed".to_string()}); - // } - // } - - // for byte in name.as_ref().unwrap().as_bytes().iter() { - // // - && 0-9 && a-z - // if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { - // return Err(ContractError::IncorrectInputData {val: "Incorrect Name. a-z0-9- allowed".to_string()}); - // } - // } - - // for byte in unbonding_period.as_ref().unwrap().as_bytes().iter() { - // // 0-9 - // if *byte < 48 || *byte > 57 { - // return Err(ContractError::IncorrectInputData {val: "Incorrect Unbonding_period. 0-9 allowed".to_string()}); - // } - // } - - // for byte in particle.as_ref().unwrap().as_bytes().iter() { - // // :/.-_0-9a-zA-Z - // if (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { - // return Err(ContractError::IncorrectInputData {val: "Incorrect particle. Only url allowed".to_string()}); - // } - // } + if validate_unbonding_period.is_err() { + return validate_protocol; + } let entry = LIST.load(deps.storage, id)?; let updated_entry = Entry { id, name: name.unwrap_or(entry.name), chain_id: chain_id.unwrap_or(entry.chain_id), + prefix: prefix.unwrap_or(entry.prefix), genesis_hash: genesis_hash.unwrap_or(entry.genesis_hash), protocol: protocol.unwrap_or(entry.protocol), - // unbonding_period: unbonding_period.unwrap_or(entry.unbonding_period), + unbonding_period: unbonding_period.unwrap_or(entry.unbonding_period), logo: logo.unwrap_or(entry.logo), particle: particle.unwrap_or(entry.particle), }; + LIST.save(deps.storage, id, &updated_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_update_item") + .add_attribute("method", "execute_update_entry") .add_attribute("updated_entry_id", id.to_string())) } @@ -216,29 +196,16 @@ pub fn execute_delete_entry( id: u64, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } LIST.remove(deps.storage, id); + Ok(Response::new() .add_attribute("method", "execute_delete_entry") .add_attribute("deleted_entry_id", id.to_string())) } - - - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - let entries: StdResult> = LIST - .range(deps.storage, start, None, Order::Ascending) - .take(limit) - .collect(); - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/cw-cyb-heroes/src/lib.rs b/contracts/hub-networks/src/lib.rs similarity index 81% rename from contracts/cw-cyb-heroes/src/lib.rs rename to contracts/hub-networks/src/lib.rs index b085561..0a43c7c 100644 --- a/contracts/cw-cyb-heroes/src/lib.rs +++ b/contracts/hub-networks/src/lib.rs @@ -1,9 +1,10 @@ pub mod contract; mod error; pub mod msg; -pub mod query; +pub mod execute; pub mod state; pub mod validating; mod tests; +mod query; pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-network/src/msg.rs b/contracts/hub-networks/src/msg.rs similarity index 77% rename from contracts/cw-cyb-network/src/msg.rs rename to contracts/hub-networks/src/msg.rs index 2e8d842..119b2dd 100644 --- a/contracts/cw-cyb-network/src/msg.rs +++ b/contracts/hub-networks/src/msg.rs @@ -1,5 +1,4 @@ use crate::state::{Entry}; -// use cosmwasm_std::{Uint64}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -10,12 +9,16 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + CreateEntry { name: String, chain_id: String, + prefix: String, genesis_hash: String, protocol: String, - // unbonding_period: String, + unbonding_period: String, logo: String, particle: Option, }, @@ -23,9 +26,10 @@ pub enum ExecuteMsg { id: u64, name: Option, chain_id: Option, + prefix: Option, genesis_hash: Option, protocol: Option, - // unbonding_period: Option, + unbonding_period: Option, logo: Option, particle: Option, }, @@ -37,21 +41,25 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, limit: Option, }, + GetEntry { id: u64 } } +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { pub id: u64, pub name: String, pub chain_id: String, + pub prefix: String, pub genesis_hash: String, pub protocol: String, - // pub unbonding_period: String, + pub unbonding_period: String, pub logo: String, pub particle: String, } diff --git a/contracts/hub-networks/src/query.rs b/contracts/hub-networks/src/query.rs new file mode 100644 index 0000000..2f49416 --- /dev/null +++ b/contracts/hub-networks/src/query.rs @@ -0,0 +1,39 @@ +use cosmwasm_std::{Deps, Order, StdResult}; +use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::LIST; + +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 20; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = LIST.load(deps.storage, id)?; + + Ok(EntryResponse { + id, + name: entry.name, + chain_id: entry.chain_id, + prefix: entry.prefix, + genesis_hash: entry.genesis_hash, + protocol: entry.protocol, + unbonding_period: entry.unbonding_period, + logo: entry.logo, + particle: entry.particle + }) +} + +pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let entries: StdResult> = LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} \ No newline at end of file diff --git a/contracts/cw-cyb-network/src/state.rs b/contracts/hub-networks/src/state.rs similarity index 88% rename from contracts/cw-cyb-network/src/state.rs rename to contracts/hub-networks/src/state.rs index dea84c5..f792de8 100644 --- a/contracts/cw-cyb-network/src/state.rs +++ b/contracts/hub-networks/src/state.rs @@ -7,7 +7,7 @@ use cw_storage_plus::{Item, Map}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -15,15 +15,15 @@ pub struct Entry { pub id: u64, pub name: String, pub chain_id: String, + pub prefix: String, pub genesis_hash: String, - + pub unbonding_period: String, pub protocol: String, pub logo: String, pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); pub const LIST: Map = Map::new("list"); diff --git a/contracts/cw-cyb-network/src/tests.rs b/contracts/hub-networks/src/tests.rs similarity index 85% rename from contracts/cw-cyb-network/src/tests.rs rename to contracts/hub-networks/src/tests.rs index 069c60b..5f883d9 100644 --- a/contracts/cw-cyb-network/src/tests.rs +++ b/contracts/hub-networks/src/tests.rs @@ -2,14 +2,11 @@ #[cfg(test)] mod tests { - // use super::*; - // use cosmwasm_std::{Uint64}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{attr, from_binary, Addr}; use std::vec::Vec; use crate::state::{Entry, CONFIG, Config}; use crate::msg::{ ListResponse, QueryMsg, InstantiateMsg, ExecuteMsg}; - // use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::contract::{query, execute, instantiate}; #[test] @@ -28,7 +25,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -44,7 +41,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -59,11 +56,13 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { name: "tst".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -72,16 +71,18 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { name: "tst2".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -90,7 +91,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -99,7 +100,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -113,7 +114,9 @@ mod tests { name: "tst".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }, @@ -122,7 +125,9 @@ mod tests { name: "tst2".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), } @@ -136,7 +141,9 @@ mod tests { name: Some("tstu".to_string()), protocol: Some("tst2".to_string()), chain_id: Some("cyber-1".to_string()), + prefix: Some("cyb".to_string()), genesis_hash: Some("bostrom0x1".to_string()), + unbonding_period: Some("42".to_string()), logo: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -145,7 +152,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); @@ -156,7 +163,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -170,7 +177,9 @@ mod tests { name: "tstu".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }, @@ -179,7 +188,9 @@ mod tests { name: "tst2".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), } @@ -202,7 +213,7 @@ mod tests { let res = query( deps.as_ref(), env, - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -215,7 +226,9 @@ mod tests { name: "tst2".to_string(), protocol: "tst2".to_string(), chain_id: "cyber-1".to_string(), + prefix: "cyb".to_string(), genesis_hash: "bostrom0x1".to_string(), + unbonding_period: "42".to_string(), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }]), diff --git a/contracts/cw-cyb-endpoints/src/validating.rs b/contracts/hub-networks/src/validating.rs similarity index 65% rename from contracts/cw-cyb-endpoints/src/validating.rs rename to contracts/hub-networks/src/validating.rs index f12c7fd..1f9c592 100644 --- a/contracts/cw-cyb-endpoints/src/validating.rs +++ b/contracts/hub-networks/src/validating.rs @@ -5,14 +5,13 @@ use cosmwasm_std::{ Response, }; -/** - * Baseic rule /[a-z0-9-]/ +/* + * Basic rule /[a-z0-9-]/ */ pub fn validate_by_basic_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -23,10 +22,26 @@ pub fn validate_by_basic_rule( Ok(Response::default()) } +/* + * Basic rule /[0-9]/ + */ +pub fn validate_period( + val: String, + field_name: String, +) -> Result { + for byte in val.as_bytes().iter() { + // 0-9 + if *byte < 48 || *byte > 57 { + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field field {}. Allowed expression /[0-9]/", field_name).to_string()}); + } + } + + Ok(Response::default()) +} + pub fn validate_datatype( val: String ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -40,7 +55,6 @@ pub fn validate_datatype( pub fn validate_url( val: String ) -> Result { - for byte in val.as_bytes().iter() { // : / . - _ 0-9 a-z A-Z if (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { @@ -51,29 +65,21 @@ pub fn validate_url( Ok(Response::default()) } - -pub fn validate_particle( - particle: Option +pub fn validate_ipfs_cid( + particle: String ) -> Result { - - if !particle.as_ref().is_none() { - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.as_ref().unwrap().clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { - - return Err(ContractError::IncorrectInputData {val: "Incorrect particle".to_string()}); - - } - } else { - return Err(ContractError::IncorrectInputData {val: "Incorrect particle".to_string()}); + let particle_value:Cid; + let try_particle = Cid::from_str(&particle.clone()); + if try_particle.is_ok() { + particle_value = try_particle.unwrap(); + if particle_value.version() != Version::V0 { + return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); } - Ok(Response::default()) } else { - Ok(Response::default()) + return Err(ContractError::IncorrectInputData {val: "Incorrect cid".to_string()}); } + + Ok(Response::default()) } diff --git a/contracts/cw-cyb-network/.cargo/config b/contracts/hub-protocols/.cargo/config similarity index 100% rename from contracts/cw-cyb-network/.cargo/config rename to contracts/hub-protocols/.cargo/config diff --git a/contracts/cw-cyb-contract/Cargo.toml b/contracts/hub-protocols/Cargo.toml similarity index 86% rename from contracts/cw-cyb-contract/Cargo.toml rename to contracts/hub-protocols/Cargo.toml index 260a655..dcb57e1 100644 --- a/contracts/cw-cyb-contract/Cargo.toml +++ b/contracts/hub-protocols/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cw-cyb-contract" +name = "hub-protocols" version = "0.1.0" authors = ["Bloqhub"] edition = "2018" @@ -15,17 +15,6 @@ exclude = [ [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] diff --git a/contracts/hub-protocols/examples/schema.rs b/contracts/hub-protocols/examples/schema.rs new file mode 100644 index 0000000..d96e492 --- /dev/null +++ b/contracts/hub-protocols/examples/schema.rs @@ -0,0 +1,17 @@ +use std::env::current_dir; +use std::fs::create_dir_all; + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; + +use hub_protocols::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + +fn main() { + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(InstantiateMsg), &out_dir); + export_schema(&schema_for!(ExecuteMsg), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); +} diff --git a/contracts/hub-protocols/schema/execute_msg.json b/contracts/hub-protocols/schema/execute_msg.json new file mode 100644 index 0000000..3098769 --- /dev/null +++ b/contracts/hub-protocols/schema/execute_msg.json @@ -0,0 +1,106 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "data_type" + ], + "properties": { + "data_type": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "data_type", + "id" + ], + "properties": { + "data_type": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "particle": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-protocols/schema/instantiate_msg.json b/contracts/hub-protocols/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-protocols/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-protocols/schema/query_msg.json b/contracts/hub-protocols/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-protocols/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-endpoints/src/contract.rs b/contracts/hub-protocols/src/contract.rs similarity index 53% rename from contracts/cw-cyb-endpoints/src/contract.rs rename to contracts/hub-protocols/src/contract.rs index 1c1b7ff..2cb405f 100644 --- a/contracts/cw-cyb-endpoints/src/contract.rs +++ b/contracts/hub-protocols/src/contract.rs @@ -1,20 +1,19 @@ use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary, }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; - -use cw2::set_contract_version; +use cw2::{get_contract_version, set_contract_version}; use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list}; use crate::state::{Config, CONFIG, ENTRY_SEQ}; //@TODO git version iteract -const CONTRACT_NAME: &str = "cw-endpoints"; -const CONTRACT_VERSION: &str = "1.0.0"; +const CONTRACT_NAME: &str = "hub-protocols"; +const CONTRACT_VERSION: &str = "0.1.0"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( @@ -31,7 +30,7 @@ pub fn instantiate( .unwrap_or(info.sender); let config = Config { - owner: owner.clone(), + owner: Some(owner.clone()), }; CONFIG.save(deps.storage, &config)?; @@ -45,37 +44,45 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::NewEntry { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::CreateEntry { data_type, - protocol, - chain_id, - url, particle, - } => execute_create_new_item(deps, info, data_type, protocol, chain_id, url, particle), + } => execute_create_entry(deps, info, data_type, particle), ExecuteMsg::UpdateEntry { id, data_type, - protocol, - chain_id, - url, particle, - } => execute_update_item(deps, info, id, data_type, protocol, chain_id, url, particle), + } => execute_update_entry(deps, info, id, data_type, particle), ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), } } - - #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetItems { start_after, limit } => { + QueryMsg::GetEntries { start_after, limit } => { to_binary(&query_list(deps, start_after, limit)?) } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + + Ok(Response::default()) } \ No newline at end of file diff --git a/contracts/hub-protocols/src/error.rs b/contracts/hub-protocols/src/error.rs new file mode 100644 index 0000000..863e417 --- /dev/null +++ b/contracts/hub-protocols/src/error.rs @@ -0,0 +1,20 @@ +use cosmwasm_std::StdError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Unauthorized")] + Unauthorized {}, + + #[error("IncorrectInputData val: {val:?}")] + IncorrectInputData {val: String }, + + #[error("Custom Error val: {val:?}")] + CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, +} diff --git a/contracts/cw-cyb-protocols/src/query.rs b/contracts/hub-protocols/src/execute.rs similarity index 60% rename from contracts/cw-cyb-protocols/src/query.rs rename to contracts/hub-protocols/src/execute.rs index c9c6483..f719506 100644 --- a/contracts/cw-cyb-protocols/src/query.rs +++ b/contracts/hub-protocols/src/execute.rs @@ -1,33 +1,50 @@ -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, -}; - -use cw_storage_plus::Bound; use std::ops::Add; +use cosmwasm_std::{attr, DepsMut, Env, MessageInfo, Response, StdResult}; use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, CONFIG, ENTRY_SEQ, LIST}; -use crate::validating::{validate_particle,validate_datatype}; +use crate::state::{CONFIG, Entry, ENTRY_SEQ, LIST}; +use crate::validating::{validate_datatype, validate_particle}; + +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 20; + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; -pub fn execute_create_new_item( + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} + +pub fn execute_create_entry( deps: DepsMut, info: MessageInfo, data_type: String, particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } - - let validate_particle = validate_particle(particle.clone()); let validate_data_typer = validate_datatype(data_type.clone()); @@ -38,8 +55,6 @@ pub fn execute_create_new_item( return validate_data_typer; } - - let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; let new_entry = Entry { @@ -47,13 +62,15 @@ pub fn execute_create_new_item( data_type: data_type, particle: particle.unwrap_or("".to_string()).to_string(), }; + LIST.save(deps.storage, id, &new_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_create_new_item") + .add_attribute("method", "execute_create_entry") .add_attribute("new_entry_id", id.to_string())) } -pub fn execute_update_item( +pub fn execute_update_entry( deps: DepsMut, info: MessageInfo, id: u64, @@ -61,7 +78,10 @@ pub fn execute_update_item( particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -74,19 +94,18 @@ pub fn execute_update_item( if validate_data_typer.is_err() { return validate_data_typer; } - - - - let entry = LIST.load(deps.storage, id)?; + let _entry = LIST.load(deps.storage, id)?; let updated_entry = Entry { id, data_type: data_type, particle: particle.unwrap_or("".to_string()), }; + LIST.save(deps.storage, id, &updated_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_update_item") + .add_attribute("method", "execute_update_entry") .add_attribute("updated_entry_id", id.to_string())) } @@ -96,27 +115,16 @@ pub fn execute_delete_entry( id: u64, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } LIST.remove(deps.storage, id); + Ok(Response::new() .add_attribute("method", "execute_delete_entry") .add_attribute("deleted_entry_id", id.to_string())) -} - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - let entries: StdResult> = LIST - .range(deps.storage, start, None, Order::Ascending) - .take(limit) - .collect(); - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} +} \ No newline at end of file diff --git a/contracts/hub-protocols/src/lib.rs b/contracts/hub-protocols/src/lib.rs new file mode 100644 index 0000000..0a43c7c --- /dev/null +++ b/contracts/hub-protocols/src/lib.rs @@ -0,0 +1,10 @@ +pub mod contract; +mod error; +pub mod msg; +pub mod execute; +pub mod state; +pub mod validating; +mod tests; +mod query; + +pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-protocols/src/msg.rs b/contracts/hub-protocols/src/msg.rs similarity index 82% rename from contracts/cw-cyb-protocols/src/msg.rs rename to contracts/hub-protocols/src/msg.rs index eaa7dce..9c7ad90 100644 --- a/contracts/cw-cyb-protocols/src/msg.rs +++ b/contracts/hub-protocols/src/msg.rs @@ -9,7 +9,10 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + CreateEntry { data_type: String, particle: Option, }, @@ -26,13 +29,16 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, limit: Option, }, + GetEntry { id: u64 } } -// Tokens +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { pub id: u64, diff --git a/contracts/hub-protocols/src/query.rs b/contracts/hub-protocols/src/query.rs new file mode 100644 index 0000000..e92a87e --- /dev/null +++ b/contracts/hub-protocols/src/query.rs @@ -0,0 +1,33 @@ +use cosmwasm_std::{Deps, Order, StdResult}; +use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::LIST; + +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 20; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = LIST.load(deps.storage, id)?; + + Ok(EntryResponse { + id, + data_type: entry.data_type, + particle: entry.particle + }) +} + +pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let entries: StdResult> = LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} diff --git a/contracts/hub-protocols/src/schema/execute_msg.json b/contracts/hub-protocols/src/schema/execute_msg.json new file mode 100644 index 0000000..3098769 --- /dev/null +++ b/contracts/hub-protocols/src/schema/execute_msg.json @@ -0,0 +1,106 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "data_type" + ], + "properties": { + "data_type": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "data_type", + "id" + ], + "properties": { + "data_type": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "particle": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-protocols/src/schema/instantiate_msg.json b/contracts/hub-protocols/src/schema/instantiate_msg.json new file mode 100644 index 0000000..2f38907 --- /dev/null +++ b/contracts/hub-protocols/src/schema/instantiate_msg.json @@ -0,0 +1,3 @@ +{ + "owner": "bostrom1d8754xqa9245pctlfcyv8eah468neqzn3a0y0t" +} \ No newline at end of file diff --git a/contracts/hub-protocols/src/schema/query_msg.json b/contracts/hub-protocols/src/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-protocols/src/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-protocols/src/state.rs b/contracts/hub-protocols/src/state.rs similarity index 94% rename from contracts/cw-cyb-protocols/src/state.rs rename to contracts/hub-protocols/src/state.rs index 4dcaa9e..df2df04 100644 --- a/contracts/cw-cyb-protocols/src/state.rs +++ b/contracts/hub-protocols/src/state.rs @@ -6,7 +6,7 @@ use cw_storage_plus::{Item, Map}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -16,7 +16,6 @@ pub struct Entry { pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); pub const LIST: Map = Map::new("list"); diff --git a/contracts/cw-cyb-protocols/src/tests.rs b/contracts/hub-protocols/src/tests.rs similarity index 91% rename from contracts/cw-cyb-protocols/src/tests.rs rename to contracts/hub-protocols/src/tests.rs index f74b71c..06af673 100644 --- a/contracts/cw-cyb-protocols/src/tests.rs +++ b/contracts/hub-protocols/src/tests.rs @@ -28,7 +28,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -44,7 +44,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -59,7 +59,7 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { data_type: "testchain-1".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -68,12 +68,12 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { data_type: "testchain-1".to_string(), // particle: None, particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), @@ -83,7 +83,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -92,7 +92,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -128,7 +128,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); @@ -139,7 +139,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -178,7 +178,7 @@ mod tests { let res = query( deps.as_ref(), env, - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, diff --git a/contracts/cw-cyb-protocols/src/validating.rs b/contracts/hub-protocols/src/validating.rs similarity index 99% rename from contracts/cw-cyb-protocols/src/validating.rs rename to contracts/hub-protocols/src/validating.rs index f9c3ea7..f3b17be 100644 --- a/contracts/cw-cyb-protocols/src/validating.rs +++ b/contracts/hub-protocols/src/validating.rs @@ -8,7 +8,6 @@ use cosmwasm_std::{ pub fn validate_datatype( val: String ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -23,7 +22,6 @@ pub fn validate_datatype( pub fn validate_particle( particle: Option ) -> Result { - if !particle.as_ref().is_none() { let particle_value:Cid; let try_particle = Cid::from_str(&particle.as_ref().unwrap().clone()); diff --git a/contracts/cw-cyb-protocols/.cargo/config b/contracts/hub-skills/.cargo/config similarity index 100% rename from contracts/cw-cyb-protocols/.cargo/config rename to contracts/hub-skills/.cargo/config diff --git a/contracts/cw-cyb-heroes/Cargo.lock b/contracts/hub-skills/Cargo.lock similarity index 100% rename from contracts/cw-cyb-heroes/Cargo.lock rename to contracts/hub-skills/Cargo.lock diff --git a/contracts/cw-cyb-skills/Cargo.toml b/contracts/hub-skills/Cargo.toml similarity index 86% rename from contracts/cw-cyb-skills/Cargo.toml rename to contracts/hub-skills/Cargo.toml index 9f28037..5577a3c 100644 --- a/contracts/cw-cyb-skills/Cargo.toml +++ b/contracts/hub-skills/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cw-cyb-skills" +name = "hub-skills" version = "0.1.0" authors = ["Bloqhub"] edition = "2018" @@ -15,17 +15,6 @@ exclude = [ [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] diff --git a/contracts/hub-skills/examples/schema.rs b/contracts/hub-skills/examples/schema.rs new file mode 100644 index 0000000..4b03d9a --- /dev/null +++ b/contracts/hub-skills/examples/schema.rs @@ -0,0 +1,17 @@ +use std::env::current_dir; +use std::fs::create_dir_all; + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; + +use hub_skills::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + +fn main() { + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(InstantiateMsg), &out_dir); + export_schema(&schema_for!(ExecuteMsg), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); +} diff --git a/contracts/hub-skills/schema/execute_msg.json b/contracts/hub-skills/schema/execute_msg.json new file mode 100644 index 0000000..034fe97 --- /dev/null +++ b/contracts/hub-skills/schema/execute_msg.json @@ -0,0 +1,164 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntryOwner" + ], + "properties": { + "UpdateEntryOwner": { + "type": "object", + "required": [ + "id", + "new_owner" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "new_owner": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "endpoint", + "network", + "neuron", + "protocol" + ], + "properties": { + "endpoint": { + "type": "string" + }, + "network": { + "type": "string" + }, + "neuron": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "protocol": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "endpoint": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "network": { + "type": [ + "string", + "null" + ] + }, + "neuron": { + "type": [ + "string", + "null" + ] + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "protocol": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/hub-skills/schema/instantiate_msg.json b/contracts/hub-skills/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-skills/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-skills/schema/query_msg.json b/contracts/hub-skills/schema/query_msg.json new file mode 100644 index 0000000..ab97d17 --- /dev/null +++ b/contracts/hub-skills/schema/query_msg.json @@ -0,0 +1,142 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "$ref": "#/definitions/Addr" + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entries_protocol" + ], + "properties": { + "get_entries_protocol": { + "type": "object", + "required": [ + "protocol" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "protocol": { + "type": "string" + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entries_network" + ], + "properties": { + "get_entries_network": { + "type": "object", + "required": [ + "network" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "network": { + "type": "string" + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + } + } +} diff --git a/contracts/hub-skills/src/contract.rs b/contracts/hub-skills/src/contract.rs new file mode 100644 index 0000000..47e9128 --- /dev/null +++ b/contracts/hub-skills/src/contract.rs @@ -0,0 +1,100 @@ +use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary}; +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cw2::{get_contract_version, set_contract_version}; + +use crate::error::ContractError; +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_entry_owner, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list_by_network, query_list_by_owner, query_list_by_protocol}; +use crate::state::{Config, CONFIG, ENTRY_SEQ}; + +//@TODO git version iteract +const CONTRACT_NAME: &str = "cw-skills"; +const CONTRACT_VERSION: &str = "0.1.0"; + +#[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)?; + + let owner = msg + .owner + .and_then(|addr_string| deps.api.addr_validate(addr_string.as_str()).ok()) + .unwrap_or(info.sender); + + let config = Config { + owner: Some(owner.clone()), + }; + + CONFIG.save(deps.storage, &config)?; + + ENTRY_SEQ.save(deps.storage, &0u64)?; + + Ok(Response::new() + .add_attribute("method", "instantiate") + .add_attribute("owner", owner)) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::UpdateEntryOwner { id, new_owner } => execute_update_entry_owner(deps, env, info, id, new_owner), + ExecuteMsg::CreateEntry { + neuron, + protocol, + network, + endpoint, + particle, + } => execute_create_entry(deps, info, neuron, network, protocol, endpoint, particle), + ExecuteMsg::UpdateEntry { + id, + neuron, + protocol, + network, + endpoint, + particle, + } => execute_update_entry(deps, info, id, neuron, network, protocol, endpoint, particle), + ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), + } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetEntries { start_after, limit, owner } => { + to_binary(&query_list_by_owner(deps, start_after, limit, owner)?) + } + QueryMsg::GetEntriesProtocol { start_after, limit, protocol } => { + to_binary(&query_list_by_protocol(deps, start_after, limit, protocol)?) + } + QueryMsg::GetEntriesNetwork { start_after, limit, network } => { + to_binary(&query_list_by_network(deps, start_after, limit, network)?) + } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } + } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); + } + + Ok(Response::default()) +} \ No newline at end of file diff --git a/contracts/hub-skills/src/error.rs b/contracts/hub-skills/src/error.rs new file mode 100644 index 0000000..863e417 --- /dev/null +++ b/contracts/hub-skills/src/error.rs @@ -0,0 +1,20 @@ +use cosmwasm_std::StdError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Unauthorized")] + Unauthorized {}, + + #[error("IncorrectInputData val: {val:?}")] + IncorrectInputData {val: String }, + + #[error("Custom Error val: {val:?}")] + CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, +} diff --git a/contracts/cw-cyb-skills/src/query.rs b/contracts/hub-skills/src/execute.rs similarity index 55% rename from contracts/cw-cyb-skills/src/query.rs rename to contracts/hub-skills/src/execute.rs index 5476975..0bfb35e 100644 --- a/contracts/cw-cyb-skills/src/query.rs +++ b/contracts/hub-skills/src/execute.rs @@ -1,32 +1,79 @@ -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, Addr, -}; -use cw_storage_plus::IndexedMap; - -// use cw_storage_plus::Bound; use std::ops::Add; -use crate::validating::{validate_by_basic_rule,validate_ipfs_cid, validate_url}; -use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, ENTRY_SEQ, items}; +use cosmwasm_std::{Addr, attr, DepsMut, Env, MessageInfo, Response, StdResult}; -const MAX_LIMIT: u32 = 50; -const DEFAULT_LIMIT: u32 = 30; +use crate::error::ContractError; +use crate::state::{CONFIG, entries, Entry, ENTRY_SEQ}; +use crate::validating::{validate_by_basic_rule, validate_ipfs_cid, validate_url}; pub fn uniq_key_by_owner(owner: Addr, id: u64) -> (Addr, u64) { (owner.clone(), id.clone()) } -pub fn execute_create_new_item( +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } + + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } + + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; + + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} + +pub fn execute_update_entry_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + id: u64, + new_owner: String, +) -> Result { + let entry = entries().load(deps.storage, id)?; + + if entry.owner != info.sender { + return Err(ContractError::Unauthorized {}); + } + + let updated_entry = Entry { + id, + neuron: entry.neuron, + network: entry.network, + protocol: entry.protocol, + endpoint: entry.endpoint, + owner: deps.api.addr_validate(&new_owner)?, + particle: entry.particle, + }; + + entries().save(deps.storage, id, &updated_entry)?; + + Ok(Response::new() + .add_attribute("method", "execute_update_entry_owner") + .add_attribute("updated_entry_id", id.to_string())) +} + +pub fn execute_create_entry( deps: DepsMut, info: MessageInfo, neuron: String, + network: String, protocol: String, endpoint: String, particle: Option, ) -> Result { - if !particle.as_ref().is_none() { let validate_particle = validate_ipfs_cid(particle.clone().unwrap(),"particle".to_string()); if validate_particle.is_err() { @@ -34,14 +81,17 @@ pub fn execute_create_new_item( } } - let validate_neuron = validate_by_basic_rule(neuron.clone(), "neuron".to_string()); + let validate_network = validate_by_basic_rule(network.clone(), "network".to_string()); let validate_protocol = validate_by_basic_rule(protocol.clone(), "protocol".to_string()); let validate_endpoint = validate_url(endpoint.clone(), "endpoint".to_string()); if validate_neuron.is_err() { return validate_neuron; } + if validate_network.is_err() { + return validate_network; + } if validate_protocol.is_err() { return validate_protocol; } @@ -49,41 +99,34 @@ pub fn execute_create_new_item( return validate_endpoint; } - - - let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; let new_entry = Entry { id, neuron, + network, protocol, endpoint, owner: info.sender, particle: particle.unwrap_or("".to_string()) }; - - items().save(deps.storage, id, &new_entry)?; + entries().save(deps.storage, id, &new_entry)?; Ok(Response::new() - .add_attribute("method", "execute_create_new_item") + .add_attribute("method", "execute_create_entry") .add_attribute("new_entry_id", id.to_string())) } -pub fn execute_update_item( +pub fn execute_update_entry( deps: DepsMut, info: MessageInfo, id: u64, neuron: Option, + network: Option, protocol: Option, endpoint: Option, particle: Option, ) -> Result { - // let owner = CONFIG.load(deps.storage)?.owner; - // if info.sender != owner { - // return Err(ContractError::Unauthorized {}); - // } - if !particle.as_ref().is_none() { let validate_particle = validate_ipfs_cid(particle.clone().unwrap(),"particle".to_string()); if validate_particle.is_err() { @@ -92,38 +135,43 @@ pub fn execute_update_item( } let validate_neuron = validate_by_basic_rule(neuron.clone().unwrap(), "neuron".to_string()); + let validate_network = validate_by_basic_rule(network.clone().unwrap(), "network".to_string()); let validate_protocol = validate_by_basic_rule(protocol.clone().unwrap(), "protocol".to_string()); let validate_endpoint = validate_url(endpoint.clone().unwrap(), "endpoint".to_string()); if validate_neuron.is_err() { return validate_neuron; } + if validate_network.is_err() { + return validate_network; + } if validate_protocol.is_err() { return validate_protocol; } if validate_endpoint.is_err() { return validate_endpoint; } - - let entry = items().load(deps.storage, id)?; + let entry = entries().load(deps.storage, id)?; if entry.owner != info.sender { return Err(ContractError::Unauthorized {}); } - let updated_entry = Entry { id, neuron: neuron.unwrap_or(entry.neuron), + network: network.unwrap_or(entry.network), protocol: protocol.unwrap_or(entry.protocol), endpoint: endpoint.unwrap_or(entry.endpoint), owner: entry.owner, particle: particle.unwrap_or("".to_string()), }; - items().save(deps.storage, id, &updated_entry)?; + + entries().save(deps.storage, id, &updated_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_update_item") + .add_attribute("method", "execute_update_entry") .add_attribute("updated_entry_id", id.to_string())) } @@ -132,53 +180,15 @@ pub fn execute_delete_entry( info: MessageInfo, id: u64, ) -> Result { - // let owner = CONFIG.load(deps.storage)?.owner; - // if info.sender != owner { - // return Err(ContractError::Unauthorized {}); - // } - - // let key = uniq_key_by_owner(info.sender, id); - let entry = items().load(deps.storage, id)?; + let entry = entries().load(deps.storage, id)?; if entry.owner != info.sender { return Err(ContractError::Unauthorized {}); } - let _result = items().remove(deps.storage, id); - + let _result = entries().remove(deps.storage, id); Ok(Response::new() .add_attribute("method", "execute_delete_entry") .add_attribute("deleted_entry_id", id.to_string())) } - - - - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option, protocol: Option, owner: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - - - // let indexedArr = items(); - let indexed_arr = items().idx.owner; - - let entries: StdResult> = indexed_arr - // .idx - // .owner - .prefix(owner.clone().unwrap_or(Addr::unchecked("")).to_string()) - .range( - deps.storage, - None, - None, - Order::Ascending, - ) - .take(limit) - .collect(); - - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/hub-skills/src/lib.rs b/contracts/hub-skills/src/lib.rs new file mode 100644 index 0000000..0a43c7c --- /dev/null +++ b/contracts/hub-skills/src/lib.rs @@ -0,0 +1,10 @@ +pub mod contract; +mod error; +pub mod msg; +pub mod execute; +pub mod state; +pub mod validating; +mod tests; +mod query; + +pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-skills/src/msg.rs b/contracts/hub-skills/src/msg.rs similarity index 65% rename from contracts/cw-cyb-skills/src/msg.rs rename to contracts/hub-skills/src/msg.rs index cc6748b..34da06f 100644 --- a/contracts/cw-cyb-skills/src/msg.rs +++ b/contracts/hub-skills/src/msg.rs @@ -13,8 +13,16 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + UpdateEntryOwner { + id: u64, + new_owner: String, + }, + CreateEntry { neuron: String, + network: String, protocol: String, endpoint: String, particle: Option, @@ -22,6 +30,7 @@ pub enum ExecuteMsg { UpdateEntry { id: u64, neuron: Option, + network: Option, protocol: Option, endpoint: Option, particle: Option, @@ -34,21 +43,35 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, - owner: Option, - protocol: Option, limit: Option, + owner: Addr, }, + GetEntriesProtocol { + start_after: Option, + limit: Option, + protocol: String, + }, + GetEntriesNetwork { + start_after: Option, + limit: Option, + network: String, + }, + GetEntry { id: u64 } } -// Tokens +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { pub id: u64, pub neuron: String, + pub network: String, pub protocol: String, pub endpoint: String, + pub owner: String, pub particle: String, } diff --git a/contracts/hub-skills/src/query.rs b/contracts/hub-skills/src/query.rs new file mode 100644 index 0000000..e9f7056 --- /dev/null +++ b/contracts/hub-skills/src/query.rs @@ -0,0 +1,96 @@ +use cosmwasm_std::{Addr, Deps, Order, StdResult}; +// use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::entries; + +// const MAX_LIMIT: u32 = 50; +// const DEFAULT_LIMIT: u32 = 30; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = entries().load(deps.storage, id)?; + Ok(EntryResponse { + id, + neuron: entry.neuron, + network: entry.network, + protocol: entry.protocol, + endpoint: entry.endpoint, + owner: entry.owner.to_string(), + particle: entry.particle + }) +} + +pub fn query_list_by_owner(deps: Deps, _start_after: Option, _limit: Option, owner: Addr) -> StdResult { + // TODO + // let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + // let start = start_after.map(Bound::exclusive); + + let indexed_arr = entries().idx.owner; + + let entries: StdResult> = indexed_arr + .prefix(owner.clone().to_string()) + .range( + deps.storage, + None, + None, + Order::Ascending, + ) + // .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} + +pub fn query_list_by_network(deps: Deps, _start_after: Option, _limit: Option, network: String) -> StdResult { + // TODO + // let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + // let start = start_after.map(Bound::exclusive); + + let indexed_arr = entries().idx.network; + + let entries: StdResult> = indexed_arr + .prefix(network.clone().to_string()) + .range( + deps.storage, + None, + None, + Order::Ascending, + ) + // .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} + +pub fn query_list_by_protocol(deps: Deps, _start_after: Option, _limit: Option, protocol: String) -> StdResult { + // TODO + // let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + // let start = start_after.map(Bound::exclusive); + + let indexed_arr = entries().idx.protocol; + + let entries: StdResult> = indexed_arr + .prefix(protocol.clone().to_string()) + .range( + deps.storage, + None, + None, + Order::Ascending, + ) + // .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} \ No newline at end of file diff --git a/contracts/cw-cyb-skills/src/state.rs b/contracts/hub-skills/src/state.rs similarity index 77% rename from contracts/cw-cyb-skills/src/state.rs rename to contracts/hub-skills/src/state.rs index a75b717..8f56474 100644 --- a/contracts/cw-cyb-skills/src/state.rs +++ b/contracts/hub-skills/src/state.rs @@ -6,46 +6,49 @@ use cw_storage_plus::{Item, UniqueIndex, IndexList, IndexedMap, Index, MultiInde #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Entry { pub id: u64, pub neuron: String, + pub network: String, pub protocol: String, pub endpoint: String, pub owner: Addr, pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); - - pub struct EntryIndexes<'a> { pub id: UniqueIndex<'a, u64, Entry>, pub owner: MultiIndex<'a, String, Entry, String>, + pub network: MultiIndex<'a, String, Entry, String>, pub protocol: MultiIndex<'a, String, Entry, String>, - } impl<'a> IndexList for EntryIndexes<'a> { fn get_indexes(&'_ self) -> Box> + '_> { - let v: Vec<&dyn Index> = vec![&self.owner, &self.id]; + let v: Vec<&dyn Index> = vec![&self.id, &self.owner, &self.network, &self.protocol]; Box::new(v.into_iter()) } } -pub fn items<'a>() -> IndexedMap<'a, u64, Entry, EntryIndexes<'a>> { +pub fn entries<'a>() -> IndexedMap<'a, u64, Entry, EntryIndexes<'a>> { let indexes = EntryIndexes { owner: MultiIndex::new( |d| (d.owner.clone().to_string()), "list", "list_owner" ), + network: MultiIndex::new( + |d| (d.network.clone().to_string()), + "list", + "list_network" + ), protocol: MultiIndex::new( |d| (d.protocol.clone().to_string()), "list", diff --git a/contracts/cw-cyb-skills/src/tests.rs b/contracts/hub-skills/src/tests.rs similarity index 64% rename from contracts/cw-cyb-skills/src/tests.rs rename to contracts/hub-skills/src/tests.rs index a18e2ef..0abca05 100644 --- a/contracts/cw-cyb-skills/src/tests.rs +++ b/contracts/hub-skills/src/tests.rs @@ -9,7 +9,7 @@ mod tests { // use std::convert::TryFrom; use std::vec::Vec; use crate::state::{Entry, CONFIG, Config}; - use crate::msg::{ ListResponse, QueryMsg, InstantiateMsg, ExecuteMsg}; + use crate::msg::{ListResponse, QueryMsg, InstantiateMsg, ExecuteMsg, EntryResponse}; // use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::contract::{query, execute, instantiate}; @@ -29,7 +29,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -45,7 +45,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -60,9 +60,10 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "cosmos".to_string(), + protocol: "cosmos-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -71,14 +72,15 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "bostrom".to_string(), + protocol: "bostrom-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -87,7 +89,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -96,12 +98,10 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, - protocol: None, - // owner: None, - owner: Some(Addr::unchecked("creator")), + owner: Addr::unchecked("creator"), }, ) .unwrap(); @@ -111,7 +111,8 @@ mod tests { Entry { id: 1, neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "cosmos".to_string(), + protocol: "cosmos-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), owner: cosmwasm_std::Addr::unchecked("creator"), @@ -119,7 +120,8 @@ mod tests { Entry { id: 2, neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "bostrom".to_string(), + protocol: "bostrom-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), owner: cosmwasm_std::Addr::unchecked("creator"), @@ -132,7 +134,8 @@ mod tests { let message = ExecuteMsg::UpdateEntry { id: 1, neuron: Some("testchain-1".to_string()), - protocol: Some("testchain-1".to_string()), + network: Some("cosmos".to_string()), + protocol: Some("cosmos-1".to_string()), endpoint: Some("https:/abcd.com".to_string()), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -141,7 +144,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); @@ -152,11 +155,10 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, - protocol: None, - owner: Some(Addr::unchecked("creator")), + owner: Addr::unchecked("creator"), }, ) .unwrap(); @@ -166,7 +168,8 @@ mod tests { Entry { id: 1, neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "cosmos".to_string(), + protocol: "cosmos-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), owner: cosmwasm_std::Addr::unchecked("creator"), @@ -174,7 +177,8 @@ mod tests { Entry { id: 2, neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "bostrom".to_string(), + protocol: "bostrom-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), owner: cosmwasm_std::Addr::unchecked("creator"), @@ -197,11 +201,10 @@ mod tests { // Query the list of entries let res = query( deps.as_ref(), - env, - QueryMsg::GetItems { + env.clone(), + QueryMsg::GetEntries { start_after: None, - protocol: None, - owner: Some(Addr::unchecked("creator")), + owner: Addr::unchecked("creator"), limit: None, }, ) @@ -211,12 +214,72 @@ mod tests { Vec::from([Entry { id: 2, neuron: "testchain-1".to_string(), - protocol: "testchain-1".to_string(), + network: "bostrom".to_string(), + protocol: "bostrom-1".to_string(), endpoint: "https:/abcd.com".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), owner: cosmwasm_std::Addr::unchecked("creator"), }]), list.entries ); + + let res = query( + deps.as_ref(), + env.clone(), + QueryMsg::GetEntry { + id: 2 + }, + ).unwrap(); + let entry: EntryResponse = from_binary(&res).unwrap(); + assert_eq!( + EntryResponse { + id: 2, + neuron: "testchain-1".to_string(), + network: "bostrom".to_string(), + protocol: "bostrom-1".to_string(), + endpoint: "https:/abcd.com".to_string(), + owner: cosmwasm_std::Addr::unchecked("creator").to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + }, + entry + ); + + let res = query( + deps.as_ref(), + env.clone(), + QueryMsg::GetEntriesProtocol { + start_after: None, + limit: None, + protocol: "bostrom-1".to_string() + }, + ).unwrap(); + let list: ListResponse = from_binary(&res).unwrap(); + assert_eq!( + Vec::from([Entry { + id: 2, + neuron: "testchain-1".to_string(), + network: "bostrom".to_string(), + protocol: "bostrom-1".to_string(), + endpoint: "https:/abcd.com".to_string(), + particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), + owner: cosmwasm_std::Addr::unchecked("creator"), + }]), + list.entries + ); + + let res = query( + deps.as_ref(), + env.clone(), + QueryMsg::GetEntriesNetwork { + start_after: None, + limit: None, + network: "cosmos".to_string() + }, + ).unwrap(); + let list: ListResponse = from_binary(&res).unwrap(); + assert_eq!( + 0, + list.entries.len() + ); } } diff --git a/contracts/cw-cyb-tokens/src/validating.rs b/contracts/hub-skills/src/validating.rs similarity index 83% rename from contracts/cw-cyb-tokens/src/validating.rs rename to contracts/hub-skills/src/validating.rs index 06a0815..444c75a 100644 --- a/contracts/cw-cyb-tokens/src/validating.rs +++ b/contracts/hub-skills/src/validating.rs @@ -6,14 +6,13 @@ use cosmwasm_std::{ Response, }; -/** - * Baseic rule /[a-z0-9-]/ +/* + * Basic rule /[a-z0-9-]/ */ pub fn validate_by_basic_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -24,14 +23,13 @@ pub fn validate_by_basic_rule( Ok(Response::default()) } -/** - * Baseic rule /[A-Z0-9]/ +/* + * Basic rule /[A-Z0-9]/ */ pub fn validate_by_basic_uppercase_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // 0-9 && A-Z if (*byte < 48 || *byte > 57) && (*byte < 65 || *byte > 90) { @@ -45,7 +43,6 @@ pub fn validate_by_basic_uppercase_rule( pub fn validate_datatype( val: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -60,7 +57,6 @@ pub fn validate_url( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // = & } { : / . - _ 0-9 a-z A-Z if (*byte != 61) && (*byte != 38) && (*byte != 125) && (*byte != 123) && (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { @@ -77,10 +73,10 @@ pub fn validate_by_int_range( field: Uint64, field_name: String, ) -> Result { - // let intField=Uint64::from(field); if field < from || field > to { return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Out from range", field_name).to_string()}); } + Ok(Response::default()) } @@ -90,20 +86,19 @@ pub fn validate_ipfs_cid( particle: String, field_name: String, ) -> Result { + let particle_value:Cid; + let try_particle = Cid::from_str(&particle.clone()); + if try_particle.is_ok() { + particle_value = try_particle.unwrap(); - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); - } - } else { + if particle_value.version() != Version::V0 { return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); } - Ok(Response::default()) + } else { + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); + } + Ok(Response::default()) } diff --git a/contracts/cw-cyb-skills/.cargo/config b/contracts/hub-tokens/.cargo/config similarity index 100% rename from contracts/cw-cyb-skills/.cargo/config rename to contracts/hub-tokens/.cargo/config diff --git a/contracts/cw-cyb-skills/Cargo.lock b/contracts/hub-tokens/Cargo.lock similarity index 100% rename from contracts/cw-cyb-skills/Cargo.lock rename to contracts/hub-tokens/Cargo.lock diff --git a/contracts/hub-tokens/Cargo.toml b/contracts/hub-tokens/Cargo.toml new file mode 100644 index 0000000..c52f4b2 --- /dev/null +++ b/contracts/hub-tokens/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "hub-tokens" +version = "0.1.0" +authors = ["Bloqhub"] +edition = "2018" + +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"] + +[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.6 +""" + +[dependencies] +cosmwasm-std = { version = "1.0.0", features = ["iterator", "abort"] } +cw-storage-plus = { version = "0.13.4" } +cw2 = { version = "0.13.4" } +schemars = "0.8.10" +serde = { version = "1.0.140", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.31" } +cid = { version = "0.8.0" } + +[dev-dependencies] +cosmwasm-schema = "1.0.0" +cw-multi-test = "0.13.2" diff --git a/contracts/hub-tokens/examples/schema.rs b/contracts/hub-tokens/examples/schema.rs new file mode 100644 index 0000000..f28a3c9 --- /dev/null +++ b/contracts/hub-tokens/examples/schema.rs @@ -0,0 +1,17 @@ +use std::env::current_dir; +use std::fs::create_dir_all; + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; + +use hub_tokens::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + +fn main() { + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(InstantiateMsg), &out_dir); + export_schema(&schema_for!(ExecuteMsg), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); +} diff --git a/contracts/hub-tokens/schema/execute_msg.json b/contracts/hub-tokens/schema/execute_msg.json new file mode 100644 index 0000000..2758170 --- /dev/null +++ b/contracts/hub-tokens/schema/execute_msg.json @@ -0,0 +1,172 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "UpdateOwner" + ], + "properties": { + "UpdateOwner": { + "type": "object", + "properties": { + "new_owner": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "CreateEntry" + ], + "properties": { + "CreateEntry": { + "type": "object", + "required": [ + "chain_id", + "channel", + "contract", + "decimals", + "logo", + "ticker" + ], + "properties": { + "chain_id": { + "type": "string" + }, + "channel": { + "$ref": "#/definitions/Uint64" + }, + "contract": { + "type": "string" + }, + "decimals": { + "$ref": "#/definitions/Uint64" + }, + "logo": { + "type": "string" + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "ticker": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "UpdateEntry" + ], + "properties": { + "UpdateEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "chain_id": { + "type": [ + "string", + "null" + ] + }, + "channel": { + "anyOf": [ + { + "$ref": "#/definitions/Uint64" + }, + { + "type": "null" + } + ] + }, + "contract": { + "type": [ + "string", + "null" + ] + }, + "decimals": { + "anyOf": [ + { + "$ref": "#/definitions/Uint64" + }, + { + "type": "null" + } + ] + }, + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "logo": { + "type": [ + "string", + "null" + ] + }, + "particle": { + "type": [ + "string", + "null" + ] + }, + "ticker": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "DeleteEntry" + ], + "properties": { + "DeleteEntry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/hub-tokens/schema/instantiate_msg.json b/contracts/hub-tokens/schema/instantiate_msg.json new file mode 100644 index 0000000..fc5f000 --- /dev/null +++ b/contracts/hub-tokens/schema/instantiate_msg.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "properties": { + "owner": { + "type": [ + "string", + "null" + ] + } + } +} diff --git a/contracts/hub-tokens/schema/query_msg.json b/contracts/hub-tokens/schema/query_msg.json new file mode 100644 index 0000000..f3d8cbe --- /dev/null +++ b/contracts/hub-tokens/schema/query_msg.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "get_entries" + ], + "properties": { + "get_entries": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_entry" + ], + "properties": { + "get_entry": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/cw-cyb-tokens/src/contract.rs b/contracts/hub-tokens/src/contract.rs similarity index 50% rename from contracts/cw-cyb-tokens/src/contract.rs rename to contracts/hub-tokens/src/contract.rs index fffc4ec..6f580da 100644 --- a/contracts/cw-cyb-tokens/src/contract.rs +++ b/contracts/hub-tokens/src/contract.rs @@ -1,20 +1,19 @@ use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, to_binary, }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; - -use cw2::set_contract_version; +use cw2::{get_contract_version, set_contract_version}; use crate::error::ContractError; -use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::query::{query_list, execute_create_new_item, execute_update_item, execute_delete_entry}; -// Token constructor +use crate::execute::{execute_create_entry, execute_delete_entry, execute_update_entry, execute_update_owner}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use crate::query::{query_entry, query_list}; use crate::state::{Config, CONFIG, ENTRY_SEQ}; //@TODO git version iteract -const CONTRACT_NAME: &str = "cw-tokens"; -const CONTRACT_VERSION: &str = "1.0.0"; +const CONTRACT_NAME: &str = "hub-tokens"; +const CONTRACT_VERSION: &str = "0.1.0"; #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( @@ -31,8 +30,9 @@ pub fn instantiate( .unwrap_or(info.sender); let config = Config { - owner: owner.clone(), + owner: Some(owner.clone()), }; + CONFIG.save(deps.storage, &config)?; ENTRY_SEQ.save(deps.storage, &0u64)?; @@ -45,26 +45,31 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::NewEntry { + ExecuteMsg::UpdateOwner { new_owner } => execute_update_owner(deps, env, info, new_owner), + ExecuteMsg::CreateEntry { ticker, chain_id, - denom, + contract, + decimals, + channel, logo, particle, - } => execute_create_new_item(deps, info, ticker, chain_id, denom, logo, particle), + } => execute_create_entry(deps, info, ticker, chain_id, contract, decimals, channel, logo, particle), ExecuteMsg::UpdateEntry { id, ticker, chain_id, - denom, + contract, + decimals, + channel, logo, particle, - } => execute_update_item(deps, info, id, ticker, chain_id, denom, logo, particle), + } => execute_update_entry(deps, info, id, ticker, chain_id, contract, decimals, channel, logo, particle), ExecuteMsg::DeleteEntry { id } => execute_delete_entry(deps, info, id), } } @@ -74,8 +79,23 @@ pub fn execute( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetItems { start_after, limit } => { + QueryMsg::GetEntries { start_after, limit } => { to_binary(&query_list(deps, start_after, limit)?) } + QueryMsg::GetEntry { id } => { + to_binary(&query_entry(deps, id)?) + } + } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + let version = get_contract_version(deps.storage)?; + if version.contract != CONTRACT_NAME { + return Err(ContractError::CannotMigrate { + previous_contract: version.contract, + }); } -} \ No newline at end of file + + Ok(Response::default()) +} diff --git a/contracts/hub-tokens/src/error.rs b/contracts/hub-tokens/src/error.rs new file mode 100644 index 0000000..863e417 --- /dev/null +++ b/contracts/hub-tokens/src/error.rs @@ -0,0 +1,20 @@ +use cosmwasm_std::StdError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Unauthorized")] + Unauthorized {}, + + #[error("IncorrectInputData val: {val:?}")] + IncorrectInputData {val: String }, + + #[error("Custom Error val: {val:?}")] + CustomError { val: String }, + + #[error("Cannot migrate from different contract type: {previous_contract}")] + CannotMigrate { previous_contract: String }, +} diff --git a/contracts/cw-cyb-tokens/src/query.rs b/contracts/hub-tokens/src/execute.rs similarity index 63% rename from contracts/cw-cyb-tokens/src/query.rs rename to contracts/hub-tokens/src/execute.rs index 5355eee..db756b4 100644 --- a/contracts/cw-cyb-tokens/src/query.rs +++ b/contracts/hub-tokens/src/execute.rs @@ -1,34 +1,53 @@ -use cosmwasm_std::{Uint64}; -// use cid::{Cid, Version}; -// use std::str::FromStr; -// use cid::multihash::{Code, MultihashDigest}; -use cosmwasm_std::{ - Deps, DepsMut, MessageInfo, Order, Response, StdResult, -}; - -use cw_storage_plus::Bound; use std::ops::Add; -use crate::validating::{validate_by_basic_rule,validate_by_basic_uppercase_rule,validate_ipfs_cid,validate_by_int_range}; +use cosmwasm_std::{attr, Env, Uint64}; +use cosmwasm_std::{DepsMut, MessageInfo, Response, StdResult}; + use crate::error::ContractError; -use crate::msg::{ListResponse}; -use crate::state::{Entry, CONFIG, ENTRY_SEQ, LIST}; +use crate::state::{CONFIG, Entry, ENTRY_SEQ, LIST}; +use crate::validating::{validate_by_basic_rule, validate_by_basic_uppercase_rule, validate_ipfs_cid}; + +pub fn execute_update_owner( + deps: DepsMut, + _env: Env, + info: MessageInfo, + new_owner: Option, +) -> Result { + let cfg = CONFIG.load(deps.storage)?; + let owner = cfg.owner.ok_or(ContractError::Unauthorized {})?; + if info.sender != owner { + return Err(ContractError::Unauthorized {}); + } -const MAX_LIMIT: u32 = 30; -const DEFAULT_LIMIT: u32 = 20; + let mut tmp_owner = None; + if let Some(addr) = new_owner { + tmp_owner = Some(deps.api.addr_validate(&addr)?) + } + CONFIG.update(deps.storage, |mut exists| -> StdResult<_> { + exists.owner = tmp_owner; + Ok(exists) + })?; -pub fn execute_create_new_item( + Ok(Response::new().add_attributes(vec![attr("action", "update_owner")])) +} + +pub fn execute_create_entry( deps: DepsMut, info: MessageInfo, ticker: String, chain_id: String, - denom: Uint64, + contract: String, + decimals: Uint64, + channel: Uint64, logo: String, particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -44,10 +63,8 @@ pub fn execute_create_new_item( } } - let validate_ticker = validate_by_basic_uppercase_rule(ticker.clone(), "ticker".to_string()); let validate_chain_id = validate_by_basic_rule(chain_id.clone(), "chain_id".to_string()); - let validate_denom = validate_by_int_range(Uint64::from(1u64),Uint64::from(18u64), denom.clone(),"denom".to_string()); if validate_ticker.is_err() { return validate_ticker; @@ -55,11 +72,9 @@ pub fn execute_create_new_item( if validate_chain_id.is_err() { return validate_chain_id; } - if validate_denom.is_err() { - return validate_denom; - } - + // TODO add denom validation + // TODO add channel validation let id = ENTRY_SEQ.update::<_, cosmwasm_std::StdError>(deps.storage, |id| Ok(id.add(1)))?; @@ -67,28 +82,37 @@ pub fn execute_create_new_item( id, ticker, chain_id, - denom, + contract, + decimals, + channel, logo, particle: particle.unwrap_or("".to_string()) }; + LIST.save(deps.storage, id, &new_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_create_new_item") + .add_attribute("method", "execute_create_entry") .add_attribute("new_entry_id", id.to_string())) } -pub fn execute_update_item( +pub fn execute_update_entry( deps: DepsMut, info: MessageInfo, id: u64, ticker: Option, chain_id: Option, - denom: Option, + contract: Option, + decimals: Option, + channel: Option, logo: Option, particle: Option, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } @@ -104,10 +128,11 @@ pub fn execute_update_item( } } - let validate_ticker = validate_by_basic_uppercase_rule(ticker.clone().unwrap(), "ticker".to_string()); let validate_chain_id = validate_by_basic_rule(chain_id.clone().unwrap(), "chain_id".to_string()); - let validate_denom = validate_by_int_range(Uint64::from(1u64),Uint64::from(18u64), denom.clone().unwrap(),"denom".to_string()); + + // TODO add denom validation + // TODO add channel validation if validate_ticker.is_err() { return validate_ticker; @@ -115,23 +140,22 @@ pub fn execute_update_item( if validate_chain_id.is_err() { return validate_chain_id; } - if validate_denom.is_err() { - return validate_denom; - } - let entry = LIST.load(deps.storage, id)?; let updated_entry = Entry { id, ticker: ticker.unwrap_or(entry.ticker), - denom: denom.unwrap_or(entry.denom), + contract: contract.unwrap_or(entry.contract), + decimals: decimals.unwrap_or(entry.decimals), chain_id: chain_id.unwrap_or(entry.chain_id), + channel: channel.unwrap_or(entry.channel), logo: logo.unwrap_or(entry.logo), particle: particle.unwrap_or("".to_string()), }; LIST.save(deps.storage, id, &updated_entry)?; + Ok(Response::new() - .add_attribute("method", "execute_update_item") + .add_attribute("method", "execute_update_entry") .add_attribute("updated_entry_id", id.to_string())) } @@ -141,30 +165,16 @@ pub fn execute_delete_entry( id: u64, ) -> Result { let owner = CONFIG.load(deps.storage)?.owner; - if info.sender != owner { + + if owner.is_none() { + return Err(ContractError::Unauthorized {}); + } else if info.sender != owner.unwrap() { return Err(ContractError::Unauthorized {}); } LIST.remove(deps.storage, id); + Ok(Response::new() .add_attribute("method", "execute_delete_entry") .add_attribute("deleted_entry_id", id.to_string())) } - - - - - -pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { - let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = start_after.map(Bound::exclusive); - let entries: StdResult> = LIST - .range(deps.storage, start, None, Order::Ascending) - .take(limit) - .collect(); - - let result = ListResponse { - entries: entries?.into_iter().map(|l| l.1).collect(), - }; - Ok(result) -} diff --git a/contracts/hub-tokens/src/lib.rs b/contracts/hub-tokens/src/lib.rs new file mode 100644 index 0000000..0a43c7c --- /dev/null +++ b/contracts/hub-tokens/src/lib.rs @@ -0,0 +1,10 @@ +pub mod contract; +mod error; +pub mod msg; +pub mod execute; +pub mod state; +pub mod validating; +mod tests; +mod query; + +pub use crate::error::ContractError; diff --git a/contracts/cw-cyb-tokens/src/msg.rs b/contracts/hub-tokens/src/msg.rs similarity index 72% rename from contracts/cw-cyb-tokens/src/msg.rs rename to contracts/hub-tokens/src/msg.rs index 30b42cd..094e491 100644 --- a/contracts/cw-cyb-tokens/src/msg.rs +++ b/contracts/hub-tokens/src/msg.rs @@ -10,10 +10,15 @@ pub struct InstantiateMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub enum ExecuteMsg { - NewEntry { + UpdateOwner { + new_owner: Option, + }, + CreateEntry { ticker: String, chain_id: String, - denom: Uint64, + contract: String, + decimals: Uint64, + channel: Uint64, logo: String, particle: Option, }, @@ -21,7 +26,9 @@ pub enum ExecuteMsg { id: u64, ticker: Option, chain_id: Option, - denom: Option, + contract: Option, + decimals: Option, + channel: Option, logo: Option, particle: Option, }, @@ -33,19 +40,24 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetItems { + GetEntries { start_after: Option, limit: Option, }, + GetEntry { id: u64 } } -// Tokens +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct MigrateMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct EntryResponse { pub id: u64, pub ticker: String, pub chain_id: String, - pub denom: Uint64, + pub contract: String, + pub decimals: Uint64, + pub channel: Uint64, pub logo: String, pub particle: String, } diff --git a/contracts/hub-tokens/src/query.rs b/contracts/hub-tokens/src/query.rs new file mode 100644 index 0000000..dc56caa --- /dev/null +++ b/contracts/hub-tokens/src/query.rs @@ -0,0 +1,38 @@ +use cosmwasm_std::{Deps, Order, StdResult}; +use cw_storage_plus::Bound; + +use crate::msg::{EntryResponse, ListResponse}; +use crate::state::LIST; + +const MAX_LIMIT: u32 = 30; +const DEFAULT_LIMIT: u32 = 20; + +pub fn query_entry(deps: Deps, id: u64) -> StdResult { + let entry = LIST.load(deps.storage, id)?; + + Ok(EntryResponse { + id, + ticker: entry.ticker, + chain_id: entry.chain_id, + contract: entry.contract, + decimals: entry.decimals, + channel: entry.channel, + logo: entry.logo, + particle: entry.particle + }) +} + +pub fn query_list(deps: Deps, start_after: Option, limit: Option) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let entries: StdResult> = LIST + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .collect(); + + let result = ListResponse { + entries: entries?.into_iter().map(|l| l.1).collect(), + }; + + Ok(result) +} diff --git a/contracts/cw-cyb-tokens/src/state.rs b/contracts/hub-tokens/src/state.rs similarity index 85% rename from contracts/cw-cyb-tokens/src/state.rs rename to contracts/hub-tokens/src/state.rs index 128eb67..d2acc5d 100644 --- a/contracts/cw-cyb-tokens/src/state.rs +++ b/contracts/hub-tokens/src/state.rs @@ -7,7 +7,7 @@ use cw_storage_plus::{Item, Map}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct Config { - pub owner: Addr, + pub owner: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -15,12 +15,13 @@ pub struct Entry { pub id: u64, pub ticker: String, pub chain_id: String, - pub denom: Uint64, + pub contract: String, + pub decimals: Uint64, + pub channel: Uint64, pub logo: String, pub particle: String, } - pub const CONFIG: Item = Item::new("config"); pub const ENTRY_SEQ: Item = Item::new("entry_seq"); pub const LIST: Map = Map::new("list"); diff --git a/contracts/cw-cyb-tokens/src/tests.rs b/contracts/hub-tokens/src/tests.rs similarity index 80% rename from contracts/cw-cyb-tokens/src/tests.rs rename to contracts/hub-tokens/src/tests.rs index 221b5f1..bf3053f 100644 --- a/contracts/cw-cyb-tokens/src/tests.rs +++ b/contracts/hub-tokens/src/tests.rs @@ -2,14 +2,12 @@ #[cfg(test)] mod tests { - // use super::*; use cosmwasm_std::{Uint64}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{attr, from_binary, Addr}; use std::vec::Vec; use crate::state::{Entry, CONFIG, Config}; use crate::msg::{ ListResponse, QueryMsg, InstantiateMsg, ExecuteMsg}; - // use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::contract::{query, execute, instantiate}; #[test] @@ -28,7 +26,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("creator".to_string()), + owner: Some(Addr::unchecked("creator".to_string())), } ); //specifying an owner address in the instantiation message @@ -44,7 +42,7 @@ mod tests { assert_eq!( state, Config { - owner: Addr::unchecked("specified_owner".to_string()), + owner: Some(Addr::unchecked("specified_owner".to_string())), } ); } @@ -59,10 +57,12 @@ mod tests { let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); assert_eq!(0, res.messages.len()); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { chain_id: "testchain-1".to_string(), ticker: "TST".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(6), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -71,15 +71,17 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "1") ] ); - let msg = ExecuteMsg::NewEntry { + let msg = ExecuteMsg::CreateEntry { ticker: "TST2".to_string(), chain_id: "testchain-1".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(6), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -88,7 +90,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_create_new_item"), + attr("method", "execute_create_entry"), attr("new_entry_id", "2") ] ); @@ -97,7 +99,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -110,7 +112,9 @@ mod tests { id: 1, chain_id: "testchain-1".to_string(), ticker: "TST".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(6), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }, @@ -118,7 +122,9 @@ mod tests { id: 2, ticker: "TST2".to_string(), chain_id: "testchain-1".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(8), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), } @@ -131,8 +137,9 @@ mod tests { id: 1, ticker: Some("TSTUPDATE".to_string()), chain_id: Some("testchain-1".to_string()), - denom: Some(Uint64::new(8)), - // logo: None, + contract: Some("cyb".to_string()), + decimals: Some(Uint64::new(7)), + channel: Some(Uint64::new(1)), logo: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), particle: Some("QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string()), }; @@ -141,7 +148,7 @@ mod tests { assert_eq!( res.attributes, vec![ - attr("method", "execute_update_item"), + attr("method", "execute_update_entry"), attr("updated_entry_id", "1") ] ); @@ -152,7 +159,7 @@ mod tests { let res = query( deps.as_ref(), env.clone(), - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -165,7 +172,9 @@ mod tests { id: 1, ticker: "TSTUPDATE".to_string(), chain_id: "testchain-1".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(6), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }, @@ -173,7 +182,9 @@ mod tests { id: 2, ticker: "TST2".to_string(), chain_id: "testchain-1".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(6), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), } @@ -196,7 +207,7 @@ mod tests { let res = query( deps.as_ref(), env, - QueryMsg::GetItems { + QueryMsg::GetEntries { start_after: None, limit: None, }, @@ -208,7 +219,9 @@ mod tests { id: 2, ticker: "TST2".to_string(), chain_id: "testchain-1".to_string(), - denom: Uint64::new(8), + contract: "cyb".to_string(), + decimals: Uint64::new(6), + channel: Uint64::new(1), logo: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), particle: "QmYpTB36duejmy1szbdL1D2EzC5fgRL4dyhSFsHkMYPtny".to_string(), }]), diff --git a/contracts/cw-cyb-skills/src/validating.rs b/contracts/hub-tokens/src/validating.rs similarity index 83% rename from contracts/cw-cyb-skills/src/validating.rs rename to contracts/hub-tokens/src/validating.rs index 06a0815..6575339 100644 --- a/contracts/cw-cyb-skills/src/validating.rs +++ b/contracts/hub-tokens/src/validating.rs @@ -6,14 +6,13 @@ use cosmwasm_std::{ Response, }; -/** - * Baseic rule /[a-z0-9-]/ +/* + * Basic rule /[a-z0-9-]/ */ pub fn validate_by_basic_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -24,14 +23,13 @@ pub fn validate_by_basic_rule( Ok(Response::default()) } -/** - * Baseic rule /[A-Z0-9]/ +/* + * Basic rule /[A-Z0-9]/ */ pub fn validate_by_basic_uppercase_rule( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // 0-9 && A-Z if (*byte < 48 || *byte > 57) && (*byte < 65 || *byte > 90) { @@ -45,7 +43,6 @@ pub fn validate_by_basic_uppercase_rule( pub fn validate_datatype( val: String, ) -> Result { - for byte in val.as_bytes().iter() { // - && 0-9 && a-z if (*byte != 45) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) { @@ -60,7 +57,6 @@ pub fn validate_url( val: String, field_name: String, ) -> Result { - for byte in val.as_bytes().iter() { // = & } { : / . - _ 0-9 a-z A-Z if (*byte != 61) && (*byte != 38) && (*byte != 125) && (*byte != 123) && (*byte != 58) && (*byte != 95) && (*byte != 45) && (*byte != 47) && (*byte != 46) && (*byte < 48 || *byte > 57) && (*byte < 97 || *byte > 122) && (*byte < 65 || *byte > 90) { @@ -77,33 +73,29 @@ pub fn validate_by_int_range( field: Uint64, field_name: String, ) -> Result { - // let intField=Uint64::from(field); if field < from || field > to { return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Out from range", field_name).to_string()}); } Ok(Response::default()) } - - pub fn validate_ipfs_cid( particle: String, field_name: String, ) -> Result { + let particle_value:Cid; + let try_particle = Cid::from_str(&particle.clone()); + if try_particle.is_ok() { + particle_value = try_particle.unwrap(); - let particle_value:Cid; - let try_particle = Cid::from_str(&particle.clone()); - if try_particle.is_ok() { - particle_value = try_particle.unwrap(); - - if particle_value.version() != Version::V0 { - return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); - } - } else { + if particle_value.version() != Version::V0 { return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); } - Ok(Response::default()) + } else { + return Err(ContractError::IncorrectInputData {val: format!("Incorrect value for field {}. Allowed only Ipfs hash", field_name).to_string()}); + } + Ok(Response::default()) } diff --git a/contracts/ibc-reflect-send/schema/account_response.json b/contracts/ibc-reflect-send/schema/account_response.json new file mode 100644 index 0000000..d6e05cc --- /dev/null +++ b/contracts/ibc-reflect-send/schema/account_response.json @@ -0,0 +1,65 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AccountResponse", + "type": "object", + "required": [ + "last_update_time", + "remote_balance" + ], + "properties": { + "last_update_time": { + "description": "last block balance was updated (0 is never)", + "allOf": [ + { + "$ref": "#/definitions/Timestamp" + } + ] + }, + "remote_addr": { + "description": "in normal cases, it should be set, but there is a delay between binding the channel and making a query and in that time it is empty", + "type": [ + "string", + "null" + ] + }, + "remote_balance": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/ibc-reflect-send/schema/admin_response.json b/contracts/ibc-reflect-send/schema/admin_response.json new file mode 100644 index 0000000..b0d3272 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/admin_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AdminResponse", + "type": "object", + "required": [ + "admin" + ], + "properties": { + "admin": { + "type": "string" + } + } +} diff --git a/contracts/ibc-reflect-send/schema/cyber_msg_wrapper.json b/contracts/ibc-reflect-send/schema/cyber_msg_wrapper.json new file mode 100644 index 0000000..ae0cc6f --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cyber_msg_wrapper.json @@ -0,0 +1,569 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CyberMsgWrapper", + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/ibc-reflect-send/schema/execute_msg.json b/contracts/ibc-reflect-send/schema/execute_msg.json new file mode 100644 index 0000000..1ca38fe --- /dev/null +++ b/contracts/ibc-reflect-send/schema/execute_msg.json @@ -0,0 +1,1355 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "description": "Changes the admin", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin" + ], + "properties": { + "admin": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "send_msgs" + ], + "properties": { + "send_msgs": { + "type": "object", + "required": [ + "channel_id", + "msgs" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_CyberMsgWrapper" + } + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "check_remote_balance" + ], + "properties": { + "check_remote_balance": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "If you sent funds to this contract, it will attempt to ibc transfer them to the account on the remote side of this channel. If we don't have the address yet, this fails.", + "type": "object", + "required": [ + "send_funds" + ], + "properties": { + "send_funds": { + "type": "object", + "required": [ + "reflect_channel_id", + "transfer_channel_id" + ], + "properties": { + "reflect_channel_id": { + "description": "The channel id we use above to talk with the reflect contract", + "type": "string" + }, + "transfer_channel_id": { + "description": "The channel to use for ibctransfer. This is bound to a different port and handled by a different module. It should connect to the same chain as the reflect_channel_id does", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_CyberMsgWrapper": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/CyberMsgWrapper" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "gov" + ], + "properties": { + "gov": { + "$ref": "#/definitions/GovMsg" + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsgWrapper": { + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + } + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "GovMsg": { + "oneOf": [ + { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/VoteOption" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcMsg": { + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", + "oneOf": [ + { + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", + "type": "object", + "required": [ + "transfer" + ], + "properties": { + "transfer": { + "type": "object", + "required": [ + "amount", + "channel_id", + "timeout", + "to_address" + ], + "properties": { + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "channel_id": { + "description": "exisiting channel to send the tokens over", + "type": "string" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", + "type": "object", + "required": [ + "send_packet" + ], + "properties": { + "send_packet": { + "type": "object", + "required": [ + "channel_id", + "data", + "timeout" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", + "type": "object", + "required": [ + "close_channel" + ], + "properties": { + "close_channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", + "type": "object", + "properties": { + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] + }, + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + } + }, + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", + "type": "object", + "required": [ + "height", + "revision" + ], + "properties": { + "height": { + "description": "block height after which the packet times out. the height within the given revision", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "revision": { + "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "VoteOption": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "no_with_veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/ibc-reflect-send/schema/instantiate_msg.json b/contracts/ibc-reflect-send/schema/instantiate_msg.json new file mode 100644 index 0000000..149ba9c --- /dev/null +++ b/contracts/ibc-reflect-send/schema/instantiate_msg.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "description": "This needs no info. Owner of the contract is whoever signed the InstantiateMsg.", + "type": "object" +} diff --git a/contracts/ibc-reflect-send/schema/list_accounts_response.json b/contracts/ibc-reflect-send/schema/list_accounts_response.json new file mode 100644 index 0000000..7c63981 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/list_accounts_response.json @@ -0,0 +1,83 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ListAccountsResponse", + "type": "object", + "required": [ + "accounts" + ], + "properties": { + "accounts": { + "type": "array", + "items": { + "$ref": "#/definitions/AccountInfo" + } + } + }, + "definitions": { + "AccountInfo": { + "type": "object", + "required": [ + "channel_id", + "last_update_time", + "remote_balance" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "last_update_time": { + "description": "last block balance was updated (0 is never)", + "allOf": [ + { + "$ref": "#/definitions/Timestamp" + } + ] + }, + "remote_addr": { + "description": "in normal cases, it should be set, but there is a delay between binding the channel and making a query and in that time it is empty", + "type": [ + "string", + "null" + ] + }, + "remote_balance": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/ibc-reflect-send/schema/packet_msg.json b/contracts/ibc-reflect-send/schema/packet_msg.json new file mode 100644 index 0000000..651e0be --- /dev/null +++ b/contracts/ibc-reflect-send/schema/packet_msg.json @@ -0,0 +1,1308 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PacketMsg", + "description": "This is the message we send over the IBC channel", + "oneOf": [ + { + "type": "object", + "required": [ + "dispatch" + ], + "properties": { + "dispatch": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_CyberMsgWrapper" + } + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "who_am_i" + ], + "properties": { + "who_am_i": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "balances" + ], + "properties": { + "balances": { + "type": "object" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_CyberMsgWrapper": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/CyberMsgWrapper" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "gov" + ], + "properties": { + "gov": { + "$ref": "#/definitions/GovMsg" + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsgWrapper": { + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + } + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "GovMsg": { + "oneOf": [ + { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/VoteOption" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcMsg": { + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", + "oneOf": [ + { + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", + "type": "object", + "required": [ + "transfer" + ], + "properties": { + "transfer": { + "type": "object", + "required": [ + "amount", + "channel_id", + "timeout", + "to_address" + ], + "properties": { + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "channel_id": { + "description": "exisiting channel to send the tokens over", + "type": "string" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", + "type": "object", + "required": [ + "send_packet" + ], + "properties": { + "send_packet": { + "type": "object", + "required": [ + "channel_id", + "data", + "timeout" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", + "type": "object", + "required": [ + "close_channel" + ], + "properties": { + "close_channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", + "type": "object", + "properties": { + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] + }, + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + } + }, + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", + "type": "object", + "required": [ + "height", + "revision" + ], + "properties": { + "height": { + "description": "block height after which the packet times out. the height within the given revision", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "revision": { + "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "VoteOption": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "no_with_veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/ibc-reflect-send/schema/query_msg.json b/contracts/ibc-reflect-send/schema/query_msg.json new file mode 100644 index 0000000..17d10a2 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/query_msg.json @@ -0,0 +1,50 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "admin" + ], + "properties": { + "admin": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "list_accounts" + ], + "properties": { + "list_accounts": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "account" + ], + "properties": { + "account": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json b/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json new file mode 100644 index 0000000..cf09b7c --- /dev/null +++ b/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AcknowledgementMsgBalances", + "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"messages\":[],\"attributes\":[],\"events\":[],\"data\":null}}\"#); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#); ```", + "oneOf": [ + { + "type": "object", + "required": [ + "ok" + ], + "properties": { + "ok": { + "$ref": "#/definitions/BalancesResponse" + } + }, + "additionalProperties": false + }, + { + "description": "An error type that every custom error created by contract developers can be converted to. This could potientially have more structure, but String is the easiest.", + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BalancesResponse": { + "description": "This is the success response we send on ack for PacketMsg::Balance. Just acknowledge success or error", + "type": "object", + "required": [ + "account", + "balances" + ], + "properties": { + "account": { + "type": "string" + }, + "balances": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json b/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json new file mode 100644 index 0000000..e89f54b --- /dev/null +++ b/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AcknowledgementMsgDispatch", + "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"messages\":[],\"attributes\":[],\"events\":[],\"data\":null}}\"#); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#); ```", + "oneOf": [ + { + "type": "object", + "required": [ + "ok" + ], + "properties": { + "ok": { + "type": "null" + } + }, + "additionalProperties": false + }, + { + "description": "An error type that every custom error created by contract developers can be converted to. This could potientially have more structure, but String is the easiest.", + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json b/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json new file mode 100644 index 0000000..bfbabf6 --- /dev/null +++ b/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json @@ -0,0 +1,46 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AcknowledgementMsgWhoAmI", + "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"messages\":[],\"attributes\":[],\"events\":[],\"data\":null}}\"#); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#); ```", + "oneOf": [ + { + "type": "object", + "required": [ + "ok" + ], + "properties": { + "ok": { + "$ref": "#/definitions/WhoAmIResponse" + } + }, + "additionalProperties": false + }, + { + "description": "An error type that every custom error created by contract developers can be converted to. This could potientially have more structure, but String is the easiest.", + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "WhoAmIResponse": { + "description": "This is the success response we send on ack for PacketMsg::WhoAmI. Return the caller's account address on the remote chain", + "type": "object", + "required": [ + "account" + ], + "properties": { + "account": { + "type": "string" + } + } + } + } +} diff --git a/contracts/ibc-reflect/schema/cyber_msg_wrapper.json b/contracts/ibc-reflect/schema/cyber_msg_wrapper.json new file mode 100644 index 0000000..ae0cc6f --- /dev/null +++ b/contracts/ibc-reflect/schema/cyber_msg_wrapper.json @@ -0,0 +1,569 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CyberMsgWrapper", + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/ibc-reflect/schema/instantiate_msg.json b/contracts/ibc-reflect/schema/instantiate_msg.json new file mode 100644 index 0000000..9bcdcf2 --- /dev/null +++ b/contracts/ibc-reflect/schema/instantiate_msg.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "description": "Just needs to know the code_id of a reflect contract to spawn sub-accounts", + "type": "object", + "required": [ + "reflect_code_id" + ], + "properties": { + "reflect_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } +} diff --git a/contracts/ibc-reflect/schema/packet_msg.json b/contracts/ibc-reflect/schema/packet_msg.json new file mode 100644 index 0000000..d7887c3 --- /dev/null +++ b/contracts/ibc-reflect/schema/packet_msg.json @@ -0,0 +1,1307 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PacketMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "dispatch" + ], + "properties": { + "dispatch": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_CyberMsgWrapper" + } + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "who_am_i" + ], + "properties": { + "who_am_i": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "balances" + ], + "properties": { + "balances": { + "type": "object" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_CyberMsgWrapper": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/CyberMsgWrapper" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "gov" + ], + "properties": { + "gov": { + "$ref": "#/definitions/GovMsg" + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsgWrapper": { + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + } + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "GovMsg": { + "oneOf": [ + { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/VoteOption" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcMsg": { + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", + "oneOf": [ + { + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", + "type": "object", + "required": [ + "transfer" + ], + "properties": { + "transfer": { + "type": "object", + "required": [ + "amount", + "channel_id", + "timeout", + "to_address" + ], + "properties": { + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "channel_id": { + "description": "exisiting channel to send the tokens over", + "type": "string" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", + "type": "object", + "required": [ + "send_packet" + ], + "properties": { + "send_packet": { + "type": "object", + "required": [ + "channel_id", + "data", + "timeout" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", + "type": "object", + "required": [ + "close_channel" + ], + "properties": { + "close_channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", + "type": "object", + "properties": { + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] + }, + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + } + }, + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", + "type": "object", + "required": [ + "height", + "revision" + ], + "properties": { + "height": { + "description": "block height after which the packet times out. the height within the given revision", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "revision": { + "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "VoteOption": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "no_with_veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/ibc-reflect/schema/query_msg.json b/contracts/ibc-reflect/schema/query_msg.json new file mode 100644 index 0000000..9a89af3 --- /dev/null +++ b/contracts/ibc-reflect/schema/query_msg.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Returns (reflect) account that is attached to this channel, or none.", + "type": "object", + "required": [ + "account" + ], + "properties": { + "account": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns all (channel, reflect_account) pairs. No pagination - this is a test contract", + "type": "object", + "required": [ + "list_accounts" + ], + "properties": { + "list_accounts": { + "type": "object" + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/reflect/schema/chain_response.json b/contracts/reflect/schema/chain_response.json new file mode 100644 index 0000000..a836c62 --- /dev/null +++ b/contracts/reflect/schema/chain_response.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ChainResponse", + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "$ref": "#/definitions/Binary" + } + }, + "definitions": { + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + } + } +} diff --git a/contracts/reflect/schema/cyber_msg_wrapper.json b/contracts/reflect/schema/cyber_msg_wrapper.json new file mode 100644 index 0000000..ae0cc6f --- /dev/null +++ b/contracts/reflect/schema/cyber_msg_wrapper.json @@ -0,0 +1,569 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CyberMsgWrapper", + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json new file mode 100644 index 0000000..c4b11ad --- /dev/null +++ b/contracts/reflect/schema/execute_msg.json @@ -0,0 +1,1367 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "reflect_msg" + ], + "properties": { + "reflect_msg": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/CosmosMsg_for_CyberMsgWrapper" + } + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "reflect_sub_msg" + ], + "properties": { + "reflect_sub_msg": { + "type": "object", + "required": [ + "msgs" + ], + "properties": { + "msgs": { + "type": "array", + "items": { + "$ref": "#/definitions/SubMsg_for_CyberMsgWrapper" + } + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_owner" + ], + "properties": { + "change_owner": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "owner": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_CyberMsgWrapper": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/CyberMsgWrapper" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "gov" + ], + "properties": { + "gov": { + "$ref": "#/definitions/GovMsg" + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsgWrapper": { + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + } + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "GovMsg": { + "oneOf": [ + { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/VoteOption" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcMsg": { + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", + "oneOf": [ + { + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", + "type": "object", + "required": [ + "transfer" + ], + "properties": { + "transfer": { + "type": "object", + "required": [ + "amount", + "channel_id", + "timeout", + "to_address" + ], + "properties": { + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "channel_id": { + "description": "exisiting channel to send the tokens over", + "type": "string" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", + "type": "object", + "required": [ + "send_packet" + ], + "properties": { + "send_packet": { + "type": "object", + "required": [ + "channel_id", + "data", + "timeout" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", + "type": "object", + "required": [ + "close_channel" + ], + "properties": { + "close_channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", + "type": "object", + "properties": { + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] + }, + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + } + }, + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", + "type": "object", + "required": [ + "height", + "revision" + ], + "properties": { + "height": { + "description": "block height after which the packet times out. the height within the given revision", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "revision": { + "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "ReplyOn": { + "description": "Use this to define when the contract gets a response callback. If you only need it for errors or success you can select just those in order to save gas.", + "type": "string", + "enum": [ + "always", + "error", + "success", + "never" + ] + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "SubMsg_for_CyberMsgWrapper": { + "description": "A submessage that will guarantee a `reply` call on success or error, depending on the `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message, but not revert any state changes in the calling contract. If this is required, it must be done manually in the `reply` entry point.", + "type": "object", + "required": [ + "id", + "msg", + "reply_on" + ], + "properties": { + "gas_limit": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "id": { + "description": "An arbitrary ID chosen by the contract. This is typically used to match `Reply`s in the `reply` entry point to the submessage.", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "msg": { + "$ref": "#/definitions/CosmosMsg_for_CyberMsgWrapper" + }, + "reply_on": { + "$ref": "#/definitions/ReplyOn" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "VoteOption": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "no_with_veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/reflect/schema/instantiate_msg.json b/contracts/reflect/schema/instantiate_msg.json new file mode 100644 index 0000000..44588cf --- /dev/null +++ b/contracts/reflect/schema/instantiate_msg.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object" +} diff --git a/contracts/reflect/schema/owner_response.json b/contracts/reflect/schema/owner_response.json new file mode 100644 index 0000000..0ec6409 --- /dev/null +++ b/contracts/reflect/schema/owner_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OwnerResponse", + "type": "object", + "required": [ + "owner" + ], + "properties": { + "owner": { + "type": "string" + } + } +} diff --git a/contracts/reflect/schema/query_msg.json b/contracts/reflect/schema/query_msg.json new file mode 100644 index 0000000..9cd8238 --- /dev/null +++ b/contracts/reflect/schema/query_msg.json @@ -0,0 +1,873 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "owner": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Queries the blockchain and returns the result untouched", + "type": "object", + "required": [ + "chain" + ], + "properties": { + "chain": { + "type": "object", + "required": [ + "request" + ], + "properties": { + "request": { + "$ref": "#/definitions/QueryRequest_for_CyberQueryWrapper" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Queries another contract and returns the data", + "type": "object", + "required": [ + "raw" + ], + "properties": { + "raw": { + "type": "object", + "required": [ + "contract", + "key" + ], + "properties": { + "contract": { + "type": "string" + }, + "key": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply", + "type": "object", + "required": [ + "sub_msg_result" + ], + "properties": { + "sub_msg_result": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "BankQuery": { + "oneOf": [ + { + "description": "This calls into the native bank module for one denomination Return value is BalanceResponse", + "type": "object", + "required": [ + "balance" + ], + "properties": { + "balance": { + "type": "object", + "required": [ + "address", + "denom" + ], + "properties": { + "address": { + "type": "string" + }, + "denom": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This calls into the native bank module for all denominations. Note that this may be much more expensive than Balance and should be avoided if possible. Return value is AllBalanceResponse.", + "type": "object", + "required": [ + "all_balances" + ], + "properties": { + "all_balances": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "CyberQuery": { + "oneOf": [ + { + "type": "object", + "required": [ + "particle_rank" + ], + "properties": { + "particle_rank": { + "type": "object", + "required": [ + "particle" + ], + "properties": { + "particle": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "particles_amount" + ], + "properties": { + "particles_amount": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "cyberlinks_amount" + ], + "properties": { + "cyberlinks_amount": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "thought" + ], + "properties": { + "thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "thought_stats" + ], + "properties": { + "thought_stats": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "thought_lowest_fee" + ], + "properties": { + "thought_lowest_fee": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "source_routes" + ], + "properties": { + "source_routes": { + "type": "object", + "required": [ + "source" + ], + "properties": { + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "source_routed_energy" + ], + "properties": { + "source_routed_energy": { + "type": "object", + "required": [ + "source" + ], + "properties": { + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "destination_routed_energy" + ], + "properties": { + "destination_routed_energy": { + "type": "object", + "required": [ + "destination" + ], + "properties": { + "destination": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "route" + ], + "properties": { + "route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "bandwidth_price" + ], + "properties": { + "bandwidth_price": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "bandwidth_load" + ], + "properties": { + "bandwidth_load": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "bandwidth_total" + ], + "properties": { + "bandwidth_total": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "neuron_bandwidth" + ], + "properties": { + "neuron_bandwidth": { + "type": "object", + "required": [ + "neuron" + ], + "properties": { + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "pool_params" + ], + "properties": { + "pool_params": { + "type": "object", + "required": [ + "pool_id" + ], + "properties": { + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "pool_liquidity" + ], + "properties": { + "pool_liquidity": { + "type": "object", + "required": [ + "pool_id" + ], + "properties": { + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "pool_supply" + ], + "properties": { + "pool_supply": { + "type": "object", + "required": [ + "pool_id" + ], + "properties": { + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "pool_price" + ], + "properties": { + "pool_price": { + "type": "object", + "required": [ + "pool_id" + ], + "properties": { + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "pool_address" + ], + "properties": { + "pool_address": { + "type": "object", + "required": [ + "pool_id" + ], + "properties": { + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberQueryWrapper": { + "type": "object", + "required": [ + "query_data", + "route" + ], + "properties": { + "query_data": { + "$ref": "#/definitions/CyberQuery" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + } + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "IbcQuery": { + "description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"", + "oneOf": [ + { + "description": "Gets the Port ID the current contract is bound to.\n\nReturns a `PortIdResponse`.", + "type": "object", + "required": [ + "port_id" + ], + "properties": { + "port_id": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Lists all channels that are bound to a given port. If `port_id` is omitted, this list all channels bound to the contract's port.\n\nReturns a `ListChannelsResponse`.", + "type": "object", + "required": [ + "list_channels" + ], + "properties": { + "list_channels": { + "type": "object", + "properties": { + "port_id": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Lists all information for a (portID, channelID) pair. If port_id is omitted, it will default to the contract's own channel. (To save a PortId{} call)\n\nReturns a `ChannelResponse`.", + "type": "object", + "required": [ + "channel" + ], + "properties": { + "channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "port_id": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + } + ] + }, + "QueryRequest_for_CyberQueryWrapper": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankQuery" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/CyberQueryWrapper" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingQuery" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate query is encoded the same way as abci_query, with path and protobuf encoded request data. The format is defined in [ADR-21](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-021-protobuf-query-encoding.md). The response is protobuf encoded data directly without a JSON response wrapper. The caller is responsible for compiling the proper protobuf definitions for both requests and responses.", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "data", + "path" + ], + "properties": { + "data": { + "description": "this is the expected protobuf message type (not any), binary encoded", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "path": { + "description": "this is the fully qualified service path used for routing, eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcQuery" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmQuery" + } + }, + "additionalProperties": false + } + ] + }, + "StakingQuery": { + "oneOf": [ + { + "description": "Returns the denomination that can be bonded (if there are multiple native tokens on the chain)", + "type": "object", + "required": [ + "bonded_denom" + ], + "properties": { + "bonded_denom": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "AllDelegations will return all delegations by the delegator", + "type": "object", + "required": [ + "all_delegations" + ], + "properties": { + "all_delegations": { + "type": "object", + "required": [ + "delegator" + ], + "properties": { + "delegator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Delegation will return more detailed info on a particular delegation, defined by delegator/validator pair", + "type": "object", + "required": [ + "delegation" + ], + "properties": { + "delegation": { + "type": "object", + "required": [ + "delegator", + "validator" + ], + "properties": { + "delegator": { + "type": "string" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns all validators in the currently active validator set.\n\nThe query response type is `AllValidatorsResponse`.", + "type": "object", + "required": [ + "all_validators" + ], + "properties": { + "all_validators": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Returns the validator at the given address. Returns None if the validator is not part of the currently active validator set.\n\nThe query response type is `ValidatorResponse`.", + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The validator's address (e.g. (e.g. cosmosvaloper1...))", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "WasmQuery": { + "oneOf": [ + { + "description": "this queries the public API of another contract at a known address (with known ABI) Return value is whatever the contract returns (caller should know), wrapped in a ContractResult that is JSON encoded.", + "type": "object", + "required": [ + "smart" + ], + "properties": { + "smart": { + "type": "object", + "required": [ + "contract_addr", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded QueryMsg struct", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "this queries the raw kv-store of the contract. returns the raw, unparsed data stored at that key, which may be an empty vector if not present", + "type": "object", + "required": [ + "raw" + ], + "properties": { + "raw": { + "type": "object", + "required": [ + "contract_addr", + "key" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "key": { + "description": "Key is the raw key used in the contracts Storage", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "returns a ContractInfoResponse with metadata on the contract from the runtime", + "type": "object", + "required": [ + "contract_info" + ], + "properties": { + "contract_info": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/reflect/schema/raw_response.json b/contracts/reflect/schema/raw_response.json new file mode 100644 index 0000000..06d1400 --- /dev/null +++ b/contracts/reflect/schema/raw_response.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "RawResponse", + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "description": "The returned value of the raw query. Empty data can be the result of a non-existent key or an empty value. We cannot differentiate those two cases in cross contract queries.", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + }, + "definitions": { + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + } + } +} diff --git a/contracts/reflect/schema/response_for__cyber_msg_wrapper.json b/contracts/reflect/schema/response_for__cyber_msg_wrapper.json new file mode 100644 index 0000000..918f5e9 --- /dev/null +++ b/contracts/reflect/schema/response_for__cyber_msg_wrapper.json @@ -0,0 +1,1377 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Response_for_CyberMsgWrapper", + "description": "A response of a contract entry point, such as `instantiate`, `execute` or `migrate`.\n\nThis type can be constructed directly at the end of the call. Alternatively a mutable response instance can be created early in the contract's logic and incrementally be updated.\n\n## Examples\n\nDirect:\n\n``` # use cosmwasm_std::{Binary, DepsMut, Env, MessageInfo}; # type InstantiateMsg = (); # use cosmwasm_std::{attr, Response, StdResult};\n\npub fn instantiate( deps: DepsMut, _env: Env, _info: MessageInfo, msg: InstantiateMsg, ) -> StdResult { // ...\n\nOk(Response::new().add_attribute(\"action\", \"instantiate\")) } ```\n\nMutating:\n\n``` # use cosmwasm_std::{coins, BankMsg, Binary, DepsMut, Env, MessageInfo, SubMsg}; # type InstantiateMsg = (); # type MyError = (); # use cosmwasm_std::Response;\n\npub fn instantiate( deps: DepsMut, _env: Env, info: MessageInfo, msg: InstantiateMsg, ) -> Result { let mut response = Response::new() .add_attribute(\"Let the\", \"hacking begin\") .add_message(BankMsg::Send { to_address: String::from(\"recipient\"), amount: coins(128, \"uint\"), }) .add_attribute(\"foo\", \"bar\") .set_data(b\"the result data\"); Ok(response) } ```", + "type": "object", + "required": [ + "attributes", + "events", + "messages" + ], + "properties": { + "attributes": { + "description": "The attributes that will be emitted as part of a \"wasm\" event.\n\nMore info about events (and their attributes) can be found in [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/master/core/events.html", + "type": "array", + "items": { + "$ref": "#/definitions/Attribute" + } + }, + "data": { + "description": "The binary payload to include in the response.", + "anyOf": [ + { + "$ref": "#/definitions/Binary" + }, + { + "type": "null" + } + ] + }, + "events": { + "description": "Extra, custom events separate from the main `wasm` one. These will have `wasm-` prepended to the type.\n\nMore info about events can be found in [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/master/core/events.html", + "type": "array", + "items": { + "$ref": "#/definitions/Event" + } + }, + "messages": { + "description": "Optional list of messages to pass. These will be executed in order. If the ReplyOn variant matches the result (Always, Success on Ok, Error on Err), the runtime will invoke this contract's `reply` entry point after execution. Otherwise, they act like \"fire and forget\". Use `SubMsg::new` to create messages with the older \"fire and forget\" semantics.", + "type": "array", + "items": { + "$ref": "#/definitions/SubMsg_for_CyberMsgWrapper" + } + } + }, + "definitions": { + "Attribute": { + "description": "An key value pair that is used in the context of event attributes in logs", + "type": "object", + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_CyberMsgWrapper": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "custom" + ], + "properties": { + "custom": { + "$ref": "#/definitions/CyberMsgWrapper" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "gov" + ], + "properties": { + "gov": { + "$ref": "#/definitions/GovMsg" + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsg": { + "oneOf": [ + { + "type": "object", + "required": [ + "cyberlink" + ], + "properties": { + "cyberlink": { + "type": "object", + "required": [ + "links", + "neuron" + ], + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/Link" + } + }, + "neuron": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "investmint" + ], + "properties": { + "investmint": { + "type": "object", + "required": [ + "amount", + "length", + "neuron", + "resource" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "length": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "neuron": { + "type": "string" + }, + "resource": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_energy_route" + ], + "properties": { + "create_energy_route": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route" + ], + "properties": { + "edit_energy_route": { + "type": "object", + "required": [ + "destination", + "source", + "value" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "edit_energy_route_name" + ], + "properties": { + "edit_energy_route_name": { + "type": "object", + "required": [ + "destination", + "name", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "name": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "delete_energy_route" + ], + "properties": { + "delete_energy_route": { + "type": "object", + "required": [ + "destination", + "source" + ], + "properties": { + "destination": { + "type": "string" + }, + "source": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_thought" + ], + "properties": { + "create_thought": { + "type": "object", + "required": [ + "load", + "name", + "particle", + "program", + "trigger" + ], + "properties": { + "load": { + "$ref": "#/definitions/Load" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "program": { + "type": "string" + }, + "trigger": { + "$ref": "#/definitions/Trigger" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "forget_thought" + ], + "properties": { + "forget_thought": { + "type": "object", + "required": [ + "name", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_input" + ], + "properties": { + "change_thought_input": { + "type": "object", + "required": [ + "input", + "name", + "program" + ], + "properties": { + "input": { + "type": "string" + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_period" + ], + "properties": { + "change_thought_period": { + "type": "object", + "required": [ + "name", + "period", + "program" + ], + "properties": { + "name": { + "type": "string" + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "change_thought_block" + ], + "properties": { + "change_thought_block": { + "type": "object", + "required": [ + "block", + "name", + "program" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "name": { + "type": "string" + }, + "program": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "create_pool" + ], + "properties": { + "create_pool": { + "type": "object", + "required": [ + "deposit_coins", + "pool_creator_address", + "pool_type_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "pool_creator_address": { + "type": "string" + }, + "pool_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "deposit_within_batch" + ], + "properties": { + "deposit_within_batch": { + "type": "object", + "required": [ + "deposit_coins", + "depositor_address", + "pool_id" + ], + "properties": { + "deposit_coins": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "depositor_address": { + "type": "string" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw_within_batch" + ], + "properties": { + "withdraw_within_batch": { + "type": "object", + "required": [ + "pool_coin", + "pool_id", + "withdrawer_address" + ], + "properties": { + "pool_coin": { + "$ref": "#/definitions/Coin" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "withdrawer_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "swap_within_batch" + ], + "properties": { + "swap_within_batch": { + "type": "object", + "required": [ + "demand_coin_denom", + "offer_coin", + "offer_coin_fee", + "order_price", + "pool_id", + "swap_requester_address", + "swap_type_id" + ], + "properties": { + "demand_coin_denom": { + "type": "string" + }, + "offer_coin": { + "$ref": "#/definitions/Coin" + }, + "offer_coin_fee": { + "$ref": "#/definitions/Coin" + }, + "order_price": { + "$ref": "#/definitions/Decimal" + }, + "pool_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "swap_requester_address": { + "type": "string" + }, + "swap_type_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] + }, + "CyberMsgWrapper": { + "type": "object", + "required": [ + "msg_data", + "route" + ], + "properties": { + "msg_data": { + "$ref": "#/definitions/CyberMsg" + }, + "route": { + "$ref": "#/definitions/CyberRoute" + } + } + }, + "CyberRoute": { + "description": "CyberRoute is enum type to represent cyber query route path", + "type": "string", + "enum": [ + "rank", + "graph", + "resources", + "grid", + "dmn", + "bandwidth", + "liquidity" + ] + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Event": { + "description": "A full [*Cosmos SDK* event].\n\nThis version uses string attributes (similar to [*Cosmos SDK* StringEvent]), which then get magically converted to bytes for Tendermint somewhere between the Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.\n\n[*Cosmos SDK* event]: https://docs.cosmos.network/master/core/events.html [*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70", + "type": "object", + "required": [ + "attributes", + "type" + ], + "properties": { + "attributes": { + "description": "The attributes to be included in the event.\n\nYou can learn more about these from [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/master/core/events.html", + "type": "array", + "items": { + "$ref": "#/definitions/Attribute" + } + }, + "type": { + "description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.", + "type": "string" + } + } + }, + "GovMsg": { + "oneOf": [ + { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/VoteOption" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcMsg": { + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", + "oneOf": [ + { + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", + "type": "object", + "required": [ + "transfer" + ], + "properties": { + "transfer": { + "type": "object", + "required": [ + "amount", + "channel_id", + "timeout", + "to_address" + ], + "properties": { + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "channel_id": { + "description": "exisiting channel to send the tokens over", + "type": "string" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", + "type": "object", + "required": [ + "send_packet" + ], + "properties": { + "send_packet": { + "type": "object", + "required": [ + "channel_id", + "data", + "timeout" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", + "type": "object", + "required": [ + "close_channel" + ], + "properties": { + "close_channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", + "type": "object", + "properties": { + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] + }, + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + } + }, + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", + "type": "object", + "required": [ + "height", + "revision" + ], + "properties": { + "height": { + "description": "block height after which the packet times out. the height within the given revision", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "revision": { + "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Link": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + } + }, + "Load": { + "type": "object", + "required": [ + "gas_price", + "input" + ], + "properties": { + "gas_price": { + "$ref": "#/definitions/Coin" + }, + "input": { + "type": "string" + } + } + }, + "ReplyOn": { + "description": "Use this to define when the contract gets a response callback. If you only need it for errors or success you can select just those in order to save gas.", + "type": "string", + "enum": [ + "always", + "error", + "success", + "never" + ] + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "SubMsg_for_CyberMsgWrapper": { + "description": "A submessage that will guarantee a `reply` call on success or error, depending on the `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message, but not revert any state changes in the calling contract. If this is required, it must be done manually in the `reply` entry point.", + "type": "object", + "required": [ + "id", + "msg", + "reply_on" + ], + "properties": { + "gas_limit": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "id": { + "description": "An arbitrary ID chosen by the contract. This is typically used to match `Reply`s in the `reply` entry point to the submessage.", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "msg": { + "$ref": "#/definitions/CosmosMsg_for_CyberMsgWrapper" + }, + "reply_on": { + "$ref": "#/definitions/ReplyOn" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Trigger": { + "type": "object", + "required": [ + "block", + "period" + ], + "properties": { + "block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "VoteOption": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "no_with_veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + } + } +} diff --git a/contracts/reflect/schema/state.json b/contracts/reflect/schema/state.json new file mode 100644 index 0000000..1c10ba4 --- /dev/null +++ b/contracts/reflect/schema/state.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "State", + "type": "object", + "required": [ + "owner" + ], + "properties": { + "owner": { + "$ref": "#/definitions/Addr" + } + }, + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + } + } +}