Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message for undefined node directly includes network name #1058

Merged
1 commit merged into from Mar 28, 2023
Merged

Error message for undefined node directly includes network name #1058

1 commit merged into from Mar 28, 2023

Conversation

ghost
Copy link

@ghost ghost commented Mar 21, 2023

Problem

- Previously, I was a a new user to near-cli and was not sure if I was passing the network name correctly. - Upon inspecting, it seems the existing error message does a redundant helperAccount to networkName matching for only a subset of networks.

Solution

- Update to directly use the network configurations that was set. - Also, updated network name from local to localnet as that's what's written on our documentations.

Tests

Nonexistent network

soonnear@Chees-MacBook-Pro nearup % NEAR_ENV=localnet2 near state node45

/Users/soonnear/Github/modified-near/near-cli/config.js:85
throw Error(Unconfigured environment '${env}'. Can be configured in src/config.js.);
^

Error: Unconfigured environment 'localnet2'. Can be configured in src/config.js.
at getConfig (/Users/soonnear/Github/modified-near/near-cli/config.js:85:15)
at getConfig (/Users/soonnear/Github/modified-near/near-cli/get-config.js:14:54)
at Object. (/Users/soonnear/Github/modified-near/near-cli/utils/inspect-response.js:2:40)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Module._load (node:internal/modules/cjs/loader:972:12)
at Module.require (node:internal/modules/cjs/loader:1157:19)
at require (node:internal/modules/helpers:119:18)
at object. (/users/soonnear/github/modified-near/near-cli/index.js:16:25)
node.js v19.8.1

Nonexistent node

soonnear@Chees-MacBook-Pro nearup % NEAR_ENV=localnet near state node45

Loaded master account test.near key from /Users/soonnear/.near/validator_key.json with public key = redacted Account node45 is not found in localnet

Proer usage

soonnear@Chees-MacBook-Pro nearup % NEAR_ENV=localnet near state node1

Loaded master account test.near key from /Users/soonnear/.near/validator_key.json with public key = redacted Account node1
{
amount: '950000000000000000000000000000000',
block_hash: '46Vc4CVx7giRpEKSQL3ywrr7dFe1vrZTzwBnPMXYY9as',
block_height: 0,
code_hash: '11111111111111111111111111111111',
locked: '50000000000000000000000000000000',
storage_paid_at: 0,
storage_usage: 182,
formattedAmount: '950,000,000'
}

<h1> Problem </h1>
- Previously, I was a a new user to near-cli and was not sure if I was passing the network name correctly.
- Upon inspecting, it seems the existing error message does a redundant helperAccount to networkName matching for only a subset of networks.

<h1> Solution </h1>
- Update to directly use the network configurations that was set.
- Also, updated network name from local to localnet as that's what's written on our documentations.

<h1> Tests </h1>
<h2> Nonexistent network </h2>
soonnear@Chees-MacBook-Pro nearup % NEAR_ENV=localnet2 near state node45

/Users/soonnear/Github/modified-near/near-cli/config.js:85
        throw Error(`Unconfigured environment '${env}'. Can be configured in src/config.js.`);
        ^

Error: Unconfigured environment 'localnet2'. Can be configured in src/config.js.
    at getConfig (/Users/soonnear/Github/modified-near/near-cli/config.js:85:15)
    at getConfig (/Users/soonnear/Github/modified-near/near-cli/get-config.js:14:54)
    at Object.<anonymous> (/Users/soonnear/Github/modified-near/near-cli/utils/inspect-response.js:2:40)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Module.require (node:internal/modules/cjs/loader:1157:19)
    at require (node:internal/modules/helpers:119:18)
    at object.<anonymous> (/users/soonnear/github/modified-near/near-cli/index.js:16:25)
node.js v19.8.1

<h2> Nonexistent node </h2>
soonnear@Chees-MacBook-Pro nearup % NEAR_ENV=localnet near state node45

Loaded master account test.near key from /Users/soonnear/.near/validator_key.json with public key = redacted
Account node45 is not found in localnet

<h2> Proer usage </h2>
soonnear@Chees-MacBook-Pro nearup % NEAR_ENV=localnet near state node1

Loaded master account test.near key from /Users/soonnear/.near/validator_key.json with public key = redacted
Account node1
{
  amount: '950000000000000000000000000000000',
  block_hash: '46Vc4CVx7giRpEKSQL3ywrr7dFe1vrZTzwBnPMXYY9as',
  block_height: 0,
  code_hash: '11111111111111111111111111111111',
  locked: '50000000000000000000000000000000',
  storage_paid_at: 0,
  storage_usage: 182,
  formattedAmount: '950,000,000'
}
@ghost ghost requested a review from volovyks March 21, 2023 19:36
@ghost
Copy link
Author

ghost commented Mar 21, 2023

Improvement upon:
#1057

@ghost ghost requested a review from wacban March 27, 2023 14:46
Copy link

@wacban wacban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing it.

@ghost ghost merged commit aff742d into near:master Mar 28, 2023
5 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant