Skip to content

Commit

Permalink
remove debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
albertandrejev committed Feb 21, 2024
1 parent ad16b62 commit 1ac1fb6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 86 deletions.
25 changes: 1 addition & 24 deletions contracts/proposal-votes/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ fn execute_update_voters_list(
info: MessageInfo,
voters: Vec<String>,
) -> ContractResult<Response<NeutronMsg>> {
deps.api.debug(&format!(
"WASMDEBUG: execute_update_voters_list data: {voters:?}",
));
cw_ownable::assert_owner(deps.storage, &info.sender)?;

VOTERS.save(deps.storage, &voters)?;
Expand All @@ -173,9 +170,6 @@ fn execute_update_active_proposals(
info: MessageInfo,
active_proposals: Vec<u64>,
) -> ContractResult<Response<NeutronMsg>> {
deps.api.debug(&format!(
"WASMDEBUG: execute_update_active_proposals data: {active_proposals:?}",
));
let config = CONFIG.load(deps.storage)?;

ensure_eq!(
Expand Down Expand Up @@ -324,22 +318,12 @@ pub fn sudo_kv_query_result(

let votes_query_id = QUERY_ID.may_load(deps.storage)?;

deps.api.debug(&format!(
"WASMDEBUG: sudo_kv_query_result proposal_votes_query_id: {:?}",
query_id.clone()
));

let interchain_query_result = get_raw_interchain_query_result(deps.as_ref(), query_id)?;

if Some(query_id) == votes_query_id {
return sudo_proposal_votes(deps, interchain_query_result);
}

deps.api.debug(&format!(
"WASMDEBUG: sudo_kv_query_result query_id: {:?}",
query_id
));

Ok(Response::default())
}

Expand Down Expand Up @@ -379,21 +363,14 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> ContractResult<Response> {
}

fn proposals_votes_reply(deps: DepsMut, _env: Env, msg: Reply) -> ContractResult<Response> {
deps.api
.debug(&format!("WASMDEBUG: proposals_votes_reply call: {msg:?}",));

let query_id = get_query_id(msg.result)?;

QUERY_ID.save(deps.storage, &query_id)?;

Ok(Response::new())
}

fn proposals_votes_remove_reply(deps: DepsMut, _env: Env, msg: Reply) -> ContractResult<Response> {
deps.api.debug(&format!(
"WASMDEBUG: proposals_votes_remove_reply call: {msg:?}",
));

fn proposals_votes_remove_reply(deps: DepsMut, _env: Env, _msg: Reply) -> ContractResult<Response> {
QUERY_ID.remove(deps.storage);

Ok(Response::new())
Expand Down
62 changes: 0 additions & 62 deletions contracts/provider-proposals/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,15 @@ fn query_proposal(deps: Deps<NeutronQuery>, proposal_id: u64) -> StdResult<Binar

fn query_proposals(deps: Deps<NeutronQuery>) -> StdResult<Binary> {
let config = CONFIG.load(deps.storage)?;
deps.api.debug("WASMDEBUG: query_proposals");
let proposals: StdResult<Vec<_>> = PROPOSALS
.range_raw(deps.storage, None, None, Order::Ascending)
.map(|item| {
item.map(|(_key, value)| {
deps.api.debug(&format!(
"WASMDEBUG: query_proposals: inside map: {:?}",
value
));

let votes = PROPOSALS_VOTES
.may_load(deps.storage, value.proposal_id)
.ok()
.unwrap_or_default();

deps.api.debug(&format!(
"WASMDEBUG: query_proposals: inside map votes: {:?}",
votes
));

ProposalInfo {
proposal: value.clone(),
votes,
Expand All @@ -165,11 +154,6 @@ fn query_proposals(deps: Deps<NeutronQuery>) -> StdResult<Binary> {
})
.collect();

deps.api.debug(&format!(
"WASMDEBUG: query_proposals: proposals: {:?}",
proposals
));

to_json_binary(&proposals?)
}

Expand Down Expand Up @@ -214,11 +198,6 @@ fn execute_update_config(
.filter(|id| *id != 0)
.collect::<Vec<u64>>();

deps.api.debug(&format!(
"WASMDEBUG: execute_update_config: {:?}",
proposal_ids
));

msgs.push(update_voting_proposals_msg(
proposal_votes_address.to_string(),
proposal_ids,
Expand Down Expand Up @@ -268,49 +247,24 @@ pub fn execute_update_votes(
info: MessageInfo,
votes: Vec<ProposalVote>,
) -> ContractResult<Response<NeutronMsg>> {
deps.api
.debug(&format!("WASMDEBUG: execute_update_votes: {:?}", votes));
let config = CONFIG.load(deps.storage)?;
deps.api.debug("WASMDEBUG: execute_update_votes: 1");
deps.api.debug(&format!(
"WASMDEBUG: execute_update_votes: ensure {:?}, {:?}",
config.proposal_votes_address, info.sender
));

ensure_eq!(
config.proposal_votes_address,
Some(info.sender.to_string()),
ContractError::Unauthorized {}
);

deps.api.debug("WASMDEBUG: execute_update_votes: 2");

let mut votes_map: HashMap<u64, Vec<ProposalVote>> = HashMap::new();

deps.api.debug("WASMDEBUG: execute_update_votes: 3");

for vote in votes.clone() {
votes_map.entry(vote.proposal_id).or_default().push(vote);
}

deps.api.debug("WASMDEBUG: execute_update_votes: 4");

deps.api.debug(&format!(
"WASMDEBUG: execute_update_votes, votes_map: {:?}",
votes_map
));

for (proposal_id, votes) in votes_map.iter() {
deps.api.debug(&format!(
"WASMDEBUG: execute_update_votes, loop: {:?}, {:?}",
proposal_id, votes
));

PROPOSALS_VOTES.save(deps.storage, *proposal_id, votes)?;
}

deps.api.debug("WASMDEBUG: execute_update_votes: 5");

Ok(response(
"config_update",
CONTRACT_NAME,
Expand Down Expand Up @@ -345,22 +299,12 @@ pub fn sudo_kv_query_result(

let proposals_query_id = QUERY_ID.may_load(deps.storage)?;

deps.api.debug(&format!(
"WASMDEBUG: sudo_kv_query_result proposal_votes_query_id: {:?}",
query_id.clone()
));

let interchain_query_result = get_raw_interchain_query_result(deps.as_ref(), query_id)?;

if Some(query_id) == proposals_query_id {
return sudo_proposals_query(deps, interchain_query_result);
}

deps.api.debug(&format!(
"WASMDEBUG: sudo_kv_query_result query_id: {:?}",
query_id
));

Ok(Response::default())
}

Expand All @@ -371,9 +315,6 @@ fn sudo_proposals_query(
let data: GovernmentProposal =
KVReconstruct::reconstruct(&interchain_query_result.result.kv_results)?;

deps.api
.debug(&format!("WASMDEBUG: sudo_proposals_query data: {data:?}",));

let mut msgs: Vec<CosmosMsg<NeutronMsg>> = Vec::new();
match data.proposals.first() {
Some(first_proposal) => {
Expand Down Expand Up @@ -484,9 +425,6 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> ContractResult<Response> {
}

fn proposals_votes_reply(deps: DepsMut, _env: Env, msg: Reply) -> ContractResult<Response> {
deps.api
.debug(&format!("WASMDEBUG: proposals_votes_reply call: {msg:?}",));

let query_id = get_query_id(msg.result)?;

QUERY_ID.save(deps.storage, &query_id)?;
Expand Down

0 comments on commit 1ac1fb6

Please sign in to comment.