sui_types/
ptb_trace.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use move_trace_format::{format::TypeTagWithRefs, value::SerializableMoveValue};
5
6use serde::Serialize;
7
8/// PTB-related vents to be stored in the trace. The first one is a summary
9/// of the whole PTB, and the following ones represent individual PTB commands.
10#[derive(Clone, Debug, Serialize)]
11pub enum PTBEvent {
12    Summary(SummaryEvent),
13    ExternalEvent(ExternalEvent),
14    MoveCallStart, // just a marker, all required info is in OpenFrame event
15    MoveCallEnd,   // just a marker to make identifying the end of a MoveCall easier
16}
17
18#[derive(Clone, Debug, Serialize)]
19pub struct SummaryEvent {
20    pub name: String,
21    pub events: Vec<PTBCommandInfo>,
22}
23
24/// Information about the external event that is stored in the trace.
25#[derive(Clone, Debug, Serialize)]
26pub struct ExternalEvent {
27    /// A longer description of the event
28    pub description: String,
29    /// A shorter name of the event.
30    pub name: String,
31    /// Values associated with the event.
32    pub values: Vec<ExtMoveValue>,
33}
34
35/// Information about the PTB commands to be stored in the PTB start event.
36/// It contains only the information needed to provide a summary of the command.
37#[derive(Clone, Debug, Serialize)]
38pub enum PTBCommandInfo {
39    MoveCall {
40        pkg: String,
41        module: String,
42        function: String,
43    },
44    ExternalEvent(String),
45}
46
47/// Information about Move value stored in external trace events.
48#[derive(Clone, Debug, Serialize)]
49pub struct ExtMoveValueInfo {
50    pub type_: TypeTagWithRefs,
51    pub value: SerializableMoveValue,
52}
53
54/// Represents a Move value stored in external trace events.
55#[derive(Clone, Debug, Serialize)]
56pub enum ExtMoveValue {
57    Single {
58        name: String,
59        info: ExtMoveValueInfo,
60    },
61    Vector {
62        name: String,
63        type_: TypeTagWithRefs,
64        value: Vec<SerializableMoveValue>,
65    },
66}