Skip to content

Commit

Permalink
TokenContract query should return optional type
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 25, 2023
1 parent 1763c90 commit f13d8d4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,19 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"token_contract"
],
"properties": {
"token_contract": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -770,19 +783,6 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"token_contract"
],
"properties": {
"token_contract": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
Expand Down Expand Up @@ -1140,9 +1140,21 @@
},
"token_contract": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Addr",
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
"title": "Nullable_Addr",
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
],
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
}
}
},
"total_power_at_height": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/voting/dao-voting-token-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::IsActive {} => query_is_active(deps),
QueryMsg::ActiveThreshold {} => query_active_threshold(deps),
QueryMsg::GetHooks {} => to_binary(&query_hooks(deps)?),
QueryMsg::TokenContract {} => to_binary(&TOKEN_ISSUER_CONTRACT.load(deps.storage)?),
QueryMsg::TokenContract {} => to_binary(&TOKEN_ISSUER_CONTRACT.may_load(deps.storage)?),
}
}

Expand Down
5 changes: 3 additions & 2 deletions contracts/voting/dao-voting-token-staked/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Binary, Uint128};
use cw_utils::Duration;
use dao_dao_macros::{active_query, token_query, voting_module_query};
use dao_dao_macros::{active_query, voting_module_query};
use dao_interface::token::NewTokenInfo;
use dao_voting::threshold::{ActiveThreshold, ActiveThresholdResponse};

Check warning on line 6 in contracts/voting/dao-voting-token-staked/src/msg.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `ActiveThresholdResponse`

Check warning on line 6 in contracts/voting/dao-voting-token-staked/src/msg.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `ActiveThresholdResponse`

Expand Down Expand Up @@ -59,7 +59,6 @@ pub enum ExecuteMsg {

#[active_query]
#[voting_module_query]
#[token_query]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
Expand All @@ -78,6 +77,8 @@ pub enum QueryMsg {
ActiveThreshold {},
#[returns(GetHooksResponse)]
GetHooks {},
#[returns(Option<cosmwasm_std::Addr>)]
TokenContract {},
}

#[cw_serde]
Expand Down

0 comments on commit f13d8d4

Please sign in to comment.