mirror of
https://github.com/pezkuwichain/pezkuwi-extension.git
synced 2026-11-23 14:29:56 +00:00
Move to @pezkuwi/dev 0.86 (eslint 10 toolchain)
- @pezkuwi/dev, dev-test, dev-ts ^0.86.3 in the root and in every workspace package (they still asked for 0.84.3) - tsconfig.base target ES2022, the @pezkuwi/dev default; it carries the ErrorOptions type for `cause` - rethrown errors carry the original as `cause`; rejections are normalised to Error - page/messaging: the typed subscriber is called directly, not as `Function` - chrome mock: constant results through Promise.resolve - useLedger: drop a construction every branch below repeated - InputWithLabel: onKeyDown instead of the deprecated onKeyPress - Account: toggleActions + 1 instead of a pre-increment of a parameter - optional chains where a guard tested the same value - specs: mount<React.Component> so the wrappers are not `any`-typed - AccountsStore.set keeps its async override of KeyringStore.set: BaseStore.set handles its own failure, so it never rejects - extension-chains keeps its ChainProperties assertion: the package's own build does not load the type augmentation - the existing React Compiler findings (37, react-hooks rules only) are recorded in eslint-suppressions.json; a new one fails lint
This commit is contained in:
1 parent
0321454dc7
commit
9d769676e4
58 files changed
+2795
-3355
No files matched your search
@@ -39,7 +39,7 @@
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pezkuwi/dev-test": "^0.84.3",
|
||||
"@pezkuwi/dev-test": "^0.86.3",
|
||||
"@pezkuwi/extension-mocks": "0.62.27"
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import type { Registry, SignerPayloadJSON, SignerPayloadRaw } from '@pezkuwi/typ
|
||||
import type { SubjectInfo } from '@pezkuwi/ui-keyring/observable/types';
|
||||
import type { KeypairType } from '@pezkuwi/util-crypto/types';
|
||||
import type { AccountJson, AllowedPath, AuthorizeRequest, MessageTypes, MetadataRequest, RequestAccountBatchExport, RequestAccountChangePassword, RequestAccountCreateExternal, RequestAccountCreateHardware, RequestAccountCreateSuri, RequestAccountEdit, RequestAccountExport, RequestAccountForget, RequestAccountShow, RequestAccountTie, RequestAccountValidate, RequestActiveTabsUrlUpdate, RequestAuthorizeApprove, RequestBatchRestore, RequestDeriveCreate, RequestDeriveValidate, RequestJsonRestore, RequestMetadataApprove, RequestMetadataReject, RequestSeedCreate, RequestSeedValidate, RequestSigningApprovePassword, RequestSigningApproveSignature, RequestSigningCancel, RequestSigningIsLocked, RequestTypes, RequestUpdateAuthorizedAccounts, ResponseAccountExport, ResponseAccountsExport, ResponseAuthorizeList, ResponseDeriveValidate, ResponseJsonGetAccountInfo, ResponseSeedCreate, ResponseSeedValidate, ResponseSigningIsLocked, ResponseType, SigningRequest } from '../types.js';
|
||||
import type { AuthorizedAccountsDiff } from './State.js';
|
||||
import type State from './State.js';
|
||||
import type { AuthorizedAccountsDiff } from './State.js';
|
||||
|
||||
import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@pezkuwi/extension-base/defaults';
|
||||
import { metadataExpand } from '@pezkuwi/extension-chains';
|
||||
@@ -296,7 +296,7 @@ export default class Extension {
|
||||
try {
|
||||
keyring.restoreAccount(file, password);
|
||||
} catch (error) {
|
||||
throw new Error((error as Error).message);
|
||||
throw new Error((error as Error).message, { cause: error });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ export default class Extension {
|
||||
try {
|
||||
keyring.restoreAccounts(file, password);
|
||||
} catch (error) {
|
||||
throw new Error((error as Error).message);
|
||||
throw new Error((error as Error).message, { cause: error });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ export default class Extension {
|
||||
} as ResponseJsonGetAccountInfo;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw new Error((e as Error).message);
|
||||
throw new Error((e as Error).message, { cause: e });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +570,6 @@ export default class Extension {
|
||||
}
|
||||
|
||||
// Weird thought, the eslint override is not needed in Tabs
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
public async handle<TMessageType extends MessageTypes> (id: string, type: TMessageType, request: RequestTypes[TMessageType], port?: chrome.runtime.Port): Promise<ResponseType<TMessageType>> {
|
||||
switch (type) {
|
||||
case 'pri(authorize.approve)':
|
||||
|
||||
@@ -30,7 +30,7 @@ interface AuthRequest extends Resolver<AuthResponse> {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type AuthorizedAccountsDiff = [url: string, authorizedAccounts: AuthUrlInfo['authorizedAccounts']][]
|
||||
export type AuthorizedAccountsDiff = [url: string, authorizedAccounts: AuthUrlInfo['authorizedAccounts']][];
|
||||
|
||||
interface MetaRequest extends Resolver<boolean> {
|
||||
id: string;
|
||||
@@ -50,7 +50,7 @@ type Providers = Record<string, {
|
||||
// The provider is not running at init, calling this will instantiate the
|
||||
// provider.
|
||||
start: () => ProviderInterface;
|
||||
}>
|
||||
}>;
|
||||
|
||||
interface SignRequest extends Resolver<ResponseSigning> {
|
||||
account: AccountJson;
|
||||
@@ -80,7 +80,7 @@ const NORMAL_WINDOW_OPTS: chrome.windows.CreateData = {
|
||||
export enum NotificationOptions {
|
||||
None,
|
||||
Normal,
|
||||
PopUp,
|
||||
PopUp
|
||||
}
|
||||
|
||||
const AUTH_URLS_KEY = 'authUrls';
|
||||
@@ -518,7 +518,7 @@ export default class State {
|
||||
return parsedUrl.origin;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw new Error('Invalid URL');
|
||||
throw new Error('Invalid URL', { cause: e });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -796,7 +796,7 @@ export default class State {
|
||||
try {
|
||||
this.handleSignRequest(url);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject): void => {
|
||||
|
||||
@@ -9,8 +9,8 @@ import type { JsonRpcResponse } from '@pezkuwi/rpc-provider/types';
|
||||
import type { SignerPayloadJSON, SignerPayloadRaw } from '@pezkuwi/types/types';
|
||||
import type { SubjectInfo } from '@pezkuwi/ui-keyring/observable/types';
|
||||
import type { AuthUrlInfo, MessageTypes, RequestAccountList, RequestAccountUnsubscribe, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestTypes, ResponseRpcListProviders, ResponseSigning, ResponseTypes, SubscriptionMessageTypes } from '../types.js';
|
||||
import type { AuthResponse } from './State.js';
|
||||
import type State from './State.js';
|
||||
import type { AuthResponse } from './State.js';
|
||||
|
||||
import { combineLatest, type Subscription } from 'rxjs';
|
||||
|
||||
@@ -113,7 +113,7 @@ export default class Tabs {
|
||||
private accountsUnsubscribe (url: string, { id }: RequestAccountUnsubscribe): boolean {
|
||||
const sub = this.#accountSubs[id];
|
||||
|
||||
if (!sub || sub.url !== url) {
|
||||
if (sub?.url !== url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright 2019-2026 @pezkuwi/extension-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
import type { InjectedAccount, InjectedMetadataKnown, MetadataDef, ProviderList, ProviderMeta } from '@pezkuwi/extension-inject/types';
|
||||
import type { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '@pezkuwi/keyring/types';
|
||||
import type { JsonRpcResponse } from '@pezkuwi/rpc-provider/types';
|
||||
@@ -45,7 +43,7 @@ export interface AccountJson extends KeyringPair$Meta {
|
||||
|
||||
export type AccountWithChildren = AccountJson & {
|
||||
children?: AccountWithChildren[];
|
||||
}
|
||||
};
|
||||
|
||||
export interface AccountsContext {
|
||||
accounts: AccountJson[];
|
||||
@@ -74,7 +72,7 @@ export interface SigningRequest {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type ConnectedTabsUrlResponse = string[]
|
||||
export type ConnectedTabsUrlResponse = string[];
|
||||
|
||||
// [MessageType]: [RequestType, ResponseType, SubscriptionMessageType?]
|
||||
export interface RequestSignatures {
|
||||
@@ -148,7 +146,7 @@ export type RequestTypes = {
|
||||
[MessageType in keyof RequestSignatures]: RequestSignatures[MessageType][0]
|
||||
};
|
||||
|
||||
export type MessageTypesWithNullRequest = NullKeys<RequestTypes>
|
||||
export type MessageTypesWithNullRequest = NullKeys<RequestTypes>;
|
||||
|
||||
export interface TransportRequestMessage<TMessageType extends MessageTypes> {
|
||||
id: string;
|
||||
@@ -396,7 +394,7 @@ export type SubscriptionMessageTypes = NoUndefinedValues<{
|
||||
}>;
|
||||
|
||||
export type MessageTypesWithSubscriptions = keyof SubscriptionMessageTypes;
|
||||
export type MessageTypesWithNoSubscriptions = Exclude<MessageTypes, keyof SubscriptionMessageTypes>
|
||||
export type MessageTypesWithNoSubscriptions = Exclude<MessageTypes, keyof SubscriptionMessageTypes>;
|
||||
|
||||
export interface RequestSign {
|
||||
readonly payload: SignerPayloadJSON | SignerPayloadRaw;
|
||||
|
||||
@@ -30,9 +30,9 @@ const handlers: Handlers = {};
|
||||
|
||||
// a generic message sender that creates an event, returning a promise that will
|
||||
// resolve once the event is resolved (by the response listener just below this)
|
||||
export function sendMessage<TMessageType extends MessageTypesWithNullRequest>(message: TMessageType): Promise<ResponseTypes[TMessageType]>;
|
||||
export function sendMessage<TMessageType extends MessageTypesWithNoSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType]): Promise<ResponseTypes[TMessageType]>;
|
||||
export function sendMessage<TMessageType extends MessageTypesWithSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType], subscriber: (data: SubscriptionMessageTypes[TMessageType]) => void): Promise<ResponseTypes[TMessageType]>;
|
||||
export function sendMessage<TMessageType extends MessageTypesWithNullRequest> (message: TMessageType): Promise<ResponseTypes[TMessageType]>;
|
||||
export function sendMessage<TMessageType extends MessageTypesWithNoSubscriptions> (message: TMessageType, request: RequestTypes[TMessageType]): Promise<ResponseTypes[TMessageType]>;
|
||||
export function sendMessage<TMessageType extends MessageTypesWithSubscriptions> (message: TMessageType, request: RequestTypes[TMessageType], subscriber: (data: SubscriptionMessageTypes[TMessageType]) => void): Promise<ResponseTypes[TMessageType]>;
|
||||
|
||||
export function sendMessage<TMessageType extends MessageTypes> (message: TMessageType, request?: RequestTypes[TMessageType], subscriber?: (data: unknown) => void): Promise<ResponseTypes[TMessageType]> {
|
||||
return new Promise((resolve, reject): void => {
|
||||
@@ -79,8 +79,7 @@ export function handleResponse<TMessageType extends MessageTypes> (data: Transpo
|
||||
}
|
||||
|
||||
if (data.subscription) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
(handler.subscriber as Function)(data.subscription);
|
||||
handler.subscriber?.(data.subscription);
|
||||
} else if (data.error) {
|
||||
handler.reject(new Error(data.error));
|
||||
} else {
|
||||
|
||||
@@ -15,10 +15,13 @@ export default class AccountsStore extends BaseStore<KeyringJson> implements Key
|
||||
);
|
||||
}
|
||||
|
||||
// KeyringStore.set returns void and the keyring does not wait on it;
|
||||
// BaseStore.set handles its own failure, so this promise never rejects.
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
public override async set (key: string, value: KeyringJson, update?: () => void): Promise<void> {
|
||||
// shortcut, don't save testing accounts in extension storage
|
||||
if (key.startsWith('account:') && value.meta && value.meta.isTesting) {
|
||||
update && update();
|
||||
if (key.startsWith('account:') && value.meta?.isTesting) {
|
||||
update?.();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user