use cosmwasm_std::{DepsMut, MessageInfo, Response};
pub use hub_base::execute::execute_update_owner;
use hub_base::execute::{check_owner, next_entry_id};
use hub_base::validating::{validate_datatype, validate_particle};
use hub_base::ContractError;
use crate::state::{Entry, LIST};
pub fn execute_create_entry(
mut deps: DepsMut,
info: MessageInfo,
data_type: String,
particle: Option<String>,
) -> Result<Response, ContractError> {
check_owner(&deps, &info)?;
validate_particle(&particle)?;
validate_datatype(data_type.clone())?;
let id = next_entry_id(&mut deps)?;
let new_entry = Entry {
id,
data_type,
particle: particle.unwrap_or("".to_string()),
};
LIST.save(deps.storage, id, &new_entry)?;
Ok(Response::new()
.add_attribute("method", "execute_create_entry")
.add_attribute("new_entry_id", id.to_string()))
}
pub fn execute_update_entry(
deps: DepsMut,
info: MessageInfo,
id: u64,
data_type: String,
particle: Option<String>,
) -> Result<Response, ContractError> {
check_owner(&deps, &info)?;
validate_particle(&particle)?;
validate_datatype(data_type.clone())?;
let entry = LIST.load(deps.storage, id)?;
let updated_entry = Entry {
id,
data_type,
particle: particle.unwrap_or(entry.particle),
};
LIST.save(deps.storage, id, &updated_entry)?;
Ok(Response::new()
.add_attribute("method", "execute_update_entry")
.add_attribute("updated_entry_id", id.to_string()))
}
cw-cyber/contracts/hub-protocols/src/execute.rs
ฯ 0.0%
use ;
pub use execute_update_owner;
use ;
use ;
use ContractError;
use crate;