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

Added minimum gas fees for sapphire networks. Send function.

This commit is contained in:
mariacarmina 2024-09-03 13:49:44 +03:00
parent 243cadb212
commit 8cfbeae0ce
2 changed files with 15 additions and 4 deletions

View File

@ -85,7 +85,7 @@ export class Datatoken4 extends Datatoken {
estGas,
this.signer,
this.config?.gasFeeMultiplier,
dtContract.setAllowListContract,
dtContract.functions.setAllowListContract,
address
)
@ -119,7 +119,7 @@ export class Datatoken4 extends Datatoken {
estGas,
this.signer,
this.config?.gasFeeMultiplier,
dtContract.setDenyListContract,
dtContract.functions.setDenyListContract,
address
)
@ -144,14 +144,14 @@ export class Datatoken4 extends Datatoken {
}
const dtContract = this.getContract(dtAddress)
const estGas = await dtContract.estimateGas.setFileObject(fileObject)
const estGas = await dtContract.estimateGas.setFilesObject(fileObject)
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
const trxReceipt = await sendTx(
estGas,
this.signer,
this.config?.gasFeeMultiplier,
dtContract.setFileObject,
dtContract.functions.setFilesObject,
fileObject
)

View File

@ -5,9 +5,12 @@ import { LoggerInstance, minAbi } from '.'
const MIN_GAS_FEE_POLYGON = 30000000000 // minimum recommended 30 gwei polygon main and mumbai fees
const MIN_GAS_FEE_SEPOLIA = 4000000000 // minimum 4 gwei for eth sepolia testnet
const MIN_GAS_FEE_SAPPHIRE = 10000000000 // recommended for mainnet and testnet 10 gwei
const POLYGON_NETWORK_ID = 137
const MUMBAI_NETWORK_ID = 80001
const SEPOLIA_NETWORK_ID = 11155111
const SAPPHIRE_TESTNET_NETWORK_ID = 23295
const SAPPHIRE_MAINNET_NETWORK_ID = 23294
export function setContractDefaults(contract: Contract, config: Config): Contract {
// TO DO - since ethers does not provide this
@ -139,6 +142,10 @@ export async function sendTx(
: chainId === SEPOLIA_NETWORK_ID &&
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
? MIN_GAS_FEE_SEPOLIA
: (chainId === SAPPHIRE_MAINNET_NETWORK_ID ||
chainId === SAPPHIRE_TESTNET_NETWORK_ID) &&
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SAPPHIRE
? MIN_GAS_FEE_SAPPHIRE
: Number(aggressiveFeePriorityFeePerGas),
maxFeePerGas:
@ -148,6 +155,10 @@ export async function sendTx(
: chainId === SEPOLIA_NETWORK_ID &&
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
? MIN_GAS_FEE_SEPOLIA
: (chainId === SAPPHIRE_MAINNET_NETWORK_ID ||
chainId === SAPPHIRE_TESTNET_NETWORK_ID) &&
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SAPPHIRE
? MIN_GAS_FEE_SAPPHIRE
: Number(aggressiveFeePerGas)
}
} else {