Skip to content

Commit 3269d7e

Browse files
authored
Merge pull request #46 from etherspot/optimism-etherscan-gas-fee
feat: use etherscan for optimism gas fees
2 parents 2e5559f + ad6cee4 commit 3269d7e

9 files changed

Lines changed: 48 additions & 18 deletions

File tree

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"npmClient": "yarn",
66
"useWorkspaces": true,
7-
"version": "0.0.10",
7+
"version": "0.0.11",
88
"stream": "true",
99
"command": {
1010
"version": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "root",
33
"private": true,
4-
"version": "0.0.10",
4+
"version": "0.0.11",
55
"engines": {
66
"node": ">=18.0.0"
77
},

packages/api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "The API module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -35,12 +35,12 @@
3535
"class-transformer": "0.5.1",
3636
"class-validator": "0.14.0",
3737
"ethers": "5.7.2",
38-
"executor": "^0.0.10",
38+
"executor": "^0.0.11",
3939
"fastify": "4.14.1",
4040
"pino": "8.11.0",
4141
"pino-pretty": "10.0.0",
4242
"reflect-metadata": "0.1.13",
43-
"types": "^0.0.10"
43+
"types": "^0.0.11"
4444
},
4545
"devDependencies": {
4646
"@types/connect": "3.4.35"

packages/cli/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cli",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "> TODO: description",
55
"author": "zincoshine <psramanuj@gmail.com>",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -31,13 +31,13 @@
3131
"url": "https://https://github.com/etherspot/skandha/issues"
3232
},
3333
"dependencies": {
34-
"api": "^0.0.10",
35-
"db": "^0.0.10",
36-
"executor": "^0.0.10",
34+
"api": "^0.0.11",
35+
"db": "^0.0.11",
36+
"executor": "^0.0.11",
3737
"find-up": "5.0.0",
3838
"got": "12.5.3",
3939
"js-yaml": "4.1.0",
40-
"types": "^0.0.10",
40+
"types": "^0.0.11",
4141
"yargs": "17.6.2"
4242
},
4343
"devDependencies": {

packages/db/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "db",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "The DB module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
@@ -37,6 +37,6 @@
3737
"devDependencies": {
3838
"@types/rocksdb": "3.0.1",
3939
"prettier": "^2.8.4",
40-
"types": "^0.0.10"
40+
"types": "^0.0.11"
4141
}
4242
}

packages/executor/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "executor",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "The Relayer module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -33,7 +33,7 @@
3333
"dependencies": {
3434
"async-mutex": "0.4.0",
3535
"ethers": "5.7.2",
36-
"params": "^0.0.10",
37-
"types": "^0.0.10"
36+
"params": "^0.0.11",
37+
"types": "^0.0.11"
3838
}
3939
}

packages/executor/src/utils/getGasFee.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ export const getGasFee = async (
1919
console.error(`Couldn't fetch fee data for matic: ${err}`);
2020
}
2121
}
22+
23+
if (network === "optimism") {
24+
try {
25+
return getOptimismGasFee();
26+
} catch (err) {
27+
// eslint-disable-next-line no-console
28+
console.error(`Couldn't fetch fee data for optimism: ${err}`);
29+
}
30+
}
31+
2232
try {
2333
const feeData = await provider.getFeeData();
2434
return {
@@ -51,3 +61,23 @@ export const getMaticGasFee = async (): Promise<IGetGasFeeResult> => {
5161
gasPrice: parseGwei(data.fast.maxFee),
5262
};
5363
};
64+
65+
export const getEtherscanGasFee = async (
66+
apiUrl: string,
67+
apiKey: string | undefined = undefined
68+
): Promise<IGetGasFeeResult> => {
69+
let oracle = `${apiUrl}?module=proxy&action=eth_gasPrice`;
70+
if (apiKey) {
71+
oracle += `&apikey=${apiKey}`;
72+
}
73+
const data = await (await fetch(oracle)).json();
74+
const gasPrice = ethers.BigNumber.from(data.result);
75+
return {
76+
maxPriorityFeePerGas: gasPrice,
77+
maxFeePerGas: gasPrice,
78+
gasPrice: gasPrice,
79+
};
80+
};
81+
82+
export const getOptimismGasFee = (): Promise<IGetGasFeeResult> =>
83+
getEtherscanGasFee("https://api-optimistic.etherscan.io/api");

packages/params/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "params",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "Various bundler parameters",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/skandha#readme",
@@ -24,7 +24,7 @@
2424
"@arbitrum/sdk": "3.1.4",
2525
"@eth-optimism/sdk": "3.0.0",
2626
"ethers": "5.7.2",
27-
"types": "^0.0.10"
27+
"types": "^0.0.11"
2828
},
2929
"scripts": {
3030
"clean": "rm -rf lib && rm -f *.tsbuildinfo",

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "types",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "The types of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",

0 commit comments

Comments
 (0)