-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
config.go
57 lines (48 loc) · 1.93 KB
/
config.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
52
53
54
55
56
57
package config
import (
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore"
dkgconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/dkg/config"
)
// PluginConfig contains custom arguments for the OCR2VRF plugin.
//
// The OCR2VRF plugin runs a DKG under the hood, so it will need both
// DKG and OCR2VRF configuration fields.
//
// The DKG contract address is provided in the plugin configuration,
// however the OCR2VRF contract address is provided in the OCR2 job spec
// under the 'contractID' key.
type PluginConfig struct {
// DKG configuration fields.
DKGEncryptionPublicKey string `json:"dkgEncryptionPublicKey"`
DKGSigningPublicKey string `json:"dkgSigningPublicKey"`
DKGKeyID string `json:"dkgKeyID"`
DKGContractAddress string `json:"dkgContractAddress"`
// VRF configuration fields
VRFCoordinatorAddress string `json:"vrfCoordinatorAddress"`
LinkEthFeedAddress string `json:"linkEthFeedAddress"`
}
// ValidatePluginConfig validates that the given OCR2VRF plugin configuration is correct.
func ValidatePluginConfig(config PluginConfig, dkgSignKs keystore.DKGSign, dkgEncryptKs keystore.DKGEncrypt) error {
err := dkgconfig.ValidatePluginConfig(dkgconfig.PluginConfig{
EncryptionPublicKey: config.DKGEncryptionPublicKey,
SigningPublicKey: config.DKGSigningPublicKey,
KeyID: config.DKGKeyID,
}, dkgSignKs, dkgEncryptKs)
if err != nil {
return err
}
// NOTE: a better validation would be to call a method on the on-chain contract pointed to by this
// address.
if config.DKGContractAddress == "" {
return errors.New("dkgContractAddress field must be provided")
}
if config.VRFCoordinatorAddress == "" {
return errors.New("vrfCoordinatorAddress field must be provided")
}
// NOTE: similar to the above.
if config.LinkEthFeedAddress == "" {
return errors.New("linkEthFieldAddress field must be provided")
}
return nil
}