Skip to content

feat: add staging network type#309

Merged
HardlyDifficult merged 2 commits intomainfrom
feat/staging-network-type
Mar 17, 2026
Merged

feat: add staging network type#309
HardlyDifficult merged 2 commits intomainfrom
feat/staging-network-type

Conversation

@HardlyDifficult
Copy link
Collaborator

@HardlyDifficult HardlyDifficult commented Mar 17, 2026

Summary

  • Adds STAGING: 'staging' to the Networks const in src/core/types.ts
  • Part of the staging environment setup that uses devnet Canton ledger with production database data

Test plan

  • Verify npm run build passes
  • Verify existing tests pass

Note

Low Risk
Low risk: this only expands the allowed NetworkType values and CANTON_CURRENT_NETWORK validation to include staging, with no behavioral changes beyond accepting a new environment string.

Overview
Adds staging as a supported NetworkType by extending the Networks constant.

Updates EnvLoader.getCurrentNetwork() to accept CANTON_CURRENT_NETWORK=staging and reflects this in the validation error message.

Written by Cursor Bugbot for commit 39dc5bf. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • New Features
    • Added support for a new "staging" network environment — you can now select and use a staging network option; environment validation and messaging have been updated to include this choice.

Add STAGING to the Networks const for staging environment support.
Staging uses the devnet Canton ledger with production database data,
isolated by a separate system_operator party.
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Added a new network constant STAGING ('staging') and updated environment loading/validation to accept "staging" as a valid CANTON_CURRENT_NETWORK value.

Changes

Cohort / File(s) Summary
Network Types
src/core/types.ts
Added STAGING: 'staging' to the exported Networks object, extending the NetworkType union to include staging.
Environment Loader
src/core/config/EnvLoader.ts
Updated validation/allowed values for CANTON_CURRENT_NETWORK to include "staging" and adjusted the corresponding error message; getCurrentNetwork now accepts staging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add staging network type' directly and clearly describes the main change: adding a new staging network type to the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/staging-network-type
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Mar 17, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Add 'staging' to the getCurrentNetwork() validation so that
CANTON_CURRENT_NETWORK=staging is accepted.
@claude
Copy link

claude bot commented Mar 17, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/core/config/EnvLoader.ts`:
- Around line 223-225: Replace the hard-coded network literals in EnvLoader.ts's
CANTON_CURRENT_NETWORK validation with the canonical runtime source `Networks`
(from src/core/types.ts): import `Networks`, derive allowedValues =
Object.values(Networks) (or equivalent), use that array in the includes() check,
and build the ConfigurationError message dynamically from allowedValues so the
validation and message automatically reflect any future additions; keep the
thrown error as ConfigurationError and preserve the environment variable name
CANTON_CURRENT_NETWORK in the message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ee1e84f-8475-4aa4-ba63-062795f9e16c

📥 Commits

Reviewing files that changed from the base of the PR and between 1ad3ab6 and 39dc5bf.

📒 Files selected for processing (1)
  • src/core/config/EnvLoader.ts

Comment on lines +223 to +225
if (!value || !['devnet', 'testnet', 'mainnet', 'localnet', 'staging'].includes(value)) {
throw new ConfigurationError(
'Missing or invalid CANTON_CURRENT_NETWORK. Must be "devnet", "testnet", "mainnet", or "localnet"'
'Missing or invalid CANTON_CURRENT_NETWORK. Must be "devnet", "testnet", "mainnet", "localnet", or "staging"'
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Use Networks as the runtime source of truth for validation.

Line 223 and Line 225 hard-code network literals, which can drift from src/core/types.ts again on future additions. Derive allowed values and message from Networks instead.

♻️ Proposed refactor
-import {
+import {
+  Networks,
   type ApiConfig,
   type ApiType,
   type AuthConfig,
   type ClientConfig,
   type NetworkType,
   type ProviderType,
 } from '../types';
...
   public getCurrentNetwork(): NetworkType {
     if (this.options.currentNetwork) {
       return this.options.currentNetwork;
     }
     const value = this.env['CANTON_CURRENT_NETWORK']?.toLowerCase();
-    if (!value || !['devnet', 'testnet', 'mainnet', 'localnet', 'staging'].includes(value)) {
+    const allowedNetworks = Object.values(Networks) as string[];
+    if (!value || !allowedNetworks.includes(value)) {
       throw new ConfigurationError(
-        'Missing or invalid CANTON_CURRENT_NETWORK. Must be "devnet", "testnet", "mainnet", "localnet", or "staging"'
+        `Missing or invalid CANTON_CURRENT_NETWORK. Must be one of: ${allowedNetworks.map((n) => `"${n}"`).join(', ')}`
       );
     }
     return value as NetworkType;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/config/EnvLoader.ts` around lines 223 - 225, Replace the hard-coded
network literals in EnvLoader.ts's CANTON_CURRENT_NETWORK validation with the
canonical runtime source `Networks` (from src/core/types.ts): import `Networks`,
derive allowedValues = Object.values(Networks) (or equivalent), use that array
in the includes() check, and build the ConfigurationError message dynamically
from allowedValues so the validation and message automatically reflect any
future additions; keep the thrown error as ConfigurationError and preserve the
environment variable name CANTON_CURRENT_NETWORK in the message.

@HardlyDifficult HardlyDifficult merged commit 81964ce into main Mar 17, 2026
8 of 9 checks passed
@HardlyDifficult HardlyDifficult deleted the feat/staging-network-type branch March 17, 2026 16:32
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.

1 participant