Skip to content

Commit

Permalink
Added minimum gas fees for sapphire networks. Send function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacarmina committed Sep 3, 2024
1 parent 243cadb commit 8cfbeae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/contracts/Datatoken4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class Datatoken4 extends Datatoken {
estGas,
this.signer,
this.config?.gasFeeMultiplier,
dtContract.setAllowListContract,
dtContract.functions.setAllowListContract,
address
)

Expand Down Expand Up @@ -119,7 +119,7 @@ export class Datatoken4 extends Datatoken {
estGas,
this.signer,
this.config?.gasFeeMultiplier,
dtContract.setDenyListContract,
dtContract.functions.setDenyListContract,
address
)

Expand All @@ -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
)

Expand Down
11 changes: 11 additions & 0 deletions src/utils/ContractUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 {
Expand Down

0 comments on commit 8cfbeae

Please sign in to comment.