Skip to content

feat: custom rpc for interacting with contracts#218

Merged
cristiam86 merged 4 commits intomainfrom
edinaldo/dxp-214-feat-setup-network
Apr 29, 2025
Merged

feat: custom rpc for interacting with contracts#218
cristiam86 merged 4 commits intomainfrom
edinaldo/dxp-214-feat-setup-network

Conversation

@epsjunior
Copy link
Copy Markdown
Contributor

@epsjunior epsjunior commented Apr 28, 2025

Add RPC URL Option to Contract Commands

Summary

This PR adds the ability to specify a custom RPC URL when using the deploy and call commands, allowing users to connect to different networks without modifying the codebase.

Changes

  • Added a new --rpc option to both deploy and call commands in the CLI
  • Extended the DeployOptions and CallOptions interfaces to include an optional rpc parameter
  • Modified the getClient method call to accept the RPC URL parameter throughout the execution flow
  • Added a new DeployScriptsOptions interface for improved type safety
  • Updated the deployScripts method to accept and propagate the RPC URL to script executions
  • Added comprehensive test coverage for the new functionality

Example Usage

# Deploy a contract using a custom RPC URL
genlayer deploy --contract myContract.gpy --rpc https://my-custom-rpc.com

# Call a contract method using a custom RPC URL
genlayer call 0x123456789 getData --rpc https://my-custom-rpc.com

# Deploy scripts using a custom RPC URL
genlayer deploy --rpc https://my-custom-rpc.com

Testing

Added unit tests for:

  • Deploying contracts with a custom RPC URL
  • Executing JS and TS deploy scripts with a custom RPC URL
  • Calling contract read and write methods with a custom RPC URL

All tests are passing. The implementation maintains backward compatibility with existing code.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (12d2faa) to head (0b49629).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #218   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           29        29           
  Lines         1522      1539   +17     
  Branches       381       388    +7     
=========================================
+ Hits          1522      1539   +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@epsjunior epsjunior requested a review from cristiam86 April 28, 2025 12:09
@cristiam86 cristiam86 merged commit 138babd into main Apr 29, 2025
3 checks passed
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.

2 participants