Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(txJSON): L1 message type MarshalJSON #630

Merged
merged 9 commits into from
Mar 5, 2024
15 changes: 13 additions & 2 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type txJSON struct {
Hash common.Hash `json:"hash"`

// L1 message transaction fields:
Sender common.Address `json:"sender,omitempty"`
Sender *common.Address `json:"sender,omitempty"`
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
}

Expand Down Expand Up @@ -130,6 +130,14 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
yparity := itx.V.Uint64()
enc.YParity = (*hexutil.Uint64)(&yparity)

case *L1MessageTx:
enc.QueueIndex = (*hexutil.Uint64)(&itx.QueueIndex)
enc.Gas = (*hexutil.Uint64)(&itx.Gas)
enc.To = tx.To()
enc.Value = (*hexutil.Big)(itx.Value)
enc.Input = (*hexutil.Bytes)(&itx.Data)
enc.Sender = &itx.Sender

case *BlobTx:
enc.ChainID = (*hexutil.Big)(itx.ChainID.ToBig())
enc.Nonce = (*hexutil.Uint64)(&itx.Nonce)
Expand Down Expand Up @@ -425,7 +433,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
return errors.New("missing required field 'input' in transaction")
}
itx.Data = *dec.Input
itx.Sender = dec.Sender
if dec.Sender == nil {
return errors.New("missing required field 'sender' in transaction")
}
itx.Sender = *dec.Sender
Thegaram marked this conversation as resolved.
Show resolved Hide resolved

default:
return ErrTxTypeNotSupported
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ type RPCTransaction struct {
S *hexutil.Big `json:"s"`

// L1 message transaction fields:
Sender common.Address `json:"sender,omitempty"`
Sender *common.Address `json:"sender,omitempty"`
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
}

Expand Down Expand Up @@ -1344,7 +1344,7 @@ func NewRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
}
case types.L1MessageTxType:
msg := tx.AsL1MessageTx()
result.Sender = msg.Sender
result.Sender = &msg.Sender
result.QueueIndex = (*hexutil.Uint64)(&msg.QueueIndex)
}
return result
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 19 // Patch version component of the current release
VersionPatch = 20 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

Expand Down
Loading