Skip to content

Commit

Permalink
fix cosmos version
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Nov 14, 2024
1 parent 42cf0bb commit e4d89d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ test: govet govulncheck test-unit

.PHONY: test test-unit test-race test-cover bench


###############################################################################
### Build ###
###############################################################################
Expand Down
7 changes: 4 additions & 3 deletions cmd/faucet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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),
Expand All @@ -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",
Expand Down
24 changes: 17 additions & 7 deletions cmd/faucet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ 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 != "" {
ccoptions = append(ccoptions, chaincmd.WithHome(home))
}

ccoptions = append(ccoptions,
chaincmd.WithVersion(cosmosver.Latest),
chaincmd.WithVersion(version),
)

cr, err := chaincmdrunner.New(context.Background(), chaincmd.New(appCli, ccoptions...))
Expand All @@ -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 {
Expand Down

0 comments on commit e4d89d9

Please sign in to comment.