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:
parent
243cadb212
commit
8cfbeae0ce
@ -85,7 +85,7 @@ export class Datatoken4 extends Datatoken {
|
|||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.signer,
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.setAllowListContract,
|
dtContract.functions.setAllowListContract,
|
||||||
address
|
address
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ export class Datatoken4 extends Datatoken {
|
|||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.signer,
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.setDenyListContract,
|
dtContract.functions.setDenyListContract,
|
||||||
address
|
address
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -144,14 +144,14 @@ export class Datatoken4 extends Datatoken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dtContract = this.getContract(dtAddress)
|
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
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.signer,
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.setFileObject,
|
dtContract.functions.setFilesObject,
|
||||||
fileObject
|
fileObject
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -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_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_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 POLYGON_NETWORK_ID = 137
|
||||||
const MUMBAI_NETWORK_ID = 80001
|
const MUMBAI_NETWORK_ID = 80001
|
||||||
const SEPOLIA_NETWORK_ID = 11155111
|
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 {
|
export function setContractDefaults(contract: Contract, config: Config): Contract {
|
||||||
// TO DO - since ethers does not provide this
|
// TO DO - since ethers does not provide this
|
||||||
@ -139,6 +142,10 @@ export async function sendTx(
|
|||||||
: chainId === SEPOLIA_NETWORK_ID &&
|
: chainId === SEPOLIA_NETWORK_ID &&
|
||||||
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
||||||
? 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),
|
: Number(aggressiveFeePriorityFeePerGas),
|
||||||
|
|
||||||
maxFeePerGas:
|
maxFeePerGas:
|
||||||
@ -148,6 +155,10 @@ export async function sendTx(
|
|||||||
: chainId === SEPOLIA_NETWORK_ID &&
|
: chainId === SEPOLIA_NETWORK_ID &&
|
||||||
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
||||||
? 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)
|
: Number(aggressiveFeePerGas)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user