From 5a6322569e4398ee00d9ea42d1a11661b76d857e Mon Sep 17 00:00:00 2001 From: Techno Freak Date: Sat, 9 Dec 2023 19:49:17 +0300 Subject: [PATCH] fix: set default denom-coefficient value --- go.mod | 2 +- go.sum | 4 ++-- pkg/config/config.go | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 72f736f..6d138de 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( github.com/BurntSushi/toml v1.1.0 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/cosmos/cosmos-sdk v0.46.0 + github.com/creasty/defaults v1.7.0 github.com/google/uuid v1.3.0 - github.com/mcuadros/go-defaults v1.2.0 github.com/prometheus/client_golang v1.12.2 github.com/rs/zerolog v1.27.0 github.com/spf13/cobra v1.5.0 diff --git a/go.sum b/go.sum index 06fd68c..fcbff59 100644 --- a/go.sum +++ b/go.sum @@ -262,6 +262,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA= +github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -750,8 +752,6 @@ github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc= -github.com/mcuadros/go-defaults v1.2.0 h1:FODb8WSf0uGaY8elWJAkoLL0Ri6AlZ1bFlenk56oZtc= -github.com/mcuadros/go-defaults v1.2.0/go.mod h1:WEZtHEVIGYVDqkKSWBdWKUVdRyKlMfulPaGDWIVeCWY= github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= github.com/mgechev/revive v1.2.1/go.mod h1:+Ro3wqY4vakcYNtkBWdZC7dBg1xSB6sp054wWwmeFm0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= diff --git a/pkg/config/config.go b/pkg/config/config.go index cd255a7..e5740f5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -6,7 +6,7 @@ import ( "os" "github.com/BurntSushi/toml" - "github.com/mcuadros/go-defaults" + "github.com/creasty/defaults" ) type Validator struct { @@ -24,7 +24,7 @@ func (v *Validator) Validate() error { type DenomInfo struct { Denom string `toml:"denom"` - DenomCoefficient int64 `default:"1000000"` + DenomCoefficient int64 `toml:"denom-coefficient "default:"1000000"` DisplayDenom string `toml:"display-denom"` CoingeckoCurrency string `toml:"coingecko-currency"` DexScreenerChainID string `toml:"dex-screener-chain-id"` @@ -144,6 +144,9 @@ func GetConfig(path string) (*Config, error) { return nil, err } - defaults.SetDefaults(&configStruct) + if err = defaults.Set(&configStruct); err != nil { + return nil, err + } + return &configStruct, nil }