diff --git a/Cargo.lock b/Cargo.lock index ce4ddde3..fbbf7bba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,6 +474,15 @@ version = "0.2.133" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" +[[package]] +name = "logic-bindings" +version = "0.2.0" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + [[package]] name = "opaque-debug" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index 7703479c..351dca39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["contracts/*"] +members = ["contracts/*", "packages/*"] [workspace.dependencies] cosmwasm-schema = "1.2.1" diff --git a/packages/logic-bindings/Cargo.toml b/packages/logic-bindings/Cargo.toml new file mode 100644 index 00000000..1f6ba30d --- /dev/null +++ b/packages/logic-bindings/Cargo.toml @@ -0,0 +1,10 @@ +[package] +authors = ["OKP4"] +edition = "2021" +name = "logic-bindings" +version = "0.2.0" + +[dependencies] +cosmwasm-std.workspace = true +schemars.workspace = true +serde.workspace = true diff --git a/packages/logic-bindings/README.md b/packages/logic-bindings/README.md new file mode 100644 index 00000000..c0f27ec7 --- /dev/null +++ b/packages/logic-bindings/README.md @@ -0,0 +1,3 @@ +# CW Logic Sample + +Sample contract to query the okp4 logic module. diff --git a/packages/logic-bindings/src/lib.rs b/packages/logic-bindings/src/lib.rs new file mode 100644 index 00000000..f675c18b --- /dev/null +++ b/packages/logic-bindings/src/lib.rs @@ -0,0 +1,3 @@ +mod query; + +pub use query::{LogicCustomQuery, AskResponse, Answer, Result, Substitution, Term}; diff --git a/packages/logic-bindings/src/query.rs b/packages/logic-bindings/src/query.rs new file mode 100644 index 00000000..31c12580 --- /dev/null +++ b/packages/logic-bindings/src/query.rs @@ -0,0 +1,51 @@ +use cosmwasm_std::CustomQuery; +use serde::{Deserialize, Serialize}; +use schemars::JsonSchema; + +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub enum LogicCustomQuery { + Ask { + program: String, + query: String, + }, +} + +impl CustomQuery for LogicCustomQuery {} + +#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub struct AskResponse { + pub height: u64, + pub gas_used: u64, + pub answer: Option, +} + +#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub struct Answer { + pub success: bool, + pub has_more: bool, + pub variables: Vec, + pub results: Vec, +} + +#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub struct Result { + pub substitutions: Vec, +} + +#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub struct Substitution { + pub variable: String, + pub term: Term, +} + +#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, JsonSchema, Debug)] +#[serde(rename_all = "snake_case")] +pub struct Term { + pub name: String, + pub arguments: Vec, +}