Fix relayer balance checking: need to get relayer locked balance in relayer registry contract, not TORN token balance on relayer wallet
This commit is contained in:
parent
26fdb54fb0
commit
d69a17073a
297
abis/RelayerRegistry.abi.json
Normal file
297
abis/RelayerRegistry.abi.json
Normal file
@ -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"
|
||||
}
|
||||
]
|
@ -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();
|
||||
|
1070
src/contracts/RelayerRegistryAbi.ts
Normal file
1070
src/contracts/RelayerRegistryAbi.ts
Normal file
File diff suppressed because it is too large
Load Diff
694
src/contracts/factories/RelayerRegistryAbi__factory.ts
Normal file
694
src/contracts/factories/RelayerRegistryAbi__factory.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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));
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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') {
|
||||
|
Loading…
Reference in New Issue
Block a user