fix(txJSON): L1 message type MarshalJSON (#849)

* update core/types/transaction_marshalling.go

* update internal/ethapi/api.go
This commit is contained in:
HAOYUatHZ 2024-06-24 15:18:43 +08:00 committed by GitHub
parent 02a6b64718
commit 9204dc4210
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -51,7 +51,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"`
}
@ -153,7 +153,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
enc.To = tx.To()
enc.Value = (*hexutil.Big)(itx.Value)
enc.Input = (*hexutil.Bytes)(&itx.Data)
enc.Sender = itx.Sender
enc.Sender = &itx.Sender
}
return json.Marshal(&enc)
}
@ -438,7 +438,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

View file

@ -1518,7 +1518,7 @@ type RPCTransaction struct {
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
// L1 message transaction fields:
Sender common.Address `json:"sender,omitempty"`
Sender *common.Address `json:"sender,omitempty"`
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
}
@ -1597,7 +1597,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