|
34 | 34 | txNonce uint64 |
35 | 35 | txGasLimit uint64 |
36 | 36 | txGasPrice string |
| 37 | + txFeeDenom string |
37 | 38 | txEncrypted bool |
38 | 39 | txYes bool |
39 | 40 | txUnsigned bool |
@@ -116,6 +117,11 @@ func SignConsensusTransaction( |
116 | 117 | } |
117 | 118 | tx.Fee.Gas = consensusTx.Gas(txGasLimit) |
118 | 119 |
|
| 120 | + // For sanity make sure no fee denomination has been specified. |
| 121 | + if txFeeDenom != "" { |
| 122 | + return nil, fmt.Errorf("consensus layer only supports the native denomination for paying fees") |
| 123 | + } |
| 124 | + |
119 | 125 | gasPrice := quantity.NewQuantity() |
120 | 126 | if txGasPrice != "" { |
121 | 127 | var err error |
@@ -215,11 +221,12 @@ func SignParaTimeTransaction( |
215 | 221 | tx.AuthInfo.Fee.Gas = txGasLimit |
216 | 222 | } |
217 | 223 |
|
| 224 | + feeDenom := types.Denomination(txFeeDenom) |
| 225 | + |
218 | 226 | gasPrice := &types.BaseUnits{} |
219 | 227 | if txGasPrice != "" { |
220 | | - // TODO: Support different denominations for gas fees. |
221 | 228 | var err error |
222 | | - gasPrice, err = helpers.ParseParaTimeDenomination(npa.ParaTime, txGasPrice, types.NativeDenomination) |
| 229 | + gasPrice, err = helpers.ParseParaTimeDenomination(npa.ParaTime, txGasPrice, feeDenom) |
223 | 230 | if err != nil { |
224 | 231 | return nil, nil, fmt.Errorf("bad gas price: %w", err) |
225 | 232 | } |
@@ -262,9 +269,7 @@ func SignParaTimeTransaction( |
262 | 269 | return nil, nil, fmt.Errorf("failed to query minimum gas price: %w", err) |
263 | 270 | } |
264 | 271 |
|
265 | | - // TODO: Support different denominations for gas fees. |
266 | | - denom := types.NativeDenomination |
267 | | - *gasPrice = types.NewBaseUnits(mgp[denom], denom) |
| 272 | + *gasPrice = types.NewBaseUnits(mgp[feeDenom], feeDenom) |
268 | 273 | } |
269 | 274 | } |
270 | 275 |
|
@@ -575,6 +580,7 @@ func init() { |
575 | 580 | RuntimeTxFlags.Uint64Var(&txNonce, "nonce", invalidNonce, "override nonce to use") |
576 | 581 | RuntimeTxFlags.Uint64Var(&txGasLimit, "gas-limit", invalidGasLimit, "override gas limit to use (disable estimation)") |
577 | 582 | RuntimeTxFlags.StringVar(&txGasPrice, "gas-price", "", "override gas price to use") |
| 583 | + RuntimeTxFlags.StringVar(&txFeeDenom, "fee-denom", "", "override fee denomination (defaults to native)") |
578 | 584 | RuntimeTxFlags.BoolVar(&txEncrypted, "encrypted", false, "encrypt transaction call data (requires online mode)") |
579 | 585 | RuntimeTxFlags.AddFlagSet(YesFlag) |
580 | 586 | RuntimeTxFlags.BoolVar(&txUnsigned, "unsigned", false, "do not sign transaction") |
|
0 commit comments