forked from Rate-Limiting-Nullifier/rlnjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configs.ts
45 lines (39 loc) · 28.9 KB
/
configs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { ethers } from "ethers";
export const treeDepth = 20
export const url = "http://localhost:8545"
// TODO: deploy to testnet and don't deploy ourselves here
const testERC20ABI = '[{"inputs": [{"internalType": "uint256", "name": "amount", "type": "uint256"}], "stateMutability": "nonpayable", "type": "constructor"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "owner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "spender", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "value", "type": "uint256"}], "name": "Approval", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "from", "type": "address"}, {"indexed": true, "internalType": "address", "name": "to", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "value", "type": "uint256"}], "name": "Transfer", "type": "event"}, {"inputs": [{"internalType": "address", "name": "owner", "type": "address"}, {"internalType": "address", "name": "spender", "type": "address"}], "name": "allowance", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "spender", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "approve", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "account", "type": "address"}], "name": "balanceOf", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "decimals", "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "spender", "type": "address"}, {"internalType": "uint256", "name": "subtractedValue", "type": "uint256"}], "name": "decreaseAllowance", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "spender", "type": "address"}, {"internalType": "uint256", "name": "addedValue", "type": "uint256"}], "name": "increaseAllowance", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "name", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "symbol", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "totalSupply", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "to", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "transfer", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "from", "type": "address"}, {"internalType": "address", "name": "to", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "transferFrom", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}]'
const testERC20ContractBytecode = "0x60806040523480156200001157600080fd5b5060405162000b8d38038062000b8d833981016040819052620000349162000179565b6040518060400160405280600981526020016805465737445524332360bc1b815250604051806040016040528060038152602001621514d560ea1b815250816003908162000083919062000237565b50600462000092828262000237565b505050620000a73382620000ae60201b60201c565b506200032b565b6001600160a01b038216620001095760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200011d919062000303565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b6000602082840312156200018c57600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001be57607f821691505b602082108103620001df57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200017457600081815260208120601f850160051c810160208610156200020e5750805b601f850160051c820191505b818110156200022f578281556001016200021a565b505050505050565b81516001600160401b0381111562000253576200025362000193565b6200026b81620002648454620001a9565b84620001e5565b602080601f831160018114620002a357600084156200028a5750858301515b600019600386901b1c1916600185901b1785556200022f565b600085815260208120601f198616915b82811015620002d457888601518255948401946001909101908401620002b3565b5085821015620002f35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200032557634e487b7160e01b600052601160045260246000fd5b92915050565b610852806200033b6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012357806370a082311461013657806395d89b411461015f578063a457c2d714610167578063a9059cbb1461017a578063dd62ed3e1461018d57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101a0565b6040516100c3919061069c565b60405180910390f35b6100df6100da366004610706565b610232565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610730565b61024c565b604051601281526020016100c3565b6100df610131366004610706565b610270565b6100f361014436600461076c565b6001600160a01b031660009081526020819052604090205490565b6100b6610292565b6100df610175366004610706565b6102a1565b6100df610188366004610706565b610321565b6100f361019b36600461078e565b61032f565b6060600380546101af906107c1565b80601f01602080910402602001604051908101604052809291908181526020018280546101db906107c1565b80156102285780601f106101fd57610100808354040283529160200191610228565b820191906000526020600020905b81548152906001019060200180831161020b57829003601f168201915b5050505050905090565b60003361024081858561035a565b60019150505b92915050565b60003361025a85828561047e565b6102658585856104f8565b506001949350505050565b600033610240818585610283838361032f565b61028d91906107fb565b61035a565b6060600480546101af906107c1565b600033816102af828661032f565b9050838110156103145760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610265828686840361035a565b6000336102408185856104f8565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103bc5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161030b565b6001600160a01b03821661041d5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161030b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600061048a848461032f565b905060001981146104f257818110156104e55760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161030b565b6104f2848484840361035a565b50505050565b6001600160a01b03831661055c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161030b565b6001600160a01b0382166105be5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161030b565b6001600160a01b038316600090815260208190526040902054818110156106365760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161030b565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36104f2565b600060208083528351808285015260005b818110156106c9578581018301518582016040015282016106ad565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461070157600080fd5b919050565b6000806040838503121561071957600080fd5b610722836106ea565b946020939093013593505050565b60008060006060848603121561074557600080fd5b61074e846106ea565b925061075c602085016106ea565b9150604084013590509250925092565b60006020828403121561077e57600080fd5b610787826106ea565b9392505050565b600080604083850312156107a157600080fd5b6107aa836106ea565b91506107b8602084016106ea565b90509250929050565b600181811c908216806107d557607f821691505b6020821081036107f557634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561024657634e487b7160e01b600052601160045260246000fdfea264697066735822122054d059ee835775206d7458a862cc8d640ae1efb1e18a09dbc64742523c5c2e2964736f6c63430008130033"
const rlnContractABI = JSON.parse('[{"inputs": [{"internalType": "uint256", "name": "minimalDeposit", "type": "uint256"}, {"internalType": "uint256", "name": "depth", "type": "uint256"}, {"internalType": "uint8", "name": "feePercentage", "type": "uint8"}, {"internalType": "address", "name": "feeReceiver", "type": "address"}, {"internalType": "uint256", "name": "freezePeriod", "type": "uint256"}, {"internalType": "address", "name": "_token", "type": "address"}, {"internalType": "address", "name": "_verifier", "type": "address"}], "stateMutability": "nonpayable", "type": "constructor"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "identityCommitment", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "messageLimit", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "index", "type": "uint256"}], "name": "MemberRegistered", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "index", "type": "uint256"}, {"indexed": false, "internalType": "address", "name": "slasher", "type": "address"}], "name": "MemberSlashed", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "index", "type": "uint256"}], "name": "MemberWithdrawn", "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"}, {"inputs": [], "name": "DEPTH", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "MINIMAL_DEPOSIT", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "SET_SIZE", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "identityCommitmentIndex", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "members", "outputs": [{"internalType": "address", "name": "userAddress", "type": "address"}, {"internalType": "uint256", "name": "messageLimit", "type": "uint256"}, {"internalType": "uint256", "name": "index", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "identityCommitment", "type": "uint256"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "register", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "identityCommitment", "type": "uint256"}], "name": "release", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "identityCommitment", "type": "uint256"}, {"internalType": "address", "name": "receiver", "type": "address"}, {"internalType": "uint256[8]", "name": "proof", "type": "uint256[8]"}], "name": "slash", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "token", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "verifier", "outputs": [{"internalType": "contract IVerifier", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "identityCommitment", "type": "uint256"}, {"internalType": "uint256[8]", "name": "proof", "type": "uint256[8]"}], "name": "withdraw", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "name": "withdrawals", "outputs": [{"internalType": "uint256", "name": "blockNumber", "type": "uint256"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}, {"internalType": "address", "name": "receiver", "type": "address"}], "stateMutability": "view", "type": "function"}]')
const rlnContractBytecode = "0x61018060405260006001553480156200001757600080fd5b5060405162001757380380620017578339810160408190526200003a91620000f5565b620000453362000088565b60809690965260a0859052600190941b60c05260ff909216610100526001600160a01b0390811660e0526101209190915290811661014052166101605262000176565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000f057600080fd5b919050565b600080600080600080600060e0888a0312156200011157600080fd5b8751965060208801519550604088015160ff811681146200013157600080fd5b94506200014160608901620000d8565b9350608088015192506200015860a08901620000d8565b91506200016860c08901620000d8565b905092959891949750929550565b60805160a05160c05160e0516101005161012051610140516101605161153662000221600039600081816101390152610e6b015260008181610304015281816104960152818161075d0152818161079101526109ab015260006103c701526000610714015260006107b30152600081816102a401526108270152600061027401526000818160ff015281816106e101528181610898015281816109da0152610c1401526115366000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80638da5cb5b11610097578063d66d6c1011610066578063d66d6c10146102c6578063eb15f675146102d9578063f2fde38b146102ec578063fc0c546a146102ff57600080fd5b80638da5cb5b1461025e57806398366e351461026f5780639cf502fe14610296578063d0383d681461029f57600080fd5b80635cc07076116100d35780635cc07076146101885780635daf08ca146101e4578063715018a6146102435780638be9b1191461024b57600080fd5b80631810847c146100fa5780632b7ac3f31461013457806337bdc99b14610173575b600080fd5b6101217f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b61015b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161012b565b610186610181366004611235565b610326565b005b6101c0610196366004611235565b6003602052600090815260409020805460018201546002909201549091906001600160a01b031683565b6040805193845260208401929092526001600160a01b03169082015260600161012b565b61021e6101f2366004611235565b60026020819052600091825260409091208054600182015491909201546001600160a01b039092169183565b604080516001600160a01b03909416845260208401929092529082015260600161012b565b6101866104c8565b610186610259366004611282565b6104dc565b6000546001600160a01b031661015b565b6101217f000000000000000000000000000000000000000000000000000000000000000081565b61012160015481565b6101217f000000000000000000000000000000000000000000000000000000000000000081565b6101866102d43660046112c0565b610825565b6101866102e73660046112e2565b610ab6565b6101866102fa366004611310565b610cdc565b61015b7f000000000000000000000000000000000000000000000000000000000000000081565b6000818152600360209081526040808320815160608101835281548082526001830154948201949094526002909101546001600160a01b03169181019190915291036103c35760405162461bcd60e51b815260206004820152602160248201527f524c4e2c2072656c656173653a206e6f2073756368207769746864726177616c6044820152607360f81b60648201526084015b60405180910390fd5b80517f0000000000000000000000000000000000000000000000000000000000000000906103f19043611348565b1161043e5760405162461bcd60e51b815260206004820181905260248201527f524c4e2c2072656c656173653a2063616e6e6f742072656c656173652079657460448201526064016103ba565b60008281526003602090815260408083208381556001808201859055600291820180546001600160a01b031990811690915582855283862080549091168155908101859055019290925590820151908201516104c4917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031691610d55565b5050565b6104d0610dbd565b6104da6000610e17565b565b6001600160a01b0382166105405760405162461bcd60e51b815260206004820152602560248201527f524c4e2c2077697468647261773a20656d707479207265636569766572206164604482015264647265737360d81b60648201526084016103ba565b600083815260026020818152604092839020835160608101855281546001600160a01b031680825260018301549382019390935292015492820192909252906105cb5760405162461bcd60e51b815260206004820181905260248201527f524c4e2c20736c6173683a206d656d62657220646f65736e277420657869737460448201526064016103ba565b80516001600160a01b038085169116036106375760405162461bcd60e51b815260206004820152602760248201527f524c4e2c20736c6173683a2073656c662d736c617368696e672069732070726f6044820152661a1a589a5d195960ca1b60648201526084016103ba565b610642848484610e67565b61068e5760405162461bcd60e51b815260206004820152601c60248201527f524c4e2c2077697468647261773a20696e76616c69642070726f6f660000000060448201526064016103ba565b600084815260026020818152604080842080546001600160a01b031990811682556001808301879055918501869055600384529185208581559081018590559092018054909216909155820151610706907f00000000000000000000000000000000000000000000000000000000000000009061135b565b9050600060646107398360ff7f00000000000000000000000000000000000000000000000000000000000000001661135b565b6107439190611372565b9050610784856107538385611348565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190610d55565b6107d86001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083610d55565b60408084015181519081526001600160a01b03871660208201527f707cd9719d0c14265b9e456f7add99095401f907e570e5cdd65a92920947c450910160405180910390a1505050505050565b7f0000000000000000000000000000000000000000000000000000000000000000600154106108965760405162461bcd60e51b815260206004820152601a60248201527f524c4e2c2072656769737465723a207365742069732066756c6c00000000000060448201526064016103ba565b7f00000000000000000000000000000000000000000000000000000000000000008110156109225760405162461bcd60e51b815260206004820152603360248201527f524c4e2c2072656769737465723a20616d6f756e74206973206c6f77657220746044820152721a185b881b5a5b9a5b585b0819195c1bdcda5d606a1b60648201526084016103ba565b6000828152600260205260409020546001600160a01b03161561099e5760405162461bcd60e51b815260206004820152602e60248201527f524c4e2c2072656769737465723a206964436f6d6d69746d656e7420616c726560448201526d18591e481c9959da5cdd195c995960921b60648201526084016103ba565b6109d36001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333084611002565b60006109ff7f000000000000000000000000000000000000000000000000000000000000000083611372565b604080516060808201835233825260208083018581526001805485870190815260008b8152600280865290889020965187546001600160a01b0319166001600160a01b0390911617875592518683015551949091019390935591548351888152928301859052928201929092529192507fff42916a89d1f5125f7f47168ee59c2b3fc9246ad1b229082ee85b69d001b5d7910160405180910390a16001806000828254610aac9190611394565b9091555050505050565b600082815260026020818152604092839020835160608101855281546001600160a01b03168082526001830154938201939093529201549282019290925290610b4d5760405162461bcd60e51b815260206004820152602360248201527f524c4e2c2077697468647261773a206d656d62657220646f65736e27742065786044820152621a5cdd60ea1b60648201526084016103ba565b60008381526003602052604090205415610bb55760405162461bcd60e51b8152602060048201526024808201527f524c4e2c2072656c656173653a2073756368207769746864726177616c2065786044820152636973747360e01b60648201526084016103ba565b610bc483826000015184610e67565b610c105760405162461bcd60e51b815260206004820152601c60248201527f524c4e2c2077697468647261773a20696e76616c69642070726f6f660000000060448201526064016103ba565b60007f00000000000000000000000000000000000000000000000000000000000000008260200151610c42919061135b565b60408051606081018252438152602080820184815286516001600160a01b0390811684860190815260008b81526003855286902094518555915160018501559051600290930180546001600160a01b03191693909116929092179091558482015191519182529192507fad2d771c5ad1c1e6f50cc769e53ec1e194002c29f28c3dd2af5639b60d8072a6910160405180910390a150505050565b610ce4610dbd565b6001600160a01b038116610d495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103ba565b610d5281610e17565b50565b6040516001600160a01b038316602482015260448101829052610db890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611040565b505050565b6000546001600160a01b031633146104da5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ba565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f5c9d69e604051806040016040528085600060088110610eb657610eb66113a7565b6020020135815260200185600160088110610ed357610ed36113a7565b6020020135905260408051608081018252868201359181019182529081906060820188600360200201358152508152602001604051806040016040528088600460088110610f2357610f236113a7565b6020020135815260200188600560088110610f4057610f406113a7565b60200201359052905260408051808201909152808760066020020135815260200187600760088110610f7457610f746113a7565b602002013581525060405180604001604052808a8152602001896001600160a01b03168152506040518563ffffffff1660e01b8152600401610fb994939291906113e0565b602060405180830381865afa158015610fd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffa919061146b565b949350505050565b6040516001600160a01b038085166024830152831660448201526064810182905261103a9085906323b872dd60e01b90608401610d81565b50505050565b6000611095826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111129092919063ffffffff16565b805190915015610db857808060200190518101906110b3919061146b565b610db85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103ba565b6060610ffa848460008585600080866001600160a01b0316858760405161113991906114b1565b60006040518083038185875af1925050503d8060008114611176576040519150601f19603f3d011682016040523d82523d6000602084013e61117b565b606091505b509150915061118c87838387611197565b979650505050505050565b606083156112065782516000036111ff576001600160a01b0385163b6111ff5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103ba565b5081610ffa565b610ffa838381511561121b5781518083602001fd5b8060405162461bcd60e51b81526004016103ba91906114cd565b60006020828403121561124757600080fd5b5035919050565b80356001600160a01b038116811461126557600080fd5b919050565b80610100810183101561127c57600080fd5b92915050565b6000806000610140848603121561129857600080fd5b833592506112a86020850161124e565b91506112b7856040860161126a565b90509250925092565b600080604083850312156112d357600080fd5b50508035926020909101359150565b60008061012083850312156112f657600080fd5b82359150611307846020850161126a565b90509250929050565b60006020828403121561132257600080fd5b61132b8261124e565b9392505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561127c5761127c611332565b808202811582820484141761127c5761127c611332565b60008261138f57634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561127c5761127c611332565b634e487b7160e01b600052603260045260246000fd5b8060005b600281101561103a5781518452602093840193909101906001016113c1565b61014081016113ef82876113bd565b6040808301866000805b60028082106114085750611442565b835185845b8381101561142b57825182526020928301929091019060010161140d565b5050509385019350602092909201916001016113f9565b505050505061145460c08301856113bd565b6114626101008301846113bd565b95945050505050565b60006020828403121561147d57600080fd5b8151801515811461132b57600080fd5b60005b838110156114a8578181015183820152602001611490565b50506000910152565b600082516114c381846020870161148d565b9190910192915050565b60208152600082518060208401526114ec81604085016020870161148d565b601f01601f1916919091016040019291505056fea26469706673582212202559bc10ac136f34793a9b29d1e129ececfc5fc95266c3e49c584ea6dde5bc7764736f6c63430008130033"
const mockVerifierABI = '[{"inputs": [], "stateMutability": "nonpayable", "type": "constructor"}, {"inputs": [{"internalType": "bool", "name": "_result", "type": "bool"}], "name": "changeResult", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "result", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "uint256[2]", "name": "", "type": "uint256[2]"}, {"internalType": "uint256[2][2]", "name": "", "type": "uint256[2][2]"}, {"internalType": "uint256[2]", "name": "", "type": "uint256[2]"}, {"internalType": "uint256[2]", "name": "", "type": "uint256[2]"}], "name": "verifyProof", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}]'
const mockVerifierBytecode = "0x608060405234801561001057600080fd5b506000805460ff1916600117905561022c8061002d6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80633f546a7b146100465780636537214714610069578063f5c9d69e1461008a575b600080fd5b6100676100543660046100a6565b6000805460ff1916911515919091179055565b005b6000546100769060ff1681565b604051901515815260200160405180910390f35b610076610098366004610156565b60005460ff16949350505050565b6000602082840312156100b857600080fd5b813580151581146100c857600080fd5b9392505050565b6040805190810167ffffffffffffffff8111828210171561010057634e487b7160e01b600052604160045260246000fd5b60405290565b600082601f83011261011757600080fd5b61011f6100cf565b80604084018581111561013157600080fd5b845b8181101561014b578035845260209384019301610133565b509095945050505050565b600080600080610140858703121561016d57600080fd5b6101778686610106565b9350604086605f87011261018a57600080fd5b6101926100cf565b8060c08801898111156101a457600080fd5b8389015b818110156101c9576101ba8b82610106565b845260209093019284016101a8565b508196506101d78a82610106565b9550505050506101eb866101008701610106565b90509295919450925056fea2646970667358221220d34849fd672045fa5d1669cae36e59adb19a0747b5ecf63a5dae9d051a32151d64736f6c63430008130033"
async function deployContract(signer: ethers.Signer, bytecode: string, abi: string, args?: any[]) {
const factory = new ethers.ContractFactory(abi, bytecode, signer)
if (!args) {
args = []
}
const contract = await factory.deploy(...args)
await contract.waitForDeployment()
const address = await contract.getAddress()
return new ethers.Contract(address, abi, signer)
}
export async function deployERC20(signer: ethers.Signer, amountForDeployer: bigint) {
return await deployContract(signer, testERC20ContractBytecode, testERC20ABI, [amountForDeployer])
}
export async function deployVerifier(signer: ethers.Signer) {
return await deployContract(signer, mockVerifierBytecode, mockVerifierABI)
}
export async function deployRLNContract(
signer: ethers.Signer, erc20Address: string, verifierAddress: string, minimalDeposit: bigint, treeDepth: number, feePercentage: bigint, feeReceiver: string, freezePeriod: bigint) {
const argsInArray = [
minimalDeposit,
treeDepth,
feePercentage,
feeReceiver,
freezePeriod,
erc20Address,
verifierAddress,
]
return await deployContract(signer, rlnContractBytecode, rlnContractABI, argsInArray)
}