Commit 8ee24756 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4730 from ethereum-optimism/feat/better-encode-wd

op-chain-ops: `Withdrawal` type use `hexutil.Bytes`
parents b002d657 614b1723
......@@ -76,7 +76,7 @@ func MigrateWithdrawal(withdrawal *LegacyWithdrawal, l1CrossDomainMessenger *com
withdrawal.Target,
value,
new(big.Int),
withdrawal.Data,
[]byte(withdrawal.Data),
)
if err != nil {
return nil, fmt.Errorf("cannot abi encode relayMessage: %w", err)
......
......@@ -2,11 +2,13 @@ package crossdomain
import (
"errors"
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
......@@ -28,7 +30,7 @@ type Withdrawal struct {
Target *common.Address `json:"target"`
Value *big.Int `json:"value"`
GasLimit *big.Int `json:"gasLimit"`
Data []byte `json:"data"`
Data hexutil.Bytes `json:"data"`
}
// NewWithdrawal will create a Withdrawal
......@@ -44,7 +46,7 @@ func NewWithdrawal(
Target: target,
Value: value,
GasLimit: gasLimit,
Data: data,
Data: hexutil.Bytes(data),
}
}
......@@ -58,9 +60,9 @@ func (w *Withdrawal) Encode() ([]byte, error) {
{Name: "gasLimit", Type: Uint256Type},
{Name: "data", Type: BytesType},
}
enc, err := args.Pack(w.Nonce, w.Sender, w.Target, w.Value, w.GasLimit, w.Data)
enc, err := args.Pack(w.Nonce, w.Sender, w.Target, w.Value, w.GasLimit, []byte(w.Data))
if err != nil {
return nil, err
return nil, fmt.Errorf("cannot encode withdrawal: %w", err)
}
return enc, nil
}
......@@ -110,7 +112,7 @@ func (w *Withdrawal) Decode(data []byte) error {
w.Target = &target
w.Value = value
w.GasLimit = gasLimit
w.Data = msgData
w.Data = hexutil.Bytes(msgData)
return nil
}
......@@ -150,6 +152,6 @@ func (w *Withdrawal) WithdrawalTransaction() bindings.TypesWithdrawalTransaction
Target: *w.Target,
Value: w.Value,
GasLimit: w.GasLimit,
Data: w.Data,
Data: []byte(w.Data),
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment