Skip to content

feat: include xHOPR token field#92

Open
QYuQianchen wants to merge 6 commits intomainfrom
q-core-726-handle-the-xhopr-token-in-the-bindings
Open

feat: include xHOPR token field#92
QYuQianchen wants to merge 6 commits intomainfrom
q-core-726-handle-the-xhopr-token-in-the-bindings

Conversation

@QYuQianchen
Copy link
Copy Markdown
Contributor

@QYuQianchen QYuQianchen commented Apr 21, 2026

Description

Closes #78
Include xHOPR token in the contracts-addresses.json, under xhopr_token

Summary by CodeRabbit

  • New Features

    • Added xHOPR token address support across multiple networks (anvil-localhost, jura, debug-staging, rotsee)
  • Chores

    • Crate version bumped to 4.8.0
  • Documentation

    • Clarified deployment script with a note about the xHOPR token contract not being deployed
  • Tests

    • Tightened a fuzz test constraint to avoid a console precompile conflict

Copilot AI review requested due to automatic review settings April 21, 2026 07:03
@linear
Copy link
Copy Markdown

linear Bot commented Apr 21, 2026

@QYuQianchen QYuQianchen self-assigned this Apr 21, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@QYuQianchen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 30 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 39 minutes and 30 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45527518-7a7c-4db4-a102-e60b648526fb

📥 Commits

Reviewing files that changed from the base of the PR and between 30773fd and 10a14fc.

📒 Files selected for processing (2)
  • ethereum/contracts/script/utils/NetworkConfig.s.sol
  • ethereum/contracts/test/Crypto.t.sol
📝 Walkthrough

Walkthrough

Adds xHOPR token address support across bindings and contracts: updates crate version, adds xhopr_token entries in contracts-addresses.json, extends address structs/serialization to include xhopr token, and small related doc/test tweaks.

Changes

Cohort / File(s) Summary
Version bump
ethereum/bindings/Cargo.toml
Bumped crate version from 4.7.4 to 4.8.0.
Contracts address data
ethereum/bindings/contracts-addresses.json
Inserted xhopr_token address entries for networks: anvil-localhost, jura, debug-staging, rotsee.
Bindings types & iteration
ethereum/bindings/src/config.rs
Added xhopr_token: Address to ContractAddresses and included it in the IntoIterator output.
Network config serialization
ethereum/contracts/script/utils/NetworkConfig.s.sol
Added address xhoprTokenContractAddress; to Addresses struct and updated writeNetwork to emit "xhopr_token"; removed displayNetworkDetail/displayCurrentNetworkDetail helpers.
Deployment script comment
ethereum/contracts/script/DeployAll.s.sol
Added inline comment clarifying xHOPR token contract is not deployed during the run sequence.
Test constraint tweak
ethereum/contracts/test/node-stake/permissioned-modules/NodeManagementModule.t.sol
Tightened fuzz input by excluding the console.log precompile address via an added vm.assume.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning One change appears unrelated: removing displayNetworkDetail and displayCurrentNetworkHelper functions in NetworkConfig.s.sol was not required by the linked issue objective. Clarify whether the removal of helper functions is necessary for this feature or if it should be separated into a distinct cleanup PR.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: include xHOPR token field' directly describes the main change: adding an xHOPR token field to the bindings and contracts configuration.
Linked Issues check ✅ Passed The PR addresses issue #78 by adding xHOPR token entries to contracts-addresses.json and updating the ContractAddresses struct in config.rs, enabling xHOPR balances to be queried as required.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch q-core-726-handle-the-xhopr-token-in-the-bindings

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.

@QYuQianchen QYuQianchen added the documentation Improvements or additions to documentation label Apr 21, 2026
@github-actions github-actions Bot added dependencies smart-contracts crate:hopr-bindings and removed documentation Improvements or additions to documentation labels Apr 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for tracking the xHOPR token address in the repository’s generated/checked-in contract address artifacts.

Changes:

  • Extend NetworkConfig to include and (intended to) serialize an xhopr_token address.
  • Add xhopr_token entries to ethereum/bindings/contracts-addresses.json.
  • Bump hopr-bindings crate version to 4.8.0 and update Cargo.lock.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ethereum/contracts/script/utils/NetworkConfig.s.sol Adds an xHOPR address field and attempts to write it into the generated JSON output.
ethereum/contracts/script/DeployAll.s.sol Notes that xHOPR is not deployed by the deploy-all script.
ethereum/bindings/contracts-addresses.json Adds xhopr_token address entries per network.
ethereum/bindings/Cargo.toml Bumps hopr-bindings version to reflect the updated address schema.
Cargo.lock Updates lockfile to the new hopr-bindings version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ethereum/bindings/Cargo.toml
Comment thread ethereum/contracts/script/utils/NetworkConfig.s.sol
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ethereum/contracts/script/utils/NetworkConfig.s.sol (1)

108-121: ⚠️ Potential issue | 🔴 Critical

Move the assignment to capture the final xhopr_token serialization.

The xhopr_token field is not included in the JSON due to improper return value handling. stdJson.serialize returns the accumulated JSON string; only the last captured return value is what gets embedded. Currently:

  • Lines 116–118 capture after winning_probability_oracle
  • Line 119 calls serialize("xhopr_token", ...) but discards the return value
  • Line 121 passes the stale addresses string (missing xhopr_token) to obj.serialize
Proposed fix
-        addresses.serialize("token", networkDetail.addresses.tokenContractAddress);
-        addresses = addresses.serialize(
-            "winning_probability_oracle", networkDetail.addresses.winningProbabilityContractAddress
-        );
-        addresses.serialize("xhopr_token", networkDetail.addresses.xhoprTokenContractAddress);
+        addresses.serialize("token", networkDetail.addresses.tokenContractAddress);
+        addresses.serialize(
+            "winning_probability_oracle", networkDetail.addresses.winningProbabilityContractAddress
+        );
+        addresses = addresses.serialize("xhopr_token", networkDetail.addresses.xhoprTokenContractAddress);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ethereum/contracts/script/utils/NetworkConfig.s.sol` around lines 108 - 121,
The JSON for addresses is missing the xhopr_token because the return value of
stdJson.serialize is ignored; update the chain so the final serialize call is
captured: assign the result of addresses.serialize("xhopr_token",
networkDetail.addresses.xhoprTokenContractAddress) back to addresses (just like
addresses = addresses.serialize("winning_probability_oracle", ...)), then pass
that updated addresses to obj.serialize("addresses", addresses) so the
xhopr_token field is included.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ethereum/bindings/contracts-addresses.json`:
- Around line 13-14: The JSON uses the zero-address for "xhopr_token", which
NetworkConfig.s.sol's isValidAddress treats as invalid and can break logic that
dereferences addresses (e.g., Rust IntoIterator balance queries); either replace
the placeholder with a locally deployed mock xHOPR address and update
contracts-addresses.json to that deployed address, or explicitly
document/implement guards so consumers (and any iteration code) skip address(0)
when reading "xhopr_token" — reference xhopr_token, isValidAddress, and
NetworkConfig.s.sol when adding the change.

In `@ethereum/contracts/script/utils/NetworkConfig.s.sol`:
- Around line 223-232: The vm.writeLine call that emits the
"xhopr_token_contract_address" field in displayNetworkDetail currently appends a
trailing comma which makes the output inconsistent/non-JSON; update the string
passed to vm.writeLine (the abi.encodePacked that builds
'"xhopr_token_contract_address": "' +
vm.toString(networkDetail.addresses.xhoprTokenContractAddress) + '"') to remove
the trailing comma so the field ends with '"' only (and ensure surrounding
fields like announcements_contract_address keep consistent punctuation), i.e.,
delete the '",' suffix or adjust concatenation in the
xhopr_token_contract_address write to not include the comma.

---

Outside diff comments:
In `@ethereum/contracts/script/utils/NetworkConfig.s.sol`:
- Around line 108-121: The JSON for addresses is missing the xhopr_token because
the return value of stdJson.serialize is ignored; update the chain so the final
serialize call is captured: assign the result of
addresses.serialize("xhopr_token",
networkDetail.addresses.xhoprTokenContractAddress) back to addresses (just like
addresses = addresses.serialize("winning_probability_oracle", ...)), then pass
that updated addresses to obj.serialize("addresses", addresses) so the
xhopr_token field is included.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4aa4626-fffa-48c4-be10-a43ccf2b4ba9

📥 Commits

Reviewing files that changed from the base of the PR and between 6c219c6 and 3149c40.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • ethereum/bindings/Cargo.toml
  • ethereum/bindings/contracts-addresses.json
  • ethereum/bindings/src/config.rs
  • ethereum/contracts/script/DeployAll.s.sol
  • ethereum/contracts/script/utils/NetworkConfig.s.sol

Comment thread ethereum/bindings/contracts-addresses.json
Comment thread ethereum/contracts/script/utils/NetworkConfig.s.sol Outdated
Copilot AI review requested due to automatic review settings April 22, 2026 06:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 116 to 121
addresses = addresses.serialize(
"winning_probability_oracle", networkDetail.addresses.winningProbabilityContractAddress
);
addresses.serialize("xhopr_token", networkDetail.addresses.xhoprTokenContractAddress);

obj.serialize("addresses", addresses);
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

In writeNetwork, addresses is used as the objectKey for stdJson.serialize(...) calls. After addresses = addresses.serialize("winning_probability_oracle", ...), the addresses variable now holds the stringified JSON, not the original object key (e.g. "addresses-<network>"). The subsequent addresses.serialize("xhopr_token", ...) therefore writes into a different in-memory object and the returned addresses JSON passed into obj.serialize("addresses", addresses) will not include xhopr_token.

Keep the original object key separate (or delay assigning addresses = ... until the final serialize call) so that xhopr_token is serialized into the same addresses-<network> object and included in the written JSON.

Suggested change
addresses = addresses.serialize(
"winning_probability_oracle", networkDetail.addresses.winningProbabilityContractAddress
);
addresses.serialize("xhopr_token", networkDetail.addresses.xhoprTokenContractAddress);
obj.serialize("addresses", addresses);
addresses.serialize("winning_probability_oracle", networkDetail.addresses.winningProbabilityContractAddress);
string memory serializedAddresses =
addresses.serialize("xhopr_token", networkDetail.addresses.xhoprTokenContractAddress);
obj.serialize("addresses", serializedAddresses);

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 22, 2026 06:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 637 to 663
@@ -659,6 +659,6 @@ contract Crypto is Test, AccountsFixtureTest, HoprCrypto, CryptoUtils {
params.hVx = rx;
params.hVy = ry;

assertFalse(crypto.vrfVerifyProxy(params, payload));
crypto.vrfVerifyProxy(params, payload);
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

vrfVerifyProxy returns bool and only reverts for invalid field elements/curve points/witnesses. In this test you tweak h and update the corresponding witness (hVx/hVy), so the call will likely return false (not revert). With a testFail_ name and no assertion/expectRevert, Foundry will treat this as an unexpected success and the test will fail. Consider restoring an assertFalse(...)-style check (and a non-testFail_ name), or explicitly vm.expectRevert(...) if the intended behavior is to revert.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle the xHOPR token in the bindings

2 participants