Skip to content

Commit

Permalink
fix: more lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AmanRaj1608 committed Sep 13, 2023
1 parent 5d12fe7 commit 10df908
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 41 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
"security/detect-object-injection": "warn",
"security/detect-unsafe-regex": "error",
"import/extensions": "off",
"security/detect-object-injection": "off", // turning off Injection Sink rule
"@typescript-eslint/no-throw-literal": "off", // temp deactivated needs to be removed once fixed
},
settings: {},
Expand Down
1 change: 1 addition & 0 deletions packages/bundler/src/Bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { JsonRpcProvider } from "@ethersproject/providers";
* Checkout the proposal for more details on Bundlers.
*/
export class Bundler implements IBundler {
// eslint-disable-next-line no-unused-vars
UserOpReceiptIntervals: { [key in ChainId]?: number };

constructor(readonly bundlerConfig: Bundlerconfig) {
Expand Down
1 change: 1 addition & 0 deletions packages/bundler/src/utils/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChainId } from "@biconomy/core-types";

// eslint-disable-next-line no-unused-vars
export const UserOpReceiptIntervals: { [key in ChainId]?: number } = {
[ChainId.MAINNET]: 10000,
[ChainId.GOERLI]: 5000,
Expand Down
1 change: 1 addition & 0 deletions packages/bundler/src/utils/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type Bundlerconfig = {
bundlerUrl: string;
entryPointAddress?: string;
chainId: ChainId;
// eslint-disable-next-line no-unused-vars
userOpReceiptIntervals?: { [key in ChainId]?: number };
};

Expand Down
1 change: 1 addition & 0 deletions packages/common/src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChainId } from "@biconomy/core-types";

export const NODE_CLIENT_URL = "https://sdk-backend.prod.biconomy.io/v1";

// eslint-disable-next-line no-unused-vars
export const RPC_PROVIDER_URLS: { [key in ChainId]?: string } = {
[ChainId.MAINNET]: "https://rpc.ankr.com/eth",
[ChainId.GOERLI]: "https://rpc.ankr.com/eth_goerli",
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/src/SessionKeyManagerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ export class SessionKeyManagerModule 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.sessionStorageClient.updateSessionStatus(param, status);
}

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

Expand Down
4 changes: 2 additions & 2 deletions packages/modules/src/interfaces/IValidationModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface IValidationModule {
getAddress(): string;
getInitData(): Promise<string>;
getSigner(): Promise<Signer>;
signUserOpHash(userOpHash: string): Promise<string>;
signMessage(message: Bytes | string): Promise<string>;
signUserOpHash(_userOpHash: string): Promise<string>;
signMessage(_message: Bytes | string): Promise<string>;
getDummySignature(): Promise<string>;
}
2 changes: 1 addition & 1 deletion packages/modules/src/utils/Uid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// small uid generator, hex: 0-9, a-f (10 chars)
export const generateRandomHex = () => {
export const generateRandomHex = (): string => {
const hexChars = "0123456789abcdef";
let result = "";

Expand Down
8 changes: 6 additions & 2 deletions packages/web3-auth-native/src/SocialLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import base64url from 'base64url'
import log from 'loglevel'
import { URL } from 'react-native-url-polyfill'

import { IWebBrowser } from './types/IWebBrowser'
import { IWebBrowser, WebBrowserAuthSessionResult } from './types/IWebBrowser'
import { SdkInitParams, SdkLoginParams, SdkLogoutParams, SocialLoginDto } from './types/sdk'
import { State } from './types/State'

Expand Down Expand Up @@ -59,7 +59,11 @@ class SocialLogin {
}
}

private async request(path: string, redirectUrl: string, params: Record<string, unknown> = {}) {
private async request(
path: string,
redirectUrl: string,
params: Record<string, unknown> = {}
): Promise<WebBrowserAuthSessionResult> {
const initParams = {
...this.initParams,
clientId: this.clientId,
Expand Down
6 changes: 3 additions & 3 deletions packages/web3-auth-native/src/types/IWebBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ export interface IWebBrowser {
* the Promise fulfills with `{ type: 'dismiss' }` object.
*/
openAuthSessionAsync(
url: string,
redirectUrl: string,
browserParams?: WebBrowserOpenOptions
_url: string,
_redirectUrl: string,
_browserParams?: WebBrowserOpenOptions
): Promise<WebBrowserAuthSessionResult>
// dismissAuthSession(): void;
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-auth-native/src/types/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type SocialLoginDto = {
}

export type IOriginData = {
[P in string]: string
[P: string]: string
}

export type SdkInitParams = Omit<
Expand Down
52 changes: 25 additions & 27 deletions packages/web3-auth/src/SocialLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import React from "react";
import { createRoot } from "react-dom/client";
import { ethers } from "ethers";
Expand All @@ -12,7 +13,7 @@ import NodeClient, { WhiteListSignatureResponse } from "@biconomy/node-client";
import UI from "./UI";
import { DefaultSocialLoginConfig, SocialLoginDTO, WhiteLabelDataType } from "./types/Web3AuthConfig";

function createLoginModal(socialLogin: SocialLogin) {
function createLoginModal(socialLogin: SocialLogin): void {
/* eslint-disable @typescript-eslint/no-explicit-any */
const root = createRoot((document as any).getElementById("w3a-modal"));
root.render(<UI socialLogin={socialLogin} />);
Expand Down Expand Up @@ -66,11 +67,10 @@ class SocialLogin {

async whitelistUrl(origin: string): Promise<string> {
const whiteListUrlResponse: WhiteListSignatureResponse = await this.nodeClient.whitelistUrl(origin);
console.log(whiteListUrlResponse.data);
return whiteListUrlResponse.data;
}

async init(socialLoginDTO?: Partial<SocialLoginDTO>) {
async init(socialLoginDTO?: Partial<SocialLoginDTO>): Promise<void> {
const finalDTO: SocialLoginDTO = {
chainId: "0x1",
whitelistUrls: {},
Expand All @@ -84,7 +84,6 @@ class SocialLogin {
if (socialLoginDTO.whteLableData) this.whiteLabel = socialLoginDTO.whteLableData;
}
try {
console.log("SocialLogin init");
const web3AuthCore = new Web3AuthCore({
clientId: this.clientId,
chainConfig: {
Expand Down Expand Up @@ -132,12 +131,12 @@ class SocialLogin {
}
}

getProvider() {
getProvider(): SafeEventEmitterProvider | null {
return this.provider;
}

/* eslint-disable @typescript-eslint/no-explicit-any */
private _createIframe(iframeContainerDiv: any) {
private _createIframe(iframeContainerDiv: any): void {
this.walletIframe = document.createElement("iframe");
this.walletIframe.style.display = "none";
this.walletIframe.style.display = "relative";
Expand All @@ -148,7 +147,7 @@ class SocialLogin {
iframeContainerDiv.appendChild(this.walletIframe);
}

private createWalletDiv() {
private createWalletDiv(): void {
// create a fixed div into html but keep it hidden initially
const walletDiv = document.createElement("div");
walletDiv.id = "w3a-modal";
Expand All @@ -167,7 +166,7 @@ class SocialLogin {
this._createIframe(walletDiv);
}

showWallet() {
showWallet(): void {
this.walletDiv.style.display = "block";
this.walletIframe.style.display = "block";
// Set height and width of the iframe to 600x341
Expand All @@ -179,13 +178,12 @@ class SocialLogin {
el?.dispatchEvent(new Event("show-modal"));
}

hideWallet() {
console.log("hide wallet");
hideWallet(): void {
this.walletDiv.style.display = "none";
this.walletIframe.style.display = "none";
}

async getUserInfo() {
async getUserInfo(): Promise<Partial<UserInfo> | null> {
if (this.web3auth) {
const userInfo = await this.web3auth.getUserInfo();
this.userInfo = userInfo;
Expand All @@ -194,20 +192,20 @@ class SocialLogin {
return null;
}

async getPrivateKey() {
async getPrivateKey(): Promise<string | null> {
if (this.web3auth && this.web3auth.provider) {
const privateKey = await this.web3auth.provider.request({
method: "eth_private_key",
});
return privateKey;
return privateKey as string;
}
return null;
}

async socialLogin(loginProvider: string) {
async socialLogin(loginProvider: string): Promise<SafeEventEmitterProvider | null> {
if (!this.web3auth) {
console.info("web3auth not initialized yet");
return;
return null;
}
try {
const web3authProvider = await this.web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
Expand All @@ -226,14 +224,14 @@ class SocialLogin {
return web3authProvider;
} catch (error) {
console.error(error);
return error;
return null;
}
}

async emailLogin(email: string) {
async emailLogin(email: string): Promise<SafeEventEmitterProvider | null> {
if (!this.web3auth) {
console.info("web3auth not initialized yet");
return;
return null;
}
try {
const web3authProvider = await this.web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
Expand All @@ -253,14 +251,14 @@ class SocialLogin {
return web3authProvider;
} catch (error) {
console.error(error);
return error;
return null;
}
}

async metamaskLogin() {
async metamaskLogin(): Promise<SafeEventEmitterProvider | null> {
if (!this.web3auth) {
console.log("web3auth not initialized yet");
return;
return null;
}
try {
const web3authProvider = await this.web3auth.connectTo(WALLET_ADAPTERS.METAMASK);
Expand All @@ -277,14 +275,14 @@ class SocialLogin {
return web3authProvider;
} catch (error) {
console.error(error);
return error;
return null;
}
}

async walletConnectLogin() {
async walletConnectLogin(): Promise<SafeEventEmitterProvider | null> {
if (!this.web3auth) {
console.log("web3auth not initialized yet");
return;
return null;
}
try {
const web3authProvider = await this.web3auth.connectTo(WALLET_ADAPTERS.WALLET_CONNECT_V1);
Expand All @@ -301,11 +299,11 @@ class SocialLogin {
return web3authProvider;
} catch (error) {
console.error(error);
return error;
return null;
}
}

async logout() {
async logout(): Promise<void> {
if (!this.web3auth) {
console.log("web3auth not initialized yet");
return;
Expand All @@ -322,7 +320,7 @@ const socialLoginSDK: SocialLogin = new SocialLogin();
export default SocialLogin;

let initializedSocialLogin: SocialLogin | null = null;
const getSocialLoginSDK = async (socialLoginDTO?: Partial<SocialLoginDTO>) => {
const getSocialLoginSDK = async (socialLoginDTO?: Partial<SocialLoginDTO>): Promise<SocialLogin> => {
if (initializedSocialLogin) {
return initializedSocialLogin;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web3-auth/src/UI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const container = {
const UI: React.FC<UIPorops> = ({ socialLogin }) => {
const [email, setEmail] = useState("");

function handleEmailSubmit(event: React.SyntheticEvent) {
function handleEmailSubmit(event: React.SyntheticEvent): void {
event.preventDefault();
socialLogin.emailLogin(email);
}

function handleEmailChange(event: React.FormEvent<HTMLInputElement>) {
function handleEmailChange(event: React.FormEvent<HTMLInputElement>): void {
setEmail(event.currentTarget.value);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/web3-auth/src/types/Web3AuthConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type WhiteLabelDataType = {

export type SocialLoginDTO = {
chainId: string;
whitelistUrls: { [P in string]: string };
whitelistUrls: { [P: string]: string };
network: "mainnet" | "testnet";
whteLableData: WhiteLabelDataType;
};

0 comments on commit 10df908

Please sign in to comment.