Skip to content

Import config and update signer network ID#203

Open
LELOUCH-Vii wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
LELOUCH-Vii:LELOUCH-Vii-patch-2
Open

Import config and update signer network ID#203
LELOUCH-Vii wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
LELOUCH-Vii:LELOUCH-Vii-patch-2

Conversation

@LELOUCH-Vii

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

Copy link
Copy Markdown

Closes #131
agent/agent.js**: same fix — buildHttpClient now imports config
and uses config.stellar.networkId.
Confirmed config.js loads without errors after the networkId change.

Summary by CodeRabbit

  • Chores
    • Updated Stellar configuration to load from external settings instead of using a hardcoded network, enabling greater flexibility in network selection and deployment.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

agent/agent.js imports config from ./backend/src/config.js and replaces the hardcoded string 'stellar:testnet' with config.stellar.networkId when instantiating the Ed25519 signer inside buildHttpClient().

Changes

Dynamic Stellar Network Config in Agent

Layer / File(s) Summary
Config import and signer network parameterization
agent/agent.js
Imports config from ./backend/src/config.js and substitutes config.stellar.networkId for the hardcoded 'stellar:testnet' string in the buildHttpClient() Ed25519 signer call.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇 No more testnet carved in stone,
The network string no longer lone!
Config now guides each stellar hop,
Mainnet or test — we'll never stop.
✨ One small import, freedom gained!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The pull request partially addresses issue #131 by replacing the hardcoded network string in agent.js, but does not complete all required changes (demo.js, services.js, startup validation, environment documentation, and tests remain incomplete). Complete remaining changes: update demo.js and services.js with config values, add startup validation in index.js, document STELLAR_NETWORK in environment examples, and add automated test coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: importing configuration and updating the signer network ID from hardcoded 'stellar:testnet' to use config.stellar.networkId.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #131's objective of centralizing network configuration and replacing hardcoded network strings.
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 and usage tips.

@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 `@agent/agent.js`:
- Line 133: The createEd25519Signer call in agent/agent.js is attempting to pass
config.stellar.networkId as the network identifier, but the config contract
defined in backend/src/config.js only exposes stellar.network and
stellar.networkPassphrase (not networkId). Update the signer initialization to
use one of the existing config properties (either stellar.network or
stellar.networkPassphrase) that are actually defined in the config contract,
mapping it to the format expected by the createEd25519Signer function to ensure
the signer receives the correct network parameter and prevents undefined values
that would break x402 Stellar payment operations.
🪄 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: bbd94a68-88f7-4791-86cc-9215603d4cac

📥 Commits

Reviewing files that changed from the base of the PR and between 5bbe6bd and 7e77d4e.

📒 Files selected for processing (1)
  • agent/agent.js

Comment thread agent/agent.js

function buildHttpClient() {
const signer = createEd25519Signer(AGENT_SECRET, 'stellar:testnet');
const signer = createEd25519Signer(AGENT_SECRET, config.stellar.networkId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

config.stellar.networkId does not exist in the shared config contract (runtime break).

Line 133 reads config.stellar.networkId, but backend/src/config.js defines stellar.network and stellar.networkPassphrase (no networkId). This makes the signer network argument undefined, which can break x402 Stellar payment signing/handshakes.

Align the contract on both sides (either expose networkId from config, or consume an existing key and map it to the signer’s required format).

Suggested contract-safe fix (example)
-  const signer = createEd25519Signer(AGENT_SECRET, config.stellar.networkId);
+  const networkId = config.stellar.network?.startsWith('stellar:')
+    ? config.stellar.network
+    : `stellar:${config.stellar.network}`;
+  const signer = createEd25519Signer(AGENT_SECRET, networkId);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const signer = createEd25519Signer(AGENT_SECRET, config.stellar.networkId);
const networkId = config.stellar.network?.startsWith('stellar:')
? config.stellar.network
: `stellar:${config.stellar.network}`;
const signer = createEd25519Signer(AGENT_SECRET, networkId);
🤖 Prompt for 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.

In `@agent/agent.js` at line 133, The createEd25519Signer call in agent/agent.js
is attempting to pass config.stellar.networkId as the network identifier, but
the config contract defined in backend/src/config.js only exposes
stellar.network and stellar.networkPassphrase (not networkId). Update the signer
initialization to use one of the existing config properties (either
stellar.network or stellar.networkPassphrase) that are actually defined in the
config contract, mapping it to the format expected by the createEd25519Signer
function to ensure the signer receives the correct network parameter and
prevents undefined values that would break x402 Stellar payment operations.

LELOUCH-Vii added a commit to LELOUCH-Vii/lodestar that referenced this pull request Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant