Bump pjs deps (#9794)

* Bump pjs deps

* Some cleanups

* Additional fixes

* Additional fixes

* kilt

* Additional fixes

* Headers

* Additional headers

* Additional

* Additional

* Additional

* Additional

* It seems to lint... locally.

* It seems to build... locally.

* Review adjustments
This commit is contained in:
Jaco 2023-08-19 09:38:42 +03:00 committed by GitHub
parent f6bded7bab
commit e23c8cf152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
228 changed files with 1347 additions and 1110 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/dev authors & contributors
// Copyright 2017-2023 @polkadot/apps authors & contributors
// SPDX-License-Identifier: Apache-2.0
import baseConfig from '@polkadot/dev/config/eslint';

View File

@ -69,7 +69,7 @@
"devDependencies": {
"@crustio/crust-pin": "^1.0.0",
"@pinata/sdk": "^1.2.1",
"@polkadot/dev": "^0.75.26",
"@polkadot/dev": "^0.76.16",
"@types/chart.js": "^2.9.37",
"@types/file-saver": "^2.0.5",
"@types/react-beautiful-dnd": "^13.1.4",
@ -99,9 +99,9 @@
"@polkadot/api-base": "^10.9.1",
"@polkadot/api-contract": "^10.9.1",
"@polkadot/api-derive": "^10.9.1",
"@polkadot/hw-ledger": "^12.3.2",
"@polkadot/keyring": "^12.3.2",
"@polkadot/networks": "^12.3.2",
"@polkadot/hw-ledger": "^12.4.1",
"@polkadot/keyring": "^12.4.1",
"@polkadot/networks": "^12.4.1",
"@polkadot/phishing": "^0.21.5",
"@polkadot/rpc-augment": "^10.9.1",
"@polkadot/rpc-core": "^10.9.1",
@ -112,16 +112,16 @@
"@polkadot/types-create": "^10.9.1",
"@polkadot/types-known": "^10.9.1",
"@polkadot/types-support": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"@polkadot/wasm-crypto": "^7.2.1",
"@polkadot/x-bigint": "^12.3.2",
"@polkadot/x-fetch": "^12.3.2",
"@polkadot/x-global": "^12.3.2",
"@polkadot/x-randomvalues": "^12.3.2",
"@polkadot/x-textdecoder": "^12.3.2",
"@polkadot/x-textencoder": "^12.3.2",
"@polkadot/x-ws": "^12.3.2",
"@polkadot/util": "^12.4.1",
"@polkadot/util-crypto": "^12.4.1",
"@polkadot/wasm-crypto": "^7.2.2",
"@polkadot/x-bigint": "^12.4.1",
"@polkadot/x-fetch": "^12.4.1",
"@polkadot/x-global": "^12.4.1",
"@polkadot/x-randomvalues": "^12.4.1",
"@polkadot/x-textdecoder": "^12.4.1",
"@polkadot/x-textencoder": "^12.4.1",
"@polkadot/x-ws": "^12.4.1",
"styled-components": "^5.3.1",
"typescript": "^5.1.6"
}

View File

@ -38,14 +38,14 @@
"@phala/typedefs": "0.2.33",
"@polkadot/api": "^10.9.1",
"@polkadot/api-derive": "^10.9.1",
"@polkadot/networks": "^12.3.2",
"@polkadot/networks": "^12.4.1",
"@polkadot/react-identicon": "^3.5.1",
"@polkadot/types": "^10.9.1",
"@polkadot/types-codec": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/wasm-util": "^7.2.1",
"@polkadot/x-fetch": "^12.3.2",
"@polkadot/x-ws": "^12.3.2",
"@polkadot/util": "^12.4.1",
"@polkadot/wasm-util": "^7.2.2",
"@polkadot/x-fetch": "^12.4.1",
"@polkadot/x-ws": "^12.4.1",
"@polymeshassociation/polymesh-types": "5.4.1",
"@snowfork/snowbridge-types": "0.2.7",
"@sora-substrate/type-definitions": "1.17.16",

View File

@ -6,6 +6,10 @@ import type { OverrideBundleDefinition } from '@polkadot/types/types';
import cere from './cere.js';
import kilt from './kilt.js';
if (!kilt) {
throw new Error('Unable to retrieve kilt');
}
// NOTE: The mapping is done from chain name in system.chain
const chain: Record<string, OverrideBundleDefinition> = {
'Cere Mainnet Beta': cere,

View File

@ -1,8 +1,10 @@
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { OverrideBundleDefinition } from '@polkadot/types/types';
import { typesBundle } from '@kiltprotocol/type-definitions';
export default typesBundle.chain as Record<string, OverrideBundleDefinition>;
if (!typesBundle.chain) {
throw new Error('Unable to find chain defintions');
}
export default typesBundle.chain;

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types';
@ -9,7 +9,7 @@ import { assert, BN } from '@polkadot/util';
function getGenesis (name: string): HexString {
const network = Object.entries(knownGenesis).find(([network]) => network === name);
assert(network && network[1][0], `Unable to find genesisHash for ${name}`);
assert(network?.[1][0], `Unable to find genesisHash for ${name}`);
return network[1][0];
}

View File

@ -20,7 +20,7 @@ const mapping: [OverrideBundleDefinition, string[]][] = [
export function applyDerives (typesBundle: OverrideBundleType): OverrideBundleType {
mapping.forEach(([{ derives }, chains]): void => {
chains.forEach((chain): void => {
if (typesBundle.spec && typesBundle.spec[chain]) {
if (typesBundle.spec?.[chain]) {
typesBundle.spec[chain].derives = derives;
}
});

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiPromise } from '@polkadot/api';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiPromise } from '@polkadot/api';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiPromise } from '@polkadot/api';
@ -31,5 +31,5 @@ const KNOWN_SPEC_TRACKS: Record<string, Record<string, TrackInfo[]>> = {
export function getGovernanceTracks (api: ApiPromise, specName: string, palletReferenda: string): TrackInfo[] | undefined {
const lookup = KNOWN_GENE_TRACKS[api.genesisHash.toHex()] || KNOWN_SPEC_TRACKS[specName];
return lookup && lookup[palletReferenda];
return lookup?.[palletReferenda];
}

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { TrackInfo } from './types.js';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { TrackInfo } from './types.js';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { BN } from '@polkadot/util';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-config authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { BN } from '@polkadot/util';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/apps authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { fetch } from '@polkadot/x-fetch';
@ -37,9 +37,9 @@ function fetchWithTimeout (url: string, timeout = 2_000): Promise<Response | nul
}
export function fetchJson <T> (url: string, timeout?: number): Promise<T | null> {
return fetchWithTimeout(url, timeout).then<T | null>((r) => r && r.json());
return fetchWithTimeout(url, timeout).then<T | null>((r) => r?.json() || null);
}
export function fetchText (url: string, timeout?: number): Promise<string | null> {
return fetchWithTimeout(url, timeout).then((r) => r && r.text());
return fetchWithTimeout(url, timeout).then((r) => r?.text() || null);
}

View File

@ -54,21 +54,23 @@ describe('urls are sorted', (): void => {
lastHeader = text as string;
} else {
it(`${lastHeader}:: ${text as string}:: ${textBy}`, (): void => {
const item = filtered[index - 1];
assert((
filtered[index - 1].isHeader ||
filtered[index - 1].linked ||
item.isHeader ||
item.linked ||
(
isNumber(filtered[index - 1].paraId) &&
isNumber(item.paraId) &&
(
(filtered[index - 1].paraId as number) < 2000
item.paraId < 2000
? isNumber(paraId) && paraId >= 2000
: false
)
) ||
filtered[index - 1].text === '' ||
text === filtered[index - 1].text ||
(text as string).localeCompare(filtered[index - 1].text as string) === 1
), `${lastHeader}:: ${text as string} needs to be before ${filtered[index - 1].text as string}`);
item.text === '' ||
text === item.text ||
(text as string).localeCompare(item.text as string) === 1
), `${lastHeader}:: ${text as string} needs to be before ${item.text as string}`);
});
}
});

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/ui-settings authors & contributors
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { TFunction } from '../types.js';

View File

@ -22,7 +22,7 @@
"electron-updater": "^5.3.0"
},
"devDependencies": {
"@polkadot/dev": "^0.75.26",
"@polkadot/dev": "^0.76.16",
"@types/tmp": "^0.2.3",
"copy-webpack-plugin": "^11.0.0",
"electron": "25.0.1",

View File

@ -1,6 +1,4 @@
// Copyright 2017-2023 @polkadot/apps authors & contributors
// SPDX-License-Identifier: Apache-2.0
export type IpcMainHandler = {
[channel: string]: (...args: any[]) => unknown
}
export type IpcMainHandler = Record<string, (...args: any[]) => unknown>;

View File

@ -18,7 +18,7 @@
"dependencies": {
"@polkadot/apps-config": "^0.132.2-55-x",
"@polkadot/apps-routing": "^0.132.2-55-x",
"@polkadot/dev": "^0.75.26",
"@polkadot/dev": "^0.76.16",
"@polkadot/react-api": "^0.132.2-55-x",
"@polkadot/react-components": "^0.132.2-55-x",
"@polkadot/react-hooks": "^0.132.2-55-x",

View File

@ -16,11 +16,11 @@
"type": "module",
"version": "0.132.2-55-x",
"dependencies": {
"@polkadot/hw-ledger": "^12.3.2",
"@polkadot/hw-ledger": "^12.4.1",
"@polkadot/phishing": "^0.21.5",
"@polkadot/react-components": "^0.132.2-55-x",
"@polkadot/react-hooks": "^0.132.2-55-x",
"@polkadot/util": "^12.3.2",
"@polkadot/util": "^12.4.1",
"@polkadot/vanitygen": "^0.55.3",
"detect-browser": "^5.3.0",
"file-saver": "^2.0.5"

View File

@ -139,7 +139,7 @@ function createClearReferendaTx (api: ApiPromise, address: string, ids: [BN, BN]
async function showLedgerAddress (getLedger: () => Ledger, meta: KeyringJson$Meta): Promise<void> {
const ledger = getLedger();
await ledger.getAddress(true, meta.accountOffset as number || 0, meta.addressOffset as number || 0);
await ledger.getAddress(true, meta.accountOffset || 0, meta.addressOffset || 0);
}
const transformRecovery = {
@ -405,7 +405,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
isFunction(api.api.tx.multisig?.asMulti) && isMultisig && createMenuGroup('multisigGroup', [
<Menu.Item
icon='file-signature'
isDisabled={!multiInfos || !multiInfos.length}
isDisabled={!multiInfos?.length}
key='multisigApprovals'
label={t('Multisig approvals')}
onClick={toggleMultisig}
@ -471,7 +471,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
/>
<td className='address all relative'>
<AddressSmall
parentAddress={meta.parentAddress as string}
parentAddress={meta.parentAddress}
value={address}
withShortAddress
/>
@ -549,8 +549,8 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
key='multisig-approve'
onClose={toggleMultisig}
ongoing={multiInfos}
threshold={meta.threshold as number}
who={meta.who as string[]}
threshold={meta.threshold}
who={meta.who}
/>
)}
{isRecoverAccountOpen && (

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
/// <reference types="@polkadot/dev-test/globals.d.ts" />

View File

@ -63,7 +63,7 @@ function groupAccounts (accounts: SortedAccount[]): Record<GroupName, string[]>
testing: []
};
for (let i = 0; i < accounts.length; i++) {
for (let i = 0, count = accounts.length; i < count; i++) {
const { account, address } = accounts[i];
const cryptoType = getAccountCryptoType(address);

View File

@ -45,9 +45,9 @@ function useProxiesImpl (address?: string | null): State | null {
useEffect((): void => {
setState(null);
address && api.query.proxy &&
address &&
api.query.proxy
.proxies<ITuple<[Vec<ITuple<[AccountId, KitchensinkRuntimeProxyType]> | PalletProxyProxyDefinition>, BalanceOf]>>(address)
?.proxies<ITuple<[Vec<ITuple<[AccountId, KitchensinkRuntimeProxyType]> | PalletProxyProxyDefinition>, BalanceOf]>>(address)
.then(([_proxies]): void => {
const proxies = api.tx.proxy.addProxy.meta.args.length === 3
? (_proxies as PalletProxyProxyDefinition[]).map(({ delay, delegate, proxyType }) =>

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
/// <reference types="@polkadot/dev-test/globals.d.ts" />

View File

@ -22,10 +22,10 @@ interface Props {
function CreateConfirmation ({ address, derivePath, name, pairType, seed }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const splitSeed = seed && seed.split(' ');
const splitSeed = seed?.split(' ');
const shortSeed = isHex(seed)
? `${seed.slice(10)} … ${seed.slice(-8)}`
: splitSeed && splitSeed.map((value, index) => (index % 3) ? '…' : value).join(' ');
: splitSeed?.map((value, index) => (index % 3) ? '…' : value).join(' ');
return (
<Modal.Content>

View File

@ -41,7 +41,7 @@ function CreateSuriLedger ({ className, onChange, seedType }: Props): React.Reac
useEffect((): void => {
const network = ledgerNets.find(({ network }) => network === chainType);
onChange(`m/44'/${network?.slip44 as number}'/${accIndex}'/0'/${addIndex}'`);
onChange(`m/44'/${network?.slip44}'/${accIndex}'/0'/${addIndex}'`);
}, [accIndex, addIndex, chainType, onChange]);
return (

View File

@ -98,12 +98,12 @@ function IdentitySubModal ({ address, className, onClose }: Props): React.ReactE
}, [allAccounts, queryIds, queryInfos]);
const _rowAdd = useCallback(
() => setInfos((infos) => infos && infos.concat([[allAccounts[0], '']])),
() => setInfos((infos) => infos?.concat([[allAccounts[0], '']])),
[allAccounts]
);
const _rowRemove = useCallback(
() => setInfos((infos) => infos && infos.slice(0, infos.length - 1)),
() => setInfos((infos) => infos?.slice(0, infos.length - 1)),
[]
);

View File

@ -116,7 +116,7 @@ function Import ({ className = '', onClose, onStatusChange }: Props): React.Reac
<Modal.Content>
<Modal.Columns>
<AddressRow
defaultName={(pair?.meta.name as string) || null}
defaultName={pair?.meta.name || null}
noDefaultNameOpacity
value={pair?.address || null}
/>

View File

@ -19,8 +19,8 @@ interface Props {
className?: string;
onClose: () => void;
ongoing: [H256, Multisig][];
threshold: number;
who: string[];
threshold?: number;
who?: string[];
}
interface MultiInfo {
@ -45,7 +45,7 @@ const EMPTY_CALL: CallData = {
callInfo: null
};
function MultisigApprove ({ className = '', onClose, ongoing, threshold, who }: Props): React.ReactElement<Props> {
function MultisigApprove ({ className = '', onClose, ongoing, threshold = 0, who = [] }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const { allAccounts } = useAccounts();

View File

@ -8,7 +8,7 @@ import { keyring } from '@polkadot/ui-keyring';
import { useTranslation } from '../translate.js';
type Props = {
interface Props {
onChange: (password: string, isPasswordValid: boolean) => void;
onEnter: () => void;
}

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global expect */

View File

@ -1,8 +1,6 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global expect */
import type { Sidebar } from '@polkadot/test-support/pagesElements';
import type { AccountOverrides } from '@polkadot/test-support/types';
@ -98,9 +96,11 @@ export class AccountsPage extends Page {
const availableCategories = await within(sortByComponent).findAllByRole('option');
const selectedCategory = availableCategories.find((category) => category.textContent === categoryName);
expect(selectedCategory).not.toBeUndefined();
if (!selectedCategory) {
throw new Error('No category found');
}
return selectedCategory as HTMLElement;
return selectedCategory;
}
private async getSortByComponent (): Promise<HTMLElement> {

View File

@ -70,7 +70,7 @@ function Address ({ address, className = '', filter, isFavorite, toggleFavorite
const current = keyring.getAddress(address);
setCurrent(current || null);
setGenesisHash((current && current.meta.genesisHash) || null);
setGenesisHash((current?.meta.genesisHash) || null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@ -89,7 +89,7 @@ function Address ({ address, className = '', filter, isFavorite, toggleFavorite
useEffect((): void => {
const account = keyring.getAddress(address);
_setTags(account?.meta?.tags as string[] || []);
_setTags(account?.meta?.tags || []);
setAccName(account?.meta?.name || '');
}, [_setTags, address]);

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/page-addresses authors & contributors
// Copyright 2017-2023 @polkadot/app-addresses authors & contributors
// SPDX-License-Identifier: Apache-2.0
/// <reference types="@polkadot/dev-test/globals.d.ts" />

View File

@ -12,7 +12,7 @@ import CreateModal from '../modals/Create.js';
import { useTranslation } from '../translate.js';
import Address from './Address.js';
type SortedAddress = { address: string; isFavorite: boolean };
interface SortedAddress { address: string; isFavorite: boolean }
interface Props {
className?: string;

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/page-addresses authors & contributors
// Copyright 2017-2023 @polkadot/app-addresses authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global jest */

View File

@ -31,7 +31,7 @@ function Announcements ({ accouncements, className }: Props): React.ReactElement
empty={accouncements && t('No annoucements')}
header={annRef.current}
>
{accouncements && accouncements.map((a) => (
{accouncements?.map((a) => (
<Accouncement
key={a.key}
value={a}

View File

@ -54,13 +54,13 @@ function Member ({ bestNumber, className, info: { accountId, role }, isPrime, is
<td className='address all relative'>
<AddressSmall value={accountId} />
<div className='absolute'>
{(info && info.isRetiringAt && (
{(info?.isRetiringAt && (
<Tag
color='yellow'
hover={t('Is retiring')}
label={t('retirting')}
/>
)) || (info && info.isUpForKicking && (
)) || (info?.isUpForKicking && (
<Tag
color='red'
hover={t('Up for kicking')}
@ -92,7 +92,7 @@ function Member ({ bestNumber, className, info: { accountId, role }, isPrime, is
<Menu>
{hasNotice && (
<Menu.Item
isDisabled={!!(info && info.isRetiringAt)}
isDisabled={!!(info?.isRetiringAt)}
label={t('Announce retirement')}
onClick={doNotice}
/>

View File

@ -19,7 +19,7 @@ interface Props {
function Summary ({ className, members, rule }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const ipfsLink = useIpfsLink(rule && rule.cid && rule.cid.ipfs);
const ipfsLink = useIpfsLink(rule?.cid?.ipfs);
return (
<SummaryBox className={className}>

View File

@ -59,7 +59,7 @@ function Overview ({ className, members, prime, rule, unscrupulous, voters }: Pr
isSplit
maxColumns={2}
>
{members && members.map((m) => (
{members?.map((m) => (
<Member
bestNumber={bestNumber}
info={m}

View File

@ -30,10 +30,10 @@ function Unscrupulous ({ className, unscrupulous }: Props): React.ReactElement<P
return (
<div className={className}>
<Table
empty={unscrupulous && unscrupulous.accounts && t('No accounts')}
empty={unscrupulous?.accounts && t('No accounts')}
header={accRef.current}
>
{unscrupulous && unscrupulous.accounts.map((m) => (
{unscrupulous?.accounts.map((m) => (
<Account
key={m}
value={m}
@ -41,10 +41,10 @@ function Unscrupulous ({ className, unscrupulous }: Props): React.ReactElement<P
))}
</Table>
<Table
empty={unscrupulous && unscrupulous.websites && t('No websites')}
empty={unscrupulous?.websites && t('No websites')}
header={webRef.current}
>
{unscrupulous && unscrupulous.websites.map((m) => (
{unscrupulous?.websites.map((m) => (
<Website
key={m}
value={m}

View File

@ -52,11 +52,11 @@ function AllianceApp ({ basePath, className }: Props): React.ReactElement<Props>
},
{
name: 'motions',
text: t('Motions ({{count}})', { replace: { count: (proposalHashes && proposalHashes.length) || 0 } })
text: t('Motions ({{count}})', { replace: { count: proposalHashes?.length || 0 } })
},
{
name: 'announcements',
text: t('Announcements ({{count}})', { replace: { count: (accouncements && accouncements.length) || 0 } })
text: t('Announcements ({{count}})', { replace: { count: accouncements?.length || 0 } })
},
{
name: 'unscrupulous',

View File

@ -10,7 +10,7 @@ function useCounterImpl (): number {
const proposalHashes = useCall<unknown[]>(isApiReady && api.derive.alliance.proposalHashes);
return useMemo(
() => (proposalHashes && proposalHashes.length) || 0,
() => proposalHashes?.length || 0,
[proposalHashes]
);
}

View File

@ -19,7 +19,7 @@ function useMemberInfoImpl (accountId: string): MemberInfo | undefined {
accountId,
deposit: depositOf.unwrapOr(null),
isUpForKicking: upForKicking && upForKicking.isTrue,
retiringAt: retiringAt && retiringAt.unwrapOr(null)
retiringAt: retiringAt?.unwrapOr(null)
},
[accountId, depositOf, retiringAt, upForKicking]
);

View File

@ -8,7 +8,7 @@ import { useEffect, useState } from 'react';
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
const ROLES = <const> ['Retiring', 'Ally', 'Fellow'];
const ROLES = ['Retiring', 'Ally', 'Fellow'] as const;
function addMembers (prev: Member[], ...query: AccountId32[][]): Member[] {
const all: Member[] = [];
@ -17,7 +17,7 @@ function addMembers (prev: Member[], ...query: AccountId32[][]): Member[] {
const role = ROLES[i];
const accountIds = query[i];
for (let j = 0; j < accountIds.length; j++) {
for (let j = 0, count = accountIds.length; j < count; j++) {
const accountId = accountIds[j].toString();
const existing = prev.find((p) =>
p.accountId === accountId &&

View File

@ -25,7 +25,7 @@ interface Props {
}
function findOpenId (ids?: BN[]): BN {
if (!ids || !ids.length) {
if (!ids?.length) {
return BN_ONE;
}

View File

@ -1,8 +1,6 @@
// Copyright 2017-2023 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { BN } from '@polkadot/util';
import React, { useMemo, useRef } from 'react';
import { Button, styled, Table } from '@polkadot/react-components';
@ -22,7 +20,7 @@ function Bounties ({ className }: Props): React.ReactElement {
const info = useBounties();
const sorted = useMemo(
() => info && info.bounties && [...info.bounties].sort((a, b) => b.index.cmp(a.index)),
() => info?.bounties && [...info.bounties].sort((a, b) => b.index.cmp(a.index)),
[info]
);
@ -32,6 +30,7 @@ function Bounties ({ className }: Props): React.ReactElement {
[t('curator'), 'start'],
[t('next action'), 'start', 3]
]);
const bestNumber = info.bestNumber;
return (
<StyledDiv className={className}>
@ -44,9 +43,9 @@ function Bounties ({ className }: Props): React.ReactElement {
empty={sorted && t('No open bounties')}
header={headerRef.current}
>
{sorted && info.bestNumber && sorted.map(({ bounty, description, index, proposals }) => (
{sorted && bestNumber && sorted.map(({ bounty, description, index, proposals }) => (
<Bounty
bestNumber={info.bestNumber as BN}
bestNumber={bestNumber}
bounty={bounty}
description={description}
index={index}

View File

@ -23,7 +23,7 @@ function getProposalByMethod (bountyProposals: DeriveCollectiveProposal[], metho
}
function bestValidProposalName (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): string | undefined {
const methods = bountyProposals.map(({ proposal }) => proposal && proposal.method);
const methods = bountyProposals.map(({ proposal }) => proposal?.method);
return validMethods(status).find((method) => methods.includes(method));
}

View File

@ -8,7 +8,7 @@ import { useMemo } from 'react';
import { createNamedHook, useAccounts, useCollectiveMembers } from '@polkadot/react-hooks';
export type UserRolesInfo = { roles: UserRole[], isCurator: boolean };
export interface UserRolesInfo { roles: UserRole[], isCurator: boolean }
function useUserRoleImpl (curatorId?: AccountId): UserRolesInfo {
const { allAccounts, hasAccounts } = useAccounts();

View File

@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0
type bountyTheme = {
interface bountyTheme {
dark: string;
light: string;
}

View File

@ -85,7 +85,7 @@ function ClaimsApp ({ basePath }: Props): React.ReactElement<Props> {
// - an `EthereumAddress` when there's a preclaim
// - null if no preclaim
// - `PRECLAIMS_LOADING` if we're fetching the results
const [preclaimEthereumAddress, setPreclaimEthereumAddress] = useState<string | null | undefined | typeof PRECLAIMS_LOADING>(PRECLAIMS_LOADING);
const [preclaimEthereumAddress, setPreclaimEthereumAddress] = useState<string | null | undefined>(PRECLAIMS_LOADING);
const isPreclaimed = !!preclaimEthereumAddress && preclaimEthereumAddress !== PRECLAIMS_LOADING;
const itemsRef = useRef([{

View File

@ -34,7 +34,7 @@ function Collators ({ className }: Props): React.ReactElement<Props> {
empty={collators && t('No running collators')}
header={hdrRef.current}
>
{collators && collators.map((c) => (
{collators?.map((c) => (
<Collator
info={c}
key={c.accountId}

View File

@ -70,7 +70,7 @@ function useCollatorImpl (): Collator[] | undefined {
const [state, setState] = useState<Collator[] | undefined>();
const accountIds = useMemo(
() => state && state.map(({ accountId }) => accountId),
() => state?.map(({ accountId }) => accountId),
[state]
);

View File

@ -48,8 +48,8 @@ function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex
[codeHash]
);
const [name, isNameValid, setName] = useNonEmptyString(code && code.json.name);
const { contractAbi, errorText, isAbiError, isAbiSupplied, isAbiValid, onChangeAbi, onRemoveAbi } = useAbi([code && code.json.abi, code && code.contractAbi], codeHash, true);
const [name, isNameValid, setName] = useNonEmptyString(code?.json.name);
const { contractAbi, errorText, isAbiError, isAbiSupplied, isAbiValid, onChangeAbi, onRemoveAbi } = useAbi([code?.json.abi, code?.contractAbi], codeHash, true);
const blueprint = useMemo(
() => isAbiValid && codeHash && contractAbi

View File

@ -34,7 +34,7 @@ function Contracts ({ className = '' }: Props): React.ReactElement<Props> {
const _onShowDeploy = useCallback(
(codeHash: string, constructorIndex: number): void => {
setCodeHash(codeHash || (allCodes && allCodes[0] ? allCodes[0].json.codeHash : undefined));
setCodeHash(codeHash || allCodes?.[0]?.json.codeHash || undefined);
setConstructorIndex(constructorIndex);
toggleDeploy();
},

View File

@ -13,13 +13,11 @@ import { getContractAbi } from '@polkadot/react-components/util';
import MessageSignature from '../shared/MessageSignature.js';
export function findCallMethod (callContract: ContractPromise | null, callMethodIndex = 0): AbiMessage | null {
const message = callContract && callContract.abi.messages[callMethodIndex];
return message || null;
return callContract?.abi.messages[callMethodIndex] || null;
}
export function getContractMethodFn (callContract: ContractPromise | null, callMethodIndex: number | null): AbiMessage | null {
const fn = callContract && callContract.abi && callMethodIndex !== null && callContract.abi.messages[callMethodIndex];
const fn = callMethodIndex !== null && callContract?.abi?.messages[callMethodIndex];
return fn || null;
}
@ -37,13 +35,11 @@ export function getContractForAddress (api: ApiPromise, address: string | null):
}
export function getCallMessageOptions (callContract: ContractPromise | null): DropdownItemProps[] {
return callContract
? callContract.abi.messages.map((m, index) => ({
key: m.identifier,
text: (
<MessageSignature message={m} />
),
value: index
}))
: [];
return callContract?.abi.messages.map((m, index) => ({
key: m.identifier,
text: (
<MessageSignature message={m} />
),
value: index
})) || [];
}

View File

@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AbiConstructor, AbiMessage, ContractCallOutcome } from '@polkadot/api-contract/types';
import type { AbiConstructor, ContractCallOutcome } from '@polkadot/api-contract/types';
import React, { useCallback } from 'react';
@ -15,7 +15,7 @@ export interface Props {
className?: string;
index: number;
lastResult?: ContractCallOutcome;
message: AbiConstructor | AbiMessage;
message: AbiConstructor;
onSelect?: (index: number) => void;
}

View File

@ -40,7 +40,7 @@ function MessageSignature ({ className, message: { args, isConstructor, isMutati
{name}:
{' '}
<span className='ui--MessageSignature-type'>
{params && params[index]
{params?.[index]
? <b>{truncate((params as string[])[index].toString())}</b>
: encodeTypeDef(api.registry, type)
}

View File

@ -53,7 +53,7 @@ function Slashing ({ className = '', isMember, members }: Props): React.ReactEle
);
useEffect((): void => {
const actioned = selectedEra && slashes && slashes.find(([era]) => era.eqn(selectedEra));
const actioned = selectedEra && slashes?.find(([era]) => era.eqn(selectedEra));
const proposal = actioned
? api.tx.staking.cancelDeferredSlash(actioned[0], actioned[1].map((_, index) => index))
: null;

View File

@ -34,7 +34,7 @@ function Voters ({ isAye, members, threshold, votes }: Props): React.ReactElemen
);
const renderVotes = useCallback(
() => votes && votes.map((address): React.ReactNode => (
() => votes?.map((address): React.ReactNode => (
<AddressMini
key={address.toString()}
value={address}

View File

@ -45,7 +45,7 @@ function Summary ({ bestNumber, className = '', electionsInfo, hasElections }: P
</>
)}
</section>
{electionsInfo && electionsInfo.voteCount && (
{electionsInfo?.voteCount && (
<section>
<CardSummary label={t('voting round')}>
#{formatNumber(electionsInfo.voteCount)}

View File

@ -15,7 +15,7 @@ interface Props {
function Voters ({ balance, voters }: Props): React.ReactElement<Props> {
const renderVoters = useCallback(
() => voters && voters.map((who): React.ReactNode =>
() => voters?.map((who): React.ReactNode =>
<AddressMini
key={who.toString()}
value={who}

View File

@ -39,7 +39,7 @@ function PreImage ({ className = '', imageHash, isImminent = false, onClose }: P
const [proposal, setProposal] = useState<SubmittableExtrinsic>();
useEffect((): void => {
const encodedProposal = (proposal as SubmittableExtrinsic)?.method.toHex() || '';
const encodedProposal = proposal?.method.toHex() || '';
const storageFee = api.consts.democracy.preimageByteDeposit
? (api.consts.democracy.preimageByteDeposit as unknown as BN).mul(
encodedProposal

View File

@ -37,7 +37,7 @@ const EMPTY_HEADER: [React.ReactNode?, string?, number?][] = [['...', 'start', 6
function transformResult ([[runtimeVersion, events], getBlock, getHeader]: [[RuntimeVersionPartial, EventRecord[] | null], SignedBlock, HeaderExtended?]): State {
return {
events: events && events.map((record, index) => ({
events: events?.map((record, index) => ({
indexes: [index],
key: `${Date.now()}-${index}-${record.hash.toHex()}`,
record
@ -69,7 +69,7 @@ function BlockByHash ({ className = '', error, value }: Props): React.ReactEleme
}, [error]);
const systemEvents = useMemo(
() => events && events.filter(({ record: { phase } }) => !phase.isApplyExtrinsic),
() => events?.filter(({ record: { phase } }) => !phase.isApplyExtrinsic),
[events]
);

View File

@ -57,7 +57,7 @@ function filterEvents (index: number, events?: KeyedEvent[] | null, maxBlockWeig
return [
dispatchInfo,
weight && weight.v1Weight,
weight?.v1Weight,
weight && maxBlockWeight
? weight.v1Weight.mul(BN_TEN_THOUSAND).div(maxBlockWeight).toNumber() / 100
: 0,

View File

@ -42,7 +42,7 @@ function Extrinsics ({ blockNumber, className = '', events, label, maxBlockWeigh
header={header}
isFixed
>
{value && value.map((extrinsic, index): React.ReactNode =>
{value?.map((extrinsic, index): React.ReactNode =>
<ExtrinsicDisplay
blockNumber={blockNumber}
events={events}

View File

@ -65,7 +65,7 @@ function Events ({ className = '', emptyLabel, error, eventClassName, events, la
<td><MarkError content={t('Unable to decode the block events. {{error}}', { replace: { error: error.message } })} /></td>
</tr>
)
: events && events.map((e) => renederEvent(eventClassName, e))
: events?.map((e) => renederEvent(eventClassName, e))
}
</Table>
);

View File

@ -55,7 +55,7 @@ function getPoints (details: Detail[], timeAvg: number): ChartInfo {
const txTotal = details.reduce((a, { extrinsics: { count } }) => a + count, 0);
const blockTotal = details.reduce((a, { block: { bytes } }) => a + bytes, 0);
for (let i = 0; i < details.length; i++) {
for (let i = 0, count = details.length; i < count; i++) {
const blockNumber = formatNumber(details[i].block.number);
blocks.labels.push(blockNumber);
@ -75,7 +75,7 @@ function getPoints (details: Detail[], timeAvg: number): ChartInfo {
const filtered = details.filter(({ delay }) => delay);
const avgBase = timeAvg * filtered.length;
for (let i = 0; i < filtered.length; i++) {
for (let i = 0, count = filtered.length; i < count; i++) {
times.labels.push(formatNumber(filtered[i].block.number));
times.values[0].push(filtered[i].delay / 1000);
times.values[1].push(avgBase / filtered.length / 1000);

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-nodeinfo authors & contributors
// Copyright 2017-2023 @polkadot/app-explorer authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { PeerInfo } from '@polkadot/types/interfaces';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-nodeinfo authors & contributors
// Copyright 2017-2023 @polkadot/app-explorer authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Info } from './types.js';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-nodeinfo authors & contributors
// Copyright 2017-2023 @polkadot/app-explorer authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiPromise } from '@polkadot/api';

View File

@ -1,4 +1,4 @@
// Copyright 2017-2023 @polkadot/app-nodeinfo authors & contributors
// Copyright 2017-2023 @polkadot/app-explorer authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Vec } from '@polkadot/types';

View File

@ -44,7 +44,7 @@ function ExtrinsicsApp ({ basePath }: Props): React.ReactElement<Props> {
<Route
element={
<Decoder
defaultValue={decoded && decoded.hex}
defaultValue={decoded?.hex}
setLast={setDecoded}
/>
}

View File

@ -123,9 +123,9 @@ function CrustFiles ({ className }: Props): React.ReactElement<Props> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
const dirFiles: DirFile[] = [];
for (let index = 0; index < files.length; index++) {
for (let i = 0, count = files.length; i < count; i++) {
// console.info('f:', files[index]);
dirFiles.push(files[index] as DirFile);
dirFiles.push(files[i]);
}
console.info(dirFiles);
@ -138,6 +138,7 @@ function CrustFiles ({ className }: Props): React.ReactElement<Props> {
e.target.value = '';
}, [setFile, setShowUpMode, queueAction, t]);
const _onImportResult = useCallback<(m: string, s?: ActionStatusBase['status']) => void>(
(message, status = 'queued') => {
queueAction && queueAction({
@ -180,7 +181,7 @@ function CrustFiles ({ className }: Props): React.ReactElement<Props> {
}
const fitter: SaveFile[] = [];
const mapImport: { [key: string]: boolean } = {};
const mapImport: Record<string, boolean> = {};
for (const item of _list) {
if (item.Hash && item.Name && item.UpEndpoint && item.PinEndpoint) {

View File

@ -124,10 +124,10 @@ function UploadModal ({ className, file, onClose = NOOP, onSuccess = NOOP }: Pro
}, [setAccount, setCurrentPair]);
useEffect(() => {
const meta = (currentPair && currentPair.meta) || {};
const isExternal = (meta.isExternal as boolean) || false;
const isHardware = (meta.isHardware as boolean) || false;
const isInjected = (meta.isInjected as boolean) || false;
const meta = currentPair?.meta || {};
const isExternal = meta.isExternal || false;
const isHardware = meta.isHardware || false;
const isInjected = meta.isInjected || false;
const isUsable = !(isExternal || isHardware || isInjected);
setAccountState({ isExternal, isHardware, isInjected });
@ -305,7 +305,7 @@ function UploadModal ({ className, file, onClose = NOOP, onSuccess = NOOP }: Pro
<Modal.Columns>
<div className='files'>
{file.file && <ShowFile file={file.file} />}
{file.files && file.files.map((f, i) =>
{file.files?.map((f, i) =>
<ShowFile
file={f}
key={`file_item:${i}`}

View File

@ -20,7 +20,7 @@ function Overview ({ className }: Props): React.ReactElement<Props> {
const { info } = useInfo();
const isDisabled = useMemo(
() => !info || !info.activeTotal || info.activeTotal.target.isZero(),
() => !info?.activeTotal || info.activeTotal.target.isZero(),
[info]
);

View File

@ -84,7 +84,7 @@ function AccountItems ({ className, infos = [] }: Props): React.ReactElement<Pro
}
header={headerRef.current}
>
{itemsInfos && itemsInfos.map((info) => (
{itemsInfos?.map((info) => (
<Item
collectionName={collectionName}
key={info.key}

View File

@ -22,7 +22,7 @@ const IPFS_FETCH_OPTIONS = {
}
try {
const result = JSON.parse(data) as {[key: string]: any};
const result = JSON.parse(data) as Record<string, any>;
if (result && typeof result === 'object') {
return {
@ -37,10 +37,14 @@ const IPFS_FETCH_OPTIONS = {
};
function extractInfo ([, itemId]: [BN, BN], metadata: Option<PalletUniquesItemMetadata>, accountItems: AccountItem[]): ItemInfo {
const { accountId } = accountItems.find(({ itemId: _itemId }) => _itemId.eq(itemId)) as AccountItem;
const item = accountItems.find(({ itemId: _itemId }) => _itemId.eq(itemId));
if (!item) {
throw new Error('Unable to extract accountId');
}
return {
account: accountId,
account: item.accountId,
id: itemId,
ipfsData: null,
key: itemId.toString(),
@ -49,7 +53,7 @@ function extractInfo ([, itemId]: [BN, BN], metadata: Option<PalletUniquesItemMe
}
const addIpfsData = (ipfsData: IpfsData) => (itemInfo: ItemInfo): ItemInfo => {
const ipfsHash = itemInfo.metadata && itemInfo.metadata.data.toString();
const ipfsHash = itemInfo.metadata?.data.toString();
return {
...itemInfo,
@ -69,7 +73,7 @@ function useItemsInfosImpl (accountItems: AccountItem[]): ItemInfo[] | undefined
const metadata = useCall<[[[BN, BN][]], Option<PalletUniquesItemMetadata>[]]>(api.query.uniques.instanceMetadataOf.multi, [ids], QUERY_OPTS);
const ipfsHashes = useMemo((): string[] | undefined => {
if (metadata && metadata[1].length) {
if (metadata?.[1].length) {
return metadata[1].map((o) =>
o.isSome
? o.unwrap().data.toPrimitive() as string
@ -83,7 +87,7 @@ function useItemsInfosImpl (accountItems: AccountItem[]): ItemInfo[] | undefined
const ipfsData = useIpfsFetch<ItemSupportedIpfsData | null>(ipfsHashes, IPFS_FETCH_OPTIONS);
useEffect((): void => {
if (ipfsData && accountItems.length && metadata && metadata[0][0].length) {
if (ipfsData && accountItems.length && metadata?.[0][0].length) {
const [collectionId] = metadata[0][0][0];
if (!collectionId.eq(ids[0][0])) {

View File

@ -29,7 +29,7 @@ const IPFS_FETCH_OPTIONS = {
}
try {
const result = JSON.parse(data) as {[key: string]: any};
const result = JSON.parse(data) as Record<string, any>;
if (result && typeof result === 'object') {
return {
@ -87,7 +87,7 @@ function useCollectionInfosImpl (ids?: BN[]): CollectionInfo[] | undefined {
const [state, setState] = useState<CollectionInfo[] | undefined>();
const ipfsHashes = useMemo(
() => metadata && metadata[1].length
() => metadata?.[1].length
? metadata[1].map((o) =>
o.isSome
? o.unwrap().data.toPrimitive() as string

View File

@ -19,7 +19,7 @@ function Overview ({ className }: Props): React.ReactElement<Props> {
const proxies = useProxies();
const { info } = useInfo();
const isDisabled = !info || !info.summary || info.summary.proportionOwed.isZero();
const isDisabled = !info?.summary || info.summary.proportionOwed.isZero();
return (
<div className={className}>

View File

@ -36,7 +36,7 @@ function Auction ({ auctionInfo, campaigns, className, winningData }: Props): Re
const loans = useMemo(
(): Campaign[] | undefined => {
if (newRaise && auctionInfo && auctionInfo.leasePeriod && campaigns.funds) {
if (newRaise && auctionInfo?.leasePeriod && campaigns.funds) {
const leasePeriodStart = auctionInfo.leasePeriod;
const leasePeriodEnd = leasePeriodStart.add(rangeMax);
@ -94,7 +94,7 @@ function Auction ({ auctionInfo, campaigns, className, winningData }: Props): Re
<Table
className={className}
empty={
newRaise && auctionInfo && auctionInfo.numAuctions && winningData && (
newRaise && auctionInfo?.numAuctions && winningData && (
auctionInfo.endBlock && !winningData.length
? t('No winners in this auction')
: t('No ongoing auction')
@ -103,7 +103,7 @@ function Auction ({ auctionInfo, campaigns, className, winningData }: Props): Re
header={headerRef.current}
noBodyTag
>
{auctionInfo && auctionInfo.leasePeriod && winningData && loans && (
{auctionInfo?.leasePeriod && winningData && loans && (
winningData.length
? winningData.map(({ blockNumber, winners }, round) => (
<tbody key={round}>

View File

@ -61,7 +61,7 @@ function Bid ({ auctionInfo, className, lastWinners, ownedIds }: Props): React.R
);
const currentWinner = useMemo(
() => lastWinners && lastWinners.winners.find(({ firstSlot, lastSlot }) =>
() => lastWinners?.winners.find(({ firstSlot, lastSlot }) =>
firstSlot.eqn(rangeOpts[range].firstSlot) &&
lastSlot.eqn(rangeOpts[range].lastSlot)
),

View File

@ -20,7 +20,7 @@ interface Props {
}
function Auctions ({ auctionInfo, campaigns, className, ownedIds, winningData }: Props): React.ReactElement<Props> {
const lastWinners = winningData && winningData[0];
const lastWinners = winningData?.[0];
return (
<div className={className}>

View File

@ -60,8 +60,8 @@ function Parachain ({ bestNumber, className = '', id, lastBacked, lastInclusion,
const valRender = useCallback(
() => renderAddresses(
validators && validators[1].map(({ validatorId }) => validatorId),
validators && validators[1].map(({ indexValidator }) => indexValidator)
validators?.[1].map(({ validatorId }) => validatorId),
validators?.[1].map(({ indexValidator }) => indexValidator)
),
[validators]
);

View File

@ -18,9 +18,9 @@ interface Props {
}
function getMapped (periods: number[], currentPeriod?: BN): string | undefined {
return currentPeriod && periods &&
return currentPeriod &&
periods
.reduce((all: [BN, BN][], period): [BN, BN][] => {
?.reduce((all: [BN, BN][], period): [BN, BN][] => {
const bnp = currentPeriod.addn(period);
if (!all.length || all[all.length - 1][1].add(BN_ONE).lt(bnp)) {

View File

@ -28,7 +28,7 @@ function includeEntry (map: EventMap, event: Event, blockHash: string, blockNumb
try {
const { descriptor } = (event as unknown as IEvent<[PolkadotPrimitivesV4CandidateReceipt]>).data[0];
if (descriptor && descriptor.paraId) {
if (descriptor?.paraId) {
map[descriptor.paraId.toString()] = {
blockHash,
blockNumber,

View File

@ -29,8 +29,7 @@ function Parathread ({ id, leasePeriod, leases, nextAction }: Props): React.Reac
const { headHex, lifecycle, manager } = useThreadInfo(id);
const periods = useMemo(
() => leasePeriod?.currentPeriod && leases &&
leases.map(({ period }) => period),
() => leasePeriod?.currentPeriod && leases?.map(({ period }) => period),
[leasePeriod?.currentPeriod, leases]
);

View File

@ -38,7 +38,7 @@ function Proposal ({ approvedIds, id, scheduled }: Props): React.ReactElement<Pr
);
const approveTx = useMemo(
() => api.tx.sudo && api.tx.sudo.sudo(api.tx.proposeParachain.approveProposal(id)),
() => api.tx.sudo?.sudo(api.tx.proposeParachain.approveProposal(id)),
[api, id]
);

View File

@ -18,7 +18,7 @@ function Proposals ({ proposals }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const sortedIds = useMemo(
() => proposals && proposals.proposalIds.sort((a, b) => a.cmp(b)),
() => proposals?.proposalIds.sort((a, b) => a.cmp(b)),
[proposals]
);

View File

@ -68,7 +68,7 @@ function Teleport ({ onClose }: Props): React.ReactElement<Props> | null {
recipientParaId === -1
? index === 0
: recipientParaId === paraId
)?.value as string,
)?.value,
[destinations, recipientParaId]
);

View File

@ -83,7 +83,7 @@ function mergeCurrent (ranges: [number, number][], auctionInfo: AuctionInfo, pre
const current = createWinning(auctionInfo, blockOffset, extractWinners(ranges, auctionInfo, optCurrent));
if (current.winners.length) {
if (!prev || !prev.length) {
if (!prev?.length) {
return [current];
}

View File

@ -25,7 +25,7 @@ function Preimage ({ className, value }: Props): React.ReactElement<Props> {
<Hash value={value} />
<Call value={info} />
<td className='number media--1000'>
{info && info.proposalLength
{info?.proposalLength
? formatNumber(info.proposalLength)
: <span className='--tmp'>999,999</span>}
</td>

View File

@ -41,7 +41,7 @@ function Hashes ({ className }: Props): React.ReactElement<Props> {
empty={hashes && t('No hashes found')}
header={headerRef.current}
>
{hashes && hashes.map((h) => (
{hashes?.map((h) => (
<Preimage
key={h}
value={h}

View File

@ -41,7 +41,7 @@ function usePreimagesImpl (): HexString[] | undefined {
], filter, startValue);
return useMemo(
() => hashes && hashes.map((h) => h.toHex()),
() => hashes?.map((h) => h.toHex()),
[hashes]
);
}

View File

@ -51,17 +51,17 @@ function App ({ basePath, className, palletColl, palletPoll }: Props): React.Rea
<Route
element={
<Referenda
members={members && members.memberIds}
members={members?.memberIds}
palletReferenda={palletPoll}
palletVote={palletColl}
ranks={members && members.memberRanks}
ranks={members?.memberRanks}
/>
}
path='referenda'
/>
<Route
element={
<Members members={members && members.members} />
<Members members={members?.members} />
}
index
/>

View File

@ -32,7 +32,7 @@ function Members ({ className, members }: Props): React.ReactElement<Props> {
header={headerRef.current}
isSplit
>
{members && members.map((a): React.ReactNode => (
{members?.map((a): React.ReactNode => (
<Member
key={a.accountId}
value={a}

View File

@ -44,7 +44,7 @@ function Activity ({ allowEmpty, className, palletReferenda, tracks, value }: Pr
{infos.map(([{ casting, classId, delegating }, info], index) => (
<tr key={index}>
<td className='all'>
{(info && info.trackName) || classId.toString()}
{info?.trackName || classId.toString()}
</td>
<td className='together'>
{

View File

@ -82,9 +82,9 @@ function Delegate ({ className, palletReferenda, palletVote, tracks }: Props): R
() => [
{ text: t('Addresses'), value: 'address' },
isFunction(api.query.staking?.nominators) &&
{ isDisabled: !allVals || !allVals.length, text: t('Validators'), value: 'validators' },
{ isDisabled: !allVals?.length, text: t('Validators'), value: 'validators' },
isFunction(api.query.fellowshipCollective?.members) &&
{ isDisabled: !allFell || !allFell.length, text: t('Fellows'), value: 'fellows' }
{ isDisabled: !allFell?.length, text: t('Fellows'), value: 'fellows' }
],
[allFell, allVals, api, t]
);

Some files were not shown because too many files have changed in this diff Show More