Skip to content

[codex] Add environment constants#22

Open
123xiaode456-boop wants to merge 2 commits into
ShadeProtocol:mainfrom
123xiaode456-boop:codex/environment-constants-3
Open

[codex] Add environment constants#22
123xiaode456-boop wants to merge 2 commits into
ShadeProtocol:mainfrom
123xiaode456-boop:codex/environment-constants-3

Conversation

@123xiaode456-boop

@123xiaode456-boop 123xiaode456-boop commented Jun 22, 2026

Copy link
Copy Markdown

Summary:

  • Adds a typed Environment enum with sandbox and production values.
  • Maps each environment to the correct Horizon URL, Stellar network passphrase, and Shade API base URL.
  • Lets Gateway default to sandbox and accept string shorthands via the environment setter.
  • Documents environment usage in README.

Validation:

  • python -m pytest: 6 passed
  • python -m compileall -q src tests: passed
  • python -m black --check src tests: unavailable locally, black module not installed
  • python -m flake8 src tests: unavailable locally, flake8 module not installed

Closes #3

Summary by CodeRabbit

  • New Features

    • Added environment-specific configuration support, including sandbox and production settings.
    • Exposed environment-related values on the gateway for easier access to URLs and network details.
  • Documentation

    • Updated the README with setup guidance for configuring the gateway environment and examples for switching between supported options.
  • Tests

    • Added coverage for environment parsing and default/production gateway configuration.

@codebestia

Copy link
Copy Markdown
Contributor

Hello @123xiaode456-boop
Please resolve the conflicts.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

The SDK now recognizes sandbox and production environments, maps them to Horizon, network passphrase, and API base values, and exposes those values through Gateway with docs and tests.

Changes

Gateway environment configuration

Layer / File(s) Summary
Environment config and parsing
src/shade/config.py
Environment now uses sandbox/production values, maps each one to Horizon, network passphrase, and API base settings, and resolves string inputs through parse_environment and get_environment_config.
Gateway wiring
src/shade/gateway.py
Gateway now stores parsed environment config, exposes derived URLs and passphrase values, and resolves _base_url before constructing the HTTP clients.
Exports and validation
src/shade/__init__.py, README.md, tests/test_config.py, tests/test_gateway.py
shade exports the new config helpers, the README describes supported environments, and tests cover parsing plus Gateway default and override behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Gateway
  participant parse_environment
  participant get_environment_config
  participant EnvironmentConfig
  Gateway->>parse_environment: environment value
  parse_environment-->>Gateway: Environment
  Gateway->>get_environment_config: resolved Environment
  get_environment_config-->>Gateway: EnvironmentConfig
  Gateway->>Gateway: set horizon_url, network_passphrase, api_base_url
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ShadeProtocol/shade-python#29: Shares the _base_url precedence chain that this PR keeps using while resolving environment-aware Gateway config.

Suggested reviewers

  • codebestia

Poem

🐰 I hopped from sandbox into bright production light,
and tucked each URL where Gateway keeps it tight.
Parse, resolve, and passphrase too,
then hop with tests and docs in view.
Hooray for environment mojo! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: adding environment constants.
Description check ✅ Passed The description covers the summary, issue reference, and validation, though it omits some template sections like type and checklist.
Linked Issues check ✅ Passed The PR appears to satisfy #3 by adding SANDBOX/PRODUCTION env mapping, coercion, defaults, and Gateway property-based resolution.
Out of Scope Changes check ✅ Passed No unrelated feature work is evident; the changes stay focused on environment configuration, docs, and tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Warning

⚠️ This pull request shows signs of AI-generated slop (phantom_api). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

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.

Add environment constants (sandbox/production, testnet/mainnet)

2 participants