Adjust object indexing (#9564)

* Add tsconfig override

* JSON Comments

* Adjust object indexing

* Dedupe yarn.lock

* Bump deps
This commit is contained in:
Jaco 2023-06-12 09:11:39 +03:00 committed by GitHub
parent 0e65096c73
commit 8f9919c834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 483 additions and 469 deletions

View File

@ -69,7 +69,7 @@
"devDependencies": {
"@crustio/crust-pin": "^1.0.0",
"@pinata/sdk": "^1.2.1",
"@polkadot/dev": "^0.75.16",
"@polkadot/dev": "^0.75.19",
"@types/chart.js": "^2.9.37",
"@types/file-saver": "^2.0.5",
"@types/react-beautiful-dnd": "^13.1.4",
@ -94,34 +94,34 @@
"styled-components": "^5.3.11"
},
"resolutions": {
"@polkadot/api": "^10.8.1",
"@polkadot/api-augment": "^10.8.1",
"@polkadot/api-base": "^10.8.1",
"@polkadot/api-contract": "^10.8.1",
"@polkadot/api-derive": "^10.8.1",
"@polkadot/hw-ledger": "^12.2.2",
"@polkadot/keyring": "^12.2.2",
"@polkadot/networks": "^12.2.2",
"@polkadot/phishing": "^0.21.4",
"@polkadot/rpc-augment": "^10.8.1",
"@polkadot/rpc-core": "^10.8.1",
"@polkadot/rpc-provider": "^10.8.1",
"@polkadot/types": "^10.8.1",
"@polkadot/types-augment": "^10.8.1",
"@polkadot/types-codec": "^10.8.1",
"@polkadot/types-create": "^10.8.1",
"@polkadot/types-known": "^10.8.1",
"@polkadot/types-support": "^10.8.1",
"@polkadot/util": "^12.2.2",
"@polkadot/util-crypto": "^12.2.2",
"@polkadot/api": "^10.9.1",
"@polkadot/api-augment": "^10.9.1",
"@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/phishing": "^0.21.5",
"@polkadot/rpc-augment": "^10.9.1",
"@polkadot/rpc-core": "^10.9.1",
"@polkadot/rpc-provider": "^10.9.1",
"@polkadot/types": "^10.9.1",
"@polkadot/types-augment": "^10.9.1",
"@polkadot/types-codec": "^10.9.1",
"@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.2.2",
"@polkadot/x-fetch": "^12.2.2",
"@polkadot/x-global": "^12.2.2",
"@polkadot/x-randomvalues": "^12.2.2",
"@polkadot/x-textdecoder": "^12.2.2",
"@polkadot/x-textencoder": "^12.2.2",
"@polkadot/x-ws": "^12.2.2",
"@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",
"styled-components": "^5.3.1",
"typescript": "^5.1.3"
}

View File

@ -35,15 +35,15 @@
"@parallel-finance/type-definitions": "1.7.17",
"@peaqnetwork/type-definitions": "0.0.4",
"@phala/typedefs": "0.2.33",
"@polkadot/api": "^10.8.1",
"@polkadot/api-derive": "^10.8.1",
"@polkadot/networks": "^12.2.2",
"@polkadot/types": "^10.8.1",
"@polkadot/types-codec": "^10.8.1",
"@polkadot/util": "^12.2.2",
"@polkadot/api": "^10.9.1",
"@polkadot/api-derive": "^10.9.1",
"@polkadot/networks": "^12.3.2",
"@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.2.2",
"@polkadot/x-ws": "^12.2.2",
"@polkadot/x-fetch": "^12.3.2",
"@polkadot/x-ws": "^12.3.2",
"@polymeshassociation/polymesh-types": "5.4.1",
"@snowfork/snowbridge-types": "0.2.7",
"@sora-substrate/type-definitions": "1.17.12-bridge.2",

View File

@ -1,10 +1,12 @@
// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types';
import { knownGenesis } from '@polkadot/networks/defaults';
import { assert, BN } from '@polkadot/util';
function getGenesis (name: string): string {
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}`);

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { HexString } from '@polkadot/util/types';
import type { Option } from '../settings/types.js';
interface BaseOption {
dnslink?: string;
genesisHash?: string;
genesisHash?: HexString;
homepage?: string;
paraId?: number;
summary?: string;
@ -29,7 +30,7 @@ export interface EndpointOption extends BaseOption {
}
export interface LinkOption extends BaseOption, Option {
genesisHashRelay?: string;
genesisHashRelay?: HexString;
isChild?: boolean;
isDevelopment?: boolean;
isLightClient?: boolean;

View File

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

View File

@ -18,7 +18,7 @@
"dependencies": {
"@polkadot/apps-config": "^0.131.5-26-x",
"@polkadot/apps-routing": "^0.131.5-26-x",
"@polkadot/dev": "^0.75.16",
"@polkadot/dev": "^0.75.19",
"@polkadot/react-api": "^0.131.5-26-x",
"@polkadot/react-components": "^0.131.5-26-x",
"@polkadot/react-hooks": "^0.131.5-26-x",

View File

@ -16,12 +16,12 @@
"type": "module",
"version": "0.131.5-26-x",
"dependencies": {
"@polkadot/hw-ledger": "^12.2.2",
"@polkadot/phishing": "^0.21.4",
"@polkadot/hw-ledger": "^12.3.2",
"@polkadot/phishing": "^0.21.5",
"@polkadot/react-components": "^0.131.5-26-x",
"@polkadot/react-hooks": "^0.131.5-26-x",
"@polkadot/util": "^12.2.2",
"@polkadot/vanitygen": "^0.55.2",
"@polkadot/util": "^12.3.2",
"@polkadot/vanitygen": "^0.55.3",
"detect-browser": "^5.3.0",
"file-saver": "^2.0.5"
},

View File

@ -454,7 +454,7 @@ describe.skip('Accounts page', () => {
describe('when genesis hash set', () => {
beforeEach(async () => {
accountsPage.renderAccountsWithDefaultAddresses(
anAccountWithInfoAndMeta({ flags: { isDevelopment: true } as AddressFlags }, { genesisHash: 'someHash', name: 'charlie' })
anAccountWithInfoAndMeta({ flags: { isDevelopment: true } as AddressFlags }, { genesisHash: '0x1234', name: 'charlie' })
);
accountRows = await accountsPage.getAccountRows();
});

View File

@ -230,7 +230,7 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ
setIsBusy(true);
nextTick((): void => {
const options = { genesisHash: isDevelopment ? undefined : api.genesisHash.toString(), isHardware: false, name: name.trim() };
const options = { genesisHash: isDevelopment ? undefined : api.genesisHash.toHex(), isHardware: false, name: name.trim() };
const status = createAccount(seed, derivePath, pairType, options, password, t<string>('created account'));
onStatusChange(status);

View File

@ -3,6 +3,7 @@
import type { KeyringPair } from '@polkadot/keyring/types';
import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { HexString } from '@polkadot/util/types';
import type { KeypairType } from '@polkadot/util-crypto/types';
import React, { useCallback, useEffect, useState } from 'react';
@ -55,7 +56,7 @@ function deriveValidate (suri: string, pairType: KeypairType): string | null {
return null;
}
function createAccount (source: KeyringPair, suri: string, name: string, password: string, success: string, genesisHash?: string): ActionStatus {
function createAccount (source: KeyringPair, suri: string, name: string, password: string, success: string, genesisHash?: HexString): ActionStatus {
const commitAccount = () => {
const derived = source.derive(suri);
@ -136,7 +137,7 @@ function Derive ({ className = '', from, onClose }: Props): React.ReactElement {
setIsBusy(true);
nextTick((): void => {
const status = createAccount(source, suri, name, password, t<string>('created account'), isDevelopment ? undefined : api.genesisHash.toString());
const status = createAccount(source, suri, name, password, t<string>('created account'), isDevelopment ? undefined : api.genesisHash.toHex());
queueAction(status);
setIsBusy(false);

View File

@ -4,6 +4,7 @@
import type { Dispatch, SetStateAction } from 'react';
import type { KeyringPair, KeyringPair$Json } from '@polkadot/keyring/types';
import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { HexString } from '@polkadot/util/types';
import type { ModalProps } from '../types.js';
import React, { useCallback, useMemo, useState } from 'react';
@ -29,7 +30,7 @@ interface PassState {
const acceptedFormats = ['application/json', 'text/plain'];
function parseFile (file: Uint8Array, setError: Dispatch<SetStateAction<string | null>>, isEthereum: boolean, genesisHash?: string | null): KeyringPair | null {
function parseFile (file: Uint8Array, setError: Dispatch<SetStateAction<string | null>>, isEthereum: boolean, genesisHash?: HexString | null): KeyringPair | null {
try {
const pair = keyring.createFromJson(JSON.parse(u8aToString(file)) as KeyringPair$Json, { genesisHash });

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { HexString } from '@polkadot/util/types';
import type { ModalProps } from '../types.js';
import React, { useCallback, useState } from 'react';
@ -22,7 +23,7 @@ interface Props extends ModalProps {
}
interface CreateOptions {
genesisHash?: string;
genesisHash?: HexString;
name: string;
tags?: string[];
}
@ -99,7 +100,7 @@ function Multisig ({ className = '', onClose, onStatusChange }: Props): React.Re
const _createMultisig = useCallback(
(): void => {
const options = { genesisHash: isDevelopment ? undefined : api.genesisHash.toString(), name: name.trim() };
const options = { genesisHash: isDevelopment ? undefined : api.genesisHash.toHex(), name: name.trim() };
const status = createMultisig(signatories, threshold, options, t<string>('created multisig'));
onStatusChange(status);

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { HexString } from '@polkadot/util/types';
import type { ModalProps } from '../types.js';
import React, { useCallback, useState } from 'react';
@ -20,7 +21,7 @@ interface Props extends ModalProps {
}
interface CreateOptions {
genesisHash?: string;
genesisHash?: HexString;
name: string;
tags?: string[];
}
@ -53,7 +54,7 @@ function ProxyAdd ({ className = '', onClose, onStatusChange }: Props): React.Re
const _createProxied = useCallback(
(): void => {
if (stashAddress) {
const options = { genesisHash: isDevelopment ? undefined : api.genesisHash.toString(), name: name.trim() };
const options = { genesisHash: isDevelopment ? undefined : api.genesisHash.toHex(), name: name.trim() };
const status = createProxy(stashAddress, options, t<string>('added proxy'));
onStatusChange(status);

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { HexString } from '@polkadot/util/types';
import type { ModalProps } from '../types.js';
import React, { useCallback, useMemo, useState } from 'react';
@ -16,7 +17,7 @@ import PasswordInput from './PasswordInput.js';
interface Scanned {
content: string;
isAddress: boolean;
genesisHash: string;
genesisHash: HexString | null;
name?: string;
}

View File

@ -6,6 +6,7 @@ import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { Balance, Conviction } from '@polkadot/types/interfaces';
import type { KeyringAddress } from '@polkadot/ui-keyring/types';
import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types';
export type { AppProps as ComponentProps } from '@polkadot/react-components/types';
@ -65,7 +66,7 @@ export interface AddressState {
}
export interface CreateOptions {
genesisHash?: string;
genesisHash?: HexString;
name: string;
tags?: string[];
}

View File

@ -74,7 +74,7 @@ export type SortCategory = typeof SORT_CATEGORY[number];
function comparator (accountsMap: Record<string, SortedAccount>, balances: Record<string, AccountBalance | undefined>, category: SortCategory, fromMax: boolean): (a: SortedAccount, b: SortedAccount) => number {
function accountQualifiedName (account: SortedAccount | undefined): string {
if (account) {
const parent = (account.account?.meta.parentAddress || '') as string;
const parent = (account.account?.meta.parentAddress || '');
return accountQualifiedName(accountsMap[parent]) + account.address;
} else {

View File

@ -3,6 +3,7 @@
import type { ActionStatus } from '@polkadot/react-components/Status/types';
import type { KeyringAddress } from '@polkadot/ui-keyring/types';
import type { HexString } from '@polkadot/util/types';
import React, { useCallback, useEffect, useState } from 'react';
@ -107,7 +108,7 @@ function Address ({ address, className = '', filter, isFavorite, toggleFavorite
}, [accName, filter, tags]);
const _onGenesisChange = useCallback(
(genesisHash: string | null): void => {
(genesisHash: HexString | null): void => {
setGenesisHash(genesisHash);
const account = keyring.getAddress(address);

View File

@ -16,7 +16,7 @@
"type": "module",
"version": "0.131.5-26-x",
"dependencies": {
"@polkadot/api-contract": "^10.8.1",
"@polkadot/api-contract": "^10.9.1",
"eventemitter3": "^5.0.1"
},
"peerDependencies": {

View File

@ -104,7 +104,7 @@ function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex
abi: stringify(result.contract.abi.json),
genesisHash: api.genesisHash.toHex()
},
name,
name: name || undefined,
tags: []
});

View File

@ -141,7 +141,7 @@ function UploadModal ({ className, file, onClose = NOOP, onSuccess = NOOP }: Pro
// for injected, retrieve the signer
if (meta.source && isInjected) {
web3FromSource(meta.source as string)
web3FromSource(meta.source)
.catch(() => null)
.then((injected) => setSigner({
isUsable: isFunction(injected?.signer?.signRaw),

View File

@ -63,7 +63,7 @@ function Sign ({ className = '' }: Props): React.ReactElement<Props> {
// for injected, retrieve the signer
if (meta.source && isInjected) {
web3FromSource(meta.source as string)
web3FromSource(meta.source)
.catch((): null => null)
.then((injected) => setSigner({
isUsable: isFunction(injected?.signer?.signRaw),

View File

@ -20,10 +20,10 @@
"path": false
},
"dependencies": {
"@polkadot/api": "^10.8.1",
"@polkadot/extension-compat-metamask": "^0.46.4",
"@polkadot/extension-dapp": "^0.46.4",
"@polkadot/rpc-provider": "^10.8.1",
"@polkadot/api": "^10.9.1",
"@polkadot/extension-compat-metamask": "^0.46.5",
"@polkadot/extension-dapp": "^0.46.5",
"@polkadot/rpc-provider": "^10.9.1",
"fflate": "^0.8.0",
"rxjs": "^7.8.1"
},

View File

@ -19,15 +19,15 @@
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@polkadot/keyring": "^12.2.2",
"@polkadot/keyring": "^12.3.2",
"@polkadot/react-api": "^0.131.5-26-x",
"@polkadot/react-identicon": "^3.4.2",
"@polkadot/react-qr": "^3.4.2",
"@polkadot/react-identicon": "^3.5.1",
"@polkadot/react-qr": "^3.5.1",
"@polkadot/react-query": "^0.131.5-26-x",
"@polkadot/ui-keyring": "^3.4.2",
"@polkadot/ui-settings": "^3.4.2",
"@polkadot/util": "^12.2.2",
"@polkadot/util-crypto": "^12.2.2",
"@polkadot/ui-keyring": "^3.5.1",
"@polkadot/ui-settings": "^3.5.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"chart.js": "^4.3.0",
"chartjs-plugin-annotation": "^3.0.1",
"chartjs-plugin-crosshair": "^1.2.0",

View File

@ -31,7 +31,7 @@ function Multisig ({ isMultisig, meta }: Props): React.ReactElement<Props> | nul
<div className='tr'>
<div className='th'>{t<string>('threshold')}</div>
<div className='td'>
{threshold as string}/{(who as string[]).length}
{threshold}/{who?.length}
</div>
</div>
<div className='tr'>

View File

@ -38,7 +38,7 @@ function SidebarEditableSection ({ accountIndex, address, isBeingEdited, onUpdat
const accountOrAddress = keyring.getAccount(address) || keyring.getAddress(address);
setName(accountOrAddress?.meta.name || '');
setTags(accountOrAddress?.meta.tags ? (accountOrAddress.meta.tags as string[]).sort() : []);
setTags(accountOrAddress?.meta.tags ? (accountOrAddress.meta.tags).sort() : []);
setIsEditingName(false);
setIsEditingTags(false);
} catch {

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types';
import React, { useCallback, useMemo } from 'react';
import { useApi } from '@polkadot/react-hooks';
@ -14,7 +16,7 @@ interface Props {
className?: string;
genesisHash: string | null;
isDisabled?: boolean;
onChange: (genesisHash: string | null) => void;
onChange: (genesisHash: HexString | null) => void;
}
function calcLock (apiGenesis: string, genesisHash: string | null): boolean {

View File

@ -16,8 +16,8 @@
"type": "module",
"version": "0.131.5-26-x",
"dependencies": {
"@polkadot/hw-ledger": "^12.2.2",
"@polkadot/hw-ledger-transports": "^12.2.2",
"@polkadot/hw-ledger": "^12.3.2",
"@polkadot/hw-ledger-transports": "^12.3.2",
"is-ipfs": "^8.0.1"
},
"peerDependencies": {

View File

@ -134,7 +134,7 @@ export interface UseAccountInfo {
toggleIsEditingTags: () => void;
onSaveName: () => void;
onSaveTags: () => void;
onSetGenesisHash: (genesisHash: string | null) => void;
onSetGenesisHash: (genesisHash: HexString | null) => void;
onForgetAddress: () => void;
setIsEditingName: (isEditing: boolean) => void;
setIsEditingTags: (isEditing: boolean) => void;

View File

@ -3,6 +3,7 @@
import type { Nominations, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { KeyringJson$Meta } from '@polkadot/ui-keyring/types';
import type { HexString } from '@polkadot/util/types';
import type { AddressFlags, AddressIdentity, UseAccountInfo } from './types.js';
import { useCallback, useEffect, useMemo, useState } from 'react';
@ -48,7 +49,7 @@ function useAccountInfoImpl (value: string | null, isContract = false): UseAccou
const [accountIndex, setAccountIndex] = useState<string | undefined>(undefined);
const [tags, setSortedTags] = useState<string[]>([]);
const [name, setName] = useState('');
const [genesisHash, setGenesisHash] = useState<string | null>(null);
const [genesisHash, setGenesisHash] = useState<HexString | null>(null);
const [identity, setIdentity] = useState<AddressIdentity | undefined>();
const [flags, setFlags] = useState<AddressFlags>(IS_NONE);
const [meta, setMeta] = useState<KeyringJson$Meta | undefined>();
@ -137,7 +138,7 @@ function useAccountInfoImpl (value: string | null, isContract = false): UseAccou
}));
setMeta(accountOrAddress?.meta);
setName(accountOrAddress?.meta.name || '');
setSortedTags(accountOrAddress?.meta.tags ? (accountOrAddress.meta.tags as string[]).sort() : []);
setSortedTags(accountOrAddress?.meta.tags?.sort() || []);
} catch {
// ignore
}
@ -228,7 +229,7 @@ function useAccountInfoImpl (value: string | null, isContract = false): UseAccou
);
const onSetGenesisHash = useCallback(
(genesisHash: string | null): void => {
(genesisHash: HexString | null): void => {
if (value) {
const account = keyring.getPair(value);

View File

@ -16,7 +16,7 @@
"type": "module",
"version": "0.131.5-26-x",
"dependencies": {
"@polkadot/hw-ledger": "^12.2.2",
"@polkadot/hw-ledger": "^12.3.2",
"@polkadot/react-components": "^0.131.5-26-x"
},
"peerDependencies": {

View File

@ -20,7 +20,7 @@
"testcontainers": "^9.8.0"
},
"devDependencies": {
"@polkadot/types-support": "^10.8.1",
"@polkadot/types-support": "^10.9.1",
"@testing-library/jest-dom": "^5.16.5",
"tsconfig-paths": "^4.2.0"
},

771
yarn.lock

File diff suppressed because it is too large Load Diff