diff --git a/core/types/transaction.go b/core/types/transaction.go index 35989160eb..3c94261061 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -340,8 +340,11 @@ func (tx *Transaction) To() *common.Address { // e.g. a user deposit event, or a L1 info deposit included in a specific L2 block height. // Non-deposit transactions return a zeroed hash. func (tx *Transaction) SourceHash() common.Hash { - if dep, ok := tx.inner.(*DepositTx); ok { - return dep.SourceHash + switch tx.inner.(type) { + case *DepositTx: + return tx.inner.(*DepositTx).SourceHash + case *depositTxWithNonce: + return tx.inner.(*depositTxWithNonce).SourceHash } return common.Hash{} } @@ -349,8 +352,11 @@ func (tx *Transaction) SourceHash() common.Hash { // Mint returns the ETH to mint in the deposit tx. // This returns nil if there is nothing to mint, or if this is not a deposit tx. func (tx *Transaction) Mint() *big.Int { - if dep, ok := tx.inner.(*DepositTx); ok { - return dep.Mint + switch tx.inner.(type) { + case *DepositTx: + return tx.inner.(*DepositTx).Mint + case *depositTxWithNonce: + return tx.inner.(*depositTxWithNonce).Mint } return nil } diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 253e4f03de..a07d65414c 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -174,6 +174,20 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) { } enc.IsSystemTx = &itx.IsSystemTransaction // other fields will show up as null. + + case *depositTxWithNonce: + enc.Gas = (*hexutil.Uint64)(&itx.Gas) + enc.Value = (*hexutil.Big)(itx.Value) + enc.Input = (*hexutil.Bytes)(&itx.Data) + enc.To = tx.To() + enc.SourceHash = &itx.SourceHash + enc.From = &itx.From + if itx.Mint != nil { + enc.Mint = (*hexutil.Big)(itx.Mint) + } + enc.IsSystemTx = &itx.IsSystemTransaction + enc.Nonce = (*hexutil.Uint64)(&itx.EffectiveNonce) + // other fields will show up as null. } return json.Marshal(&enc) }