Skip to content

Commit 85019e1

Browse files
[GMS-1265] Add default gas overrides (#140)
* add default gas overrides * remove * udpate gas config --------- Co-authored-by: Allan Almeida <[email protected]>
1 parent 720ed7d commit 85019e1

File tree

4 files changed

+187
-120
lines changed

4 files changed

+187
-120
lines changed

clients/config/overrides.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { CallOverrides } from "@ethersproject/contracts";
2+
3+
// https://docs.immutable.com/docs/zkEVM/architecture/gas-config
4+
export const defaultGasOverrides: CallOverrides = {
5+
maxPriorityFeePerGas: 10e9, // 10 Gwei
6+
maxFeePerGas: 15e9,
7+
};

clients/erc20.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CallOverrides, PopulatedTransaction } from "@ethersproject/contracts";
66
import { ERC20 } from "../typechain-types/@openzeppelin/contracts/token/ERC20";
77
import { ERC20__factory } from "../typechain-types/factories/@openzeppelin/contracts/token/ERC20/ERC20__factory";
88
import { PromiseOrValue } from "../typechain-types/common";
9+
import { defaultGasOverrides } from "./config/overrides";
910

1011
export class ERC20Client {
1112
private readonly contract: ERC20;
@@ -19,7 +20,7 @@ export class ERC20Client {
1920
* @returns a promise that resolves with a BigNumber that represents the amount of tokens in existence
2021
*/
2122
public async totalSupply(provider: Provider, overrides: CallOverrides = {}): Promise<BigNumber> {
22-
return this.contract.connect(provider).totalSupply(overrides);
23+
return this.contract.connect(provider).totalSupply({ ...defaultGasOverrides, ...overrides });
2324
}
2425

2526
/**
@@ -30,7 +31,7 @@ export class ERC20Client {
3031
account: PromiseOrValue<string>,
3132
overrides: CallOverrides = {}
3233
): Promise<BigNumber> {
33-
return this.contract.connect(provider).balanceOf(account, overrides);
34+
return this.contract.connect(provider).balanceOf(account, { ...defaultGasOverrides, ...overrides });
3435
}
3536

3637
/**
@@ -42,7 +43,7 @@ export class ERC20Client {
4243
spender: PromiseOrValue<string>,
4344
overrides: CallOverrides = {}
4445
): Promise<BigNumber> {
45-
return this.contract.connect(provider).allowance(owner, spender, overrides);
46+
return this.contract.connect(provider).allowance(owner, spender, { ...defaultGasOverrides, ...overrides });
4647
}
4748

4849
/**
@@ -53,7 +54,7 @@ export class ERC20Client {
5354
amount: PromiseOrValue<BigNumberish>,
5455
overrides: Overrides & { from?: PromiseOrValue<string> } = {}
5556
): Promise<PopulatedTransaction> {
56-
return this.contract.populateTransaction.transfer(to, amount, overrides);
57+
return this.contract.populateTransaction.transfer(to, amount, { ...defaultGasOverrides, ...overrides });
5758
}
5859

5960
/**
@@ -64,7 +65,7 @@ export class ERC20Client {
6465
amount: PromiseOrValue<BigNumberish>,
6566
overrides: Overrides & { from?: PromiseOrValue<string> } = {}
6667
): Promise<PopulatedTransaction> {
67-
return this.contract.populateTransaction.approve(spender, amount, overrides);
68+
return this.contract.populateTransaction.approve(spender, amount, { ...defaultGasOverrides, ...overrides });
6869
}
6970

7071
/**
@@ -76,6 +77,6 @@ export class ERC20Client {
7677
amount: PromiseOrValue<BigNumberish>,
7778
overrides: Overrides & { from?: PromiseOrValue<string> } = {}
7879
): Promise<PopulatedTransaction> {
79-
return this.contract.populateTransaction.transferFrom(from, to, amount, overrides);
80+
return this.contract.populateTransaction.transferFrom(from, to, amount, { ...defaultGasOverrides, ...overrides });
8081
}
8182
}

0 commit comments

Comments
 (0)