Skip to content

Commit

Permalink
⛽️ Gas price in GWEI from CLI param (#80)
Browse files Browse the repository at this point in the history
* ⛽️ Gas price in GWEI from CLI param

Docs (usage) says it's GWEI so the impl is aligned to it.

#78

* Create seven-stingrays-suffer.md

* Update docs
  • Loading branch information
marcin-trust authored Jan 20, 2022
1 parent 5fa85b5 commit e3fbe04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-stingrays-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ethereum-mars": patch
---

⛽️ Gas price in GWEI from CLI param
2 changes: 1 addition & 1 deletion docs/source/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Dry run>` |
+-----------------+-------+------+----------------+--------------------+-----------------------------------------------------------------+
Expand Down
6 changes: 3 additions & 3 deletions packages/mars/src/options/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion packages/mars/test/options/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit e3fbe04

Please sign in to comment.