From 65dc698022fd54e9c33b521e93c9d2617ca7f6ce Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Tue, 8 Dec 2020 15:33:02 +0300 Subject: [PATCH] Fix interaction with the legacy v1 contracts --- commons/v1Abis.js | 122 ++++++++++++++++++++++++++++++ monitor/getRequestsOutOfLimits.js | 10 ++- 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/commons/v1Abis.js b/commons/v1Abis.js index 815b630a..297a626b 100644 --- a/commons/v1Abis.js +++ b/commons/v1Abis.js @@ -79,6 +79,67 @@ const homeV1Abi = [ payable: false, stateMutability: 'view', type: 'function' + }, + { + constant: true, + inputs: [], + name: 'foreignDailyLimit', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'foreignMaxPerTx', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'getCurrentDay', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [ + { + name: '', + type: 'uint256' + } + ], + name: 'totalExecutedPerDay', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' } ] @@ -182,6 +243,67 @@ const foreignViAbi = [ payable: false, stateMutability: 'view', type: 'function' + }, + { + constant: true, + inputs: [], + name: 'homeDailyLimit', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'homeMaxPerTx', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'getCurrentDay', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [ + { + name: '', + type: 'uint256' + } + ], + name: 'totalExecutedPerDay', + outputs: [ + { + name: '', + type: 'uint256' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' } ] diff --git a/monitor/getRequestsOutOfLimits.js b/monitor/getRequestsOutOfLimits.js index 451c5c71..194f5c88 100644 --- a/monitor/getRequestsOutOfLimits.js +++ b/monitor/getRequestsOutOfLimits.js @@ -2,7 +2,7 @@ require('dotenv').config() const BN = require('bignumber.js') const { fromWei } = require('web3').utils const logger = require('./logger')('getRequestsOutOfLimits') -const { getBridgeABIs } = require('../commons') +const { BRIDGE_MODES, getBridgeABIs } = require('../commons') const { web3Home, web3Foreign } = require('./utils/web3') const { COMMON_HOME_BRIDGE_ADDRESS, COMMON_FOREIGN_BRIDGE_ADDRESS } = process.env @@ -53,6 +53,14 @@ async function main(bridgeMode, unprocessedRequests) { const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, COMMON_FOREIGN_BRIDGE_ADDRESS) const homeBridge = new web3Home.eth.Contract(HOME_ABI, COMMON_HOME_BRIDGE_ADDRESS) + // replace the required methods by their legacy versions + if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) { + homeBridge.methods.executionDailyLimit = homeBridge.methods.foreignDailyLimit + homeBridge.methods.executionMaxPerTx = homeBridge.methods.foreignMaxPerTx + foreignBridge.methods.executionDailyLimit = foreignBridge.methods.homeDailyLimit + foreignBridge.methods.executionMaxPerTx = foreignBridge.methods.homeMaxPerTx + } + return { home: await checkOutOfLimitsStats(homeBridge, foreignRequests), foreign: await checkOutOfLimitsStats(foreignBridge, homeRequests)