Function hdk::entry::update

source ·
pub fn update(input: UpdateInput) -> ExternResult<ActionHash>
Expand description

General function that can update any entry type.

This is used under the hood by update_entry, update_cap_grant and update_cap_claim.

@todo implement update_cap_claim

The host builds an Update action for the passed entry value and commits a new update to the chain.

Usually you don’t need to use this function directly; it is the most general way to update an entry and standardizes the internals of higher level update functions.

Examples found in repository?
src/capability.rs (lines 195-199)
191
192
193
194
195
196
197
198
199
200
pub fn update_cap_grant(
    old_grant_action_hash: ActionHash,
    new_grant_value: CapGrantEntry,
) -> ExternResult<ActionHash> {
    update(UpdateInput {
        original_action_address: old_grant_action_hash,
        entry: Entry::CapGrant(new_grant_value),
        chain_top_ordering: ChainTopOrdering::default(),
    })
}
More examples
Hide additional examples
src/entry.rs (line 170)
160
161
162
163
164
165
166
167
168
169
170
171
pub fn update_entry<I, E>(hash: ActionHash, input: I) -> ExternResult<ActionHash>
where
    Entry: TryFrom<I, Error = E>,
    WasmError: From<E>,
{
    let input = UpdateInput {
        original_action_address: hash,
        entry: input.try_into()?,
        chain_top_ordering: ChainTopOrdering::default(),
    };
    update(input)
}