Customizable ethers provider

This commit is contained in:
Ayanami 2022-06-07 15:38:55 +09:00 committed by Danil Kovtonyuk
parent 142ce883b4
commit 32a712e1db

View File

@ -21,10 +21,10 @@ const defaultConfig = {
} }
class TxManager { class TxManager {
constructor({ privateKey, rpcUrl, broadcastNodes = [], config = {}, gasPriceOracleConfig = {} }) { constructor({ privateKey, rpcUrl, broadcastNodes = [], config = {}, gasPriceOracleConfig = {}, provider }) {
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 = 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