How can we view full non-truncated logs?

I’m getting this error

---- functions::pyth_info::price_feed_unsafe::success::gets_price_feed_from_batch_update stdout ----
thread 'functions::pyth_info::price_feed_unsafe::success::gets_price_feed_from_batch_update' panicked at tests/utils/interface/pyth_core.rs:132:10:
called `Result::unwrap()` on an `Err` value: RevertTransactionError { reason: "SignatureInvalid", revert_id: 18446744073709486080, receipts: [Call { id: 0000000000000000000000000000000000000000000000000000000000000000, to: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, amount: 2, asset_id: 0000000000000000000000000000000000000000000000000000000000000000, gas: 6363, param1: 2305799257, param2: 10448, pc: 15144, is: 15144 }, Log { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 1, rb: 303, rc: 0, rd: 0, pc: 90600, is: 15144 }, Log { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 3, rb: 305, rc: 0, rd: 0, pc: 91692, is: 15144 }, Log { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 0, rb: 312, rc: 0, rd: 0, pc: 116688, is: 15144 }, LogData { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 0, rb: 316, ptr: 359528, len: 32, digest: 82addcfbea836febfb87422b9f05f53fbb278ba14d2c774cf322784e398876c2, pc: 120448, is: 15144, data: Some(00000000000000000000000058...) }, LogData { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 0, rb: 317, ptr: 359560, len: 32, digest: b8d323a0422397c1a296c77fe1db34edcf2f4c5beccac7e700b0391684670864, pc: 120476, is: 15144, data: Some(00000000000000000000000000...) }, LogData { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 0, rb: 318, ptr: 359592, len: 8, digest: e85f440b865d705e30c4e50635ffb8880ca03b3c54f294deb577b800bbd96de9, pc: 120680, is: 15144, data: Some(0000000000000015) }, Revert { id: ef92edb21c9f5627d23b7d36445e5a3fc25711706f7fd635ae81bcc56b1b2d55, ra: 18446744073709486080, pc: 120688, is: 15144 }, ScriptResult { result: Revert, gas_used: 8049 }] }

and as you can see, some data are being truncated in the logs, how can I view the full logs without truncation?

2 Likes
contract;

abi MyContract {
    fn test_function();
}

struct MyStruct {
    val: u64,
}

impl MyContract for Contract {
    fn test_function() {
        log(MyStruct { val: 101 });
        log(102);
        require(false, "I fail");
    }
}
    let result = contract_instance.methods().test_function().call().await;
    if let Err(Error::Transaction(Reason::Reverted { receipts, .. })) = result {
        let decoded = contract_instance.log_decoder().decode_logs(&receipts);

        let stringified: Vec<&str> = decoded.filter_succeeded();
        for log in stringified {
            eprintln!("{log}");
        }

        let only_this_type: Vec<MyStruct> = contract_instance
            .log_decoder()
            .decode_logs_with_type::<MyStruct>(&receipts)
            .unwrap();

        // Decode into a type
        for log in only_this_type {
            eprintln!("{log:?}");
        }
    }

Prints:

MyStruct { val: 101 }
102
AsciiString { data: "I fail" }
MyStruct { val: 101 }
1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.