Remove debugging transaction (#1788)

This commit is contained in:
Bogdan-Ștefan Neacşu
2022-11-22 14:33:35 +02:00
committed by GitHub
parent 2db1bc8efa
commit 1cec2ddff0
2 changed files with 0 additions and 49 deletions
@@ -36,12 +36,6 @@ pub enum ExecuteMsg {
},
AdvanceEpochState {},
// DEBUG ONLY TXs. THEY SHALL BE REMOVED BEFORE FINALISING THE CODE
// only exists for debugging purposes on local network to reset the entire state of the contract
DebugUnsafeResetAll {
init_msg: InstantiateMsg,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
-43
View File
@@ -89,53 +89,10 @@ pub fn execute(
deps, info, owner,
)
}
ExecuteMsg::DebugUnsafeResetAll { init_msg } => {
reset_contract_state(deps, env, info, init_msg)
}
ExecuteMsg::AdvanceEpochState {} => advance_epoch_state(deps, info),
}
}
fn reset_contract_state(
mut deps: DepsMut<'_>,
env: Env,
info: MessageInfo,
init_msg: InstantiateMsg,
) -> Result<Response, ContractError> {
ADMIN.assert_admin(deps.as_ref(), &info.sender)?;
// this resets the epoch
instantiate(deps.branch(), env, info, init_msg)?;
// clear all dealings, public keys, etc
let current = dealers::storage::current_dealers()
.keys(deps.storage, None, None, cosmwasm_std::Order::Ascending)
.collect::<Result<Vec<_>, _>>()?;
let past = dealers::storage::past_dealers()
.keys(deps.storage, None, None, cosmwasm_std::Order::Ascending)
.collect::<Result<Vec<_>, _>>()?;
let dealings = dealings::storage::DEALINGS_BYTES[0]
.keys(deps.storage, None, None, cosmwasm_std::Order::Ascending)
.collect::<Result<Vec<_>, _>>()?;
for dealer in current {
dealers::storage::current_dealers().remove(deps.storage, &dealer)?;
}
for dealer in past {
dealers::storage::past_dealers().remove(deps.storage, &dealer)?;
}
for addr in dealings {
for map in dealings::storage::DEALINGS_BYTES {
map.remove(deps.storage, &addr);
}
}
dealers::storage::NODE_INDEX_COUNTER.save(deps.storage, &0u64)?;
Ok(Response::default())
}
#[entry_point]
pub fn query(deps: Deps<'_>, _env: Env, msg: QueryMsg) -> Result<QueryResponse, ContractError> {
let response = match msg {