Skip to content

feat(cli): multi-environment support#132

Merged
andrew-ifrita merged 1 commit into
mainfrom
spha/cli-multi-env
May 13, 2026
Merged

feat(cli): multi-environment support#132
andrew-ifrita merged 1 commit into
mainfrom
spha/cli-multi-env

Conversation

@sphamjoli
Copy link
Copy Markdown
Member

@sphamjoli sphamjoli commented May 13, 2026

Summary

  • Adds --env / --network selector so the CLI can target multiple DotNS deployments, with per-environment RPC and contract addresses.
  • Reads native token decimals and symbol from chain spec metadata instead of hard-coded constants.
  • Mirrors the env mapping in the UI network store and surfaces --env in the deploy and bulletin GitHub Actions.

Test plan

  • bun run --cwd packages/cli test tests/unit/cli/environment.test.ts
  • dotns --env paseo-v2 account info against a configured account
  • dotns lookup name dotnscli shows correct token decimals/symbol from chain

Order

First in the stack. Depends on nothing. The next three PRs all build on it.

Adds a `--env` / `--network` selector that lets the CLI target
multiple DotNS deployments, with per-environment RPC and contract
addresses. Native token decimals and symbol are read from chain
spec metadata instead of being hard-coded.

* Adds `resolveDotnsEnvironment` and `getChainTokenInfo`
* Threads env into auth options, lookup, info, and context
* Adds per-env entries in `CONTRACTS` and shared constants
* Mirrors the env mapping in the UI network store
* Surfaces `--env` in deploy and bulletin GitHub Actions
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

CI Summary

Check Result
Lint Passed
Lint (UI) Passed
Format Passed
Format (UI) Passed
Typecheck Passed
Typecheck (UI) Passed
Build Passed
Build (UI) Passed
Release Passed
Deploy UI Failed
Deploy Example Failed
Benchmark UI Passed
PR Title Passed
Labels Passed
Test Passed - 167 passed, 0 failed

Release - Passed

Test this PR

Download artifact (GitHub CLI required):

gh run download 25775147485 -n cli-release-0.0.0-pr.132 -R paritytech/dotns-sdk

Install globally:

npm install -g ./parity-dotns-cli-0.0.0-pr.132.tgz

Verify:

dotns --help
Deploy UI — Failed

Failed at: Deploy — Deploy workflow failed — see run logs for upload/register/contenthash details

Stage Status
✓ Build Build succeeded
✗ Deploy Deploy workflow failed — see run logs for upload/register/contenthash details

View run

Deploy Example — Failed

Failed at: Deploy — Deploy workflow failed — see run logs for upload/register/contenthash details

Stage Status
✓ Site validation Site validated
✗ Deploy Deploy workflow failed — see run logs for upload/register/contenthash details

View run

Benchmark UI - Passed (269s)
Property Value
Duration 269s
Domain pr132-ui.bulletin-benchmarks.dot
CID bafybeiee6c4vfljsd2edw4jr56zugehcpkqsxewqkrl5r2dieug6jaykeq
Preview (dot.li) open
Preview (direct) open
Workflow view
Labels

pkg: cli, type: test, dependencies, pkg: ui

Test - Passed

167 passed, 0 failed across 167 tests.

Waited for other CI summary workflows and hit the timeout; wrote the latest available summary.

View run

$ bun test tests/unit/
bun test v1.2.6 (8ebd5d53)

::group::tests/unit/text/textHelp.test.ts:
(pass) text --help lists subcommands and auth options [17.00ms]
(pass) text view --help shows name and key arguments [4.00ms]
(pass) text set --help shows name, key, and value arguments [3.00ms]

::endgroup::

::group::tests/unit/text/textJson.test.ts:
(pass) text view --help shows --json option [4.00ms]
(pass) text set --help shows --json option [3.00ms]
(pass) text set --json emits JSON error when both mnemonic and key-uri provided [3.00ms]

::endgroup::

::group::tests/unit/content/contentJson.test.ts:
(pass) content view --help shows --json option [2.00ms]
(pass) content set --help shows --json option [2.00ms]
(pass) content set --json emits JSON error when both mnemonic and key-uri provided [2.00ms]

::endgroup::

::group::tests/unit/content/contentHelp.test.ts:
result:  {
  exitCode: 0,
  standardOutput: "Usage: dotns content [options] [command]\n\nManage domain content hashes\n\nOptions:\n  --env <environment>         DotNS environment: paseo-v2 (env: DOTNS_ENV)\n  --network <environment>     Alias for --env\n  --rpc <wsUrl>               WebSocket RPC endpoint (env: DOTNS_RPC)\n  --keystore-path <path>      Keystore path (env: DOTNS_KEYSTORE_PATH)\n  --min-balance <pas>         Minimum balance in PAS (env:\n                              DOTNS_MIN_BALANCE_PAS)\n  --account <name>            Keystore account name (default: keystore default)\n  --password <pw>             Keystore password (env: DOTNS_KEYSTORE_PASSWORD)\n  -m, --mnemonic <phrase>     BIP39 mnemonic phrase (env: DOTNS_MNEMONIC)\n  -k, --key-uri <uri>         Substrate key URI (env: DOTNS_KEY_URI)\n  -h, --help                  display help for command\n\nCommands:\n  view [options] <name>       View domain content hash\n  set [options] <name> <cid>  Set domain content hash (IPFS CID)\n  help [command]              display help for command\n",
  standardError: "",
  combinedOutput: "Usage: dotns content [options] [command]\n\nManage domain content hashes\n\nOptions:\n  --env <environment>         DotNS environment: paseo-v2 (env: DOTNS_ENV)\n  --network <environment>     Alias for --env\n  --rpc <wsUrl>               WebSocket RPC endpoint (env: DOTNS_RPC)\n  --keystore-path <path>      Keystore path (env: DOTNS_KEYSTORE_PATH)\n  --min-balance <pas>         Minimum balance in PAS (env:\n                              DOTNS_MIN_BALANCE_PAS)\n  --account <name>            Keystore account name (default: keystore default)\n  --password <pw>             Keystore password (env: DOTNS_KEYSTORE_PASSWORD)\n  -m, --mnemonic <phrase>     BIP39 mnemonic phrase (env: DOTNS_MNEMONIC)\n  -k, --key-uri <uri>         Substrate key URI (env: DOTNS_KEY_URI)\n  -h, --help                  display help for command\n\nCommands:\n  view [options] <name>       View domain content hash\n  set [options] <name> <cid>  Set domain content hash (IPFS CID)\n  help [command]              display help for command\n",
}
(pass) content --help lists subcommands and auth options [3.00ms]
(pass) content view --help shows name argument and options [2.00ms]
(pass) content set --help shows name and cid arguments [2.00ms]

::endgroup::

::group::tests/unit/utils/formatting.test.ts:
(pass) native balance formatting uses DOT/PAS 10 decimals > defaults to 10 native decimals and 18 EVM decimals
(pass) native balance formatting uses DOT/PAS 10 decimals > formatNativeBalance renders 5000 PAS from 5000 * 10^10 units
(pass) native balance formatting uses DOT/PAS 10 decimals > formatNativeBalance renders fractional 0.1 PAS as 10^9 units
(pass) native balance formatting uses DOT/PAS 10 decimals > formatNativeBalance renders zero balance
(pass) native balance formatting uses DOT/PAS 10 decimals > parseNativeBalance inverts formatNativeBalance
(pass) native balance formatting uses DOT/PAS 10 decimals > parseNativeBalance('0.1') is 10^9

::endgroup::

::group::tests/unit/utils/contractInteractions.test.ts:
(pass) isRevertFlag matches the EVM revert bit > flags=0n → false
(pass) isRevertFlag matches the EVM revert bit > flags=1n → true
(pass) isRevertFlag matches the EVM revert bit > flags=2n → false
(pass) isRevertFlag matches the EVM revert bit > flags=3n → true
(pass) buildRevertError > empty data returns the unmapped-origin hint
(pass) buildRevertError > known ABI selector decodes to the named error [6.00ms]
(pass) buildRevertError > unknown selector falls back to raw hex [1.00ms]

::endgroup::

::group::tests/unit/auth/auth.test.ts:
(pass) auth set creates keystore and stores multiple accounts [291.00ms]
(pass) auth set accepts account names with special characters [414.00ms]
(pass) auth list reports missing keystore [4.00ms]
(pass) auth list shows all accounts and auth types [275.00ms]
(pass) auth use switches default account [426.00ms]
(pass) auth remove last account clears default [72.00ms]
(pass) auth remove preserves remaining accounts and reassigns default [209.00ms]
(pass) auth clear deletes all accounts [84.00ms]

::endgroup::

::group::tests/unit/auth/authHelp.test.ts:
(pass) root help lists auth command [2.00ms]
(pass) auth help shows options and subcommands [2.00ms]
(pass) auth set help shows all options [2.00ms]
(pass) auth list help shows options [1.00ms]
(pass) auth use help shows options [2.00ms]
(pass) auth remove help shows options [2.00ms]
(pass) auth clear help shows options [1.00ms]
(pass) auth parses keystore-path option [3.00ms]
(pass) auth parses password option [2.00ms]
(pass) auth set parses account option [2.00ms]
(pass) auth set parses mnemonic option [2.00ms]
(pass) auth set parses key-uri option [3.00ms]
(pass) auth help command shows help [2.00ms]
(pass) auth help set shows set command help [3.00ms]
(pass) auth help list shows list command help [2.00ms]
(pass) auth help use shows use command help [2.00ms]
(pass) auth help remove shows remove command help [3.00ms]
(pass) auth help clear shows clear command help [2.00ms]

::endgroup::

::group::tests/unit/auth/authRevert.test.ts:
(pass) auth set rejects account name with forward slash [3.00ms]
(pass) auth set rejects account name with backslash [2.00ms]
(pass) auth set rejects account name that is just a dot [1.00ms]
(pass) auth set rejects account name that is double dots [1.00ms]
(pass) auth set rejects account name starting with dot [1.00ms]
(pass) auth set rejects account name ending with dot [1.00ms]
(pass) auth set rejects account name with special characters [10.00ms]
(pass) auth set rejects account name that is too long [2.00ms]
(pass) auth use rejects non-existent account [71.00ms]
(pass) auth remove rejects non-existent account [80.00ms]

::endgroup::

::group::tests/unit/auth/resolveAuthSourceReadOnly.test.ts:
(pass) resolveAuthSourceReadOnly honours environment variables > $label
(pass) resolveAuthSourceReadOnly honours environment variables > $label
(pass) resolveAuthSourceReadOnly honours environment variables > $label
(pass) resolveAuthSourceReadOnly honours environment variables > $label
(pass) resolveAuthSourceReadOnly honours environment variables > $label

::endgroup::

::group::tests/unit/store/storeHelp.test.ts:
(pass) store --help lists subcommands [2.00ms]
(pass) store info --help shows auth options [2.00ms]
(pass) store list --help shows options [1.00ms]
(pass) store get --help shows key argument [2.00ms]
(pass) store set --help shows key and value arguments with auth [1.00ms]
(pass) store delete --help shows key argument with auth [1.00ms]
(pass) store check --help shows address argument [2.00ms]
(pass) store authorize --help shows address argument with auth [1.00ms]
(pass) store unauthorize --help shows address argument [1.00ms]
(pass) store authorize-controller --help shows address argument [1.00ms]
(pass) store unauthorize-controller --help shows address argument [1.00ms]
(pass) store ensure-auth --help shows description and auth options [1.00ms]

::endgroup::

::group::tests/unit/pop/popJson.test.ts:
(pass) pop set --help shows --json option [2.00ms]
(pass) pop info --help shows --json option [1.00ms]

::endgroup::

::group::tests/unit/pop/setPopHelp.test.ts:
(pass) root help lists pop command [2.00ms]
(pass) pop help shows commands and description [1.00ms]
(pass) pop help shows auth options [2.00ms]
(pass) pop set help shows status parameter [1.00ms]
(pass) pop set help shows auth options [1.00ms]
(pass) pop info help shows description [1.00ms]
(pass) pop info help shows auth options [2.00ms]
(pass) pop set parses rpc option at pop level [1.00ms]
(pass) pop set parses rpc option at set level [1.00ms]
(pass) pop set parses keystore-path option [1.00ms]
(pass) pop set parses account option at pop level [1.00ms]
(pass) pop set parses account option at set level [1.00ms]
(pass) pop set parses password option [1.00ms]
(pass) pop set parses mnemonic option [1.00ms]
(pass) pop set parses key-uri option [1.00ms]
(pass) pop info parses auth options at pop level [1.00ms]
(pass) pop info parses auth options at info level [2.00ms]
(pass) pop set parses mixed options across levels [1.00ms]
(pass) pop help command shows pop help [2.00ms]
(pass) pop help set shows set help [1.00ms]
(pass) pop help info shows info help [1.00ms]

::endgroup::

::group::tests/unit/account/accountHelp.test.ts:
(pass) account --help lists subcommands including is-mapped, is-whitelisted, whitelist [3.00ms]
(pass) account is-mapped --help shows address argument and --json [1.00ms]
(pass) account is-whitelisted --help shows address argument and --json [1.00ms]
(pass) account whitelist --help shows address argument, --remove, and --json [1.00ms]
(pass) account is alias works for is-mapped [1.00ms]
(pass) account iw alias works for is-whitelisted [2.00ms]

::endgroup::

::group::tests/unit/cli/reporter.test.ts:
(pass) cli reporter > stream reporter emits durable progress lines [1.00ms]
(pass) cli reporter > withConsoleToStderr redirects console and stdout writes

::endgroup::

::group::tests/unit/cli/environment.test.ts:
(pass) defaults to paseo-v2 [1.00ms]
(pass) accepts friendly paseo-v2 aliases
(pass) DOTNS_ENV selects rpc and contract set
(pass) --env takes precedence over DOTNS_ENV while --rpc only overrides endpoint

::endgroup::

::group::tests/unit/bulletin/uploadManifest.test.ts:
(pass) upload manifest resume behavior > returns stale manifest when fingerprint does not match [3.00ms]
(pass) upload manifest resume behavior > deduplicates completed blocks by index

::endgroup::

::group::tests/unit/bulletin/uploadProfiling.test.ts:
(pass) upload profiler > writes schema-complete profile report with peak aggregation [18.00ms]
(pass) upload profiler > default profile path is deterministic for a given fingerprint

::endgroup::

::group::tests/unit/bulletin/bulletinHelp.test.ts:
(pass) root help lists bulletin command [2.00ms]
(pass) bulletin help shows commands and description [1.00ms]
(pass) bulletin upload help shows all options [2.00ms]
(pass) bulletin upload help shows default values [1.00ms]
(pass) bulletin authorize help shows all options [2.00ms]
(pass) bulletin authorize help shows default values [1.00ms]
(pass) bulletin history help shows options [1.00ms]
(pass) bulletin history:remove help shows usage [1.00ms]
(pass) bulletin history:clear help shows description [1.00ms]
(pass) bulletin help command shows bulletin help [2.00ms]
(pass) bulletin help upload shows upload help [1.00ms]
(pass) bulletin help authorize shows authorize help [1.00ms]
(pass) bulletin status help shows all options [1.00ms]
(pass) bulletin help status shows status help [1.00ms]
(pass) bulletin list alias works [1.00ms]
(pass) bulletin verify help shows usage [1.00ms]
(pass) bulletin help verify shows verify help [1.00ms]

::endgroup::

::group::tests/unit/register/registerHelp.test.ts:
(pass) root help lists register command [2.00ms]
(pass) register help shows subcommands [2.00ms]
(pass) register domain help shows options [1.00ms]
(pass) register subname help shows options [1.00ms]
(pass) register domain parses status none [2.00ms]
(pass) register domain parses status lite [1.00ms]
(pass) register domain parses status full [1.00ms]
(pass) register domain parses reverse flag [1.00ms]
(pass) register domain parses governance flag [1.00ms]
(pass) register domain parses owner option [1.00ms]
(pass) register domain parses transfer with destination [1.00ms]
(pass) register domain parses account option [1.00ms]
(pass) register domain parses keystore-path option [1.00ms]
(pass) register domain parses password option [1.00ms]
(pass) register domain parses mnemonic option [1.00ms]
(pass) register domain parses key-uri option [2.00ms]
(pass) register domain parses commitment-buffer option [1.00ms]
(pass) register domain parses commitment-buffer alias --cb [1.00ms]
(pass) register subname parses name and parent [1.00ms]
(pass) register subname parses owner option [1.00ms]
(pass) getCommitmentBufferSeconds defaults to 6 when env is not set
(pass) getCommitmentBufferSeconds reads from DOTNS_COMMITMENT_BUFFER env variable
(pass) COMMITMENT_POLL_INTERVAL_MS is 2000
(pass) COMMITMENT_POLL_TIMEOUT_MS is 30000

::endgroup::

::group::tests/unit/register/registerJson.test.ts:
(pass) register domain --help shows --json option [2.00ms]
(pass) register subname --help shows --json option [1.00ms]
(pass) register domain --json emits JSON error when --transfer without --to [2.00ms]

::endgroup::

::group::tests/unit/lookup/lookupHelp.test.ts:
(pass) lookup --help lists subcommands and auth options [2.00ms]
(pass) lookup name --help shows label argument and options [1.00ms]
(pass) lookup owner-of --help shows label argument and options [1.00ms]
(pass) lookup transfer --help shows label argument and destination option [1.00ms]
(pass) lookup transfer parses destination at transfer level [2.00ms]
(pass) lookup transfer parses auth options at lookup level [1.00ms]

::endgroup::

 167 pass
 0 fail
 588 expect() calls
Ran 167 tests across 22 files. [2.61s]

@andrew-ifrita
Copy link
Copy Markdown
Collaborator

Looks good. CI deploys are failing for a few reasons.

First, the address did not have enough funds on paseo v2. I ran !drip 5DtFfWy6TfjsZGF4ingDoEeL49PW8H5oS6qQfFJ3FX2tTMLe:1500 in https://matrix.to/#/#paseo_faucet:matrix.org to top up with 5000PAS

Next issue looks like it relates to PoP status

@andrew-ifrita
Copy link
Copy Markdown
Collaborator

The deploy issues aren't related to this PR so I will merge and try to address them in a follow up

@andrew-ifrita andrew-ifrita merged commit acf33fc into main May 13, 2026
47 of 55 checks passed
@andrew-ifrita andrew-ifrita deleted the spha/cli-multi-env branch May 13, 2026 11:40
andrew-ifrita pushed a commit that referenced this pull request May 13, 2026
## Summary
- Personhood status is no longer mutable from the CLI. The precompile is
the source of truth for reads. Drops `dotns pop set`, the `--status`
flag on `dotns register`, and the helpers that supported them.
- `getUserProofOfPersonhoodStatus` now calls the personhood precompile
via the env-aware constants from PR #132.
- `finalizeRegularRegistration` threads native token decimals through.

## Test plan
- [ ] `bun run --cwd packages/cli test tests/unit/pop`
- [ ] `dotns register domain --name <new>` succeeds without `--status`
- [ ] `dotns pop info --key-uri //Alice` reads from the precompile

## Order
Second in the stack. Base is `spha/cli-multi-env` (#132). Merge after PR
#132 lands so the precompile constants resolve cleanly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants