From 9747c1a397c940beb01aaeb765653fa462f5a6be Mon Sep 17 00:00:00 2001 From: Danil Kovtonyuk Date: Tue, 15 Jun 2021 15:04:14 +0300 Subject: [PATCH] feat: add polygon --- package.json | 6 +++--- src/constants.js | 22 ++++++++++++++++++++++ src/worker.js | 3 ++- yarn.lock | 26 +++++++++----------------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index aafe642..7731b23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "relay", - "version": "5.0.0-beta.0", + "version": "5.0.0-beta.1", "description": "Relayer for Tornado.cash privacy solution. https://tornado.cash", "scripts": { "server": "node src/server.js", @@ -20,9 +20,9 @@ "bull": "^3.12.1", "dotenv": "^8.2.0", "express": "^4.17.1", - "gas-price-oracle": "^0.3.2", + "gas-price-oracle": "^0.3.3", "ioredis": "^4.14.1", - "tx-manager": "^0.3.0", + "tx-manager": "^0.3.1", "uuid": "^8.3.0", "web3": "^1.3.0", "web3-utils": "^1.2.2" diff --git a/src/constants.js b/src/constants.js index cd945c3..86817ff 100644 --- a/src/constants.js +++ b/src/constants.js @@ -35,6 +35,28 @@ const networkConfig = { }, proxyLight: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', }, + netId137: { + gasPrices: { + instant: 7.5, + fast: 5, + standard: 1, + low: 1, + }, + nativeCurrency: 'matic', + instances: { + matic: { + instanceAddress: { + 0.1: '0x992A81FA34aa6ecD9520F39f858abc51fee6994a', + 1: undefined, + 10: undefined, + 100: undefined, + }, + symbol: 'MATIC', + decimals: 18, + }, + }, + proxyLight: '0xDC16d16341A62c60E7C9889F9d1FcE4cde57a90F', + }, } module.exports = { diff --git a/src/worker.js b/src/worker.js index 0460bd8..c3a3a21 100644 --- a/src/worker.js +++ b/src/worker.js @@ -30,7 +30,8 @@ function start() { const { CONFIRMATIONS, MAX_GAS_PRICE } = process.env let gasPriceOracleConfig = {} - if (netId === 56) { + const networksWithOracle = [56, 137] + if (networksWithOracle.includes(netId)) { gasPriceOracleConfig = { chainId: netId, defaultFallbackGasPrices: gasPrices, diff --git a/yarn.lock b/yarn.lock index 896006e..fe3029c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2019,18 +2019,10 @@ functional-red-black-tree@^1.0.1: resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= -gas-price-oracle@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.3.1.tgz#4977de5edfa49ae17defad0e0d06f9a67bdf2cc6" - integrity sha512-v82AEeQVnO4lGKoJbRqLI9YdOVoImBorYDSOMTGZZAF+RNC89fdTsbhLQVsI/1Zsduqcpiz4VqlQ/4I8wwCbAg== - dependencies: - axios "^0.19.2" - bignumber.js "^9.0.0" - -gas-price-oracle@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.3.2.tgz#842ec6fe4f362703bb45add642288dbdf70b240b" - integrity sha512-KWET9iL/QtoZmBXDy8t1sDELIg0bhkH6ExZQwuW6jUs4tJfZGNmB8NPKTnSaycXuIe72nW5t/1pjn6pUQlSByg== +gas-price-oracle@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.3.3.tgz#25a478d406263961af740dbfa314e053d334ed0f" + integrity sha512-euMl8Q42pigzpNvl95XvsRE41huNmTcFaGR7FO2fI0Kutu51c2Toh78B6sPrKhgOHQmoCyokj+jb0gDmxMxOwA== dependencies: axios "^0.19.2" bignumber.js "^9.0.0" @@ -3894,14 +3886,14 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= -tx-manager@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/tx-manager/-/tx-manager-0.3.0.tgz#db4373f51388391d655a59c20ce58048a2987e7a" - integrity sha512-GQZNqUg6qfbEM3qRtd6Iblc2jfH08JkTj54HU8MQx7gcKix7YiGvKkvQM+FBBcmG9JuN5V6vmOmXixf97/Wq8A== +tx-manager@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/tx-manager/-/tx-manager-0.3.1.tgz#6cb601a26feeba2d85b62a6fe0f732ed82762141" + integrity sha512-KKzpuTHEhWPG5aREeypNzXHjGp+qfzoTsVWYLRIx9xvMEAbOj8kfPKoPS3liEK01RylLW+IwbYDqbji8RK83Hg== dependencies: async-mutex "^0.2.4" ethers "^5.0.17" - gas-price-oracle "^0.3.1" + gas-price-oracle "^0.3.3" web3-core-promievent "^1.3.0" type-check@~0.3.2: