non working changes

This commit is contained in:
BiPhan4 2022-03-26 20:56:27 -04:00
parent aef216b839
commit ce7f2fc6be
3 changed files with 20 additions and 2 deletions

View file

@ -5,7 +5,7 @@ use cw2::set_contract_version;
use crate::error::ContractError;
use crate::msg::{CountResponse, ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::state::{State, STATE};
use crate::state::{State, User, STATE, CUSTOMERS};
// version info for migration info
const CONTRACT_NAME: &str = "crates.io:counter";
@ -41,9 +41,20 @@ pub fn execute(
match msg {
ExecuteMsg::Increment {} => try_increment(deps),
ExecuteMsg::Reset { count } => try_reset(deps, info, count),
//ExecuteMsg::EnterCustomer {} => try_enter_address(deps, info),
}
}
pub fn try_enter_address(deps: DepsMut, info: MessageInfo, entering_address: String) -> Result<Response, ContractError>{
let entry_address = deps.api.addr_validate(&entering_address)?;
//load and save with extra key argument
let empty = CUSTOMERS.may_load(deps.storage, &str.to_string());
Ok(Response::new())
}
pub fn try_increment(deps: DepsMut) -> Result<Response, ContractError> {
STATE.update(deps.storage, |mut state| -> Result<_, ContractError> {
state.count += 1;

View file

@ -11,6 +11,7 @@ pub struct InstantiateMsg {
pub enum ExecuteMsg {
Increment {},
Reset { count: i32 },
EnterCustomer { entering_address: String}
//we will get user address and names. Then divide bill. Then take money from users and put into our own contract.
//
}

View file

@ -2,7 +2,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::Addr;
use cw_storage_plus::Item; //import map and figure out how to use it
use cw_storage_plus::{Item, Map}; //import map and figure out how to use it
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct State {
@ -10,8 +10,14 @@ pub struct State {
pub owner: Addr,
}
pub struct User {
pub name: String,
pub address: Addr,
}
pub const STATE: Item<State> = Item::new("state");
pub const CUSTOMERS: Map<&str, User> = Map::new("customers");
/*
add states: