Skip to content

Commit

Permalink
Merge pull request #49 from etherspot/l2-gas-fees
Browse files Browse the repository at this point in the history
change docs & set query limit on read receipt & set mumbai gas oracle
  • Loading branch information
0xSulpiride authored Jul 11, 2023
2 parents 89b7f6c + 269b09b commit a88440b
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.13",
"version": "0.0.14",
"stream": "true",
"command": {
"version": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "root",
"private": true,
"version": "0.0.13",
"version": "0.0.14",
"engines": {
"node": ">=18.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "0.0.13",
"version": "0.0.14",
"description": "The API module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -35,12 +35,12 @@
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
"ethers": "5.7.2",
"executor": "^0.0.13",
"executor": "^0.0.14",
"fastify": "4.14.1",
"pino": "8.11.0",
"pino-pretty": "10.0.0",
"reflect-metadata": "0.1.13",
"types": "^0.0.13"
"types": "^0.0.14"
},
"devDependencies": {
"@types/connect": "3.4.35"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Server {

setup(): void {
this.app.get("*", () => {
return "GET requests are not supported. Visit https://docs.etherspot.io/etherspot-skandha-bundler";
return "GET requests are not supported. Visit https://skandha.fyi";
});
}

Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli",
"version": "0.0.13",
"version": "0.0.14",
"description": "> TODO: description",
"author": "zincoshine <[email protected]>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -31,13 +31,13 @@
"url": "https://https://github.com/etherspot/skandha/issues"
},
"dependencies": {
"api": "^0.0.13",
"db": "^0.0.13",
"executor": "^0.0.13",
"api": "^0.0.14",
"db": "^0.0.14",
"executor": "^0.0.14",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
"types": "^0.0.13",
"types": "^0.0.14",
"yargs": "17.6.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "db",
"version": "0.0.13",
"version": "0.0.14",
"description": "The DB module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
Expand Down Expand Up @@ -37,6 +37,6 @@
"devDependencies": {
"@types/rocksdb": "3.0.1",
"prettier": "^2.8.4",
"types": "^0.0.13"
"types": "^0.0.14"
}
}
6 changes: 3 additions & 3 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "executor",
"version": "0.0.13",
"version": "0.0.14",
"description": "The Relayer module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"params": "^0.0.13",
"types": "^0.0.13"
"params": "^0.0.14",
"types": "^0.0.14"
}
}
10 changes: 9 additions & 1 deletion packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,16 @@ export class Eth {
for (const addr of await this.getSupportedEntryPoints()) {
const contract = EntryPoint__factory.connect(addr, this.provider);
try {
const blockNumber = await this.provider.getBlockNumber();
let fromBlockNumber = blockNumber - 15000; // limit query to 15k blocks, otherwise it throw timeout error
// underflow check
if (fromBlockNumber < 0) {
fromBlockNumber = blockNumber;
}

event = await contract.queryFilter(
contract.filters.UserOperationEvent(userOpHash)
contract.filters.UserOperationEvent(userOpHash),
fromBlockNumber
);
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (event[0]) {
Expand Down
21 changes: 20 additions & 1 deletion packages/executor/src/utils/getGasFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ export const getGasFee = async (

if (network === "optimism") {
try {
return getOptimismGasFee();
return await getOptimismGasFee();
} catch (err) {
// eslint-disable-next-line no-console
console.error(`Couldn't fetch fee data for optimism: ${err}`);
}
}

if (network === "mumbai") {
try {
return await getMumbaiGasFee();
} catch (err) {
// eslint-disable-next-line no-console
console.error(`Couldn't fetch fee data for mumbai: ${err}`);
}
}

try {
const feeData = await provider.getFeeData();
return {
Expand Down Expand Up @@ -65,6 +74,16 @@ export const getMaticGasFee = async (): Promise<IGetGasFeeResult> => {
};
};

export const getMumbaiGasFee = async (): Promise<IGetGasFeeResult> => {
const oracle = "https://gasstation-testnet.polygon.technology/v2";
const data = await (await fetch(oracle)).json();
return {
maxPriorityFeePerGas: parseGwei(data.fast.maxPriorityFee),
maxFeePerGas: parseGwei(data.fast.maxFee),
gasPrice: parseGwei(data.fast.maxFee),
};
};

export const getEtherscanGasFee = async (
apiUrl: string,
apiKey: string | undefined = undefined
Expand Down
4 changes: 2 additions & 2 deletions packages/params/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "params",
"version": "0.0.13",
"version": "0.0.14",
"description": "Various bundler parameters",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/skandha#readme",
Expand All @@ -24,7 +24,7 @@
"@arbitrum/sdk": "3.1.4",
"@eth-optimism/sdk": "3.0.0",
"ethers": "5.7.2",
"types": "^0.0.13"
"types": "^0.0.14"
},
"scripts": {
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
Expand Down
7 changes: 7 additions & 0 deletions packages/params/src/types/IGetL1Cost.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BigNumber, providers } from "ethers";

export type IGetL1GasPriceWrapper = (
provider: providers.StaticJsonRpcProvider
) => IGetL1GasPrice;

export type IGetL1GasPrice = () => Promise<BigNumber>;
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "types",
"version": "0.0.13",
"version": "0.0.14",
"description": "The types of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down

0 comments on commit a88440b

Please sign in to comment.