-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.go
62 lines (50 loc) · 1.42 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
58
59
60
61
62
package ethereum
import (
"fmt"
"os"
"strings"
"github.com/strangelove-ventures/noble-cctp-relayer/types"
)
var _ types.ChainConfig = (*ChainConfig)(nil)
type ChainConfig struct {
RPC string `yaml:"rpc"`
WS string `yaml:"ws"`
Domain types.Domain
ChainID int64 `yaml:"chain-id"`
MessageTransmitter string `yaml:"message-transmitter"`
StartBlock uint64 `yaml:"start-block"`
LookbackPeriod uint64 `yaml:"lookback-period"`
BroadcastRetries int `yaml:"broadcast-retries"`
BroadcastRetryInterval int `yaml:"broadcast-retry-interval"`
MinMintAmount uint64 `yaml:"min-mint-amount"`
MetricsDenom string `yaml:"metrics-denom"`
MetricsExponent int `yaml:"metrics-exponent"`
MinterPrivateKey string `yaml:"minter-private-key"`
}
func (c *ChainConfig) Chain(name string) (types.Chain, error) {
envKey := strings.ToUpper(name) + "_PRIV_KEY"
privKey := os.Getenv(envKey)
if len(c.MinterPrivateKey) == 0 || len(privKey) != 0 {
if len(privKey) == 0 {
return nil, fmt.Errorf("env variable %s is empty, priv key not found for chain %s", envKey, name)
} else {
c.MinterPrivateKey = privKey
}
}
return NewChain(
name,
c.Domain,
c.ChainID,
c.RPC,
c.WS,
c.MessageTransmitter,
c.StartBlock,
c.LookbackPeriod,
c.MinterPrivateKey,
c.BroadcastRetries,
c.BroadcastRetryInterval,
c.MinMintAmount,
c.MetricsDenom,
c.MetricsExponent,
)
}