Skip to content

Commit

Permalink
feat(geth/trace): add field log.position (#1150)
Browse files Browse the repository at this point in the history
* chore(geth): add position in CallLogFrame

Signed-off-by: jsvisa <delweng@gmail.com>

* typo: json indent

Signed-off-by: jsvisa <delweng@gmail.com>

* test: add position in with_log

Signed-off-by: jsvisa <delweng@gmail.com>

* chore(call): position use u64 instead

Signed-off-by: jsvisa <delweng@gmail.com>

* use Option<u64>

Signed-off-by: jsvisa <delweng@gmail.com>

* fix: skip serialize if none

Signed-off-by: jsvisa <delweng@gmail.com>

---------

Signed-off-by: jsvisa <delweng@gmail.com>
  • Loading branch information
jsvisa authored Aug 17, 2024
1 parent f5eaddf commit 502d69b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion crates/rpc-types-trace/src/geth/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct CallFrame {
pub typ: String,
}

/// Represents a recorded call.
/// Represents a recorded log that is emitted during a trace call.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct CallLogFrame {
/// The address of the contract that was called.
Expand All @@ -56,6 +56,9 @@ pub struct CallLogFrame {
/// The data of the log.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub data: Option<Bytes>,
/// The position of the log relative to subcalls within the same trace.
#[serde(default, with = "alloy_serde::quantity::opt", skip_serializing_if = "Option::is_none")]
pub position: Option<u64>,
}

/// The configuration for the call tracer.
Expand Down
9 changes: 5 additions & 4 deletions crates/rpc-types-trace/test_data/call_tracer/with_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
{
"address": "0xf4eced2f682ce333f96f2d8966c613ded8fc95dd",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000d1220a0cf47c7b9be7a2e6ba89f429762e7b9adb",
"0x000000000000000000000000dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb"
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000d1220a0cf47c7b9be7a2e6ba89f429762e7b9adb",
"0x000000000000000000000000dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000989680"
"data": "0x0000000000000000000000000000000000000000000000000000000000989680",
"position": "0x0"
}
],
"value": "0x0",
Expand Down

0 comments on commit 502d69b

Please sign in to comment.