Commit c0b4d704 authored by Mark Tyneway's avatar Mark Tyneway

op-chain-ops: withdrawal tx helper

Adds a method to the `Withdrawal` that turns it into
a `bindings.TypesWithdrawalTransaction` that is suitable
for sending via an `ethclient` when sending a transaction.
This will help to deduplicate code.
parent 764a9271
......@@ -4,6 +4,7 @@ import (
"errors"
"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/crypto"
......@@ -139,3 +140,16 @@ func (w *Withdrawal) StorageSlot() (common.Hash, error) {
slot := crypto.Keccak256(preimage)
return common.BytesToHash(slot), nil
}
// WithdrawalTransaction will convert the Withdrawal to a type
// suitable for sending a transaction.
func (w *Withdrawal) WithdrawalTransaction() bindings.TypesWithdrawalTransaction {
return bindings.TypesWithdrawalTransaction{
Nonce: w.Nonce,
Sender: *w.Sender,
Target: *w.Target,
Value: w.Value,
GasLimit: w.GasLimit,
Data: 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