-
Notifications
You must be signed in to change notification settings - Fork 0
/
evm.go
51 lines (46 loc) · 1.37 KB
/
evm.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package evmutil
import (
"encoding/binary"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/GoPlugin/libocr/gethwrappers2/ocr2aggregator"
"github.com/GoPlugin/libocr/offchainreporting2plus/types"
)
func SplitSignature(sig []byte) (r, s [32]byte, v byte, err error) {
if len(sig) != 65 {
return r, s, v, fmt.Errorf("SplitSignature: wrong size")
}
r = common.BytesToHash(sig[:32])
s = common.BytesToHash(sig[32:64])
v = sig[64]
return r, s, v, nil
}
func RawReportContext(repctx types.ReportContext) [3][32]byte {
rawRepctx := [3][32]byte{}
copy(rawRepctx[0][:], repctx.ConfigDigest[:])
binary.BigEndian.PutUint32(rawRepctx[1][32-5:32-1], repctx.Epoch)
rawRepctx[1][31] = repctx.Round
rawRepctx[2] = repctx.ExtraHash
return rawRepctx
}
func ContractConfigFromConfigSetEvent(changed ocr2aggregator.OCR2AggregatorConfigSet) types.ContractConfig {
transmitAccounts := []types.Account{}
for _, addr := range changed.Transmitters {
transmitAccounts = append(transmitAccounts, types.Account(addr.Hex()))
}
signers := []types.OnchainPublicKey{}
for _, addr := range changed.Signers {
addr := addr
signers = append(signers, types.OnchainPublicKey(addr[:]))
}
return types.ContractConfig{
changed.ConfigDigest,
changed.ConfigCount,
signers,
transmitAccounts,
changed.F,
changed.OnchainConfig,
changed.OffchainConfigVersion,
changed.OffchainConfig,
}
}