Skip to content

Commit

Permalink
bring Lint to work
Browse files Browse the repository at this point in the history
upgrade yar and node and remove some ts nocheck directives
  • Loading branch information
Nick-1979 committed Jul 23, 2024
1 parent 6d7e745 commit 9406150
Show file tree
Hide file tree
Showing 21 changed files with 19,045 additions and 13,775 deletions.
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.1.cjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ logFilters:
- code: YN0013
level: discard

nodeLinker: node-modules
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.1.cjs
2 changes: 1 addition & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "Functions, classes and other utilities used in @polkadot/extension",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-base#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "Definitions for all known chains as exposed by the extension.",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-chains#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-compat-metamask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "Metamask compatibility layer",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-compat-metamask#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "Provides an interfaces around the injected globals for ease of access by dapp developers.",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-dapp#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-inject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "A generic injector (usable to any extension), that populates the base exposed interfaces to be used by dapps.",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-inject#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "Definitions for all known chains as exposed by the extension.",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-mocks#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-polkagate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "A user-friendly wallet for seamless browser-based interaction with Polkadot/Substrate-based blockchains.",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-polkagate#readme",
"license": "Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/extension-polkagate/src/components/Assets.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors
// SPDX-License-Identifier: Apache-2.0
// @ts-nocheck

/* eslint-disable react/jsx-max-props-per-line */

Expand All @@ -13,15 +12,15 @@ import Select2 from './Select2';

interface Props {
address: string | null | undefined;
onChange: (value: string | number) => void;
onChange: (value: any) => void;
label: string;
style: SxProps<Theme> | undefined;
assetId: number | undefined;
setAssetId: React.Dispatch<React.SetStateAction<number | undefined>>

}

function Assets({ address, assetId, label, onChange, setAssetId, style }: Props) {
function Assets ({ address, assetId, label, onChange, setAssetId, style }: Props) {
const tokens = useTokens(address as string);
const chain = useChain(address);
const assetHubOptions = useAssetHubAssets(address as string); // TODO: should we show zero or spam assets?!
Expand All @@ -30,12 +29,13 @@ function Assets({ address, assetId, label, onChange, setAssetId, style }: Props)
assetHubOptions
? (tokens || []).concat(assetHubOptions || [])
: multiChainAssetsOptions || tokens || []
, [assetHubOptions, multiChainAssetsOptions, tokens]);
, [assetHubOptions, multiChainAssetsOptions, tokens]);

const [isLoading, setLoading] = useState<boolean>();

useEffect(() => {
setAssetId(undefined); // this will set the asset to the native asset on chain switch
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chain]);

useEffect(() => {
Expand Down
26 changes: 12 additions & 14 deletions packages/extension-polkagate/src/components/Identity.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors
// SPDX-License-Identifier: Apache-2.0
// @ts-nocheck

/* eslint-disable react/jsx-max-props-per-line */

import { Email as EmailIcon, Language as LanguageIcon, X as XIcon } from '@mui/icons-material';
import { Box, Grid, Link, type SxProps, type Theme, Typography, useTheme } from '@mui/material';
import { grey } from '@mui/material/colors';
import React, { useEffect, useMemo } from 'react';

import { ApiPromise } from '@polkadot/api';
import { DeriveAccountInfo, DeriveAccountRegistration } from '@polkadot/api-derive/types';
import type { ApiPromise } from '@polkadot/api';
import type { DeriveAccountInfo, DeriveAccountRegistration } from '@polkadot/api-derive/types';
import type { Chain } from '@polkadot/extension-chains/types';

import type { AccountId } from '@polkadot/types/interfaces/runtime';

import { Email as EmailIcon, Language as LanguageIcon, X as XIcon } from '@mui/icons-material';
import { Box, Grid, Link, Typography, useTheme } from '@mui/material';
import { grey } from '@mui/material/colors';
import React, { type CSSProperties, useEffect, useMemo } from 'react';

import { ms, msGreen, msWarning, riot } from '../assets/icons';
import { useAccountName, useChain, useFormatted2, useIdentity, useMerkleScience, useTranslation } from '../hooks';
import { getSubstrateAddress, isValidAddress } from '../util/utils';
Expand All @@ -24,7 +22,7 @@ interface Props {
accountInfo?: DeriveAccountInfo | null;
address?: string | AccountId;
api?: ApiPromise;
chain?: Chain;
chain?: Chain | null;
direction?: 'row' | 'column';
formatted?: string | AccountId;
identiconSize?: number;
Expand All @@ -33,15 +31,15 @@ interface Props {
noIdenticon?: boolean;
onClick?: () => void;
returnIdentity?: React.Dispatch<React.SetStateAction<DeriveAccountRegistration | undefined>>;// to return back identity when needed
style?: SxProps<Theme>;
style?: CSSProperties;
showChainLogo?: boolean;
showShortAddress?: boolean;
showSocial?: boolean;
withShortAddress?: boolean;
subIdOnly?: boolean;
}

function Identity({ accountInfo, address, api, chain, direction = 'column', formatted, identiconSize = 40, judgement, name, noIdenticon = false, onClick, returnIdentity, showChainLogo = false, showShortAddress, showSocial = true, style, subIdOnly = false, withShortAddress }: Props): React.ReactElement<Props> {
function Identity ({ accountInfo, address, api, chain, direction = 'column', formatted, identiconSize = 40, judgement, name, noIdenticon = false, onClick, returnIdentity, showChainLogo = false, showShortAddress, showSocial = true, style, subIdOnly = false, withShortAddress }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const theme = useTheme();

Expand All @@ -52,8 +50,8 @@ function Identity({ accountInfo, address, api, chain, direction = 'column', form
const _formatted = useFormatted2(address, formatted, chain)?.toString();
const msData = useMerkleScience(_formatted, chain);

const isMSgreen = ['Exchange', 'Donation'].includes(msData?.tag_type_verbose);
const isMSwarning = ['Scam', 'High Risk Organization', 'Theft', 'Sanctions'].includes(msData?.tag_type_verbose);
const isMSgreen = ['Exchange', 'Donation'].includes(msData?.tag_type_verbose as string);
const isMSwarning = ['Scam', 'High Risk Organization', 'Theft', 'Sanctions'].includes(msData?.tag_type_verbose as string);
const _showSocial = msData ? false : showSocial;

const genesisHash = chain?.genesisHash || api?.genesisHash?.toHex();
Expand Down
3 changes: 1 addition & 2 deletions packages/extension-polkagate/src/hooks/useChain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors
// SPDX-License-Identifier: Apache-2.0
// @ts-nocheck

import type { Chain } from '@polkadot/extension-chains/types';
import type { AccountId } from '@polkadot/types/interfaces/runtime';
Expand All @@ -10,7 +9,7 @@ import { useMemo } from 'react';
import { getSubstrateAddress } from '../util/utils';
import { useAccount, useMetadata } from './';

export default function useChain(address: AccountId | string | null | undefined, chain?: Chain): Chain | null | undefined {
export default function useChain (address: AccountId | string | null | undefined, chain?: Chain | null): Chain | null | undefined {
/** address can be a formatted address hence needs to find its substrate format first */
const sAddr = getSubstrateAddress(address);
const account = useAccount(sAddr);
Expand Down
9 changes: 4 additions & 5 deletions packages/extension-polkagate/src/hooks/useIdentity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors
// SPDX-License-Identifier: Apache-2.0

// @ts-nocheck

//@ts-nocheck
import type { DeriveAccountInfo } from '@polkadot/api-derive/types';
import type { PalletIdentityRegistration } from '@polkadot/types/lookup';

Expand All @@ -17,7 +16,7 @@ interface SubIdentity {
display: string
}

export default function useIdentity(genesisHash: string | undefined, formatted: string | undefined, accountInfo?: DeriveAccountInfo): DeriveAccountInfo | undefined | null {
export default function useIdentity (genesisHash: string | undefined, formatted: string | undefined, accountInfo?: DeriveAccountInfo | null): DeriveAccountInfo | undefined | null {
const [info, setInfo] = useState<DeriveAccountInfo | null>();

const { peopleChain } = usePeopleChain(undefined, genesisHash);
Expand Down Expand Up @@ -55,7 +54,7 @@ export default function useIdentity(genesisHash: string | undefined, formatted:
}

const s = await api.query['identity']['superOf'](formatted) as any;
const subId = s.isSome ? s.unwrap() : undefined;
const subId = s.isSome ? s.unwrap() : undefined;

return subId
? {
Expand Down Expand Up @@ -94,7 +93,7 @@ export default function useIdentity(genesisHash: string | undefined, formatted:
return setInfo(subIdentity);
}
}).catch(console.error);
}else{
} else {
setInfo(null);
}
}).catch(console.error);
Expand Down
13 changes: 6 additions & 7 deletions packages/extension-polkagate/src/hooks/useMerkleScience.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors
// SPDX-License-Identifier: Apache-2.0
// @ts-nocheck

import { useEffect, useState } from 'react';

import type { Chain } from '@polkadot/extension-chains/types';

import type { AccountId } from '@polkadot/types/interfaces/runtime';
import type { MsData } from '../util/getMS';

import { useEffect, useState } from 'react';

import { POLKADOT_GENESIS_HASH } from '../util/constants';
import { getJsonFileFromRepo, MsData } from '../util/getMS';
import { getJsonFileFromRepo } from '../util/getMS';

export default function useMerkleScience(address: string | AccountId | null | undefined, chain: Chain | undefined, initialize?: boolean): MsData | undefined {
export default function useMerkleScience (address: string | AccountId | null | undefined, chain: Chain | null | undefined, initialize?: boolean): MsData | undefined {
const [data, setData] = useState<MsData>();

useEffect(() => {
Expand All @@ -20,7 +19,7 @@ export default function useMerkleScience(address: string | AccountId | null | un
}

chrome.storage.local.get('merkleScience', (res) => {
const data = res?.merkleScience as MsData[];
const data = res?.['merkleScience'] as MsData[];
const found = data?.find((d) => d.address?.toLowerCase() === String(address).toLowerCase());

setData(found);
Expand Down
15 changes: 8 additions & 7 deletions packages/extension-polkagate/src/popup/account/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors
// SPDX-License-Identifier: Apache-2.0
// @ts-nocheck

/* eslint-disable header/header */
/* eslint-disable react/jsx-max-props-per-line */

Expand All @@ -9,6 +9,8 @@
* this component shows an account information in detail
* */

import type { BalancesInfo, FormattedAddressState } from '../../util/types';

import { faCoins, faHistory, faPaperPlane, faPiggyBank, faVoteYea } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { ArrowForwardIosRounded as ArrowForwardIosRoundedIcon } from '@mui/icons-material';
Expand All @@ -25,7 +27,6 @@ import { useBalances, useGenesisHashOptions, useInfo, useMyAccountIdentity, useT
import { tieAccount, windowOpen } from '../../messaging';
import { FullScreenRemoteNode, HeaderBrand } from '../../partials';
import { CROWDLOANS_CHAINS, GOVERNANCE_CHAINS, STAKING_CHAINS } from '../../util/constants';
import type { BalancesInfo, FormattedAddressState } from '../../util/types';
import StakingOption from '../staking/Options';
import LockedInReferenda from './unlock/LockedInReferenda';
import AccountBrief from './AccountBrief';
Expand Down Expand Up @@ -125,7 +126,7 @@ export default function AccountDetails(): React.ReactElement {
: showStakingOptions
? theme.palette.secondary.main
: theme.palette.text.primary
, [genesisHash, showStakingOptions, theme.palette.action.disabledBackground, theme.palette.secondary.main, theme.palette.text.primary]);
, [genesisHash, showStakingOptions, theme.palette.action.disabledBackground, theme.palette.secondary.main, theme.palette.text.primary]);

const goToOthers = useCallback(() => {
setShowOthers(true);
Expand Down Expand Up @@ -169,7 +170,7 @@ export default function AccountDetails(): React.ReactElement {
<Motion>
<HeaderBrand
_centerItem={
<Identity address={address} api={api} chain={chain as any} formatted={formatted} identiconSize={40} showSocial={false} style={{ fontSize: '32px', height: '40px', lineHeight: 'initial', maxWidth: '65%' }} subIdOnly />
<Identity address={address} api={api} chain={chain} formatted={formatted} identiconSize={40} showSocial={false} style={{ fontSize: '32px', height: '40px', lineHeight: 'initial', maxWidth: '65%' }} subIdOnly />
}
address={address}
fullScreenURL={`/accountfs/${address}/0`}
Expand All @@ -194,7 +195,7 @@ export default function AccountDetails(): React.ReactElement {
address={address}
assetId={assetId}
label={t<string>('Asset')}
onChange={_onChangeAsset as any}
onChange={_onChangeAsset}
setAssetId={setAssetId}
style={{ width: '27%' }}
/>
Expand Down Expand Up @@ -269,7 +270,7 @@ export default function AccountDetails(): React.ReactElement {
divider
icon={
showStakingOptions
? <Box component='img' src={stakingClose} width='30px' />
? <Box component='img' src={stakingClose as string} width='30px' />
: <FontAwesomeIcon
color={stakingIconColor}
icon={faCoins}
Expand Down Expand Up @@ -309,7 +310,7 @@ export default function AccountDetails(): React.ReactElement {
<Others
address={address}
balances={balances}
chain={chain as any}
chain={chain}
identity={identity}
setShow={setShowOthers}
show={showOthers}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const ShowMembers = ({ address, poolToShow }: InsidersProps) => {
{membersToShow?.length
? membersToShow.map((member, index) => (
<Grid container item key={index} sx={{ '&:last-child': { border: 'none' }, borderBottom: '1px solid', borderBottomColor: 'secondary.light' }}>
<Identity address={member.accountId} api={api} chain={chain as any} formatted={member.accountId} identiconSize={25} showShortAddress style={{ fontSize: '14px', minHeight: '45px', pl: '10px', width: '50%' }} />
<Identity address={member.accountId} api={api} chain={chain as any} formatted={member.accountId} identiconSize={25} showShortAddress style={{ fontSize: '14px', minHeight: '45px', width: '50%' }} />
<Grid alignItems='center' container fontSize='14px' fontWeight='400' item justifyContent='center' sx={{ borderColor: 'secondary.light', borderInline: '1px solid' }} width='30%'>
<ShowBalance
balance={toBalance(member.points) as Balance}
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "A sample signer extension for the @polkadot/api",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension-ui#readme",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bugs": "https://github.com/polkagate/extension/issues",
"description": "A sample signer extension for the @polkadot/api",
"engines": {
"node": ">=18"
"node": ">=18.18"
},
"homepage": "https://github.com/polkagate/extension/tree/master/packages/extension#readme",
"license": "Apache-2.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1341,5 +1341,8 @@
"Dismiss": "",
"Version {{version}}": "",
"Dismiss All": "",
"Address offset {{index}}": ""
"Address offset {{index}}": "",
"What's New 🚀": "",
"Import the account into the extension": "",
"Select accounts to import into the extension": ""
}
Loading

0 comments on commit 9406150

Please sign in to comment.