Conversation
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.
📝 WalkthroughWalkthroughAdded a new network constant Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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 encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/core/config/EnvLoader.ts
| 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"' |
There was a problem hiding this comment.
🧹 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.

Summary
STAGING: 'staging'to theNetworksconst insrc/core/types.tsTest plan
npm run buildpassesNote
Low Risk
Low risk: this only expands the allowed
NetworkTypevalues andCANTON_CURRENT_NETWORKvalidation to includestaging, with no behavioral changes beyond accepting a new environment string.Overview
Adds
stagingas a supportedNetworkTypeby extending theNetworksconstant.Updates
EnvLoader.getCurrentNetwork()to acceptCANTON_CURRENT_NETWORK=stagingand 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