add gasPriceOracleConfig

This commit is contained in:
Danil Kovtonyuk 2021-06-03 16:16:31 +03:00
parent f6a4e93a23
commit 72a665a19a
3 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "tx-manager", "name": "tx-manager",
"version": "0.2.9", "version": "0.3.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -23,7 +23,7 @@
"dependencies": { "dependencies": {
"async-mutex": "^0.2.4", "async-mutex": "^0.2.4",
"ethers": "^5.0.17", "ethers": "^5.0.17",
"gas-price-oracle": "^0.2.2", "gas-price-oracle": "^0.3.1",
"web3-core-promievent": "^1.3.0" "web3-core-promievent": "^1.3.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -18,14 +18,14 @@ const defaultConfig = {
} }
class TxManager { class TxManager {
constructor({ privateKey, rpcUrl, broadcastNodes = [], config = {} }) { constructor({ privateKey, rpcUrl, broadcastNodes = [], config = {}, gasPriceOracleConfig = {} }) {
this.config = Object.assign({ ...defaultConfig }, config) this.config = Object.assign({ ...defaultConfig }, config)
this._privateKey = privateKey.startsWith('0x') ? privateKey : '0x' + privateKey this._privateKey = privateKey.startsWith('0x') ? privateKey : '0x' + privateKey
this._provider = new ethers.providers.JsonRpcProvider(rpcUrl) this._provider = new ethers.providers.JsonRpcProvider(rpcUrl)
this._wallet = new ethers.Wallet(this._privateKey, this._provider) this._wallet = new ethers.Wallet(this._privateKey, this._provider)
this.address = this._wallet.address this.address = this._wallet.address
this._broadcastNodes = broadcastNodes this._broadcastNodes = broadcastNodes
this._gasPriceOracle = new GasPriceOracle({ defaultRpc: rpcUrl }) this._gasPriceOracle = new GasPriceOracle({ defaultRpc: rpcUrl, ...gasPriceOracleConfig })
this._mutex = new Mutex() this._mutex = new Mutex()
this._nonce = null this._nonce = null
} }

View File

@ -1141,10 +1141,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" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
gas-price-oracle@^0.2.2: gas-price-oracle@^0.3.1:
version "0.2.2" version "0.3.1"
resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.2.2.tgz#32c57a9aa6bc69152be96812880232efebfecbc6" resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.3.1.tgz#4977de5edfa49ae17defad0e0d06f9a67bdf2cc6"
integrity sha512-I4+rLbc7C1vgYXV+cYY0MKeqdZVna2hXpNfD2fcIvf/wIgvtIYmG9gsmhiaYGSgOE2RSPUs2xf/W4K2nJOoNuQ== integrity sha512-v82AEeQVnO4lGKoJbRqLI9YdOVoImBorYDSOMTGZZAF+RNC89fdTsbhLQVsI/1Zsduqcpiz4VqlQ/4I8wwCbAg==
dependencies: dependencies:
axios "^0.19.2" axios "^0.19.2"
bignumber.js "^9.0.0" bignumber.js "^9.0.0"