generated from okp4/template-rust
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logic): introduce logic module bindings
- Loading branch information
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# CW Logic Sample | ||
|
||
Sample contract to query the okp4 logic module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod query; | ||
|
||
pub use query::{LogicCustomQuery, AskResponse, Answer, Result, Substitution, Term}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Answer>, | ||
} | ||
|
||
#[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<String>, | ||
pub results: Vec<Result>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, JsonSchema, Debug)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct Result { | ||
pub substitutions: Vec<Substitution>, | ||
} | ||
|
||
#[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<Term>, | ||
} |