diff --git a/commons/abis.js b/commons/abis.js index 655c785f..3664b77f 100644 --- a/commons/abis.js +++ b/commons/abis.js @@ -14,9 +14,40 @@ const BLOCK_REWARD_ABI = require('../contracts/build/contracts/IBlockReward').ab const BRIDGE_VALIDATORS_ABI = require('../contracts/build/contracts/BridgeValidators').abi const REWARDABLE_VALIDATORS_ABI = require('../contracts/build/contracts/RewardableValidators').abi -const { homeV1Abi, foreignViAbi } = require('./v1Abis') +const { HOME_V1_ABI, FOREIGN_V1_ABI } = require('./v1Abis') const { BRIDGE_MODES } = require('./constants') +const ERC20_BYTES32_ABI = [ + { + constant: true, + inputs: [], + name: 'name', + outputs: [ + { + name: '', + type: 'bytes32' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + }, + { + constant: true, + inputs: [], + name: 'symbol', + outputs: [ + { + name: '', + type: 'bytes32' + } + ], + payable: false, + stateMutability: 'view', + type: 'function' + } +] + function getBridgeABIs(bridgeMode) { let HOME_ABI = null let FOREIGN_ABI = null @@ -30,8 +61,8 @@ function getBridgeABIs(bridgeMode) { HOME_ABI = HOME_ERC_TO_NATIVE_ABI FOREIGN_ABI = FOREIGN_ERC_TO_NATIVE_ABI } else if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) { - HOME_ABI = homeV1Abi - FOREIGN_ABI = foreignViAbi + HOME_ABI = HOME_V1_ABI + FOREIGN_ABI = FOREIGN_V1_ABI } else { throw new Error(`Unrecognized bridge mode: ${bridgeMode}`) } @@ -52,5 +83,8 @@ module.exports = { ERC677_BRIDGE_TOKEN_ABI, BLOCK_REWARD_ABI, BRIDGE_VALIDATORS_ABI, - REWARDABLE_VALIDATORS_ABI + REWARDABLE_VALIDATORS_ABI, + HOME_V1_ABI, + FOREIGN_V1_ABI, + ERC20_BYTES32_ABI } diff --git a/commons/v1Abis.js b/commons/v1Abis.js index ba8cc8f5..9f9e866c 100644 --- a/commons/v1Abis.js +++ b/commons/v1Abis.js @@ -158,6 +158,6 @@ const foreignViAbi = [ ] module.exports = { - homeV1Abi, - foreignViAbi + HOME_V1_ABI: homeV1Abi, + FOREIGN_V1_ABI: foreignViAbi } diff --git a/monitor/stuckTransfers.js b/monitor/stuckTransfers.js index 21ec022e..7f98a40e 100644 --- a/monitor/stuckTransfers.js +++ b/monitor/stuckTransfers.js @@ -1,7 +1,7 @@ require('dotenv').config() const Web3 = require('web3') const logger = require('./logger')('stuckTransfers.js') -const { foreignViAbi } = require('../commons/abis') +const { FOREIGN_V1_ABI } = require('../commons/abis') const { FOREIGN_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env const FOREIGN_DEPLOYMENT_BLOCK = Number(process.env.FOREIGN_DEPLOYMENT_BLOCK) || 0 @@ -75,7 +75,7 @@ function compareTransfers(transfersNormal) { } async function main() { - const foreignBridge = new web3Foreign.eth.Contract(foreignViAbi, FOREIGN_BRIDGE_ADDRESS) + const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_V1_ABI, FOREIGN_BRIDGE_ADDRESS) const erc20Address = await foreignBridge.methods.erc677token().call() const tokenContract = new web3Foreign.eth.Contract(ABITransferWithoutData, erc20Address) const tokenContractWithData = new web3Foreign.eth.Contract(ABIWithData, erc20Address) diff --git a/ui/src/stores/ForeignStore.js b/ui/src/stores/ForeignStore.js index 73354457..0cd5d17e 100644 --- a/ui/src/stores/ForeignStore.js +++ b/ui/src/stores/ForeignStore.js @@ -7,7 +7,8 @@ import { FEE_MANAGER_MODE, getUnit, decodeFeeManagerMode, - getBridgeABIs + getBridgeABIs, + ERC20_BYTES32_ABI } from '../../../commons' import { getMaxPerTxLimit, @@ -34,7 +35,6 @@ import { } from './utils/contract' import { balanceLoaded, removePendingTransaction } from './utils/testUtils' import sleep from './utils/sleep' -import ERC20Bytes32Abi from './utils/ERC20Bytes32.abi' import BN from 'bignumber.js' import { processLargeArrayAsync } from './utils/array' import { fromDecimals } from './utils/decimals' @@ -192,7 +192,7 @@ class ForeignStore { ) this.tokenType = await getTokenType(this.tokenContract, this.FOREIGN_BRIDGE_ADDRESS) const alternativeContract = new this.foreignWeb3.eth.Contract( - ERC20Bytes32Abi, + ERC20_BYTES32_ABI, this.tokenAddress ) try { diff --git a/ui/src/stores/HomeStore.js b/ui/src/stores/HomeStore.js index 3a7a89ec..f16ad537 100644 --- a/ui/src/stores/HomeStore.js +++ b/ui/src/stores/HomeStore.js @@ -9,7 +9,9 @@ import { FEE_MANAGER_MODE, getUnit, decodeFeeManagerMode, - getBridgeABIs + getBridgeABIs, + HOME_V1_ABI, + ERC20_BYTES32_ABI } from '../../../commons' import { getMaxPerTxLimit, @@ -40,10 +42,8 @@ import { import { balanceLoaded, removePendingTransaction } from './utils/testUtils' import sleep from './utils/sleep' import BN from 'bignumber.js' -import ERC20Bytes32Abi from './utils/ERC20Bytes32.abi' import { processLargeArrayAsync } from './utils/array' import { getRewardableData } from './utils/rewardable' -import HomeBridgeV1Abi from './utils/HomeBridgeV1.abi' async function asyncForEach(array, callback) { for (let index = 0; index < array.length; index++) { @@ -199,7 +199,10 @@ class HomeStore { ) this.symbol = await getSymbol(this.tokenContract) this.tokenName = await getName(this.tokenContract) - const alternativeContract = new this.homeWeb3.eth.Contract(ERC20Bytes32Abi, this.tokenAddress) + const alternativeContract = new this.homeWeb3.eth.Contract( + ERC20_BYTES32_ABI, + this.tokenAddress + ) try { this.symbol = await getSymbol(this.tokenContract) } catch (e) { @@ -447,7 +450,7 @@ class HomeStore { try { const deployedAtBlock = await getDeployedAtBlock(this.homeBridge) const { HOME_ABI } = getBridgeABIs(this.rootStore.bridgeMode) - const abi = [...HomeBridgeV1Abi, ...HOME_ABI] + const abi = [...HOME_V1_ABI, ...HOME_ABI] const contract = new this.homeWeb3.eth.Contract(abi, this.HOME_BRIDGE_ADDRESS) const events = await getPastEvents(contract, deployedAtBlock, 'latest') processLargeArrayAsync(events, this.processEvent, () => { diff --git a/ui/src/stores/utils/ERC20Bytes32.abi.json b/ui/src/stores/utils/ERC20Bytes32.abi.json deleted file mode 100644 index 3c6ccd2d..00000000 --- a/ui/src/stores/utils/ERC20Bytes32.abi.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] diff --git a/ui/src/stores/utils/HomeBridgeV1.abi.json b/ui/src/stores/utils/HomeBridgeV1.abi.json deleted file mode 100644 index b8a4bc26..00000000 --- a/ui/src/stores/utils/HomeBridgeV1.abi.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "name": "transactionHash", - "type": "bytes32" - } - ], - "name": "Withdraw", - "type": "event" - } -]