-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.go
48 lines (41 loc) · 1.41 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
package celo
import (
"fmt"
"github.com/celo-org/celo-blockchain/common"
"github.com/keep-network/keep-common/pkg/chain/ethlike"
)
// Config is a struct that contains the configuration needed to connect to an
// Celo node. This information will give access to a Celo network.
type Config struct {
ethlike.Config
// MaxGasPrice specifies the maximum gas price the client is
// willing to pay for the transaction to be mined. The offered transaction
// gas price can not be higher than the max gas price value. If the maximum
// allowed gas price is reached, no further resubmission attempts are
// performed.
MaxGasPrice *Wei
// BalanceAlertThreshold defines a minimum value of the operator's
// account balance below which an alert will be triggered.
BalanceAlertThreshold *Wei
}
// ContractAddress finds a given contract's address configuration and returns it
// as Celo address.
func (c *Config) ContractAddress(contractName string) (common.Address, error) {
addressString, exists := c.ContractAddresses[contractName]
if !exists {
return common.Address{}, fmt.Errorf(
"no address information for [%v] in configuration",
contractName,
)
}
if !common.IsHexAddress(addressString) {
return common.Address{}, fmt.Errorf(
"configured address [%v] for contract [%v] "+
"is not valid hex address",
addressString,
contractName,
)
}
address := common.HexToAddress(addressString)
return address, nil
}