From 1dba07623dd06e3d041344f20bbeb2e550deff3d Mon Sep 17 00:00:00 2001 From: rzadp Date: Fri, 7 Jun 2019 13:00:07 +0200 Subject: [PATCH 1/3] Remove reduntant dotenv configs --- oracle/config/affirmation-request-watcher.config.js | 1 - oracle/config/foreign-sender.config.js | 1 - oracle/config/home-sender.config.js | 1 - 3 files changed, 3 deletions(-) diff --git a/oracle/config/affirmation-request-watcher.config.js b/oracle/config/affirmation-request-watcher.config.js index b1325be3..1acd26b6 100644 --- a/oracle/config/affirmation-request-watcher.config.js +++ b/oracle/config/affirmation-request-watcher.config.js @@ -1,4 +1,3 @@ -require('dotenv').config() const baseConfig = require('./base.config') const erc20Abi = require('../../contracts/build/contracts/ERC20').abi const { ERC_TYPES } = require('../src/utils/constants') diff --git a/oracle/config/foreign-sender.config.js b/oracle/config/foreign-sender.config.js index 43fab9a2..c589a119 100644 --- a/oracle/config/foreign-sender.config.js +++ b/oracle/config/foreign-sender.config.js @@ -1,4 +1,3 @@ -require('dotenv').config() const baseConfig = require('./base.config') const { web3Foreign } = require('../src/services/web3') diff --git a/oracle/config/home-sender.config.js b/oracle/config/home-sender.config.js index b9a147ef..cc5ab3a1 100644 --- a/oracle/config/home-sender.config.js +++ b/oracle/config/home-sender.config.js @@ -1,4 +1,3 @@ -require('dotenv').config() const baseConfig = require('./base.config') const { web3Home } = require('../src/services/web3') From 9285ac534e2aaabe3cd191b01a11264b1944bd2a Mon Sep 17 00:00:00 2001 From: rzadp Date: Fri, 7 Jun 2019 13:19:12 +0200 Subject: [PATCH 2/3] Introduced new way of getting env variables --- oracle/config/base.config.js | 2 +- oracle/env.js | 4 ++++ oracle/scripts/erc20_to_erc20/sendForeign.js | 5 +---- oracle/scripts/erc20_to_erc20/sendHome.js | 5 +---- oracle/scripts/erc20_to_native/sendForeign.js | 5 +---- oracle/scripts/erc20_to_native/sendHome.js | 5 +---- oracle/scripts/getValidatorStartBlocks.js | 5 +---- oracle/scripts/initialChecks.js | 5 +---- oracle/scripts/native_to_erc20/sendForeign.js | 5 +---- oracle/scripts/native_to_erc20/sendHome.js | 5 +---- oracle/scripts/privateKeyToAddress.js | 5 +---- oracle/scripts/resetLastBlock.js | 5 +---- oracle/src/events/processAffirmationRequests/index.js | 2 +- oracle/src/events/processCollectedSignatures/index.js | 2 +- oracle/src/events/processSignatureRequests/index.js | 2 +- oracle/src/events/processTransfers/index.js | 2 +- oracle/src/sender.js | 2 +- oracle/src/services/amqpClient.js | 2 +- oracle/src/services/gasPrice.js | 2 +- oracle/src/watcher.js | 2 +- oracle/test/test.env | 2 ++ 21 files changed, 25 insertions(+), 49 deletions(-) create mode 100644 oracle/env.js create mode 100644 oracle/test/test.env diff --git a/oracle/config/base.config.js b/oracle/config/base.config.js index 28f0f663..089c6c45 100644 --- a/oracle/config/base.config.js +++ b/oracle/config/base.config.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../env') const { toBN } = require('web3').utils const { web3Home, web3Foreign } = require('../src/services/web3') diff --git a/oracle/env.js b/oracle/env.js new file mode 100644 index 00000000..f285f615 --- /dev/null +++ b/oracle/env.js @@ -0,0 +1,4 @@ +const path = require('path') +require('dotenv').config({ + path: path.join(__dirname, process.env.NODE_ENV === 'test' ? './test/test.env' : './.env') +}) diff --git a/oracle/scripts/erc20_to_erc20/sendForeign.js b/oracle/scripts/erc20_to_erc20/sendForeign.js index f14643a5..d292f8d3 100644 --- a/oracle/scripts/erc20_to_erc20/sendForeign.js +++ b/oracle/scripts/erc20_to_erc20/sendForeign.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../../.env') -}) +require('../../env') const Web3 = require('web3') const Web3Utils = require('web3-utils') const rpcUrlsManager = require('../../src/services/getRpcUrlsManager') diff --git a/oracle/scripts/erc20_to_erc20/sendHome.js b/oracle/scripts/erc20_to_erc20/sendHome.js index 71a43ae9..bc89fb93 100644 --- a/oracle/scripts/erc20_to_erc20/sendHome.js +++ b/oracle/scripts/erc20_to_erc20/sendHome.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../../.env') -}) +require('../../env') const Web3 = require('web3') const Web3Utils = require('web3-utils') const rpcUrlsManager = require('../../src/services/getRpcUrlsManager') diff --git a/oracle/scripts/erc20_to_native/sendForeign.js b/oracle/scripts/erc20_to_native/sendForeign.js index 952ef690..0b728322 100644 --- a/oracle/scripts/erc20_to_native/sendForeign.js +++ b/oracle/scripts/erc20_to_native/sendForeign.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../../.env') -}) +require('../../env') const Web3 = require('web3') const Web3Utils = require('web3-utils') const rpcUrlsManager = require('../../src/services/getRpcUrlsManager') diff --git a/oracle/scripts/erc20_to_native/sendHome.js b/oracle/scripts/erc20_to_native/sendHome.js index 0df8a4dc..530c6a8c 100644 --- a/oracle/scripts/erc20_to_native/sendHome.js +++ b/oracle/scripts/erc20_to_native/sendHome.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../../.env') -}) +require('../../env') const Web3Utils = require('web3-utils') const { web3Home } = require('../../src/services/web3') const { sendTx, sendRawTx } = require('../../src/tx/sendTx') diff --git a/oracle/scripts/getValidatorStartBlocks.js b/oracle/scripts/getValidatorStartBlocks.js index 318fe7f9..8d97ddb4 100644 --- a/oracle/scripts/getValidatorStartBlocks.js +++ b/oracle/scripts/getValidatorStartBlocks.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../.env') -}) +require('../env') const Web3 = require('web3') const bridgeValidatorsABI = require('../../contracts/build/contracts/BridgeValidators').abi diff --git a/oracle/scripts/initialChecks.js b/oracle/scripts/initialChecks.js index 87cac4be..741c0de2 100644 --- a/oracle/scripts/initialChecks.js +++ b/oracle/scripts/initialChecks.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../.env') -}) +require('../env') const Web3 = require('web3') const ERC677BridgeTokenABI = require('../../contracts/build/contracts/ERC677BridgeToken').abi const { ERC_TYPES } = require('../src/utils/constants') diff --git a/oracle/scripts/native_to_erc20/sendForeign.js b/oracle/scripts/native_to_erc20/sendForeign.js index bf794b8f..56d773ab 100644 --- a/oracle/scripts/native_to_erc20/sendForeign.js +++ b/oracle/scripts/native_to_erc20/sendForeign.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../../.env') -}) +require('../../env') const Web3Utils = require('web3-utils') const { web3Foreign } = require('../../src/services/web3') const { sendTx, sendRawTx } = require('../../src/tx/sendTx') diff --git a/oracle/scripts/native_to_erc20/sendHome.js b/oracle/scripts/native_to_erc20/sendHome.js index cfcfa13c..6f02747b 100644 --- a/oracle/scripts/native_to_erc20/sendHome.js +++ b/oracle/scripts/native_to_erc20/sendHome.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../../.env') -}) +require('../../env') const Web3Utils = require('web3-utils') const { web3Home } = require('../../src/services/web3') const { sendTx, sendRawTx } = require('../../src/tx/sendTx') diff --git a/oracle/scripts/privateKeyToAddress.js b/oracle/scripts/privateKeyToAddress.js index 3ba23fff..dd0f255f 100644 --- a/oracle/scripts/privateKeyToAddress.js +++ b/oracle/scripts/privateKeyToAddress.js @@ -1,7 +1,4 @@ -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '..', '.env') -}) +require('../env') const { privateKeyToAddress } = require('../src/utils/utils') const { EXIT_CODES } = require('../src/utils/constants') diff --git a/oracle/scripts/resetLastBlock.js b/oracle/scripts/resetLastBlock.js index 57feed4a..a62068a9 100644 --- a/oracle/scripts/resetLastBlock.js +++ b/oracle/scripts/resetLastBlock.js @@ -1,8 +1,5 @@ +require('../env') const Redis = require('ioredis') -const path = require('path') -require('dotenv').config({ - path: path.join(__dirname, '../.env') -}) const { id } = require('../config/base.config') const { EXIT_CODES } = require('../src/utils/constants') diff --git a/oracle/src/events/processAffirmationRequests/index.js b/oracle/src/events/processAffirmationRequests/index.js index aa240991..09996c6f 100644 --- a/oracle/src/events/processAffirmationRequests/index.js +++ b/oracle/src/events/processAffirmationRequests/index.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../../../env') const promiseLimit = require('promise-limit') const { HttpListProviderError } = require('http-list-provider') const rootLogger = require('../../services/logger') diff --git a/oracle/src/events/processCollectedSignatures/index.js b/oracle/src/events/processCollectedSignatures/index.js index d84800a1..db83a20b 100644 --- a/oracle/src/events/processCollectedSignatures/index.js +++ b/oracle/src/events/processCollectedSignatures/index.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../../../env') const promiseLimit = require('promise-limit') const { HttpListProviderError } = require('http-list-provider') const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi diff --git a/oracle/src/events/processSignatureRequests/index.js b/oracle/src/events/processSignatureRequests/index.js index 6aadf00b..309a810a 100644 --- a/oracle/src/events/processSignatureRequests/index.js +++ b/oracle/src/events/processSignatureRequests/index.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../../../env') const promiseLimit = require('promise-limit') const { HttpListProviderError } = require('http-list-provider') const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi diff --git a/oracle/src/events/processTransfers/index.js b/oracle/src/events/processTransfers/index.js index 9be7523c..4ac75608 100644 --- a/oracle/src/events/processTransfers/index.js +++ b/oracle/src/events/processTransfers/index.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../../../env') const promiseLimit = require('promise-limit') const { HttpListProviderError } = require('http-list-provider') const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi diff --git a/oracle/src/sender.js b/oracle/src/sender.js index 07ffc9cd..97d8361c 100644 --- a/oracle/src/sender.js +++ b/oracle/src/sender.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../env') const path = require('path') const { connectSenderToQueue } = require('./services/amqpClient') const { redis, redlock } = require('./services/redisClient') diff --git a/oracle/src/services/amqpClient.js b/oracle/src/services/amqpClient.js index 7fbd8306..f16cabe6 100644 --- a/oracle/src/services/amqpClient.js +++ b/oracle/src/services/amqpClient.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../../env') const connection = require('amqp-connection-manager').connect(process.env.QUEUE_URL) const logger = require('./logger') diff --git a/oracle/src/services/gasPrice.js b/oracle/src/services/gasPrice.js index 9f472ce3..bd25716d 100644 --- a/oracle/src/services/gasPrice.js +++ b/oracle/src/services/gasPrice.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../../env') const fetch = require('node-fetch') const Web3Utils = require('web3-utils') const { web3Home, web3Foreign } = require('../services/web3') diff --git a/oracle/src/watcher.js b/oracle/src/watcher.js index e566c5b8..ce43a3c5 100644 --- a/oracle/src/watcher.js +++ b/oracle/src/watcher.js @@ -1,4 +1,4 @@ -require('dotenv').config() +require('../env') const path = require('path') const { BN, toBN } = require('web3').utils const { connectWatcherToQueue, connection } = require('./services/amqpClient') diff --git a/oracle/test/test.env b/oracle/test/test.env new file mode 100644 index 00000000..710c869c --- /dev/null +++ b/oracle/test/test.env @@ -0,0 +1,2 @@ +HOME_RPC_URL=http://example.com +FOREIGN_RPC_URL=http://example.com From 404b1d4959565cec51ed41dd3c4fb479ed6750d5 Mon Sep 17 00:00:00 2001 From: rzadp Date: Fri, 7 Jun 2019 13:19:36 +0200 Subject: [PATCH 3/3] Removed env variables from CI --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ba8b065d..fc640144 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,9 +58,6 @@ jobs: test: docker: - image: circleci/node:10.15 - environment: - HOME_RPC_URL: http://example.com - FOREIGN_RPC_URL: http://example.com steps: - restore_cache: key: initialize-{{ .Environment.CIRCLE_SHA1 }}