1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

fix getFairGasPrice

This commit is contained in:
Bogdan Fazakas 2022-08-10 16:19:04 +03:00
parent 8b1842e1e9
commit 41881ac6eb
7 changed files with 78 additions and 1 deletions

View File

@ -69,6 +69,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.deployERC721Contract, this.contract.methods.deployERC721Contract,
nftData.name, nftData.name,
nftData.symbol, nftData.symbol,
@ -194,6 +195,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.add721TokenTemplate, this.contract.methods.add721TokenTemplate,
templateAddress templateAddress
) )
@ -232,6 +234,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.disable721TokenTemplate, this.contract.methods.disable721TokenTemplate,
templateIndex templateIndex
) )
@ -272,6 +275,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.reactivate721TokenTemplate, this.contract.methods.reactivate721TokenTemplate,
templateIndex templateIndex
) )
@ -308,6 +312,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.addTokenTemplate, this.contract.methods.addTokenTemplate,
templateAddress templateAddress
) )
@ -350,6 +355,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.disableTokenTemplate, this.contract.methods.disableTokenTemplate,
templateIndex templateIndex
) )
@ -393,6 +399,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.reactivateTokenTemplate, this.contract.methods.reactivateTokenTemplate,
templateIndex templateIndex
) )
@ -432,6 +439,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.startMultipleTokenOrder, this.contract.methods.startMultipleTokenOrder,
orders orders
) )
@ -468,6 +476,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.createNftWithErc20, this.contract.methods.createNftWithErc20,
nftCreateData, nftCreateData,
ercCreateData ercCreateData
@ -509,6 +518,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.createNftWithErc20WithPool, this.contract.methods.createNftWithErc20WithPool,
nftCreateData, nftCreateData,
ercCreateData, ercCreateData,
@ -551,6 +561,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.createNftWithErc20WithFixedRate, this.contract.methods.createNftWithErc20WithFixedRate,
nftCreateData, nftCreateData,
ercCreateData, ercCreateData,
@ -595,6 +606,7 @@ export class NftFactory extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.createNftWithErc20WithDispenser, this.contract.methods.createNftWithErc20WithDispenser,
nftCreateData, nftCreateData,
ercCreateData, ercCreateData,

View File

@ -59,6 +59,7 @@ export class Dispenser extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.create, this.contract.methods.create,
dtAddress, dtAddress,
this.web3.utils.toWei(maxTokens), this.web3.utils.toWei(maxTokens),
@ -98,6 +99,7 @@ export class Dispenser extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.activate, this.contract.methods.activate,
dtAddress, dtAddress,
this.web3.utils.toWei(maxTokens), this.web3.utils.toWei(maxTokens),
@ -129,6 +131,7 @@ export class Dispenser extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.deactivate, this.contract.methods.deactivate,
dtAddress dtAddress
) )
@ -160,6 +163,7 @@ export class Dispenser extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.setAllowedSwapper, this.contract.methods.setAllowedSwapper,
dtAddress, dtAddress,
newAllowedSwapper newAllowedSwapper
@ -197,6 +201,7 @@ export class Dispenser extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.dispense, this.contract.methods.dispense,
dtAddress, dtAddress,
this.web3.utils.toWei(amount), this.web3.utils.toWei(amount),
@ -228,6 +233,7 @@ export class Dispenser extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.ownerWithdraw, this.contract.methods.ownerWithdraw,
dtAddress dtAddress
) )

View File

@ -70,6 +70,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.buyDT, this.contract.methods.buyDT,
exchangeId, exchangeId,
dtAmountFormatted, dtAmountFormatted,
@ -127,6 +128,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.sellDT, this.contract.methods.sellDT,
exchangeId, exchangeId,
dtAmountFormatted, dtAmountFormatted,
@ -173,6 +175,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.setRate, this.contract.methods.setRate,
exchangeId, exchangeId,
this.web3.utils.toWei(newRate) this.web3.utils.toWei(newRate)
@ -206,6 +209,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.setAllowedSwapper, this.contract.methods.setAllowedSwapper,
exchangeId, exchangeId,
newAllowedSwapper newAllowedSwapper
@ -238,6 +242,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.toggleExchangeState, this.contract.methods.toggleExchangeState,
exchangeId exchangeId
) )
@ -270,6 +275,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.toggleExchangeState, this.contract.methods.toggleExchangeState,
exchangeId exchangeId
) )
@ -504,6 +510,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.toggleMintState, this.contract.methods.toggleMintState,
exchangeId, exchangeId,
true true
@ -538,6 +545,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.toggleMintState, this.contract.methods.toggleMintState,
exchangeId, exchangeId,
false false
@ -582,6 +590,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.collectBT, this.contract.methods.collectBT,
exchangeId, exchangeId,
amountWei amountWei
@ -626,6 +635,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.collectDT, this.contract.methods.collectDT,
exchangeId, exchangeId,
amountWei amountWei
@ -658,6 +668,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.collectMarketFee, this.contract.methods.collectMarketFee,
exchangeId exchangeId
) )
@ -690,6 +701,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.collectOceanFee, this.contract.methods.collectOceanFee,
exchangeId exchangeId
) )
@ -750,6 +762,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.updateMarketFee, this.contract.methods.updateMarketFee,
exchangeId, exchangeId,
this.web3.utils.toWei(newMarketFee) this.web3.utils.toWei(newMarketFee)
@ -783,6 +796,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.updateMarketFeeCollector, this.contract.methods.updateMarketFeeCollector,
exchangeId, exchangeId,
newMarketFeeCollector newMarketFeeCollector

View File

@ -35,6 +35,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.buyDTBatch, this.contract.methods.buyDTBatch,
operations operations
) )
@ -110,6 +111,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.addApprovedToken, this.contract.methods.addApprovedToken,
tokenAddress tokenAddress
) )
@ -143,6 +145,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.removeApprovedToken, this.contract.methods.removeApprovedToken,
tokenAddress tokenAddress
) )
@ -175,6 +178,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.addSSContract, this.contract.methods.addSSContract,
tokenAddress tokenAddress
) )
@ -207,6 +211,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.removeSSContract, this.contract.methods.removeSSContract,
tokenAddress tokenAddress
) )
@ -239,6 +244,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.addFixedRateContract, this.contract.methods.addFixedRateContract,
tokenAddress tokenAddress
) )
@ -272,6 +278,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.removeFixedRateContract, this.contract.methods.removeFixedRateContract,
tokenAddress tokenAddress
) )
@ -305,6 +312,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.addDispenserContract, this.contract.methods.addDispenserContract,
tokenAddress tokenAddress
) )
@ -337,6 +345,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.removeDispenserContract, this.contract.methods.removeDispenserContract,
tokenAddress tokenAddress
) )
@ -392,6 +401,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.updateOPCFee, this.contract.methods.updateOPCFee,
newSwapOceanFee, newSwapOceanFee,
newSwapNonOceanFee, newSwapNonOceanFee,
@ -428,6 +438,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.addPoolTemplate, this.contract.methods.addPoolTemplate,
templateAddress templateAddress
) )
@ -461,6 +472,7 @@ export class Router extends SmartContractWithAddress {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
this.contract.methods.removePoolTemplate, this.contract.methods.removePoolTemplate,
templateAddress templateAddress
) )

View File

@ -73,6 +73,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.approve, dtContract.methods.approve,
spender, spender,
this.web3.utils.toWei(amount) this.web3.utils.toWei(amount)
@ -128,6 +129,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.createFixedRate, dtContract.methods.createFixedRate,
fixedRateParams.fixedRateAddress, fixedRateParams.fixedRateAddress,
[ [
@ -189,6 +191,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.createDispenser, dtContract.methods.createDispenser,
dispenserAddress, dispenserAddress,
dispenserParams.maxTokens, dispenserParams.maxTokens,
@ -275,6 +278,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.addMinter, dtContract.methods.addMinter,
minter minter
) )
@ -314,6 +318,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.removeMinter, dtContract.methods.removeMinter,
minter minter
) )
@ -352,6 +357,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.addPaymentManager, dtContract.methods.addPaymentManager,
paymentManager paymentManager
) )
@ -390,6 +396,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.removePaymentManager, dtContract.methods.removePaymentManager,
paymentManager paymentManager
) )
@ -435,6 +442,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.setPaymentCollector, dtContract.methods.setPaymentCollector,
paymentCollector paymentCollector
) )
@ -498,6 +506,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.transfer, dtContract.methods.transfer,
toAddress, toAddress,
amount amount
@ -546,6 +555,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.startOrder, dtContract.methods.startOrder,
consumer, consumer,
serviceIndex, serviceIndex,
@ -585,6 +595,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.reuseOrder, dtContract.methods.reuseOrder,
orderTxId, orderTxId,
providerFees providerFees
@ -622,6 +633,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.buyFromFreAndOrder, dtContract.methods.buyFromFreAndOrder,
orderParams, orderParams,
freContractParams freContractParams
@ -657,6 +669,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.buyFromDispenserAndOrder, dtContract.methods.buyFromDispenserAndOrder,
orderParams, orderParams,
dispenserContract dispenserContract
@ -691,6 +704,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.setData, dtContract.methods.setData,
value value
) )
@ -725,6 +739,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.cleanPermissions dtContract.methods.cleanPermissions
) )
@ -834,6 +849,7 @@ export class Datatoken extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
dtContract.methods.setPublishingMarketFee, dtContract.methods.setPublishingMarketFee,
publishMarketFeeAddress, publishMarketFeeAddress,
publishMarketFeeToken, publishMarketFeeToken,

View File

@ -67,6 +67,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.createERC20, nftContract.methods.createERC20,
templateIndex, templateIndex,
[name, symbol], [name, symbol],
@ -108,6 +109,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.addManager, nftContract.methods.addManager,
manager manager
) )
@ -145,6 +147,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.removeManager, nftContract.methods.removeManager,
manager manager
) )
@ -183,6 +186,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.addToCreateERC20List, nftContract.methods.addToCreateERC20List,
datatokenDeployer datatokenDeployer
) )
@ -223,6 +227,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.removeFromCreateERC20List, nftContract.methods.removeFromCreateERC20List,
datatokenDeployer datatokenDeployer
) )
@ -260,6 +265,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.addToMetadataList, nftContract.methods.addToMetadataList,
metadataUpdater metadataUpdater
) )
@ -300,6 +306,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.removeFromMetadataList, nftContract.methods.removeFromMetadataList,
metadataUpdater metadataUpdater
) )
@ -336,6 +343,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.addTo725StoreList, nftContract.methods.addTo725StoreList,
storeUpdater storeUpdater
) )
@ -377,6 +385,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.removeFrom725StoreList, nftContract.methods.removeFrom725StoreList,
storeUpdater storeUpdater
) )
@ -414,6 +423,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.cleanPermissions nftContract.methods.cleanPermissions
) )
@ -457,6 +467,7 @@ export class Nft extends SmartContract {
nftOwner, nftOwner,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.transferFrom, nftContract.methods.transferFrom,
nftOwner, nftOwner,
nftReceiver, nftReceiver,
@ -503,6 +514,7 @@ export class Nft extends SmartContract {
nftOwner, nftOwner,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.safeTransferFrom, nftContract.methods.safeTransferFrom,
nftOwner, nftOwner,
nftReceiver, nftReceiver,
@ -553,6 +565,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.setMetaData, nftContract.methods.setMetaData,
metadataState, metadataState,
metadataDecryptorUrl, metadataDecryptorUrl,
@ -598,6 +611,7 @@ export class Nft extends SmartContract {
metadataUpdater, metadataUpdater,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.setMetaDataAndTokenURI, nftContract.methods.setMetaDataAndTokenURI,
sanitizedMetadataAndTokenURI sanitizedMetadataAndTokenURI
) )
@ -635,6 +649,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.setMetaDataState, nftContract.methods.setMetaDataState,
metadataState metadataState
) )
@ -667,6 +682,7 @@ export class Nft extends SmartContract {
address, address,
estGas + 1, estGas + 1,
this.web3, this.web3,
this.config,
nftContract.methods.setTokenURI, nftContract.methods.setTokenURI,
'1', '1',
data data

View File

@ -109,6 +109,7 @@ export async function sendTx(
from: string, from: string,
estGas: any, estGas: any,
web3: Web3, web3: Web3,
config: Config,
functionToSend: Function, functionToSend: Function,
...args: any[] ...args: any[]
): Promise<any> { ): Promise<any> {
@ -128,7 +129,7 @@ export async function sendTx(
.toString(10) .toString(10)
} catch (err) { } catch (err) {
LoggerInstance.log('EIP 1559 not supported by network') LoggerInstance.log('EIP 1559 not supported by network')
sendTxValue.gasPrice = await this.getFairGasPrice() sendTxValue.gasPrice = await getFairGasPrice(web3, config)
} }
const trxReceipt = await functionToSend.apply(null, args).send(sendTxValue) const trxReceipt = await functionToSend.apply(null, args).send(sendTxValue)