Skip to content

Commit

Permalink
feat(law-stone)!: update needed by new logic bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Feb 22, 2024
1 parent f1a809c commit dcaef7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
14 changes: 5 additions & 9 deletions contracts/okp4-law-stone/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ mod tests {
use okp4_logic_bindings::testing::mock::mock_dependencies_with_logic_handler;
use okp4_logic_bindings::uri::CosmwasmUri;
use okp4_logic_bindings::{
Answer, AskResponse, LogicCustomQuery, Result as LogicResult, Substitution, Term,
Answer, AskResponse, LogicCustomQuery, Result as LogicResult, Substitution,
};
use okp4_objectarium::msg::PageInfo;
use std::collections::VecDeque;
Expand Down Expand Up @@ -300,15 +300,13 @@ mod tests {
gas_used: 1000,
answer: Some(Answer {
success: true,
error: None,
has_more: false,
variables: vec!["Files".to_string()],
results: vec![LogicResult {
substitutions: vec![Substitution {
variable: "Files".to_string(),
term: Term {
name: deps_name,
arguments: vec![],
},
expression: deps_name,
}],
}],
}),
Expand Down Expand Up @@ -462,15 +460,13 @@ mod tests {
gas_used: 1000,
answer: Some(Answer {
success: true,
error: None,
has_more: false,
variables: vec!["Foo".to_string()],
results: vec![LogicResult {
substitutions: vec![Substitution {
variable: "Foo".to_string(),
term: Term {
name: "bar".to_string(),
arguments: vec![],
},
expression: "bar".to_string(),
}],
}],
}),
Expand Down
11 changes: 4 additions & 7 deletions contracts/okp4-law-stone/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ pub fn ask_response_to_objects(
.flat_map(|r: &okp4_logic_bindings::Result| r.substitutions.clone())
.filter(|s| s.variable == variable)
.map(|s: Substitution| {
s.term
.parse()
s.parse_expression()
.map_err(|e| ContractError::LogicAskResponse(LogicAskResponseError::Parse(e)))
.and_then(term_as_vec)
})
Expand All @@ -72,7 +71,7 @@ pub fn ask_response_to_objects(
mod tests {
use super::*;
use okp4_logic_bindings::error::TermParseError;
use okp4_logic_bindings::{Answer, Term};
use okp4_logic_bindings::Answer;

#[test]
fn logic_to_objects() {
Expand Down Expand Up @@ -105,15 +104,13 @@ mod tests {
results: vec![okp4_logic_bindings::Result {
substitutions: vec![Substitution {
variable: "X".to_string(),
term: Term {
name: case.0,
arguments: vec![],
}
expression: case.0,
}]
}],
has_more: false,
success: true,
variables: vec![],
error: None,
}),
height: 1,
gas_used: 1,
Expand Down

0 comments on commit dcaef7a

Please sign in to comment.