Skip to content

Commit

Permalink
devop: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Oct 23, 2024
1 parent 139e1c3 commit c6464d9
Show file tree
Hide file tree
Showing 701 changed files with 8,623 additions and 8,623 deletions.
2 changes: 1 addition & 1 deletion packages/extension/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": true,
"singleQuote": false,
"singleQuote": true,
"arrowParens": "avoid"
}
2 changes: 1 addition & 1 deletion packages/extension/src/configs/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const EXTENSION_NAMESPACE =
"dfc62431af1c3c1258035e5ab4058b6440e507238cf0fe429ea39827a7ee43fc"; //keccak256("enkrypt")
'dfc62431af1c3c1258035e5ab4058b6440e507238cf0fe429ea39827a7ee43fc'; //keccak256("enkrypt")
10 changes: 5 additions & 5 deletions packages/extension/src/libs/activity-state/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { InternalStorageNamespace } from "@/types/provider";
import BrowserStorage from "@/libs/common/browser-storage";
import { ActivityOptions } from "./types";
import { Activity, ActivityStatus } from "@/types/activity";
const STORAGE_KEY = "activity";
import { InternalStorageNamespace } from '@/types/provider';
import BrowserStorage from '@/libs/common/browser-storage';
import { ActivityOptions } from './types';
import { Activity, ActivityStatus } from '@/types/activity';
const STORAGE_KEY = 'activity';
const MAX_PENDING_TIME = 12 * 60 * 60 * 1000; // 12 hours

class ActivityState {
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/libs/activity-state/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Activity } from "@/types/activity";
import { BaseNetwork } from "@/types/base-network";
import { Activity } from '@/types/activity';
import { BaseNetwork } from '@/types/base-network';

export interface ActivityOptions {
address: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ActivityState from ".";
import { ActivityHandlerType } from "./types";
import ActivityState from '.';
import { ActivityHandlerType } from './types';
const CACHE_TTL = 1000 * 60 * 5; // 5 mins
export default (activityHandler: ActivityHandlerType): ActivityHandlerType => {
const returnFunction: ActivityHandlerType = async (network, address) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import PersistentEvents from "@/libs/persistent-events";
import Browser from "webextension-polyfill";
import { sendToWindow } from "@/libs/messenger/extension";
import { OnMessageResponse } from "@enkryptcom/types";
import { EnkryptProviderEventMethods } from "@/types/provider";
import type BackgroundHandler from "..";
import PersistentEvents from '@/libs/persistent-events';
import Browser from 'webextension-polyfill';
import { sendToWindow } from '@/libs/messenger/extension';
import { OnMessageResponse } from '@enkryptcom/types';
import { EnkryptProviderEventMethods } from '@/types/provider';
import type BackgroundHandler from '..';

async function handlePersistentEvents(this: BackgroundHandler) {
const persistentEvents = new PersistentEvents();
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/libs/background/external/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import handlePersistentEvents from "./handle-persistent-events";
import handlePersistentEvents from './handle-persistent-events';
export { handlePersistentEvents };
36 changes: 18 additions & 18 deletions packages/extension/src/libs/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import {
InternalMethods,
InternalOnMessageResponse,
Message,
} from "@/types/messenger";
import { RPCRequestType, OnMessageResponse } from "@enkryptcom/types";
import { v4 as randomUUID } from "uuid";
import { getCustomError } from "../error";
import KeyRingBase from "../keyring/keyring";
import { sendToWindow } from "@/libs/messenger/extension";
import { ProviderName } from "@/types/provider";
import Providers from "@/providers";
import Browser from "webextension-polyfill";
import TabInfo from "@/libs/utils/tab-info";
import PersistentEvents from "@/libs/persistent-events";
import DomainState from "@/libs/domain-state";
import { TabProviderType, ProviderType, ExternalMessageOptions } from "./types";
import { getProviderNetworkByName } from "../utils/networks";
} from '@/types/messenger';
import { RPCRequestType, OnMessageResponse } from '@enkryptcom/types';
import { v4 as randomUUID } from 'uuid';
import { getCustomError } from '../error';
import KeyRingBase from '../keyring/keyring';
import { sendToWindow } from '@/libs/messenger/extension';
import { ProviderName } from '@/types/provider';
import Providers from '@/providers';
import Browser from 'webextension-polyfill';
import TabInfo from '@/libs/utils/tab-info';
import PersistentEvents from '@/libs/persistent-events';
import DomainState from '@/libs/domain-state';
import { TabProviderType, ProviderType, ExternalMessageOptions } from './types';
import { getProviderNetworkByName } from '../utils/networks';
import {
sign,
getEthereumPubKey,
Expand All @@ -25,9 +25,9 @@ import {
sendToTab,
newAccount,
lock,
} from "./internal";
import { handlePersistentEvents } from "./external";
import SettingsState from "../settings-state";
} from './internal';
import { handlePersistentEvents } from './external';
import SettingsState from '../settings-state';

class BackgroundHandler {
#keyring: KeyRingBase;
Expand Down Expand Up @@ -93,7 +93,7 @@ class BackgroundHandler {
});
}
return {
error: JSON.stringify(getCustomError("Enkrypt: not implemented")),
error: JSON.stringify(getCustomError('Enkrypt: not implemented')),
};
}
const tabInfo = TabInfo(await Browser.tabs.get(_tabid));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getCustomError } from "@/libs/error";
import { getNetworkByName } from "@/libs/utils/networks";
import { BaseNetwork } from "@/types/base-network";
import { getCustomError } from '@/libs/error';
import { getNetworkByName } from '@/libs/utils/networks';
import { BaseNetwork } from '@/types/base-network';
import {
ActionSendMessage,
InternalOnMessageResponse,
Message,
} from "@/types/messenger";
import { RPCRequestType } from "@enkryptcom/types";
import { TabProviderType } from "../types";
} from '@/types/messenger';
import { RPCRequestType } from '@enkryptcom/types';
import { TabProviderType } from '../types';

const changeNetwork = async (
msg: Message,
Expand All @@ -16,7 +16,7 @@ const changeNetwork = async (
const message = JSON.parse(msg.message) as RPCRequestType;
if (!message.params || message.params.length < 1)
return Promise.resolve({
error: getCustomError("background: invalid params for change network"),
error: getCustomError('background: invalid params for change network'),
});
const networkName = message.params[0] as string;
const network = (await getNetworkByName(networkName)) as BaseNetwork;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getCustomError } from "@/libs/error";
import KeyRingBase from "@/libs/keyring/keyring";
import { InternalOnMessageResponse } from "@/types/messenger";
import { EnkryptAccount, RPCRequestType } from "@enkryptcom/types";
import { getCustomError } from '@/libs/error';
import KeyRingBase from '@/libs/keyring/keyring';
import { InternalOnMessageResponse } from '@/types/messenger';
import { EnkryptAccount, RPCRequestType } from '@enkryptcom/types';

const ethereumDecrypt = (
keyring: KeyRingBase,
message: RPCRequestType,
): Promise<InternalOnMessageResponse> => {
if (!message.params || message.params.length < 2)
return Promise.resolve({
error: getCustomError("background: invalid params for decrypt"),
error: getCustomError('background: invalid params for decrypt'),
});
const encryptedMessage = message.params[0] as string;
const account = message.params[1] as EnkryptAccount;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getCustomError } from "@/libs/error";
import KeyRingBase from "@/libs/keyring/keyring";
import { InternalOnMessageResponse } from "@/types/messenger";
import { EnkryptAccount, RPCRequestType } from "@enkryptcom/types";
import { getCustomError } from '@/libs/error';
import KeyRingBase from '@/libs/keyring/keyring';
import { InternalOnMessageResponse } from '@/types/messenger';
import { EnkryptAccount, RPCRequestType } from '@enkryptcom/types';

const getEthereumPubKey = (
keyring: KeyRingBase,
message: RPCRequestType,
): Promise<InternalOnMessageResponse> => {
if (!message.params || message.params.length < 1)
return Promise.resolve({
error: getCustomError("background: invalid params for public key"),
error: getCustomError('background: invalid params for public key'),
});
const account = message.params[0] as EnkryptAccount;
return keyring
Expand Down
16 changes: 8 additions & 8 deletions packages/extension/src/libs/background/internal/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sign from "./sign";
import getEthereumPubKey from "./ethereum-pub-key";
import ethereumDecrypt from "./ethereum-decrypt";
import unlock from "./unlock";
import changeNetwork from "./change-network";
import sendToTab from "./send-to-tab";
import newAccount from "./new-account";
import lock from "./lock";
import sign from './sign';
import getEthereumPubKey from './ethereum-pub-key';
import ethereumDecrypt from './ethereum-decrypt';
import unlock from './unlock';
import changeNetwork from './change-network';
import sendToTab from './send-to-tab';
import newAccount from './new-account';
import lock from './lock';
export {
sign,
getEthereumPubKey,
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/libs/background/internal/lock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import KeyRingBase from "@/libs/keyring/keyring";
import { InternalOnMessageResponse } from "@/types/messenger";
import KeyRingBase from '@/libs/keyring/keyring';
import { InternalOnMessageResponse } from '@/types/messenger';

const lock = (keyring: KeyRingBase): Promise<InternalOnMessageResponse> => {
keyring.lock();
Expand Down
14 changes: 7 additions & 7 deletions packages/extension/src/libs/background/internal/new-account.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { getCustomError } from "@/libs/error";
import KeyRingBase from "@/libs/keyring/keyring";
import { InternalMethods, InternalOnMessageResponse } from "@/types/messenger";
import { KeyRecordAdd, RPCRequestType } from "@enkryptcom/types";
import { getCustomError } from '@/libs/error';
import KeyRingBase from '@/libs/keyring/keyring';
import { InternalMethods, InternalOnMessageResponse } from '@/types/messenger';
import { KeyRecordAdd, RPCRequestType } from '@enkryptcom/types';

const newAccount = (
keyring: KeyRingBase,
message: RPCRequestType,
): Promise<InternalOnMessageResponse> => {
if (!message.params || message.params.length < 1)
return Promise.resolve({
error: getCustomError("background: invalid params for new account"),
error: getCustomError('background: invalid params for new account'),
});
const method =
message.method === InternalMethods.getNewAccount
? "getNewAccount"
: "saveNewAccount";
? 'getNewAccount'
: 'saveNewAccount';
const keyrecord = message.params[0] as KeyRecordAdd;
return keyring[method](keyrecord)
.then(res => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
ActionSendMessage,
InternalOnMessageResponse,
Message,
} from "@/types/messenger";
import { RPCRequestType } from "@enkryptcom/types";
import { TabProviderType } from "../types";
} from '@/types/messenger';
import { RPCRequestType } from '@enkryptcom/types';
import { TabProviderType } from '../types';

const sendToTab = (
msg: Message,
Expand Down
10 changes: 5 additions & 5 deletions packages/extension/src/libs/background/internal/sign.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getCustomError } from "@/libs/error";
import KeyRingBase from "@/libs/keyring/keyring";
import { InternalOnMessageResponse } from "@/types/messenger";
import { EnkryptAccount, RPCRequestType } from "@enkryptcom/types";
import { getCustomError } from '@/libs/error';
import KeyRingBase from '@/libs/keyring/keyring';
import { InternalOnMessageResponse } from '@/types/messenger';
import { EnkryptAccount, RPCRequestType } from '@enkryptcom/types';

const sign = (
keyring: KeyRingBase,
message: RPCRequestType,
): Promise<InternalOnMessageResponse> => {
if (!message.params || message.params.length < 2)
return Promise.resolve({
error: getCustomError("background: invalid params for signing"),
error: getCustomError('background: invalid params for signing'),
});
const msgHash = message.params[0] as `0x${string}`;
const account = message.params[1] as EnkryptAccount;
Expand Down
12 changes: 6 additions & 6 deletions packages/extension/src/libs/background/internal/unlock.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { getCustomError } from "@/libs/error";
import KeyRingBase from "@/libs/keyring/keyring";
import { InternalOnMessageResponse } from "@/types/messenger";
import { RPCRequestType } from "@enkryptcom/types";
import { initAccounts } from "@/libs/utils/initialize-wallet";
import { getCustomError } from '@/libs/error';
import KeyRingBase from '@/libs/keyring/keyring';
import { InternalOnMessageResponse } from '@/types/messenger';
import { RPCRequestType } from '@enkryptcom/types';
import { initAccounts } from '@/libs/utils/initialize-wallet';

const unlock = (
keyring: KeyRingBase,
message: RPCRequestType,
): Promise<InternalOnMessageResponse> => {
if (!message.params || message.params.length < 1)
return Promise.resolve({
error: getCustomError("background: invalid params for unlocking"),
error: getCustomError('background: invalid params for unlocking'),
});
const password = message.params[0] as string;
const initNewAccounts = (message.params[1] as boolean) ?? false;
Expand Down
10 changes: 5 additions & 5 deletions packages/extension/src/libs/background/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BitcoinProvider from "@/providers/bitcoin";
import type EthereumProvider from "@/providers/ethereum";
import type PolkadotProvider from "@/providers/polkadot";
import type KadenaProvider from "@/providers/kadena";
import SolanaProvider from "@/providers/solana";
import BitcoinProvider from '@/providers/bitcoin';
import type EthereumProvider from '@/providers/ethereum';
import type PolkadotProvider from '@/providers/polkadot';
import type KadenaProvider from '@/providers/kadena';
import SolanaProvider from '@/providers/solana';

export interface TabProviderType {
[key: string]: Record<
Expand Down
14 changes: 7 additions & 7 deletions packages/extension/src/libs/cache-fetch/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RequestOptions, StoredData } from "./types";
import BrowserStorage from "../common/browser-storage";
import { InternalStorageNamespace } from "@/types/provider";
import { keccak256 } from "web3-utils";
import { RequestOptions, StoredData } from './types';
import BrowserStorage from '../common/browser-storage';
import { InternalStorageNamespace } from '@/types/provider';
import { keccak256 } from 'web3-utils';
const STORAGE_TTL = 1000 * 60 * 60 * 24;
const TIMESTAMP = "timestamp";
const TIMESTAMP = 'timestamp';
const cacheFetch = async (
options: RequestOptions,
ttl: number = STORAGE_TTL,
Expand Down Expand Up @@ -31,7 +31,7 @@ const cacheFetch = async (
body?: string;
} = {};
if (options.post) {
fetchOptions.method = "POST";
fetchOptions.method = 'POST';
fetchOptions.body = JSON.stringify(options.post);
}
if (options.headers) {
Expand All @@ -42,7 +42,7 @@ const cacheFetch = async (
.then(json => {
const jsondata = options.postProcess ? options.postProcess(json) : json;
const jsonstring = JSON.stringify(jsondata);
if (!jsonstring.includes("error")) {
if (!jsonstring.includes('error')) {
const store: StoredData = {
timestamp: new Date().getTime(),
data: jsonstring,
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/libs/common/browser-storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Storage from "@enkryptcom/storage";
import { BrowserStorageArea } from "@enkryptcom/types";
import Storage from '@enkryptcom/storage';
import { BrowserStorageArea } from '@enkryptcom/types';

class BrowserStorage extends Storage {
constructor(namespace: string, storage?: BrowserStorageArea) {
Expand Down
8 changes: 4 additions & 4 deletions packages/extension/src/libs/custom-networks-state/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CustomEvmNetworkOptions } from "@/providers/ethereum/types/custom-evm-network";
import { InternalStorageNamespace } from "@/types/provider";
import BrowserStorage from "../common/browser-storage";
import { IState, StorageKeys } from "./types";
import { CustomEvmNetworkOptions } from '@/providers/ethereum/types/custom-evm-network';
import { InternalStorageNamespace } from '@/types/provider';
import BrowserStorage from '../common/browser-storage';
import { IState, StorageKeys } from './types';

export default class CustomNetworksState {
private storage: BrowserStorage;
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/libs/custom-networks-state/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CustomEvmNetworkOptions } from "@/providers/ethereum/types/custom-evm-network";
import { CustomEvmNetworkOptions } from '@/providers/ethereum/types/custom-evm-network';

export enum StorageKeys {
customNetworksInfo = "custom-networks-info",
customNetworksInfo = 'custom-networks-info',
}

export interface IState {
Expand Down
Loading

1 comment on commit c6464d9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.