Skip to content

feat: enhance Djed-SDK by shipping pre-configured network variables#97

Open
Rav1Chauhan wants to merge 2 commits intoDjedAlliance:mainfrom
Rav1Chauhan:feat/preconfigured-network-variables
Open

feat: enhance Djed-SDK by shipping pre-configured network variables#97
Rav1Chauhan wants to merge 2 commits intoDjedAlliance:mainfrom
Rav1Chauhan:feat/preconfigured-network-variables

Conversation

@Rav1Chauhan
Copy link
Copy Markdown

@Rav1Chauhan Rav1Chauhan commented Mar 11, 2026

Addressed Issues:

Fixes #6

Screenshots/Recordings:

N/A – This change introduces SDK configuration variables and does not affect the UI.

Additional Notes:

This PR enhances the Djed-SDK by introducing pre-configured network variables to improve developer experience.

Previously, developers had to manually configure network-specific variables such as DJED contract addresses when using SDK functions. This update introduces a NETWORKS configuration object that provides predefined variables for supported networks.

Changes included in this PR:

Added NETWORKS configuration in src/constants.js

Exported network variables through src/index.js

Developers can now directly import network configurations from the SDK without manual setup.

Benefits:

Reduces configuration errors

Improves developer experience

Enables faster integration with the SDK

Checklist

  • [ x] My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • [x ] My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • [ x] My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • [x ] I have read the Contribution Guidelines
  • [ x] Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.

AI Usage Disclosure

Check one of the checkboxes below:

  • [ x] This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Summary by CodeRabbit

  • New Features
    • Network configuration support added for Sepolia and Mainnet, with a default to Sepolia.
    • Runtime validation when retrieving a network config; requesting an unsupported network returns an error.
    • Network configs are now exposed from the SDK’s public entry so they’re available to consumers.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

Adds exported pre-configured network variables and a helper to retrieve them: a NETWORKS constant with sepolia and mainnet entries and a getNetworkConfig(networkName) function; these are re-exported from the SDK entry point.

Changes

Cohort / File(s) Summary
Network Configuration
djed-sdk/src/constants.js
Added export const NETWORKS with sepolia and mainnet configs and export const getNetworkConfig(networkName = "sepolia") which returns matching config or throws for unsupported networks. Minor non-functional formatting adjustments.
Public API Export
djed-sdk/src/index.js
Added export * from "./constants" to expose network constants and helper via the main SDK entry point.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 I found the nets all set and neat,
Sepolia and mainnet ready to meet.
No more hunting addresses at night,
Prewired configs hopping into sight,
Djed SDK—now tidy and bright! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding pre-configured network variables to enhance the Djed-SDK for easier developer integration.
Linked Issues check ✅ Passed The PR implements all requirements from issue #6: exports pre-configured NETWORKS object with network configurations and getNetworkConfig function, enabling developers to directly import network variables without manual setup.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the objective to ship pre-configured network variables. Minor formatting adjustments (FEE_UI spacing, TRANSACTION_VALIDITY reflow) are non-functional and within scope.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@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 `@djed-sdk/src/constants.js`:
- Around line 24-39: The NETWORKS constant contains invalid placeholder Ethereum
addresses and incomplete Infura RPC URLs which will break runtime contract
instantiation; update NETWORKS (the sepolia and mainnet entries: djedAddress,
oracleAddress, rpcUrl) by either (A) replacing the placeholder hex strings with
the actual deployed contract addresses and full RPC URLs (including the Infura
project id) or (B) explicitly mark them as configurable (e.g., set djedAddress
and oracleAddress to null) and add JSDoc/comments and runtime validation that
throws a clear error if NETWORKS.*.djedAddress or oracleAddress or rpcUrl are
missing so consumers must provide real values before calling any
contract-related code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e111cf1-7ac9-4bf9-a826-e37cc0de4b2c

📥 Commits

Reviewing files that changed from the base of the PR and between 509e7d3 and 440e879.

📒 Files selected for processing (2)
  • djed-sdk/src/constants.js
  • djed-sdk/src/index.js

Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
djed-sdk/src/constants.js (1)

24-50: ⚠️ Potential issue | 🟠 Major

NETWORKS is still a template, not a usable pre-configured SDK config.

Both entries leave rpcUrl, djedAddress, and oracleAddress as null, and getNetworkConfig() returns them unchanged. That means callers still need to manually supply every runtime-critical value before getWeb3, getDjedContract, or getOracleContract can work, so this doesn’t yet deliver the “pre-configured network variables” promised by the PR. If real deployed values cannot be shipped here, the helper should at least merge explicit overrides and fail fast with a clear error instead of returning an unusable config.

Suggested direction
 export const NETWORKS = {
   sepolia: {
     name: "Sepolia",
     chainId: 11155111,
     rpcUrl: null,
     djedAddress: null,
     oracleAddress: null
   },

   mainnet: {
     name: "Ethereum Mainnet",
     chainId: 1,
     rpcUrl: null,
     djedAddress: null,
     oracleAddress: null
   }
 };

-export const getNetworkConfig = (networkName = "sepolia") => {
-  const config = NETWORKS[networkName];
+export const getNetworkConfig = (networkName = "sepolia", overrides = {}) => {
+  const config = NETWORKS[networkName];

   if (!config) {
     throw new Error(`Unsupported network: ${networkName}`);
   }

-  return config;
+  const resolvedConfig = { ...config, ...overrides };
+
+  if (!resolvedConfig.rpcUrl || !resolvedConfig.djedAddress || !resolvedConfig.oracleAddress) {
+    throw new Error(
+      `Network "${networkName}" is incomplete. Provide rpcUrl, djedAddress, and oracleAddress.`
+    );
+  }
+
+  return resolvedConfig;
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@djed-sdk/src/constants.js` around lines 24 - 50, getNetworkConfig currently
returns template entries from NETWORKS with rpcUrl, djedAddress, and
oracleAddress left null; update getNetworkConfig(networkName = "sepolia",
overrides = {}) to merge NETWORKS[networkName] with the overrides object
(Object.assign or spread) and then validate required keys (rpcUrl, djedAddress,
oracleAddress) on the merged config; if any are missing or falsy, throw a clear
Error naming the missing fields so callers fail fast instead of receiving an
unusable config. Use the NETWORKS constant and function getNetworkConfig as the
reference points to implement the merge-and-validate behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@djed-sdk/src/constants.js`:
- Around line 24-50: getNetworkConfig currently returns template entries from
NETWORKS with rpcUrl, djedAddress, and oracleAddress left null; update
getNetworkConfig(networkName = "sepolia", overrides = {}) to merge
NETWORKS[networkName] with the overrides object (Object.assign or spread) and
then validate required keys (rpcUrl, djedAddress, oracleAddress) on the merged
config; if any are missing or falsy, throw a clear Error naming the missing
fields so callers fail fast instead of receiving an unusable config. Use the
NETWORKS constant and function getNetworkConfig as the reference points to
implement the merge-and-validate behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83119050-7fac-4076-9720-8d573fa606b0

📥 Commits

Reviewing files that changed from the base of the PR and between 440e879 and a4f7250.

📒 Files selected for processing (1)
  • djed-sdk/src/constants.js

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.

feat: Enhance Djed-SDK by Shipping Pre-configured Network Variables

1 participant