Skip to content

Fix import path for config.js in demo.js#204

Open
LELOUCH-Vii wants to merge 11 commits into
Stellar-Ecosystem:mainfrom
LELOUCH-Vii:LELOUCH-Vii-patch-3
Open

Fix import path for config.js in demo.js#204
LELOUCH-Vii wants to merge 11 commits into
Stellar-Ecosystem:mainfrom
LELOUCH-Vii:LELOUCH-Vii-patch-3

Conversation

@LELOUCH-Vii

@LELOUCH-Vii LELOUCH-Vii commented Jun 22, 2026

Copy link
Copy Markdown

Closes #131
backend/src/routes/demo.js**: buildHttpClientnow usesconfig.stellar.networkIdinstead of the hardcoded'stellar:testnet'. Verified demo.jsandagent.jsimportconfig` from the correct
relative path for their respective locations.

Summary by CodeRabbit

  • Bug Fixes

    • Updated payment signing and middleware for demo flows to use the configured Stellar network, avoiding hardcoded testnet behavior and ensuring transactions are signed for the intended environment.
  • Configuration

    • Added stellar.networkId to central settings (defaults to testnet when not specified) so signing and payment “accepts” values stay consistent across the app.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fd292b18-51a0-48c5-bb86-c4b5c8a58aca

📥 Commits

Reviewing files that changed from the base of the PR and between e34a925 and 1c2d72c.

📒 Files selected for processing (2)
  • agent/agent.js
  • backend/src/routes/services.js
💤 Files with no reviewable changes (1)
  • backend/src/routes/services.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • agent/agent.js

📝 Walkthrough

Walkthrough

The PR replaces hardcoded 'stellar:testnet' network strings with a configurable config.stellar.networkId across backend and agent HTTP client initialization and payment route setup. A new STELLAR_NETWORK environment variable (defaulting to testnet) drives the network identity computation in config, eliminating network mismatch risks on non-testnet deployments.

Changes

Dynamic Stellar network ID in demo HTTP client and payment routes

Layer / File(s) Summary
Stellar network ID configuration property
backend/src/config.js
Config adds stellar.networkId field derived from STELLAR_NETWORK environment variable with 'testnet' default, computing the full network string as stellar:${STELLAR_NETWORK ?? 'testnet'}.
HTTP client and agent signer network initialization
backend/src/routes/demo.js, agent/agent.js
buildHttpClient() in both files now passes config.stellar.networkId to createEd25519Signer instead of the hardcoded 'stellar:testnet' string. Agent imports the shared config module.
Payment route configuration aligned with network ID
backend/src/routes/services.js
Payment configuration for /demo/weather and /demo/search routes now use config.stellar.networkId for the network field and config.server.address for payment destinations, replacing hardcoded testnet and the previous config.x402.payTo. The shared paymentMiddlewareFromConfig middleware setup also uses config.stellar.networkId.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny once hopped past a testnet sign,
"Why hardcode the path? Let config define!"
With swaps through four files on one little line,
The network now bends to STELLAR_NETWORK's design.
🐇✨ Configurable at last — no more strings to confine!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning Title mentions fixing import path in demo.js, but changes span multiple files and primarily address network identifier configuration across the codebase. Revise title to reflect the main change: configuring the Stellar network identifier across multiple files instead of focusing solely on an import path fix.
Linked Issues check ⚠️ Warning PR partially implements issue #131 requirements but omits critical components: no startup assertion in backend/src/index.js, no environment variable documentation updates, and incomplete network identifier standardization. Add startup assertion verifying RPC URL matches configured network, document STELLAR_NETWORK in .env.example files, and ensure all hardcoded network strings are replaced across all files.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes directly relate to issue #131's objective of replacing hardcoded network identifiers with configuration-driven values across backend and agent files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/routes/demo.js`:
- Line 15: The `createEd25519Signer` call in the demo.js file references
`config.stellar.networkId`, but this property is not defined in the config
schema in backend/src/config.js. Add a new `networkId` property to the
`config.stellar` object in backend/src/config.js, deriving its value from the
`STELLAR_NETWORK` environment variable, and ensure all other x402-related
callers that reference `config.stellar` use this same key for consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1aabb235-51cd-49b3-b486-bcf83faedb23

📥 Commits

Reviewing files that changed from the base of the PR and between 5bbe6bd and 036a1d5.

📒 Files selected for processing (1)
  • backend/src/routes/demo.js

Comment thread backend/src/routes/demo.js

@ritik4ever ritik4ever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution! Unfortunately this doesn't fully address Issue #131 yet.

The issue requires moving all hardcoded Stellar network strings to configuration (demo.js, services.js, and agent.js), adding the STELLAR_NETWORK-driven config, startup validation, environment documentation updates, and related test updates.

Additionally, the current change references config.stellar.networkId, but it isn't clear that this property exists in the current config contract, which could introduce a runtime issue.

Could you please expand the implementation to cover the full issue requirements and verify the configuration path is defined and tested?

@LELOUCH-Vii

Copy link
Copy Markdown
Author

Fixed code rabbit complaint in both PR #203 and #204 in the way that matches documented @x402/stellarAPI

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent/agent.js`:
- Line 10: The import path for the config module in agent/agent.js is using an
incorrect relative path. The current import statement uses
'./backend/src/config.js' which resolves to a non-existent path within the agent
directory. Change the relative path from './backend/src/config.js' to
'../backend/src/config.js' to correctly reference the config module one
directory level up and then into the backend/src directory.

In `@backend/src/routes/services.js`:
- Around line 36-40: The object being created has duplicate keys for network and
payTo. The first definitions use configuration values (config.stellar.networkId
and config.server.address), but they are immediately followed by duplicate key
definitions with hardcoded values ('stellar:testnet' and config.x402.payTo).
Since JavaScript objects only keep the last value when keys are duplicated, the
hardcoded values are overwriting the config-driven ones. Remove the duplicate
network and payTo key definitions so that the config-driven values are retained
in the final object.
- Around line 47-51: The configuration object has duplicate key definitions
where `network` and `payTo` are defined twice. The first definitions on lines
using config.stellar.networkId and config.server.address are immediately
overwritten by hardcoded values on the subsequent lines with 'stellar:testnet'
and config.x402.payTo. Remove the duplicate key definitions (the hardcoded
`network: 'stellar:testnet'` and `payTo: config.x402.payTo` lines) so only the
config-driven values remain and are not overwritten.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f284973-0787-4676-8f6b-6ea507beeddb

📥 Commits

Reviewing files that changed from the base of the PR and between 036a1d5 and e34a925.

📒 Files selected for processing (3)
  • agent/agent.js
  • backend/src/config.js
  • backend/src/routes/services.js

Comment thread agent/agent.js Outdated
Comment thread backend/src/routes/services.js
Comment thread backend/src/routes/services.js
LELOUCH-Vii and others added 3 commits June 23, 2026 17:18
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@LELOUCH-Vii LELOUCH-Vii left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants