Skip to content

Commit f2ad23a

Browse files
authored
feat(rln)!: generate contract types, migrate from ethers to viem (#2705)
* feat: use wagmi to generate contract types * feat: migrate rln from ethers to viem * fix: remove .gitmodules * fix: update readme * fix: refactor to use a single viem client object * fix: update comments, tsconfig * feat: remove membership event tracking * fix: script name in package.json and readme * fix: only allow linea sepolia * fix: consolidate viem types, typed window * fix: use viem to infer type of decoded event * fix: use js for generate abi script * feat: generate abi and build rln package as release condition * fix: check that eth_requestAccounts returns an array * fix: handle error messages * fix: use https instead of git for cloning in script * fix: add warning annotations for contract typings check * fix: install deps for rln package before building * fix: use pnpm when installing rln contracts * fix: use workspace flag to run abi script * fix: add ref to checkout action * fix: include pnpm in ci
1 parent 788f7e6 commit f2ad23a

25 files changed

+2169
-2158
lines changed

.cspell.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"reactjs",
105105
"recid",
106106
"rlnrelay",
107+
"rlnv",
107108
"roadmap",
108109
"sandboxed",
109110
"scanf",
@@ -132,7 +133,9 @@
132133
"upgrader",
133134
"vacp",
134135
"varint",
136+
"viem",
135137
"vkey",
138+
"wagmi",
136139
"waku",
137140
"wakuconnect",
138141
"wakunode",

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,44 @@ jobs:
113113
node-version: ${{ env.NODE_JS }}
114114
registry-url: "https://registry.npmjs.org"
115115

116+
- uses: pnpm/action-setup@v4
117+
if: ${{ steps.release.outputs.releases_created }}
118+
with:
119+
version: 9
120+
116121
- run: npm install
117122
if: ${{ steps.release.outputs.releases_created }}
118123

119124
- run: npm run build
120125
if: ${{ steps.release.outputs.releases_created }}
121126

127+
- name: Setup Foundry
128+
if: ${{ steps.release.outputs.releases_created }}
129+
uses: foundry-rs/foundry-toolchain@v1
130+
with:
131+
version: nightly
132+
133+
- name: Generate RLN contract ABIs
134+
id: rln-abi
135+
if: ${{ steps.release.outputs.releases_created }}
136+
run: |
137+
npm run setup:contract-abi -w @waku/rln || {
138+
echo "::warning::Failed to generate contract ABIs, marking @waku/rln as private to skip publishing"
139+
cd packages/rln
140+
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); pkg.private = true; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
141+
echo "failed=true" >> $GITHUB_OUTPUT
142+
}
143+
144+
- name: Rebuild with new ABIs
145+
if: ${{ steps.release.outputs.releases_created && steps.rln-abi.outputs.failed != 'true' }}
146+
run: |
147+
npm install -w packages/rln
148+
npm run build -w @waku/rln || {
149+
echo "::warning::Failed to build @waku/rln, marking as private to skip publishing"
150+
cd packages/rln
151+
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); pkg.private = true; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
152+
}
153+
122154
- run: npm run publish
123155
if: ${{ steps.release.outputs.releases_created }}
124156
env:

.github/workflows/pre-release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,46 @@ jobs:
1717
- uses: actions/checkout@v4
1818
with:
1919
repository: waku-org/js-waku
20+
ref: ${{ github.ref }}
2021

2122
- uses: actions/setup-node@v4
2223
with:
2324
node-version: ${{ env.NODE_JS }}
2425
registry-url: "https://registry.npmjs.org"
2526

27+
- uses: pnpm/action-setup@v4
28+
with:
29+
version: 9
30+
2631
- run: npm install
2732

2833
- run: npm run build
2934

35+
- name: Setup Foundry
36+
uses: foundry-rs/foundry-toolchain@v1
37+
with:
38+
version: nightly
39+
40+
- name: Generate RLN contract ABIs
41+
id: rln-abi
42+
run: |
43+
npm run setup:contract-abi -w @waku/rln || {
44+
echo "::warning::Failed to generate contract ABIs, marking @waku/rln as private to skip publishing"
45+
cd packages/rln
46+
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); pkg.private = true; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
47+
echo "failed=true" >> $GITHUB_OUTPUT
48+
}
49+
50+
- name: Rebuild with new ABIs
51+
if: steps.rln-abi.outputs.failed != 'true'
52+
run: |
53+
npm install -w packages/rln
54+
npm run build -w @waku/rln || {
55+
echo "::warning::Failed to build @waku/rln, marking as private to skip publishing"
56+
cd packages/rln
57+
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); pkg.private = true; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
58+
}
59+
3060
- run: npm run publish -- --tag next
3161
env:
3262
NODE_AUTH_TOKEN: ${{ secrets.NPM_JS_WAKU_PUBLISH }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ packages/discovery/mock_local_storage
2020
CLAUDE.md
2121
.env
2222
postgres-data/
23+
packages/rln/waku-rlnv2-contract/

0 commit comments

Comments
 (0)