From 40be5a5f8e5fa5da70aed177eb662373cc9a639e Mon Sep 17 00:00:00 2001 From: Przemyslaw Rzad Date: Thu, 1 Aug 2019 15:10:22 +0200 Subject: [PATCH] Extend line width to 120 (#174) * Extend line width to 120 * Lint fixes --- .prettierrc | 2 +- commons/abis.js | 9 +- monitor/alerts.js | 26 +--- monitor/checkWorker.js | 10 +- monitor/checkWorker2.js | 10 +- monitor/checkWorker3.js | 5 +- monitor/eventsStats.js | 12 +- monitor/getBalances.js | 20 +-- monitor/getShortEventStats.js | 4 +- monitor/index.js | 3 +- monitor/logger.js | 7 +- monitor/utils/events.js | 3 +- monitor/validators.js | 10 +- oracle-e2e/test/ercToErc.js | 5 +- oracle-e2e/test/ercToNative.js | 5 +- .../affirmation-request-watcher.config.js | 3 +- oracle/config/base.config.js | 3 +- oracle/scripts/compute-stats.js | 5 +- oracle/scripts/erc20_to_erc20/sendHome.js | 3 +- oracle/scripts/getValidatorStartBlocks.js | 5 +- oracle/scripts/initialChecks.js | 5 +- oracle/scripts/native_to_erc20/sendForeign.js | 3 +- .../processAffirmationRequests/estimateGas.js | 28 +--- .../processAffirmationRequests/index.js | 19 +-- .../processCollectedSignatures/estimateGas.js | 20 +-- .../processCollectedSignatures/index.js | 41 ++---- .../processSignatureRequests/estimateGas.js | 6 +- .../events/processSignatureRequests/index.js | 19 +-- oracle/src/events/processTransfers/index.js | 14 +- oracle/src/sender.js | 8 +- oracle/src/services/amqpClient.js | 9 +- oracle/src/services/gasPrice.js | 6 +- oracle/src/services/logger.js | 3 +- oracle/src/tx/sendTx.js | 13 +- oracle/src/tx/web3.js | 5 +- oracle/src/utils/message.js | 13 +- oracle/src/utils/utils.js | 22 +-- oracle/src/watcher.js | 10 +- oracle/test/gasPrice.test.js | 22 +-- oracle/test/message.test.js | 15 +- ui-e2e/MetaMask.js | 11 +- ui-e2e/test.js | 136 ++++-------------- ui/config-overrides.js | 4 +- ui/src/App.js | 17 +-- ui/src/components/Bridge.js | 25 ++-- ui/src/components/BridgeAddress.js | 6 +- ui/src/components/BridgeNetwork.js | 10 +- ui/src/components/Configuration.js | 14 +- ui/src/components/Disclaimer.js | 18 +-- ui/src/components/FeeStatistics.js | 3 +- ui/src/components/Header.js | 12 +- ui/src/components/Loading.js | 9 +- ui/src/components/NetworkDetails.js | 12 +- ui/src/components/NoWallet.js | 7 +- ui/src/components/RelayEvents.js | 50 +++---- ui/src/components/StatisticsPage.js | 19 +-- ui/src/components/StatusPage.js | 12 +- ui/src/components/TransactionsStatistics.js | 6 +- ui/src/components/TransferAlert.js | 5 +- ui/src/components/Wallet.js | 4 +- .../__tests__/FeeStatistics.test.js | 20 +-- ui/src/components/events/Event.js | 11 +- ui/src/stores/ForeignStore.js | 33 +---- ui/src/stores/HomeStore.js | 53 ++----- ui/src/stores/RootStore.js | 5 +- ui/src/stores/Web3Store.js | 10 +- ui/src/stores/__tests__/HomeStore.test.js | 12 +- ui/src/stores/utils/decimals.js | 10 +- 68 files changed, 225 insertions(+), 740 deletions(-) diff --git a/.prettierrc b/.prettierrc index c8e7be8d..29c57560 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "semi": false, "singleQuote": true, - "printWidth": 100, + "printWidth": 120, "bracketSpacing": true } diff --git a/commons/abis.js b/commons/abis.js index 3664b77f..05e97a2b 100644 --- a/commons/abis.js +++ b/commons/abis.js @@ -1,12 +1,9 @@ const HOME_NATIVE_TO_ERC_ABI = require('../contracts/build/contracts/HomeBridgeNativeToErc').abi -const FOREIGN_NATIVE_TO_ERC_ABI = require('../contracts/build/contracts/ForeignBridgeNativeToErc') - .abi +const FOREIGN_NATIVE_TO_ERC_ABI = require('../contracts/build/contracts/ForeignBridgeNativeToErc').abi const HOME_ERC_TO_ERC_ABI = require('../contracts/build/contracts/HomeBridgeErcToErc').abi -const FOREIGN_ERC_TO_ERC_ABI = require('../contracts/build/contracts/ForeignBridgeErc677ToErc677') - .abi +const FOREIGN_ERC_TO_ERC_ABI = require('../contracts/build/contracts/ForeignBridgeErc677ToErc677').abi const HOME_ERC_TO_NATIVE_ABI = require('../contracts/build/contracts/HomeBridgeErcToNative').abi -const FOREIGN_ERC_TO_NATIVE_ABI = require('../contracts/build/contracts/ForeignBridgeErcToNative') - .abi +const FOREIGN_ERC_TO_NATIVE_ABI = require('../contracts/build/contracts/ForeignBridgeErcToNative').abi const ERC20_ABI = require('../contracts/build/contracts/ERC20').abi const ERC677_ABI = require('../contracts/build/contracts/ERC677').abi const ERC677_BRIDGE_TOKEN_ABI = require('../contracts/build/contracts/ERC677BridgeToken').abi diff --git a/monitor/alerts.js b/monitor/alerts.js index fd290d29..31f9e351 100644 --- a/monitor/alerts.js +++ b/monitor/alerts.js @@ -30,25 +30,15 @@ async function main() { ) logger.debug('extracting most recent transactionHash') - const { transactionHash: xSignaturesMostRecentTxHash = '' } = - xSignatures.sort(sortEvents).reverse()[0] || {} - const { transactionHash: xAffirmationsMostRecentTxHash = '' } = - xAffirmations.sort(sortEvents).reverse()[0] || {} + const { transactionHash: xSignaturesMostRecentTxHash = '' } = xSignatures.sort(sortEvents).reverse()[0] || {} + const { transactionHash: xAffirmationsMostRecentTxHash = '' } = xAffirmations.sort(sortEvents).reverse()[0] || {} logger.debug('building transaction objects') - const foreignValidators = await Promise.all( - xSignatures.map(event => findTxSender(web3Foreign)(event)) - ) - const homeValidators = await Promise.all( - xAffirmations.map(event => findTxSender(web3Home)(event)) - ) + const foreignValidators = await Promise.all(xSignatures.map(event => findTxSender(web3Foreign)(event))) + const homeValidators = await Promise.all(xAffirmations.map(event => findTxSender(web3Home)(event))) - const xSignaturesTxs = xSignatures - .map(normalizeEventInformation) - .reduce(buildTxList(foreignValidators), {}) - const xAffirmationsTxs = xAffirmations - .map(normalizeEventInformation) - .reduce(buildTxList(homeValidators), {}) + const xSignaturesTxs = xSignatures.map(normalizeEventInformation).reduce(buildTxList(foreignValidators), {}) + const xAffirmationsTxs = xAffirmations.map(normalizeEventInformation).reduce(buildTxList(homeValidators), {}) logger.debug('Done') @@ -166,9 +156,7 @@ const findDifferences = src => dest => { return ( src .map(normalizeEventInformation) - .filter( - a => a.referenceTx === b.referenceTx && a.recipient === b.recipient && a.value === b.value - ).length === 0 + .filter(a => a.referenceTx === b.referenceTx && a.recipient === b.recipient && a.value === b.value).length === 0 ) } diff --git a/monitor/checkWorker.js b/monitor/checkWorker.js index 884db163..896787b5 100644 --- a/monitor/checkWorker.js +++ b/monitor/checkWorker.js @@ -26,18 +26,12 @@ async function checkWorker() { const foreign = Object.assign({}, balances.foreign, events.foreign) const status = Object.assign({}, balances, events, { home }, { foreign }) if (!status) throw new Error('status is empty: ' + JSON.stringify(status)) - fs.writeFileSync( - path.join(__dirname, '/responses/getBalances.json'), - JSON.stringify(status, null, 4) - ) + fs.writeFileSync(path.join(__dirname, '/responses/getBalances.json'), JSON.stringify(status, null, 4)) logger.debug('calling validators()') const vBalances = await validators(bridgeMode) if (!vBalances) throw new Error('vBalances is empty: ' + JSON.stringify(vBalances)) - fs.writeFileSync( - path.join(__dirname, '/responses/validators.json'), - JSON.stringify(vBalances, null, 4) - ) + fs.writeFileSync(path.join(__dirname, '/responses/validators.json'), JSON.stringify(vBalances, null, 4)) logger.debug('Done') } catch (e) { logger.error(e) diff --git a/monitor/checkWorker2.js b/monitor/checkWorker2.js index be99c295..6375e47d 100644 --- a/monitor/checkWorker2.js +++ b/monitor/checkWorker2.js @@ -9,17 +9,11 @@ async function checkWorker2() { logger.debug('calling eventsStats()') const evStats = await eventsStats() if (!evStats) throw new Error('evStats is empty: ' + JSON.stringify(evStats)) - fs.writeFileSync( - path.join(__dirname, '/responses/eventsStats.json'), - JSON.stringify(evStats, null, 4) - ) + fs.writeFileSync(path.join(__dirname, '/responses/eventsStats.json'), JSON.stringify(evStats, null, 4)) logger.debug('calling alerts()') const _alerts = await alerts() if (!_alerts) throw new Error('alerts is empty: ' + JSON.stringify(_alerts)) - fs.writeFileSync( - path.join(__dirname, '/responses/alerts.json'), - JSON.stringify(_alerts, null, 4) - ) + fs.writeFileSync(path.join(__dirname, '/responses/alerts.json'), JSON.stringify(_alerts, null, 4)) logger.debug('Done x2') } catch (e) { logger.error(e) diff --git a/monitor/checkWorker3.js b/monitor/checkWorker3.js index 4b3fab27..d6ec4714 100644 --- a/monitor/checkWorker3.js +++ b/monitor/checkWorker3.js @@ -9,10 +9,7 @@ async function checkWorker3() { const transfers = await stuckTransfers() // console.log(transfers) if (!transfers) throw new Error('transfers is empty: ' + JSON.stringify(transfers)) - fs.writeFileSync( - path.join(__dirname, '/responses/stuckTransfers.json'), - JSON.stringify(transfers, null, 4) - ) + fs.writeFileSync(path.join(__dirname, '/responses/stuckTransfers.json'), JSON.stringify(transfers, null, 4)) logger.debug('Done') } catch (e) { logger.error('checkWorker3.js', e) diff --git a/monitor/eventsStats.js b/monitor/eventsStats.js index 7bd36959..a960bf1b 100644 --- a/monitor/eventsStats.js +++ b/monitor/eventsStats.js @@ -57,18 +57,10 @@ function compareTransferForeign(home) { } async function main() { - const { - foreignDeposits, - homeDeposits, - homeWithdrawals, - foreignWithdrawals, - isExternalErc20 - } = await eventsInfo() + const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals, isExternalErc20 } = await eventsInfo() const onlyInHomeDeposits = homeDeposits.filter(compareDepositsHome(foreignDeposits)) - const onlyInForeignDeposits = foreignDeposits - .concat([]) - .filter(compareDepositsForeign(homeDeposits)) + const onlyInForeignDeposits = foreignDeposits.concat([]).filter(compareDepositsForeign(homeDeposits)) const onlyInHomeWithdrawals = isExternalErc20 ? homeWithdrawals.filter(compareTransferHome(foreignWithdrawals)) diff --git a/monitor/getBalances.js b/monitor/getBalances.js index 7ac381b8..29060985 100644 --- a/monitor/getBalances.js +++ b/monitor/getBalances.js @@ -27,10 +27,7 @@ const { async function main(bridgeMode) { if (bridgeMode === BRIDGE_MODES.ERC_TO_ERC) { - const foreignBridge = new web3Foreign.eth.Contract( - FOREIGN_ERC_TO_ERC_ABI, - FOREIGN_BRIDGE_ADDRESS - ) + const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ERC_TO_ERC_ABI, FOREIGN_BRIDGE_ADDRESS) const erc20Address = await foreignBridge.methods.erc20token().call() const erc20Contract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address) logger.debug('calling erc20Contract.methods.balanceOf') @@ -55,15 +52,9 @@ async function main(bridgeMode) { balanceDiff: Number(Web3Utils.fromWei(diff)), lastChecked: Math.floor(Date.now() / 1000) } - } else if ( - bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC || - bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1 - ) { + } else if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC || bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) { logger.debug('calling web3Home.eth.getBalance') - const foreignBridge = new web3Foreign.eth.Contract( - FOREIGN_NATIVE_TO_ERC_ABI, - FOREIGN_BRIDGE_ADDRESS - ) + const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_NATIVE_TO_ERC_ABI, FOREIGN_BRIDGE_ADDRESS) const erc20Address = await foreignBridge.methods.erc677token().call() const homeBalance = await web3Home.eth.getBalance(HOME_BRIDGE_ADDRESS) const tokenContract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address) @@ -84,10 +75,7 @@ async function main(bridgeMode) { lastChecked: Math.floor(Date.now() / 1000) } } else if (bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE) { - const foreignBridge = new web3Foreign.eth.Contract( - FOREIGN_ERC_TO_NATIVE_ABI, - FOREIGN_BRIDGE_ADDRESS - ) + const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ERC_TO_NATIVE_ABI, FOREIGN_BRIDGE_ADDRESS) const erc20Address = await foreignBridge.methods.erc20token().call() const erc20Contract = new web3Foreign.eth.Contract(ERC20_ABI, erc20Address) logger.debug('calling erc20Contract.methods.balanceOf') diff --git a/monitor/getShortEventStats.js b/monitor/getShortEventStats.js index 648e59f2..9571a5d6 100644 --- a/monitor/getShortEventStats.js +++ b/monitor/getShortEventStats.js @@ -2,9 +2,7 @@ require('dotenv').config() const eventsInfo = require('./utils/events') async function main(bridgeMode) { - const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals } = await eventsInfo( - bridgeMode - ) + const { foreignDeposits, homeDeposits, homeWithdrawals, foreignWithdrawals } = await eventsInfo(bridgeMode) return { depositsDiff: homeDeposits.length - foreignDeposits.length, diff --git a/monitor/index.js b/monitor/index.js index d92dbfc1..3d0cd869 100644 --- a/monitor/index.js +++ b/monitor/index.js @@ -91,8 +91,7 @@ app.get('/eventsStats', async (req, res, next) => { app.get('/alerts', async (req, res, next) => { try { const results = await readFile('./responses/alerts.json') - results.ok = - !results.executeAffirmations.mostRecentTxHash && !results.executeSignatures.mostRecentTxHash + results.ok = !results.executeAffirmations.mostRecentTxHash && !results.executeSignatures.mostRecentTxHash res.json(results) } catch (e) { next(e) diff --git a/monitor/logger.js b/monitor/logger.js index 0b74a979..50cdc1fb 100644 --- a/monitor/logger.js +++ b/monitor/logger.js @@ -3,12 +3,7 @@ module.exports = function logger(name) { function log(...args) { const now = new Date() - console.log( - now.toISOString(), - `(+${lastlog ? now.getTime() - lastlog : 0}ms)`, - `[${name}]`, - ...args - ) + console.log(now.toISOString(), `(+${lastlog ? now.getTime() - lastlog : 0}ms)`, `[${name}]`, ...args) lastlog = now.getTime() } diff --git a/monitor/utils/events.js b/monitor/utils/events.js index b562fc89..2342bb19 100644 --- a/monitor/utils/events.js +++ b/monitor/utils/events.js @@ -32,8 +32,7 @@ async function main(mode) { const homeBridge = new web3Home.eth.Contract(HOME_ABI, HOME_BRIDGE_ADDRESS) const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, FOREIGN_BRIDGE_ADDRESS) const v1Bridge = bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1 - const erc20MethodName = - bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC || v1Bridge ? 'erc677token' : 'erc20token' + const erc20MethodName = bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC || v1Bridge ? 'erc677token' : 'erc20token' const erc20Address = await foreignBridge.methods[erc20MethodName]().call() const tokenType = await getTokenType( new web3Foreign.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, erc20Address), diff --git a/monitor/validators.js b/monitor/validators.js index d686e8ae..5de872db 100644 --- a/monitor/validators.js +++ b/monitor/validators.js @@ -72,20 +72,14 @@ async function main(bridgeMode) { const homeBridge = new web3Home.eth.Contract(HOME_ABI, HOME_BRIDGE_ADDRESS) const foreignBridge = new web3Foreign.eth.Contract(FOREIGN_ABI, FOREIGN_BRIDGE_ADDRESS) const homeValidatorsAddress = await homeBridge.methods.validatorContract().call() - const homeBridgeValidators = new web3Home.eth.Contract( - BRIDGE_VALIDATORS_ABI, - homeValidatorsAddress - ) + const homeBridgeValidators = new web3Home.eth.Contract(BRIDGE_VALIDATORS_ABI, homeValidatorsAddress) logger.debug('getting last block numbers') const [homeBlockNumber, foreignBlockNumber] = await getBlockNumber(web3Home, web3Foreign) logger.debug('calling foreignBridge.methods.validatorContract().call()') const foreignValidatorsAddress = await foreignBridge.methods.validatorContract().call() - const foreignBridgeValidators = new web3Foreign.eth.Contract( - BRIDGE_VALIDATORS_ABI, - foreignValidatorsAddress - ) + const foreignBridgeValidators = new web3Foreign.eth.Contract(BRIDGE_VALIDATORS_ABI, foreignValidatorsAddress) logger.debug('calling foreignBridgeValidators getValidatorList()') const foreignValidators = await getValidatorList( diff --git a/oracle-e2e/test/ercToErc.js b/oracle-e2e/test/ercToErc.js index 619aebe1..926a127f 100644 --- a/oracle-e2e/test/ercToErc.js +++ b/oracle-e2e/test/ercToErc.js @@ -16,10 +16,7 @@ const { toBN } = foreignWeb3.utils homeWeb3.eth.accounts.wallet.add(user.privateKey) foreignWeb3.eth.accounts.wallet.add(user.privateKey) -const erc20Token = new foreignWeb3.eth.Contract( - ERC677_BRIDGE_TOKEN_ABI, - ercToErcBridge.foreignToken -) +const erc20Token = new foreignWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ercToErcBridge.foreignToken) const erc677Token = new homeWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ercToErcBridge.homeToken) describe('erc to erc', () => { diff --git a/oracle-e2e/test/ercToNative.js b/oracle-e2e/test/ercToNative.js index 638d2716..c3c55736 100644 --- a/oracle-e2e/test/ercToNative.js +++ b/oracle-e2e/test/ercToNative.js @@ -16,10 +16,7 @@ const { toBN } = foreignWeb3.utils homeWeb3.eth.accounts.wallet.add(user.privateKey) foreignWeb3.eth.accounts.wallet.add(user.privateKey) -const erc20Token = new foreignWeb3.eth.Contract( - ERC677_BRIDGE_TOKEN_ABI, - ercToNativeBridge.foreignToken -) +const erc20Token = new foreignWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ercToNativeBridge.foreignToken) describe('erc to native', () => { it('should convert tokens in foreign to coins in home', async () => { diff --git a/oracle/config/affirmation-request-watcher.config.js b/oracle/config/affirmation-request-watcher.config.js index 8f487535..0f1f85f0 100644 --- a/oracle/config/affirmation-request-watcher.config.js +++ b/oracle/config/affirmation-request-watcher.config.js @@ -21,8 +21,7 @@ if (baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC677 const id = `${baseConfig.id}-affirmation-request` module.exports = - (baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC20) || - baseConfig.id === 'erc-native' + (baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC20) || baseConfig.id === 'erc-native' ? { ...baseConfig.bridgeConfig, ...baseConfig.foreignConfig, diff --git a/oracle/config/base.config.js b/oracle/config/base.config.js index 898ca64b..9ead83b2 100644 --- a/oracle/config/base.config.js +++ b/oracle/config/base.config.js @@ -49,8 +49,7 @@ let maxProcessingTime = null if (String(process.env.MAX_PROCESSING_TIME) === '0') { maxProcessingTime = 0 } else if (!process.env.MAX_PROCESSING_TIME) { - maxProcessingTime = - 4 * Math.max(process.env.HOME_POLLING_INTERVAL, process.env.FOREIGN_POLLING_INTERVAL) + maxProcessingTime = 4 * Math.max(process.env.HOME_POLLING_INTERVAL, process.env.FOREIGN_POLLING_INTERVAL) } else { maxProcessingTime = Number(process.env.MAX_PROCESSING_TIME) } diff --git a/oracle/scripts/compute-stats.js b/oracle/scripts/compute-stats.js index c395e023..cd494b9a 100644 --- a/oracle/scripts/compute-stats.js +++ b/oracle/scripts/compute-stats.js @@ -61,10 +61,7 @@ async function main() { console.log('Signature Requests') console.log(signatureRequestsStats) - const collectedSignaturesStats = computeCollectedSignaturesStats( - collectedSignatures, - senderForeign - ) + const collectedSignaturesStats = computeCollectedSignaturesStats(collectedSignatures, senderForeign) console.log('Collected Signatures') console.log(collectedSignaturesStats) } diff --git a/oracle/scripts/erc20_to_erc20/sendHome.js b/oracle/scripts/erc20_to_erc20/sendHome.js index cdbf2ebb..87fa90c4 100644 --- a/oracle/scripts/erc20_to_erc20/sendHome.js +++ b/oracle/scripts/erc20_to_erc20/sendHome.js @@ -14,8 +14,7 @@ const { HOME_TEST_TX_GAS_PRICE } = process.env -const NUMBER_OF_WITHDRAWALS_TO_SEND = - process.argv[2] || process.env.NUMBER_OF_WITHDRAWALS_TO_SEND || 1 +const NUMBER_OF_WITHDRAWALS_TO_SEND = process.argv[2] || process.env.NUMBER_OF_WITHDRAWALS_TO_SEND || 1 const BRIDGEABLE_TOKEN_ABI = [ { diff --git a/oracle/scripts/getValidatorStartBlocks.js b/oracle/scripts/getValidatorStartBlocks.js index 7bf48b70..72fc033b 100644 --- a/oracle/scripts/getValidatorStartBlocks.js +++ b/oracle/scripts/getValidatorStartBlocks.js @@ -17,10 +17,7 @@ async function getStartBlock(rpcUrl, bridgeAddress, bridgeAbi) { const deployedAtBlock = await bridgeContract.methods.deployedAtBlock().call() const validatorContractAddress = await bridgeContract.methods.validatorContract().call() - const validatorContract = new web3Instance.eth.Contract( - BRIDGE_VALIDATORS_ABI, - validatorContractAddress - ) + const validatorContract = new web3Instance.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorContractAddress) const validatorDeployedAtBlock = await validatorContract.methods.deployedAtBlock().call() diff --git a/oracle/scripts/initialChecks.js b/oracle/scripts/initialChecks.js index 553653f8..452b0ef4 100644 --- a/oracle/scripts/initialChecks.js +++ b/oracle/scripts/initialChecks.js @@ -8,10 +8,7 @@ async function initialChecks() { if (BRIDGE_MODE === 'ERC_TO_ERC') { const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL)) - const bridgeTokenContract = new foreignWeb3.eth.Contract( - ERC677_BRIDGE_TOKEN_ABI, - ERC20_TOKEN_ADDRESS - ) + const bridgeTokenContract = new foreignWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ERC20_TOKEN_ADDRESS) result.foreignERC = await getTokenType(bridgeTokenContract, FOREIGN_BRIDGE_ADDRESS) } diff --git a/oracle/scripts/native_to_erc20/sendForeign.js b/oracle/scripts/native_to_erc20/sendForeign.js index 14d95143..f6a26c16 100644 --- a/oracle/scripts/native_to_erc20/sendForeign.js +++ b/oracle/scripts/native_to_erc20/sendForeign.js @@ -13,8 +13,7 @@ const { FOREIGN_TEST_TX_GAS_PRICE } = process.env -const NUMBER_OF_WITHDRAWALS_TO_SEND = - process.argv[2] || process.env.NUMBER_OF_WITHDRAWALS_TO_SEND || 1 +const NUMBER_OF_WITHDRAWALS_TO_SEND = process.argv[2] || process.env.NUMBER_OF_WITHDRAWALS_TO_SEND || 1 const ERC677_ABI = [ { diff --git a/oracle/src/events/processAffirmationRequests/estimateGas.js b/oracle/src/events/processAffirmationRequests/estimateGas.js index 5146e595..82cbf792 100644 --- a/oracle/src/events/processAffirmationRequests/estimateGas.js +++ b/oracle/src/events/processAffirmationRequests/estimateGas.js @@ -1,28 +1,14 @@ const { HttpListProviderError } = require('http-list-provider') -const { - AlreadyProcessedError, - AlreadySignedError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors') const logger = require('../../services/logger').child({ module: 'processAffirmationRequests:estimateGas' }) -async function estimateGas({ - web3, - homeBridge, - validatorContract, - recipient, - value, - txHash, - address -}) { +async function estimateGas({ web3, homeBridge, validatorContract, recipient, value, txHash, address }) { try { - const gasEstimate = await homeBridge.methods - .executeAffirmation(recipient, value, txHash) - .estimateGas({ - from: address - }) + const gasEstimate = await homeBridge.methods.executeAffirmation(recipient, value, txHash).estimateGas({ + from: address + }) return gasEstimate } catch (e) { @@ -36,9 +22,7 @@ async function estimateGas({ // Check if minimum number of validations was already reached logger.debug('Check if minimum number of validations was already reached') const numAffirmationsSigned = await homeBridge.methods.numAffirmationsSigned(messageHash).call() - const alreadyProcessed = await homeBridge.methods - .isAlreadyProcessed(numAffirmationsSigned) - .call() + const alreadyProcessed = await homeBridge.methods.isAlreadyProcessed(numAffirmationsSigned).call() if (alreadyProcessed) { throw new AlreadyProcessedError(e.message) diff --git a/oracle/src/events/processAffirmationRequests/index.js b/oracle/src/events/processAffirmationRequests/index.js index 57d36a0d..16b726ad 100644 --- a/oracle/src/events/processAffirmationRequests/index.js +++ b/oracle/src/events/processAffirmationRequests/index.js @@ -7,11 +7,7 @@ const { web3Home } = require('../../services/web3') const { BRIDGE_VALIDATORS_ABI } = require('../../../../commons') const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants') const estimateGas = require('./estimateGas') -const { - AlreadyProcessedError, - AlreadySignedError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors') const limit = promiseLimit(MAX_CONCURRENT_EVENTS) @@ -40,10 +36,7 @@ function processAffirmationRequestsBuilder(config) { eventTransactionHash: affirmationRequest.transactionHash }) - logger.info( - { sender: recipient, value }, - `Processing affirmationRequest ${affirmationRequest.transactionHash}` - ) + logger.info({ sender: recipient, value }, `Processing affirmationRequest ${affirmationRequest.transactionHash}`) let gasEstimate try { @@ -60,9 +53,7 @@ function processAffirmationRequestsBuilder(config) { logger.debug({ gasEstimate }, 'Gas estimated') } catch (e) { if (e instanceof HttpListProviderError) { - throw new Error( - 'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.' - ) + throw new Error('RPC Connection Error: submitSignature Gas Estimate cannot be obtained.') } else if (e instanceof InvalidValidatorError) { logger.fatal({ address: config.validatorAddress }, 'Invalid validator') process.exit(EXIT_CODES.INCOMPATIBILITY) @@ -71,9 +62,7 @@ function processAffirmationRequestsBuilder(config) { return } else if (e instanceof AlreadyProcessedError) { logger.info( - `affirmationRequest ${ - affirmationRequest.transactionHash - } was already processed by other validators` + `affirmationRequest ${affirmationRequest.transactionHash} was already processed by other validators` ) return } else { diff --git a/oracle/src/events/processCollectedSignatures/estimateGas.js b/oracle/src/events/processCollectedSignatures/estimateGas.js index 7788a998..6c8a215c 100644 --- a/oracle/src/events/processCollectedSignatures/estimateGas.js +++ b/oracle/src/events/processCollectedSignatures/estimateGas.js @@ -1,10 +1,6 @@ const Web3 = require('web3') const { HttpListProviderError } = require('http-list-provider') -const { - AlreadyProcessedError, - IncompatibleContractError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, IncompatibleContractError, InvalidValidatorError } = require('../../utils/errors') const { parseMessage } = require('../../utils/message') const logger = require('../../services/logger').child({ module: 'processCollectedSignatures:estimateGas' @@ -13,19 +9,9 @@ const logger = require('../../services/logger').child({ const web3 = new Web3() const { toBN } = Web3.utils -async function estimateGas({ - foreignBridge, - validatorContract, - message, - numberOfCollectedSignatures, - v, - r, - s -}) { +async function estimateGas({ foreignBridge, validatorContract, message, numberOfCollectedSignatures, v, r, s }) { try { - const gasEstimate = await foreignBridge.methods - .executeSignatures(v, r, s, message) - .estimateGas() + const gasEstimate = await foreignBridge.methods.executeSignatures(v, r, s, message).estimateGas() return gasEstimate } catch (e) { if (e instanceof HttpListProviderError) { diff --git a/oracle/src/events/processCollectedSignatures/index.js b/oracle/src/events/processCollectedSignatures/index.js index 288f57f3..a6f0773b 100644 --- a/oracle/src/events/processCollectedSignatures/index.js +++ b/oracle/src/events/processCollectedSignatures/index.js @@ -6,11 +6,7 @@ const rootLogger = require('../../services/logger') const { web3Home, web3Foreign } = require('../../services/web3') const { signatureToVRS } = require('../../utils/message') const estimateGas = require('./estimateGas') -const { - AlreadyProcessedError, - IncompatibleContractError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, IncompatibleContractError, InvalidValidatorError } = require('../../utils/errors') const { MAX_CONCURRENT_EVENTS } = require('../../utils/constants') const limit = promiseLimit(MAX_CONCURRENT_EVENTS) @@ -20,10 +16,7 @@ let validatorContract = null function processCollectedSignaturesBuilder(config) { const homeBridge = new web3Home.eth.Contract(config.homeBridgeAbi, config.homeBridgeAddress) - const foreignBridge = new web3Foreign.eth.Contract( - config.foreignBridgeAbi, - config.foreignBridgeAddress - ) + const foreignBridge = new web3Foreign.eth.Contract(config.foreignBridgeAbi, config.foreignBridgeAddress) return async function processCollectedSignatures(signatures) { const txToSend = [] @@ -33,28 +26,19 @@ function processCollectedSignaturesBuilder(config) { const validatorContractAddress = await foreignBridge.methods.validatorContract().call() rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained') - validatorContract = new web3Foreign.eth.Contract( - BRIDGE_VALIDATORS_ABI, - validatorContractAddress - ) + validatorContract = new web3Foreign.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorContractAddress) } rootLogger.debug(`Processing ${signatures.length} CollectedSignatures events`) const callbacks = signatures.map(colSignature => limit(async () => { - const { - authorityResponsibleForRelay, - messageHash, - NumberOfCollectedSignatures - } = colSignature.returnValues + const { authorityResponsibleForRelay, messageHash, NumberOfCollectedSignatures } = colSignature.returnValues const logger = rootLogger.child({ eventTransactionHash: colSignature.transactionHash }) - if ( - authorityResponsibleForRelay === web3Home.utils.toChecksumAddress(config.validatorAddress) - ) { + if (authorityResponsibleForRelay === web3Home.utils.toChecksumAddress(config.validatorAddress)) { logger.info(`Processing CollectedSignatures ${colSignature.transactionHash}`) const message = await homeBridge.methods.message(messageHash).call() @@ -90,16 +74,11 @@ function processCollectedSignaturesBuilder(config) { logger.debug({ gasEstimate }, 'Gas estimated') } catch (e) { if (e instanceof HttpListProviderError) { - throw new Error( - 'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.' - ) + throw new Error('RPC Connection Error: submitSignature Gas Estimate cannot be obtained.') } else if (e instanceof AlreadyProcessedError) { logger.info(`Already processed CollectedSignatures ${colSignature.transactionHash}`) return - } else if ( - e instanceof IncompatibleContractError || - e instanceof InvalidValidatorError - ) { + } else if (e instanceof IncompatibleContractError || e instanceof InvalidValidatorError) { logger.error(`The message couldn't be processed; skipping: ${e.message}`) return } else { @@ -115,11 +94,7 @@ function processCollectedSignaturesBuilder(config) { to: config.foreignBridgeAddress }) } else { - logger.info( - `Validator not responsible for relaying CollectedSignatures ${ - colSignature.transactionHash - }` - ) + logger.info(`Validator not responsible for relaying CollectedSignatures ${colSignature.transactionHash}`) } }) ) diff --git a/oracle/src/events/processSignatureRequests/estimateGas.js b/oracle/src/events/processSignatureRequests/estimateGas.js index a73c01d1..79a3523d 100644 --- a/oracle/src/events/processSignatureRequests/estimateGas.js +++ b/oracle/src/events/processSignatureRequests/estimateGas.js @@ -1,9 +1,5 @@ const { HttpListProviderError } = require('http-list-provider') -const { - AlreadyProcessedError, - AlreadySignedError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors') const logger = require('../../services/logger').child({ module: 'processSignatureRequests:estimateGas' }) diff --git a/oracle/src/events/processSignatureRequests/index.js b/oracle/src/events/processSignatureRequests/index.js index a90f9da6..dcacbf84 100644 --- a/oracle/src/events/processSignatureRequests/index.js +++ b/oracle/src/events/processSignatureRequests/index.js @@ -6,11 +6,7 @@ const rootLogger = require('../../services/logger') const { web3Home } = require('../../services/web3') const { createMessage } = require('../../utils/message') const estimateGas = require('./estimateGas') -const { - AlreadyProcessedError, - AlreadySignedError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors') const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants') const { VALIDATOR_ADDRESS_PRIVATE_KEY } = process.env @@ -47,10 +43,7 @@ function processSignatureRequestsBuilder(config) { eventTransactionHash: signatureRequest.transactionHash }) - logger.info( - { sender: recipient, value }, - `Processing signatureRequest ${signatureRequest.transactionHash}` - ) + logger.info({ sender: recipient, value }, `Processing signatureRequest ${signatureRequest.transactionHash}`) const message = createMessage({ recipient, @@ -76,9 +69,7 @@ function processSignatureRequestsBuilder(config) { logger.debug({ gasEstimate }, 'Gas estimated') } catch (e) { if (e instanceof HttpListProviderError) { - throw new Error( - 'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.' - ) + throw new Error('RPC Connection Error: submitSignature Gas Estimate cannot be obtained.') } else if (e instanceof InvalidValidatorError) { logger.fatal({ address: config.validatorAddress }, 'Invalid validator') process.exit(EXIT_CODES.INCOMPATIBILITY) @@ -87,9 +78,7 @@ function processSignatureRequestsBuilder(config) { return } else if (e instanceof AlreadyProcessedError) { logger.info( - `signatureRequest ${ - signatureRequest.transactionHash - } was already processed by other validators` + `signatureRequest ${signatureRequest.transactionHash} was already processed by other validators` ) return } else { diff --git a/oracle/src/events/processTransfers/index.js b/oracle/src/events/processTransfers/index.js index 3354fecb..5cb135cc 100644 --- a/oracle/src/events/processTransfers/index.js +++ b/oracle/src/events/processTransfers/index.js @@ -4,11 +4,7 @@ const { HttpListProviderError } = require('http-list-provider') const { BRIDGE_VALIDATORS_ABI } = require('../../../../commons') const rootLogger = require('../../services/logger') const { web3Home } = require('../../services/web3') -const { - AlreadyProcessedError, - AlreadySignedError, - InvalidValidatorError -} = require('../../utils/errors') +const { AlreadyProcessedError, AlreadySignedError, InvalidValidatorError } = require('../../utils/errors') const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants') const estimateGas = require('../processAffirmationRequests/estimateGas') @@ -56,9 +52,7 @@ function processTransfersBuilder(config) { logger.debug({ gasEstimate }, 'Gas estimated') } catch (e) { if (e instanceof HttpListProviderError) { - throw new Error( - 'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.' - ) + throw new Error('RPC Connection Error: submitSignature Gas Estimate cannot be obtained.') } else if (e instanceof InvalidValidatorError) { logger.fatal({ address: config.validatorAddress }, 'Invalid validator') process.exit(EXIT_CODES.INCOMPATIBILITY) @@ -66,9 +60,7 @@ function processTransfersBuilder(config) { logger.info(`Already signed transfer ${transfer.transactionHash}`) return } else if (e instanceof AlreadyProcessedError) { - logger.info( - `transfer ${transfer.transactionHash} was already processed by other validators` - ) + logger.info(`transfer ${transfer.transactionHash} was already processed by other validators`) return } else { logger.error(e, 'Unknown error while processing transaction') diff --git a/oracle/src/sender.js b/oracle/src/sender.js index 77db9cfc..23b5dedf 100644 --- a/oracle/src/sender.js +++ b/oracle/src/sender.js @@ -63,9 +63,7 @@ async function initialize() { } function resume(newBalance) { - logger.info( - `Validator balance changed. New balance is ${newBalance}. Resume messages processing.` - ) + logger.info(`Validator balance changed. New balance is ${newBalance}. Resume messages processing.`) initialize() } @@ -164,9 +162,7 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry }) { logger.debug(`Finished processing msg`) if (insufficientFunds) { - logger.warn( - 'Insufficient funds. Stop sending transactions until the account has the minimum balance' - ) + logger.warn('Insufficient funds. Stop sending transactions until the account has the minimum balance') channel.close() waitForFunds(web3Instance, VALIDATOR_ADDRESS, minimumBalance, resume, logger) } diff --git a/oracle/src/services/amqpClient.js b/oracle/src/services/amqpClient.js index 0fc79b94..805009f1 100644 --- a/oracle/src/services/amqpClient.js +++ b/oracle/src/services/amqpClient.js @@ -59,14 +59,7 @@ function connectSenderToQueue({ queueName, cb }) { }) } -async function generateRetry({ - data, - msgRetries, - channelWrapper, - channel, - queueName, - deadLetterExchange -}) { +async function generateRetry({ data, msgRetries, channelWrapper, channel, queueName, deadLetterExchange }) { const retries = msgRetries + 1 const delay = getRetrySequence(retries) * 1000 const retryQueue = `${queueName}-retry-${delay}` diff --git a/oracle/src/services/gasPrice.js b/oracle/src/services/gasPrice.js index ad8f1d19..e5713629 100644 --- a/oracle/src/services/gasPrice.js +++ b/oracle/src/services/gasPrice.js @@ -7,11 +7,7 @@ const logger = require('../services/logger').child({ module: 'gasPrice' }) const { setIntervalAndRun } = require('../utils/utils') -const { - DEFAULT_UPDATE_INTERVAL, - GAS_PRICE_BOUNDARIES, - DEFAULT_GAS_PRICE_FACTOR -} = require('../utils/constants') +const { DEFAULT_UPDATE_INTERVAL, GAS_PRICE_BOUNDARIES, DEFAULT_GAS_PRICE_FACTOR } = require('../utils/constants') const HomeABI = bridgeConfig.homeBridgeAbi const ForeignABI = bridgeConfig.foreignBridgeAbi diff --git a/oracle/src/services/logger.js b/oracle/src/services/logger.js index e7122b73..33666642 100644 --- a/oracle/src/services/logger.js +++ b/oracle/src/services/logger.js @@ -1,8 +1,7 @@ const pino = require('pino') const path = require('path') -const config = - process.env.NODE_ENV !== 'test' ? require(path.join('../../config/', process.argv[2])) : {} +const config = process.env.NODE_ENV !== 'test' ? require(path.join('../../config/', process.argv[2])) : {} const logger = pino({ enabled: process.env.NODE_ENV !== 'test', diff --git a/oracle/src/tx/sendTx.js b/oracle/src/tx/sendTx.js index 88ebc97e..6bdfdf45 100644 --- a/oracle/src/tx/sendTx.js +++ b/oracle/src/tx/sendTx.js @@ -3,18 +3,7 @@ const fetch = require('node-fetch') const rpcUrlsManager = require('../services/getRpcUrlsManager') // eslint-disable-next-line consistent-return -async function sendTx({ - chain, - privateKey, - data, - nonce, - gasPrice, - amount, - gasLimit, - to, - chainId, - web3 -}) { +async function sendTx({ chain, privateKey, data, nonce, gasPrice, amount, gasLimit, to, chainId, web3 }) { const serializedTx = await web3.eth.accounts.signTransaction( { nonce: Number(nonce), diff --git a/oracle/src/tx/web3.js b/oracle/src/tx/web3.js index 776300c1..1c603d36 100644 --- a/oracle/src/tx/web3.js +++ b/oracle/src/tx/web3.js @@ -47,10 +47,7 @@ async function getRequiredBlockConfirmations(contract) { const contractAddress = contract.options.address logger.debug({ contractAddress }, 'Getting required block confirmations') const requiredBlockConfirmations = await contract.methods.requiredBlockConfirmations().call() - logger.debug( - { contractAddress, requiredBlockConfirmations }, - 'Required block confirmations obtained' - ) + logger.debug({ contractAddress, requiredBlockConfirmations }, 'Required block confirmations obtained') return requiredBlockConfirmations } catch (e) { throw new Error(`Required block confirmations cannot be obtained`) diff --git a/oracle/src/utils/message.js b/oracle/src/utils/message.js index 82194fee..dca93dcb 100644 --- a/oracle/src/utils/message.js +++ b/oracle/src/utils/message.js @@ -6,13 +6,7 @@ function strip0x(input) { return input.replace(/^0x/, '') } -function createMessage({ - recipient, - value, - transactionHash, - bridgeAddress, - expectedMessageLength -}) { +function createMessage({ recipient, value, transactionHash, bridgeAddress, expectedMessageLength }) { recipient = strip0x(recipient) assert.strictEqual(recipient.length, 20 * 2) @@ -50,10 +44,7 @@ function parseMessage(message) { const contractAddressStart = txHashStart + txHashLength const contractAddressLength = 32 * 2 - const contractAddress = `0x${message.slice( - contractAddressStart, - contractAddressStart + contractAddressLength - )}` + const contractAddress = `0x${message.slice(contractAddressStart, contractAddressStart + contractAddressLength)}` return { recipient, diff --git a/oracle/src/utils/utils.js b/oracle/src/utils/utils.js index 124820fa..3aa089fa 100644 --- a/oracle/src/utils/utils.js +++ b/oracle/src/utils/utils.js @@ -5,9 +5,7 @@ const Web3 = require('web3') const retrySequence = [1, 2, 3, 5, 8, 13, 21, 34, 55, 60] function getRetrySequence(count) { - return count > retrySequence.length - ? retrySequence[retrySequence.length - 1] - : retrySequence[count - 1] + return count > retrySequence.length ? retrySequence[retrySequence.length - 1] : retrySequence[count - 1] } async function syncForEach(array, callback) { @@ -23,9 +21,7 @@ function checkHTTPS(ALLOW_HTTP, logger) { if (ALLOW_HTTP !== 'yes') { throw new Error(`http is not allowed: ${url}`) } else { - logger.warn( - `You are using http (${url}) on ${network} network. In production https must be used instead.` - ) + logger.warn(`You are using http (${url}) on ${network} network. In production https must be used instead.`) } } } @@ -38,16 +34,10 @@ async function waitForFunds(web3, address, minimumBalance, cb, logger) { logger.debug('Getting balance of validator account') const newBalance = web3.utils.toBN(await web3.eth.getBalance(address)) if (newBalance.gte(minimumBalance)) { - logger.debug( - { balance: newBalance, minimumBalance }, - 'Validator has minimum necessary balance' - ) + logger.debug({ balance: newBalance, minimumBalance }, 'Validator has minimum necessary balance') cb(newBalance) } else { - logger.debug( - { balance: newBalance, minimumBalance }, - 'Balance of validator is still less than the minimum' - ) + logger.debug({ balance: newBalance, minimumBalance }, 'Balance of validator is still less than the minimum') retry() } }, @@ -99,9 +89,7 @@ function add0xPrefix(s) { } function privateKeyToAddress(privateKey) { - return privateKey - ? new Web3().eth.accounts.privateKeyToAccount(add0xPrefix(privateKey)).address - : null + return privateKey ? new Web3().eth.accounts.privateKeyToAccount(add0xPrefix(privateKey)).address : null } function nonceError(e) { diff --git a/oracle/src/watcher.js b/oracle/src/watcher.js index ce43a3c5..207ac473 100644 --- a/oracle/src/watcher.js +++ b/oracle/src/watcher.js @@ -72,10 +72,7 @@ async function runMain({ sendToQueue }) { async function getLastProcessedBlock() { const result = await redis.get(lastBlockRedisKey) - logger.debug( - { fromRedis: result, fromConfig: lastProcessedBlock.toString() }, - 'Last Processed block obtained' - ) + logger.debug({ fromRedis: result, fromConfig: lastProcessedBlock.toString() }, 'Last Processed block obtained') lastProcessedBlock = result ? toBN(result) : lastProcessedBlock } @@ -146,10 +143,7 @@ async function main({ sendToQueue }) { } } - logger.debug( - { lastProcessedBlock: lastBlockToProcess.toString() }, - 'Updating last processed block' - ) + logger.debug({ lastProcessedBlock: lastBlockToProcess.toString() }, 'Updating last processed block') await updateLastProcessedBlock(lastBlockToProcess) } catch (e) { logger.error(e) diff --git a/oracle/test/gasPrice.test.js b/oracle/test/gasPrice.test.js index aa4eba0c..e7ffd1da 100644 --- a/oracle/test/gasPrice.test.js +++ b/oracle/test/gasPrice.test.js @@ -2,11 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const proxyquire = require('proxyquire').noPreserveCache() const Web3Utils = require('web3-utils') -const { - fetchGasPrice, - gasPriceWithinLimits, - normalizeGasPrice -} = require('../src/services/gasPrice') +const { fetchGasPrice, gasPriceWithinLimits, normalizeGasPrice } = require('../src/services/gasPrice') const { DEFAULT_UPDATE_INTERVAL, GAS_PRICE_BOUNDARIES } = require('../src/utils/constants') describe('gasPrice', () => { @@ -94,12 +90,8 @@ describe('gasPrice', () => { // then expect(process.env.HOME_GAS_PRICE_UPDATE_INTERVAL).to.equal('15000') - expect(process.env.HOME_GAS_PRICE_UPDATE_INTERVAL).to.not.equal( - DEFAULT_UPDATE_INTERVAL.toString() - ) - expect(utils.setIntervalAndRun.args[0][1]).to.equal( - process.env.HOME_GAS_PRICE_UPDATE_INTERVAL.toString() - ) + expect(process.env.HOME_GAS_PRICE_UPDATE_INTERVAL).to.not.equal(DEFAULT_UPDATE_INTERVAL.toString()) + expect(utils.setIntervalAndRun.args[0][1]).to.equal(process.env.HOME_GAS_PRICE_UPDATE_INTERVAL.toString()) }) it('should call setIntervalAndRun with FOREIGN_GAS_PRICE_UPDATE_INTERVAL interval value on Foreign', async () => { // given @@ -111,12 +103,8 @@ describe('gasPrice', () => { // then expect(process.env.FOREIGN_GAS_PRICE_UPDATE_INTERVAL).to.equal('15000') - expect(process.env.HOME_GAS_PRICE_UPDATE_INTERVAL).to.not.equal( - DEFAULT_UPDATE_INTERVAL.toString() - ) - expect(utils.setIntervalAndRun.args[0][1]).to.equal( - process.env.FOREIGN_GAS_PRICE_UPDATE_INTERVAL.toString() - ) + expect(process.env.HOME_GAS_PRICE_UPDATE_INTERVAL).to.not.equal(DEFAULT_UPDATE_INTERVAL.toString()) + expect(utils.setIntervalAndRun.args[0][1]).to.equal(process.env.FOREIGN_GAS_PRICE_UPDATE_INTERVAL.toString()) }) it('should call setIntervalAndRun with default interval value on Home', async () => { // given diff --git a/oracle/test/message.test.js b/oracle/test/message.test.js index 1953b81a..a0703076 100644 --- a/oracle/test/message.test.js +++ b/oracle/test/message.test.js @@ -148,8 +148,7 @@ describe('message utils', () => { const transactionHash = '0x4a298455c1ccb17de77718fc045a876e1b4e063afaad361dcdef142a8ee48d5a' // when - const messageThunk = () => - createMessage({ recipient, value, transactionHash, expectedMessageLength }) + const messageThunk = () => createMessage({ recipient, value, transactionHash, expectedMessageLength }) // then expect(messageThunk).to.throw() @@ -162,8 +161,7 @@ describe('message utils', () => { const transactionHash = '0x4a298455c1ccb17de77718fc045a876e1b4e063afaad361dcdef142a8ee48d5a' // when - const messageThunk = () => - createMessage({ recipient, value, transactionHash, expectedMessageLength }) + const messageThunk = () => createMessage({ recipient, value, transactionHash, expectedMessageLength }) // then expect(messageThunk).to.throw() @@ -176,8 +174,7 @@ describe('message utils', () => { const transactionHash = '0x4a298455c1ccb17de77718fc045a876e1b4e063afaad361dcdef142a8ee48d5' // when - const messageThunk = () => - createMessage({ recipient, value, transactionHash, expectedMessageLength }) + const messageThunk = () => createMessage({ recipient, value, transactionHash, expectedMessageLength }) // then expect(messageThunk).to.throw() @@ -190,8 +187,7 @@ describe('message utils', () => { const transactionHash = '0x4a298455c1ccb17de77718fc045a876e1b4e063afaad361dcdef142a8ee48d5aa' // when - const messageThunk = () => - createMessage({ recipient, value, transactionHash, expectedMessageLength }) + const messageThunk = () => createMessage({ recipient, value, transactionHash, expectedMessageLength }) // then expect(messageThunk).to.throw() @@ -232,8 +228,7 @@ describe('message utils', () => { // given const originalRecipient = '0xe3D952Ad4B96A756D65790393128FA359a7CD888' const originalValue = '0x2a' - const originalTransactionHash = - '0x4a298455c1ccb17de77718fc045a876e1b4e063afaad361dcdef142a8ee48d5a' + const originalTransactionHash = '0x4a298455c1ccb17de77718fc045a876e1b4e063afaad361dcdef142a8ee48d5a' const originalBridgeAddress = '0xfA79875FB0828c1FBD438583ED23fF5a956D80a1' // when diff --git a/ui-e2e/MetaMask.js b/ui-e2e/MetaMask.js index 1b13df22..577a27d4 100644 --- a/ui-e2e/MetaMask.js +++ b/ui-e2e/MetaMask.js @@ -74,9 +74,7 @@ class MetaMask extends Page { await this.setNetwork(user.networkID) await super.clickWithWait(popupAccount) await this.driver.executeScript( - "document.getElementsByClassName('dropdown-menu-item')[" + - user.accountOrderInMetamask + - '].click();' + "document.getElementsByClassName('dropdown-menu-item')[" + user.accountOrderInMetamask + '].click();' ) await this.switchToNextPage() return true @@ -89,9 +87,7 @@ class MetaMask extends Page { try { await super.clickWithWait(popupAccount) await this.driver.executeScript( - "document.getElementsByClassName('dropdown-menu-item')[" + - (accountOrderNumber + 1) + - '].click();' + "document.getElementsByClassName('dropdown-menu-item')[" + (accountOrderNumber + 1) + '].click();' ) accountOrderNumber++ return true @@ -121,8 +117,7 @@ class MetaMask extends Page { try { await super.clickWithWait(popupNetwork) const orderNumber = networks.indexOf(provider) - const script = - "document.getElementsByClassName('dropdown-menu-item')[" + orderNumber + '].click();' + const script = "document.getElementsByClassName('dropdown-menu-item')[" + orderNumber + '].click();' if (orderNumber < 0) await this.addNetwork(provider) else await this.driver.executeScript(script) return true diff --git a/ui-e2e/test.js b/ui-e2e/test.js index 0e51cec7..fb1cec90 100644 --- a/ui-e2e/test.js +++ b/ui-e2e/test.js @@ -59,22 +59,14 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { foreignBalanceBefore = await mainPage.getForeignPOABalance() console.log('foreignBalanceBefore = ' + foreignBalanceBefore) const result = foreignBalanceBefore === 0 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Foreign POA balance is zero or not displayed ' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Foreign POA balance is zero or not displayed ') }) test.it('Main page: home POA balance is displayed', async () => { homeBalanceBefore = await mainPage.getHomePOABalance() console.log('homeBalanceBefore = ' + homeBalanceBefore) const result = homeBalanceBefore !== 0 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is zero or not displayed ' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is zero or not displayed ') }) test.it('User is able to send tokens from Home account to Foreign account', async () => { @@ -93,30 +85,19 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100 homeBalanceBefore = newHomeBalance - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is not correct after transaction') }) - test.it( - 'Foreign account has received correct amount of tokens after transaction ', - async () => { - const newForeignBalance = await mainPage.getForeignPOABalance() + test.it('Foreign account has received correct amount of tokens after transaction ', async () => { + const newForeignBalance = await mainPage.getForeignPOABalance() - const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit - console.log('newForeignBalance = ' + newForeignBalance) - console.log('shouldBe = ' + shouldBe) + const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit + console.log('newForeignBalance = ' + newForeignBalance) + console.log('shouldBe = ' + shouldBe) - const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED. Foreign POA balance is not correct after transaction' - ) - } - ) + const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 + return await assert.strictEqual(result, true, 'Test FAILED. Foreign POA balance is not correct after transaction') + }) test.it('User is able to send tokens from Foreign account to Home account', async () => { await foreignAccount.setMetaMaskNetwork() @@ -135,11 +116,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('newForeignBalance = ' + newForeignBalance) console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Foreign POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Foreign POA balance is not correct after transaction') }) test.it('Home account has received correct amount of tokens after transaction', async () => { @@ -148,11 +125,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('newHomeBalance = ' + newHomeBalance) console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is not correct after transaction') }) }) @@ -173,22 +146,14 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { foreignBalanceBefore = await mainPage.getForeignPOABalance() console.log('foreignBalanceBefore = ' + foreignBalanceBefore) const result = foreignBalanceBefore === 0 - return await assert.strictEqual( - result, - true, - 'Test FAILED. Foreign erc20 balance is not zero' - ) + return await assert.strictEqual(result, true, 'Test FAILED. Foreign erc20 balance is not zero') }) test.it('Main page: home erc20 balance is displayed', async () => { homeBalanceBefore = await mainPage.getHomePOABalance() console.log('homeBalanceBefore = ' + homeBalanceBefore) const result = homeBalanceBefore !== 0 - return await assert.strictEqual( - result, - true, - 'Test FAILED. Home erc20 balance is zero or not displayed ' - ) + return await assert.strictEqual(result, true, 'Test FAILED. Home erc20 balance is zero or not displayed ') }) test.it('User is able to send tokens from Foreign account to Home account ', async () => { @@ -208,11 +173,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('newForeignBalance = ' + newForeignBalance) console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Foreign POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Foreign POA balance is not correct after transaction') }) test.it('Home account has received correct amount of tokens after transaction ', async () => { @@ -221,11 +182,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('newHomeBalance = ' + newHomeBalance) console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is not correct after transaction') }) test.it('User is able to send tokens from Home account to Foreign account ', async () => { await homeAccount.setMetaMaskNetwork() @@ -246,30 +203,19 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100 homeBalanceBefore = newHomeBalance - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is not correct after transaction') }) - test.it( - 'Foreign account has received correct amount of tokens after transaction ', - async () => { - const newForeignBalance = await mainPage.getForeignPOABalance() + test.it('Foreign account has received correct amount of tokens after transaction ', async () => { + const newForeignBalance = await mainPage.getForeignPOABalance() - const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit - console.log('newForeignBalance = ' + newForeignBalance) - console.log('shouldBe = ' + shouldBe) + const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit + console.log('newForeignBalance = ' + newForeignBalance) + console.log('shouldBe = ' + shouldBe) - const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED. Foreign POA balance is not correct after transaction' - ) - } - ) + const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 + return await assert.strictEqual(result, true, 'Test FAILED. Foreign POA balance is not correct after transaction') + }) }) test.describe('ERC TO NATIVE', async () => { @@ -297,11 +243,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { homeBalanceBefore = await mainPage.getHomePOABalance() console.log('homeBalanceBefore = ' + homeBalanceBefore) const result = homeBalanceBefore !== 0 - return await assert.strictEqual( - result, - true, - 'Test FAILED. Home erc20 balance is zero or not displayed ' - ) + return await assert.strictEqual(result, true, 'Test FAILED. Home erc20 balance is zero or not displayed ') }) test.it('User is able to send tokens from Foreign account to Home account', async () => { @@ -321,11 +263,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('newForeignBalance = ' + newForeignBalance) console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Foreign POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Foreign POA balance is not correct after transaction') }) test.it('Home account has received correct amount of tokens after transaction', async () => { @@ -334,11 +272,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('newHomeBalance = ' + newHomeBalance) console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is not correct after transaction') }) test.it('User is able to send tokens from Home account to Foreign account', async () => { await homeAccount.setMetaMaskNetwork() @@ -359,11 +293,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100 homeBalanceBefore = newHomeBalance - return await assert.strictEqual( - result, - true, - 'Test FAILED.Home POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED.Home POA balance is not correct after transaction') }) test.it('Foreign account has received correct amount of tokens after transaction', async () => { @@ -374,11 +304,7 @@ test.describe('e2e-test for bridge.poa, version 1.5.0', async function() { console.log('shouldBe = ' + shouldBe) const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100 - return await assert.strictEqual( - result, - true, - 'Test FAILED. Foreign POA balance is not correct after transaction' - ) + return await assert.strictEqual(result, true, 'Test FAILED. Foreign POA balance is not correct after transaction') }) }) }) diff --git a/ui/config-overrides.js b/ui/config-overrides.js index 57ebebc9..8f1dda5f 100644 --- a/ui/config-overrides.js +++ b/ui/config-overrides.js @@ -2,9 +2,7 @@ const { addDecoratorsLegacy, disableEsLint, override } = require('customize-cra' const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin') const disableModuleScopePlugin = () => config => { - config.resolve.plugins = config.resolve.plugins.filter( - plugin => !(plugin instanceof ModuleScopePlugin) - ) + config.resolve.plugins = config.resolve.plugins.filter(plugin => !(plugin instanceof ModuleScopePlugin)) return config } diff --git a/ui/src/App.js b/ui/src/App.js index 336fcc5e..97880866 100644 --- a/ui/src/App.js +++ b/ui/src/App.js @@ -1,14 +1,5 @@ import React from 'react' -import { - Header, - Bridge, - RelayEvents, - Footer, - SweetAlert, - Loading, - StatusPage, - StatisticsPage -} from './components' +import { Header, Bridge, RelayEvents, Footer, SweetAlert, Loading, StatusPage, StatisticsPage } from './components' import { Route } from 'react-router-dom' import './assets/stylesheets/application.css' import { Disclaimer } from './components' @@ -45,11 +36,7 @@ export class App extends React.Component {
- ( -
- )} - /> +
} />
{showMobileMenu &&
} />} diff --git a/ui/src/components/Bridge.js b/ui/src/components/Bridge.js index 9501b6e1..34655943 100644 --- a/ui/src/components/Bridge.js +++ b/ui/src/components/Bridge.js @@ -87,9 +87,9 @@ export class Bridge extends React.Component { } if (isGreaterThan(amount, homeStore.maxCurrentDeposit)) { alertStore.pushError( - `The amount is above current daily limit.\nThe max deposit today: ${ - homeStore.maxCurrentDeposit - } ${homeStore.symbol}` + `The amount is above current daily limit.\nThe max deposit today: ${homeStore.maxCurrentDeposit} ${ + homeStore.symbol + }` ) return } @@ -140,24 +140,22 @@ export class Bridge extends React.Component { } if (!isExternalErc20 && isGreaterThan(amount, foreignStore.maxPerTx)) { alertStore.pushError( - `The amount is above maximum amount per transaction.\nThe max per transaction is: ${ - foreignStore.maxPerTx - } ${foreignStore.symbol}` + `The amount is above maximum amount per transaction.\nThe max per transaction is: ${foreignStore.maxPerTx} ${ + foreignStore.symbol + }` ) return } if (!isExternalErc20 && isGreaterThan(amount, foreignStore.maxCurrentDeposit)) { alertStore.pushError( - `The amount is above current daily limit.\nThe max withdrawal today: ${ - foreignStore.maxCurrentDeposit - } ${foreignStore.symbol}` + `The amount is above current daily limit.\nThe max withdrawal today: ${foreignStore.maxCurrentDeposit} ${ + foreignStore.symbol + }` ) return } if (isGreaterThan(amount, foreignStore.balance)) { - alertStore.pushError( - `Insufficient token balance. Your balance is ${foreignStore.balance} ${foreignStore.symbol}` - ) + alertStore.pushError(`Insufficient token balance. Your balance is ${foreignStore.balance} ${foreignStore.symbol}`) } else { try { alertStore.setLoading(true) @@ -262,8 +260,7 @@ export class Bridge extends React.Component { loadHomeDetails = () => { const { web3Store, homeStore, bridgeMode } = this.props.RootStore const isErcToErcMode = bridgeMode === BRIDGE_MODES.ERC_TO_ERC - const isExternalErc20 = - bridgeMode === BRIDGE_MODES.ERC_TO_ERC || bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE + const isExternalErc20 = bridgeMode === BRIDGE_MODES.ERC_TO_ERC || bridgeMode === BRIDGE_MODES.ERC_TO_NATIVE const modalData = { isHome: true, diff --git a/ui/src/components/BridgeAddress.js b/ui/src/components/BridgeAddress.js index b4df2223..610beded 100644 --- a/ui/src/components/BridgeAddress.js +++ b/ui/src/components/BridgeAddress.js @@ -2,11 +2,7 @@ import React from 'react' export const BridgeAddress = ({ isHome, reverse }) => { const getAddress = () => - isHome ? ( -
- ) : ( -
- ) + isHome ?
:
return isHome ? (
diff --git a/ui/src/components/BridgeNetwork.js b/ui/src/components/BridgeNetwork.js index 3c76ac04..ad534012 100644 --- a/ui/src/components/BridgeNetwork.js +++ b/ui/src/components/BridgeNetwork.js @@ -2,15 +2,7 @@ import React from 'react' import numeral from 'numeral' import { InfoIcon } from './icons/InfoIcon' -export const BridgeNetwork = ({ - balance, - currency, - isHome, - networkSubtitle, - networkTitle, - showModal, - side -}) => { +export const BridgeNetwork = ({ balance, currency, isHome, networkSubtitle, networkTitle, showModal, side }) => { const containerName = isHome ? 'home' : 'foreign' const formattedBalance = isNaN(numeral(balance).format('0.00', Math.floor)) ? numeral(0).format('0,0.00', Math.floor) diff --git a/ui/src/components/Configuration.js b/ui/src/components/Configuration.js index 63e9bfb9..b08687d5 100644 --- a/ui/src/components/Configuration.js +++ b/ui/src/components/Configuration.js @@ -2,19 +2,9 @@ import React from 'react' import numeral from 'numeral' import { DataBlock } from './DataBlock' -export const Configuration = ({ - requiredSignatures, - authorities, - symbol, - maxSingleDeposit, - maxTotalBalance -}) => ( +export const Configuration = ({ requiredSignatures, authorities, symbol, maxSingleDeposit, maxTotalBalance }) => (
- +
{maxSingleDeposit && diff --git a/ui/src/components/Disclaimer.js b/ui/src/components/Disclaimer.js index 4dc48cf2..85e66ee2 100644 --- a/ui/src/components/Disclaimer.js +++ b/ui/src/components/Disclaimer.js @@ -12,22 +12,18 @@ export const Disclaimer = ({ onConfirmation }) => (
TokenBridge UI App Beta+

- We’re launching our TokenBridge and our UI App on a beta-testing basis. While we’ve worked - long and hard to develop the core features of the software, we expect that our users may - detect bugs and other issues. Help us improve by posting any difficulties to our - + We’re launching our TokenBridge and our UI App on a beta-testing basis. While we’ve worked long and hard to + develop the core features of the software, we expect that our users may detect bugs and other issues. Help us + improve by posting any difficulties to our + {' '} support page .

- Use of this app and the TokenBridge is at your own risk. Users may experience unexpected - delays, unexpected visual artifacts, unexpected loss of tokens or funds from improper app - configuration, or other negative outcomes. + Use of this app and the TokenBridge is at your own risk. Users may experience unexpected delays, unexpected + visual artifacts, unexpected loss of tokens or funds from improper app configuration, or other negative + outcomes.

By hitting the "continue" button, you are representing that you’ve read our diff --git a/ui/src/components/FeeStatistics.js b/ui/src/components/FeeStatistics.js index 6f4fe5ba..9043045a 100644 --- a/ui/src/components/FeeStatistics.js +++ b/ui/src/components/FeeStatistics.js @@ -16,8 +16,7 @@ export const FeeStatistics = ({ depositFeeCollected, withdrawFeeCollected }) => dataTestid="deposit-fees-block" /> )} - {depositFeeCollected.shouldDisplay && - withdrawFeeCollected.shouldDisplay &&

} + {depositFeeCollected.shouldDisplay && withdrawFeeCollected.shouldDisplay &&
} {withdrawFeeCollected.shouldDisplay && ( - {showMobileMenu ? ( - - ) : null} + {showMobileMenu ? : null}
diff --git a/ui/src/components/Loading.js b/ui/src/components/Loading.js index def4fd1d..f5a9cdf9 100644 --- a/ui/src/components/Loading.js +++ b/ui/src/components/Loading.js @@ -13,10 +13,7 @@ export class Loading extends React.Component { const progress = loadingStepIndex === 3 ? 100 : loadingStepIndex * 25 + blockConfirmations * 4 return ( -
0 ? 'mobile-container' : ''}`} - style={style} - > +
0 ? 'mobile-container' : ''}`} style={style}> {loadingStepIndex > 0 && ( } {loadingStepIndex === 0 &&
} - {loadingStepIndex > 0 && ( -
{loadingSteps[loadingStepIndex]}
- )} + {loadingStepIndex > 0 &&
{loadingSteps[loadingStepIndex]}
} {alertStore.showLoading && }
) diff --git a/ui/src/components/NetworkDetails.js b/ui/src/components/NetworkDetails.js index 27a873cc..cf5342bf 100644 --- a/ui/src/components/NetworkDetails.js +++ b/ui/src/components/NetworkDetails.js @@ -48,11 +48,7 @@ export const NetworkDetails = ({

{networkTitle} Address - + {address.slice(0, 27).concat('...')} @@ -90,11 +86,7 @@ export const NetworkDetails = ({

Token Address - + {tokenAddress.slice(0, 27).concat('...')} diff --git a/ui/src/components/NoWallet.js b/ui/src/components/NoWallet.js index 04d83970..361d7941 100644 --- a/ui/src/components/NoWallet.js +++ b/ui/src/components/NoWallet.js @@ -34,12 +34,11 @@ export class NoWallet extends Component {

Wallet not found

- A wallet is not installed. Before continue, please install one (AlphaWallet, Metamask - or Nifty Wallet) and return to this page to continue using the application. + A wallet is not installed. Before continue, please install one (AlphaWallet, Metamask or Nifty Wallet) and + return to this page to continue using the application.

- For further information on how to install any of both wallets, please click the - buttons below. + For further information on how to install any of both wallets, please click the buttons below.

{ - return homeStore.events - .slice() - .map(({ event, transactionHash, blockNumber, returnValues }) => ({ + return homeStore.events.slice().map(({ event, transactionHash, blockNumber, returnValues }) => ({ + color: this.colors[event], + eventName: event, + transactionHash, + recipient: returnValues.recipient, + value: returnValues.value, + blockNumber + })) + } + + getForeignEvents = foreignStore => { + return foreignStore.events.slice().map(({ event, transactionHash, signedTxHash, blockNumber, returnValues }) => { + return { color: this.colors[event], eventName: event, transactionHash, recipient: returnValues.recipient, value: returnValues.value, blockNumber - })) - } - - getForeignEvents = foreignStore => { - return foreignStore.events - .slice() - .map(({ event, transactionHash, signedTxHash, blockNumber, returnValues }) => { - return { - color: this.colors[event], - eventName: event, - transactionHash, - recipient: returnValues.recipient, - value: returnValues.value, - blockNumber - } - }) + } + }) } onChangeList = e => { @@ -143,12 +139,8 @@ export class RelayEvents extends React.Component { const { selectedList } = this.state const home = this.getHomeEvents(homeStore, foreignStore) const foreign = this.getForeignEvents(foreignStore, homeStore) - const { - REACT_APP_HOME_WITHOUT_EVENTS: HOME, - REACT_APP_FOREIGN_WITHOUT_EVENTS: FOREIGN - } = process.env - const withoutEvents = - web3Store.metamaskNet.id === web3Store.homeNet.id.toString() ? yn(HOME) : yn(FOREIGN) + const { REACT_APP_HOME_WITHOUT_EVENTS: HOME, REACT_APP_FOREIGN_WITHOUT_EVENTS: FOREIGN } = process.env + const withoutEvents = web3Store.metamaskNet.id === web3Store.homeNet.id.toString() ? yn(HOME) : yn(FOREIGN) return withoutEvents ? ( @@ -156,12 +148,8 @@ export class RelayEvents extends React.Component {
@@ -32,9 +28,7 @@ export class StatisticsPage extends React.Component { Bridge Statistics {homeStore.depositFeeCollected.finished && homeStore.withdrawFeeCollected.finished && - (homeStore.depositFeeCollected.shouldDisplay || - homeStore.withdrawFeeCollected.shouldDisplay) && ( + (homeStore.depositFeeCollected.shouldDisplay || homeStore.withdrawFeeCollected.shouldDisplay) && (
- - Tokens {rightTitle} - + Tokens {rightTitle} diff --git a/ui/src/components/TransactionsStatistics.js b/ui/src/components/TransactionsStatistics.js index c409870e..3fcdfee8 100644 --- a/ui/src/components/TransactionsStatistics.js +++ b/ui/src/components/TransactionsStatistics.js @@ -6,10 +6,6 @@ export const TransactionsStatistics = ({ txNumber, value, type }) => (
- +
) diff --git a/ui/src/components/TransferAlert.js b/ui/src/components/TransferAlert.js index db684074..6a10b59a 100644 --- a/ui/src/components/TransferAlert.js +++ b/ui/src/components/TransferAlert.js @@ -42,9 +42,8 @@ export const TransferAlert = ({

{fee && `Fee: ${fee.toString()}%`}
- Please confirm that you would like to send {formattedFromAmount}{' '} - {fromCurrency} from {from} to receive {formattedToAmount} {toCurrency} on{' '} - {to}. + Please confirm that you would like to send {formattedFromAmount} {fromCurrency} from {from}{' '} + to receive {formattedToAmount} {toCurrency} on {to}.