sui_analytics_indexer/handlers/tables/
move_call.rs1use std::sync::Arc;
5
6use anyhow::Result;
7use async_trait::async_trait;
8use sui_indexer_alt_framework::pipeline::Processor;
9use sui_types::base_types::EpochId;
10use sui_types::effects::TransactionEffectsAPI;
11use sui_types::full_checkpoint_content::Checkpoint;
12use sui_types::transaction::TransactionDataAPI;
13
14use crate::Row;
15use crate::pipeline::Pipeline;
16use crate::tables::MoveCallRow;
17
18pub struct MoveCallProcessor;
19
20impl Row for MoveCallRow {
21 fn get_epoch(&self) -> EpochId {
22 self.epoch
23 }
24
25 fn get_checkpoint(&self) -> u64 {
26 self.checkpoint
27 }
28}
29
30#[async_trait]
31impl Processor for MoveCallProcessor {
32 const NAME: &'static str = Pipeline::MoveCall.name();
33 type Value = MoveCallRow;
34
35 async fn process(&self, checkpoint: &Arc<Checkpoint>) -> Result<Vec<Self::Value>> {
36 let epoch = checkpoint.summary.data().epoch;
37 let checkpoint_seq = checkpoint.summary.data().sequence_number;
38 let timestamp_ms = checkpoint.summary.data().timestamp_ms;
39
40 let mut entries = Vec::new();
41
42 for executed_tx in &checkpoint.transactions {
43 let move_calls = executed_tx.transaction.move_calls();
44 let transaction_digest = executed_tx.effects.transaction_digest().base58_encode();
45
46 for (cmd_idx, package, module, function) in move_calls.iter() {
47 let row = MoveCallRow {
48 transaction_digest: transaction_digest.clone(),
49 cmd_idx: *cmd_idx as u64,
50 checkpoint: checkpoint_seq,
51 epoch,
52 timestamp_ms,
53 package: package.to_string(),
54 module: module.to_string(),
55 function: function.to_string(),
56 };
57 entries.push(row);
58 }
59 }
60
61 Ok(entries)
62 }
63}