fix: update deps

fix: update gasLimit

fix: rpc
This commit is contained in:
Danil Kovtonyuk 2021-10-19 01:35:31 +10:00 committed by 0xZick
parent f594c2d1a7
commit b73a650d7b
8 changed files with 116 additions and 56 deletions

View File

@ -32,13 +32,13 @@
"ajv": "^8.6.1",
"bull": "^3.22.11",
"class-validator": "^0.13.1",
"ethers": "^5.4.1",
"ethers": "^5.4.6",
"gas-price-oracle": "^0.4.0",
"redis": "^3.1.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"tx-manager": "^0.3.1",
"tx-manager": "^0.4.2",
"uuid": "^8.3.2"
},
"devDependencies": {

View File

@ -9,4 +9,7 @@ export default registerAs('txManager', () => ({
CONFIRMATIONS: process.env.CONFIRMATIONS,
MAX_GAS_PRICE: process.env.MAX_GAS_PRICE,
},
gasPriceOracleConfig: {
chainId: Number(process.env.CHAIN_ID),
},
}));

View File

@ -11,7 +11,7 @@ export const RPC_LIST: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: 'https://mainnet.infura.io/v3/eb6a84e726614079948e0b1efce5baa5',
[ChainId.GOERLI]: 'https://eth-goerli.alchemyapi.io/v2/hlSj0EqPUuLGyyTExs6UqFKnXDrc_eOh',
[ChainId.OPTIMISM]: 'https://optimism-kovan.infura.io/v3/8f786b96d16046b78e0287fa61c6fcf8',
[ChainId.XDAI]: 'https://rpc.xdaichain.com',
[ChainId.XDAI]: 'https://xdai-rpc.ztake.org',
};
export const OFF_CHAIN_ORACLE = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';

View File

@ -15,7 +15,7 @@ const NETWORKS_INFO: { [chainId in ChainId] } = {
minimumBalance: '0.5',
},
[ChainId.XDAI]: {
gasLimit: BigNumber.from(2500000),
gasLimit: BigNumber.from(1650000),
minimumBalance: '0.5',
},
};
@ -32,6 +32,7 @@ const numbers = {
};
export const jobStatus = {
QUEUED: 'QUEUED',
ACCEPTED: 'ACCEPTED',
CONFIRMED: 'CONFIRMED',
FAILED: 'FAILED',

View File

@ -3,6 +3,7 @@ import { v4 as uuid } from 'uuid';
import { InjectQueue } from '@nestjs/bull';
import { Injectable } from '@nestjs/common';
import { jobStatus } from '@/constants';
import { ProviderService } from '@/services';
import { ConfigService } from '@nestjs/config';
@ -37,7 +38,7 @@ class ApiService {
async transaction(data: any): Promise<string> {
const jobId = uuid();
await this.transactionQueue.add({ ...data, status: 'QUEUED' }, { jobId });
await this.transactionQueue.add({ ...data, status: jobStatus.QUEUED }, { jobId });
return jobId;
}

View File

@ -103,7 +103,7 @@ export class TransactionProcessor extends BaseProcessor<Transaction> {
const data = contract.interface.encodeFunctionData('transact', [args, extData]);
let gasLimit = this.configService.get<BigNumber>('base.gasLimit');
const gasLimit = this.configService.get<BigNumber>('base.gasLimit');
const { fast } = await this.gasPriceService.getGasPrice();

View File

@ -4,9 +4,8 @@ import { ConfigService } from '@nestjs/config';
import { BigNumber } from 'ethers';
import { GasPriceOracle } from 'gas-price-oracle';
import { ChainId } from '@/types';
import { RPC_LIST, numbers } from '@/constants';
import { toWei } from '@/utilities';
import { RPC_LIST } from '@/constants';
@Injectable()
export class GasPriceService {
@ -17,12 +16,9 @@ export class GasPriceService {
}
async getGasPrice() {
const TIMER = 3;
const INTERVAL = TIMER * numbers.SECOND;
const instance = new GasPriceOracle({
timeout: INTERVAL,
defaultRpc: RPC_LIST[ChainId.XDAI],
chainId: this.chainId,
defaultRpc: RPC_LIST[this.chainId],
});
const fast = await instance.fetchGasPriceFromRpc();

145
yarn.lock
View File

@ -378,7 +378,22 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"
"@ethersproject/abi@5.4.0", "@ethersproject/abi@^5.4.0":
"@ethersproject/abi@5.4.1":
version "5.4.1"
resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.4.1.tgz#6ac28fafc9ef6f5a7a37e30356a2eb31fa05d39b"
integrity sha512-9mhbjUk76BiSluiiW4BaYyI58KSbDMMQpCLdsAR+RsT2GyATiNYxVv+pGWRrekmsIdY3I+hOqsYQSTkc8L/mcg==
dependencies:
"@ethersproject/address" "^5.4.0"
"@ethersproject/bignumber" "^5.4.0"
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/constants" "^5.4.0"
"@ethersproject/hash" "^5.4.0"
"@ethersproject/keccak256" "^5.4.0"
"@ethersproject/logger" "^5.4.0"
"@ethersproject/properties" "^5.4.0"
"@ethersproject/strings" "^5.4.0"
"@ethersproject/abi@^5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.4.0.tgz#a6d63bdb3672f738398846d4279fa6b6c9818242"
integrity sha512-9gU2H+/yK1j2eVMdzm6xvHSnMxk8waIHQGYCZg5uvAyH0rsAzxkModzBSpbAkAuhKFEovC2S9hM4nPuLym8IZw==
@ -393,7 +408,20 @@
"@ethersproject/properties" "^5.4.0"
"@ethersproject/strings" "^5.4.0"
"@ethersproject/abstract-provider@5.4.0", "@ethersproject/abstract-provider@^5.4.0":
"@ethersproject/abstract-provider@5.4.1":
version "5.4.1"
resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.4.1.tgz#e404309a29f771bd4d28dbafadcaa184668c2a6e"
integrity sha512-3EedfKI3LVpjSKgAxoUaI+gB27frKsxzm+r21w9G60Ugk+3wVLQwhi1LsEJAKNV7WoZc8CIpNrATlL1QFABjtQ==
dependencies:
"@ethersproject/bignumber" "^5.4.0"
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/logger" "^5.4.0"
"@ethersproject/networks" "^5.4.0"
"@ethersproject/properties" "^5.4.0"
"@ethersproject/transactions" "^5.4.0"
"@ethersproject/web" "^5.4.0"
"@ethersproject/abstract-provider@^5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.4.0.tgz#415331031b0f678388971e1987305244edc04e1d"
integrity sha512-vPBR7HKUBY0lpdllIn7tLIzNN7DrVnhCLKSzY0l8WAwxz686m/aL7ASDzrVxV93GJtIub6N2t4dfZ29CkPOxgA==
@ -406,7 +434,18 @@
"@ethersproject/transactions" "^5.4.0"
"@ethersproject/web" "^5.4.0"
"@ethersproject/abstract-signer@5.4.0", "@ethersproject/abstract-signer@^5.4.0":
"@ethersproject/abstract-signer@5.4.1":
version "5.4.1"
resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.4.1.tgz#e4e9abcf4dd4f1ba0db7dff9746a5f78f355ea81"
integrity sha512-SkkFL5HVq1k4/25dM+NWP9MILgohJCgGv5xT5AcRruGz4ILpfHeBtO/y6j+Z3UN/PAjDeb4P7E51Yh8wcGNLGA==
dependencies:
"@ethersproject/abstract-provider" "^5.4.0"
"@ethersproject/bignumber" "^5.4.0"
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/logger" "^5.4.0"
"@ethersproject/properties" "^5.4.0"
"@ethersproject/abstract-signer@^5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.4.0.tgz#cd5f50b93141ee9f9f49feb4075a0b3eafb57d65"
integrity sha512-AieQAzt05HJZS2bMofpuxMEp81AHufA5D6M4ScKwtolj041nrfIbIi8ciNW7+F59VYxXq+V4c3d568Q6l2m8ew==
@ -443,7 +482,16 @@
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/properties" "^5.4.0"
"@ethersproject/bignumber@5.4.0", "@ethersproject/bignumber@^5.4.0":
"@ethersproject/bignumber@5.4.2":
version "5.4.2"
resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.4.2.tgz#44232e015ae4ce82ac034de549eb3583c71283d8"
integrity sha512-oIBDhsKy5bs7j36JlaTzFgNPaZjiNDOXsdSgSpXRucUl+UA6L/1YLlFeI3cPAoodcenzF4nxNPV13pcy7XbWjA==
dependencies:
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/logger" "^5.4.0"
bn.js "^4.11.9"
"@ethersproject/bignumber@^5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.4.0.tgz#be8dea298c0ec71208ee60f0b245be0761217ad9"
integrity sha512-OXUu9f9hO3vGRIPxU40cignXZVaYyfx6j9NNMjebKdnaCL3anCLSSy8/b8d03vY6dh7duCC0kW72GEC4tZer2w==
@ -466,10 +514,10 @@
dependencies:
"@ethersproject/bignumber" "^5.4.0"
"@ethersproject/contracts@5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.4.0.tgz#e05fe6bd33acc98741e27d553889ec5920078abb"
integrity sha512-hkO3L3IhS1Z3ZtHtaAG/T87nQ7KiPV+/qnvutag35I0IkiQ8G3ZpCQ9NNOpSCzn4pWSW4CfzmtE02FcqnLI+hw==
"@ethersproject/contracts@5.4.1":
version "5.4.1"
resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.4.1.tgz#3eb4f35b7fe60a962a75804ada2746494df3e470"
integrity sha512-m+z2ZgPy4pyR15Je//dUaymRUZq5MtDajF6GwFbGAVmKz/RF+DNIPwF0k5qEcL3wPGVqUjFg2/krlCRVTU4T5w==
dependencies:
"@ethersproject/abi" "^5.4.0"
"@ethersproject/abstract-provider" "^5.4.0"
@ -541,12 +589,24 @@
"@ethersproject/bytes" "^5.4.0"
js-sha3 "0.5.7"
"@ethersproject/logger@5.4.0", "@ethersproject/logger@^5.4.0":
"@ethersproject/logger@5.4.1":
version "5.4.1"
resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.4.1.tgz#503bd33683538b923c578c07d1c2c0dd18672054"
integrity sha512-DZ+bRinnYLPw1yAC64oRl0QyVZj43QeHIhVKfD/+YwSz4wsv1pfwb5SOFjz+r710YEWzU6LrhuSjpSO+6PeE4A==
"@ethersproject/logger@^5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.4.0.tgz#f39adadf62ad610c420bcd156fd41270e91b3ca9"
integrity sha512-xYdWGGQ9P2cxBayt64d8LC8aPFJk6yWCawQi/4eJ4+oJdMMjEBMrIcIMZ9AxhwpPVmnBPrsB10PcXGmGAqgUEQ==
"@ethersproject/networks@5.4.1", "@ethersproject/networks@^5.4.0":
"@ethersproject/networks@5.4.2":
version "5.4.2"
resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.4.2.tgz#2247d977626e97e2c3b8ee73cd2457babde0ce35"
integrity sha512-eekOhvJyBnuibfJnhtK46b8HimBc5+4gqpvd1/H9LEl7Q7/qhsIhM81dI9Fcnjpk3jB1aTy6bj0hz3cifhNeYw==
dependencies:
"@ethersproject/logger" "^5.4.0"
"@ethersproject/networks@^5.4.0":
version "5.4.1"
resolved "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.4.1.tgz#2ce83b8e42aa85216e5d277a7952d97b6ce8d852"
integrity sha512-8SvowCKz9Uf4xC5DTKI8+il8lWqOr78kmiqAVLYT9lzB8aSmJHQMD1GSuJI0CW4hMAnzocpGpZLgiMdzsNSPig==
@ -561,17 +621,24 @@
"@ethersproject/bytes" "^5.4.0"
"@ethersproject/sha2" "^5.4.0"
"@ethersproject/properties@5.4.0", "@ethersproject/properties@^5.4.0":
"@ethersproject/properties@5.4.1":
version "5.4.1"
resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.4.1.tgz#9f051f976ce790142c6261ccb7b826eaae1f2f36"
integrity sha512-cyCGlF8wWlIZyizsj2PpbJ9I7rIlUAfnHYwy/T90pdkSn/NFTa5YWZx2wTJBe9V7dD65dcrrEMisCRUJiq6n3w==
dependencies:
"@ethersproject/logger" "^5.4.0"
"@ethersproject/properties@^5.4.0":
version "5.4.0"
resolved "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.4.0.tgz#38ba20539b44dcc5d5f80c45ad902017dcdbefe7"
integrity sha512-7jczalGVRAJ+XSRvNA6D5sAwT4gavLq3OXPuV/74o3Rd2wuzSL035IMpIMgei4CYyBdialJMrTqkOnzccLHn4A==
dependencies:
"@ethersproject/logger" "^5.4.0"
"@ethersproject/providers@5.4.1":
version "5.4.1"
resolved "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.4.1.tgz#654267b563b833046b9c9647647cfc8267cb93b4"
integrity sha512-p06eiFKz8nu/5Ju0kIX024gzEQIgE5pvvGrBCngpyVjpuLtUIWT3097Agw4mTn9/dEA0FMcfByzFqacBMSgCVg==
"@ethersproject/providers@5.4.5":
version "5.4.5"
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.4.5.tgz#eb2ea2a743a8115f79604a8157233a3a2c832928"
integrity sha512-1GkrvkiAw3Fj28cwi1Sqm8ED1RtERtpdXmRfwIBGmqBSN5MoeRUHuwHPppMtbPayPgpFcvD7/Gdc9doO5fGYgw==
dependencies:
"@ethersproject/abstract-provider" "^5.4.0"
"@ethersproject/abstract-signer" "^5.4.0"
@ -2766,30 +2833,30 @@ etag@~1.8.1:
resolved "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
ethers@^5.0.17, ethers@^5.4.1:
version "5.4.1"
resolved "https://registry.npmjs.org/ethers/-/ethers-5.4.1.tgz#bcff1e9f45bf1a061bf313ec04e8d9881d2d53f9"
integrity sha512-SrcddMdCgP1hukDvCPd87Aipbf4NWjQvdfAbZ65XSZGbfyuYPtIrUJPDH5B1SBRsdlfiEgX3eoz28DdBDzMNFg==
ethers@^5.4.6:
version "5.4.7"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.4.7.tgz#0fd491a5da7c9793de2d6058d76b41b1e7efba8f"
integrity sha512-iZc5p2nqfWK1sj8RabwsPM28cr37Bpq7ehTQ5rWExBr2Y09Sn1lDKZOED26n+TsZMye7Y6mIgQ/1cwpSD8XZew==
dependencies:
"@ethersproject/abi" "5.4.0"
"@ethersproject/abstract-provider" "5.4.0"
"@ethersproject/abstract-signer" "5.4.0"
"@ethersproject/abi" "5.4.1"
"@ethersproject/abstract-provider" "5.4.1"
"@ethersproject/abstract-signer" "5.4.1"
"@ethersproject/address" "5.4.0"
"@ethersproject/base64" "5.4.0"
"@ethersproject/basex" "5.4.0"
"@ethersproject/bignumber" "5.4.0"
"@ethersproject/bignumber" "5.4.2"
"@ethersproject/bytes" "5.4.0"
"@ethersproject/constants" "5.4.0"
"@ethersproject/contracts" "5.4.0"
"@ethersproject/contracts" "5.4.1"
"@ethersproject/hash" "5.4.0"
"@ethersproject/hdnode" "5.4.0"
"@ethersproject/json-wallets" "5.4.0"
"@ethersproject/keccak256" "5.4.0"
"@ethersproject/logger" "5.4.0"
"@ethersproject/networks" "5.4.1"
"@ethersproject/logger" "5.4.1"
"@ethersproject/networks" "5.4.2"
"@ethersproject/pbkdf2" "5.4.0"
"@ethersproject/properties" "5.4.0"
"@ethersproject/providers" "5.4.1"
"@ethersproject/properties" "5.4.1"
"@ethersproject/providers" "5.4.5"
"@ethersproject/random" "5.4.0"
"@ethersproject/rlp" "5.4.0"
"@ethersproject/sha2" "5.4.0"
@ -3132,17 +3199,9 @@ functional-red-black-tree@^1.0.1:
resolved "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
gas-price-oracle@^0.3.3:
version "0.3.3"
resolved "https://registry.npmjs.org/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"
gas-price-oracle@^0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/gas-price-oracle/-/gas-price-oracle-0.4.0.tgz#1b8426bce92ebcff6cc98a0c5638769cb22417b1"
resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.4.0.tgz#1b8426bce92ebcff6cc98a0c5638769cb22417b1"
integrity sha512-5ct4VwTqTigD1V3EvUn513e41OIA+/Ubw0FITVfarw7AjVpg4LQSt9anRt+LcDU4+u+eMUEA3VP0VnvMN8nybA==
dependencies:
axios "^0.19.2"
@ -5741,14 +5800,14 @@ tsutils@^3.21.0:
dependencies:
tslib "^1.8.1"
tx-manager@^0.3.1:
version "0.3.1"
resolved "https://registry.npmjs.org/tx-manager/-/tx-manager-0.3.1.tgz#6cb601a26feeba2d85b62a6fe0f732ed82762141"
integrity sha512-KKzpuTHEhWPG5aREeypNzXHjGp+qfzoTsVWYLRIx9xvMEAbOj8kfPKoPS3liEK01RylLW+IwbYDqbji8RK83Hg==
tx-manager@^0.4.2:
version "0.4.2"
resolved "https://registry.yarnpkg.com/tx-manager/-/tx-manager-0.4.2.tgz#117e5da2e720f2389492f51a1cb99f1316dfd894"
integrity sha512-3Q9eNA9lPFvAp32oqINRA3d5L5r9Gxxb5vIfyou5dJ7YTyIaqO37MEqHkNXxpKIcmPK6KM9j8iPIheg3lwvpAA==
dependencies:
async-mutex "^0.2.4"
ethers "^5.0.17"
gas-price-oracle "^0.3.3"
ethers "^5.4.6"
gas-price-oracle "^0.4.0"
web3-core-promievent "^1.3.0"
type-check@^0.4.0, type-check@~0.4.0: