Skip to content

Commit

Permalink
Rename net param
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Feb 28, 2024
1 parent d073cee commit 57ffa36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions packages/ethernaut-network/src/tasks/add.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { types } = require('hardhat/config')
const output = require('common/src/output')
const autocompleteProvider = require('./autocomplete/provider')
const autocompleteUrl = require('./autocomplete/url')
const storage = require('../internal/storage')

const add = require('../scopes/net')
Expand All @@ -12,12 +12,12 @@ const add = require('../scopes/net')
types.string,
)
.addOptionalParam(
'provider',
'url',
'The url of the network provider, e.g. https://ethereum-rpc.publicnode.com. Note: Environment variables may be included, e.g. https://eth-mainnet.alchemyapi.io/v2/${INFURA_API_KEY}. Make sure to specify these in your .env file.',
undefined,
types.string,
)
.setAction(async ({ alias, provider }) => {
.setAction(async ({ alias, url }) => {
try {
const validateAlias = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/
if (!validateAlias.test(alias)) {
Expand All @@ -33,15 +33,15 @@ const add = require('../scopes/net')
}

networks[alias] = {
url: provider,
url,
}

storage.storeNetworks(networks)

output.resultBox(`Added network ${alias} with provider ${provider}`)
output.resultBox(`Added network ${alias} with provider ${url}`)
} catch (err) {
return output.errorBox(err)
}
})

add.paramDefinitions.provider.autocomplete = autocompleteProvider
add.paramDefinitions.url.autocomplete = autocompleteUrl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const strategies = {
MANUAL: 'Enter url manually',
}

module.exports = async function autocompleteProvider({ provider }) {
if (provider) return undefined
module.exports = async function autocompleteProvider({ url }) {
if (url) return undefined

const choice = await selectStrategy()
switch (choice) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ethernaut-network/test/tasks/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('add', function () {
describe('when all params are specified', function () {
before('run add', async function () {
await terminal.run(
'npx hardhat net add test__1 --provider http://localhost:8545',
'npx hardhat net add test__1 --url http://localhost:8545',
)
})

Expand Down

0 comments on commit 57ffa36

Please sign in to comment.