Skip to content

Commit b85fa34

Browse files
committed
feat: enhance correct-last-epoch command with detailed message preview
- Show JSON message in pretty-printed format before confirmation - Display encoded payload with size and hex representation - Show these details in both dry-run mode and before confirmation - Add example JSON file for CorrectLastEpoch message - Remove redundant calldata display (same as payload for DataEdge contract)
1 parent b044cab commit b85fa34

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"message": "CorrectLastEpoch",
4+
"chainId": "eip155:42161",
5+
"blockNumber": 248691234,
6+
"merkleRoot": "0xf7c8c1f6d8a9e2b5c4a7d0e3f6b9c1d8e5a2f7b4c8d1e6a9f2c5b8d3e6f9a1b4"
7+
}
8+
]

crates/oracle/src/commands/correct_epoch.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,25 @@ pub async fn correct_last_epoch(
298298
);
299299
println!(" Total networks in merkle tree: {}", all_blocks.len());
300300

301+
// Step 8: Create the CorrectLastEpoch message and show details
302+
println!();
303+
println!("📝 Message Details:");
304+
305+
let json_message = serde_json::json!([{
306+
"message": "CorrectLastEpoch",
307+
"chainId": chain_id,
308+
"blockNumber": corrected_block_number,
309+
"merkleRoot": format!("0x{}", hex::encode(computed_merkle_root))
310+
}]);
311+
312+
println!(" JSON message:");
313+
println!(" {}", serde_json::to_string_pretty(&json_message)?);
314+
315+
let payload = messages_to_payload(json_message.clone())?;
316+
println!();
317+
println!(" Encoded payload ({} bytes):", payload.len());
318+
println!(" 0x{}", hex::encode(&payload));
319+
301320
if dry_run {
302321
println!();
303322
println!("🏃 Dry run complete. No transaction submitted.");
@@ -317,18 +336,8 @@ pub async fn correct_last_epoch(
317336
}
318337
}
319338

320-
// Step 8: Create and submit the CorrectLastEpoch message
321-
println!("📤 Creating CorrectLastEpoch message...");
322-
let json_message = serde_json::json!([{
323-
"message": "CorrectLastEpoch",
324-
"chainId": chain_id,
325-
"blockNumber": corrected_block_number,
326-
"merkleRoot": format!("0x{}", hex::encode(computed_merkle_root))
327-
}]);
328-
329-
let payload = messages_to_payload(json_message)?;
330-
println!(" Message payload: {} bytes", payload.len());
331-
339+
// Step 9: Submit the transaction
340+
println!();
332341
println!("🚀 Submitting transaction...");
333342
let contracts = super::init_contracts(config.clone())?;
334343
let tx = contracts

0 commit comments

Comments
 (0)