Skip to content

Conversation

@adklempner
Copy link
Member

@adklempner adklempner commented Oct 24, 2025

Problem / Description

Previous to this, the ABIs for the contracts were manually added to the rln package (not clear how).
Additionally, code related to calling the contracts was not typed, so any breaking changes to the ABI would not be detected at compile time.

Solution

  • Create a script that:
  1. cloneshttps://github.com/waku-org/waku-rlnv2-contract
  2. compiles it
  3. uses the output to generate typesafe ABI code using wagmi

The rest of the code has been updated to use viem, which provides clean and typesafe ways to interact with the smart contracts.

Also adds new methods that were introduced in latest contract changes, specifically the ability to query for merkle root and merkle proof for a commitment directly from the smart contract.

Notes


Checklist

  • Code changes are covered by unit tests.
  • Code changes are covered by e2e tests, if applicable.
  • Dogfooding has been performed, if feasible.
  • A test version has been published, if required.
  • All CI checks pass successfully.

@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 1fcf108 to a88dd8c Compare October 24, 2025 22:43
@github-actions
Copy link

github-actions bot commented Oct 24, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 96.24 KB (0%) 2 s (0%) 1.1 s (+76.4% 🔺) 3 s
Waku Simple Light Node 147.6 KB (0%) 3 s (0%) 705 ms (-3.76% 🔽) 3.7 s
ECIES encryption 22.62 KB (0%) 453 ms (0%) 287 ms (+26.15% 🔺) 739 ms
Symmetric encryption 22 KB (0%) 440 ms (0%) 236 ms (+28.06% 🔺) 676 ms
DNS discovery 52.17 KB (0%) 1.1 s (0%) 494 ms (+65.58% 🔺) 1.6 s
Peer Exchange discovery 52.91 KB (0%) 1.1 s (0%) 372 ms (-29.51% 🔽) 1.5 s
Peer Cache Discovery 46.64 KB (0%) 933 ms (0%) 394 ms (-23.68% 🔽) 1.4 s
Privacy preserving protocols 77.31 KB (0%) 1.6 s (0%) 627 ms (+35.87% 🔺) 2.2 s
Waku Filter 79.82 KB (0%) 1.6 s (0%) 714 ms (-1.34% 🔽) 2.4 s
Waku LightPush 77.97 KB (0%) 1.6 s (0%) 859 ms (+102.61% 🔺) 2.5 s
History retrieval protocols 83.74 KB (0%) 1.7 s (0%) 485 ms (-5% 🔽) 2.2 s
Deterministic Message Hashing 28.98 KB (0%) 580 ms (0%) 227 ms (-5.29% 🔽) 807 ms

@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 264f2c0 to 5ea574e Compare October 27, 2025 20:48
@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch 3 times, most recently from 70922e5 to 7e5680f Compare November 11, 2025 21:42
@adklempner adklempner marked this pull request as ready for review November 12, 2025 03:58
@adklempner adklempner requested a review from a team as a code owner November 12, 2025 03:58
@weboko weboko requested a review from Copilot November 12, 2025 11:52
Copy link

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

This PR migrates the RLN package from ethers.js to viem for Ethereum interactions and introduces automated contract type generation using wagmi CLI. The changes enable type-safe contract interactions by generating TypeScript bindings directly from the smart contract ABIs.

Key changes:

  • Replaced ethers.js with viem for all blockchain interactions
  • Automated ABI generation via wagmi CLI from waku-rlnv2-contract repository
  • Updated all contract interaction code to use viem's type-safe APIs
  • Added new methods for querying merkle root and merkle proof directly from contracts

Reviewed Changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/rln/wagmi.config.ts Configures wagmi CLI to generate TypeScript bindings from Foundry contracts
packages/rln/src/contract/wagmi/generated.ts Auto-generated type-safe contract ABIs (977 lines)
packages/rln/src/contract/rln_base_contract.ts Migrated from ethers Contract to viem getContract with type-safe reads/writes
packages/rln/src/utils/walletClient.ts New utility to create viem client from window.ethereum
packages/rln/src/types.ts Updated to use viem WalletClient instead of ethers.Signer
packages/rln/generate_contract_abi.sh Shell script to clone, build, and generate contract types
packages/rln/package.json Removed ethers dependency, added viem and wagmi tooling

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

Copy link

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 21 out of 23 changed files in this pull request and generated 4 comments.


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

Copy link
Collaborator

@weboko weboko left a comment

Choose a reason for hiding this comment

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

good first iteration

left comments in addition to Copilot's

and make sure you properly integrate it with release CI

Copy link

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 21 out of 23 changed files in this pull request and generated 5 comments.


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

@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 44ad556 to 8221064 Compare November 18, 2025 02:38
@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 0b90116 to 12d56f9 Compare November 21, 2025 18:36
Copy link

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 23 out of 25 changed files in this pull request and generated 7 comments.


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

@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch 2 times, most recently from 2b36cb2 to 4eb4978 Compare November 21, 2025 22:59
@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 4eb4978 to 354dc65 Compare November 21, 2025 23:29
@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 807439a to f7c6831 Compare December 1, 2025 22:13
@adklempner adklempner force-pushed the feat/rln-contract-gen-types branch from 55e2e02 to d1e0074 Compare December 1, 2025 23:52
@adklempner adklempner merged commit f2ad23a into master Dec 2, 2025
10 checks passed
@adklempner adklempner deleted the feat/rln-contract-gen-types branch December 2, 2025 01:32
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(rln): replace manual smart contract classes/functions with generate typings

3 participants