From 3d57a27149fcbe774947bac85827dd17550b457a Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Tue, 4 Jul 2023 19:04:43 +0500 Subject: [PATCH 1/3] feat: use etherscan for optimism gas fees --- packages/executor/src/utils/getGasFee.ts | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/executor/src/utils/getGasFee.ts b/packages/executor/src/utils/getGasFee.ts index 47d4f636..3de019bb 100644 --- a/packages/executor/src/utils/getGasFee.ts +++ b/packages/executor/src/utils/getGasFee.ts @@ -19,6 +19,16 @@ export const getGasFee = async ( console.error(`Couldn't fetch fee data for matic: ${err}`); } } + + if (network === "optimism") { + try { + return getOptimismGasFee(); + } catch (err) { + // eslint-disable-next-line no-console + console.error(`Couldn't fetch fee data for optimism: ${err}`); + } + } + try { const feeData = await provider.getFeeData(); return { @@ -51,3 +61,23 @@ export const getMaticGasFee = async (): Promise => { gasPrice: parseGwei(data.fast.maxFee), }; }; + +export const getEtherscanGasFee = async ( + apiUrl: string, + apiKey: string | undefined = undefined +): Promise => { + const oracle = + `${apiUrl}?module=proxy&action=eth_gasPrice` + apiKey + ? "" + : `&apikey=${apiKey}`; + const data = await (await fetch(oracle)).json(); + const gasPrice = ethers.BigNumber.from(data.result); + return { + maxPriorityFeePerGas: gasPrice, + maxFeePerGas: gasPrice, + gasPrice: gasPrice, + }; +}; + +export const getOptimismGasFee = (): Promise => + getEtherscanGasFee("https://api-optimistic.etherscan.io/api"); From d9ad461e3744b2b58cf8dd43421737d05f8df86c Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Tue, 4 Jul 2023 19:11:39 +0500 Subject: [PATCH 2/3] fix --- packages/executor/src/utils/getGasFee.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/executor/src/utils/getGasFee.ts b/packages/executor/src/utils/getGasFee.ts index 3de019bb..f8590aad 100644 --- a/packages/executor/src/utils/getGasFee.ts +++ b/packages/executor/src/utils/getGasFee.ts @@ -66,10 +66,10 @@ export const getEtherscanGasFee = async ( apiUrl: string, apiKey: string | undefined = undefined ): Promise => { - const oracle = - `${apiUrl}?module=proxy&action=eth_gasPrice` + apiKey - ? "" - : `&apikey=${apiKey}`; + let oracle = `${apiUrl}?module=proxy&action=eth_gasPrice`; + if (apiKey) { + oracle += `&apikey=${apiKey}`; + } const data = await (await fetch(oracle)).json(); const gasPrice = ethers.BigNumber.from(data.result); return { From ad6cee4700fc3c174df1d437b1c11895e0a4f452 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Tue, 4 Jul 2023 19:15:02 +0500 Subject: [PATCH 3/3] chore(release): v0.0.11 --- lerna.json | 2 +- package.json | 2 +- packages/api/package.json | 6 +++--- packages/cli/package.json | 10 +++++----- packages/db/package.json | 4 ++-- packages/executor/package.json | 6 +++--- packages/params/package.json | 4 ++-- packages/types/package.json | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lerna.json b/lerna.json index e8385498..88b00e27 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "0.0.10", + "version": "0.0.11", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index 12abacc7..285537a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "0.0.10", + "version": "0.0.11", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index b9bcf528..a3717e3e 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "0.0.10", + "version": "0.0.11", "description": "The API module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -35,12 +35,12 @@ "class-transformer": "0.5.1", "class-validator": "0.14.0", "ethers": "5.7.2", - "executor": "^0.0.10", + "executor": "^0.0.11", "fastify": "4.14.1", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^0.0.10" + "types": "^0.0.11" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index c6b90f55..c3d828ed 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "0.0.10", + "version": "0.0.11", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -31,13 +31,13 @@ "url": "https://https://github.com/etherspot/skandha/issues" }, "dependencies": { - "api": "^0.0.10", - "db": "^0.0.10", - "executor": "^0.0.10", + "api": "^0.0.11", + "db": "^0.0.11", + "executor": "^0.0.11", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "types": "^0.0.10", + "types": "^0.0.11", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index 411d91f5..df40a7de 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "0.0.10", + "version": "0.0.11", "description": "The DB module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -37,6 +37,6 @@ "devDependencies": { "@types/rocksdb": "3.0.1", "prettier": "^2.8.4", - "types": "^0.0.10" + "types": "^0.0.11" } } diff --git a/packages/executor/package.json b/packages/executor/package.json index d2b2507d..8a5065c6 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "0.0.10", + "version": "0.0.11", "description": "The Relayer module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -33,7 +33,7 @@ "dependencies": { "async-mutex": "0.4.0", "ethers": "5.7.2", - "params": "^0.0.10", - "types": "^0.0.10" + "params": "^0.0.11", + "types": "^0.0.11" } } diff --git a/packages/params/package.json b/packages/params/package.json index 55fde10b..592d9e04 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "0.0.10", + "version": "0.0.11", "description": "Various bundler parameters", "author": "Etherspot", "homepage": "https://github.com/etherspot/skandha#readme", @@ -24,7 +24,7 @@ "@arbitrum/sdk": "3.1.4", "@eth-optimism/sdk": "3.0.0", "ethers": "5.7.2", - "types": "^0.0.10" + "types": "^0.0.11" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/types/package.json b/packages/types/package.json index 66d34a01..a829fabb 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "0.0.10", + "version": "0.0.11", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme",