From 524da2accf2278d084af955c27a5c6bcdedaf572 Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Mon, 15 May 2023 20:55:17 +0000 Subject: [PATCH] services/registry: fetch min stake amount before filtering Signed-off-by: AlienTornadosaurusHex <> --- services/registry/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/registry/index.js b/services/registry/index.js index 056224a..aae4438 100644 --- a/services/registry/index.js +++ b/services/registry/index.js @@ -10,8 +10,6 @@ import { sleep, flattenNArray } from '@/utils' import AggregatorABI from '@/abis/Aggregator.abi.json' import RelayerRegistryABI from '@/abis/RelayerRegistry.abi.json' -const MIN_STAKE_BALANCE = '0X1B1AE4D6E2EF500000' // 500 TORN - const subdomains = Object.values(networkConfig).map(({ ensSubdomainKey }) => ensSubdomainKey) class RelayerRegister { @@ -219,14 +217,14 @@ class RelayerRegister { return allRelayers } - filterRelayer = (acc, curr, ensSubdomainKey, relayer) => { + filterRelayer = (acc, curr, ensSubdomainKey, relayer, minStakeAmount) => { const subdomainIndex = subdomains.indexOf(ensSubdomainKey) const mainnetSubdomain = curr.records[0] const hostname = curr.records[subdomainIndex] const isHostWithProtocol = hostname.includes('http') const isOwner = relayer.relayerAddress === curr.owner - const hasMinBalance = new BN(curr.balance).gte(MIN_STAKE_BALANCE) + const hasMinBalance = new BN(curr.balance).gte(minStakeAmount) if ( hostname && @@ -261,8 +259,10 @@ class RelayerRegister { const relayersData = await this.aggregator.methods.relayersData(relayerNameHashes, subdomains).call() + const minStakeAmount = await this.relayerRegistry.minStakeAmount() + const validRelayers = relayersData.reduce( - (acc, curr, index) => this.filterRelayer(acc, curr, ensSubdomainKey, relayers[index]), + (acc, curr, index) => this.filterRelayer(acc, curr, ensSubdomainKey, relayers[index], minStakeAmount), [] )