-
Notifications
You must be signed in to change notification settings - Fork 931
/
ETH1logs.go
31 lines (26 loc) · 888 Bytes
/
ETH1logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 []byte, withdrawalCredentials []byte, amount []byte,
signature []byte, 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
}