Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^5.9.2-2",
"@polkadot/api-contract": "^5.9.2-2",
"@polkadot/hw-ledger": "^7.3.1",
"@polkadot/keyring": "^7.3.1",
"@polkadot/networks": "^7.3.1",
"@polkadot/phishing": "^0.6.290",
"@polkadot/types": "^5.9.2-2",
"@polkadot/types-known": "^5.9.2-2",
"@polkadot/types-support": "^5.9.2-2",
"@polkadot/util": "^7.3.1",
"@polkadot/util-crypto": "^7.3.1",
"@polkadot/api": "^6.0.1",
"@polkadot/api-contract": "^6.0.1",
"@polkadot/hw-ledger": "^7.4.1",
"@polkadot/keyring": "^7.4.1",
"@polkadot/networks": "^7.4.1",
"@polkadot/phishing": "^0.6.296",
"@polkadot/types": "^6.0.1",
"@polkadot/types-known": "^6.0.1",
"@polkadot/types-support": "^6.0.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"@polkadot/wasm-crypto": "^4.2.1",
"babel-core": "^7.0.0-bridge.0",
"styled-components": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@laminar/type-definitions": "0.3.1",
"@parallel-finance/type-definitions": "1.1.3",
"@phala/typedefs": "0.2.25",
"@polkadot/networks": "^7.3.1",
"@polkadot/networks": "^7.4.1",
"@polymathnetwork/polymesh-types": "0.0.2",
"@snowfork/snowbridge-types": "0.2.5",
"@sora-substrate/type-definitions": "1.6.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/page-accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/phishing": "^0.6.295",
"@polkadot/phishing": "^0.6.296",
"@polkadot/react-components": "^0.95.2-139",
"@polkadot/vanitygen": "^0.45.6-0",
"@polkadot/vanitygen": "^0.45.6-1",
"detect-browser": "^5.2.1",
"file-saver": "^2.0.5"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/page-accounts/src/Sidebar/Identity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Identity ({ address, identity }: Props): React.ReactElement<Props> | nu
? identity.email
: (
<a
href={`mailto:${identity.email as string}`}
href={`mailto:${identity.email}`}
rel='noopener noreferrer'
target='_blank'
>
Expand All @@ -121,7 +121,7 @@ function Identity ({ address, identity }: Props): React.ReactElement<Props> | nu
? identity.web
: (
<a
href={(identity.web as string).replace(/^(https?:\/\/)?/g, 'https://')}
href={(identity.web).replace(/^(https?:\/\/)?/g, 'https://')}
rel='noopener noreferrer'
target='_blank'
>
Expand All @@ -140,9 +140,9 @@ function Identity ({ address, identity }: Props): React.ReactElement<Props> | nu
: (
<a
href={
(identity.twitter as string).startsWith('https://twitter.com/')
? (identity.twitter as string)
: `https://twitter.com/${identity.twitter as string}`
(identity.twitter).startsWith('https://twitter.com/')
? (identity.twitter)
: `https://twitter.com/${identity.twitter}`
}
rel='noopener noreferrer'
target='_blank'
Expand Down
2 changes: 1 addition & 1 deletion packages/page-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api-contract": "^5.9.2-2"
"@polkadot/api-contract": "^6.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/page-contracts/src/Contracts/Deploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex
const [params, setParams] = useState<any[]>([]);
const [accountId, isAccountIdValid, setAccountId] = useFormField<string | null>(null);
const [endowment, isEndowmentValid, setEndowment] = useNonZeroBn(ENDOWMENT);
const [salt, setSalt] = useState(() => randomAsHex());
const [salt, setSalt] = useState<string>(() => randomAsHex());
const [withSalt, setWithSalt] = useState(false);

useEffect((): void => {
Expand Down
36 changes: 18 additions & 18 deletions packages/page-settings/src/useChainInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2017-2021 @polkadot/app-settings authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { ApiPromise } from '@polkadot/api';
import type { ChainInfo } from './types';

import { useMemo } from 'react';
Expand All @@ -11,29 +10,30 @@ import { DEFAULT_DECIMALS, DEFAULT_SS58 } from '@polkadot/react-api';
import { useApi } from '@polkadot/react-hooks';
import { getSpecTypes } from '@polkadot/types-known';
import { formatBalance, isNumber } from '@polkadot/util';

function createInfo (api: ApiPromise, systemChain: string, systemName: string, specName: string, isEthereum: boolean): ChainInfo {
return {
chain: systemChain,
chainType: isEthereum ? 'ethereum' : 'substrate',
color: getSystemColor(systemChain, systemName, specName),
genesisHash: api.genesisHash.toHex(),
icon: getSystemIcon(systemName, specName),
metaCalls: Buffer.from(api.runtimeMetadata.asCallsOnly.toU8a()).toString('base64'),
specVersion: api.runtimeVersion.specVersion.toNumber(),
ss58Format: isNumber(api.registry.chainSS58) ? api.registry.chainSS58 : DEFAULT_SS58.toNumber(),
tokenDecimals: (api.registry.chainDecimals || [DEFAULT_DECIMALS.toNumber()])[0],
tokenSymbol: (api.registry.chainTokens || formatBalance.getDefaults().unit)[0],
types: getSpecTypes(api.registry, systemChain, api.runtimeVersion.specName, api.runtimeVersion.specVersion) as unknown as Record<string, string>
};
}
import { base64Encode } from '@polkadot/util-crypto';

export default function useChainInfo (): ChainInfo | null {
const { api, isApiReady, isEthereum, specName, systemChain, systemName } = useApi();

return useMemo(
() => isApiReady
? createInfo(api, systemChain, systemName, specName, isEthereum)
? {
chain: systemChain,
chainType: isEthereum
? 'ethereum'
: 'substrate',
color: getSystemColor(systemChain, systemName, specName),
genesisHash: api.genesisHash.toHex(),
icon: getSystemIcon(systemName, specName),
metaCalls: base64Encode(api.runtimeMetadata.asCallsOnly.toU8a()),
specVersion: api.runtimeVersion.specVersion.toNumber(),
ss58Format: isNumber(api.registry.chainSS58)
? api.registry.chainSS58
: DEFAULT_SS58.toNumber(),
tokenDecimals: (api.registry.chainDecimals || [DEFAULT_DECIMALS.toNumber()])[0],
tokenSymbol: (api.registry.chainTokens || formatBalance.getDefaults().unit)[0],
types: getSpecTypes(api.registry, systemChain, api.runtimeVersion.specName, api.runtimeVersion.specVersion) as unknown as Record<string, string>
}
: null,
[api, isApiReady, specName, systemChain, systemName, isEthereum]
);
Expand Down
7 changes: 1 addition & 6 deletions packages/page-signing/src/Verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { KeypairType } from '@polkadot/util-crypto/types';
import React, { useCallback, useEffect, useState } from 'react';
import styled from 'styled-components';

import { wrapBytes } from '@polkadot/extension-dapp';
import { Badge, Dropdown, Input, InputAddress, Static } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import { keyring } from '@polkadot/ui-keyring';
Expand Down Expand Up @@ -37,11 +36,7 @@ function Verify ({ className = '' }: Props): React.ReactElement {

// We use signatureVerify to detect validity and crypto type
if (isValid && publicKey) {
let verification = signatureVerify(data, signature, publicKey);

if (verification.crypto === 'none') {
verification = signatureVerify(wrapBytes(data), signature, publicKey);
}
const verification = signatureVerify(data, signature, publicKey);

if (verification.crypto !== 'none') {
isValid = verification.isValid;
Expand Down
2 changes: 1 addition & 1 deletion packages/page-storage/src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function getCachedComponent (registry: Registry, query: QueryTypes): CacheInstan
const { meta, method, section } = key as unknown as ConstValue;

renderHelper = withCallDiv(`consts.${section}.${method}`, { withIndicator: true });
type = meta.type.toString();
type = registry.lookup.getTypeDef(meta.type).type;
} else {
if (isU8a(key)) {
// subscribe to the raw key here
Expand Down
72 changes: 38 additions & 34 deletions packages/page-storage/src/Selection/Modules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import type { QueryableStorageEntry } from '@polkadot/api/types';
import type { RawParams } from '@polkadot/react-params/types';
import type { StorageEntryTypeLatest } from '@polkadot/types/interfaces';
import type { TypeDef } from '@polkadot/types/types';
import type { SiLookupTypeId, StorageEntryTypeLatest } from '@polkadot/types/interfaces';
import type { Registry, TypeDef } from '@polkadot/types/types';
import type { ComponentProps as Props } from '../types';

import React, { useCallback, useState } from 'react';
Expand Down Expand Up @@ -38,31 +38,29 @@ interface ValState {
}

function areParamsValid ({ creator: { meta: { type } } }: QueryableStorageEntry<'promise'>, values: RawParams): boolean {
return values.reduce((isValid: boolean, value): boolean => {
return isValid &&
!isUndefined(value) &&
!isUndefined(value.value) &&
value.isValid;
}, (values.length === (
type.isPlain
? 0
: type.isMap
? 1
: type.isDoubleMap
? 2
: type.asNMap.keyVec.length
)));
return values.reduce((isValid: boolean, value) =>
isValid &&
!isUndefined(value) &&
!isUndefined(value.value) &&
value.isValid,
(values.length === (type.isPlain ? 0 : type.asMap.hashers.length)));
}

function expandParams (st: StorageEntryTypeLatest, isIterable: boolean): ParamsType {
function expandSiKey (registry: Registry, key: SiLookupTypeId): string {
const typeDef = registry.lookup.getTypeDef(key);

return typeDef.lookupName || typeDef.type;
}

function expandParams (registry: Registry, st: StorageEntryTypeLatest, isIterable: boolean): ParamsType {
let types: string[] = [];

if (st.isDoubleMap) {
types = [st.asDoubleMap.key1.toString(), st.asDoubleMap.key2.toString()];
} else if (st.isMap) {
types = [st.asMap.key.toString()];
} else if (st.isNMap) {
types = st.asNMap.keyVec.map((k) => k.toString());
if (st.isMap) {
const { hashers, key } = st.asMap;

types = hashers.length === 1
? [expandSiKey(registry, key)]
: registry.lookup.getSiType(key).def.asTuple.map((k) => expandSiKey(registry, k));
}

return types.map((str, index) => {
Expand All @@ -79,29 +77,35 @@ function expandParams (st: StorageEntryTypeLatest, isIterable: boolean): ParamsT
});
}

function checkIterable (type: StorageEntryTypeLatest): boolean {
function checkIterable (registry: Registry, type: StorageEntryTypeLatest): boolean {
// in the case of Option<type> keys, we don't allow map iteration, in this case
// we would have option for the iterable and then option for the key value
return type.isPlain || (
type.isMap
? getTypeDef(type.asMap.key.toString())
: type.isDoubleMap
? getTypeDef(type.asDoubleMap.key2.toString())
: getTypeDef(type.asNMap.keyVec[type.asNMap.keyVec.length - 1].toString())
).info !== TypeDefInfo.Option;
if (type.isPlain) {
return true;
}

const { hashers, key } = type.asMap;

if (hashers.length === 1) {
return registry.lookup.getTypeDef(key).info !== TypeDefInfo.Option;
}

const keys = registry.lookup.getSiType(key).def.asTuple;

return registry.lookup.getTypeDef(keys[keys.length - 1]).info !== TypeDefInfo.Option;
}

function expandKey (api: ApiPromise, key: QueryableStorageEntry<'promise'>): KeyState {
const { creator: { meta: { type }, section } } = key;
const isIterable = checkIterable(type);
const isIterable = checkIterable(api.registry, type);

return {
defaultValues: section === 'session' && type.isDoubleMap
defaultValues: section === 'session' && type.isMap
? [{ isValid: true, value: api.consts.session.dedupKeyPrefix.toHex() }]
: null,
isIterable,
key,
params: expandParams(type, isIterable)
params: expandParams(api.registry, type, isIterable)
};
}

Expand Down
6 changes: 3 additions & 3 deletions packages/react-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "^5.9.2-2",
"@polkadot/extension-compat-metamask": "^0.40.2",
"@polkadot/extension-dapp": "^0.40.2",
"@polkadot/api": "^6.0.1",
"@polkadot/extension-compat-metamask": "^0.40.3",
"@polkadot/extension-dapp": "^0.40.3",
"@substrate/connect": "^0.3.18",
"fflate": "^0.7.1",
"rxjs": "^7.3.0"
Expand Down
14 changes: 7 additions & 7 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.15",
"@polkadot/keyring": "^7.3.1",
"@polkadot/keyring": "^7.4.1",
"@polkadot/react-api": "^0.95.2-139",
"@polkadot/react-identicon": "^0.85.4-3",
"@polkadot/react-qr": "^0.85.4-3",
"@polkadot/react-identicon": "^0.85.4",
"@polkadot/react-qr": "^0.85.4",
"@polkadot/react-query": "^0.95.2-139",
"@polkadot/ui-keyring": "^0.85.4-3",
"@polkadot/ui-settings": "^0.85.4-3",
"@polkadot/util": "^7.3.1",
"@polkadot/util-crypto": "^7.3.1",
"@polkadot/ui-keyring": "^0.85.4",
"@polkadot/ui-settings": "^0.85.4",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"chart.js": "^2.9.4",
"codeflask": "^1.4.1",
"i18next": "^19.9.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/Call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import styled from 'styled-components';

import Params from '@polkadot/react-params';
import { FormatBalance } from '@polkadot/react-query';
import { Enum, GenericCall, getTypeDef } from '@polkadot/types';
import { Enum, getTypeDef } from '@polkadot/types';

import Static from './Static';
import { useTranslation } from './translate';
Expand Down Expand Up @@ -58,7 +58,7 @@ function getRawSignature (value: IExtrinsic): ExtrinsicSignature | undefined {
}

function extractState (value: IExtrinsic | IMethod, withHash?: boolean, withSignature?: boolean): Extracted {
const params = GenericCall.filterOrigin(value.meta).map(({ name, type }): Param => ({
const params = value.meta.args.map(({ name, type }): Param => ({
name: name.toString(),
type: getTypeDef(type.toString())
}));
Expand Down
3 changes: 1 addition & 2 deletions packages/react-components/src/Extrinsic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { TypeDef } from '@polkadot/types/types';
import React, { useCallback, useEffect, useState } from 'react';

import Params from '@polkadot/react-params';
import { GenericCall } from '@polkadot/types';
import { getTypeDef } from '@polkadot/types/create';
import { isUndefined } from '@polkadot/util';

Expand Down Expand Up @@ -38,7 +37,7 @@ interface CallState {
}

function getParams ({ meta }: SubmittableExtrinsicFunction<'promise'>): { name: string; type: TypeDef }[] {
return GenericCall.filterOrigin(meta).map((arg): { name: string; type: TypeDef } => ({
return meta.args.map((arg): { name: string; type: TypeDef } => ({
name: arg.name.toString(),
type: getTypeDef(arg.type.toString())
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/src/InputConsts/options/key.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function createOptions (api: ApiPromise, sectionName: string): Dr
className='ui--DropdownLinked-Item-call'
key={`${sectionName}_${value}:call`}
>
{value}: {method.meta.type.toString()}
{value}: {api.registry.lookup.getTypeDef(method.meta.type).type}
</div>,
<div
className='ui--DropdownLinked-Item-text'
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/InputConsts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import type { StorageEntryBase } from '@polkadot/api/types';
import type { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
import type { PalletConstantMetadataLatest } from '@polkadot/types/interfaces';
import type { AnyTuple } from '@polkadot/types/types';

export type StorageEntryPromise = StorageEntryBase<'promise', any, AnyTuple>;
Expand All @@ -13,5 +13,5 @@ export interface ConstValueBase {
}

export interface ConstValue extends ConstValueBase {
meta: ModuleConstantMetadataLatest;
meta: PalletConstantMetadataLatest;
}
Loading