From 9fb047534935b0600bd08a4de7e68fd91a8a089a Mon Sep 17 00:00:00 2001 From: amanraj1608 Date: Wed, 13 Sep 2023 13:53:02 -0400 Subject: [PATCH] fix: build errors --- packages/account/package.json | 3 ++- packages/account/src/BaseSmartAccount.ts | 29 ++++++++---------------- packages/core-types/package.json | 2 +- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/packages/account/package.json b/packages/account/package.json index d959ab3d8..55a5f7252 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -43,6 +43,7 @@ "@biconomy/modules": "^3.1.1-alpha.0", "@biconomy/node-client": "^3.1.1-alpha.0", "@biconomy/paymaster": "^3.1.1-alpha.0", - "ethers": "^5.7.0" + "ethers": "^5.7.0", + "@ethersproject/providers": "^5.7.2" } } diff --git a/packages/account/src/BaseSmartAccount.ts b/packages/account/src/BaseSmartAccount.ts index 77c2e3d08..dcec3f76f 100644 --- a/packages/account/src/BaseSmartAccount.ts +++ b/packages/account/src/BaseSmartAccount.ts @@ -1,21 +1,16 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-nocheck - import { JsonRpcProvider, Provider } from "@ethersproject/providers"; -import { BigNumber, BigNumberish, Signer, BytesLike, ethers, Bytes } from "ethers"; +import { BigNumber, BigNumberish, BytesLike, ethers, Bytes } from "ethers"; import { IBaseSmartAccount } from "./interfaces/IBaseSmartAccount"; -import { defaultAbiCoder, keccak256, arrayify, Result } from "ethers/lib/utils"; +import { defaultAbiCoder, keccak256 } from "ethers/lib/utils"; import { UserOperation, ChainId } from "@biconomy/core-types"; import { calcPreVerificationGas, DefaultGasLimits } from "./utils/Preverificaiton"; -import { NotPromise, packUserOp } from "@biconomy/common"; +import { NotPromise, packUserOp, Logger, RPC_PROVIDER_URLS } from "@biconomy/common"; import { IBundler, UserOpResponse } from "@biconomy/bundler"; import { IPaymaster, PaymasterAndDataResponse } from "@biconomy/paymaster"; -import { EntryPoint_v005, Logger } from "@biconomy/common"; import { BaseSmartAccountConfig, Overrides, TransactionDetailsForUserOp } from "./utils/Types"; import { GasOverheads } from "./utils/Preverificaiton"; import { EntryPoint, EntryPoint__factory } from "@account-abstraction/contracts"; import { DEFAULT_ENTRYPOINT_ADDRESS } from "./utils/Constants"; -import { RPC_PROVIDER_URLS } from "@biconomy/common"; type UserOperationKey = keyof UserOperation; @@ -275,6 +270,7 @@ export abstract class BaseSmartAccount implements IBaseSmartAccount { // Making call to bundler to get gas estimations for userOp const { callGasLimit, verificationGasLimit, preVerificationGas, maxFeePerGas, maxPriorityFeePerGas } = await this.bundler.estimateUserOpGas(userOp); + // if neither user sent gas fee nor the bundler, estimate gas from provider if (!userOp.maxFeePerGas && !userOp.maxPriorityFeePerGas && (!maxFeePerGas || !maxPriorityFeePerGas)) { const feeData = await this.provider.getFeeData(); finalUserOp.maxFeePerGas = feeData.maxFeePerGas ?? feeData.gasPrice ?? (await this.provider.getGasPrice()); @@ -302,22 +298,17 @@ export abstract class BaseSmartAccount implements IBaseSmartAccount { // Review : usage trace of this method. in the order of init and methods called on the Account async isAccountDeployed(address: string): Promise { this.isProviderDefined(); - let contractCode; if (this.isDeployed !== undefined || this.isDeployed !== null) { // already deployed. no need to check anymore. return this.isDeployed; } - try { - contractCode = await this.provider.getCode(address); - if (contractCode.length > 2) { - this.isDeployed = true; - } else { - this.isDeployed = false; - } - return this.isDeployed; - } catch (error) { - throw error; + const contractCode = await this.provider.getCode(address); + if (contractCode.length > 2) { + this.isDeployed = true; + } else { + this.isDeployed = false; } + return this.isDeployed; } /** diff --git a/packages/core-types/package.json b/packages/core-types/package.json index 6f0a60c9e..048d14207 100644 --- a/packages/core-types/package.json +++ b/packages/core-types/package.json @@ -39,7 +39,7 @@ "@ethersproject/bignumber": "^5.6.0", "@ethersproject/contracts": "^5.6.0", "@ethersproject/providers": "^5.7.0", - "ethers": "^6.7.1", + "ethers": "^5.7.2", "web3-core": "^1.7.1" } }