Skip to content

Commit

Permalink
feat: get urls from AECLI_NODE_URL, AECLI_COMPILER_URL env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Sep 5, 2022
1 parent 2f8bf0f commit 78a9953
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/arguments.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Argument, Option } from 'commander';
import BigNumber from 'bignumber.js';
import { NODE_URL } from './utils/constant';
import { NODE_URL, COMPILER_URL } from './utils/constant';

export const coinAmountParser = (amount) => (
new BigNumber(amount.replace(/ae$/, '')).shiftedBy(amount.endsWith('ae') ? 18 : 0)
Expand All @@ -12,8 +12,13 @@ export const feeOption = new Option('-F, --fee [fee]', 'Override the transaction
export const nonceArgument = new Argument('<nonce>', 'Unique number that is required to sign transaction securely')
.argParser((nonce) => +nonce);

export const nodeOption = new Option('-u, --url [hostname]', 'Node to connect to')
.default(NODE_URL, 'Aeternity testnet');
export const nodeOption = new Option('-u, --url [nodeUrl]', 'Node to connect to')
.default(NODE_URL, 'Aeternity testnet')
.env('AECLI_NODE_URL');

export const compilerOption = new Option('--compilerUrl [compilerUrl]', 'Compiler to connect to')
.default(COMPILER_URL, 'Stable compiler')
.env('AECLI_COMPILER_URL');

export const jsonOption = new Option('--json', 'Print result in json format');

Expand Down
5 changes: 2 additions & 3 deletions src/commands/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
// We'll use `commander` for parsing options
import { Argument, Option, Command } from 'commander';
import { TX_TTL, MIN_GAS_PRICE } from '@aeternity/aepp-sdk';
import { COMPILER_URL } from '../utils/constant';
import { withGlobalOpts } from '../utils/cli';
import CliError from '../utils/CliError';
import * as Contract from '../actions/contract';
import {
nodeOption, jsonOption, gasOption, feeOption,
nodeOption, compilerOption, jsonOption, gasOption, feeOption,
} from '../arguments';

const callArgs = new Argument('[args]', 'JSON-encoded arguments array of contract call')
Expand All @@ -50,7 +49,7 @@ const program = new Command().name('aecli contract');
// ## Initialize `options`
program
.addOption(nodeOption)
.option('--compilerUrl [compilerUrl]', 'Compiler URL', COMPILER_URL)
.addOption(compilerOption)
.option('-f --force', 'Ignore node version compatibility check')
.addOption(jsonOption);

Expand Down

0 comments on commit 78a9953

Please sign in to comment.