Skip to content

TransactionRequest loses contract creation when deserializing to: null #4076

Description

@1sgtpepper

Summary

TransactionRequest::to uses an outer Option<TxKind>. A creation request represented as Some(TxKind::Create) serializes to the JSON/RPC form to: null, but deserializing that JSON produces to == None.

This collapses the distinction between a known contract creation and an incomplete request without a destination.

Reproduction

let request = TransactionRequest::default().create();
let json = serde_json::to_value(&request).unwrap();
let decoded: TransactionRequest = serde_json::from_value(json).unwrap();

assert_eq!(decoded.to, Some(TxKind::Create));

The assertion currently fails because decoded.to is None.

Expected JSON/RPC behavior

  • omitted to deserializes as None;
  • present to: null deserializes as Some(TxKind::Create);
  • present address deserializes as Some(TxKind::Call(address)).

The binary bincode format must retain its existing decoding behavior.

Related

#4071 correctly preserves TxKind::Create when converting concrete consensus transactions into TransactionRequest and emits to: null. This issue tracks the pre-existing inbound JSON/RPC round-trip loss separately to keep that PR scoped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions