Cleanup WebPack (#4258)

* Remove unused WP5 override

* Adjust

* Additional imports

* Adjust
This commit is contained in:
Jaco Greeff 2020-12-21 13:15:40 +01:00 committed by GitHub
parent cdf006198a
commit 93b38ece21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 136 additions and 169 deletions

View File

@ -43,8 +43,6 @@
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"style-loader": "^2.0.0",
"thread-loader": "^3.0.1",
"url-loader": "^4.1.1",
"webpack": "^5.10.1",
"webpack-cli": "^4.2.0",

View File

@ -14,7 +14,7 @@ import styled from 'styled-components';
import { createWsEndpoints, CUSTOM_ENDPOINT_KEY } from '@polkadot/apps-config';
import { Button, Input, Sidebar } from '@polkadot/react-components';
import uiSettings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import { isAscii } from '@polkadot/util';
import { useTranslation } from '../translate';
@ -97,7 +97,7 @@ function extractUrlState (apiUrl: string, groups: Group[]): UrlState {
return {
apiUrl,
groupIndex,
hasUrlChanged: uiSettings.get().apiUrl !== apiUrl,
hasUrlChanged: settings.get().apiUrl !== apiUrl,
isUrlValid: isValidUrl(apiUrl)
};
}
@ -122,7 +122,7 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem
const { t } = useTranslation();
const linkOptions = createWsEndpoints(t);
const [groups, setGroups] = useState(combineEndpoints(linkOptions));
const [{ apiUrl, groupIndex, hasUrlChanged, isUrlValid }, setApiUrl] = useState<UrlState>(extractUrlState(uiSettings.get().apiUrl, groups));
const [{ apiUrl, groupIndex, hasUrlChanged, isUrlValid }, setApiUrl] = useState<UrlState>(extractUrlState(settings.get().apiUrl, groups));
const [storedCustomEndpoints, setStoredCustomEndpoints] = useState<string[]>(getCustomEndpoints());
const [affinities, setAffinities] = useState(loadAffinities(groups));
@ -215,7 +215,7 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem
const _onApply = useCallback(
(): void => {
uiSettings.set({ ...(uiSettings.get()), apiUrl });
settings.set({ ...(settings.get()), apiUrl });
window.location.assign(`${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(apiUrl)}${window.location.hash}`);
// window.location.reload();

View File

@ -11,7 +11,7 @@ import { ThemeProvider } from 'styled-components';
import { Api } from '@polkadot/react-api';
import Queue from '@polkadot/react-components/Status/Queue';
import { BlockAuthors, Events } from '@polkadot/react-query';
import settings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import Apps from './Apps';
import { darkTheme, lightTheme } from './themes';

View File

@ -6,7 +6,7 @@ import store from 'store';
import { createWsEndpoints } from '@polkadot/apps-config';
import { extractIpfsDetails } from '@polkadot/react-hooks/useIpfs';
import settings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import { assert } from '@polkadot/util';
function getApiUrl (): string {

View File

@ -4,7 +4,7 @@
import React from 'react';
import { useApi } from '@polkadot/react-hooks';
import settings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import { useTranslation } from '../translate';
import BaseOverlay from './Base';

View File

@ -59,28 +59,11 @@ function createWebpack (ENV, context) {
test: /\.mjs$/,
type: 'javascript/auto'
},
{
exclude: /(node_modules)/,
test: /\.css$/,
use: [
isProd
? MiniCssExtractPlugin.loader
: require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1
}
}
]
},
{
include: /node_modules/,
test: /\.css$/,
use: [
isProd
? MiniCssExtractPlugin.loader
: require.resolve('style-loader'),
MiniCssExtractPlugin.loader,
require.resolve('css-loader')
]
},
@ -88,7 +71,6 @@ function createWebpack (ENV, context) {
exclude: /(node_modules)/,
test: /\.(js|mjs|ts|tsx)$/,
use: [
require.resolve('thread-loader'),
{
loader: require.resolve('babel-loader'),
options: require('@polkadot/dev/config/babel-config-webpack.cjs')

View File

@ -11,7 +11,7 @@
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/react-components": "^0.72.2-0",
"@polkadot/vanitygen": "^0.25.1",
"@polkadot/vanitygen": "^0.25.2-0",
"detect-browser": "^5.2.0",
"file-saver": "^2.0.5"
},

View File

@ -18,7 +18,7 @@ import { ApiPromise } from '@polkadot/api';
import { getLedger } from '@polkadot/react-api';
import { AddressInfo, AddressMini, AddressSmall, Badge, Button, ChainLock, CryptoType, Forget, Icon, IdentityIcon, LinkExternal, Menu, Popup, StatusContext, Tags } from '@polkadot/react-components';
import { useAccountInfo, useApi, useCall, useToggle } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { BN_ZERO, formatBalance, formatNumber } from '@polkadot/util';
import Backup from '../modals/Backup';

View File

@ -10,7 +10,7 @@ import styled from 'styled-components';
import { Button, Dropdown, Input, Table } from '@polkadot/react-components';
import { useApi, useIsMountedRef } from '@polkadot/react-hooks';
import uiSettings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import generator from '@polkadot/vanitygen/generator';
import matchRegex from '@polkadot/vanitygen/regex';
import generatorSort from '@polkadot/vanitygen/sort';
@ -213,7 +213,7 @@ function VanityApp ({ className = '', onStatusChange }: Props): React.ReactEleme
help={t<string>('Determines what cryptography will be used to create this account. Note that to validate on Polkadot, the session account must use "ed25519".')}
label={t<string>('keypair crypto type')}
onChange={setType}
options={isEthereum ? uiSettings.availableCryptosEth : uiSettings.availableCryptos}
options={isEthereum ? settings.availableCryptosEth : settings.availableCryptos}
/>
</div>
<Button.Group>

View File

@ -5,7 +5,7 @@ import FileSaver from 'file-saver';
import React, { useCallback, useState } from 'react';
import { AddressRow, Button, Modal, Password } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate';

View File

@ -4,7 +4,7 @@
import React, { useCallback, useState } from 'react';
import { AddressRow, Button, Modal, Password, PasswordStrength } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate';

View File

@ -14,8 +14,8 @@ import { DEV_PHRASE } from '@polkadot/keyring/defaults';
import { getEnvironment } from '@polkadot/react-api/util';
import { AddressRow, Button, Checkbox, CopyButton, Dropdown, Expander, Input, InputAddress, Modal, TextArea } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import uiSettings from '@polkadot/ui-settings';
import { keyring } from '@polkadot/ui-keyring';
import { settings } from '@polkadot/ui-settings';
import { isHex, u8aToHex } from '@polkadot/util';
import { keyExtractSuri, mnemonicGenerate, mnemonicValidate, randomAsU8a } from '@polkadot/util-crypto';
@ -344,7 +344,7 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ
help={t<string>('Determines what cryptography will be used to create this account. Note that to validate on Polkadot, the session account must use "ed25519".')}
label={t<string>('keypair crypto type')}
onChange={_onChangePairType}
options={isEthereum ? uiSettings.availableCryptosEth : uiSettings.availableCryptos}
options={isEthereum ? settings.availableCryptosEth : settings.availableCryptos}
tabIndex={-1}
/>
</Modal.Column>

View File

@ -9,7 +9,7 @@ import React, { useCallback, useContext, useEffect, useState } from 'react';
import { AddressRow, Button, Input, InputAddress, Modal, Password, StatusContext } from '@polkadot/react-components';
import { useApi, useDebounce, useToggle } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { keyExtractPath } from '@polkadot/util-crypto';
import { useTranslation } from '../translate';

View File

@ -9,7 +9,7 @@ import React, { useCallback, useMemo, useState } from 'react';
import { AddressRow, Button, InputAddress, InputFile, Modal, Password } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { u8aToString } from '@polkadot/util';
import { useTranslation } from '../translate';

View File

@ -5,7 +5,7 @@ import React, { useCallback, useRef, useState } from 'react';
import { getLedger } from '@polkadot/react-api';
import { Button, Dropdown, Modal } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate';

View File

@ -9,7 +9,7 @@ import React, { useCallback, useState } from 'react';
import { Button, Input, InputAddressMulti, InputNumber, Modal } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import useKnownAddresses from '../Accounts/useKnownAddresses';
import { useTranslation } from '../translate';

View File

@ -4,7 +4,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import { Modal, Password, PasswordStrength } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate';

View File

@ -8,7 +8,7 @@ import React, { useCallback, useState } from 'react';
import { Button, Input, InputAddressSimple, Modal } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import useProxies from '../Accounts/useProxies';
import { useTranslation } from '../translate';

View File

@ -9,7 +9,7 @@ import styled from 'styled-components';
import { AddressRow, Button, Input, InputAddress, Modal, QrScanAddress } from '@polkadot/react-components';
import { useApi, useIpfs } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate';
import PasswordInput from './PasswordInput';

View File

@ -7,7 +7,7 @@ import type { SortedAccount } from './types';
import React from 'react';
import { Menu } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
export function createMenuGroup (items: (React.ReactNode | false | undefined | null)[]): React.ReactNode | null {
const filtered = items.filter((item): item is React.ReactNode => !!item);

View File

@ -12,7 +12,7 @@ import styled, { ThemeContext } from 'styled-components';
import Transfer from '@polkadot/app-accounts/modals/Transfer';
import { AddressInfo, AddressSmall, Button, ChainLock, Forget, Icon, LinkExternal, Menu, Popup, Tags } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { BN_ZERO, formatNumber } from '@polkadot/util';
import { useTranslation } from '../translate';

View File

@ -9,7 +9,7 @@ import React, { useCallback, useState } from 'react';
import { AddressRow, Button, Input, InputAddress, Modal } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { hexToU8a } from '@polkadot/util';
import { ethereumEncode } from '@polkadot/util-crypto';

View File

@ -7,7 +7,7 @@ import type { SortedAccount } from './types';
import React from 'react';
import { Menu } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
export function createMenuGroup (items: (React.ReactNode | false | undefined | null)[]): React.ReactNode | null {
const filtered = items.filter((item): item is React.ReactNode => !!item);

View File

@ -7,7 +7,7 @@ import React, { useCallback, useState } from 'react';
import { AddressRow, Button, Input, Modal } from '@polkadot/react-components';
import { useApi, useNonEmptyString } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { ABI, InputName } from '../shared';
import { useTranslation } from '../translate';

View File

@ -13,7 +13,7 @@ import { ContractPromise } from '@polkadot/api-contract';
import { AddressInfo, AddressMini, Button, Forget } from '@polkadot/react-components';
import { useApi, useCall, useToggle } from '@polkadot/react-hooks';
import { BlockToTime } from '@polkadot/react-query';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { formatNumber, isFunction, isUndefined } from '@polkadot/util';
import Messages from '../shared/Messages';

View File

@ -8,7 +8,7 @@ import React, { useEffect, useState } from 'react';
import { InfoForInput } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate';

View File

@ -11,7 +11,7 @@ import { BlueprintPromise } from '@polkadot/api-contract';
import { Dropdown, Input, InputAddress, InputBalance, Modal, Toggle, TxButton } from '@polkadot/react-components';
import { useApi, useFormField, useNonEmptyString, useNonZeroBn } from '@polkadot/react-hooks';
import { Available } from '@polkadot/react-query';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { isHex } from '@polkadot/util';
import { randomAsHex } from '@polkadot/util-crypto';

View File

@ -2,13 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import type { Option } from '@polkadot/apps-config/settings/types';
import type { SettingsStruct } from '@polkadot/ui-settings/types';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { createLanguages, createSs58 } from '@polkadot/apps-config';
import { isLedgerCapable } from '@polkadot/react-api';
import { Button, Dropdown } from '@polkadot/react-components';
import uiSettings, { SettingsStruct } from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import { useTranslation } from './translate';
import { createIdenticon, createOption, save, saveAndReload } from './util';
@ -17,20 +18,20 @@ interface Props {
className?: string;
}
const ledgerConnOptions = uiSettings.availableLedgerConn;
const ledgerConnOptions = settings.availableLedgerConn;
function General ({ className = '' }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
// tri-state: null = nothing changed, false = no reload, true = reload required
const [changed, setChanged] = useState<boolean | null>(null);
const [settings, setSettings] = useState((): SettingsStruct => {
const settings = uiSettings.get();
const [state, setSettings] = useState((): SettingsStruct => {
const values = settings.get();
return { ...settings, uiTheme: settings.uiTheme === 'dark' ? 'dark' : 'light' };
return { ...values, uiTheme: values.uiTheme === 'dark' ? 'dark' : 'light' };
});
const iconOptions = useMemo(
() => uiSettings.availableIcons
() => settings.availableIcons
.map((o): Option => createIdenticon(o, ['default']))
.concat(createIdenticon({ info: 'robohash', text: 'RoboHash', value: 'robohash' })),
[]
@ -55,37 +56,37 @@ function General ({ className = '' }: Props): React.ReactElement<Props> {
);
useEffect((): void => {
const prev = uiSettings.get() as unknown as Record<string, unknown>;
const hasChanges = Object.entries(settings).some(([key, value]) => prev[key] !== value);
const needsReload = prev.apiUrl !== settings.apiUrl || prev.prefix !== settings.prefix;
const prev = settings.get() as unknown as Record<string, unknown>;
const hasChanges = Object.entries(state).some(([key, value]) => prev[key] !== value);
const needsReload = prev.apiUrl !== state.apiUrl || prev.prefix !== state.prefix;
setChanged(
hasChanges
? needsReload
: null
);
}, [settings]);
}, [state]);
const _handleChange = useCallback(
(key: keyof SettingsStruct) => <T extends string | number>(value: T) =>
setSettings((settings) => ({ ...settings, [key]: value })),
setSettings((state) => ({ ...state, [key]: value })),
[]
);
const _saveAndReload = useCallback(
() => saveAndReload(settings),
[settings]
() => saveAndReload(state),
[state]
);
const _save = useCallback(
(): void => {
save(settings);
save(state);
setChanged(null);
},
[settings]
[state]
);
const { i18nLang, icon, ledgerConn, prefix, uiTheme } = settings;
const { i18nLang, icon, ledgerConn, prefix, uiTheme } = state;
return (
<div className={className}>

View File

@ -9,7 +9,7 @@ import { Button, Columar, Column, Dropdown, Progress, Spinner, Toggle } from '@p
import i18n from '@polkadot/react-components/i18n';
import languageCache from '@polkadot/react-components/i18n/cache';
import { useToggle } from '@polkadot/react-hooks';
import uiSettings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import { useTranslation } from '../translate';
import StringInput from './StringInput';
@ -165,8 +165,8 @@ function Translate ({ className }: Props): React.ReactElement<Props> {
useEffect((): void => {
setLng(
keys.some(({ value }) => value === uiSettings.i18nLang)
? uiSettings.i18nLang
keys.some(({ value }) => value === settings.i18nLang)
? settings.i18nLang
: 'zh'
);
}, [keys]);

View File

@ -1,6 +1,7 @@
// Copyright 2017-2020 @polkadot/app-settings authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { NetworkSpecsStruct } from '@polkadot/ui-settings/types';
import type { ChainInfo } from '../types';
import React, { useCallback, useEffect, useReducer, useState } from 'react';
@ -8,7 +9,6 @@ import styled from 'styled-components';
import { Button, ChainImg, Columar, Column, Input, QrNetworkSpecs, Spinner } from '@polkadot/react-components';
import { useApi, useDebounce } from '@polkadot/react-hooks';
import { NetworkSpecsStruct } from '@polkadot/ui-settings';
import { useTranslation } from '../translate';
import ChainColorIndicator from './ChainColorIndicator';

View File

@ -7,7 +7,7 @@ import type { SettingsStruct } from '@polkadot/ui-settings/types';
import React from 'react';
import { ChainImg, Dropdown, IdentityIcon } from '@polkadot/react-components';
import uiSettings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
export function createOption ({ info, isHeader, text, value }: Option, overrides: string[] = [], override = 'empty'): Option | React.ReactNode {
if (isHeader) {
@ -73,12 +73,12 @@ export function createIdenticon ({ info, text, value }: Option, overrides: strin
};
}
export function save (settings: SettingsStruct): void {
uiSettings.set(settings);
export function save (state: SettingsStruct): void {
settings.set(state);
}
export function saveAndReload (settings: SettingsStruct): void {
save(settings);
export function saveAndReload (state: SettingsStruct): void {
save(state);
// HACK This is terrible, but since the API needs to re-connect and
// the API does not yet handle re-connections properly, it is what it is

View File

@ -10,7 +10,7 @@ import styled from 'styled-components';
import { web3FromSource } from '@polkadot/extension-dapp';
import { Button, Input, InputAddress, Output, Static } from '@polkadot/react-components';
import { useToggle } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { hexToU8a, isFunction, isHex, stringToHex, stringToU8a, u8aToHex } from '@polkadot/util';
import { useTranslation } from './translate';

View File

@ -8,8 +8,8 @@ import styled from 'styled-components';
import { Badge, Dropdown, Input, InputAddress, Static } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import uiSettings from '@polkadot/ui-settings';
import { keyring } from '@polkadot/ui-keyring';
import { settings } from '@polkadot/ui-settings';
import { isHex } from '@polkadot/util';
import { signatureVerify } from '@polkadot/util-crypto';
@ -28,7 +28,7 @@ function Verify ({ className = '' }: Props): React.ReactElement {
const [{ data, isHexData }, setData] = useState<{ data: string; isHexData: boolean }>({ data: '', isHexData: false });
const [{ isValidPk, publicKey }, setPublicKey] = useState<{ isValidPk: boolean; publicKey: Uint8Array | null }>({ isValidPk: false, publicKey: null });
const [{ isValidSignature, signature }, setSignature] = useState<{ isValidSignature: boolean; signature: string }>({ isValidSignature: false, signature: '' });
const [cryptoOptions] = useState([{ text: t<string>('Crypto not detected'), value: 'unknown' }].concat(uiSettings.availableCryptos as any[]));
const [cryptoOptions] = useState([{ text: t<string>('Crypto not detected'), value: 'unknown' }].concat(settings.availableCryptos as any[]));
useEffect((): void => {
let cryptoType: CryptoTypes = 'unknown';

View File

@ -6,7 +6,7 @@ import type { KeypairType } from '@polkadot/util-crypto/types';
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import { Button, Dropdown, Input, Modal, StatusContext } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { assert, u8aToHex } from '@polkadot/util';
import { keyExtractSuri, mnemonicValidate } from '@polkadot/util-crypto';

View File

@ -17,8 +17,8 @@ import { TokenUnit } from '@polkadot/react-components/InputNumber';
import { StatusContext } from '@polkadot/react-components/Status';
import ApiSigner from '@polkadot/react-signer/signers/ApiSigner';
import { WsProvider } from '@polkadot/rpc-provider';
import keyring from '@polkadot/ui-keyring';
import uiSettings from '@polkadot/ui-settings';
import { keyring } from '@polkadot/ui-keyring';
import { settings } from '@polkadot/ui-settings';
import { formatBalance, isTestChain } from '@polkadot/util';
import { setSS58Format } from '@polkadot/util-crypto';
import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
@ -122,9 +122,9 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise<InjectedExten
async function loadOnReady (api: ApiPromise, injectedPromise: Promise<InjectedExtension[]>, store: KeyringStore | undefined, types: Record<string, Record<string, string>>): Promise<ApiState> {
registry.register(types);
const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise);
const ss58Format = uiSettings.prefix === -1
const ss58Format = settings.prefix === -1
? properties.ss58Format.unwrapOr(DEFAULT_SS58).toNumber()
: uiSettings.prefix;
: settings.prefix;
const tokenSymbol = properties.tokenSymbol.unwrapOr(undefined)?.toString();
const tokenDecimals = properties.tokenDecimals.unwrapOr(DEFAULT_DECIMALS).toNumber();
const isEthereum = ethereumNetworks.includes(api.runtimeVersion.specName.toString());

View File

@ -4,7 +4,7 @@
import { unzlibSync, zlibSync } from 'fflate';
import queryString from 'query-string';
import uiSettings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import { assert, stringToU8a, u8aToString } from '@polkadot/util';
import { base64Decode, base64Encode } from '@polkadot/util-crypto';
@ -33,5 +33,5 @@ export function encodeUrlTypes (types: Record<string, any>): string {
const compressed = zlibSync(jsonU8a, { level: 9 });
const encoded = base64Encode(compressed);
return `${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(uiSettings.apiUrl)}&types=${encodeURIComponent(encoded)}`;
return `${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(settings.apiUrl)}&types=${encodeURIComponent(encoded)}`;
}

View File

@ -14,11 +14,11 @@
"@fortawesome/react-fontawesome": "^0.1.13",
"@polkadot/keyring": "^5.1.1",
"@polkadot/react-api": "^0.72.2-0",
"@polkadot/react-identicon": "^0.63.2-4",
"@polkadot/react-qr": "^0.63.2-4",
"@polkadot/react-identicon": "^0.64.1",
"@polkadot/react-qr": "^0.64.1",
"@polkadot/react-query": "^0.72.2-0",
"@polkadot/ui-keyring": "^0.63.2-4",
"@polkadot/ui-settings": "^0.63.2-4",
"@polkadot/ui-keyring": "^0.64.1",
"@polkadot/ui-settings": "^0.64.1",
"@polkadot/util": "^5.1.1",
"@polkadot/util-crypto": "^5.1.1",
"chart.js": "^2.9.4",

View File

@ -5,7 +5,7 @@ import type { AccountId, AccountIndex, Address } from '@polkadot/types/interface
import React, { useEffect, useState } from 'react';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
interface Props {
accountId: AccountId | AccountIndex | Address | string | Uint8Array | null;

View File

@ -9,7 +9,7 @@ import styled from 'styled-components';
import { getSystemIcon } from '@polkadot/apps-config';
import { useApi } from '@polkadot/react-hooks';
import BaseIdentityIcon from '@polkadot/react-identicon';
import uiSettings from '@polkadot/ui-settings';
import { settings } from '@polkadot/ui-settings';
import StatusContext from '../Status/Context';
import { useTranslation } from '../translate';
@ -24,7 +24,7 @@ interface Props {
}
export function getIdentityTheme (systemName: string): 'substrate' {
return ((uiSettings.icon === 'default' && getSystemIcon(systemName)) || uiSettings.icon) as 'substrate';
return ((settings.icon === 'default' && getSystemIcon(systemName)) || settings.icon) as 'substrate';
}
function IdentityIcon ({ className = '', prefix, size = 24, theme, value }: Props): React.ReactElement<Props> {

View File

@ -9,7 +9,7 @@ import store from 'store';
import styled from 'styled-components';
import { withMulti, withObservable } from '@polkadot/react-api/hoc';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { createOptionItem } from '@polkadot/ui-keyring/options/item';
import { isNull, isUndefined } from '@polkadot/util';

View File

@ -5,7 +5,7 @@ import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
import uiSettings, { LANGUAGE_DEFAULT } from '@polkadot/ui-settings';
import { LANGUAGE_DEFAULT, settings } from '@polkadot/ui-settings';
import Backend from './Backend';
@ -13,7 +13,7 @@ const languageDetector = new LanguageDetector();
languageDetector.addDetector({
lookup: () => {
const i18nLang = uiSettings.i18nLang;
const i18nLang = settings.i18nLang;
return i18nLang === LANGUAGE_DEFAULT
? undefined
@ -82,7 +82,7 @@ i18next
console.log('i18n: failure', error)
);
uiSettings.on('change', (settings): void => {
settings.on('change', (settings): void => {
i18next.changeLanguage(
settings.i18nLang === LANGUAGE_DEFAULT
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access

View File

@ -4,7 +4,7 @@
import type { DeriveAccountInfo } from '@polkadot/api-derive/types';
import { ApiPromise } from '@polkadot/api';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
export default function checkVisibility (api: ApiPromise, address: string, accountInfo: DeriveAccountInfo, filterName = '', onlyNamed = false): boolean {
let isVisible = false;

View File

@ -3,7 +3,7 @@
import type { KeyringItemType, KeyringJson$Meta } from '@polkadot/ui-keyring/types';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
export default function getAddressMeta (address: string, type: KeyringItemType | null = null): KeyringJson$Meta {
let meta: KeyringJson$Meta | undefined;

View File

@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { assert, hexToU8a, isHex } from '@polkadot/util';
import { ethereumEncode } from '@polkadot/util-crypto';

View File

@ -7,7 +7,7 @@ import type { AddressFlags, AddressIdentity, UseAccountInfo } from './types';
import { useCallback, useEffect, useState } from 'react';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useAccounts } from './useAccounts';
import { useAddresses } from './useAddresses';

View File

@ -3,7 +3,7 @@
import { useEffect, useState } from 'react';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useIsMountedRef } from './useIsMountedRef';

View File

@ -3,7 +3,7 @@
import { useEffect, useState } from 'react';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useIsMountedRef } from './useIsMountedRef';

View File

@ -3,7 +3,7 @@
import { useEffect, useState } from 'react';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useIsMountedRef } from './useIsMountedRef';

View File

@ -3,7 +3,7 @@
import { useEffect, useState } from 'react';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
interface PasswordProps {
password: string;

View File

@ -6,7 +6,7 @@ import type { Props } from '../types';
import React, { useCallback, useState } from 'react';
import { InputAddress } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import Bare from './Bare';

View File

@ -7,7 +7,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import styled from 'styled-components';
import { Modal, Password, Toggle } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from './translate';
import { UNLOCK_MINS } from './util';

View File

@ -16,7 +16,7 @@ import { ApiPromise } from '@polkadot/api';
import { web3FromSource } from '@polkadot/extension-dapp';
import { Button, ErrorBoundary, Modal, Output, StatusContext, Toggle } from '@polkadot/react-components';
import { useApi, useToggle } from '@polkadot/react-hooks';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
import { assert, BN_ZERO } from '@polkadot/util';
import Address from './Address';

View File

@ -6,7 +6,7 @@ import type { QueueTx, QueueTxMessageSetStatus, QueueTxStatus } from '@polkadot/
import type { AddressFlags } from './types';
import { SubmittableResult } from '@polkadot/api';
import keyring from '@polkadot/ui-keyring';
import { keyring } from '@polkadot/ui-keyring';
const NOOP = () => undefined;

102
yarn.lock
View File

@ -1998,7 +1998,7 @@ __metadata:
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/react-components": ^0.72.2-0
"@polkadot/vanitygen": ^0.25.1
"@polkadot/vanitygen": ^0.25.2-0
"@testing-library/react": ^11.2.2
detect-browser: ^5.2.0
file-saver: ^2.0.5
@ -2303,8 +2303,6 @@ __metadata:
punycode: ^2.1.1
query-string: ^6.13.7
stream-browserify: ^3.0.0
style-loader: ^2.0.0
thread-loader: ^3.0.1
url-loader: ^4.1.1
webpack: ^5.10.1
webpack-cli: ^4.2.0
@ -2446,9 +2444,9 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/ledger-transports@npm:0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/ledger-transports@npm:0.63.2-4"
"@polkadot/ledger-transports@npm:0.64.1":
version: 0.64.1
resolution: "@polkadot/ledger-transports@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
"@ledgerhq/hw-transport-node-hid-singleton": ^5.36.0
@ -2456,21 +2454,21 @@ __metadata:
dependenciesMeta:
"@ledgerhq/hw-transport-node-hid-singleton":
optional: true
checksum: 40242dfc7d9838f8cb9f4499b35a64e40e145268317e7a44660dd6b1ce145656992d192c8bf6ab9a9926875773727f7e782114e79d30bed6c926c0f24d0221a6
checksum: d59fbad8f109471041682b75870845912ceb9b69a9f4c74c3ed8c0e1b8c49c610196ee3442692faaca6f1629ee8e5cbacede05d52d487be32afd6fcfbbb90a18
languageName: node
linkType: hard
"@polkadot/ledger@npm:^0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/ledger@npm:0.63.2-4"
"@polkadot/ledger@npm:^0.64.1":
version: 0.64.1
resolution: "@polkadot/ledger@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/ledger-transports": 0.63.2-4
"@polkadot/ledger-transports": 0.64.1
"@polkadot/util": ^5.1.1
"@zondax/ledger-polkadot": ^0.12.0
peerDependencies:
"@polkadot/util": "*"
checksum: 6d57441f085f591a3fd2338e0398fc5947beb476959da2b498669a14c2a75397a89cff4fb104418069b200e5e5066d10bbc770a581281fec4b0dd222ae61545e
checksum: 48b6d69c45c93a06f317d5a467e70d054af80fc76933168f1b3c612f748f88f3b951734bda82bd25b497da880be92099bb9f9bb5ddae377547ae43b3c1208797
languageName: node
linkType: hard
@ -2519,11 +2517,11 @@ __metadata:
"@fortawesome/react-fontawesome": ^0.1.13
"@polkadot/keyring": ^5.1.1
"@polkadot/react-api": ^0.72.2-0
"@polkadot/react-identicon": ^0.63.2-4
"@polkadot/react-qr": ^0.63.2-4
"@polkadot/react-identicon": ^0.64.1
"@polkadot/react-qr": ^0.64.1
"@polkadot/react-query": ^0.72.2-0
"@polkadot/ui-keyring": ^0.63.2-4
"@polkadot/ui-settings": ^0.63.2-4
"@polkadot/ui-keyring": ^0.64.1
"@polkadot/ui-settings": ^0.64.1
"@polkadot/util": ^5.1.1
"@polkadot/util-crypto": ^5.1.1
"@types/codeflask": ^1.4.2
@ -2560,14 +2558,14 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/react-identicon@npm:^0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/react-identicon@npm:0.63.2-4"
"@polkadot/react-identicon@npm:^0.64.1":
version: 0.64.1
resolution: "@polkadot/react-identicon@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/keyring": ^5.1.1
"@polkadot/ui-settings": 0.63.2-4
"@polkadot/ui-shared": 0.63.2-4
"@polkadot/ui-settings": 0.64.1
"@polkadot/ui-shared": 0.64.1
"@polkadot/util": ^5.1.1
"@polkadot/util-crypto": ^5.1.1
color: ^3.1.3
@ -2583,7 +2581,7 @@ __metadata:
react-dom: "*"
react-is: "*"
styled-components: "*"
checksum: df3f9a948dcbd8b048430d9f9a1b64a77e6d60494128e33e9402d9d4e8fb9b7f84913b40010e9f15bcc9e963840be004e81ff64322228c2fee9501070ffcf6da
checksum: f9395e3a6e258ba2514e7bdefec0af7f5d6f4c2756b7bd63390ba000274f71e8a42fe9878b49003cafcf0012730c4d8f2b4848ecffd42271f398d1bd88116ab5
languageName: node
linkType: hard
@ -2596,9 +2594,9 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/react-qr@npm:^0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/react-qr@npm:0.63.2-4"
"@polkadot/react-qr@npm:^0.64.1":
version: 0.64.1
resolution: "@polkadot/react-qr@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/util": ^5.1.1
@ -2612,7 +2610,7 @@ __metadata:
react: "*"
react-dom: "*"
styled-components: "*"
checksum: c451e98d4640c5cfc0f542b92b767f7a917a3dfc6743586e5fed5266d00a53f1ba25a67b491ed4448096fcbd10cf20206465cc9343da7be8fdd11bda88dd1b15
checksum: 099b51cf3aff3ce97aee8015222afc26a5356a87540e28f2b22cf472b0b4177e4124598cbb23eda788c24506d22167d97ffd2ff6ab64b2ea2fe83431d56bb64e
languageName: node
linkType: hard
@ -2699,14 +2697,14 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/ui-keyring@npm:^0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/ui-keyring@npm:0.63.2-4"
"@polkadot/ui-keyring@npm:^0.64.1":
version: 0.64.1
resolution: "@polkadot/ui-keyring@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/keyring": ^5.1.1
"@polkadot/ledger": ^0.63.2-4
"@polkadot/ui-settings": 0.63.2-4
"@polkadot/ledger": ^0.64.1
"@polkadot/ui-settings": 0.64.1
"@polkadot/util": ^5.1.1
"@polkadot/x-rxjs": ^3.1.1
mkdirp: ^1.0.4
@ -2715,13 +2713,13 @@ __metadata:
"@polkadot/keyring": "*"
"@polkadot/ui-settings": "*"
"@polkadot/util": "*"
checksum: c3be6b622bc33f15030004f0be8269bf9dc6144c84db7db3613ba2dbb2d95837e4ad9d63a2e015749ddf9bf53c684002da8e1ca47e20597bf8755e4ded6973d6
checksum: bda734c6e73724d5eedfe9cb8b8fef99bbfe06a7a1102c9547de6fe6a6f207776b5126fb0828fceed2b5fa0e7b5d0c9d7e7e2bcd59c58c3543af425c3538cef7
languageName: node
linkType: hard
"@polkadot/ui-settings@npm:0.63.2-4, @polkadot/ui-settings@npm:^0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/ui-settings@npm:0.63.2-4"
"@polkadot/ui-settings@npm:0.64.1, @polkadot/ui-settings@npm:^0.64.1":
version: 0.64.1
resolution: "@polkadot/ui-settings@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
"@polkadot/networks": ^5.1.1
@ -2731,20 +2729,20 @@ __metadata:
peerDependencies:
"@polkadot/networks": "*"
"@polkadot/util": "*"
checksum: a36df2c2aebfc2841e5d989613218cfbfacda0f0aae7ae841c96c999c2611261fae902cb469be8c015444c9c85fed77ea1c912b30a66bff763bc3973db1f67c8
checksum: 7eb83aa13eca8916b2fc73c5efd061ffbfed7dd569a9b53eff060dfa405e216b161bc2c520181f3eddb561452c78b237f9d8226d0fab1adc37cf8b01d7520a71
languageName: node
linkType: hard
"@polkadot/ui-shared@npm:0.63.2-4":
version: 0.63.2-4
resolution: "@polkadot/ui-shared@npm:0.63.2-4"
"@polkadot/ui-shared@npm:0.64.1":
version: 0.64.1
resolution: "@polkadot/ui-shared@npm:0.64.1"
dependencies:
"@babel/runtime": ^7.12.5
color: ^3.1.3
peerDependencies:
"@polkadot/util": "*"
"@polkadot/util-crypto": "*"
checksum: 3164c001901acde41485a9ca4eca70115dbd1087a338ee0c4a2e0b5ecbb0b690d5ea1ef9fa0331fd59a6d004b3c0d2a1f59d8df32817c670cbfc6a4f25cad8f1
checksum: 308b613ea809f72d8af3b29fade2ade765c154c7308a90be7c7752d6006074df1998049ec5c0bf89421901cca6ae7e7b3daf7680249c89da67c5690b76c69c18
languageName: node
linkType: hard
@ -2788,20 +2786,20 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/vanitygen@npm:^0.25.1":
version: 0.25.1
resolution: "@polkadot/vanitygen@npm:0.25.1"
"@polkadot/vanitygen@npm:^0.25.2-0":
version: 0.25.2-0
resolution: "@polkadot/vanitygen@npm:0.25.2-0"
dependencies:
"@babel/core": ^7.12.10
"@babel/register": ^7.12.10
"@babel/runtime": ^7.12.5
"@polkadot/util": ^5.0.1
"@polkadot/util-crypto": ^5.0.1
"@polkadot/util": ^5.1.1
"@polkadot/util-crypto": ^5.1.1
chalk: ^4.1.0
yargs: ^16.2.0
bin:
polkadot-js-vanitygen: index.js
checksum: fe80cac368c1fbf6d1c8e30893a9cbfaed2b3fb2f540529be63c2f542b548c7b0eef55c72459a84d0f4c52f5509e8bb8d534ac9de669989e37ea03a44c02f54e
checksum: 281ca8764953d0767774506e63209c2960eac323ca003c69324b2f7d5f5ae4a8357f99ab6c8ddade989d23e6291f2f992d4c7d4fa38d02a26167185c01f771c9
languageName: node
linkType: hard
@ -17376,18 +17374,6 @@ fsevents@~2.1.2:
languageName: node
linkType: hard
"style-loader@npm:^2.0.0":
version: 2.0.0
resolution: "style-loader@npm:2.0.0"
dependencies:
loader-utils: ^2.0.0
schema-utils: ^3.0.0
peerDependencies:
webpack: ^4.0.0 || ^5.0.0
checksum: ffc305488244ab499f91b05a1c94dd199b8b106d69e260ce38bd599819bbb352357e107bef3c319b775b9fb0eaed571cb68f8c7940e457553f85a980f4b630d8
languageName: node
linkType: hard
"style-search@npm:^0.1.0":
version: 0.1.0
resolution: "style-search@npm:0.1.0"