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) <noreply@anthropic.com>
This commit is contained in:
Satoshi Qazi MuhammedandClaude Opus 5.5 authored and SatoshiQaziMuhammed committed 2026-10-04 04:33:58 +04:00
1 parent d14acff1d3
commit f72ba84aac
9 files changed
+15 -30

No files matched your search

+1 -3
View File
@@ -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<Props> {
function Root ({ store }: Props): React.ReactElement<Props> {
const [theme, setTheme] = useState(() => createTheme(settings));
useEffect((): void => {
@@ -45,7 +44,6 @@ function Root ({ isElectron, store }: Props): React.ReactElement<Props> {
<ApiCtxRoot
apiUrl={settings.apiUrl}
beforeApiInit={<BeforeApiInit />}
isElectron={isElectron}
store={store}
>
<KeyringCtxRoot>
+1 -1
View File
@@ -21,5 +21,5 @@ if (!rootElement) {
}
createRoot(rootElement).render(
<Root isElectron={false} />
<Root />
);
@@ -96,7 +96,7 @@ function groupAccounts (accounts: SortedAccount[]): Record<GroupName, string[]>
function Overview ({ className = '', onStatusChange }: Props): React.ReactElement<Props> {
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,
@@ -29,7 +29,6 @@ const renderAccounts = () => {
<ThemeProvider theme={lightTheme}>
<ApiCtxRoot
apiUrl={`ws://127.0.0.1:${BIZINIKIWI_PORT}`}
isElectron={false}
store={memoryStore}
>
<WaitForApi>
@@ -31,7 +31,6 @@ const renderBounties = () => {
<ThemeProvider theme={lightTheme}>
<ApiCtxRoot
apiUrl={`ws://127.0.0.1:${BIZINIKIWI_PORT}`}
isElectron={false}
store={memoryStore}
>
<WaitForApi>
+3 -8
View File
@@ -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<Props> {
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<Props> {
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<Props> {
options={prefixOptions}
/>
</div>
{!isIpfs && !isElectron && (
{!isIpfs && (
<>
<div className='ui--row'>
<Dropdown
+7 -11
View File
@@ -33,7 +33,6 @@ import { decodeUrlTypes } from './urlTypes.js';
interface Props {
children: React.ReactNode;
apiUrl: string;
isElectron: boolean;
store?: KeyringStore;
beforeApiInit?: React.ReactNode
}
@@ -97,12 +96,9 @@ async function getInjectedAccounts (injectedPromise: Promise<InjectedExtension[]
}
}
function makeCreateLink (baseApiUrl: string, isElectron: boolean): (path: string) => 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<InjectedExtension[]>): Promise<ChainData> {
@@ -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<Props> | null {
export function ApiCtxRoot ({ apiUrl, beforeApiInit, children, store: keyringStore }: Props): React.ReactElement<Props> | null {
const { queuePayload, queueSetTxStatus } = useQueue();
const [state, setState] = useState<ApiState>(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<ApiProps>(
() => 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
-1
View File
@@ -87,7 +87,6 @@ export interface ApiProps extends ApiState {
extensions?: InjectedExtension[];
isApiConnected: boolean;
isApiInitialized: boolean;
isElectron: boolean;
isWaitingInjected: boolean;
isLocalFork?: boolean;
}
-1
View File
@@ -66,7 +66,6 @@ export interface ApiProps extends ApiState {
extensions?: InjectedExtension[];
isApiConnected: boolean;
isApiInitialized: boolean;
isElectron: boolean;
isWaitingInjected: boolean;
isLocalFork?: boolean;
}