Skip to content

Commit

Permalink
refactor(logic-bindings): ensure safe conversion of strings to Prolog…
Browse files Browse the repository at this point in the history
… atoms
  • Loading branch information
ccamel committed Dec 23, 2024
1 parent a6d5858 commit 84df057
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions contracts/axone-law-stone/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn query(deps: Deps<'_, LogicCustomQuery>, env: Env, msg: QueryMsg) -> StdRe
pub mod query {
use cosmwasm_std::QueryRequest;

use axone_logic_bindings::{Answer, AskResponse};
use axone_logic_bindings::{as_prolog_atom, Answer, AskResponse};

use crate::helper::object_ref_to_uri;
use crate::msg::ProgramResponse;
Expand Down Expand Up @@ -184,7 +184,7 @@ pub mod query {
let program_uri = object_ref_to_uri(program)?;

Ok(LogicCustomQuery::Ask {
program: format!(":- consult('{}').", program_uri),
program: format!(":- consult({}).", as_prolog_atom(&program_uri.to_string())),
query,
})
}
Expand All @@ -203,10 +203,10 @@ pub fn reply(
}

pub mod reply {
use cw_utils::ParseReplyError;

use crate::helper::{ask_response_to_objects, get_reply_event_attribute, object_ref_to_uri};
use crate::state::{LawStone, DEPENDENCIES, PROGRAM};
use axone_logic_bindings::as_prolog_atom;
use cw_utils::ParseReplyError;

use super::*;

Expand Down Expand Up @@ -267,12 +267,10 @@ pub mod reply {

Ok(LogicCustomQuery::Ask {
program: "source_files(Files) :- bagof(File, source_file(File), Files).".to_string(),
query: [
"consult('",
program_uri.as_str(),
"'), source_files(Files).",
]
.join(""),
query: format!(
"consult({}), source_files(Files).",
as_prolog_atom(&program_uri)
),
})
}
}
Expand Down

0 comments on commit 84df057

Please sign in to comment.