mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
fix(txJSON): L1 message type MarshalJSON (#849)
* update core/types/transaction_marshalling.go * update internal/ethapi/api.go
This commit is contained in:
parent
02a6b64718
commit
9204dc4210
2 changed files with 8 additions and 5 deletions
|
|
@ -51,7 +51,7 @@ type txJSON struct {
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
|
|
||||||
// L1 message transaction fields:
|
// L1 message transaction fields:
|
||||||
Sender common.Address `json:"sender,omitempty"`
|
Sender *common.Address `json:"sender,omitempty"`
|
||||||
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
|
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
|
||||||
enc.To = tx.To()
|
enc.To = tx.To()
|
||||||
enc.Value = (*hexutil.Big)(itx.Value)
|
enc.Value = (*hexutil.Big)(itx.Value)
|
||||||
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
||||||
enc.Sender = itx.Sender
|
enc.Sender = &itx.Sender
|
||||||
}
|
}
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
@ -438,7 +438,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
|
||||||
return errors.New("missing required field 'input' in transaction")
|
return errors.New("missing required field 'input' in transaction")
|
||||||
}
|
}
|
||||||
itx.Data = *dec.Input
|
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:
|
default:
|
||||||
return ErrTxTypeNotSupported
|
return ErrTxTypeNotSupported
|
||||||
|
|
|
||||||
|
|
@ -1518,7 +1518,7 @@ type RPCTransaction struct {
|
||||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||||
|
|
||||||
// L1 message transaction fields:
|
// L1 message transaction fields:
|
||||||
Sender common.Address `json:"sender,omitempty"`
|
Sender *common.Address `json:"sender,omitempty"`
|
||||||
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
|
QueueIndex *hexutil.Uint64 `json:"queueIndex,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1597,7 +1597,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
|
||||||
|
|
||||||
case types.L1MessageTxType:
|
case types.L1MessageTxType:
|
||||||
msg := tx.AsL1MessageTx()
|
msg := tx.AsL1MessageTx()
|
||||||
result.Sender = msg.Sender
|
result.Sender = &msg.Sender
|
||||||
result.QueueIndex = (*hexutil.Uint64)(&msg.QueueIndex)
|
result.QueueIndex = (*hexutil.Uint64)(&msg.QueueIndex)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue