43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
type Config struct {
|
|
EthereumRPCURL string
|
|
GenexRPCURL string
|
|
AxelarGatewayAddress string
|
|
GenexBridgeTokenAddress string
|
|
ReconcileInterval time.Duration
|
|
DiscrepancyThreshold float64 // 0.0001 = 0.01%
|
|
AlertWebhookURL string
|
|
Port int
|
|
}
|
|
|
|
func Load() *Config {
|
|
port, _ := strconv.Atoi(getEnv("PORT", "3024"))
|
|
interval, _ := strconv.Atoi(getEnv("RECONCILE_INTERVAL_SECONDS", "300"))
|
|
threshold, _ := strconv.ParseFloat(getEnv("DISCREPANCY_THRESHOLD", "0.0001"), 64)
|
|
|
|
return &Config{
|
|
EthereumRPCURL: getEnv("ETHEREUM_RPC_URL", "https://mainnet.infura.io/v3/YOUR_KEY"),
|
|
GenexRPCURL: getEnv("GENEX_RPC_URL", "http://localhost:8545"),
|
|
AxelarGatewayAddress: getEnv("AXELAR_GATEWAY_ADDRESS", "0x0000000000000000000000000000000000000000"),
|
|
GenexBridgeTokenAddress: getEnv("GENEX_BRIDGE_TOKEN_ADDRESS", "0x0000000000000000000000000000000000000000"),
|
|
ReconcileInterval: time.Duration(interval) * time.Second,
|
|
DiscrepancyThreshold: threshold,
|
|
AlertWebhookURL: getEnv("ALERT_WEBHOOK_URL", ""),
|
|
Port: port,
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|