diff --git a/abis/RelayerRegistry.abi.json b/abis/RelayerRegistry.abi.json new file mode 100644 index 0000000..c539213 --- /dev/null +++ b/abis/RelayerRegistry.abi.json @@ -0,0 +1,297 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_torn", "type": "address" }, + { "internalType": "address", "name": "_governance", "type": "address" }, + { "internalType": "address", "name": "_ens", "type": "address" }, + { "internalType": "address", "name": "_staking", "type": "address" }, + { "internalType": "address", "name": "_feeManager", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint256", "name": "minStakeAmount", "type": "uint256" }], + "name": "MinimumStakeAmount", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "relayer", "type": "address" }], + "name": "RelayerBalanceNullified", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "bytes32", "name": "relayer", "type": "bytes32" }, + { "indexed": false, "internalType": "string", "name": "ensName", "type": "string" }, + { "indexed": false, "internalType": "address", "name": "relayerAddress", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "stakedAmount", "type": "uint256" } + ], + "name": "RelayerRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "tornadoRouter", "type": "address" }], + "name": "RouterRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "relayer", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amountStakeAdded", "type": "uint256" } + ], + "name": "StakeAddedToRelayer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "relayer", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amountBurned", "type": "uint256" } + ], + "name": "StakeBurned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "relayer", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "worker", "type": "address" } + ], + "name": "WorkerRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "relayer", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "worker", "type": "address" } + ], + "name": "WorkerUnregistered", + "type": "event" + }, + { + "inputs": [{ "internalType": "bytes32[]", "name": "domains", "type": "bytes32[]" }], + "name": "bulkResolve", + "outputs": [{ "internalType": "address[]", "name": "result", "type": "address[]" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "contract ITornadoInstance", "name": "pool", "type": "address" } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "ens", + "outputs": [{ "internalType": "contract IENS", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeManager", + "outputs": [{ "internalType": "contract IFeeManager", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "relayer", "type": "address" }], + "name": "getRelayerBalance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "relayer", "type": "address" }], + "name": "getRelayerEnsHash", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governance", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "_tornadoRouter", "type": "bytes32" }], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "toResolve", "type": "address" }], + "name": "isRelayer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "address", "name": "toResolve", "type": "address" } + ], + "name": "isRelayerRegistered", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minStakeAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "relayer", "type": "address" }], + "name": "nullifyBalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "ensName", "type": "string" }, + { "internalType": "uint256", "name": "stake", "type": "uint256" }, + { "internalType": "address[]", "name": "workersToRegister", "type": "address[]" } + ], + "name": "register", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "ensName", "type": "string" }, + { "internalType": "uint256", "name": "stake", "type": "uint256" }, + { "internalType": "address[]", "name": "workersToRegister", "type": "address[]" }, + { "internalType": "address", "name": "relayer", "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" } + ], + "name": "registerPermit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "address", "name": "worker", "type": "address" } + ], + "name": "registerWorker", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "relayers", + "outputs": [ + { "internalType": "uint256", "name": "balance", "type": "uint256" }, + { "internalType": "bytes32", "name": "ensHash", "type": "bytes32" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "node", "type": "bytes32" }], + "name": "resolve", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "minAmount", "type": "uint256" }], + "name": "setMinStakeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "tornadoRouterAddress", "type": "address" }], + "name": "setTornadoRouter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "uint256", "name": "stake", "type": "uint256" } + ], + "name": "stakeToRelayer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "uint256", "name": "stake", "type": "uint256" }, + { "internalType": "address", "name": "staker", "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" } + ], + "name": "stakeToRelayerPermit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "staking", + "outputs": [{ "internalType": "contract TornadoStakingRewards", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "torn", + "outputs": [{ "internalType": "contract TORN", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tornadoRouter", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "worker", "type": "address" }], + "name": "unregisterWorker", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "workers", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/config.ts b/src/config.ts index 79a8065..263f161 100644 --- a/src/config.ts +++ b/src/config.ts @@ -44,7 +44,7 @@ const minimumBalances: { [availableId in availableIds]: number } = { 43114: 10, // 10 AVAX on Avalanche C-Chain }; const decimals = BigNumber.from(10).pow(18); -export const minimumBalance = BigNumber.from(minimumBalances[netId] * 10) +export const minimumBalance = BigNumber.from(minimumBalances[netId] * 10) // BN don't accept float values .mul(decimals.div(10)) .toString(); export const minimumTornBalance = BigNumber.from(500).mul(decimals).toString(); diff --git a/src/contracts/RelayerRegistryAbi.ts b/src/contracts/RelayerRegistryAbi.ts new file mode 100644 index 0000000..2c15133 --- /dev/null +++ b/src/contracts/RelayerRegistryAbi.ts @@ -0,0 +1,1070 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { + FunctionFragment, + Result, + EventFragment, +} from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, +} from "./common"; + +export interface RelayerRegistryAbiInterface extends utils.Interface { + functions: { + "bulkResolve(bytes32[])": FunctionFragment; + "burn(address,address,address)": FunctionFragment; + "ens()": FunctionFragment; + "feeManager()": FunctionFragment; + "getRelayerBalance(address)": FunctionFragment; + "getRelayerEnsHash(address)": FunctionFragment; + "governance()": FunctionFragment; + "initialize(bytes32)": FunctionFragment; + "isRelayer(address)": FunctionFragment; + "isRelayerRegistered(address,address)": FunctionFragment; + "minStakeAmount()": FunctionFragment; + "nullifyBalance(address)": FunctionFragment; + "register(string,uint256,address[])": FunctionFragment; + "registerPermit(string,uint256,address[],address,uint256,uint8,bytes32,bytes32)": FunctionFragment; + "registerWorker(address,address)": FunctionFragment; + "relayers(address)": FunctionFragment; + "resolve(bytes32)": FunctionFragment; + "setMinStakeAmount(uint256)": FunctionFragment; + "setTornadoRouter(address)": FunctionFragment; + "stakeToRelayer(address,uint256)": FunctionFragment; + "stakeToRelayerPermit(address,uint256,address,uint256,uint8,bytes32,bytes32)": FunctionFragment; + "staking()": FunctionFragment; + "torn()": FunctionFragment; + "tornadoRouter()": FunctionFragment; + "unregisterWorker(address)": FunctionFragment; + "workers(address)": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | "bulkResolve" + | "burn" + | "ens" + | "feeManager" + | "getRelayerBalance" + | "getRelayerEnsHash" + | "governance" + | "initialize" + | "isRelayer" + | "isRelayerRegistered" + | "minStakeAmount" + | "nullifyBalance" + | "register" + | "registerPermit" + | "registerWorker" + | "relayers" + | "resolve" + | "setMinStakeAmount" + | "setTornadoRouter" + | "stakeToRelayer" + | "stakeToRelayerPermit" + | "staking" + | "torn" + | "tornadoRouter" + | "unregisterWorker" + | "workers" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "bulkResolve", + values: [BytesLike[]] + ): string; + encodeFunctionData( + functionFragment: "burn", + values: [string, string, string] + ): string; + encodeFunctionData(functionFragment: "ens", values?: undefined): string; + encodeFunctionData( + functionFragment: "feeManager", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getRelayerBalance", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "getRelayerEnsHash", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "governance", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "initialize", + values: [BytesLike] + ): string; + encodeFunctionData(functionFragment: "isRelayer", values: [string]): string; + encodeFunctionData( + functionFragment: "isRelayerRegistered", + values: [string, string] + ): string; + encodeFunctionData( + functionFragment: "minStakeAmount", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "nullifyBalance", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "register", + values: [string, BigNumberish, string[]] + ): string; + encodeFunctionData( + functionFragment: "registerPermit", + values: [ + string, + BigNumberish, + string[], + string, + BigNumberish, + BigNumberish, + BytesLike, + BytesLike + ] + ): string; + encodeFunctionData( + functionFragment: "registerWorker", + values: [string, string] + ): string; + encodeFunctionData(functionFragment: "relayers", values: [string]): string; + encodeFunctionData(functionFragment: "resolve", values: [BytesLike]): string; + encodeFunctionData( + functionFragment: "setMinStakeAmount", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "setTornadoRouter", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "stakeToRelayer", + values: [string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "stakeToRelayerPermit", + values: [ + string, + BigNumberish, + string, + BigNumberish, + BigNumberish, + BytesLike, + BytesLike + ] + ): string; + encodeFunctionData(functionFragment: "staking", values?: undefined): string; + encodeFunctionData(functionFragment: "torn", values?: undefined): string; + encodeFunctionData( + functionFragment: "tornadoRouter", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "unregisterWorker", + values: [string] + ): string; + encodeFunctionData(functionFragment: "workers", values: [string]): string; + + decodeFunctionResult( + functionFragment: "bulkResolve", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "burn", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "ens", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "feeManager", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getRelayerBalance", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getRelayerEnsHash", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "governance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "isRelayer", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "isRelayerRegistered", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "minStakeAmount", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "nullifyBalance", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "register", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "registerPermit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "registerWorker", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "relayers", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "resolve", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "setMinStakeAmount", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setTornadoRouter", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "stakeToRelayer", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "stakeToRelayerPermit", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "staking", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "torn", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "tornadoRouter", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "unregisterWorker", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "workers", data: BytesLike): Result; + + events: { + "MinimumStakeAmount(uint256)": EventFragment; + "RelayerBalanceNullified(address)": EventFragment; + "RelayerRegistered(bytes32,string,address,uint256)": EventFragment; + "RouterRegistered(address)": EventFragment; + "StakeAddedToRelayer(address,uint256)": EventFragment; + "StakeBurned(address,uint256)": EventFragment; + "WorkerRegistered(address,address)": EventFragment; + "WorkerUnregistered(address,address)": EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: "MinimumStakeAmount"): EventFragment; + getEvent(nameOrSignatureOrTopic: "RelayerBalanceNullified"): EventFragment; + getEvent(nameOrSignatureOrTopic: "RelayerRegistered"): EventFragment; + getEvent(nameOrSignatureOrTopic: "RouterRegistered"): EventFragment; + getEvent(nameOrSignatureOrTopic: "StakeAddedToRelayer"): EventFragment; + getEvent(nameOrSignatureOrTopic: "StakeBurned"): EventFragment; + getEvent(nameOrSignatureOrTopic: "WorkerRegistered"): EventFragment; + getEvent(nameOrSignatureOrTopic: "WorkerUnregistered"): EventFragment; +} + +export interface MinimumStakeAmountEventObject { + minStakeAmount: BigNumber; +} +export type MinimumStakeAmountEvent = TypedEvent< + [BigNumber], + MinimumStakeAmountEventObject +>; + +export type MinimumStakeAmountEventFilter = + TypedEventFilter; + +export interface RelayerBalanceNullifiedEventObject { + relayer: string; +} +export type RelayerBalanceNullifiedEvent = TypedEvent< + [string], + RelayerBalanceNullifiedEventObject +>; + +export type RelayerBalanceNullifiedEventFilter = + TypedEventFilter; + +export interface RelayerRegisteredEventObject { + relayer: string; + ensName: string; + relayerAddress: string; + stakedAmount: BigNumber; +} +export type RelayerRegisteredEvent = TypedEvent< + [string, string, string, BigNumber], + RelayerRegisteredEventObject +>; + +export type RelayerRegisteredEventFilter = + TypedEventFilter; + +export interface RouterRegisteredEventObject { + tornadoRouter: string; +} +export type RouterRegisteredEvent = TypedEvent< + [string], + RouterRegisteredEventObject +>; + +export type RouterRegisteredEventFilter = + TypedEventFilter; + +export interface StakeAddedToRelayerEventObject { + relayer: string; + amountStakeAdded: BigNumber; +} +export type StakeAddedToRelayerEvent = TypedEvent< + [string, BigNumber], + StakeAddedToRelayerEventObject +>; + +export type StakeAddedToRelayerEventFilter = + TypedEventFilter; + +export interface StakeBurnedEventObject { + relayer: string; + amountBurned: BigNumber; +} +export type StakeBurnedEvent = TypedEvent< + [string, BigNumber], + StakeBurnedEventObject +>; + +export type StakeBurnedEventFilter = TypedEventFilter; + +export interface WorkerRegisteredEventObject { + relayer: string; + worker: string; +} +export type WorkerRegisteredEvent = TypedEvent< + [string, string], + WorkerRegisteredEventObject +>; + +export type WorkerRegisteredEventFilter = + TypedEventFilter; + +export interface WorkerUnregisteredEventObject { + relayer: string; + worker: string; +} +export type WorkerUnregisteredEvent = TypedEvent< + [string, string], + WorkerUnregisteredEventObject +>; + +export type WorkerUnregisteredEventFilter = + TypedEventFilter; + +export interface RelayerRegistryAbi extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: RelayerRegistryAbiInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + bulkResolve( + domains: BytesLike[], + overrides?: CallOverrides + ): Promise<[string[]] & { result: string[] }>; + + burn( + sender: string, + relayer: string, + pool: string, + overrides?: Overrides & { from?: string } + ): Promise; + + ens(overrides?: CallOverrides): Promise<[string]>; + + feeManager(overrides?: CallOverrides): Promise<[string]>; + + getRelayerBalance( + relayer: string, + overrides?: CallOverrides + ): Promise<[BigNumber]>; + + getRelayerEnsHash( + relayer: string, + overrides?: CallOverrides + ): Promise<[string]>; + + governance(overrides?: CallOverrides): Promise<[string]>; + + initialize( + _tornadoRouter: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + isRelayer(toResolve: string, overrides?: CallOverrides): Promise<[boolean]>; + + isRelayerRegistered( + relayer: string, + toResolve: string, + overrides?: CallOverrides + ): Promise<[boolean]>; + + minStakeAmount(overrides?: CallOverrides): Promise<[BigNumber]>; + + nullifyBalance( + relayer: string, + overrides?: Overrides & { from?: string } + ): Promise; + + register( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + overrides?: Overrides & { from?: string } + ): Promise; + + registerPermit( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + relayer: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + registerWorker( + relayer: string, + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + relayers( + arg0: string, + overrides?: CallOverrides + ): Promise<[BigNumber, string] & { balance: BigNumber; ensHash: string }>; + + resolve(node: BytesLike, overrides?: CallOverrides): Promise<[string]>; + + setMinStakeAmount( + minAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setTornadoRouter( + tornadoRouterAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayer( + relayer: string, + stake: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayerPermit( + relayer: string, + stake: BigNumberish, + staker: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + staking(overrides?: CallOverrides): Promise<[string]>; + + torn(overrides?: CallOverrides): Promise<[string]>; + + tornadoRouter(overrides?: CallOverrides): Promise<[string]>; + + unregisterWorker( + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + workers(arg0: string, overrides?: CallOverrides): Promise<[string]>; + }; + + bulkResolve( + domains: BytesLike[], + overrides?: CallOverrides + ): Promise; + + burn( + sender: string, + relayer: string, + pool: string, + overrides?: Overrides & { from?: string } + ): Promise; + + ens(overrides?: CallOverrides): Promise; + + feeManager(overrides?: CallOverrides): Promise; + + getRelayerBalance( + relayer: string, + overrides?: CallOverrides + ): Promise; + + getRelayerEnsHash( + relayer: string, + overrides?: CallOverrides + ): Promise; + + governance(overrides?: CallOverrides): Promise; + + initialize( + _tornadoRouter: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + isRelayer(toResolve: string, overrides?: CallOverrides): Promise; + + isRelayerRegistered( + relayer: string, + toResolve: string, + overrides?: CallOverrides + ): Promise; + + minStakeAmount(overrides?: CallOverrides): Promise; + + nullifyBalance( + relayer: string, + overrides?: Overrides & { from?: string } + ): Promise; + + register( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + overrides?: Overrides & { from?: string } + ): Promise; + + registerPermit( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + relayer: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + registerWorker( + relayer: string, + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + relayers( + arg0: string, + overrides?: CallOverrides + ): Promise<[BigNumber, string] & { balance: BigNumber; ensHash: string }>; + + resolve(node: BytesLike, overrides?: CallOverrides): Promise; + + setMinStakeAmount( + minAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setTornadoRouter( + tornadoRouterAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayer( + relayer: string, + stake: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayerPermit( + relayer: string, + stake: BigNumberish, + staker: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + staking(overrides?: CallOverrides): Promise; + + torn(overrides?: CallOverrides): Promise; + + tornadoRouter(overrides?: CallOverrides): Promise; + + unregisterWorker( + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + workers(arg0: string, overrides?: CallOverrides): Promise; + + callStatic: { + bulkResolve( + domains: BytesLike[], + overrides?: CallOverrides + ): Promise; + + burn( + sender: string, + relayer: string, + pool: string, + overrides?: CallOverrides + ): Promise; + + ens(overrides?: CallOverrides): Promise; + + feeManager(overrides?: CallOverrides): Promise; + + getRelayerBalance( + relayer: string, + overrides?: CallOverrides + ): Promise; + + getRelayerEnsHash( + relayer: string, + overrides?: CallOverrides + ): Promise; + + governance(overrides?: CallOverrides): Promise; + + initialize( + _tornadoRouter: BytesLike, + overrides?: CallOverrides + ): Promise; + + isRelayer(toResolve: string, overrides?: CallOverrides): Promise; + + isRelayerRegistered( + relayer: string, + toResolve: string, + overrides?: CallOverrides + ): Promise; + + minStakeAmount(overrides?: CallOverrides): Promise; + + nullifyBalance(relayer: string, overrides?: CallOverrides): Promise; + + register( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + overrides?: CallOverrides + ): Promise; + + registerPermit( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + relayer: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + registerWorker( + relayer: string, + worker: string, + overrides?: CallOverrides + ): Promise; + + relayers( + arg0: string, + overrides?: CallOverrides + ): Promise<[BigNumber, string] & { balance: BigNumber; ensHash: string }>; + + resolve(node: BytesLike, overrides?: CallOverrides): Promise; + + setMinStakeAmount( + minAmount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + setTornadoRouter( + tornadoRouterAddress: string, + overrides?: CallOverrides + ): Promise; + + stakeToRelayer( + relayer: string, + stake: BigNumberish, + overrides?: CallOverrides + ): Promise; + + stakeToRelayerPermit( + relayer: string, + stake: BigNumberish, + staker: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides + ): Promise; + + staking(overrides?: CallOverrides): Promise; + + torn(overrides?: CallOverrides): Promise; + + tornadoRouter(overrides?: CallOverrides): Promise; + + unregisterWorker(worker: string, overrides?: CallOverrides): Promise; + + workers(arg0: string, overrides?: CallOverrides): Promise; + }; + + filters: { + "MinimumStakeAmount(uint256)"( + minStakeAmount?: null + ): MinimumStakeAmountEventFilter; + MinimumStakeAmount(minStakeAmount?: null): MinimumStakeAmountEventFilter; + + "RelayerBalanceNullified(address)"( + relayer?: null + ): RelayerBalanceNullifiedEventFilter; + RelayerBalanceNullified(relayer?: null): RelayerBalanceNullifiedEventFilter; + + "RelayerRegistered(bytes32,string,address,uint256)"( + relayer?: null, + ensName?: null, + relayerAddress?: null, + stakedAmount?: null + ): RelayerRegisteredEventFilter; + RelayerRegistered( + relayer?: null, + ensName?: null, + relayerAddress?: null, + stakedAmount?: null + ): RelayerRegisteredEventFilter; + + "RouterRegistered(address)"( + tornadoRouter?: null + ): RouterRegisteredEventFilter; + RouterRegistered(tornadoRouter?: null): RouterRegisteredEventFilter; + + "StakeAddedToRelayer(address,uint256)"( + relayer?: null, + amountStakeAdded?: null + ): StakeAddedToRelayerEventFilter; + StakeAddedToRelayer( + relayer?: null, + amountStakeAdded?: null + ): StakeAddedToRelayerEventFilter; + + "StakeBurned(address,uint256)"( + relayer?: null, + amountBurned?: null + ): StakeBurnedEventFilter; + StakeBurned(relayer?: null, amountBurned?: null): StakeBurnedEventFilter; + + "WorkerRegistered(address,address)"( + relayer?: null, + worker?: null + ): WorkerRegisteredEventFilter; + WorkerRegistered( + relayer?: null, + worker?: null + ): WorkerRegisteredEventFilter; + + "WorkerUnregistered(address,address)"( + relayer?: null, + worker?: null + ): WorkerUnregisteredEventFilter; + WorkerUnregistered( + relayer?: null, + worker?: null + ): WorkerUnregisteredEventFilter; + }; + + estimateGas: { + bulkResolve( + domains: BytesLike[], + overrides?: CallOverrides + ): Promise; + + burn( + sender: string, + relayer: string, + pool: string, + overrides?: Overrides & { from?: string } + ): Promise; + + ens(overrides?: CallOverrides): Promise; + + feeManager(overrides?: CallOverrides): Promise; + + getRelayerBalance( + relayer: string, + overrides?: CallOverrides + ): Promise; + + getRelayerEnsHash( + relayer: string, + overrides?: CallOverrides + ): Promise; + + governance(overrides?: CallOverrides): Promise; + + initialize( + _tornadoRouter: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + isRelayer(toResolve: string, overrides?: CallOverrides): Promise; + + isRelayerRegistered( + relayer: string, + toResolve: string, + overrides?: CallOverrides + ): Promise; + + minStakeAmount(overrides?: CallOverrides): Promise; + + nullifyBalance( + relayer: string, + overrides?: Overrides & { from?: string } + ): Promise; + + register( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + overrides?: Overrides & { from?: string } + ): Promise; + + registerPermit( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + relayer: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + registerWorker( + relayer: string, + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + relayers(arg0: string, overrides?: CallOverrides): Promise; + + resolve(node: BytesLike, overrides?: CallOverrides): Promise; + + setMinStakeAmount( + minAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setTornadoRouter( + tornadoRouterAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayer( + relayer: string, + stake: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayerPermit( + relayer: string, + stake: BigNumberish, + staker: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + staking(overrides?: CallOverrides): Promise; + + torn(overrides?: CallOverrides): Promise; + + tornadoRouter(overrides?: CallOverrides): Promise; + + unregisterWorker( + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + workers(arg0: string, overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + bulkResolve( + domains: BytesLike[], + overrides?: CallOverrides + ): Promise; + + burn( + sender: string, + relayer: string, + pool: string, + overrides?: Overrides & { from?: string } + ): Promise; + + ens(overrides?: CallOverrides): Promise; + + feeManager(overrides?: CallOverrides): Promise; + + getRelayerBalance( + relayer: string, + overrides?: CallOverrides + ): Promise; + + getRelayerEnsHash( + relayer: string, + overrides?: CallOverrides + ): Promise; + + governance(overrides?: CallOverrides): Promise; + + initialize( + _tornadoRouter: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + isRelayer( + toResolve: string, + overrides?: CallOverrides + ): Promise; + + isRelayerRegistered( + relayer: string, + toResolve: string, + overrides?: CallOverrides + ): Promise; + + minStakeAmount(overrides?: CallOverrides): Promise; + + nullifyBalance( + relayer: string, + overrides?: Overrides & { from?: string } + ): Promise; + + register( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + overrides?: Overrides & { from?: string } + ): Promise; + + registerPermit( + ensName: string, + stake: BigNumberish, + workersToRegister: string[], + relayer: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + registerWorker( + relayer: string, + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + relayers( + arg0: string, + overrides?: CallOverrides + ): Promise; + + resolve( + node: BytesLike, + overrides?: CallOverrides + ): Promise; + + setMinStakeAmount( + minAmount: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + setTornadoRouter( + tornadoRouterAddress: string, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayer( + relayer: string, + stake: BigNumberish, + overrides?: Overrides & { from?: string } + ): Promise; + + stakeToRelayerPermit( + relayer: string, + stake: BigNumberish, + staker: string, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string } + ): Promise; + + staking(overrides?: CallOverrides): Promise; + + torn(overrides?: CallOverrides): Promise; + + tornadoRouter(overrides?: CallOverrides): Promise; + + unregisterWorker( + worker: string, + overrides?: Overrides & { from?: string } + ): Promise; + + workers( + arg0: string, + overrides?: CallOverrides + ): Promise; + }; +} diff --git a/src/contracts/factories/RelayerRegistryAbi__factory.ts b/src/contracts/factories/RelayerRegistryAbi__factory.ts new file mode 100644 index 0000000..e74639f --- /dev/null +++ b/src/contracts/factories/RelayerRegistryAbi__factory.ts @@ -0,0 +1,694 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from "ethers"; +import type { Provider } from "@ethersproject/providers"; +import type { + RelayerRegistryAbi, + RelayerRegistryAbiInterface, +} from "../RelayerRegistryAbi"; + +const _abi = [ + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address", + }, + { + internalType: "address", + name: "_governance", + type: "address", + }, + { + internalType: "address", + name: "_ens", + type: "address", + }, + { + internalType: "address", + name: "_staking", + type: "address", + }, + { + internalType: "address", + name: "_feeManager", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "minStakeAmount", + type: "uint256", + }, + ], + name: "MinimumStakeAmount", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address", + }, + ], + name: "RelayerBalanceNullified", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "relayer", + type: "bytes32", + }, + { + indexed: false, + internalType: "string", + name: "ensName", + type: "string", + }, + { + indexed: false, + internalType: "address", + name: "relayerAddress", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "stakedAmount", + type: "uint256", + }, + ], + name: "RelayerRegistered", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "tornadoRouter", + type: "address", + }, + ], + name: "RouterRegistered", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amountStakeAdded", + type: "uint256", + }, + ], + name: "StakeAddedToRelayer", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amountBurned", + type: "uint256", + }, + ], + name: "StakeBurned", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "worker", + type: "address", + }, + ], + name: "WorkerRegistered", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "worker", + type: "address", + }, + ], + name: "WorkerUnregistered", + type: "event", + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "domains", + type: "bytes32[]", + }, + ], + name: "bulkResolve", + outputs: [ + { + internalType: "address[]", + name: "result", + type: "address[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "address", + name: "relayer", + type: "address", + }, + { + internalType: "contract ITornadoInstance", + name: "pool", + type: "address", + }, + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "ens", + outputs: [ + { + internalType: "contract IENS", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "feeManager", + outputs: [ + { + internalType: "contract IFeeManager", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + ], + name: "getRelayerBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + ], + name: "getRelayerEnsHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_tornadoRouter", + type: "bytes32", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "toResolve", + type: "address", + }, + ], + name: "isRelayer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + { + internalType: "address", + name: "toResolve", + type: "address", + }, + ], + name: "isRelayerRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "minStakeAmount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + ], + name: "nullifyBalance", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "string", + name: "ensName", + type: "string", + }, + { + internalType: "uint256", + name: "stake", + type: "uint256", + }, + { + internalType: "address[]", + name: "workersToRegister", + type: "address[]", + }, + ], + name: "register", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "string", + name: "ensName", + type: "string", + }, + { + internalType: "uint256", + name: "stake", + type: "uint256", + }, + { + internalType: "address[]", + name: "workersToRegister", + type: "address[]", + }, + { + internalType: "address", + name: "relayer", + 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", + }, + ], + name: "registerPermit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + { + internalType: "address", + name: "worker", + type: "address", + }, + ], + name: "registerWorker", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "relayers", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256", + }, + { + internalType: "bytes32", + name: "ensHash", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32", + }, + ], + name: "resolve", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "minAmount", + type: "uint256", + }, + ], + name: "setMinStakeAmount", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "tornadoRouterAddress", + type: "address", + }, + ], + name: "setTornadoRouter", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + { + internalType: "uint256", + name: "stake", + type: "uint256", + }, + ], + name: "stakeToRelayer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address", + }, + { + internalType: "uint256", + name: "stake", + type: "uint256", + }, + { + internalType: "address", + name: "staker", + 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", + }, + ], + name: "stakeToRelayerPermit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "staking", + outputs: [ + { + internalType: "contract TornadoStakingRewards", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "tornadoRouter", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "worker", + type: "address", + }, + ], + name: "unregisterWorker", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "workers", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class RelayerRegistryAbi__factory { + static readonly abi = _abi; + static createInterface(): RelayerRegistryAbiInterface { + return new utils.Interface(_abi) as RelayerRegistryAbiInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): RelayerRegistryAbi { + return new Contract(address, _abi, signerOrProvider) as RelayerRegistryAbi; + } +} diff --git a/src/contracts/factories/index.ts b/src/contracts/factories/index.ts index 9f71a6a..c0dcbf9 100644 --- a/src/contracts/factories/index.ts +++ b/src/contracts/factories/index.ts @@ -7,5 +7,6 @@ export { MulticallAbi__factory } from "./MulticallAbi__factory"; export { OffchainOracleAbi__factory } from "./OffchainOracleAbi__factory"; export { OvmGasPriceOracleAbi__factory } from "./OvmGasPriceOracleAbi__factory"; export { ProxyLightAbi__factory } from "./ProxyLightAbi__factory"; +export { RelayerRegistryAbi__factory } from "./RelayerRegistryAbi__factory"; export { TornadoInstanceAbi__factory } from "./TornadoInstanceAbi__factory"; export { TornadoProxyAbi__factory } from "./TornadoProxyAbi__factory"; diff --git a/src/contracts/index.ts b/src/contracts/index.ts index 6fece1b..0afd350 100644 --- a/src/contracts/index.ts +++ b/src/contracts/index.ts @@ -7,6 +7,7 @@ export type { MulticallAbi } from "./MulticallAbi"; export type { OffchainOracleAbi } from "./OffchainOracleAbi"; export type { OvmGasPriceOracleAbi } from "./OvmGasPriceOracleAbi"; export type { ProxyLightAbi } from "./ProxyLightAbi"; +export type { RelayerRegistryAbi } from "./RelayerRegistryAbi"; export type { TornadoInstanceAbi } from "./TornadoInstanceAbi"; export type { TornadoProxyAbi } from "./TornadoProxyAbi"; export * as factories from "./factories"; @@ -16,5 +17,6 @@ export { MulticallAbi__factory } from "./factories/MulticallAbi__factory"; export { OffchainOracleAbi__factory } from "./factories/OffchainOracleAbi__factory"; export { OvmGasPriceOracleAbi__factory } from "./factories/OvmGasPriceOracleAbi__factory"; export { ProxyLightAbi__factory } from "./factories/ProxyLightAbi__factory"; +export { RelayerRegistryAbi__factory } from "./factories/RelayerRegistryAbi__factory"; export { TornadoInstanceAbi__factory } from "./factories/TornadoInstanceAbi__factory"; export { TornadoProxyAbi__factory } from "./factories/TornadoProxyAbi__factory"; diff --git a/src/modules/contracts.ts b/src/modules/contracts.ts index f30cef8..aacbfdd 100644 --- a/src/modules/contracts.ts +++ b/src/modules/contracts.ts @@ -4,6 +4,7 @@ import { OffchainOracleAbi__factory, OvmGasPriceOracleAbi__factory, ProxyLightAbi__factory, + RelayerRegistryAbi__factory, TornadoProxyAbi__factory, } from '../contracts'; import { providers } from 'ethers'; @@ -41,6 +42,11 @@ export const getMultiCallContract = () => { export const getTornTokenContract = (tokenAddress: string) => { return ERC20Abi__factory.connect(tokenAddress, getProvider(true, mainnetRpcUrl)); }; + export const getOvmGasPriceOracle = () => { return OvmGasPriceOracleAbi__factory.connect(ovmGasPriceOracleContract, getProvider()); }; + +export const getRelayerRegistryContract = (relayerRegistryAddress: string) => { + return RelayerRegistryAbi__factory.connect(relayerRegistryAddress, getProvider(true, mainnetRpcUrl)); +}; diff --git a/src/services/config.service.ts b/src/services/config.service.ts index 232386a..f84ce16 100644 --- a/src/services/config.service.ts +++ b/src/services/config.service.ts @@ -14,9 +14,15 @@ import { tornToken, } from '../config'; import { ChainIds, Token } from '../types'; -import { getProvider, getTornadoProxyContract, getTornadoProxyLightContract, getTornTokenContract } from '../modules/contracts'; +import { + getProvider, + getRelayerRegistryContract, + getTornadoProxyContract, + getTornadoProxyLightContract, + getTornTokenContract, +} from '../modules/contracts'; import { resolve } from '../modules'; -import { ERC20Abi, ProxyLightAbi, TornadoProxyAbi } from '../contracts'; +import { ERC20Abi, ProxyLightAbi, RelayerRegistryAbi, TornadoProxyAbi } from '../contracts'; import { availableIds, netIds, NetInstances } from 'torn-token'; import { getAddress } from 'ethers/lib/utils'; import { BigNumber, providers, Wallet } from 'ethers'; @@ -47,6 +53,8 @@ export class ConfigService { fallbackGasPrices: FallbackGasPrices; private _tokenAddress: string; private _tokenContract: ERC20Abi; + private _relayerRegistryAddress: string; + private _relayerRegistryContract: RelayerRegistryAbi; balances: { MAIN: { warn: string; critical: string }; TORN: { warn: string; critical: string }; @@ -85,6 +93,10 @@ export class ConfigService { return this._tokenContract; } + get relayerRegistryContract(): RelayerRegistryAbi { + return this._relayerRegistryContract; + } + private _fillInstanceMap() { if (!this.instances) throw new Error('config mismatch, check your environment variables'); for (const [currency, { instanceAddress, symbol, decimals }] of Object.entries(this.instances)) { @@ -113,8 +125,13 @@ export class ConfigService { if (this.isInit) return; await this.checkNetwork(); console.log('Initializing...'); + this._tokenAddress = await resolve(torn.torn.address); this._tokenContract = getTornTokenContract(this._tokenAddress); + + this._relayerRegistryAddress = await resolve(torn.relayerRegistry.address); + this._relayerRegistryContract = getRelayerRegistryContract(this._relayerRegistryAddress); + if (this.isLightMode) { this._proxyAddress = torn.tornadoProxyLight.address; this._proxyContract = getTornadoProxyLightContract(this._proxyAddress); diff --git a/src/services/health.service.ts b/src/services/health.service.ts index 2cf19c6..8bac363 100644 --- a/src/services/health.service.ts +++ b/src/services/health.service.ts @@ -142,7 +142,7 @@ export class HealthService { async check() { await this.config.checkNetwork(); const mainBalance = await this.config.wallet.getBalance(); - const tornBalance = await this.config.tokenContract.balanceOf(this.config.wallet.address); + const tornBalance = await this.config.relayerRegistryContract.getRelayerBalance(this.config.wallet.address); const mainStatus = await this._checkBalance(mainBalance, 'MAIN'); const tornStatus = await this._checkBalance(tornBalance, 'TORN'); if (mainStatus.level === 'CRITICAL') {