mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-05 15:23:12 +00:00
feat(rln): use wagmi for type generation
This commit is contained in:
parent
e92cc570f2
commit
5d8205d9db
@ -67,7 +67,8 @@
|
||||
"**/rollup.config.js",
|
||||
"**/playwright.config.ts",
|
||||
"**/.eslintrc.cjs",
|
||||
"**/karma.conf.cjs"
|
||||
"**/karma.conf.cjs",
|
||||
"**/wagmi.config.ts"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
4358
package-lock.json
generated
4358
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -42,6 +42,7 @@
|
||||
"test:browser": "karma start karma.conf.cjs",
|
||||
"watch:build": "tsc -p tsconfig.json -w",
|
||||
"watch:test": "mocha --watch",
|
||||
"generate:wagmi": "wagmi generate",
|
||||
"prepublish": "npm run build",
|
||||
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
||||
},
|
||||
@ -54,15 +55,17 @@
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@types/chai": "^5.0.1",
|
||||
"@types/chai-spies": "^1.0.6",
|
||||
"@waku/interfaces": "0.0.32",
|
||||
"@types/deep-equal-in-any-order": "^1.0.4",
|
||||
"@types/lodash": "^4.17.15",
|
||||
"@types/sinon": "^17.0.3",
|
||||
"@wagmi/cli": "^2.3.2",
|
||||
"@waku/build-utils": "^1.0.0",
|
||||
"@waku/interfaces": "0.0.32",
|
||||
"@waku/message-encryption": "^0.0.35",
|
||||
"deep-equal-in-any-order": "^2.0.6",
|
||||
"fast-check": "^3.23.2",
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"viem": "^2.32.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
@ -76,18 +79,19 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@chainsafe/bls-keystore": "3.0.0",
|
||||
"@noble/hashes": "^1.2.0",
|
||||
"@waku/core": "^0.0.37",
|
||||
"@waku/utils": "^0.0.25",
|
||||
"@noble/hashes": "^1.2.0",
|
||||
"@waku/zerokit-rln-wasm": "^0.0.13",
|
||||
"ethereum-cryptography": "^3.1.0",
|
||||
"ethers": "^5.7.2",
|
||||
"lodash": "^4.17.21",
|
||||
"uuid": "^11.0.5",
|
||||
"chai": "^5.1.2",
|
||||
"chai-as-promised": "^8.0.1",
|
||||
"chai-spies": "^1.1.0",
|
||||
"chai-subset": "^1.6.0",
|
||||
"sinon": "^19.0.2"
|
||||
"ethereum-cryptography": "^3.1.0",
|
||||
"ethers": "^5.7.2",
|
||||
"lodash": "^4.17.21",
|
||||
"sinon": "^19.0.2",
|
||||
"uuid": "^11.0.5",
|
||||
"wagmi": "^2.15.7"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,34 @@
|
||||
export { RLNContract } from "./rln_contract.js";
|
||||
export * from "./constants.js";
|
||||
export * from "./types.js";
|
||||
export * from "./constants.js";
|
||||
|
||||
export {
|
||||
readRlnGetMembershipInfo,
|
||||
readRlnCurrentTotalRateLimit,
|
||||
readRlnMaxMembershipRateLimit,
|
||||
readRlnIsExpired,
|
||||
readRlnIsInGracePeriod,
|
||||
readRlnMemberships,
|
||||
writeRlnRegister,
|
||||
writeRlnRegisterWithPermit,
|
||||
writeRlnEraseMemberships,
|
||||
writeRlnExtendMemberships,
|
||||
simulateRlnRegister,
|
||||
simulateRlnRegisterWithPermit,
|
||||
simulateRlnEraseMemberships,
|
||||
simulateRlnExtendMemberships,
|
||||
watchRlnMembershipRegisteredEvent,
|
||||
watchRlnMembershipErasedEvent,
|
||||
watchRlnMembershipExpiredEvent,
|
||||
readPriceCalculatorCalculate,
|
||||
rlnAbi,
|
||||
rlnAddress,
|
||||
priceCalculatorAbi,
|
||||
priceCalculatorAddress,
|
||||
WagmiRLNContract
|
||||
} from "./wagmi-actions-contract.js";
|
||||
|
||||
export type {
|
||||
MembershipInfo as WagmiMembershipInfo,
|
||||
RateLimitTier
|
||||
} from "./wagmi-actions-contract.js";
|
||||
|
||||
42
packages/rln/src/contract/wagmi-actions-contract.ts
Normal file
42
packages/rln/src/contract/wagmi-actions-contract.ts
Normal file
@ -0,0 +1,42 @@
|
||||
export {
|
||||
readRlnGetMembershipInfo,
|
||||
readRlnCurrentTotalRateLimit,
|
||||
readRlnMaxMembershipRateLimit,
|
||||
readRlnIsExpired,
|
||||
readRlnIsInGracePeriod,
|
||||
readRlnMemberships,
|
||||
writeRlnRegister,
|
||||
writeRlnRegisterWithPermit,
|
||||
writeRlnEraseMemberships,
|
||||
writeRlnExtendMemberships,
|
||||
simulateRlnRegister,
|
||||
simulateRlnRegisterWithPermit,
|
||||
simulateRlnEraseMemberships,
|
||||
simulateRlnExtendMemberships,
|
||||
watchRlnMembershipRegisteredEvent,
|
||||
watchRlnMembershipErasedEvent,
|
||||
watchRlnMembershipExpiredEvent,
|
||||
readPriceCalculatorCalculate,
|
||||
rlnAbi,
|
||||
rlnAddress,
|
||||
priceCalculatorAbi,
|
||||
priceCalculatorAddress
|
||||
} from "../generated/wagmi.js";
|
||||
|
||||
export class WagmiRLNContract {}
|
||||
|
||||
export type MembershipInfo = {
|
||||
membershipRateLimit: bigint;
|
||||
holder: string;
|
||||
index: number;
|
||||
gracePeriodStartTimestamp: bigint;
|
||||
exists: boolean;
|
||||
};
|
||||
|
||||
export type RateLimitTier = "LOW" | "MEDIUM" | "HIGH";
|
||||
|
||||
export const RATE_LIMIT_TIERS = {
|
||||
LOW: 20,
|
||||
MEDIUM: 200,
|
||||
HIGH: 600
|
||||
} as const;
|
||||
1775
packages/rln/src/generated/wagmi.ts
Normal file
1775
packages/rln/src/generated/wagmi.ts
Normal file
File diff suppressed because it is too large
Load Diff
30
packages/rln/wagmi.config.ts
Normal file
30
packages/rln/wagmi.config.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { defineConfig } from "@wagmi/cli";
|
||||
import { actions } from "@wagmi/cli/plugins";
|
||||
import type { Abi } from "viem";
|
||||
|
||||
import {
|
||||
PRICE_CALCULATOR_CONTRACT,
|
||||
RLN_CONTRACT
|
||||
} from "./src/contract/constants.js";
|
||||
|
||||
export default defineConfig({
|
||||
out: "src/generated/wagmi.ts",
|
||||
contracts: [
|
||||
{
|
||||
name: "RLN",
|
||||
address: {
|
||||
[RLN_CONTRACT.chainId]: RLN_CONTRACT.address as `0x${string}`
|
||||
},
|
||||
abi: RLN_CONTRACT.abi as Abi
|
||||
},
|
||||
{
|
||||
name: "PriceCalculator",
|
||||
address: {
|
||||
[PRICE_CALCULATOR_CONTRACT.chainId]:
|
||||
PRICE_CALCULATOR_CONTRACT.address as `0x${string}`
|
||||
},
|
||||
abi: PRICE_CALCULATOR_CONTRACT.abi as Abi
|
||||
}
|
||||
],
|
||||
plugins: [actions({})]
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user