From f72ba84aac665fe0191397098112f4321cf7787a Mon Sep 17 00:00:00 2001 From: Satoshi Qazi Muhammed Date: Sun, 4 Oct 2026 03:41:54 +0400 Subject: [PATCH] Drop the isElectron flag from the API context Only the Electron renderer ever set isElectron to true; the web entry passed false. With that package gone the flag is constant, so remove it from ApiCtxRoot, the context types and its consumers, together with the pezkuwi.js.org link base it selected. In-browser account storage and the WebUSB ledger option now follow the settings alone, as they already did on the web. Runtime environment detection (getEnvironment, ExternalWarning) reads the user agent and is left as is. Co-Authored-By: Claude Opus 5.5 (1M context) --- packages/apps/src/Root.tsx | 4 +--- packages/apps/src/index.tsx | 2 +- packages/page-accounts/src/Accounts/index.tsx | 6 +++--- .../src/CreateAccount.slow.spec.tsx | 1 - .../page-bounties/src/Bounties.slow.spec.tsx | 1 - packages/page-settings/src/General.tsx | 11 +++-------- packages/react-api/src/Api.tsx | 18 +++++++----------- packages/react-api/src/types.ts | 1 - packages/react-hooks/src/ctx/types.ts | 1 - 9 files changed, 15 insertions(+), 30 deletions(-) diff --git a/packages/apps/src/Root.tsx b/packages/apps/src/Root.tsx index cedd8dc..1b35578 100644 --- a/packages/apps/src/Root.tsx +++ b/packages/apps/src/Root.tsx @@ -16,7 +16,6 @@ import BeforeApiInit from './overlays/BeforeInit.js'; import Apps from './Apps.js'; interface Props { - isElectron: boolean; store?: KeyringStore; } @@ -29,7 +28,7 @@ function createTheme (settings: { uiTheme?: string }): ThemeDef { return { theme }; } -function Root ({ isElectron, store }: Props): React.ReactElement { +function Root ({ store }: Props): React.ReactElement { const [theme, setTheme] = useState(() => createTheme(settings)); useEffect((): void => { @@ -45,7 +44,6 @@ function Root ({ isElectron, store }: Props): React.ReactElement { } - isElectron={isElectron} store={store} > diff --git a/packages/apps/src/index.tsx b/packages/apps/src/index.tsx index 97c48ec..1c99578 100644 --- a/packages/apps/src/index.tsx +++ b/packages/apps/src/index.tsx @@ -21,5 +21,5 @@ if (!rootElement) { } createRoot(rootElement).render( - + ); diff --git a/packages/page-accounts/src/Accounts/index.tsx b/packages/page-accounts/src/Accounts/index.tsx index b8cc033..b317104 100644 --- a/packages/page-accounts/src/Accounts/index.tsx +++ b/packages/page-accounts/src/Accounts/index.tsx @@ -96,7 +96,7 @@ function groupAccounts (accounts: SortedAccount[]): Record function Overview ({ className = '', onStatusChange }: Props): React.ReactElement { const { t } = useTranslation(); - const { api, fork, isElectron } = useApi(); + const { api, fork } = useApi(); const { allAccounts, hasAccounts } = useAccounts(); const { isIpfs } = useIpfs(); const { isLedgerEnabled } = useLedger(); @@ -154,8 +154,8 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen ); const canStoreAccounts = useMemo( - () => isElectron || (!isIpfs && settings.get().storage === 'on'), - [isElectron, isIpfs] + () => !isIpfs && settings.get().storage === 'on', + [isIpfs] ); // We use favorites only to check if it includes some element, diff --git a/packages/page-accounts/src/CreateAccount.slow.spec.tsx b/packages/page-accounts/src/CreateAccount.slow.spec.tsx index 3503ecc..86ff637 100644 --- a/packages/page-accounts/src/CreateAccount.slow.spec.tsx +++ b/packages/page-accounts/src/CreateAccount.slow.spec.tsx @@ -29,7 +29,6 @@ const renderAccounts = () => { diff --git a/packages/page-bounties/src/Bounties.slow.spec.tsx b/packages/page-bounties/src/Bounties.slow.spec.tsx index 3e12c66..e1ae483 100644 --- a/packages/page-bounties/src/Bounties.slow.spec.tsx +++ b/packages/page-bounties/src/Bounties.slow.spec.tsx @@ -31,7 +31,6 @@ const renderBounties = () => { diff --git a/packages/page-settings/src/General.tsx b/packages/page-settings/src/General.tsx index 59315cc..ccdcebd 100644 --- a/packages/page-settings/src/General.tsx +++ b/packages/page-settings/src/General.tsx @@ -19,12 +19,12 @@ interface Props { className?: string; } -const _ledgerConnOptions = settings.availableLedgerConn; +const ledgerConnOptions = settings.availableLedgerConn; const _ledgerAppOptions = settings.availableLedgerApp; function General ({ className = '' }: Props): React.ReactElement { const { t } = useTranslation(); - const { chainSS58, isApiReady, isElectron } = useApi(); + const { chainSS58, isApiReady } = useApi(); const { isIpfs } = useIpfs(); const { hasLedgerChain, hasWebUsb } = useLedger(); // tri-state: null = nothing changed, false = no reload, true = reload required @@ -35,11 +35,6 @@ function General ({ className = '' }: Props): React.ReactElement { return { ...values, uiTheme: values.uiTheme === 'dark' ? 'dark' : 'light' }; }); - const ledgerConnOptions = useMemo( - () => _ledgerConnOptions.filter(({ value }) => !isElectron || value !== 'webusb'), - [isElectron] - ); - const iconOptions = useMemo( () => settings.availableIcons .map((o): Option => createIdenticon(o, ['default'])) @@ -153,7 +148,7 @@ function General ({ className = '' }: Props): React.ReactElement { options={prefixOptions} /> - {!isIpfs && !isElectron && ( + {!isIpfs && ( <>
string { +function makeCreateLink (baseApiUrl: string): (path: string) => string { return (path: string, apiUrl?: string): string => - `${isElectron - ? 'https://pezkuwi.js.org/apps/' - : `${window.location.origin}${window.location.pathname}` - }?rpc=${encodeURIComponent(apiUrl || baseApiUrl)}#${path}`; + `${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(apiUrl || baseApiUrl)}#${path}`; } async function retrieve (api: ApiPromise, injectedPromise: Promise): Promise { @@ -308,7 +304,7 @@ async function createApi (apiUrl: string, signer: ApiSigner, isLocalFork: boolea return { fork: chopsticksFork, types }; } -export function ApiCtxRoot ({ apiUrl, beforeApiInit, children, isElectron, store: keyringStore }: Props): React.ReactElement | null { +export function ApiCtxRoot ({ apiUrl, beforeApiInit, children, store: keyringStore }: Props): React.ReactElement | null { const { queuePayload, queueSetTxStatus } = useQueue(); const [state, setState] = useState(EMPTY_STATE); const [isApiConnected, setIsApiConnected] = useState(false); @@ -341,8 +337,8 @@ export function ApiCtxRoot ({ apiUrl, beforeApiInit, children, isElectron, store const apiCoretime = useApiUrl(coretimeUrls); const apiSystemPeople = useApiUrl(peopleUrls); const createLink = useMemo( - () => makeCreateLink(apiUrl, isElectron), - [apiUrl, isElectron] + () => makeCreateLink(apiUrl), + [apiUrl] ); const enableIdentity = apiEndpoint?.isPeople || // Ensure that teyrchains that don't have isPeopleForIdentity set, can access there own identity pallet. @@ -350,8 +346,8 @@ export function ApiCtxRoot ({ apiUrl, beforeApiInit, children, isElectron, store // Ensure that when isPeopleForIdentity is set to false that it enables the identity pallet access. (typeof apiEndpoint?.isPeopleForIdentity === 'boolean' && !apiEndpoint?.isPeopleForIdentity); const value = useMemo( - () => objectSpread({}, state, { api: statics.api, apiCoretime, apiEndpoint, apiError, apiIdentity: ((apiEndpoint?.isPeopleForIdentity && apiSystemPeople) || statics.api), apiRelay, apiSystemPeople, apiUrl, createLink, enableIdentity, extensions, isApiConnected, isApiInitialized, isElectron, isLocalFork, isWaitingInjected: !extensions }), - [apiError, createLink, extensions, isApiConnected, isApiInitialized, isElectron, isLocalFork, state, apiEndpoint, apiCoretime, apiRelay, apiUrl, apiSystemPeople, enableIdentity] + () => objectSpread({}, state, { api: statics.api, apiCoretime, apiEndpoint, apiError, apiIdentity: ((apiEndpoint?.isPeopleForIdentity && apiSystemPeople) || statics.api), apiRelay, apiSystemPeople, apiUrl, createLink, enableIdentity, extensions, isApiConnected, isApiInitialized, isLocalFork, isWaitingInjected: !extensions }), + [apiError, createLink, extensions, isApiConnected, isApiInitialized, isLocalFork, state, apiEndpoint, apiCoretime, apiRelay, apiUrl, apiSystemPeople, enableIdentity] ); // initial initialization diff --git a/packages/react-api/src/types.ts b/packages/react-api/src/types.ts index af6c9a9..913f307 100644 --- a/packages/react-api/src/types.ts +++ b/packages/react-api/src/types.ts @@ -87,7 +87,6 @@ export interface ApiProps extends ApiState { extensions?: InjectedExtension[]; isApiConnected: boolean; isApiInitialized: boolean; - isElectron: boolean; isWaitingInjected: boolean; isLocalFork?: boolean; } diff --git a/packages/react-hooks/src/ctx/types.ts b/packages/react-hooks/src/ctx/types.ts index 92e78ba..7c1fab4 100644 --- a/packages/react-hooks/src/ctx/types.ts +++ b/packages/react-hooks/src/ctx/types.ts @@ -66,7 +66,6 @@ export interface ApiProps extends ApiState { extensions?: InjectedExtension[]; isApiConnected: boolean; isApiInitialized: boolean; - isElectron: boolean; isWaitingInjected: boolean; isLocalFork?: boolean; }