Skip to content

Commit

Permalink
fix: lint warning and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AmanRaj1608 committed Sep 13, 2023
1 parent 9fb0475 commit 2135498
Show file tree
Hide file tree
Showing 23 changed files with 94 additions and 117 deletions.
10 changes: 5 additions & 5 deletions packages/account/src/BaseSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export abstract class BaseSmartAccount implements IBaseSmartAccount {
return this;
}

setEntryPointAddress(entryPointAddress: string) {
setEntryPointAddress(entryPointAddress: string): void {
this.entryPointAddress = entryPointAddress;
}

Expand Down Expand Up @@ -108,23 +108,23 @@ export abstract class BaseSmartAccount implements IBaseSmartAccount {
* @param value
* @param data
*/
abstract encodeExecute(to: string, value: BigNumberish, data: BytesLike): Promise<string>;
abstract encodeExecute(_to: string, _value: BigNumberish, _data: BytesLike): Promise<string>;

/**
* encode the batch call from entryPoint through our account to the target contract.
* @param to
* @param value
* @param data
*/
abstract encodeExecuteBatch(to: Array<string>, value: Array<BigNumberish>, data: Array<BytesLike>): Promise<string>;
abstract encodeExecuteBatch(_to: Array<string>, _value: Array<BigNumberish>, _data: Array<BytesLike>): Promise<string>;

/**
* sign a userOp's hash (userOpHash).
* @param userOpHash
*/
abstract signUserOpHash(userOpHash: string): Promise<string>;
abstract signUserOpHash(_userOpHash: string): Promise<string>;

abstract signMessage(message: Bytes | string): Promise<string>;
abstract signMessage(_message: Bytes | string): Promise<string>;

/**
* get dummy signature for userOp
Expand Down
8 changes: 4 additions & 4 deletions packages/account/src/BiconomySmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class BiconomySmartAccount extends SmartAccount implements IBiconomySmart
return true;
}

private setProxyContractState() {
private setProxyContractState(): void {
if (!BICONOMY_IMPLEMENTATION_ADDRESSES[this.smartAccountInfo.implementationAddress])
throw new Error(
"Could not find attached implementation address against your smart account. Please raise an issue on https://github.com/bcnmy/biconomy-client-sdk for further investigation.",
Expand All @@ -133,7 +133,7 @@ export class BiconomySmartAccount extends SmartAccount implements IBiconomySmart
this.proxy = getSAProxyContract(proxyInstanceDto);
}

private setEntryPointContractState() {
private setEntryPointContractState(): void {
const _entryPointAddress = this.smartAccountInfo.entryPointAddress;
this.setEntryPointAddress(_entryPointAddress);
if (!ENTRYPOINT_ADDRESSES[_entryPointAddress])

Check warning on line 139 in packages/account/src/BiconomySmartAccount.ts

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Generic Object Injection Sink
Expand All @@ -149,7 +149,7 @@ export class BiconomySmartAccount extends SmartAccount implements IBiconomySmart
this.entryPoint = getEntryPointContract(entryPointInstanceDto);
}

private setFactoryContractState() {
private setFactoryContractState(): void {
const _factoryAddress = this.smartAccountInfo.factoryAddress;
if (!BICONOMY_FACTORY_ADDRESSES[_factoryAddress])

Check warning on line 154 in packages/account/src/BiconomySmartAccount.ts

View workflow job for this annotation

GitHub Actions / Lint sources (18.x)

Generic Object Injection Sink
throw new Error(
Expand All @@ -164,7 +164,7 @@ export class BiconomySmartAccount extends SmartAccount implements IBiconomySmart
this.factory = getSAFactoryContract(factoryInstanceDto) as SmartAccountFactory_v100;
}

private async setContractsState() {
private async setContractsState(): Promise<void> {
this.setProxyContractState();
this.setEntryPointContractState();
this.setFactoryContractState();
Expand Down
27 changes: 10 additions & 17 deletions packages/account/src/BiconomySmartAccountV2.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck

import { JsonRpcProvider } from "@ethersproject/providers";
import { Signer } from "ethers";
import { ethers, BigNumberish, BytesLike, BigNumber } from "ethers";
import { BaseSmartAccount } from "./BaseSmartAccount";
import { keccak256, Bytes, arrayify, hexConcat } from "ethers/lib/utils";
import { Logger, NODE_CLIENT_URL, RPC_PROVIDER_URLS } from "@biconomy/common";

import { Bytes, hexConcat } from "ethers/lib/utils";
// Review failure reason for import from '@biconomy/account-contracts-v2/typechain'

import { SmartAccount_v200, SmartAccountFactory_v200, SmartAccount_v200__factory, SmartAccountFactory_v200__factory } from "@biconomy/common";

import {
Overrides,
BiconomyTokenPaymasterRequest,
BiconomySmartAccountV2Config,
CounterFactualAddressParam,
BuildUserOpOptions,
} from "./utils/Types";
Logger,
NODE_CLIENT_URL,
SmartAccount_v200,
SmartAccountFactory_v200,
SmartAccount_v200__factory,
SmartAccountFactory_v200__factory,
} from "@biconomy/common";
import { BiconomyTokenPaymasterRequest, BiconomySmartAccountV2Config, CounterFactualAddressParam, BuildUserOpOptions } from "./utils/Types";
import { BaseValidationModule, ModuleInfo } from "@biconomy/modules";
import { UserOperation, Transaction, SmartAccountType } from "@biconomy/core-types";
import { UserOperation, Transaction } from "@biconomy/core-types";
import NodeClient from "@biconomy/node-client";
import INodeClient from "@biconomy/node-client";
import { IHybridPaymaster, BiconomyPaymaster, SponsorUserOperationDto } from "@biconomy/paymaster";
Expand Down
4 changes: 2 additions & 2 deletions packages/account/src/SmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export abstract class SmartAccount implements ISmartAccount {
this.smartAccountConfig = _smartAccountConfig;
}

setEntryPointAddress(entryPointAddress: string) {
setEntryPointAddress(entryPointAddress: string): void {
this.smartAccountConfig.entryPointAddress = entryPointAddress;
}

Expand Down Expand Up @@ -199,7 +199,7 @@ export abstract class SmartAccount implements ISmartAccount {
return keccak256(enc);
}

abstract getSmartAccountAddress(accountIndex: number): Promise<string>;
abstract getSmartAccountAddress(_accountIndex: number): Promise<string>;

async estimateCreationGas(initCode: string): Promise<BigNumber> {
if (initCode == null || initCode === "0x") return BigNumber.from("0");
Expand Down
17 changes: 8 additions & 9 deletions packages/account/src/interfaces/IBaseSmartAccount.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { UserOperation } from "@biconomy/core-types";
import { UserOpResponse } from "@biconomy/bundler";
import { BigNumberish, Bytes, BytesLike, BigNumber } from "ethers";
/**
* Interface for Smart Contract Wallet aka Smart Account.
* This SA does not have to implement ERC4337 interfaces
*/
export interface INon4337Account {
estimateCreationGas(initCode: string): Promise<BigNumberish>;
estimateCreationGas(_initCode: string): Promise<BigNumberish>;
getNonce(): Promise<BigNumber>;
signMessage(message: Bytes | string): Promise<string>;
getAccountAddress(accountIndex?: number): Promise<string>;
signMessage(_message: Bytes | string): Promise<string>;
getAccountAddress(_accountIndex?: number): Promise<string>;
}

export interface IBaseSmartAccount extends INon4337Account {
getVerificationGasLimit(initCode: BytesLike): Promise<BigNumberish>;
getPreVerificationGas(userOp: Partial<UserOperation>): Promise<BigNumberish>;
signUserOp(userOp: UserOperation): Promise<UserOperation>;
signUserOpHash(userOpHash: string): Promise<string>;
getUserOpHash(userOp: Partial<UserOperation>): Promise<string>;
getVerificationGasLimit(_initCode: BytesLike): Promise<BigNumberish>;
getPreVerificationGas(_userOp: Partial<UserOperation>): Promise<BigNumberish>;
signUserOp(_userOp: UserOperation): Promise<UserOperation>;
signUserOpHash(_userOpHash: string): Promise<string>;
getUserOpHash(_userOp: Partial<UserOperation>): Promise<string>;
getAccountInitCode(): Promise<string>;
getDummySignature(): Promise<string>;
}
22 changes: 11 additions & 11 deletions packages/account/src/interfaces/IBiconomySmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import { ISmartAccount } from "./ISmartAccount";
import { Signer } from "ethers";

export interface IBiconomySmartAccount extends ISmartAccount {
init(initilizationData?: InitilizationData): Promise<this>;
initializeAccountAtIndex(accountIndex: number): void;
getExecuteCallData(to: string, value: BigNumberish, data: BytesLike): string;
getExecuteBatchCallData(to: Array<string>, value: Array<BigNumberish>, data: Array<BytesLike>): string;
buildUserOp(transactions: Transaction[], overrides?: Overrides): Promise<Partial<UserOperation>>;
getAllTokenBalances(balancesDto: BalancesDto): Promise<BalancesResponse>;
getTotalBalanceInUsd(balancesDto: BalancesDto): Promise<UsdBalanceResponse>;
getSmartAccountsByOwner(smartAccountByOwnerDto: SmartAccountByOwnerDto): Promise<SmartAccountsResponse>;
getTransactionsByAddress(chainId: number, address: string): Promise<SCWTransactionResponse[]>;
getTransactionByHash(txHash: string): Promise<SCWTransactionResponse>;
init(_initilizationData?: InitilizationData): Promise<this>;
initializeAccountAtIndex(_accountIndex: number): void;
getExecuteCallData(_to: string, _value: BigNumberish, _data: BytesLike): string;
getExecuteBatchCallData(_to: Array<string>, _value: Array<BigNumberish>, _data: Array<BytesLike>): string;
buildUserOp(_transactions: Transaction[], _overrides?: Overrides): Promise<Partial<UserOperation>>;
getAllTokenBalances(_balancesDto: BalancesDto): Promise<BalancesResponse>;
getTotalBalanceInUsd(_balancesDto: BalancesDto): Promise<UsdBalanceResponse>;
getSmartAccountsByOwner(_smartAccountByOwnerDto: SmartAccountByOwnerDto): Promise<SmartAccountsResponse>;
getTransactionsByAddress(_chainId: number, _address: string): Promise<SCWTransactionResponse[]>;
getTransactionByHash(_txHash: string): Promise<SCWTransactionResponse>;
getAllSupportedChains(): Promise<SupportedChainsResponse>;
attachSigner(signer: Signer): Promise<void>;
attachSigner(_signer: Signer): Promise<void>;
}
8 changes: 4 additions & 4 deletions packages/account/src/interfaces/ISmartAccount.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UserOperation } from "@biconomy/core-types";
import { UserOpResponse } from "@biconomy/bundler";
export interface ISmartAccount {
getSmartAccountAddress(accountIndex: number): Promise<string>;
signUserOp(userOp: UserOperation): Promise<UserOperation>;
sendUserOp(userOp: UserOperation): Promise<UserOpResponse>;
sendSignedUserOp(userOp: UserOperation): Promise<UserOpResponse>;
getSmartAccountAddress(_accountIndex: number): Promise<string>;
signUserOp(_userOp: UserOperation): Promise<UserOperation>;
sendUserOp(_userOp: UserOperation): Promise<UserOpResponse>;
sendSignedUserOp(_userOp: UserOperation): Promise<UserOpResponse>;
}
2 changes: 1 addition & 1 deletion packages/account/src/utils/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BigNumberish } from "ethers";
import { IBundler } from "@biconomy/bundler";
import { IPaymaster, PaymasterFeeQuote } from "@biconomy/paymaster";
import { BaseValidationModule, ModuleInfo } from "@biconomy/modules";
import { JsonRpcProvider, Provider } from "@ethersproject/providers";
import { Provider } from "@ethersproject/providers";
import { GasOverheads } from "./Preverificaiton";

export type EntryPointAddresses = {
Expand Down
8 changes: 4 additions & 4 deletions packages/bundler/src/interfaces/IBundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { UserOpResponse, UserOpGasResponse, UserOpReceipt, UserOpByHashResponse
import { UserOperation } from "@biconomy/core-types";

export interface IBundler {
estimateUserOpGas(userOp: Partial<UserOperation>): Promise<UserOpGasResponse>;
sendUserOp(userOp: UserOperation): Promise<UserOpResponse>;
getUserOpReceipt(userOpHash: string): Promise<UserOpReceipt>;
getUserOpByHash(userOpHash: string): Promise<UserOpByHashResponse>;
estimateUserOpGas(_userOp: Partial<UserOperation>): Promise<UserOpGasResponse>;
sendUserOp(_userOp: UserOperation): Promise<UserOpResponse>;
getUserOpReceipt(_userOpHash: string): Promise<UserOpReceipt>;
getUserOpByHash(_userOpHash: string): Promise<UserOpByHashResponse>;
}
3 changes: 1 addition & 2 deletions packages/bundler/src/utils/HelperFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const transformUserOP = (userOp: UserOperation): UserOperation => {
}
return userOperation;
} catch (error) {
console.error(`Failed to transform user operation: ${error}`);
throw error;
throw `Failed to transform user operation: ${error}`;
}
};
2 changes: 1 addition & 1 deletion packages/bundler/src/utils/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type SendUserOpResponse = {

export type UserOpResponse = {
userOpHash: string;
wait(confirmations?: number): Promise<UserOpReceipt>;
wait(_confirmations?: number): Promise<UserOpReceipt>;
};

// Converted to JsonRpcResponse with strict type
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/ContractsInstances.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SmartAccountType } from "@biconomy/core-types";
import { JsonRpcProvider } from "@ethersproject/providers";
import { EntryPoint, IEntryPoint, EntryPoint__factory } from "@account-abstraction/contracts";
import { IEntryPoint } from "@account-abstraction/contracts";
import {
EntryPoint_v005__factory,
EntryPoint_v006__factory,
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/**
* Single class to be used for logging purpose.
*
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/httpRequests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from "node-fetch";
import { Logger } from "./Logger";

export enum HttpMethod {
Expand Down
8 changes: 4 additions & 4 deletions packages/modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"access": "public"
},
"dependencies": {
"merkletreejs": "^0.3.9"
},
"devDependencies": {
"@biconomy/common": "^3.1.1-alpha.0",
"@biconomy/core-types": "^3.1.1-alpha.0",
"@biconomy/node-client": "^3.1.1-alpha.0"
"@biconomy/node-client": "^3.1.1-alpha.0",
"merkletreejs": "^0.3.9",
"ethers": "^5.7.2",
"ethereumjs-util": "^7.1.5"
}
}
8 changes: 4 additions & 4 deletions packages/modules/src/BaseValidationModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ export abstract class BaseValidationModule implements IValidationModule {

abstract getAddress(): string;

setEntryPointAddress(entryPointAddress: string) {
setEntryPointAddress(entryPointAddress: string): void {
this.entryPointAddress = entryPointAddress;
}

abstract getInitData(): Promise<string>;

// Anything required to get dummy signature can be passed as params
abstract getDummySignature(params?: ModuleInfo): Promise<string>;
abstract getDummySignature(_params?: ModuleInfo): Promise<string>;

// Review naming convention for getter
abstract getSigner(): Promise<Signer>;

// Signer specific or any other additional information can be passed as params
abstract signUserOpHash(userOpHash: string, params?: ModuleInfo): Promise<string>;
abstract signUserOpHash(_userOpHash: string, _params?: ModuleInfo): Promise<string>;

abstract signMessage(message: Bytes | string): Promise<string>;
abstract signMessage(_message: Bytes | string): Promise<string>;
}
23 changes: 5 additions & 18 deletions packages/modules/src/BatchedSessionRouterModule.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import { Signer, ethers } from "ethers";
import MerkleTree from "merkletreejs";
import { NODE_CLIENT_URL, Logger } from "@biconomy/common";
import { Logger } from "@biconomy/common";
import { hexConcat, arrayify, hexZeroPad, defaultAbiCoder, Bytes } from "ethers/lib/utils";
import { keccak256 } from "ethereumjs-util";
import {
ModuleVersion,
CreateSessionDataParams,
StorageType,
SessionParams,
BatchedSessionRouterModuleConfig,
ModuleInfo,
CreateSessionDataResponse,
} from "./utils/Types";
import { ModuleVersion, CreateSessionDataParams, BatchedSessionRouterModuleConfig, ModuleInfo, CreateSessionDataResponse } from "./utils/Types";
import {
BATCHED_SESSION_ROUTER_MODULE_ADDRESSES_BY_VERSION,
SESSION_MANAGER_MODULE_ADDRESSES_BY_VERSION,
DEFAULT_SESSION_KEY_MANAGER_MODULE,
DEFAULT_BATCHED_SESSION_ROUTER_MODULE,
} from "./utils/Constants";
import { generateRandomHex } from "./utils/Uid";
import { BaseValidationModule } from "./BaseValidationModule";
import { SessionLocalStorage } from "./session-storage/SessionLocalStorage";
import { ISessionStorage, SessionSearchParam, SessionStatus } from "./interfaces/ISessionStorage";
import { SessionKeyManagerModule } from "./SessionKeyManagerModule";
import { SessionSearchParam, SessionStatus } from "./interfaces/ISessionStorage";

export class BatchedSessionRouterModule extends BaseValidationModule {
version: ModuleVersion = "V1_0_0";
Expand Down Expand Up @@ -180,15 +167,15 @@ export class BatchedSessionRouterModule extends BaseValidationModule {
* @param status The status to be updated
* @returns
*/
async updateSessionStatus(param: SessionSearchParam, status: SessionStatus) {
async updateSessionStatus(param: SessionSearchParam, status: SessionStatus): Promise<void> {
this.sessionKeyManagerModule.sessionStorageClient.updateSessionStatus(param, status);
}

/**
* @remarks This method is used to clear all the pending sessions
* @returns
*/
async clearPendingSessions() {
async clearPendingSessions(): Promise<void> {
this.sessionKeyManagerModule.sessionStorageClient.clearPendingSessions();
}

Expand Down

0 comments on commit 2135498

Please sign in to comment.