mirror of
https://github.com/BiPhan4/DefiHackathon-2022.git
synced 2025-04-02 10:41:42 -04:00
map and payer count works
This commit is contained in:
parent
7e8771557e
commit
ed89f66457
6 changed files with 13 additions and 6 deletions
|
@ -1 +1 @@
|
|||
e82335a5bc6a618e7e7d5a70b7581475af25e434cc69dd10744d20a72730e929 counter.wasm
|
||||
bb14886bfd94d6402eb40a6632d5b0fb7ec24f9120c1ce8d83f771776402c48b counter.wasm
|
||||
|
|
|
@ -1 +1 @@
|
|||
919f0f03ccd5dcf907d768d9691034204ba89c7fc6322c7ef0af03297232870d ./target/wasm32-unknown-unknown/release/counter.wasm
|
||||
77a2fd2a04bd7c5f38ca2e35452d08b97c5bb8191121406e100d58fa20409974 ./target/wasm32-unknown-unknown/release/counter.wasm
|
||||
|
|
Binary file not shown.
|
@ -61,7 +61,7 @@ pub fn try_payup(deps: DepsMut, info: MessageInfo) -> Result<Response, ContractE
|
|||
.collect();
|
||||
|
||||
STATE.update(deps.storage, |mut state| -> Result<_, ContractError> {
|
||||
state.TotalPayers += all.iter().len();
|
||||
state.TotalPayers += all.unwrap_or_default().len() as i32;
|
||||
Ok(state)
|
||||
})?;
|
||||
|
||||
|
@ -92,6 +92,14 @@ pub fn try_payup(deps: DepsMut, info: MessageInfo) -> Result<Response, ContractE
|
|||
Ok(Response::new().add_message(msg))
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "library"), entry_point)]
|
||||
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
|
||||
match msg {
|
||||
QueryMsg::QueryPayers {} => to_binary(&QueryPayers(deps)?),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn QueryPayers(deps: Deps) -> StdResult<totalPayersResponse> {
|
||||
let state = STATE.load(deps.storage)?;
|
||||
Ok(totalPayersResponse { payers: state.TotalPayers})
|
||||
|
|
|
@ -18,7 +18,6 @@ pub enum ExecuteMsg {
|
|||
#[serde(rename_all = "snake_case")]
|
||||
pub enum QueryMsg {
|
||||
// GetCount returns the current count as a json-encoded number
|
||||
GetCount {},
|
||||
QueryPayers{},
|
||||
|
||||
}
|
||||
|
@ -26,7 +25,7 @@ pub enum QueryMsg {
|
|||
//We define a custom struct for each query response
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
pub struct totalPayersResponse {
|
||||
pub payers: usize,
|
||||
pub payers: i32,
|
||||
}
|
||||
|
||||
//initiate balances?
|
|
@ -8,7 +8,7 @@ use cw_storage_plus::{Item, Map};
|
|||
pub struct State {
|
||||
pub storeowner: Addr,
|
||||
pub bill: i32,
|
||||
pub TotalPayers: usize,
|
||||
pub TotalPayers: i32,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue