mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-10-28 05:19:49 +00:00
Remove the local fork
"Fork Locally" ran the selected chain in the browser through @acala-network/chopsticks-core, which brings its own @polkadot stack (types, rpc-provider, util-crypto 13 and 14) and @polkadot/wasm-crypto 7.5.4 with the crate versions pezkuwi-wasm 7.5.21 moved off. The app shipped that second wasm twice, next to ours, for a developer tool; chopsticks itself stays available from the command line. Gone: the button, the overlay, the "Local" mock-account modal and the chopsticks account group, the fork path in the API context, and their 69 locale strings. Mock accounts a fork left in a browser's keyring are address-only; they now show with the test accounts. yarn.lock: 32 @polkadot and 2 @acala-network entries -> 0.
This commit is contained in:
1 parent
8f49d487dc
commit
b77006ccfc
20 files changed
+35
-1154
No files matched your search
@@ -164,31 +164,11 @@ function loadAffinities (groups: Group[]): Record<string, string> {
|
||||
}), {});
|
||||
}
|
||||
|
||||
function isSwitchDisabled (hasUrlChanged: boolean, apiUrl: string, isUrlValid: boolean, isLocalFork?: boolean): boolean {
|
||||
function isSwitchDisabled (hasUrlChanged: boolean, apiUrl: string, isUrlValid: boolean): boolean {
|
||||
if (!hasUrlChanged) {
|
||||
if (isLocalFork) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (apiUrl.startsWith('light://')) {
|
||||
return false;
|
||||
} else if (isUrlValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isLocalForkDisabled (hasUrlChanged: boolean, apiUrl: string, isUrlValid: boolean, isLocalFork?: boolean): boolean {
|
||||
if (!hasUrlChanged) {
|
||||
if (isLocalFork) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (apiUrl.startsWith('light://')) {
|
||||
return true;
|
||||
} else if (apiUrl.startsWith('light://')) {
|
||||
return false;
|
||||
} else if (isUrlValid) {
|
||||
return false;
|
||||
}
|
||||
@@ -199,7 +179,7 @@ function isLocalForkDisabled (hasUrlChanged: boolean, apiUrl: string, isUrlValid
|
||||
function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const linkOptions = createWsEndpoints(t);
|
||||
const { apiEndpoint, isLocalFork } = useApi();
|
||||
const { apiEndpoint } = useApi();
|
||||
const [favoriteChains, setFavoriteChains] = useState(() => getFavoriteChains());
|
||||
const [groups, setGroups] = useState(() => combineEndpoints(linkOptions));
|
||||
const [{ apiUrl, groupIndex, hasUrlChanged, isUrlValid }, setApiUrl] = useState<UrlState>(() => extractUrlState(settings.get().apiUrl, groups));
|
||||
@@ -297,22 +277,6 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem
|
||||
|
||||
const _onApply = useCallback(
|
||||
(): void => {
|
||||
store.set('localFork', '');
|
||||
settings.set({ ...(settings.get()), apiUrl });
|
||||
window.location.assign(`${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(apiUrl)}${window.location.hash}`);
|
||||
|
||||
if (!hasUrlChanged) {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
onClose();
|
||||
},
|
||||
[apiUrl, onClose, hasUrlChanged]
|
||||
);
|
||||
|
||||
const _onLocalFork = useCallback(
|
||||
(): void => {
|
||||
store.set('localFork', apiUrl);
|
||||
settings.set({ ...(settings.get()), apiUrl });
|
||||
window.location.assign(`${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(apiUrl)}${window.location.hash}`);
|
||||
|
||||
@@ -339,33 +303,19 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem
|
||||
);
|
||||
|
||||
const canSwitch = useMemo(
|
||||
() => isSwitchDisabled(hasUrlChanged, apiUrl, isUrlValid, isLocalFork),
|
||||
[hasUrlChanged, apiUrl, isUrlValid, isLocalFork]
|
||||
);
|
||||
|
||||
const canLocalFork = useMemo(
|
||||
() => isLocalForkDisabled(hasUrlChanged, apiUrl, isUrlValid, isLocalFork),
|
||||
[hasUrlChanged, apiUrl, isUrlValid, isLocalFork]
|
||||
() => isSwitchDisabled(hasUrlChanged, apiUrl, isUrlValid),
|
||||
[hasUrlChanged, apiUrl, isUrlValid]
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledSidebar
|
||||
buttons={
|
||||
<>
|
||||
<Button
|
||||
icon='code-fork'
|
||||
isDisabled={canLocalFork}
|
||||
label={t('Fork Locally')}
|
||||
onClick={_onLocalFork}
|
||||
tooltip='fork-locally-btn'
|
||||
/>
|
||||
<Button
|
||||
icon='sync'
|
||||
isDisabled={canSwitch}
|
||||
label={t('Switch')}
|
||||
onClick={_onApply}
|
||||
/>
|
||||
</>
|
||||
<Button
|
||||
icon='sync'
|
||||
isDisabled={canSwitch}
|
||||
label={t('Switch')}
|
||||
onClick={_onApply}
|
||||
/>
|
||||
}
|
||||
className={className}
|
||||
offset={offset}
|
||||
|
||||
@@ -6,7 +6,6 @@ import React from 'react';
|
||||
import { styled } from '@pezkuwi/react-components';
|
||||
|
||||
import DotApps from './DotApps.js';
|
||||
import LocalFork from './LocalFork.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@@ -15,7 +14,6 @@ interface Props {
|
||||
function Bottom ({ className }: Props): React.ReactElement<Props> | null {
|
||||
return (
|
||||
<StyledDiv className={className}>
|
||||
<LocalFork />
|
||||
<DotApps />
|
||||
</StyledDiv>
|
||||
);
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright 2017-2026 @pezkuwi/apps authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { useApi } from '@pezkuwi/react-hooks';
|
||||
|
||||
import { useTranslation } from '../translate.js';
|
||||
import BaseOverlay from './Base.js';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function LocalFork ({ className }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const { isLocalFork } = useApi();
|
||||
|
||||
if (isLocalFork) {
|
||||
return (
|
||||
<BaseOverlay
|
||||
className={className}
|
||||
icon='link'
|
||||
isBottom
|
||||
isFull
|
||||
type='info'
|
||||
>
|
||||
<div>
|
||||
{t('Local fork powered by ')}
|
||||
<a
|
||||
href='https://github.com/AcalaNetwork/chopsticks'
|
||||
rel='noreferrer'
|
||||
target='_blank'
|
||||
>
|
||||
Chopsticks
|
||||
</a>
|
||||
.
|
||||
</div>
|
||||
</BaseOverlay>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default React.memo(LocalFork);
|
||||
Reference in new issue
Block a user