From 9a1d1af14536d15f507343e00ada5b40a8b23a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Fri, 27 Jun 2025 10:10:36 +0200 Subject: [PATCH] cmd/account/deposit: Set gas price to 0 by default --- cmd/account/deposit.go | 5 +++++ cmd/common/transaction.go | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/account/deposit.go b/cmd/account/deposit.go index 6f6bdd0e..2b6260ef 100644 --- a/cmd/account/deposit.go +++ b/cmd/account/deposit.go @@ -63,6 +63,11 @@ var depositCmd = &cobra.Command{ amountBaseUnits, err := helpers.ParseParaTimeDenomination(npa.ParaTime, amount, npa.ConsensusDenomination()) cobra.CheckErr(err) + // ParaTime deposit tx doesn't need gas. Don't detect the gas price, but set it to 0, if none provided. + if common.TxGasPrice == "" { + common.TxGasPrice = "0" + } + // Prepare transaction. tx := consensusaccounts.NewDepositTx(nil, &consensusaccounts.Deposit{ To: toAddr, diff --git a/cmd/common/transaction.go b/cmd/common/transaction.go index 848523e9..0c4f6ad3 100644 --- a/cmd/common/transaction.go +++ b/cmd/common/transaction.go @@ -35,7 +35,7 @@ var ( txOffline bool txNonce uint64 txGasLimit uint64 - txGasPrice string + TxGasPrice string txFeeDenom string txEncrypted bool txUnsigned bool @@ -109,8 +109,8 @@ func PrepareConsensusTransaction(ctx context.Context, npa *NPASelection, signer // Gas price estimation if not specified. gasPrice := quantity.NewQuantity() var err error - if txGasPrice != "" { - gasPrice, err = helpers.ParseConsensusDenomination(npa.Network, txGasPrice) + if TxGasPrice != "" { + gasPrice, err = helpers.ParseConsensusDenomination(npa.Network, TxGasPrice) if err != nil { return 0, nil, fmt.Errorf("bad gas price: %w", err) } @@ -242,8 +242,8 @@ func PrepareParatimeTransaction(ctx context.Context, npa *NPASelection, account // Gas price estimation if not specified. gasPrice := &types.BaseUnits{} feeDenom := types.Denomination(txFeeDenom) - if txGasPrice != "" { - gasPrice, err = helpers.ParseParaTimeDenomination(npa.ParaTime, txGasPrice, feeDenom) + if TxGasPrice != "" { + gasPrice, err = helpers.ParseParaTimeDenomination(npa.ParaTime, TxGasPrice, feeDenom) if err != nil { return 0, nil, "", fmt.Errorf("bad gas price: %w", err) } @@ -601,7 +601,7 @@ func init() { RuntimeTxFlags.BoolVar(&txOffline, "offline", false, "do not perform any operations requiring network access") RuntimeTxFlags.Uint64Var(&txNonce, "nonce", invalidNonce, "override nonce to use") RuntimeTxFlags.Uint64Var(&txGasLimit, "gas-limit", invalidGasLimit, "override gas limit to use (disable estimation)") - RuntimeTxFlags.StringVar(&txGasPrice, "gas-price", "", "override gas price to use") + RuntimeTxFlags.StringVar(&TxGasPrice, "gas-price", "", "override gas price to use") RuntimeTxFlags.StringVar(&txFeeDenom, "fee-denom", "", "override fee denomination (defaults to native)") RuntimeTxFlags.BoolVar(&txEncrypted, "encrypted", false, "encrypt transaction call data (requires online mode)") RuntimeTxFlags.AddFlagSet(AnswerYesFlag) @@ -613,7 +613,7 @@ func init() { TxFlags.BoolVar(&txOffline, "offline", false, "do not perform any operations requiring network access") TxFlags.Uint64Var(&txNonce, "nonce", invalidNonce, "override nonce to use") TxFlags.Uint64Var(&txGasLimit, "gas-limit", invalidGasLimit, "override gas limit to use (disable estimation)") - TxFlags.StringVar(&txGasPrice, "gas-price", "", "override gas price to use") + TxFlags.StringVar(&TxGasPrice, "gas-price", "", "override gas price to use") TxFlags.AddFlagSet(AnswerYesFlag) TxFlags.BoolVar(&txUnsigned, "unsigned", false, "do not sign transaction") TxFlags.StringVar(&txFormat, "format", "json", "transaction output format (for offline/unsigned modes) [json, cbor]")