secret_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, Eq, 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), wrapped in a
12 /// ContractResult that is JSON encoded.
13 Smart {
14 contract_addr: String,
15 /// code_hash is the hex encoded hash of the code. This is used by Secret Network to harden against replaying the contract
16 /// It is used to bind the request to a destination contract in a stronger way than just the contract address which can be faked
17 #[serde(rename = "callback_code_hash")]
18 code_hash: String,
19 /// msg is the json-encoded QueryMsg struct
20 msg: Binary,
21 },
22 /// returns a ContractInfoResponse with metadata on the contract from the runtime
23 ContractInfo { contract_addr: String },
24 /// Raw queries are unsupported in Secret Network - keys and values in raw storage are encrypted,
25 /// and must be queried through a smart query
26 Raw { key: Binary, contract_addr: String },
27}
28
29#[non_exhaustive]
30#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
31pub struct ContractInfoResponse {
32 pub code_id: u64,
33 /// address that instantiated this contract
34 pub creator: String,
35 /// if set, the contract is pinned to the cache, and thus uses less gas when called
36 pub pinned: bool,
37 /// set if this contract has bound an IBC port
38 pub ibc_port: Option<String>,
39}
40
41impl ContractInfoResponse {
42 /// Convenience constructor for tests / mocks
43 #[doc(hidden)]
44 pub fn new(code_id: u64, creator: impl Into<String>) -> Self {
45 Self {
46 code_id,
47 creator: creator.into(),
48 pinned: false,
49 ibc_port: None,
50 }
51 }
52}