pub fn update_attribute<H: Into<Addr>, S: Into<String>, B: Into<Binary>>(
address: H,
name: S,
original_value: B,
original_value_type: AttributeValueType,
update_value: B,
update_value_type: AttributeValueType,
) -> StdResult<CosmosMsg<ProvenanceMsg>>
Expand description
Create a message that will update an attribute (a typed key-value pair) on an account.
ยงExample
// Imports required
use cosmwasm_std::{Binary, Env, Addr, Response, StdResult};
use provwasm_std::{update_attribute, AttributeValueType, ProvenanceMsg};
// Update an attribute on an account.
// NOTE: The name below must resolve to the contract address.
fn try_update_attribute(
env: Env,
address: Addr,
text: String,
) -> StdResult<Response<ProvenanceMsg>> {
let attr_name = String::from("attribute.my-contract.sc.pb");
let original_attribute_value = String::from("hello");
let updated_attribute_value = String::from("goodbye");
let msg = update_attribute(
address,
&attr_name,
Binary::from(original_attribute_value.as_bytes()),
AttributeValueType::String,
Binary::from(original_attribute_value.as_bytes()),
AttributeValueType::String,
)?;
let mut res = Response::new().add_message(msg);
Ok(res)
}