Zilliqa / zq2

Zilliqa 2.0 code base
Apache License 2.0
9 stars 0 forks source link

Event logs values seem to be double encoded #1380

Open saeed-zil opened 3 weeks ago

saeed-zil commented 3 weeks ago

The problem is here:

   for event in output.events {
                let log = ScillaLog {
                    address: to_addr,
                    event_name: event.event_name,
                    params: event
                        .params
                        .into_iter()
                        .map(|p| {
                            Ok(ScillaParam {
                                ty: p.ty,
                                // If the value is a JSON string, don't double encode it.
                                value: if let Value::String(v) = p.value {
                                    v
                                } else {
                                    serde_json::to_string(&p.value)?
                                },
                                name: p.name,
                            })
                        })
                        .collect::<Result<_>>()?,
                };
                logs.push(log);
            }

We serialize the p.value to string which causes to need to have an extra JSON.parse on the client side to get the real object.

saeed-zil commented 3 weeks ago

I got this error when I tried to implmenet data types for p.value:

2024-08-30T07:55:23.730678Z ERROR zilliqa::api::zil: 38: e=Conversion error from type Blob at index: 7, Bincode does not support the serde::Deserializer::deserialize_any method

Caused by:
    Bincode does not support the serde::Deserializer::deserialize_any method
2024-08-30T07:55:25.427219Z ERROR zilliqa: 62: thread_name="tokio-runtime-worker" called `Result::unwrap()` on an `Err` value: Conversion error from type Blob at index: 7, Bincode does not support the serde::Deserializer::deserialize_any method