sui_move_natives_latest/object_runtime/
accumulator.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use move_core_types::account_address::AccountAddress;
5use sui_types::{TypeTag, base_types::ObjectID, effects::AccumulatorOperation};
6
7#[derive(Debug)]
8pub enum MoveAccumulatorAction {
9    Merge,
10    Split,
11}
12
13impl MoveAccumulatorAction {
14    pub fn into_sui_accumulator_action(self) -> AccumulatorOperation {
15        match self {
16            MoveAccumulatorAction::Merge => AccumulatorOperation::Merge,
17            MoveAccumulatorAction::Split => AccumulatorOperation::Split,
18        }
19    }
20}
21
22#[derive(Debug)]
23pub enum MoveAccumulatorValue {
24    U64(u64),
25    // commit the nth event emitted by the transaction to an event stream
26    EventRef(u64),
27}
28
29#[derive(Debug)]
30pub struct MoveAccumulatorEvent {
31    // Note: accumulator_id is derived by hashing target and ty, but we include
32    // both for simplicity.
33    pub accumulator_id: ObjectID,
34    pub action: MoveAccumulatorAction,
35    pub target_addr: AccountAddress,
36    pub target_ty: TypeTag,
37    pub value: MoveAccumulatorValue,
38}