Skip to content

Commit

Permalink
Merge pull request #708 from CosmWasm/optional-query
Browse files Browse the repository at this point in the history
Make query endpoint optional
  • Loading branch information
mergify[bot] authored Jan 12, 2021
2 parents afd642f + ab6d555 commit f548fd4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 27 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 0.14.0 (unreleased)

**all**

- The `query` enpoint is now optional. It is still hightly recommended to expose
it an almost any use case though.

**cosmwasm-std**

- Remove `from_address` from `BankMsg::Send`, as it always sends from the
Expand Down
2 changes: 1 addition & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ points in order to demonstrate and test the flexibility we have.

| Contract | Macro | Has `query` | Has `migrate` |
| -------- | --------------------------------------------- | ----------- | ------------- |
| burner | `#[entry_point]` | yes | yes |
| burner | `#[entry_point]` | no | yes |
| hackatom | [`create_entry_points_with_migration!`][cepm] | yes | yes |
| queue | mixed<sup>1</sup> | yes | yes |
| reflect | [`create_entry_points!`][cep] | yes | no |
Expand Down
3 changes: 1 addition & 2 deletions contracts/burner/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fs::create_dir_all;

use cosmwasm_schema::{export_schema, remove_schemas, schema_for};

use burner::msg::{HandleMsg, InitMsg, MigrateMsg, QueryMsg};
use burner::msg::{HandleMsg, InitMsg, MigrateMsg};

fn main() {
let mut out_dir = current_dir().unwrap();
Expand All @@ -14,5 +14,4 @@ fn main() {
export_schema(&schema_for!(HandleMsg), &out_dir);
export_schema(&schema_for!(InitMsg), &out_dir);
export_schema(&schema_for!(MigrateMsg), &out_dir);
export_schema(&schema_for!(QueryMsg), &out_dir);
}
6 changes: 0 additions & 6 deletions contracts/burner/schema/query_msg.json

This file was deleted.

13 changes: 3 additions & 10 deletions contracts/burner/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use cosmwasm_std::{
attr, entry_point, BankMsg, Deps, DepsMut, Env, HandleResponse, InitResponse, MessageInfo,
MigrateResponse, Order, QueryResponse, StdError, StdResult,
attr, entry_point, BankMsg, DepsMut, Env, HandleResponse, InitResponse, MessageInfo,
MigrateResponse, Order, StdError, StdResult,
};

use crate::msg::{HandleMsg, InitMsg, MigrateMsg, QueryMsg};
use crate::msg::{HandleMsg, InitMsg, MigrateMsg};

#[entry_point]
pub fn init(
Expand Down Expand Up @@ -63,13 +63,6 @@ pub fn migrate(
})
}

#[entry_point]
pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult<QueryResponse> {
Err(StdError::generic_err(
"You can only use this contract for migrations",
))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
4 changes: 0 additions & 4 deletions contracts/burner/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ pub struct InitMsg {}
/// HandleMsg is a placeholder where we don't take any input
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct HandleMsg {}

/// QueryMsg is a placeholder where we don't take any input
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct QueryMsg {}
3 changes: 1 addition & 2 deletions packages/vm/src/compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ const SUPPORTED_IMPORTS: &[&str] = &[
];

/// Lists all entry points we expect to be present when calling a contract.
/// Basically, anything that is used in calls.rs
/// Other optional exports exist, e.g. "query" and "migrate".
/// This is unlikely to change much, must be frozen at 1.0 to avoid breaking existing contracts
const REQUIRED_EXPORTS: &[&str] = &[
"cosmwasm_vm_version_4",
"query",
"init",
"handle",
"allocate",
Expand Down
2 changes: 0 additions & 2 deletions packages/vm/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ mod tests {
(export "cosmwasm_vm_version_4" (func 0))
(export "init" (func 0))
(export "handle" (func 0))
(export "query" (func 0))
(export "allocate" (func 0))
(export "deallocate" (func 0))
)"#,
Expand All @@ -512,7 +511,6 @@ mod tests {
(export "cosmwasm_vm_version_4" (func 0))
(export "init" (func 0))
(export "handle" (func 0))
(export "query" (func 0))
(export "allocate" (func 0))
(export "deallocate" (func 0))
)"#,
Expand Down

0 comments on commit f548fd4

Please sign in to comment.