From e4d89d9fdf0cac1a227b5bc8ddd8a8480b87c532 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Wed, 13 Nov 2024 22:47:33 -0300 Subject: [PATCH] fix cosmos version --- Makefile | 1 - cmd/faucet/config.go | 7 ++++--- cmd/faucet/main.go | 24 +++++++++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 602c85b..be655d8 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,6 @@ test: govet govulncheck test-unit .PHONY: test test-unit test-race test-cover bench - ############################################################################### ### Build ### ############################################################################### diff --git a/cmd/faucet/config.go b/cmd/faucet/config.go index 452001b..b5f1646 100644 --- a/cmd/faucet/config.go +++ b/cmd/faucet/config.go @@ -4,6 +4,7 @@ import ( "flag" "github.com/ignite/cli/v28/ignite/pkg/cosmosfaucet" + "github.com/ignite/cli/v28/ignite/pkg/cosmosver" "github.com/tendermint/faucet/internal/environ" ) @@ -39,8 +40,8 @@ func init() { "keyring backend to be used", ) flag.StringVar(&sdkVersion, "sdk-version", - environ.GetString("SDK_VERSION", "latest"), - "version of sdk (launchpad, stargate-40, stargate-44 or latest)", + environ.GetString("SDK_VERSION", cosmosver.Latest.String()), + "version of sdk", ) flag.StringVar(&keyName, "account-name", environ.GetString("ACCOUNT_NAME", cosmosfaucet.DefaultAccountName), @@ -60,7 +61,7 @@ func init() { ) flag.StringVar(&defaultDenoms, "denoms", environ.GetString("DENOMS", cosmosfaucet.DefaultDenom), - "denomination of the coins sent by default (comma separated)", + "denomination comma separated of the coins sent by default (the first one will be used for the fee denom)", ) flag.Uint64Var(&creditAmount, "credit-amount", diff --git a/cmd/faucet/main.go b/cmd/faucet/main.go index 80830b9..a7331c7 100644 --- a/cmd/faucet/main.go +++ b/cmd/faucet/main.go @@ -24,11 +24,17 @@ func main() { log.Fatal(err) } + version, err := cosmosver.Parse(sdkVersion) + if err != nil { + log.Fatal(err) + } + ccoptions := []chaincmd.Option{ chaincmd.WithKeyringPassword(keyringPassword), chaincmd.WithKeyringBackend(configKeyringBackend), chaincmd.WithAutoChainIDDetection(), chaincmd.WithNodeAddress(nodeAddress), + chaincmd.WithVersion(version), } if home != "" { @@ -36,7 +42,7 @@ func main() { } ccoptions = append(ccoptions, - chaincmd.WithVersion(cosmosver.Latest), + chaincmd.WithVersion(version), ) cr, err := chaincmdrunner.New(context.Background(), chaincmd.New(appCli, ccoptions...)) @@ -45,18 +51,22 @@ func main() { } coins := strings.Split(defaultDenoms, denomSeparator) + if len(coins) == 0 { + log.Fatal("empty denoms") + } - faucetOptions := make([]cosmosfaucet.Option, len(coins)) - for i, coin := range coins { + faucetOptions := []cosmosfaucet.Option{ + cosmosfaucet.Version(version), + cosmosfaucet.Account(keyName, keyMnemonic, coinType), + cosmosfaucet.FeeAmount(sdkmath.NewInt(int64(feeAmount)), coins[0]), + } + for _, coin := range coins { creditAmount := sdkmath.NewInt(int64(creditAmount)) maxCredit := sdkmath.NewInt(int64(maxCredit)) - - faucetOptions[i] = cosmosfaucet.Coin(creditAmount, maxCredit, coin) + faucetOptions = append(faucetOptions, cosmosfaucet.Coin(creditAmount, maxCredit, coin)) } - faucetOptions = append(faucetOptions, cosmosfaucet.Account(keyName, keyMnemonic, coinType)) // it is fair to consider the first coin added because it is considered as the default coin during transfer requests. - faucetOptions = append(faucetOptions, cosmosfaucet.FeeAmount(sdkmath.NewInt(int64(feeAmount)), coins[0])) faucet, err := cosmosfaucet.New(context.Background(), cr, faucetOptions...) if err != nil {