use cosmwasm_std::{self, from_slice, to_vec, Response, StdResult}; use fadroma_proc_derive::*; const KEY_STRING: &[u8] = b"string_data"; #[contract(entry)] pub trait StringComponent { #[init] fn new(string: String) -> StdResult { deps.storage.set(KEY_STRING, &to_vec(&string)?); Ok(Response::default()) } #[execute] fn set_string(string: String) -> StdResult { deps.storage.set(KEY_STRING, &to_vec(&string)?); Ok(Response::default()) } #[query] fn get_string() -> StdResult { let value = deps.storage.get(KEY_STRING).unwrap(); from_slice(&value) } }