mirror of
https://github.com/BiPhan4/DefiHackathon-2022.git
synced 2025-04-02 10:41:42 -04:00
non working changes
This commit is contained in:
parent
aef216b839
commit
ce7f2fc6be
3 changed files with 20 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue