Skip to content

Commit

Permalink
fix(contract): don't use -G flag for both gas and gas price
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Apr 7, 2024
1 parent d4e7bca commit 047cf8e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/arguments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Argument, Option } from 'commander';
import BigNumber from 'bignumber.js';
import { MIN_GAS_PRICE } from '@aeternity/aepp-sdk';
import { NODE_URL, COMPILER_URL } from './utils/constant.js';

export const coinAmountParser = (amount) => {
Expand All @@ -26,6 +27,10 @@ export const jsonOption = new Option('--json', 'Print result in json format');
export const gasOption = new Option('-G --gas [gas]', 'Amount of gas to call/deploy the contract')
.argParser((gas) => +gas);

export const gasPriceOption = new Option('--gasPrice [gasPrice]', 'Gas price to call/deploy the contract')
.default(MIN_GAS_PRICE, 'Minimum gas price') // TODO: use gas price from the node after updating sdk to 13.3.0
.argParser(coinAmountParser);

export const forceOption = new Option('-f --force', 'Ignore node version compatibility check');

export const passwordOption = new Option('-P, --password [password]', 'Wallet Password');
Expand Down
4 changes: 2 additions & 2 deletions src/commands/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// This script initialize all `contract` command's
// We'll use `commander` for parsing options
import { Argument, Option, Command } from 'commander';
import { MIN_GAS_PRICE } from '@aeternity/aepp-sdk';
import CliError from '../utils/CliError.js';
import * as Contract from '../actions/contract.js';
import {
nodeOption,
compilerOption,
jsonOption,
gasOption,
gasPriceOption,
feeOption,
forceOption,
passwordOption,
Expand Down Expand Up @@ -137,7 +137,7 @@ addCommonOptions(program
.option('-W, --no-waitMined', 'Force waiting until transaction will be mined')
.addOption(passwordOption)
.addOption(gasOption)
.option('-G --gasPrice [gas]', 'Amount of gas to deploy the contract', MIN_GAS_PRICE)
.addOption(gasPriceOption)
.addOption(feeOption)
.addOption(ttlOption)
.option('-N, --nonce [nonce]', 'Override the nonce that the transaction is going to be sent with')
Expand Down
7 changes: 4 additions & 3 deletions src/commands/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
// Also we need `esm` package to handle `ES imports`
import { Command } from 'commander';
import {
NAME_TTL, CLIENT_TTL, MIN_GAS_PRICE, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL,
NAME_TTL, CLIENT_TTL, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL,
} from '@aeternity/aepp-sdk';
import * as Transaction from '../actions/transaction.js';
import {
nodeOption,
jsonOption,
gasOption,
gasPriceOption,
nonceArgument,
feeOption,
forceOption,
Expand Down Expand Up @@ -121,7 +122,7 @@ addCommonOptions(program
.addOption(ttlOption)
.addOption(feeOption)
.addOption(gasOption)
.option('-G --gasPrice [gas]', 'Amount of gas to deploy the contract', MIN_GAS_PRICE)
.addOption(gasPriceOption)
.option('--amount [amount]', 'Amount', 0)
.description('Build contract create transaction.')
.action(Transaction.contractDeploy));
Expand All @@ -137,7 +138,7 @@ addCommonOptions(program
.addOption(ttlOption)
.addOption(feeOption)
.addOption(gasOption)
.option('-G --gasPrice [gas]', 'Amount of gas to deploy the contract', MIN_GAS_PRICE)
.addOption(gasPriceOption)
.option('--amount [amount]', 'Amount', 0)
.description('Build contract create transaction.')
.action(Transaction.contractCall));
Expand Down

0 comments on commit 047cf8e

Please sign in to comment.