Skip to content

Commit

Permalink
fix(txJSON): L1 message type MarshalJSON (#630)
Browse files Browse the repository at this point in the history
* fix(txJSON): L1 message type MarshalJSON

* address comments

* bump version

* trigger ci

* bump version

* bump version
  • Loading branch information
colinlyguo committed Mar 5, 2024
1 parent 06a21f3 commit a807a41
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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

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

0 comments on commit a807a41

Please sign in to comment.