Skip to content

Commit 6a22c2b

Browse files
fix: fetch gas-prices from the chain config if provided (#1508)
1 parent 4e4e953 commit 6a22c2b

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

cregistry/chain_info.go

+18-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"math/rand"
1010
"net/http"
1111
"net/url"
12+
"strconv"
1213
"time"
1314

1415
"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
@@ -87,6 +88,12 @@ type ChainInfo struct {
8788
MaxGasAmount uint64 `json:"max_gas_amount"`
8889
ExtraCodecs []string `json:"extra_codecs"`
8990
ExtensionOptions []provider.ExtensionOption `json:"extension_options"`
91+
Fees struct {
92+
FeeTokens []struct {
93+
Denom string `json:"denom"`
94+
LowGasPrice float64 `json:"low_gas_price"`
95+
} `json:"fee_tokens"`
96+
} `json:"fees"`
9097
}
9198

9299
// NewChainInfo returns a ChainInfo that is uninitialized other than the provided zap.Logger.
@@ -292,14 +299,18 @@ func (c ChainInfo) GetChainConfig(ctx context.Context, forceAdd, testnet bool, n
292299
debug := viper.GetBool("debug")
293300
home := viper.GetString("home")
294301

295-
assetList, err := c.GetAssetList(ctx, testnet, name)
296-
if err != nil {
297-
return nil, err
298-
}
299-
300302
var gasPrices string
301-
if len(assetList.Assets) > 0 {
302-
gasPrices = fmt.Sprintf("%.2f%s", 0.01, assetList.Assets[0].Base)
303+
if len(c.Fees.FeeTokens) > 0 {
304+
gasPrices = strconv.FormatFloat(c.Fees.FeeTokens[0].LowGasPrice, 'f', -1, 64) + c.Fees.FeeTokens[0].Denom
305+
} else {
306+
assetList, err := c.GetAssetList(ctx, testnet, name)
307+
if err != nil {
308+
return nil, err
309+
}
310+
311+
if len(assetList.Assets) > 0 {
312+
gasPrices = fmt.Sprintf("%.2f%s", 0.01, assetList.Assets[0].Base)
313+
}
303314
}
304315

305316
rpc, err := c.GetRandomRPCEndpoint(ctx, forceAdd)

0 commit comments

Comments
 (0)