diff --git a/.gitignore b/.gitignore index 1e6952cf2f..188172b1d3 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ packages/discovery/mock_local_storage CLAUDE.md .env postgres-data/ +packages/rln/waku-rlnv2-contract/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..31530f9b50 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "packages/rln/waku-rlnv2-contract"] + path = packages/rln/waku-rlnv2-contract + url = git@github.com:waku-org/waku-rlnv2-contract.git diff --git a/package-lock.json b/package-lock.json index 9bc9d3b4ed..0f5db83b83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,6 +52,13 @@ "wscat": "^6.0.1" } }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz", + "integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -7532,6 +7539,118 @@ "integrity": "sha512-CabR+UN630VnsJO/jHWYBC1YVXyMq94KKp6iF5MQgZJs5I8cmjw6oVMO1oDbtBkENSHSSn/UadWlW/OAgdmKrg==", "license": "MIT" }, + "node_modules/@wagmi/cli": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@wagmi/cli/-/cli-2.7.0.tgz", + "integrity": "sha512-M0FDVK2/mQSOJne3nG7GiZrecw069GYFY6YGQZbG9IyxPgfOHRgVBvGkeXzGXmb3ezFlzn5jCCIQ2q/9lYh07g==", + "dev": true, + "license": "MIT", + "dependencies": { + "abitype": "^1.0.4", + "bundle-require": "^5.1.0", + "cac": "^6.7.14", + "change-case": "^5.4.4", + "chokidar": "4.0.1", + "dedent": "^0.7.0", + "dotenv": "^16.3.1", + "dotenv-expand": "^10.0.0", + "esbuild": "~0.25.4", + "escalade": "3.2.0", + "fdir": "^6.1.1", + "nanospinner": "1.2.2", + "pathe": "^1.1.2", + "picocolors": "^1.0.0", + "picomatch": "^3.0.0", + "prettier": "^3.0.3", + "viem": "2.x", + "zod": "^4.1.11" + }, + "bin": { + "wagmi": "dist/esm/cli.js" + }, + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@wagmi/cli/node_modules/chokidar": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.1.tgz", + "integrity": "sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@wagmi/cli/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/@wagmi/cli/node_modules/picomatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz", + "integrity": "sha512-I3EurrIQMlRc9IaAZnqRR044Phh2DXY+55o7uJ0V+hYZAcQYSuFWsc9q5PvyDHUSCe1Qxn/iBz+78s86zWnGag==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@wagmi/cli/node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@wagmi/cli/node_modules/zod": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz", + "integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, "node_modules/@waku/browser-tests": { "resolved": "packages/browser-tests", "link": true @@ -7840,6 +7959,28 @@ "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", "license": "BSD-2-Clause" }, + "node_modules/abitype": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.1.1.tgz", + "integrity": "sha512-Loe5/6tAgsBukY95eGaPSDmQHIjRZYQq8PB1MpsNccDIK8WiV+Uw6WzaIXipvaxTEL2yEB0OpEaQv3gs8pkS9Q==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3.22.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -10658,6 +10799,22 @@ "node": ">=10.0.0" } }, + "node_modules/bundle-require": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz", + "integrity": "sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "load-tsconfig": "^0.2.3" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "peerDependencies": { + "esbuild": ">=0.18" + } + }, "node_modules/byline": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz", @@ -10720,6 +10877,16 @@ } } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/cacheable-lookup": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz", @@ -11066,6 +11233,13 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/change-case": { + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", + "integrity": "sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==", + "dev": true, + "license": "MIT" + }, "node_modules/char-regex": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", @@ -12514,6 +12688,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", + "dev": true, + "license": "MIT" + }, "node_modules/deep-eql": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", @@ -13151,6 +13332,29 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-expand": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz", + "integrity": "sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -17891,6 +18095,22 @@ "whatwg-fetch": "^3.4.1" } }, + "node_modules/isows": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", + "integrity": "sha512-I1fSfDCZL5P0v33sVqeTDSpcstAg/N+wF5HS033mogOVIp4B+oHC7oOCsA3axAbBSGTJ8QubbNmnIRN/h8U7hg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -19603,6 +19823,16 @@ "node": ">=4" } }, + "node_modules/load-tsconfig": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/load-tsconfig/-/load-tsconfig-0.2.5.tgz", + "integrity": "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", @@ -25572,6 +25802,60 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/ox": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.9.6.tgz", + "integrity": "sha512-8SuCbHPvv2eZLYXrNmC0EC12rdzXQLdhnOMlHDW2wiCPLxBrOOJwX5L5E61by+UjTPOryqQiRSnjIKCI+GykKg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.0.9", + "eventemitter3": "5.0.1" + }, + "peerDependencies": { + "typescript": ">=5.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/ox/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/ox/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "dev": true, + "license": "MIT" + }, "node_modules/p-cancelable": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-4.0.1.tgz", @@ -26233,6 +26517,13 @@ "inherits": "2.0.3" } }, + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true, + "license": "MIT" + }, "node_modules/pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -26959,7 +27250,6 @@ "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -32965,6 +33255,97 @@ "node": ">= 0.8" } }, + "node_modules/viem": { + "version": "2.38.3", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.3.tgz", + "integrity": "sha512-By2TutLv07iNHHtWqHHzjGipevYsfGqT7KQbGEmqLco1qTJxKnvBbSviqiu6/v/9REV6Q/FpmIxf2Z7/l5AbcQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@noble/curves": "1.9.1", + "@noble/hashes": "1.8.0", + "@scure/bip32": "1.7.0", + "@scure/bip39": "1.6.0", + "abitype": "1.1.0", + "isows": "1.0.7", + "ox": "0.9.6", + "ws": "8.18.3" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/abitype": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.1.0.tgz", + "integrity": "sha512-6Vh4HcRxNMLA0puzPjM5GBgT4aAcFGKZzSgAXvuZ27shJP6NEpielTuqbBmZILR5/xd0PizkBGy5hReKz9jl5A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3.22.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -35114,6 +35495,7 @@ "@types/deep-equal-in-any-order": "^1.0.4", "@types/lodash": "^4.17.15", "@types/sinon": "^17.0.3", + "@wagmi/cli": "^2.7.0", "@waku/build-utils": "^1.0.0", "@waku/interfaces": "0.0.34", "@waku/message-encryption": "^0.0.38", diff --git a/packages/rln/.eslintrc.cjs b/packages/rln/.eslintrc.cjs index c49a7edc19..eb0b4b9fae 100644 --- a/packages/rln/.eslintrc.cjs +++ b/packages/rln/.eslintrc.cjs @@ -3,5 +3,13 @@ module.exports = { tsconfigRootDir: __dirname, project: "./tsconfig.dev.json" }, - ignorePatterns: ["src/resources/**/*"] + ignorePatterns: ["src/resources/**/*"], + overrides: [ + { + files: ["*.config.ts", "*.config.js"], + rules: { + "import/no-extraneous-dependencies": ["error", { "devDependencies": true }] + } + } + ] }; diff --git a/packages/rln/package.json b/packages/rln/package.json index 6d1962b6a0..1c3e524ad4 100644 --- a/packages/rln/package.json +++ b/packages/rln/package.json @@ -43,7 +43,9 @@ "watch:build": "tsc -p tsconfig.json -w", "watch:test": "mocha --watch", "prepublish": "npm run build", - "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" + "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", + "setup:contract-abi": "./setup-contract-abi.sh", + "generate:contract": "npx wagmi generate" }, "engines": { "node": ">=22" @@ -59,7 +61,8 @@ "@types/lodash": "^4.17.15", "@types/sinon": "^17.0.3", "@waku/build-utils": "^1.0.0", - "@waku/message-encryption": "^0.0.38", + "@waku/message-encryption": "^0.0.37", + "@wagmi/cli": "^2.7.0", "deep-equal-in-any-order": "^2.0.6", "fast-check": "^3.23.2", "rollup-plugin-copy": "^3.5.0" diff --git a/packages/rln/setup-contract-abi.sh b/packages/rln/setup-contract-abi.sh new file mode 100755 index 0000000000..73061023cc --- /dev/null +++ b/packages/rln/setup-contract-abi.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SUBMODULE_DIR="$SCRIPT_DIR/waku-rlnv2-contract" + +echo "Setting up waku-rlnv2-contract submodule..." + +# Initialize submodule if needed +if [ ! -d "$SUBMODULE_DIR/.git" ]; then + echo "Initializing submodule..." + cd "$SCRIPT_DIR/../.." + git submodule update --init --recursive packages/rln/waku-rlnv2-contract +fi + +# Install dependencies +echo "Installing submodule dependencies..." +cd "$SUBMODULE_DIR" +npm install + +# Build contracts with Foundry +echo "Building contracts with Foundry..." +forge build + +# Generate ABIs +echo "Generating contract ABIs..." +cd "$SCRIPT_DIR" +npx wagmi generate + +echo "✅ Contract ABI setup complete!" diff --git a/packages/rln/src/contract/abi/price_calculator.ts b/packages/rln/src/contract/abi/price_calculator.ts deleted file mode 100644 index 8199e7764b..0000000000 --- a/packages/rln/src/contract/abi/price_calculator.ts +++ /dev/null @@ -1,93 +0,0 @@ -export const PRICE_CALCULATOR_ABI = [ - { - inputs: [ - { internalType: "address", name: "_token", type: "address" }, - { - internalType: "uint256", - name: "_pricePerMessagePerEpoch", - type: "uint256" - } - ], - stateMutability: "nonpayable", - type: "constructor" - }, - { inputs: [], name: "OnlyTokensAllowed", type: "error" }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address" - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address" - } - ], - name: "OwnershipTransferred", - type: "event" - }, - { - inputs: [{ internalType: "uint32", name: "_rateLimit", type: "uint32" }], - name: "calculate", - outputs: [ - { internalType: "address", name: "", type: "address" }, - { internalType: "uint256", name: "", type: "uint256" } - ], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "owner", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "pricePerMessagePerEpoch", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "_token", type: "address" }, - { - internalType: "uint256", - name: "_pricePerMessagePerEpoch", - type: "uint256" - } - ], - name: "setTokenAndPrice", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [], - name: "token", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [{ internalType: "address", name: "newOwner", type: "address" }], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function" - } -]; diff --git a/packages/rln/src/contract/abi/rln.ts b/packages/rln/src/contract/abi/rln.ts deleted file mode 100644 index 858ec25de5..0000000000 --- a/packages/rln/src/contract/abi/rln.ts +++ /dev/null @@ -1,646 +0,0 @@ -export const RLN_ABI = [ - { inputs: [], stateMutability: "nonpayable", type: "constructor" }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "CannotEraseActiveMembership", - type: "error" - }, - { inputs: [], name: "CannotExceedMaxTotalRateLimit", type: "error" }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "CannotExtendNonGracePeriodMembership", - type: "error" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "InvalidIdCommitment", - type: "error" - }, - { inputs: [], name: "InvalidMembershipRateLimit", type: "error" }, - { - inputs: [ - { internalType: "uint256", name: "startIndex", type: "uint256" }, - { internalType: "uint256", name: "endIndex", type: "uint256" } - ], - name: "InvalidPaginationQuery", - type: "error" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "MembershipDoesNotExist", - type: "error" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "NonHolderCannotEraseGracePeriodMembership", - type: "error" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "NonHolderCannotExtend", - type: "error" - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "address", - name: "previousAdmin", - type: "address" - }, - { - indexed: false, - internalType: "address", - name: "newAdmin", - type: "address" - } - ], - name: "AdminChanged", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "beacon", - type: "address" - } - ], - name: "BeaconUpgraded", - type: "event" - }, - { - anonymous: false, - inputs: [ - { indexed: false, internalType: "uint8", name: "version", type: "uint8" } - ], - name: "Initialized", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "idCommitment", - type: "uint256" - }, - { - indexed: false, - internalType: "uint32", - name: "membershipRateLimit", - type: "uint32" - }, - { indexed: false, internalType: "uint32", name: "index", type: "uint32" } - ], - name: "MembershipErased", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "idCommitment", - type: "uint256" - }, - { - indexed: false, - internalType: "uint32", - name: "membershipRateLimit", - type: "uint32" - }, - { indexed: false, internalType: "uint32", name: "index", type: "uint32" } - ], - name: "MembershipExpired", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "idCommitment", - type: "uint256" - }, - { - indexed: false, - internalType: "uint32", - name: "membershipRateLimit", - type: "uint32" - }, - { indexed: false, internalType: "uint32", name: "index", type: "uint32" }, - { - indexed: false, - internalType: "uint256", - name: "newGracePeriodStartTimestamp", - type: "uint256" - } - ], - name: "MembershipExtended", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "idCommitment", - type: "uint256" - }, - { - indexed: false, - internalType: "uint256", - name: "membershipRateLimit", - type: "uint256" - }, - { indexed: false, internalType: "uint32", name: "index", type: "uint32" } - ], - name: "MembershipRegistered", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address" - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address" - } - ], - name: "OwnershipTransferred", - type: "event" - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "implementation", - type: "address" - } - ], - name: "Upgraded", - type: "event" - }, - { - inputs: [], - name: "MAX_MEMBERSHIP_SET_SIZE", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "MERKLE_TREE_DEPTH", - outputs: [{ internalType: "uint8", name: "", type: "uint8" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "Q", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "activeDurationForNewMemberships", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "currentTotalRateLimit", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "deployedBlockNumber", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "holder", type: "address" }, - { internalType: "address", name: "token", type: "address" } - ], - name: "depositsToWithdraw", - outputs: [{ internalType: "uint256", name: "balance", type: "uint256" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256[]", name: "idCommitments", type: "uint256[]" } - ], - name: "eraseMemberships", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "uint256[]", name: "idCommitments", type: "uint256[]" }, - { internalType: "bool", name: "eraseFromMembershipSet", type: "bool" } - ], - name: "eraseMemberships", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "uint256[]", name: "idCommitments", type: "uint256[]" } - ], - name: "extendMemberships", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "getMembershipInfo", - outputs: [ - { internalType: "uint32", name: "", type: "uint32" }, - { internalType: "uint32", name: "", type: "uint32" }, - { internalType: "uint256", name: "", type: "uint256" } - ], - stateMutability: "view", - type: "function" - }, - { - inputs: [{ internalType: "uint40", name: "index", type: "uint40" }], - name: "getMerkleProof", - outputs: [{ internalType: "uint256[20]", name: "", type: "uint256[20]" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint32", name: "startIndex", type: "uint32" }, - { internalType: "uint32", name: "endIndex", type: "uint32" } - ], - name: "getRateCommitmentsInRangeBoundsInclusive", - outputs: [{ internalType: "uint256[]", name: "", type: "uint256[]" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "gracePeriodDurationForNewMemberships", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [{ internalType: "uint256", name: "", type: "uint256" }], - name: "indicesOfLazilyErasedMemberships", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "_priceCalculator", type: "address" }, - { internalType: "uint32", name: "_maxTotalRateLimit", type: "uint32" }, - { - internalType: "uint32", - name: "_minMembershipRateLimit", - type: "uint32" - }, - { - internalType: "uint32", - name: "_maxMembershipRateLimit", - type: "uint32" - }, - { internalType: "uint32", name: "_activeDuration", type: "uint32" }, - { internalType: "uint32", name: "_gracePeriod", type: "uint32" } - ], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "_idCommitment", type: "uint256" } - ], - name: "isExpired", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "_idCommitment", type: "uint256" } - ], - name: "isInGracePeriod", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "isInMembershipSet", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "isValidIdCommitment", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "pure", - type: "function" - }, - { - inputs: [{ internalType: "uint32", name: "rateLimit", type: "uint32" }], - name: "isValidMembershipRateLimit", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "maxMembershipRateLimit", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "maxTotalRateLimit", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "_idCommitment", type: "uint256" } - ], - name: "membershipExpirationTimestamp", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" } - ], - name: "memberships", - outputs: [ - { internalType: "uint256", name: "depositAmount", type: "uint256" }, - { internalType: "uint32", name: "activeDuration", type: "uint32" }, - { - internalType: "uint256", - name: "gracePeriodStartTimestamp", - type: "uint256" - }, - { internalType: "uint32", name: "gracePeriodDuration", type: "uint32" }, - { internalType: "uint32", name: "rateLimit", type: "uint32" }, - { internalType: "uint32", name: "index", type: "uint32" }, - { internalType: "address", name: "holder", type: "address" }, - { internalType: "address", name: "token", type: "address" } - ], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "merkleTree", - outputs: [ - { internalType: "uint40", name: "maxIndex", type: "uint40" }, - { internalType: "uint40", name: "numberOfLeaves", type: "uint40" } - ], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "minMembershipRateLimit", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "nextFreeIndex", - outputs: [{ internalType: "uint32", name: "", type: "uint32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "owner", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "priceCalculator", - outputs: [ - { internalType: "contract IPriceCalculator", name: "", type: "address" } - ], - stateMutability: "view", - type: "function" - }, - { - inputs: [], - name: "proxiableUUID", - outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { internalType: "uint256", name: "idCommitment", type: "uint256" }, - { internalType: "uint32", name: "rateLimit", type: "uint32" }, - { - internalType: "uint256[]", - name: "idCommitmentsToErase", - type: "uint256[]" - } - ], - name: "register", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "owner", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - { internalType: "uint8", name: "v", type: "uint8" }, - { internalType: "bytes32", name: "r", type: "bytes32" }, - { internalType: "bytes32", name: "s", type: "bytes32" }, - { internalType: "uint256", name: "idCommitment", type: "uint256" }, - { internalType: "uint32", name: "rateLimit", type: "uint32" }, - { - internalType: "uint256[]", - name: "idCommitmentsToErase", - type: "uint256[]" - } - ], - name: "registerWithPermit", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [], - name: "root", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function" - }, - { - inputs: [ - { - internalType: "uint32", - name: "_activeDurationForNewMembership", - type: "uint32" - } - ], - name: "setActiveDuration", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { - internalType: "uint32", - name: "_gracePeriodDurationForNewMembership", - type: "uint32" - } - ], - name: "setGracePeriodDuration", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { - internalType: "uint32", - name: "_maxMembershipRateLimit", - type: "uint32" - } - ], - name: "setMaxMembershipRateLimit", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "uint32", name: "_maxTotalRateLimit", type: "uint32" } - ], - name: "setMaxTotalRateLimit", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { - internalType: "uint32", - name: "_minMembershipRateLimit", - type: "uint32" - } - ], - name: "setMinMembershipRateLimit", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "_priceCalculator", type: "address" } - ], - name: "setPriceCalculator", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [{ internalType: "address", name: "newOwner", type: "address" }], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "newImplementation", type: "address" } - ], - name: "upgradeTo", - outputs: [], - stateMutability: "nonpayable", - type: "function" - }, - { - inputs: [ - { internalType: "address", name: "newImplementation", type: "address" }, - { internalType: "bytes", name: "data", type: "bytes" } - ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", - type: "function" - }, - { - inputs: [{ internalType: "address", name: "token", type: "address" }], - name: "withdraw", - outputs: [], - stateMutability: "nonpayable", - type: "function" - } -]; diff --git a/packages/rln/src/contract/constants.ts b/packages/rln/src/contract/constants.ts index 7869e65bc6..9e895424d1 100644 --- a/packages/rln/src/contract/constants.ts +++ b/packages/rln/src/contract/constants.ts @@ -1,16 +1,15 @@ -import { PRICE_CALCULATOR_ABI } from "./abi/price_calculator.js"; -import { RLN_ABI } from "./abi/rln.js"; +import { linearPriceCalculatorAbi, wakuRlnV2Abi } from "./wagmi/generated.js"; export const RLN_CONTRACT = { chainId: 59141, address: "0xb9cd878c90e49f797b4431fbf4fb333108cb90e6", - abi: RLN_ABI + abi: wakuRlnV2Abi }; export const PRICE_CALCULATOR_CONTRACT = { chainId: 59141, address: "0xBcfC0660Df69f53ab409F32bb18A3fb625fcE644", - abi: PRICE_CALCULATOR_ABI + abi: linearPriceCalculatorAbi }; /** diff --git a/packages/rln/src/contract/rln_base_contract.ts b/packages/rln/src/contract/rln_base_contract.ts index 9934360be3..db6481ec76 100644 --- a/packages/rln/src/contract/rln_base_contract.ts +++ b/packages/rln/src/contract/rln_base_contract.ts @@ -4,11 +4,11 @@ import { ethers } from "ethers"; import { IdentityCredential } from "../identity.js"; import { DecryptedCredentials } from "../keystore/types.js"; -import { RLN_ABI } from "./abi/rln.js"; import { DEFAULT_RATE_LIMIT, PRICE_CALCULATOR_CONTRACT, - RATE_LIMIT_PARAMS + RATE_LIMIT_PARAMS, + RLN_CONTRACT } from "./constants.js"; import { CustomQueryOptions, @@ -47,7 +47,8 @@ export class RLNBaseContract { log.info("Initializing RLNBaseContract", { address, rateLimit }); - this.contract = contract || new ethers.Contract(address, RLN_ABI, signer); + this.contract = + contract || new ethers.Contract(address, RLN_CONTRACT.abi, signer); this.rateLimit = rateLimit; try { diff --git a/packages/rln/src/contract/wagmi/generated.ts b/packages/rln/src/contract/wagmi/generated.ts new file mode 100644 index 0000000000..f13fa0c2ce --- /dev/null +++ b/packages/rln/src/contract/wagmi/generated.ts @@ -0,0 +1,977 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// IPriceCalculator +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const iPriceCalculatorAbi = [ + { + type: "function", + inputs: [{ name: "_rateLimit", internalType: "uint32", type: "uint32" }], + name: "calculate", + outputs: [ + { name: "", internalType: "address", type: "address" }, + { name: "", internalType: "uint256", type: "uint256" } + ], + stateMutability: "view" + } +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// LinearPriceCalculator +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const linearPriceCalculatorAbi = [ + { + type: "constructor", + inputs: [ + { name: "_token", internalType: "address", type: "address" }, + { + name: "_pricePerMessagePerEpoch", + internalType: "uint256", + type: "uint256" + } + ], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [{ name: "_rateLimit", internalType: "uint32", type: "uint32" }], + name: "calculate", + outputs: [ + { name: "", internalType: "address", type: "address" }, + { name: "", internalType: "uint256", type: "uint256" } + ], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "pricePerMessagePerEpoch", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "_token", internalType: "address", type: "address" }, + { + name: "_pricePerMessagePerEpoch", + internalType: "uint256", + type: "uint256" + } + ], + name: "setTokenAndPrice", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [], + name: "token", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [{ name: "newOwner", internalType: "address", type: "address" }], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "previousOwner", + internalType: "address", + type: "address", + indexed: true + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true + } + ], + name: "OwnershipTransferred" + }, + { type: "error", inputs: [], name: "OnlyTokensAllowed" } +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// MembershipUpgradeable +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const membershipUpgradeableAbi = [ + { + type: "function", + inputs: [], + name: "activeDurationForNewMemberships", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "currentTotalRateLimit", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "holder", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" } + ], + name: "depositsToWithdraw", + outputs: [{ name: "balance", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "gracePeriodDurationForNewMemberships", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "indicesOfLazilyErasedMemberships", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "_idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "isExpired", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "_idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "isInGracePeriod", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [{ name: "rateLimit", internalType: "uint32", type: "uint32" }], + name: "isValidMembershipRateLimit", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "maxMembershipRateLimit", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "maxTotalRateLimit", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "_idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "membershipExpirationTimestamp", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "memberships", + outputs: [ + { name: "depositAmount", internalType: "uint256", type: "uint256" }, + { name: "activeDuration", internalType: "uint32", type: "uint32" }, + { + name: "gracePeriodStartTimestamp", + internalType: "uint256", + type: "uint256" + }, + { name: "gracePeriodDuration", internalType: "uint32", type: "uint32" }, + { name: "rateLimit", internalType: "uint32", type: "uint32" }, + { name: "index", internalType: "uint32", type: "uint32" }, + { name: "holder", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" } + ], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "minMembershipRateLimit", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "nextFreeIndex", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "priceCalculator", + outputs: [ + { name: "", internalType: "contract IPriceCalculator", type: "address" } + ], + stateMutability: "view" + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "version", internalType: "uint8", type: "uint8", indexed: false } + ], + name: "Initialized" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint32", + type: "uint32", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false } + ], + name: "MembershipErased" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint32", + type: "uint32", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false } + ], + name: "MembershipExpired" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint32", + type: "uint32", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false }, + { + name: "newGracePeriodStartTimestamp", + internalType: "uint256", + type: "uint256", + indexed: false + } + ], + name: "MembershipExtended" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false } + ], + name: "MembershipRegistered" + } +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// WakuRlnV2 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const wakuRlnV2Abi = [ + { type: "constructor", inputs: [], stateMutability: "nonpayable" }, + { + type: "function", + inputs: [], + name: "MAX_MEMBERSHIP_SET_SIZE", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "MERKLE_TREE_DEPTH", + outputs: [{ name: "", internalType: "uint8", type: "uint8" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "Q", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "activeDurationForNewMemberships", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "currentTotalRateLimit", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "deployedBlockNumber", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "holder", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" } + ], + name: "depositsToWithdraw", + outputs: [{ name: "balance", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "idCommitments", internalType: "uint256[]", type: "uint256[]" } + ], + name: "eraseMemberships", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "idCommitments", internalType: "uint256[]", type: "uint256[]" }, + { name: "eraseFromMembershipSet", internalType: "bool", type: "bool" } + ], + name: "eraseMemberships", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "idCommitments", internalType: "uint256[]", type: "uint256[]" } + ], + name: "extendMemberships", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "getMembershipInfo", + outputs: [ + { name: "", internalType: "uint32", type: "uint32" }, + { name: "", internalType: "uint32", type: "uint32" }, + { name: "", internalType: "uint256", type: "uint256" } + ], + stateMutability: "view" + }, + { + type: "function", + inputs: [{ name: "index", internalType: "uint40", type: "uint40" }], + name: "getMerkleProof", + outputs: [{ name: "", internalType: "uint256[20]", type: "uint256[20]" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "startIndex", internalType: "uint32", type: "uint32" }, + { name: "endIndex", internalType: "uint32", type: "uint32" } + ], + name: "getRateCommitmentsInRangeBoundsInclusive", + outputs: [{ name: "", internalType: "uint256[]", type: "uint256[]" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "gracePeriodDurationForNewMemberships", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "indicesOfLazilyErasedMemberships", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "_priceCalculator", internalType: "address", type: "address" }, + { name: "_maxTotalRateLimit", internalType: "uint32", type: "uint32" }, + { + name: "_minMembershipRateLimit", + internalType: "uint32", + type: "uint32" + }, + { + name: "_maxMembershipRateLimit", + internalType: "uint32", + type: "uint32" + }, + { name: "_activeDuration", internalType: "uint32", type: "uint32" }, + { name: "_gracePeriod", internalType: "uint32", type: "uint32" } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "_idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "isExpired", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "_idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "isInGracePeriod", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "isInMembershipSet", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "isValidIdCommitment", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "pure" + }, + { + type: "function", + inputs: [{ name: "rateLimit", internalType: "uint32", type: "uint32" }], + name: "isValidMembershipRateLimit", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "maxMembershipRateLimit", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "maxTotalRateLimit", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "_idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "membershipExpirationTimestamp", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "memberships", + outputs: [ + { name: "depositAmount", internalType: "uint256", type: "uint256" }, + { name: "activeDuration", internalType: "uint32", type: "uint32" }, + { + name: "gracePeriodStartTimestamp", + internalType: "uint256", + type: "uint256" + }, + { name: "gracePeriodDuration", internalType: "uint32", type: "uint32" }, + { name: "rateLimit", internalType: "uint32", type: "uint32" }, + { name: "index", internalType: "uint32", type: "uint32" }, + { name: "holder", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" } + ], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "merkleTree", + outputs: [ + { name: "maxIndex", internalType: "uint40", type: "uint40" }, + { name: "numberOfLeaves", internalType: "uint40", type: "uint40" } + ], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "minMembershipRateLimit", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "nextFreeIndex", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "priceCalculator", + outputs: [ + { name: "", internalType: "contract IPriceCalculator", type: "address" } + ], + stateMutability: "view" + }, + { + type: "function", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" }, + { name: "rateLimit", internalType: "uint32", type: "uint32" }, + { + name: "idCommitmentsToErase", + internalType: "uint256[]", + type: "uint256[]" + } + ], + name: "register", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [], + name: "root", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view" + }, + { + type: "function", + inputs: [ + { + name: "_activeDurationForNewMembership", + internalType: "uint32", + type: "uint32" + } + ], + name: "setActiveDuration", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { + name: "_gracePeriodDurationForNewMembership", + internalType: "uint32", + type: "uint32" + } + ], + name: "setGracePeriodDuration", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { + name: "_maxMembershipRateLimit", + internalType: "uint32", + type: "uint32" + } + ], + name: "setMaxMembershipRateLimit", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "_maxTotalRateLimit", internalType: "uint32", type: "uint32" } + ], + name: "setMaxTotalRateLimit", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { + name: "_minMembershipRateLimit", + internalType: "uint32", + type: "uint32" + } + ], + name: "setMinMembershipRateLimit", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "_priceCalculator", internalType: "address", type: "address" } + ], + name: "setPriceCalculator", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [{ name: "newOwner", internalType: "address", type: "address" }], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable" + }, + { + type: "function", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "previousAdmin", + internalType: "address", + type: "address", + indexed: false + }, + { + name: "newAdmin", + internalType: "address", + type: "address", + indexed: false + } + ], + name: "AdminChanged" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "beacon", + internalType: "address", + type: "address", + indexed: true + } + ], + name: "BeaconUpgraded" + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "version", internalType: "uint8", type: "uint8", indexed: false } + ], + name: "Initialized" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint32", + type: "uint32", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false } + ], + name: "MembershipErased" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint32", + type: "uint32", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false } + ], + name: "MembershipExpired" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint32", + type: "uint32", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false }, + { + name: "newGracePeriodStartTimestamp", + internalType: "uint256", + type: "uint256", + indexed: false + } + ], + name: "MembershipExtended" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "idCommitment", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { + name: "membershipRateLimit", + internalType: "uint256", + type: "uint256", + indexed: false + }, + { name: "index", internalType: "uint32", type: "uint32", indexed: false } + ], + name: "MembershipRegistered" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "previousOwner", + internalType: "address", + type: "address", + indexed: true + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true + } + ], + name: "OwnershipTransferred" + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true + } + ], + name: "Upgraded" + }, + { + type: "error", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "CannotEraseActiveMembership" + }, + { type: "error", inputs: [], name: "CannotExceedMaxTotalRateLimit" }, + { + type: "error", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "CannotExtendNonGracePeriodMembership" + }, + { + type: "error", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "InvalidIdCommitment" + }, + { type: "error", inputs: [], name: "InvalidMembershipRateLimit" }, + { + type: "error", + inputs: [ + { name: "startIndex", internalType: "uint256", type: "uint256" }, + { name: "endIndex", internalType: "uint256", type: "uint256" } + ], + name: "InvalidPaginationQuery" + }, + { + type: "error", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "MembershipDoesNotExist" + }, + { + type: "error", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "NonHolderCannotEraseGracePeriodMembership" + }, + { + type: "error", + inputs: [ + { name: "idCommitment", internalType: "uint256", type: "uint256" } + ], + name: "NonHolderCannotExtend" + } +] as const; diff --git a/packages/rln/src/index.ts b/packages/rln/src/index.ts index 3348e370f7..855720b7d5 100644 --- a/packages/rln/src/index.ts +++ b/packages/rln/src/index.ts @@ -1,4 +1,3 @@ -import { RLN_ABI } from "./contract/abi/rln.js"; import { RLN_CONTRACT } from "./contract/index.js"; import { RLNBaseContract } from "./contract/rln_base_contract.js"; import { createRLN } from "./create.js"; @@ -14,10 +13,17 @@ export { RLNInstance, IdentityCredential, RLN_CONTRACT, - extractMetaMaskSigner, - RLN_ABI + extractMetaMaskSigner }; +// Export wagmi-generated ABIs +export { + wakuRlnV2Abi, + linearPriceCalculatorAbi, + iPriceCalculatorAbi, + membershipUpgradeableAbi +} from "./contract/wagmi/generated.js"; + export type { DecryptedCredentials, EncryptedCredentials, diff --git a/packages/rln/wagmi.config.ts b/packages/rln/wagmi.config.ts new file mode 100644 index 0000000000..bffe3f0576 --- /dev/null +++ b/packages/rln/wagmi.config.ts @@ -0,0 +1,18 @@ +import { defineConfig } from "@wagmi/cli"; +import { foundry } from "@wagmi/cli/plugins"; + +export default defineConfig({ + out: "src/contract/wagmi/generated.ts", + plugins: [ + foundry({ + project: "./waku-rlnv2-contract", + artifacts: "out", + include: [ + "WakuRlnV2.sol/**", + "Membership.sol/**", + "LinearPriceCalculator.sol/**", + "IPriceCalculator.sol/**" + ] + }) + ] +});