prov_cosmwasm_std/query/
wasm.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::Binary;
5
6#[non_exhaustive]
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
8#[serde(rename_all = "snake_case")]
9pub enum WasmQuery {
10    /// this queries the public API of another contract at a known address (with known ABI)
11    /// return value is whatever the contract returns (caller should know)
12    Smart {
13        contract_addr: String,
14        /// msg is the json-encoded QueryMsg struct
15        msg: Binary,
16    },
17    /// this queries the raw kv-store of the contract.
18    /// returns the raw, unparsed data stored at that key, which may be an empty vector if not present
19    Raw {
20        contract_addr: String,
21        /// Key is the raw key used in the contracts Storage
22        key: Binary,
23    },
24    /// returns a ContractInfoResponse with metadata on the contract from the runtime
25    ContractInfo { contract_addr: String },
26}
27
28#[non_exhaustive]
29#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
30pub struct ContractInfoResponse {
31    pub code_id: u64,
32    /// address that instantiated this contract
33    pub creator: String,
34    /// admin who can run migrations (if any)
35    pub admin: Option<String>,
36    /// if set, the contract is pinned to the cache, and thus uses less gas when called
37    pub pinned: bool,
38    /// set if this contract has bound an IBC port
39    pub ibc_port: Option<String>,
40}
41
42impl ContractInfoResponse {
43    /// Convenience constructor for tests / mocks
44    #[doc(hidden)]
45    pub fn new(code_id: u64, creator: impl Into<String>) -> Self {
46        Self {
47            code_id,
48            creator: creator.into(),
49            admin: None,
50            pinned: false,
51            ibc_port: None,
52        }
53    }
54}