diff --git a/src/contract/abis/rlnv2.ts b/src/contract/abis/rlnv2.ts new file mode 100644 index 0000000..47ee866 --- /dev/null +++ b/src/contract/abis/rlnv2.ts @@ -0,0 +1,314 @@ +export const RLNv2ABI = [ + { + type: "constructor", + inputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + name: "MAX_MEMBERSHIP_SET_SIZE", + inputs: [], + outputs: [ + { + name: "", + type: "uint32", + internalType: "uint32" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "MERKLE_TREE_DEPTH", + inputs: [], + outputs: [ + { + name: "", + type: "uint8", + internalType: "uint8" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "Q", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "activeDurationForNewMemberships", + inputs: [], + outputs: [ + { + name: "", + type: "uint32", + internalType: "uint32" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "currentTotalRateLimit", + inputs: [], + outputs: [ + { + name: "", + type: "uint256", + internalType: "uint256" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "deployedBlockNumber", + inputs: [], + outputs: [ + { + name: "", + type: "uint32", + internalType: "uint32" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "depositsToWithdraw", + inputs: [ + { + name: "holder", + type: "address", + internalType: "address" + }, + { + name: "token", + type: "address", + internalType: "address" + } + ], + outputs: [ + { + name: "balance", + type: "uint256", + internalType: "uint256" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "eraseMemberships", + inputs: [ + { + name: "idCommitments", + type: "uint256[]", + internalType: "uint256[]" + } + ], + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + name: "eraseMemberships", + inputs: [ + { + name: "idCommitments", + type: "uint256[]", + internalType: "uint256[]" + }, + { + name: "eraseFromMembershipSet", + type: "bool", + internalType: "bool" + } + ], + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + name: "extendMemberships", + inputs: [ + { + name: "idCommitments", + type: "uint256[]", + internalType: "uint256[]" + } + ], + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + name: "getMembershipInfo", + inputs: [ + { + name: "idCommitment", + type: "uint256", + internalType: "uint256" + } + ], + outputs: [ + { + name: "", + type: "uint32", + internalType: "uint32" + }, + { + name: "", + type: "uint32", + internalType: "uint32" + }, + { + name: "", + type: "uint256", + internalType: "uint256" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "getMerkleProof", + inputs: [ + { + name: "index", + type: "uint40", + internalType: "uint40" + } + ], + outputs: [ + { + name: "", + type: "uint256[20]", + internalType: "uint256[20]" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "getRateCommitmentsInRangeBoundsInclusive", + inputs: [ + { + name: "startIndex", + type: "uint32", + internalType: "uint32" + }, + { + name: "endIndex", + type: "uint32", + internalType: "uint32" + } + ], + outputs: [ + { + name: "", + type: "uint256[]", + internalType: "uint256[]" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "gracePeriodDurationForNewMemberships", + inputs: [], + outputs: [ + { + name: "", + type: "uint32", + internalType: "uint32" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "indicesOfLazilyErasedMemberships", + inputs: [ + { + name: "", + type: "uint256", + internalType: "uint256" + } + ], + outputs: [ + { + name: "", + type: "uint32", + internalType: "uint32" + } + ], + stateMutability: "view" + }, + { + type: "function", + name: "initialize", + inputs: [ + { + name: "_priceCalculator", + type: "address", + internalType: "address" + }, + { + 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", + internalType: "uint32" + } + ], + outputs: [], + stateMutability: "nonpayable" + }, + { + type: "function", + name: "isExpired", + inputs: [ + { + name: "_idCommitment", + type: "uint256", + internalType: "uint256" + } + ], + outputs: [ + { + name: "", + type: "bool", + internalType: "bool" + } + ], + stateMutability: "view" + } +]; diff --git a/src/contract/constants.ts b/src/contract/constants.ts index f884ce7..923d666 100644 --- a/src/contract/constants.ts +++ b/src/contract/constants.ts @@ -1,68 +1,7 @@ -// ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnRegistry_Implementation.json#L3 -export const RLN_REGISTRY_ABI = [ - "error IncompatibleStorage()", - "error IncompatibleStorageIndex()", - "error NoStorageContractAvailable()", - "error StorageAlreadyExists(address storageAddress)", - "event AdminChanged(address previousAdmin, address newAdmin)", - "event BeaconUpgraded(address indexed beacon)", - "event Initialized(uint8 version)", - "event NewStorageContract(uint16 index, address storageAddress)", - "event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)", - "event Upgraded(address indexed implementation)", - "function forceProgress()", - "function initialize(address _poseidonHasher)", - "function newStorage()", - "function nextStorageIndex() view returns (uint16)", - "function owner() view returns (address)", - "function poseidonHasher() view returns (address)", - "function proxiableUUID() view returns (bytes32)", - "function register(uint16 storageIndex, uint256 commitment)", - "function register(uint256[] commitments)", - "function register(uint16 storageIndex, uint256[] commitments)", - "function registerStorage(address storageAddress)", - "function renounceOwnership()", - "function storages(uint16) view returns (address)", - "function transferOwnership(address newOwner)", - "function upgradeTo(address newImplementation)", - "function upgradeToAndCall(address newImplementation, bytes data) payable", - "function usingStorageIndex() view returns (uint16)" -]; - -// ref https://github.com/waku-org/waku-rln-contract/blob/19fded82bca07e7b535b429dc507cfb83f10dfcf/deployments/sepolia/WakuRlnStorage_0.json#L3 -export const RLN_STORAGE_ABI = [ - "constructor(address _poseidonHasher, uint16 _contractIndex)", - "error DuplicateIdCommitment()", - "error FullTree()", - "error InvalidIdCommitment(uint256 idCommitment)", - "error NotImplemented()", - "event MemberRegistered(uint256 idCommitment, uint256 index)", - "event MemberWithdrawn(uint256 idCommitment, uint256 index)", - "event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)", - "function DEPTH() view returns (uint256)", - "function MEMBERSHIP_DEPOSIT() view returns (uint256)", - "function SET_SIZE() view returns (uint256)", - "function contractIndex() view returns (uint16)", - "function deployedBlockNumber() view returns (uint32)", - "function idCommitmentIndex() view returns (uint256)", - "function isValidCommitment(uint256 idCommitment) view returns (bool)", - "function memberExists(uint256) view returns (bool)", - "function members(uint256) view returns (uint256)", - "function owner() view returns (address)", - "function poseidonHasher() view returns (address)", - "function register(uint256[] idCommitments)", - "function register(uint256 idCommitment) payable", - "function renounceOwnership()", - "function slash(uint256 idCommitment, address receiver, uint256[8] proof) pure", - "function stakedAmounts(uint256) view returns (uint256)", - "function transferOwnership(address newOwner)", - "function verifier() view returns (address)", - "function withdraw() pure", - "function withdrawalBalance(address) view returns (uint256)" -]; +import { RLNv2ABI } from "./abis/rlnv2"; export const SEPOLIA_CONTRACT = { chainId: 11155111, - address: "0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4", - abi: RLN_REGISTRY_ABI + address: "0xCB33Aa5B38d79E3D9Fa8B10afF38AA201399a7e3", + abi: RLNv2ABI };