Skip to content

Commit

Permalink
[ECO-2617] Fix the event_index field to use the event index and not…
Browse files Browse the repository at this point in the history
… the sequence number (#69)

* Fix using sequence number, replace with event_index the same way the default aptos indexer processors do

* Make event index appearance in struct unpack the same order as swap
  • Loading branch information
xbtmatt authored Dec 20, 2024
1 parent f09cb58 commit f0697ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl EventWithMarket {
event_type: &str,
data: &str,
txn_version: i64,
sequence_number: i64,
event_index: i64,
) -> Result<Option<Self>> {
match EmojicoinTypeTag::from_type_str(event_type) {
Some(EmojicoinTypeTag::PeriodicState) => {
Expand All @@ -457,7 +457,7 @@ impl EventWithMarket {
},
Some(EmojicoinTypeTag::Swap) => {
let mut json_data = serde_json::Value::from_str(data)?;
json_data["event_index"] = serde_json::Value::from(sequence_number.to_string());
json_data["event_index"] = serde_json::Value::from(event_index.to_string());
serde_json::from_value(json_data).map(|inner: SwapEvent| Some(Self::Swap(inner)))
},
Some(EmojicoinTypeTag::Chat) => {
Expand All @@ -468,7 +468,7 @@ impl EventWithMarket {
},
Some(EmojicoinTypeTag::Liquidity) => {
let mut json_data = serde_json::Value::from_str(data)?;
json_data["event_index"] = serde_json::Value::from(sequence_number.to_string());
json_data["event_index"] = serde_json::Value::from(event_index.to_string());
serde_json::from_value(json_data)
.map(|inner: LiquidityEvent| Some(Self::Liquidity(inner)))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl SwapEventModel {
} = state_event;

let SwapEvent {
event_index,
market_id,
market_nonce,
swapper,
Expand All @@ -105,6 +104,7 @@ impl SwapEventModel {
time,
balance_as_fraction_of_circulating_supply_before_q64,
balance_as_fraction_of_circulating_supply_after_q64,
event_index,
..
} = swap_event;

Expand Down
4 changes: 2 additions & 2 deletions rust/processor/src/processors/emojicoin_dot_fun/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ impl ProcessorTrait for EmojicoinProcessor {

// Group the market events in this transaction.
let mut market_events = vec![];
for event in user_txn.events.iter() {
for (event_index, event) in user_txn.events.iter().enumerate() {
let type_str = event.type_str.as_str();
let data = event.data.as_str();

match EventWithMarket::from_event_type(
type_str,
data,
txn_version,
event.sequence_number as i64,
event_index as i64,
)? {
Some(evt) => {
market_events.push(evt.clone());
Expand Down

0 comments on commit f0697ce

Please sign in to comment.