Skip to main content

axone_law_stone/
msg.rs

1#[allow(unused_imports)]
2use axone_logic_bindings::AskResponse;
3use cosmwasm_schema::{cw_serde, QueryResponses};
4use cosmwasm_std::Binary;
5
6/// Instantiate message
7#[cw_serde]
8pub struct InstantiateMsg {
9    /// The Prolog program carrying law rules and facts.
10    pub program: Binary,
11
12    /// The `axone-objectarium` contract address on which to store the law program.
13    pub storage_address: String,
14}
15
16/// Execute messages
17#[cw_serde]
18pub enum ExecuteMsg {
19    /// # BreakStone
20    /// Break the stone making this contract unusable, by clearing all the related resources:
21    /// - Unpin all the pinned objects on `axone-objectarium` contracts, if any.
22    /// - Forget the main program (i.e. or at least unpin it).
23    ///
24    /// Only the creator address (the address that instantiated the contract) is authorized to invoke
25    /// this message.
26    /// If already broken, this is a no-op.
27    BreakStone {},
28}
29
30/// Query messages
31#[cw_serde]
32#[derive(QueryResponses)]
33pub enum QueryMsg {
34    /// # Ask
35    /// Submits a Prolog query string to the `Logic` module, evaluating it against the
36    /// law program associated with this contract.
37    ///
38    /// If the law stone is broken the query returns a response with the error `error(system_error(broken_law_stone),root)`
39    /// set in the `answer` field.
40    #[returns(AskResponse)]
41    Ask { query: String },
42
43    /// # Program
44    /// Retrieves the location metadata of the law program bound to this contract.
45    ///
46    /// This includes the contract address of the `objectarium` and the program object ID,
47    /// where the law program's code can be accessed.
48    #[returns(ProgramResponse)]
49    Program {},
50
51    /// # ProgramCode
52    /// Fetches the raw code of the law program tied to this contract.
53    ///
54    /// If the law stone is broken, the query may fail if the program is no longer available in the
55    /// `Objectarium`.
56    #[returns(Binary)]
57    ProgramCode {},
58}
59
60/// # ProgramResponse
61/// ProgramResponse carry elements to locate the program in a `axone-objectarium` contract.
62#[cw_serde]
63pub struct ProgramResponse {
64    /// The program object id in the `axone-objectarium` contract.
65    pub object_id: String,
66
67    /// The `axone-objectarium` contract address on which the law program is stored.
68    pub storage_address: String,
69}