-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WasmQuery::CodeInfo to get checksum for code ID #1561
Changes from all commits
5a6fec1
e2814e5
e92c8e5
910f853
e41df95
afd3c34
224b80c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ use schemars::JsonSchema; | |
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::Binary; | ||
#[cfg(feature = "cosmwasm_1_2")] | ||
use crate::HexBinary; | ||
|
||
use super::query_response::QueryResponseType; | ||
|
||
|
@@ -26,6 +28,9 @@ pub enum WasmQuery { | |
}, | ||
/// Returns a [`ContractInfoResponse`] with metadata on the contract from the runtime | ||
ContractInfo { contract_addr: String }, | ||
/// Returns a [`CodeInfoResponse`] with metadata of the code | ||
#[cfg(feature = "cosmwasm_1_2")] | ||
CodeInfo { code_id: u64 }, | ||
} | ||
|
||
#[non_exhaustive] | ||
|
@@ -61,3 +66,24 @@ impl ContractInfoResponse { | |
} | ||
} | ||
} | ||
|
||
/// The essential data from wasmd's [CodeInfo]/[CodeInfoResponse]. | ||
/// | ||
/// `code_hash`/`data_hash` was renamed to `checksum` to follow the CosmWasm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 good to have the naming correct here. |
||
/// convention and naming in `instantiate2_address`. | ||
/// | ||
/// [CodeInfo]: https://github.com/CosmWasm/wasmd/blob/v0.30.0/proto/cosmwasm/wasm/v1/types.proto#L62-L72 | ||
/// [CodeInfoResponse]: https://github.com/CosmWasm/wasmd/blob/v0.30.0/proto/cosmwasm/wasm/v1/query.proto#L184-L199 | ||
#[non_exhaustive] | ||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] | ||
#[cfg(feature = "cosmwasm_1_2")] | ||
pub struct CodeInfoResponse { | ||
pub code_id: u64, | ||
/// The address that initially stored the code | ||
pub creator: String, | ||
/// The hash of the Wasm blob | ||
pub checksum: HexBinary, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to return the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hesitant to add it since it is a complex deeply nested type that is not trivial to add to all the layers in between. But I can have a second look today. I agree it feels incomplete. But on the other hand the smaller the interface, the more we can break on the wasmd side without breaking contracts. Do you see a clear use case for this information in the contract? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that
I would like to avoid blockin Instantiate2 usage on that. The field can be added later on. |
||
|
||
#[cfg(feature = "cosmwasm_1_2")] | ||
impl QueryResponseType for CodeInfoResponse {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍