Skip to content

Commit

Permalink
Merge pull request #15 from enigmampc/contract-status
Browse files Browse the repository at this point in the history
ContractStatus query
  • Loading branch information
reuvenpo authored May 25, 2021
2 parents f7585cd + dad03fc commit b76b4b4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
27 changes: 27 additions & 0 deletions schema/query_answer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@
}
}
},
{
"type": "object",
"required": [
"contract_status"
],
"properties": {
"contract_status": {
"type": "object",
"required": [
"status"
],
"properties": {
"status": {
"$ref": "#/definitions/ContractStatusLevel"
}
}
}
}
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -271,6 +290,14 @@
}
}
},
"ContractStatusLevel": {
"type": "string",
"enum": [
"normal_run",
"stop_all_but_redeems",
"stop_all"
]
},
"HumanAddr": {
"type": "string"
},
Expand Down
11 changes: 11 additions & 0 deletions schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
}
}
},
{
"type": "object",
"required": [
"contract_status"
],
"properties": {
"contract_status": {
"type": "object"
}
}
},
{
"type": "object",
"required": [
Expand Down
9 changes: 9 additions & 0 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pub fn query<S: Storage, A: Api, Q: Querier>(deps: &Extern<S, A, Q>, msg: QueryM
match msg {
QueryMsg::TokenInfo {} => query_token_info(&deps.storage),
QueryMsg::TokenConfig {} => query_token_config(&deps.storage),
QueryMsg::ContractStatus {} => query_contract_status(&deps.storage),
QueryMsg::ExchangeRate {} => query_exchange_rate(&deps.storage),
QueryMsg::Minters { .. } => query_minters(deps),
_ => authenticated_queries(deps, msg),
Expand Down Expand Up @@ -331,6 +332,14 @@ fn query_token_config<S: ReadonlyStorage>(storage: &S) -> QueryResult {
})
}

fn query_contract_status<S: ReadonlyStorage>(storage: &S) -> QueryResult {
let config = ReadonlyConfig::from_storage(storage);

to_binary(&QueryAnswer::ContractStatus {
status: config.contract_status(),
})
}

pub fn query_transfers<S: Storage, A: Api, Q: Querier>(
deps: &Extern<S, A, Q>,
account: &HumanAddr,
Expand Down
4 changes: 4 additions & 0 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ pub enum HandleAnswer {
pub enum QueryMsg {
TokenInfo {},
TokenConfig {},
ContractStatus {},
ExchangeRate {},
Allowance {
owner: HumanAddr,
Expand Down Expand Up @@ -370,6 +371,9 @@ pub enum QueryAnswer {
mint_enabled: bool,
burn_enabled: bool,
},
ContractStatus {
status: ContractStatusLevel,
},
ExchangeRate {
rate: Uint128,
denom: String,
Expand Down

0 comments on commit b76b4b4

Please sign in to comment.