Support latest api (with dynamic types) (#1447)

* Make a start, halfway down with issues found...

* Around  80% through untangling  the linter

* Seems linted...

* Adjust latest

* Update for latest (Moment -> u64)

* Method -> Call

* Bump api from npm

* formatNumber (no unwrap needed)

* Update to latest ui packages

* Revert internal version downgrades
This commit is contained in:
Jaco Greeff 2019-07-29 12:24:43 +02:00 committed by GitHub
parent 8b35e0a3f8
commit b4de745cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
132 changed files with 410 additions and 1136 deletions

View File

@ -10,12 +10,12 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^0.82.0-beta.95",
"@polkadot/api-contract": "^0.82.0-beta.95",
"@polkadot/keyring": "^0.95.0-beta.0",
"@polkadot/types": "^0.82.0-beta.95",
"@polkadot/util": "^0.95.0-beta.0",
"@polkadot/util-crypto": "^0.95.0-beta.0",
"@polkadot/api": "^0.90.0-beta.1",
"@polkadot/api-contract": "^0.90.0-beta.1",
"@polkadot/keyring": "^0.95.0-beta.2",
"@polkadot/types": "^0.90.0-beta.1",
"@polkadot/util": "^0.95.0-beta.2",
"@polkadot/util-crypto": "^0.95.0-beta.2",
"@types/styled-components": "4.1.8",
"babel-core": "^7.0.0-bridge.0",
"typescript": "^3.5.3"

View File

@ -3,12 +3,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, RuntimeVersion } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { BareProps, I18nProps } from '@polkadot/ui-app/types';
import BN from 'bn.js';
import React from 'react';
import { AccountId, RuntimeVersion } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api/with';
import { Bubble, IdentityIcon } from '@polkadot/ui-app';
import { formatBalance, formatNumber } from '@polkadot/util';

View File

@ -3,15 +3,15 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import { Index } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { DerivedFees } from '@polkadot/api-derive/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import BN from 'bn.js';
import React from 'react';
import styled from 'styled-components';
import { Index } from '@polkadot/types';
import { Button, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/ui-app';
import { Available } from '@polkadot/ui-reactive';
import Checks, { calcSignatureLength } from '@polkadot/ui-signer/Checks';

View File

@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.5.5",
"@polkadot/api-contract": "^0.82.0-beta.95",
"@polkadot/api-contract": "^0.90.0-beta.1",
"@polkadot/ui-app": "^0.34.0-beta.87"
}
}

View File

@ -3,8 +3,8 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import React from 'react';
import { createType } from '@polkadot/types';
import { Button, Input } from '@polkadot/ui-app';
import { Hash } from '@polkadot/types';
import ContractModal, { ContractModalProps, ContractModalState } from '../Modal';
import ValidateCode from './ValidateCode';
@ -94,7 +94,7 @@ class Add extends ContractModal<Props, State> {
this.setState({ isBusy: true }, (): void => {
store
.saveCode(new Hash(codeHash), { abi, name, tags })
.saveCode(createType('Hash', codeHash), { abi, name, tags })
.then((): void => {
this.setState(
{ isBusy: false },

View File

@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Hash } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic';
@ -10,7 +11,6 @@ import React from 'react';
import { withApi, withMulti } from '@polkadot/ui-api';
import { Button, InputFile, TxButton } from '@polkadot/ui-app';
import { compactAddLength } from '@polkadot/util';
import { Hash } from '@polkadot/types';
import ContractModal, { ContractModalProps, ContractModalState } from '../Modal';
import store from '../store';

View File

@ -3,7 +3,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { PrefabWasmModule } from '@polkadot/types/srml/contracts/types';
import { PrefabWasmModule } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';

View File

@ -3,7 +3,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ContractInfo } from '@polkadot/types/srml/contracts/types';
import { ContractInfo } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';

View File

@ -2,6 +2,8 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types/interfaces';
import { TypeDef } from '@polkadot/types/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic';
import { I18nProps } from '@polkadot/ui-app/types';
@ -14,7 +16,7 @@ import { Abi } from '@polkadot/api-contract';
import { withApi, withMulti } from '@polkadot/ui-api';
import keyring from '@polkadot/ui-keyring';
import { Button, Dropdown, InputBalance, TxButton } from '@polkadot/ui-app';
import { AccountId, TypeDef, getTypeDef } from '@polkadot/types';
import { getTypeDef } from '@polkadot/types';
import createValues from '@polkadot/ui-params/values';
import ContractModal, { ContractModalProps, ContractModalState } from './Modal';

View File

@ -3,11 +3,12 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ContractABIFnArg } from '@polkadot/api-contract/types';
import { TypeDef } from '@polkadot/types/types';
import { RawParams } from '@polkadot/ui-params/types';
import React from 'react';
import UIParams from '@polkadot/ui-params';
import { getTypeDef, TypeDef } from '@polkadot/types';
import { getTypeDef } from '@polkadot/types';
interface Props {
isDisabled?: boolean;

View File

@ -2,12 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Hash } from '@polkadot/types/interfaces';
import { CodeJson, CodeStored } from './types';
import EventEmitter from 'eventemitter3';
import store from 'store';
import { Abi } from '@polkadot/api-contract';
import { Hash } from '@polkadot/types';
import { createType } from '@polkadot/types';
import { api } from '@polkadot/ui-api';
const KEY_CODE = 'code:';
@ -30,7 +31,7 @@ class Store extends EventEmitter {
}
public async saveCode (codeHash: string | Hash, partial: Partial<CodeJson>): Promise<void> {
const hex = (typeof codeHash === 'string' ? new Hash(codeHash) : codeHash).toHex();
const hex = (typeof codeHash === 'string' ? createType('Hash', codeHash) : codeHash).toHex();
const existing = this.getCode(hex);

View File

@ -2,11 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Proposal as ProposalType, Votes } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { Option, Proposal as ProposalType, Votes } from '@polkadot/types';
import BN from 'bn.js';
import React from 'react';
import { Option } from '@polkadot/types';
import { ActionItem, InputAddress, Labelled, Voting } from '@polkadot/ui-app';
import { withCalls, withMulti } from '@polkadot/ui-api';

View File

@ -2,12 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Call, Proposal } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { Method, Proposal } from '@polkadot/types';
import BN from 'bn.js';
import React from 'react';
import { createType } from '@polkadot/types';
import { Button, Extrinsic, InputNumber } from '@polkadot/ui-app';
import TxModal, { TxModalState, TxModalProps } from '@polkadot/ui-app/TxModal';
import { withApi, withCalls, withMulti } from '@polkadot/ui-api';
@ -19,7 +19,7 @@ interface Props extends TxModalProps, ApiProps {
}
interface State extends TxModalState {
method: Method | null;
method: Call | null;
threshold: BN | null;
}
@ -54,7 +54,7 @@ class Propose extends TxModal<Props, State> {
return [
threshold,
...(method ? [new Proposal(method)] : [])
...(method ? [createType('Proposal', method)] : [])
];
}
@ -124,7 +124,7 @@ class Propose extends TxModal<Props, State> {
this.setState({ threshold });
}
private onChangeExtrinsic = (method: Method): void => {
private onChangeExtrinsic = (method: Call): void => {
if (!method) {
return;
}

View File

@ -3,7 +3,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Hash } from '@polkadot/types';
import { Hash } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types';
import { AccountId } from '@polkadot/types/interfaces';
import React from 'react';
import { AddressCard } from '@polkadot/ui-app';

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber } from '@polkadot/types';
import { BlockNumber } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';

View File

@ -2,8 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { VoteIndex } from '@polkadot/types';
// import { SetIndex } from '@polkadot/types/srml/types';
import { VoteIndex } from '@polkadot/types/interfaces';
import { DerivedVoterPositions } from '@polkadot/api-derive/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { ComponentProps } from './types';
@ -11,6 +10,7 @@ import { ComponentProps } from './types';
import BN from 'bn.js';
import React from 'react';
import styled from 'styled-components';
import { createType } from '@polkadot/types';
import { withApi, withCalls, withMulti } from '@polkadot/ui-api';
import { AddressRow, Button, Icon, Toggle, TxButton } from '@polkadot/ui-app';
import TxModal, { TxModalState, TxModalProps } from '@polkadot/ui-app/TxModal';
@ -140,7 +140,7 @@ class Vote extends TxModal<Props, State> {
return [
approvals ? approvals.slice(0, 1 + approvals.lastIndexOf(true)) : [],
new VoteIndex(voteCount),
createType('VoteIndex', voteCount),
voterPositions && accountId && voterPositions[accountId]
? voterPositions[accountId].setIndex
: nextVoterSet

View File

@ -2,14 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { createType, BlockNumber, VoteIndex } from '@polkadot/types';
import { SetIndex } from '@polkadot/types/srml/elections/types';
import { DerivedElectionsInfo } from '@polkadot/api-derive/types';
import { ComponentProps as Props } from './types';
import BN from 'bn.js';
import React from 'react';
import { createType } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api';
import { Button } from '@polkadot/ui-app';
@ -23,10 +21,10 @@ const NULL_INFO: DerivedElectionsInfo = {
candidates: [],
candidateCount: new BN(0),
desiredSeats: new BN(0),
nextVoterSet: createType<SetIndex>('SetIndex', 0),
termDuration: new BlockNumber(0),
voteCount: new VoteIndex(0),
voterCount: createType<SetIndex>('SetIndex', 0)
nextVoterSet: createType('SetIndex'),
termDuration: createType('BlockNumber'),
voteCount: createType('VoteIndex'),
voterCount: createType('SetIndex')
};
class Overview extends React.PureComponent<Props> {

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { SetIndex } from '@polkadot/types/srml/types';
import { SetIndex } from '@polkadot/types/interfaces';
import { DerivedElectionsInfo } from '@polkadot/api-derive/types';
import BN from 'bn.js';

View File

@ -3,11 +3,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, Balance, Proposal } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import BN from 'bn.js';
import React from 'react';
import { AccountId, Balance, Option, Proposal, Tuple, Vector } from '@polkadot/types';
import { Option, Tuple, Vec } from '@polkadot/types';
import { ActionItem, InputAddress, Labelled, Static } from '@polkadot/ui-app';
import { withCalls, withMulti } from '@polkadot/ui-api';
import { formatBalance } from '@polkadot/util';
@ -16,7 +17,7 @@ import translate from '../translate';
import Seconding from './Seconding';
interface Props extends I18nProps {
democracy_depositOf?: [Balance, Vector<AccountId>] | null;
democracy_depositOf?: [Balance, Vec<AccountId>] | null;
idNumber: BN;
value: Proposal;
}

View File

@ -3,11 +3,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Proposal } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import BN from 'bn.js';
import React from 'react';
import { Proposal } from '@polkadot/types';
import { withCalls, withMulti } from '@polkadot/ui-api';
import { Column } from '@polkadot/ui-app';

View File

@ -2,12 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
import BN from 'bn.js';
import React from 'react';
import { AccountId } from '@polkadot/types';
import { Button, InputAddress, Modal, TxButton } from '@polkadot/ui-app';
import accountObservable from '@polkadot/ui-keyring/observable/accounts';
import { withMulti, withObservable } from '@polkadot/ui-api';

View File

@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Call } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
@ -9,8 +10,7 @@ import BN from 'bn.js';
import React from 'react';
import { RouteComponentProps } from 'react-router';
import { withRouter } from 'react-router-dom';
import { Method, Proposal } from '@polkadot/types';
import { createType } from '@polkadot/types';
import { Button, Extrinsic, InputAddress, InputBalance, TxButton, TxComponent } from '@polkadot/ui-app';
import { withApi, withMulti } from '@polkadot/ui-api';
@ -22,7 +22,7 @@ type Props = I18nProps & ApiProps & RouteComponentProps & {
interface State {
accountId?: string;
method: Method | null;
method: Call | null;
value: BN;
isValid: boolean;
}
@ -69,7 +69,7 @@ class Propose extends TxComponent<Props, State> {
tx='democracy.propose'
isDisabled={!isValid}
params={[
...(method ? [new Proposal(method)] : []),
...(method ? [createType('Proposal', method)] : []),
...(hasValue ? [value] : [])
]}
onSuccess={this.onSubmitProposal}
@ -100,7 +100,7 @@ class Propose extends TxComponent<Props, State> {
this.nextState({ accountId });
}
private onChangeExtrinsic = (method: Method): void => {
private onChangeExtrinsic = (method: Call): void => {
if (!method) {
return;
}

View File

@ -3,10 +3,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Header } from '@polkadot/types/interfaces';
import { BareProps, CallProps } from '@polkadot/ui-api/types';
import React from 'react';
import { Header } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api';
type Props = BareProps & CallProps & {

View File

@ -27,9 +27,8 @@ export default class BlockHeader extends React.PureComponent<Props> {
return null;
}
const { author, blockNumber, hash } = value;
const hashHex = hash.toHex();
const textNumber = formatNumber(blockNumber);
const hashHex = value.hash.toHex();
const textNumber = formatNumber(value.number);
return (
<article className='explorer--BlockHeader'>
@ -42,8 +41,8 @@ export default class BlockHeader extends React.PureComponent<Props> {
}&nbsp;</div>
<div className='hash'>{hashHex}</div>
<div className='author ui--media-small'>{
author
? <AddressMini value={author} />
value.author
? <AddressMini value={value.author} />
: undefined
}</div>
</div>
@ -62,7 +61,7 @@ export default class BlockHeader extends React.PureComponent<Props> {
);
}
private renderDetails ({ blockNumber, extrinsicsRoot, parentHash, stateRoot }: HeaderExtended): React.ReactNode {
private renderDetails ({ number: blockNumber, extrinsicsRoot, parentHash, stateRoot }: HeaderExtended): React.ReactNode {
const parentHex = parentHash.toHex();
return (
@ -70,7 +69,7 @@ export default class BlockHeader extends React.PureComponent<Props> {
<div className='info'>
<label>parentHash</label>
<span className='hash'>{
blockNumber.gtn(1)
blockNumber.unwrap().gtn(1)
? <Link to={`/explorer/query/${parentHex}`}>{parentHex}</Link>
: parentHex
}</span>

View File

@ -21,7 +21,7 @@ const transform = (header: HeaderExtended): HeaderExtended[] => {
blockHeaders = blockHeaders
.filter((old, index): boolean =>
index < MAX_ITEMS && old.blockNumber.lt(header.blockNumber)
index < MAX_ITEMS && old.number.unwrap().lt(header.number.unwrap())
)
.reduce((next, header): HeaderExtended[] => {
next.push(header);
@ -29,7 +29,7 @@ const transform = (header: HeaderExtended): HeaderExtended[] => {
return next;
}, [header])
.sort((a, b): number =>
b.blockNumber.cmp(a.blockNumber)
b.number.unwrap().cmp(a.number.unwrap())
);
return blockHeaders;
@ -46,9 +46,9 @@ class BlockHeaders extends React.PureComponent<Props> {
return headers.map((header, index): React.ReactNode => (
<BlockHeader
isSummary={!!index}
key={header.blockNumber.toString()}
key={header.number.toString()}
value={header}
withLink={!header.blockNumber.isZero()}
withLink={!header.number.isEmpty}
/>
));
}

View File

@ -3,12 +3,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import React from 'react';
import { HeaderExtended } from '@polkadot/api-derive';
import { EventRecord, SignedBlock } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api';
import { Columar } from '@polkadot/ui-app';
@ -43,7 +43,7 @@ class BlockByHash extends React.PureComponent<Props> {
</header>
<Columar>
<Extrinsics
blockNumber={chain_getHeader.blockNumber}
blockNumber={chain_getHeader.number.unwrap()}
value={chain_getBlock.block.extrinsics}
/>
<Events value={system_events} />

View File

@ -3,10 +3,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Hash } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import React from 'react';
import { Hash } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api';
import BlockByHash from './ByHash';

View File

@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventRecord } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import { EventRecord } from '@polkadot/types';
import { Column } from '@polkadot/ui-app';
import EventsDisplay from '../Events';

View File

@ -2,13 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber, Extrinsic } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import styled from 'styled-components';
import { GenericCall } from '@polkadot/types';
import { AddressMini, Call, Column, LinkPolkascan } from '@polkadot/ui-app';
import { formatNumber } from '@polkadot/util';
import { BlockNumber, Extrinsic, Method } from '@polkadot/types';
import translate from '../translate';
@ -42,7 +43,7 @@ class Extrinsics extends React.PureComponent<Props> {
// FIXME This is _very_ similar to what we have in democracy/Item
private renderExtrinsic = (extrinsic: Extrinsic, index: number): React.ReactNode => {
const { blockNumber, t } = this.props;
const { meta, method, section } = Method.findFunction(extrinsic.callIndex);
const { meta, method, section } = GenericCall.findFunction(extrinsic.callIndex);
const isMortal = extrinsic.era.isMortalEra;
let eraEnd;
let eraStart;

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec } from '@polkadot/types/types';
import { DigestItem } from '@polkadot/types/interfaces';
import { Codec, TypeDef } from '@polkadot/types/types';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import { DigestItem, Struct, Tuple, TypeDef, U8a, Vector, getTypeDef } from '@polkadot/types';
import { Struct, Tuple, U8a, Vec, getTypeDef } from '@polkadot/types';
import { Column } from '@polkadot/ui-app';
import Params from '@polkadot/ui-params';
@ -39,7 +40,7 @@ class Logs extends React.PureComponent<Props> {
content = this.formatStruct(item.value);
} else if (item.value instanceof Tuple) {
content = this.formatTuple(item.value);
} else if (item.value instanceof Vector) {
} else if (item.value instanceof Vec) {
content = this.formatVector(item.value);
} else if (item.value instanceof U8a) {
content = this.formatU8a(item.value);
@ -114,7 +115,7 @@ class Logs extends React.PureComponent<Props> {
);
}
private formatVector (vector: Vector<any>): React.ReactNode {
private formatVector (vector: Vec<any>): React.ReactNode {
const type = getTypeDef(vector.Type);
const values = vector.toArray().map((value): { isValid: boolean; value: Codec } => ({
isValid: true,

View File

@ -3,12 +3,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber } from '@polkadot/types/interfaces';
import { BareProps } from '@polkadot/ui-app/types';
import React from 'react';
import { withCalls, withMulti } from '@polkadot/ui-api';
import { isHex } from '@polkadot/util';
import { BlockNumber } from '@polkadot/types';
import Query from '../Query';
import BlockByHash from './ByHash';

View File

@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { PeerInfo } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import { PeerInfo } from '@polkadot/types';
import { formatNumber } from '@polkadot/util';
import translate from './translate';

View File

@ -2,13 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Health, PeerInfo, Extrinsic } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { AppProps, I18nProps } from '@polkadot/ui-app/types';
import { Info } from './types';
import React from 'react';
import { withApi, withMulti } from '@polkadot/ui-api';
import { Health, PeerInfo, PendingExtrinsics, Vector } from '@polkadot/types';
import { Vec } from '@polkadot/types';
import './index.css';
@ -89,8 +90,8 @@ class App extends React.PureComponent<Props, State> {
const [blockNumber, health, peers, extrinsics] = await Promise.all([
api.derive.chain.bestNumber(),
api.rpc.system.health<Health>(),
api.rpc.system.peers<Vector<PeerInfo>>(),
api.rpc.author.pendingExtrinsics<PendingExtrinsics>()
api.rpc.system.peers<Vec<PeerInfo>>(),
api.rpc.author.pendingExtrinsics<Vec<Extrinsic>>()
]);
this.setInfo({ blockNumber, extrinsics, health, peers });

View File

@ -2,11 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber, Health, PeerInfo, PendingExtrinsics } from '@polkadot/types';
import { BlockNumber, Extrinsic, Health, PeerInfo } from '@polkadot/types/interfaces';
import { Vec } from '@polkadot/types';
export interface Info {
blockNumber?: BlockNumber;
health?: Health | null;
peers?: PeerInfo[] | null;
extrinsics?: PendingExtrinsics | null;
extrinsics?: Vec<Extrinsic> | null;
}

View File

@ -3,6 +3,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventRecord } from '@polkadot/types/interfaces';
import { AppProps, BareProps, I18nProps } from '@polkadot/ui-app/types';
import { KeyedEvent } from './types';
@ -11,7 +12,6 @@ import './index.css';
import React from 'react';
import { Route, Switch } from 'react-router';
import styled from 'styled-components';
import { EventRecord } from '@polkadot/types';
import { withCalls, withMulti } from '@polkadot/ui-api';
import Tabs, { TabItem } from '@polkadot/ui-app/Tabs';
import uiSettings from '@polkadot/ui-settings';

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventRecord } from '@polkadot/types';
import { EventRecord } from '@polkadot/types/interfaces';
export interface KeyedEvent {
key: string;

View File

@ -2,14 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import BN from 'bn.js';
import { Call } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { QueueTxExtrinsicAdd } from '@polkadot/ui-app/Status/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import BN from 'bn.js';
import React from 'react';
import { Method } from '@polkadot/types';
import { Button, Extrinsic, InputAddress, Labelled, TxButton, TxComponent } from '@polkadot/ui-app';
import { withApi, withMulti } from '@polkadot/ui-api';
import { Nonce } from '@polkadot/ui-reactive';
@ -24,7 +24,7 @@ type Props = ApiProps & I18nProps & {
interface State {
isValid: boolean;
isValidUnsigned: boolean;
method: Method | null;
method: Call | null;
accountNonce?: BN;
accountId?: string;
}
@ -116,7 +116,7 @@ class Selection extends TxComponent<Props, State> {
);
}
private onChangeExtrinsic = (method: Method | null = null): void => {
private onChangeExtrinsic = (method: Call | null = null): void => {
this.nextState({ method });
}
@ -136,7 +136,7 @@ class Selection extends TxComponent<Props, State> {
return null;
}
const fn = Method.findFunction(method.callIndex);
const fn = api.findCall(method.callIndex);
return api.tx[fn.section][fn.method](...method.args);
}

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, StakingLedger } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import { Icon } from '@polkadot/ui-app';
import { AccountId, Option, StakingLedger } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api';
import translate from '../../translate';

View File

@ -3,13 +3,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, StakingLedger } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import BN from 'bn.js';
import React from 'react';
import styled from 'styled-components';
import { AccountId, Option, StakingLedger } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { AddressInfo, Button, InputAddress, InputBalance, Modal, TxButton, TxComponent } from '@polkadot/ui-app';
import { withCalls, withApi, withMulti } from '@polkadot/ui-api';
@ -147,10 +148,10 @@ class Unbond extends TxComponent<Props, State> {
return;
}
const { active: maxBalance } = staking_ledger.unwrap();
const { active } = staking_ledger.unwrap();
this.nextState({
maxBalance
maxBalance: active.unwrap()
});
}

View File

@ -2,11 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ValidatorPrefs } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import BN from 'bn.js';
import React from 'react';
import { ValidatorPrefs } from '@polkadot/types';
import { Button, InputAddress, InputBalance, InputNumber, Modal, TxButton, TxComponent } from '@polkadot/ui-app';
import InputValidationUnstakeThreshold from './InputValidationUnstakeThreshold';

View File

@ -4,7 +4,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { RecentlyOfflineMap } from '../../types';
import { AccountId, Exposure, StakingLedger, ValidatorPrefs } from '@polkadot/types';
import { AccountId, Exposure, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { DerivedBalances, DerivedStaking } from '@polkadot/api-derive/types';
import { I18nProps } from '@polkadot/ui-app/types';

View File

@ -3,13 +3,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, Balance, Exposure } from '@polkadot/types/interfaces';
import { DerivedBalancesMap, DerivedStaking } from '@polkadot/api-derive/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { ValidatorFilter, RecentlyOfflineMap } from '../types';
import React from 'react';
import styled from 'styled-components';
import { AccountId, Balance, Exposure } from '@polkadot/types';
import { withCalls, withMulti } from '@polkadot/ui-api/with';
import { AddressCard, AddressMini, RecentlyOffline } from '@polkadot/ui-app';
import keyring from '@polkadot/ui-keyring';
@ -79,8 +79,8 @@ class Address extends React.PureComponent<Props, State> {
public render (): React.ReactNode {
const { className, defaultName, filter } = this.props;
const { controllerId, stakers, stashId } = this.state;
const bonded = stakers && !stakers.own.isZero()
? [stakers.own, stakers.total.sub(stakers.own)]
const bonded = stakers && !stakers.own.isEmpty
? [stakers.own.unwrap(), stakers.total.unwrap().sub(stakers.own.unwrap())]
: true;
if ((filter === 'hasNominators' && !this.hasNominators()) ||
@ -148,7 +148,7 @@ class Address extends React.PureComponent<Props, State> {
const { stakers } = this.state;
return stakers
? stakers.others.map(({ who, value }): [AccountId, Balance] => [who, value])
? stakers.others.map(({ who, value }): [AccountId, Balance] => [who, value.unwrap()])
: [];
}

View File

@ -41,7 +41,7 @@ class Overview extends React.PureComponent<Props> {
let lastAuthor: string | undefined;
if (chain_subscribeNewHead) {
lastBlock = formatNumber(chain_subscribeNewHead.blockNumber);
lastBlock = formatNumber(chain_subscribeNewHead.number);
lastAuthor = (chain_subscribeNewHead.author || '').toString();
}

View File

@ -3,6 +3,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types/interfaces';
import { AppProps, I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
@ -10,7 +11,7 @@ import { ComponentProps, RecentlyOffline, RecentlyOfflineMap } from './types';
import React from 'react';
import { Route, Switch } from 'react-router';
import { AccountId, Option } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { HelpOverlay } from '@polkadot/ui-app';
import Tabs, { TabItem } from '@polkadot/ui-app/Tabs';
import { withCalls, withMulti, withObservable } from '@polkadot/ui-api';

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, BlockNumber } from '@polkadot/types';
import BN from 'bn.js';
import { AccountId, BlockNumber } from '@polkadot/types/interfaces';
import { DerivedFees, DerivedBalances } from '@polkadot/api-derive/types';
import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
import BN from 'bn.js';
export type Nominators = Record<string, string[]>;
export interface ComponentProps {

View File

@ -3,13 +3,14 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { StorageEntryPromise } from '@polkadot/api/types';
import { TypeDef, getTypeDef } from '@polkadot/types';
import { TypeDef } from '@polkadot/types/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { RawParams } from '@polkadot/ui-params/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { ComponentProps } from '../types';
import React from 'react';
import { getTypeDef } from '@polkadot/types';
import { Button, InputStorage, TxComponent } from '@polkadot/ui-app';
import Params from '@polkadot/ui-params';
import { withApi, withMulti } from '@polkadot/ui-api';

View File

@ -2,12 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Call } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { ComponentProps } from './types';
import React from 'react';
import { Method, Proposal } from '@polkadot/types';
import { createType } from '@polkadot/types';
import { Button, Icon, Extrinsic, TxButton, TxComponent } from '@polkadot/ui-app';
import { withApi, withMulti } from '@polkadot/ui-api';
@ -18,7 +19,7 @@ type Props = I18nProps & ApiProps & ComponentProps & {
};
interface State {
method: Method | null;
method: Call | null;
isValid: boolean;
}
@ -48,7 +49,7 @@ class Propose extends TxComponent<Props, State> {
label={t('Submit')}
tx='sudo.sudo'
isDisabled={!method || !isValid}
params={method ? [new Proposal(method)] : []}
params={method ? [createType('Proposal', method)] : []}
ref={this.button}
/>
</Button.Group>
@ -78,7 +79,7 @@ class Propose extends TxComponent<Props, State> {
);
}
private onChangeExtrinsic = (method: Method): void => {
private onChangeExtrinsic = (method: Call): void => {
if (!method) {
return;
}

View File

@ -3,13 +3,14 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethod } from '@polkadot/jsonrpc/types';
import { TypeDef } from '@polkadot/types/types';
import { RawParam } from '@polkadot/ui-params/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { QueueTxRpcAdd } from '@polkadot/ui-app/Status/types';
import React from 'react';
import rpc from '@polkadot/jsonrpc';
import { TypeDef, getTypeDef } from '@polkadot/types';
import { getTypeDef } from '@polkadot/types';
import { Button, InputRpc, TxComponent } from '@polkadot/ui-app';
import Params from '@polkadot/ui-params';

View File

@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, BlockNumber } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { AccountId, BlockNumber } from '@polkadot/types';
import React from 'react';
import { Button, Dropdown } from '@polkadot/ui-app';

View File

@ -2,12 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TreasuryProposal as TreasuryProposalType } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
import React from 'react';
import styled from 'styled-components';
import { Option, TreasuryProposal as TreasuryProposalType } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { ActionItem, Icon, TreasuryProposal } from '@polkadot/ui-app';
import { withCalls, withMulti, withObservable } from '@polkadot/ui-api';
import keyring from '@polkadot/ui-keyring';

View File

@ -3,8 +3,8 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ProposalIndex } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ProposalIndex } from '@polkadot/types';
import BN from 'bn.js';
import React from 'react';

View File

@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber, BalanceOf, Permill } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { BlockNumber, BalanceOf, Permill } from '@polkadot/types';
import BN from 'bn.js';
import React from 'react';

View File

@ -14,7 +14,7 @@
"dependencies": {
"@babel/runtime": "^7.5.5",
"@polkadot/ui-app": "^0.34.0-beta.87",
"@polkadot/ui-assets": "^0.42.0-beta.16",
"@polkadot/ui-assets": "^0.42.0-beta.19",
"@polkadot/ui-signer": "^0.34.0-beta.87",
"query-string": "^6.8.1"
}

View File

@ -3,13 +3,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventRecord } from '@polkadot/types/interfaces';
import { KeyringOptions } from '@polkadot/ui-keyring/options/types';
import { QueueStatus, QueueTx, QueueAction$Add } from '@polkadot/ui-app/Status/types';
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import keyringOption from '@polkadot/ui-keyring/options';
import { EventRecord } from '@polkadot/types';
import { Status as StatusDisplay } from '@polkadot/ui-app';
import { withCalls, withMulti, withObservable } from '@polkadot/ui-api';
import { stringToU8a } from '@polkadot/util';

View File

@ -25,6 +25,8 @@ type Props = I18nProps & ApiProps & {
};
class Item extends React.PureComponent<Props> {
private _disabledLog: Map<string, string> = new Map();
public render (): React.ReactNode {
const { route: { Modal, i18n, icon, name }, t, isCollapsed, onClick } = this.props;
@ -78,6 +80,14 @@ class Item extends React.PureComponent<Props> {
);
}
private logDisabled (route: string, message: string): void {
if (!this._disabledLog.get(route)) {
this._disabledLog.set(route, message);
console.warn(`Disabling ${route}: ${message}`);
}
}
private hasApi (endpoint: string): boolean {
const { api } = this.props;
const [area, section, method] = endpoint.split('.');
@ -104,7 +114,7 @@ class Item extends React.PureComponent<Props> {
return false;
} else if (needsSudo) {
if (!hasSudo) {
console.info('Disabling route sudo, no authority');
this.logDisabled('sudo', 'Sudo key not available');
return false;
}
}
@ -118,7 +128,7 @@ class Item extends React.PureComponent<Props> {
});
if (notFound.length !== 0) {
console.info(`Disabling route ${name}, API ${notFound} not available`);
this.logDisabled(name, `API not available: ${notFound}`);
}
return notFound.length === 0;

View File

@ -31,8 +31,8 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.5.5",
"@polkadot/api": "^0.82.0-beta.95",
"@polkadot/extension-dapp": "^0.5.0-beta.5",
"@polkadot/api": "^0.90.0-beta.1",
"@polkadot/extension-dapp": "^0.5.1",
"rxjs-compat": "^6.4.0"
}
}

View File

@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ProviderInterface } from '@polkadot/rpc-provider/types';
import { ChainProperties } from '@polkadot/types/interfaces';
import { QueueTxPayloadAdd, QueueTxMessageSetStatus } from '@polkadot/ui-app/Status/types';
import { Prefix } from '@polkadot/util-crypto/address/types';
import { ApiProps } from './types';
@ -16,7 +17,7 @@ import { InputNumber } from '@polkadot/ui-app/InputNumber';
import keyring from '@polkadot/ui-keyring';
import uiSettings from '@polkadot/ui-settings';
import ApiSigner from '@polkadot/ui-signer/ApiSigner';
import { ChainProperties, Text } from '@polkadot/types';
import { createType, Text } from '@polkadot/types';
import { formatBalance, isTestChain } from '@polkadot/util';
import ApiContext from './ApiContext';
@ -107,13 +108,16 @@ export default class Api extends React.PureComponent<Props, State> {
}
private async loadOnReady (api: ApiPromise): Promise<void> {
const [properties = new ChainProperties(), value] = await Promise.all([
const [properties = createType('ChainProperties'), value] = await Promise.all([
api.rpc.system.properties<ChainProperties>(),
api.rpc.system.chain<Text>()
]);
const addressPrefix = uiSettings.prefix === -1
? properties.get('networkId')
: uiSettings.prefix as Prefix;
const addressPrefix = (
uiSettings.prefix === -1
? 42
: uiSettings.prefix
) as Prefix;
const tokenSymbol = properties.tokenSymbol.toString() || 'Unit';
const chain = value
? value.toString()
: null;
@ -132,10 +136,10 @@ export default class Api extends React.PureComponent<Props, State> {
// first setup the UI helpers
formatBalance.setDefaults({
decimals: properties.tokenDecimals,
unit: properties.tokenSymbol
decimals: properties.tokenDecimals.toNumber(),
unit: tokenSymbol
});
InputNumber.setUnit(properties.tokenSymbol);
InputNumber.setUnit(tokenSymbol);
// finally load the keyring
keyring.loadAll({

View File

@ -11,12 +11,12 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.5.5",
"@polkadot/keyring": "^0.95.0-beta.0",
"@polkadot/keyring": "^0.95.0-beta.2",
"@polkadot/react-identicon": "^0.42.0-beta.19",
"@polkadot/ui-api": "^0.34.0-beta.87",
"@polkadot/ui-identicon": "^0.42.0-beta.16",
"@polkadot/ui-keyring": "^0.42.0-beta.16",
"@polkadot/ui-keyring": "^0.42.0-beta.19",
"@polkadot/ui-reactive": "^0.34.0-beta.87",
"@polkadot/ui-settings": "^0.42.0-beta.16",
"@polkadot/ui-settings": "^0.42.0-beta.19",
"@types/chart.js": "^2.7.55",
"@types/i18next": "^12.1.0",
"@types/react-copy-to-clipboard": "^4.2.6",

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Proposal } from '@polkadot/types';
import { Proposal } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import React from 'react';

View File

@ -255,8 +255,9 @@ class AddressInfo extends React.PureComponent<Props> {
{validatorPrefsDisplay.validatorPayment && staking_info.validatorPrefs.validatorPayment && (
<>
<Label label={t('commision')} />
<div className='result'>{formatBalance(staking_info.validatorPrefs.validatorPayment.toBn())}
</div>
<div className='result'>{
formatBalance(staking_info.validatorPrefs.validatorPayment)
}</div>
</>
)}
</>

View File

@ -2,12 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { BareProps } from './types';
import BN from 'bn.js';
import React from 'react';
import styled from 'styled-components';
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { KeyringItemType } from '@polkadot/ui-keyring/types';
import { classes, getAddressName, toShortAddress } from './util';

View File

@ -3,14 +3,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import BN from 'bn.js';
import React from 'react';
import styled from 'styled-components';
import { withCalls, withMulti } from '@polkadot/ui-api';
import BaseIdentityIcon from '@polkadot/ui-identicon';
import BaseIdentityIcon from '@polkadot/react-identicon';
import keyring from '@polkadot/ui-keyring';
import AddressInfo, { BalanceActiveType } from './AddressInfo';

View File

@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { BareProps } from './types';
import React from 'react';
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { Available } from '@polkadot/ui-reactive';
import { classes } from './util';

View File

@ -2,11 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { BareProps } from './types';
import BN from 'bn.js';
import React from 'react';
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { formatBalance } from '@polkadot/util';
import { Balance } from '@polkadot/ui-reactive';

View File

@ -2,11 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { BareProps } from './types';
import BN from 'bn.js';
import React from 'react';
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { formatBalance } from '@polkadot/util';
import { Bonded } from '@polkadot/ui-reactive';

View File

@ -2,12 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec, IExtrinsic, IMethod } from '@polkadot/types/types';
import { Codec, IExtrinsic, IMethod, TypeDef } from '@polkadot/types/types';
import { BareProps, I18nProps } from './types';
import React from 'react';
import styled from 'styled-components';
import { Method, getTypeDef, TypeDef } from '@polkadot/types';
import { GenericCall, getTypeDef } from '@polkadot/types';
import Params from '@polkadot/ui-params';
import Static from './Static';
@ -33,9 +33,9 @@ const Wrapper = styled.div`
class Call extends React.PureComponent<Props> {
public render (): React.ReactNode {
const { children, className, style, mortality, value, withHash, t } = this.props;
const params = Method.filterOrigin(value.meta).map(({ name, type }): { name: string; type: TypeDef } => ({
const params = GenericCall.filterOrigin(value.meta).map(({ name, type }): { name: string; type: TypeDef } => ({
name: name.toString(),
type: getTypeDef(type)
type: getTypeDef(type.toString())
}));
const values = value.args.map((value): { isValid: boolean; value: Codec } => ({
isValid: true,

View File

@ -4,11 +4,11 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { I18nProps } from '@polkadot/ui-app/types';
import { Hash } from '@polkadot/types';
import { CodeStored } from '@polkadot/app-contracts/types';
import React from 'react';
import styled from 'styled-components';
import { createType } from '@polkadot/types';
import { withMulti } from '@polkadot/ui-api';
import { classes, toShortAddress } from '@polkadot/ui-app/util';
import contracts from '@polkadot/app-contracts/store';
@ -192,7 +192,7 @@ class CodeRow extends Row<Props, State> {
// Save only if the name was changed or if it's no empty.
if (trimmedName && codeHash) {
await contracts.saveCode(new Hash(codeHash), { name });
await contracts.saveCode(createType('Hash', codeHash), { name });
this.setState({ isEditingName: false });
}
@ -202,7 +202,7 @@ class CodeRow extends Row<Props, State> {
const { codeHash, tags } = this.state;
if (codeHash) {
await contracts.saveCode(new Hash(codeHash), { tags });
await contracts.saveCode(createType('Hash', codeHash), { tags });
this.setState({ isEditingTags: false });
}

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { BareProps } from './types';
import React from 'react';

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec } from '@polkadot/types/types';
import { Event } from '@polkadot/types/interfaces';
import { Codec, TypeDef } from '@polkadot/types/types';
import { BareProps } from './types';
import React from 'react';
import { Event, TypeDef, getTypeDef } from '@polkadot/types';
import { getTypeDef } from '@polkadot/types';
import Params from '@polkadot/ui-params';
import { classes } from './util';

View File

@ -2,13 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { MethodFunction } from '@polkadot/types/primitive/Method';
import { Call } from '@polkadot/types/interfaces';
import { CallFunction, TypeDef } from '@polkadot/types/types';
import { BareProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { RawParam } from '@polkadot/ui-params/types';
import React from 'react';
import { Method, TypeDef, getTypeDef } from '@polkadot/types';
import { GenericCall, getTypeDef } from '@polkadot/types';
import { InputExtrinsic } from '@polkadot/ui-app';
import Params from '@polkadot/ui-params';
@ -18,18 +19,18 @@ import { isUndefined } from '@polkadot/util';
import paramComponents from './Params';
type Props = BareProps & ApiProps & {
defaultValue: MethodFunction;
defaultValue: CallFunction;
isDisabled?: boolean;
isError?: boolean;
isPrivate?: boolean;
label?: React.ReactNode;
onChange: (method?: Method) => void;
onChange: (method?: Call) => void;
onEnter: () => void;
withLabel?: boolean;
};
interface State {
methodfn: MethodFunction;
methodfn: CallFunction;
params: { name: string; type: TypeDef }[];
values: RawParam[];
}
@ -102,7 +103,7 @@ class ExtrinsicDisplay extends React.PureComponent<Props, State> {
});
}
private onChangeMethod = (methodfn: MethodFunction): void => {
private onChangeMethod = (methodfn: CallFunction): void => {
this.nextState({
methodfn,
params: this.getParams(methodfn),
@ -114,10 +115,10 @@ class ExtrinsicDisplay extends React.PureComponent<Props, State> {
this.nextState({ values });
}
private getParams (methodfn: MethodFunction): { name: string; type: TypeDef }[] {
return Method.filterOrigin(methodfn.meta).map((arg): { name: string; type: TypeDef } => ({
private getParams (methodfn: CallFunction): { name: string; type: TypeDef }[] {
return GenericCall.filterOrigin(methodfn.meta).map((arg): { name: string; type: TypeDef } => ({
name: arg.name.toString(),
type: getTypeDef(arg.type)
type: getTypeDef(arg.type.toString())
}));
}
}

View File

@ -3,15 +3,16 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types/interfaces';
import { ApiProps } from '@polkadot/ui-api/types';
import { IdentityProps } from '@polkadot/ui-identicon/types';
import { IdentityProps } from '@polkadot/react-identicon/types';
import { QueueAction$Add } from './Status/types';
import { I18nProps } from './types';
import React from 'react';
import { AccountId, Option } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { withCalls } from '@polkadot/ui-api/with';
import BaseIdentityIcon from '@polkadot/ui-identicon';
import BaseIdentityIcon from '@polkadot/react-identicon';
import { QueueConsumer } from './Status/Context';
import translate from './translate';

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { MethodFunction } from '@polkadot/types/primitive/Method';
import { CallFunction } from '@polkadot/types/types';
import { BareProps } from '../types';
import { DropdownOptions } from '../util/types';
@ -15,9 +15,9 @@ import { classes } from '../util';
interface Props extends BareProps {
api: ApiPromise;
isError?: boolean;
onChange: (value: MethodFunction) => void;
onChange: (value: CallFunction) => void;
options: DropdownOptions;
value: MethodFunction;
value: CallFunction;
}
export default class SelectMethod extends React.PureComponent<Props> {
@ -42,7 +42,7 @@ export default class SelectMethod extends React.PureComponent<Props> {
);
}
private transform = (method: string): MethodFunction => {
private transform = (method: string): CallFunction => {
const { api, value } = this.props;
return api.tx[value.section][method];

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { MethodFunction } from '@polkadot/types/primitive/Method';
import { CallFunction } from '@polkadot/types/types';
import { BareProps } from '../types';
import { DropdownOptions } from '../util/types';
@ -16,7 +16,7 @@ interface Props extends BareProps {
isError?: boolean;
onChange: (value: string) => void;
options: DropdownOptions;
value: MethodFunction;
value: CallFunction;
}
export default class SelectSection extends React.PureComponent<Props> {

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { MethodFunction } from '@polkadot/types/primitive/Method';
import { CallFunction } from '@polkadot/types/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { I18nProps } from '../types';
import { DropdownOptions } from '../util/types';
@ -20,20 +20,20 @@ import methodOptions from './options/method';
import sectionOptions from './options/section';
type Props = ApiProps & I18nProps & {
defaultValue: MethodFunction;
defaultValue: CallFunction;
help?: React.ReactNode;
isDisabled?: boolean;
isError?: boolean;
isPrivate?: boolean;
label: React.ReactNode;
onChange: (value: MethodFunction) => void;
onChange: (value: CallFunction) => void;
withLabel?: boolean;
};
interface State {
optionsMethod?: DropdownOptions;
optionsSection?: DropdownOptions;
value: MethodFunction;
value: CallFunction;
}
class InputExtrinsic extends React.PureComponent<Props, State> {
@ -88,7 +88,7 @@ class InputExtrinsic extends React.PureComponent<Props, State> {
);
}
private onKeyChange = (newValue: MethodFunction): void => {
private onKeyChange = (newValue: CallFunction): void => {
const { onChange } = this.props;
const { value } = this.state;

View File

@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { BareProps } from './types';
import React from 'react';
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { Nonce } from '@polkadot/ui-reactive';
import { classes } from './util';

View File

@ -2,17 +2,17 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { MethodFunction } from '@polkadot/types/primitive/Method';
import { Call } from '@polkadot/types/interfaces';
import { CallFunction } from '@polkadot/types/types';
import { RawParamOnChange, RawParamOnEnter } from '@polkadot/ui-params/types';
import { BareProps } from '../types';
import React from 'react';
import { Method } from '@polkadot/types';
import BaseExtrinsic from '../Extrinsic';
interface Props extends BareProps {
defaultValue: MethodFunction;
defaultValue: CallFunction;
isDisabled?: boolean;
isError?: boolean;
isPrivate: boolean;
@ -42,7 +42,7 @@ export default class ExtrinsicDisplay extends React.PureComponent<Props> {
);
}
private onChange = (method: Method): void => {
private onChange = (method: Call): void => {
const { onChange } = this.props;
onChange && onChange({

View File

@ -6,7 +6,7 @@ import { Props as BaseProps, RawParam } from '@polkadot/ui-params/types';
import { ApiProps } from '@polkadot/ui-api/types';
import React from 'react';
import { Proposal } from '@polkadot/types';
import { createType } from '@polkadot/types';
import { withApi } from '@polkadot/ui-api';
import ExtrinsicDisplay from './Extrinsic';
@ -38,7 +38,7 @@ class ProposalDisplay extends React.PureComponent<Props> {
let proposal = null;
if (isValid && value) {
proposal = new Proposal(value);
proposal = createType('Proposal', value);
}
onChange && onChange({

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Method, Proposal } from '@polkadot/types';
import { Proposal } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import React from 'react';
import styled from 'styled-components';
import { GenericCall } from '@polkadot/types';
import { formatNumber } from '@polkadot/util';
import Call from './Call';
@ -53,7 +54,7 @@ class ProposedAction extends React.PureComponent<Props> {
);
}
const { meta, method, section } = Method.findFunction(proposal.callIndex);
const { meta, method, section } = GenericCall.findFunction(proposal.callIndex);
const header = `#${idNumber}: ${section}.${method}`;
const documentation = (meta && meta.documentation)

View File

@ -1,7 +1,8 @@
// Copyright 2017-2019 @polkadot/app-staking authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types';
import { AccountId } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { OfflineStatus } from '@polkadot/app-staking/types';

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex } from '@polkadot/types';
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import { KeyringItemType } from '@polkadot/ui-keyring/types';
import { Label } from 'semantic-ui-react';

View File

@ -9,7 +9,7 @@ import { ActionStatus, PartialQueueTxExtrinsic, PartialQueueTxRpc, QueueProps, Q
import React from 'react';
import jsonrpc from '@polkadot/jsonrpc';
import { Extrinsic, Method } from '@polkadot/types';
import { createType } from '@polkadot/types';
import { QueueProvider } from './Context';
import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic';
@ -191,8 +191,8 @@ export default class Queue extends React.Component<Props, State> {
return this.queueAdd({
accountId: payload.address,
// this is not great, but the Extrinsic we don't need a submittable
extrinsic: new Extrinsic(
{ method: new Method(payload.method) },
extrinsic: createType('Extrinsic',
{ method: createType('Call', payload.method) },
{ version: payload.version }
) as unknown as SubmittableExtrinsic,
payload,

View File

@ -7,7 +7,7 @@ import { QueueStatus, QueueTx, QueueTxStatus } from './types';
import React from 'react';
import styled from 'styled-components';
import { Method } from '@polkadot/types';
import { GenericCall } from '@polkadot/types';
import AddressMini from '../AddressMini';
import Icon from '../Icon';
@ -144,7 +144,7 @@ class Status extends React.PureComponent<Props> {
let { method, section } = rpc;
if (extrinsic) {
const found = Method.findFunction(extrinsic.callIndex);
const found = GenericCall.findFunction(extrinsic.callIndex);
if (found.section !== 'unknown') {
method = found.method;

View File

@ -6,7 +6,7 @@ import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic';
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import { SignerPayload, SignerResult } from '@polkadot/api/types';
import { RpcMethod } from '@polkadot/jsonrpc/types';
import { AccountId, Address } from '@polkadot/types';
import { AccountId, Address } from '@polkadot/types/interfaces';
export type Actions = 'create' | 'edit' | 'restore' | 'forget' | 'backup' | 'changePassword' | 'transfer';

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TreasuryProposal as TreasuryProposalType } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { Option, TreasuryProposal as TreasuryProposalType } from '@polkadot/types';
import React from 'react';
import { Option } from '@polkadot/types';
import { InputAddress, Labelled, Static } from '@polkadot/ui-app';
import { withMulti, withApi } from '@polkadot/ui-api';
import { formatBalance } from '@polkadot/util';

View File

@ -5,7 +5,7 @@
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { assert, isFunction, isUndefined } from '@polkadot/util';
import { Index } from '@polkadot/types';
import { Index } from '@polkadot/types/interfaces';
import { IExtrinsic } from '@polkadot/types/types';
import { QueueTx, QueueTxExtrinsicAdd, TxCallback, TxFailedCallback } from './Status/types';

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Proposal } from '@polkadot/types';
import { Proposal } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/ui-app/types';
import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';

View File

@ -2,14 +2,15 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Method, Proposal } from '@polkadot/types';
import { Proposal } from '@polkadot/types/interfaces';
import { GenericCall } from '@polkadot/types';
export default function isTreasuryProposalVote (proposal?: Proposal | null): boolean {
if (!proposal) {
return false;
}
const { method, section } = Method.findFunction(proposal.callIndex);
const { method, section } = GenericCall.findFunction(proposal.callIndex);
return section === 'treasury' &&
['approveProposal', 'rejectProposal'].includes(method) &&

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
export default function toShortAddress (_address?: AccountId | AccountIndex | Address | string | null): string {
const address = (_address || '').toString();

View File

@ -6,7 +6,7 @@ import { Props } from '../types';
import BN from 'bn.js';
import React from 'react';
import { AccountIndex } from '@polkadot/types';
import { ClassOf } from '@polkadot/types';
import { Input } from '@polkadot/ui-app';
import { bnToBn, formatNumber } from '@polkadot/util';
@ -17,7 +17,7 @@ export default class Amount extends React.PureComponent<Props> {
const { className, defaultValue: { value }, isDisabled, isError, label, onEnter, style, withLabel } = this.props;
const defaultValue = isDisabled
? (
value instanceof AccountIndex
value instanceof ClassOf('AccountIndex')
? value.toString()
: formatNumber(value)
)

View File

@ -2,10 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef } from '@polkadot/types/types';
import { Props as BaseProps, RawParam } from '../types';
import React from 'react';
import { Enum, TypeDef, createType, getTypeDef } from '@polkadot/types';
import { Enum, createType, getTypeDef } from '@polkadot/types';
import { Dropdown } from '@polkadot/ui-app';
import Params from '../';
@ -39,7 +40,7 @@ export default class EnumParam extends React.PureComponent<Props, State> {
return null;
}
const sub = getTypeDef(createType(type).toRawType()).sub as TypeDef[];
const sub = getTypeDef(createType(type as any).toRawType()).sub as TypeDef[];
const options = sub.map(({ name }): Option => ({
text: name,
value: name

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { WithTranslation } from 'react-i18next';
import { KeyValue as Pair } from '@polkadot/types/interfaces';
import { Props as BaseProps, RawParam } from '../types';
import React from 'react';
import { KeyValue as Pair, Vector } from '@polkadot/types';
import { WithTranslation } from 'react-i18next';
import { Vec } from '@polkadot/types';
import translate from '@polkadot/ui-app/translate';
import { assert, isHex, u8aToHex, u8aToString } from '@polkadot/util';
@ -70,7 +71,7 @@ class KeyValueArray extends React.PureComponent<Props, State> {
private renderReadOnly (): React.ReactNode {
const { className, defaultValue: { value }, label, onEnter, style } = this.props;
const pairs = value as Vector<Pair>;
const pairs = value as Vec<Pair>;
return (
<>
@ -83,7 +84,7 @@ class KeyValueArray extends React.PureComponent<Props, State> {
<div />
</Base>
<div className='ui--Params'>
{pairs.map(({ key, value }): React.ReactNode => {
{pairs.map(([key, value]): React.ReactNode => {
const keyHex = u8aToHex(key.toU8a(true));
return (

View File

@ -2,10 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Extrinsic } from '@polkadot/types/interfaces';
import { Props } from '../types';
import React from 'react';
import { Extrinsic, Method } from '@polkadot/types';
import { GenericCall } from '@polkadot/types';
import { Call, Static } from '@polkadot/ui-app';
import { classes } from '@polkadot/ui-app/util';
@ -23,7 +24,7 @@ export default class Proposal extends React.PureComponent<Props> {
}
const proposal = value as Extrinsic;
const { method, section } = Method.findFunction(proposal.callIndex);
const { method, section } = GenericCall.findFunction(proposal.callIndex);
return (
<Bare>

View File

@ -2,10 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef } from '@polkadot/types/types';
import { Props as BaseProps, RawParam } from '../types';
import React from 'react';
import { TypeDef, createType, getTypeDef } from '@polkadot/types';
import { createType, getTypeDef } from '@polkadot/types';
import Params from '../';
import Base from './Base';
@ -29,7 +30,7 @@ export default class StructParam extends React.PureComponent<Props, State> {
return null;
}
const defs = getTypeDef(createType(type).toRawType()).sub as TypeDef[];
const defs = getTypeDef(createType(type as any).toRawType()).sub as TypeDef[];
return {
defs,

View File

@ -2,11 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec } from '@polkadot/types/types';
import { Codec, TypeDef } from '@polkadot/types/types';
import { Props, RawParam } from '../types';
import React from 'react';
import { TypeDef } from '@polkadot/types';
import { isUndefined } from '@polkadot/util';
import Bare from './Bare';

View File

@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { WithTranslation } from 'react-i18next';
import { TypeDef } from '@polkadot/types';
import { TypeDef } from '@polkadot/types/types';
import { Props as BareProps, RawParam } from '../types';
import React from 'react';

View File

@ -5,7 +5,7 @@
import { Props } from '../types';
import React from 'react';
import { VoteThreshold } from '@polkadot/types';
import { ClassOf } from '@polkadot/types';
import { Dropdown } from '@polkadot/ui-app';
import { bnToBn } from '@polkadot/util';
@ -28,7 +28,7 @@ export const textMap = options.reduce((textMap, { text, value }): TextMap => {
export default class VoteThresholdParam extends React.PureComponent<Props> {
public render (): React.ReactNode {
const { className, defaultValue: { value }, isDisabled, isError, label, style, withLabel } = this.props;
const defaultValue = value instanceof VoteThreshold
const defaultValue = value instanceof ClassOf('VoteThreshold')
? value.toNumber()
: bnToBn(value as number).toNumber();

View File

@ -2,10 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef, TypeDefInfo } from '@polkadot/types/types';
import { Props, ComponentMap } from '../types';
import BN from 'bn.js';
import { TypeDef, TypeDefInfo, createType, getTypeDef } from '@polkadot/types';
import { createType, getTypeDef } from '@polkadot/types';
import Account from './Account';
import Amount from './Amount';
@ -78,7 +79,7 @@ export default function findComponent (def: TypeDef, overrides: ComponentMap = {
case TypeDefInfo.Tuple:
return 'Tuple';
case TypeDefInfo.Vector:
case TypeDefInfo.Vec:
return ['Vec<KeyValue>'].includes(type)
? 'Vec<KeyValue>'
: 'Vector';
@ -92,7 +93,7 @@ export default function findComponent (def: TypeDef, overrides: ComponentMap = {
if (!Component) {
try {
const instance = createType(type);
const instance = createType(type as any);
const raw = getTypeDef(instance.toRawType());
if (instance instanceof BN) {

View File

@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef } from '@polkadot/types';
import { TypeDef } from '@polkadot/types/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { ComponentMap, RawParam, RawParams, RawParamOnChange, RawParamOnChangeValue } from './types';

View File

@ -2,13 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef, TypeDefInfo } from '@polkadot/types/types';
import { RawParamValue } from './types';
import BN from 'bn.js';
import { Bytes, Hash, TypeDef, TypeDefInfo, U8a, createType, getTypeDef } from '@polkadot/types';
import { Bytes, U8a, createType, getTypeDef } from '@polkadot/types';
export default function getInitValue (def: TypeDef): RawParamValue | RawParamValue[] {
if (def.info === TypeDefInfo.Vector) {
if (def.info === TypeDefInfo.Vec) {
return [getInitValue(def.sub as TypeDef)];
} else if (def.info === TypeDefInfo.Tuple) {
return Array.isArray(def.sub)
@ -72,7 +73,7 @@ export default function getInitValue (def: TypeDef): RawParamValue | RawParamVal
case 'CodeHash':
case 'Hash':
return new Hash();
return createType('Hash');
case 'AccountId':
case 'AccountIdOf':
@ -97,7 +98,7 @@ export default function getInitValue (def: TypeDef): RawParamValue | RawParamVal
default: {
try {
const instance = createType(type);
const instance = createType(type as any);
const raw = getTypeDef(instance.toRawType());
if (instance instanceof BN) {

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