prysm-pulse/contracts/deposit-contract/ETH1logs.go
Victor Farazdagi a019a0db4c
Combines func params of the same type (#7500)
* combines func params

* update leftovers

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2020-10-12 15:43:19 +00:00

31 lines
859 B
Go

package depositcontract
import (
"bytes"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/pkg/errors"
)
// UnpackDepositLogData unpacks the data from a deposit log using the ABI decoder.
func UnpackDepositLogData(data []byte) (pubkey, withdrawalCredentials, amount, signature, index []byte, err error) {
reader := bytes.NewReader([]byte(DepositContractABI))
contractAbi, err := abi.JSON(reader)
if err != nil {
return nil, nil, nil, nil, nil, errors.Wrap(err, "unable to generate contract abi")
}
unpackedLogs := []interface{}{
&pubkey,
&withdrawalCredentials,
&amount,
&signature,
&index,
}
if err := contractAbi.Unpack(&unpackedLogs, "DepositEvent", data); err != nil {
return nil, nil, nil, nil, nil, errors.Wrap(err, "unable to unpack logs")
}
return pubkey, withdrawalCredentials, amount, signature, index, nil
}