diff --git a/.changeset/seven-stingrays-suffer.md b/.changeset/seven-stingrays-suffer.md new file mode 100644 index 0000000..5865e16 --- /dev/null +++ b/.changeset/seven-stingrays-suffer.md @@ -0,0 +1,5 @@ +--- +"ethereum-mars": patch +--- + +⛽️ Gas price in GWEI from CLI param diff --git a/docs/source/cli.rst b/docs/source/cli.rst index ff7312d..ec5317f 100644 --- a/docs/source/cli.rst +++ b/docs/source/cli.rst @@ -66,7 +66,7 @@ CLI flags +-----------------+-------+------+----------------+--------------------+-----------------------------------------------------------------+ | --out-file | -o | Path | No | ./deployments.json | Path to the JSON file with deployed contract addresses | +-----------------+-------+------+----------------+--------------------+-----------------------------------------------------------------+ -| --gas-price | -g | Int | No | | Gas price in wei | +| --gas-price | -g | Int | No | | Gas price in gwei | +-----------------+-------+------+----------------+--------------------+-----------------------------------------------------------------+ | --dry-run | -d | Bool | No | false | Simulate deployment locally. :ref:`Learn more ` | +-----------------+-------+------+----------------+--------------------+-----------------------------------------------------------------+ diff --git a/packages/mars/src/options/cli.ts b/packages/mars/src/options/cli.ts index 7acc7c3..ef6c1b4 100644 --- a/packages/mars/src/options/cli.ts +++ b/packages/mars/src/options/cli.ts @@ -11,7 +11,7 @@ import { exit, } from './checks' import { Options } from './Options' -import { usage, ALLOWED_OPTIONS } from './usage' +import { ALLOWED_OPTIONS, usage } from './usage' import path from 'path' const STRING_ARGUMENTS = ['p', 'private-key', 'i', 'infura-key', 'a', 'alchemy-key', 'e', 'etherscan-key', 'f', 'from'] @@ -60,8 +60,8 @@ export function getCommandLineOptions(): Options { const gasPrice = get(parsed, 'g', 'gas-price') if (gasPrice) { - ensureNumber(gasPrice, 'Invalid gas price provided as argument') - result.gasPrice = BigNumber.from(gasPrice) + ensureNumber(gasPrice, 'Invalid gas price (gwei) provided as argument') + result.gasPrice = BigNumber.from(gasPrice).mul('1000000000') } const dryRun = get(parsed, 'd', 'dry-run') diff --git a/packages/mars/test/options/cli.test.ts b/packages/mars/test/options/cli.test.ts index 3848ca9..e2a1a19 100644 --- a/packages/mars/test/options/cli.test.ts +++ b/packages/mars/test/options/cli.test.ts @@ -73,7 +73,7 @@ describe('getCommandLineOptions', () => { checkParam('infuraApiKey', 'i', 'infura-key', 'boo', 'bam bam') checkParam('alchemyApiKey', 'a', 'alchemy-key', 'boo', 'bam bam') checkParam('outputFile', 'o', 'out-file', 'file.json', '123') - checkParam('gasPrice', 'g', 'gas-price', '2', 'foo', BigNumber.from(2)) + checkParam('gasPrice', 'g', 'gas-price', '2', 'foo', BigNumber.from('2000000000')) checkParam('dryRun', 'd', 'dry-run', '', 'asd', true) checkParam('fromAddress', 'f', 'from', '0xAF98FD86fBe3e490417A95B4B6c1572bB227a7CC', 'asd') checkParam('logFile', 'l', 'log', 'mars.log', '123')