Fix parameter updates (#105)

This commit is contained in:
Jaco Greeff 2018-06-26 12:10:41 +02:00 committed by GitHub
parent 75b3a9759b
commit f2d234b591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 211 additions and 225 deletions

View File

@ -24,7 +24,7 @@
},
"devDependencies": {
"@polkadot/dev-react": "^0.20.3",
"@polkadot/ts": "^0.1.2",
"@polkadot/ts": "^0.1.3",
"autoprefixer": "^8.6.2",
"gh-pages": "^1.1.0",
"postcss-import": "^11.1.0",

View File

@ -16,8 +16,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/primitives-codec": "^0.19.5",
"@polkadot/primitives-json": "^0.19.5",
"@polkadot/primitives-codec": "^0.20.1",
"@polkadot/primitives-json": "^0.20.1",
"@polkadot/ui-app": "^0.18.1",
"@polkadot/util-crypto": "^0.24.6"
}

View File

@ -16,7 +16,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/extrinsics-codec": "^0.19.5",
"@polkadot/extrinsics-codec": "^0.20.1",
"@polkadot/ui-app": "^0.18.1",
"@polkadot/ui-signer": "^0.18.1",
"react-dropzone": "^4.2.9"

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Extrinsic$Method } from '@polkadot/extrinsics/types';
import { SectionItem } from '@polkadot/params/types';
import { Extrinsics } from '@polkadot/extrinsics/types';
import { BareProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-react-rx/types';
import { RawParam } from '@polkadot/ui-app/Params/types';
@ -20,7 +21,7 @@ import withApi from '@polkadot/ui-react-rx/with/api';
import paramComponents from './Params';
type Props = BareProps & ApiProps & {
defaultValue: Extrinsic$Method,
defaultValue: SectionItem<Extrinsics>,
isDisabled?: boolean,
isError?: boolean,
isPrivate?: boolean,
@ -31,7 +32,7 @@ type Props = BareProps & ApiProps & {
};
type State = {
extrinsic: Extrinsic$Method,
extrinsic: SectionItem<Extrinsics>,
values: Array<RawParam>
};
@ -98,7 +99,7 @@ class Extrinsic extends React.PureComponent<Props, State> {
});
}
onChangeExtrinsic = (extrinsic: Extrinsic$Method): void => {
onChangeExtrinsic = (extrinsic: SectionItem<Extrinsics>): void => {
this.nextState({ extrinsic } as State);
};

View File

@ -10,8 +10,7 @@ import extrinsics from '@polkadot/extrinsics';
import Extrinsic from './Extrinsic';
// @ts-ignore checking?
const defaultValue = extrinsics.get('staking').public.transfer;
const defaultValue = extrinsics.staking.public.transfer;
export default function Call ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props) {
return (

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Extrinsic$Method } from '@polkadot/extrinsics/types';
import { SectionItem } from '@polkadot/params/types';
import { Extrinsics } from '@polkadot/extrinsics/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { RawParam$OnChange } from '@polkadot/ui-app/Params/types';
import { EncodedMessage } from '@polkadot/ui-signer/types';
@ -13,7 +14,7 @@ import BaseExtrinsic from '../Extrinsic';
import translate from '../translate';
type Props = I18nProps & {
defaultValue: Extrinsic$Method,
defaultValue: SectionItem<Extrinsics>,
isDisabled?: boolean,
isError?: boolean,
isPrivate: boolean,

View File

@ -10,8 +10,7 @@ import extrinsics from '@polkadot/extrinsics';
import Extrinsic from './Extrinsic';
// @ts-ignore check?
const defaultValue = extrinsics.get('consensus').private.setCode;
const defaultValue = extrinsics.consensus.private.setCode;
export default function Proposal ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props) {
return (

View File

@ -29,10 +29,8 @@ type State = {
publicKey: Uint8Array
};
// @ts-ignore check?
const defaultExtrinsic = extrinsics.get('staking').public.transfer;
// @ts-ignore check?
const defaultRpc = rpc.get('author').public.submitExtrinsic;
const defaultExtrinsic = extrinsics.staking.public.transfer;
const defaultRpc = rpc.author.public.submitExtrinsic;
class Selection extends React.PureComponent<Props, State> {
state: State = {

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Method } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { Interfaces } from '@polkadot/jsonrpc/types';
import { RawParam } from '@polkadot/ui-app/Params/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { QueueTx$MessageAdd } from '@polkadot/ui-signer/types';
@ -30,12 +31,11 @@ type State = {
isValid: boolean,
nonce: BN,
publicKey?: Uint8Array | null,
rpc: Interface$Method,
rpc: SectionItem<Interfaces>,
values: Array<RawParam>
}
// @ts-ignore check?
const defaultMethod = rpc.get('author').public.submitExtrinsic;
const defaultMethod = rpc.author.public.submitExtrinsic;
class Selection extends React.PureComponent<Props, State> {
state: State = {
@ -116,7 +116,7 @@ class Selection extends React.PureComponent<Props, State> {
this.nextState({ nonce, publicKey } as State);
}
onChangeMethod = (rpc: Interface$Method): void => {
onChangeMethod = (rpc: SectionItem<Interfaces>): void => {
this.nextState({ rpc } as State);
}

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Key } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages } from '@polkadot/storage/types';
import { I18nProps } from '@polkadot/ui-app/types';
import { RawParams } from '@polkadot/ui-app/Params/types';
import { StorageQuery } from './types';
@ -25,12 +26,11 @@ type Props = I18nProps & {
type State = {
isValid: boolean,
key: Storage$Key,
key: SectionItem<Storages>,
params: RawParams
};
// @ts-ignore check?
const defaultValue = storage.get('timestamp').public.current;
const defaultValue = storage.timestamp.public.current;
let id = -1;
class Selection extends React.PureComponent<Props, State> {
@ -106,7 +106,7 @@ class Selection extends React.PureComponent<Props, State> {
});
}
onChangeKey = (key: Storage$Key): void => {
onChangeKey = (key: SectionItem<Storages>): void => {
this.nextState({ key } as State);
}

View File

@ -2,11 +2,12 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Key } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages } from '@polkadot/storage/types';
import { RawParams } from '@polkadot/ui-app/Params/types';
export type StorageQuery = {
id: number,
key: Storage$Key,
key: SectionItem<Storages>,
params: RawParams
}

View File

@ -16,8 +16,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/extrinsics": "^0.19.5",
"@polkadot/storage": "^0.19.5",
"@polkadot/extrinsics": "^0.20.1",
"@polkadot/storage": "^0.20.1",
"@polkadot/ui-keyring": "^0.18.1",
"@polkadot/ui-react": "^0.18.1",
"@polkadot/ui-react-rx": "^0.18.1",

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Extrinsic$Method } from '@polkadot/extrinsics/types';
import { SectionItem } from '@polkadot/params/types';
import { Extrinsics, Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { I18nProps } from '../types';
import { DropdownOptions } from './types';
@ -17,10 +18,10 @@ import translate from '../translate';
type Props = I18nProps & {
isError?: boolean,
label?: string,
onChange: (value: Extrinsic$Method) => void,
onChange: (value: SectionItem<Extrinsics>) => void,
options: DropdownOptions,
type: 'private' | 'public',
value: Extrinsic$Method,
value: SectionItem<Extrinsics>,
withLabel?: boolean
};
@ -29,9 +30,8 @@ function SelectMethod ({ className, isError, label = '', onChange, options, styl
return null;
}
const transform = (name: string): Extrinsic$Method =>
// @ts-ignore check?
extrinsics.get(section)[type][name];
const transform = (name: Extrinsic$Sections): SectionItem<Extrinsics> =>
extrinsics[section][type][name];
return (
<Dropdown

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Extrinsic$Method, Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { SectionItem } from '@polkadot/params/types';
import { Extrinsics, Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { I18nProps } from '../types';
import { DropdownOptions } from './types';
@ -18,7 +19,7 @@ type Props = I18nProps & {
label?: string,
onChange: (value: Extrinsic$Sections) => void,
options: DropdownOptions,
value: Extrinsic$Method,
value: SectionItem<Extrinsics>,
withLabel?: boolean
};

View File

@ -4,7 +4,8 @@
// TODO: We have a lot shared between this and InputStorage
import { Extrinsic$Method, Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { SectionItem } from '@polkadot/params/types';
import { Extrinsics, Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { I18nProps } from '../types';
import { DropdownOptions } from './types';
@ -21,13 +22,13 @@ import methodOptions from './options/method';
import sectionOptions from './options/section';
type Props = I18nProps & {
defaultValue: Extrinsic$Method,
defaultValue: SectionItem<Extrinsics>,
isDisabled?: boolean,
isError?: boolean,
isPrivate?: boolean,
labelMethod?: string,
labelSection?: string,
onChange: (value: Extrinsic$Method) => void,
onChange: (value: SectionItem<Extrinsics>) => void,
withLabel?: boolean
};
@ -35,7 +36,7 @@ type State = {
optionsMethod: DropdownOptions,
optionsSection: DropdownOptions,
type: 'private' | 'public',
value: Extrinsic$Method
value: SectionItem<Extrinsics>
};
class InputExtrinsic extends React.PureComponent<Props, State> {
@ -93,7 +94,7 @@ class InputExtrinsic extends React.PureComponent<Props, State> {
);
}
onKeyChange = (value: Extrinsic$Method): void => {
onKeyChange = (value: SectionItem<Extrinsics>): void => {
const { onChange } = this.props;
const { value: { name, section } } = this.state;
@ -114,8 +115,7 @@ class InputExtrinsic extends React.PureComponent<Props, State> {
}
const optionsMethod = methodOptions(newSection, type);
// @ts-ignore check?
const value = map.get(newSection)[type][optionsMethod[0].value];
const value = map[newSection][type][optionsMethod[0].value];
this.setState({ optionsMethod }, () =>
this.onKeyChange(value)

View File

@ -10,7 +10,7 @@ import React from 'react';
import map from '@polkadot/extrinsics';
export default function createOptions (sectionName: Extrinsic$Sections, type: 'private' | 'public'): DropdownOptions {
const section = map.get(sectionName);
const section = map[sectionName];
if (!section) {
return [];

View File

@ -2,17 +2,18 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Extrinsic$Sections } from '@polkadot/extrinsics/types';
import { DropdownOptions } from '../types';
import map from '@polkadot/extrinsics';
export default function createOptions (type: 'private' | 'public'): DropdownOptions {
const keys = [...map.keys()];
return keys
return Object
.keys(map)
.sort()
.filter((name) => {
const section = map.get(name);
const section = map[name as Extrinsic$Sections];
// cannot really get here
if (!section) {

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Method, Interface$Sections } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from '@polkadot/jsonrpc/types';
import { DropdownOptions } from '../InputExtrinsic/types';
import { I18nProps } from '../types';
@ -17,9 +18,9 @@ import translate from '../translate';
type Props = I18nProps & {
isError?: boolean,
label?: string,
onChange: (value: Interface$Method) => void,
onChange: (value: SectionItem<Interfaces>) => void,
options: DropdownOptions,
value: Interface$Method,
value: SectionItem<Interfaces>,
withLabel?: boolean
};
@ -28,9 +29,8 @@ function SelectMethod ({ className, isError, label = '', onChange, options, styl
return null;
}
const transform = (name: Interface$Sections): Interface$Method =>
// @ts-ignore check?
map.get(section).public[name];
const transform = (name: Interface$Sections): SectionItem<Interfaces> =>
map[section].public[name];
return (
<Dropdown

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Method, Interface$Sections } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from '@polkadot/jsonrpc/types';
import { DropdownOptions } from '../InputExtrinsic/types';
import { I18nProps } from '../types';
@ -18,7 +19,7 @@ type Props = I18nProps & {
label?: string,
onChange: (value: Interface$Sections) => void,
options: DropdownOptions,
value: Interface$Method,
value: SectionItem<Interfaces>,
withLabel?: boolean
};

View File

@ -4,7 +4,8 @@
// TODO: We have a lot shared between this and InputExtrinsic & InputStorage
import { Interface$Method, Interface$Sections } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from '@polkadot/jsonrpc/types';
import { DropdownOptions } from '../InputExtrinsic/types';
import { I18nProps } from '../types';
@ -22,18 +23,18 @@ import methodOptions from './options/method';
import sectionOptions from './options/section';
type Props = I18nProps & {
defaultValue: Interface$Method,
defaultValue: SectionItem<Interfaces>,
isError?: boolean,
labelMethod?: string,
labelSection?: string,
onChange: (value: Interface$Method) => void,
onChange: (value: SectionItem<Interfaces>) => void,
withLabel?: boolean
};
type State = {
optionsMethod: DropdownOptions,
optionsSection: DropdownOptions,
value: Interface$Method
value: SectionItem<Interfaces>
};
class InputRpc extends React.PureComponent<Props, State> {
@ -80,7 +81,7 @@ class InputRpc extends React.PureComponent<Props, State> {
);
}
onMethodChange = (value: Interface$Method): void => {
onMethodChange = (value: SectionItem<Interfaces>): void => {
const { onChange } = this.props;
const { value: { name, section } } = this.state;
@ -101,8 +102,7 @@ class InputRpc extends React.PureComponent<Props, State> {
}
const optionsMethod = methodOptions(newSection);
// @ts-ignore check?
const value = map.get(newSection).public[optionsMethod[0].value];
const value = map[newSection].public[optionsMethod[0].value];
this.setState({ optionsMethod }, () =>
this.onMethodChange(value)

View File

@ -10,7 +10,7 @@ import React from 'react';
import map from '@polkadot/jsonrpc';
export default function createOptions (sectionName: Interface$Sections): DropdownOptions {
const section = map.get(sectionName);
const section = map[sectionName];
if (!section) {
return [];

View File

@ -2,17 +2,18 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Sections } from '@polkadot/jsonrpc/types';
import { DropdownOptions } from '../../InputExtrinsic/types';
import map from '@polkadot/jsonrpc';
export default function createOptions (): DropdownOptions {
const keys = [...map.keys()];
return keys
return Object
.keys(map)
.sort()
.filter((name) => {
const section = map.get(name);
const section = map[name as Interface$Sections];
// cannot really get here
if (!section) {

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Key } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages } from '@polkadot/storage/types';
import { DropdownOptions } from '../InputExtrinsic/types';
import { I18nProps } from '../types';
@ -17,9 +18,9 @@ import translate from '../translate';
type Props = I18nProps & {
isError?: boolean,
label?: string,
onChange: (value: Storage$Key) => void,
onChange: (value: SectionItem<Storages>) => void,
options: DropdownOptions,
value: Storage$Key,
value: SectionItem<Storages>,
withLabel?: boolean
};
@ -28,7 +29,7 @@ function SelectKey ({ className, isError, label = '', onChange, options, style,
return null;
}
const transform = (name: string): Storage$Key =>
const transform = (name: string): SectionItem<Storages> =>
// @ts-ignore check?
map.get(section).public[name];

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Key, Storage$Sections } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages, Storage$Sections } from '@polkadot/storage/types';
import { DropdownOptions } from '../InputExtrinsic/types';
import { I18nProps } from '../types';
@ -18,7 +19,7 @@ type Props = I18nProps & {
label?: string,
onChange: (value: Storage$Sections) => void,
options: DropdownOptions,
value: Storage$Key,
value: SectionItem<Storages>,
withLabel?: boolean
};

View File

@ -4,7 +4,8 @@
// TODO: We have a lot shared between this and InputExtrinsic
import { Storage$Key, Storage$Sections } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages, Storage$Sections } from '@polkadot/storage/types';
import { DropdownOptions } from '../InputExtrinsic/types';
import { I18nProps } from '../types';
@ -22,18 +23,18 @@ import keyOptions from './options/key';
import sectionOptions from './options/section';
type Props = I18nProps & {
defaultValue: Storage$Key,
defaultValue: SectionItem<Storages>,
isError?: boolean,
labelMethod?: string,
labelSection?: string,
onChange: (value: Storage$Key) => void,
onChange: (value: SectionItem<Storages>) => void,
withLabel?: boolean
};
type State = {
optionsMethod: DropdownOptions,
optionsSection: DropdownOptions,
value: Storage$Key
value: SectionItem<Storages>
};
class InputStorage extends React.PureComponent<Props, State> {
@ -80,7 +81,7 @@ class InputStorage extends React.PureComponent<Props, State> {
);
}
onKeyChange = (value: Storage$Key): void => {
onKeyChange = (value: SectionItem<Storages>): void => {
const { onChange } = this.props;
const { value: { name, section } } = this.state;
@ -101,8 +102,7 @@ class InputStorage extends React.PureComponent<Props, State> {
}
const optionsMethod = keyOptions(newSection);
// @ts-ignore check?
const value = map.get(newSection).public[optionsMethod[0].value];
const value = map[newSection].public[optionsMethod[0].value];
this.setState({ optionsMethod }, () =>
this.onKeyChange(value)

View File

@ -10,7 +10,7 @@ import React from 'react';
import map from '@polkadot/storage';
export default function createOptions (sectionName: Storage$Sections): DropdownOptions {
const section = map.get(sectionName);
const section = map[sectionName];
if (!section) {
return [];

View File

@ -2,17 +2,17 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Sections } from '@polkadot/storage/types';
import { DropdownOptions } from '../../InputExtrinsic/types';
import map from '@polkadot/storage';
export default function createOptions (): DropdownOptions {
const keys = [...map.keys()];
return keys
return Object
.keys(map)
.sort()
.filter((name) => {
const section = map.get(name);
const section = map[name as Storage$Sections];
// cannot really get here
if (!section) {

View File

@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Section$Item } from '@polkadot/params/types';
import { SectionItem } from '@polkadot/params/types';
import { I18nProps } from '../types';
import { ComponentMap, RawParam, RawParams, RawParam$OnChange, RawParam$OnChange$Value } from './types';
import { ComponentMap, RawParams, RawParam$OnChange, RawParam$OnChange$Value } from './types';
import './Params.css';
@ -15,28 +15,28 @@ import translate from '../translate';
import Param from './Param';
import createValues from './values';
type Props<SectionItem> = I18nProps & {
item: SectionItem,
type Props<S> = I18nProps & {
item: S,
onChange: (value: RawParams) => void,
overrides?: ComponentMap
};
type State<SectionItem> = {
item: SectionItem,
type State<S> = {
item: S,
handlers: Array<RawParam$OnChange>,
onChangeParam: (at: number, next: RawParam$OnChange$Value) => void,
values: RawParams
};
class Params<T, SectionItem extends Section$Item<T>> extends React.PureComponent<Props<SectionItem>, State<SectionItem>> {
state: State<SectionItem>;
class Params<T, S extends SectionItem<T>> extends React.PureComponent<Props<S>, State<S>> {
state: State<S>;
constructor (props: Props<SectionItem>) {
constructor (props: Props<S>) {
super(props);
this.state = ({
onChangeParam: this.onChangeParam
} as State<SectionItem>);
} as State<S>);
}
static getDerivedStateFromProps (props: Props<any>, { item, onChangeParam }: State<any>): State<any> | null {
@ -53,22 +53,12 @@ class Params<T, SectionItem extends Section$Item<T>> extends React.PureComponent
);
return {
item,
item: props.item,
handlers,
values
} as State<any>;
}
// FIXME Do we really need this one? The fact that we have to do deep inspection here just shows something is amis? We notify on param change below. Really cannot remember or see the actual real need here - apart from making things more complicated than they should be. (But there must be a reason)
// componentDidUpdate (prevProps: Props<SectionItem>, prevState: State<SectionItem>) {
// const { onChange } = this.props;
// const { values } = this.state;
// if (JSON.stringify(prevState.values) !== JSON.stringify(values)) {
// onChange(values);
// }
// }
render () {
const { className, item: { params }, overrides, style } = this.props;
const { handlers, values } = this.state;
@ -99,8 +89,8 @@ class Params<T, SectionItem extends Section$Item<T>> extends React.PureComponent
onChangeParam = (at: number, { isValid = false, value }: RawParam$OnChange$Value): void => {
this.setState(
(prevState: State<SectionItem>): State<SectionItem> => {
const values = prevState.values.map((prev, index) =>
(prevState: State<S>): State<S> => ({
values: prevState.values.map((prev, index) =>
index !== at
? prev
: {
@ -108,24 +98,19 @@ class Params<T, SectionItem extends Section$Item<T>> extends React.PureComponent
type: prev.type,
value
}
);
// FIXME this should really be as the second parameter of setState, however... that stopped working, never getting the latest version from the actual state
this.props.onChange(values);
return {
values
} as State<SectionItem>;
},
)
} as State<S>),
this.triggerUpdate
);
}
triggerUpdate = (): void => {
// BUG The actual values here is not the actual new values - seems React related, was working on 16.3
// console.log('triggerUpdate', arguments, this.state.values);
// this.props.onChange(this.state.values);
const { values } = this.state;
const { onChange } = this.props;
onChange(values);
}
}
// @ts-ignore something is wrong with generics and these imports
export default translate(Params);

View File

@ -36,9 +36,9 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/api-rx": "^0.14.5",
"@polkadot/extrinsics-codec": "^0.19.5",
"@polkadot/storage": "^0.19.5"
"@polkadot/api-rx": "^0.14.6",
"@polkadot/extrinsics-codec": "^0.20.1",
"@polkadot/storage": "^0.20.1"
},
"devDependencies": {
"babel-loader": "^8.0.0-beta.2",

View File

@ -7,8 +7,7 @@ import storage from '@polkadot/storage';
import numberFormat from './util/numberFormat';
import withStorageDiv from './with/storageDiv';
// @ts-ignore check?
const method = storage.get('staking').public.freeBalanceOf;
const method = storage.staking.public.freeBalanceOf;
const Component: React.ComponentType<any> = withStorageDiv(method)(
numberFormat,

View File

@ -9,8 +9,7 @@ import rpcs from '@polkadot/jsonrpc';
import numberFormat from './util/numberFormat';
import withApiDiv from './with/apiDiv';
// @ts-ignore check?
const method = rpcs.get('chain').public.newHead;
const method = rpcs.chain.public.newHead;
const Component: React.ComponentType<any> = withApiDiv(method)(
(value?: Header): string => {

View File

@ -6,8 +6,7 @@ import rpcs from '@polkadot/jsonrpc';
import withApiDiv from './with/apiDiv';
// @ts-ignore check?
const method = rpcs.get('system').public.chain;
const method = rpcs.system.public.chain;
const Component: React.ComponentType<any> = withApiDiv(method)(
(value: string = 'unknown'): string =>

View File

@ -6,8 +6,7 @@ import rpcs from '@polkadot/jsonrpc';
import withApiDiv from './with/apiDiv';
// @ts-ignore check?
const method = rpcs.get('system').public.name;
const method = rpcs.system.public.name;
const Component: React.ComponentType<any> = withApiDiv(method)(
(value: string = 'unknown'): string =>

View File

@ -6,8 +6,7 @@ import storage from '@polkadot/storage';
import withStorageDiv from './with/storageDiv';
// @ts-ignore check?
const method = storage.get('timestamp').public.current;
const method = storage.timestamp.public.current;
const Component: React.ComponentType<any> = withStorageDiv(method)(
(value?: Date): string => {

View File

@ -6,8 +6,7 @@ import rpcs from '@polkadot/jsonrpc';
import withApiDiv from './with/apiDiv';
// @ts-ignore check?
const method = rpcs.get('system').public.version;
const method = rpcs.system.public.version;
const Component: React.ComponentType<any> = withApiDiv(method)(
(value: string = 'unknown'): string =>

View File

@ -7,8 +7,7 @@ import storage from '@polkadot/storage';
import numberFormat from './util/numberFormat';
import withStorageDiv from './with/storageDiv';
// @ts-ignore check?
const method = storage.get('system').public.accountIndexOf;
const method = storage.system.public.accountIndexOf;
const Component: React.ComponentType<any> = withStorageDiv(method)(
numberFormat,

View File

@ -4,7 +4,8 @@
// TODO: Lots of duplicated code between this and withObservable, surely there ois a better way of doing this?
import { Storage$Key, Storage$Key$Value } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages, Storage$Key$Value } from '@polkadot/storage/types';
import { ApiProps, BareProps, ChangeProps, ParamProps, RxProps } from '../types';
import { HOC, StorageOptions, DefaultProps, Transform } from './types';
@ -34,7 +35,7 @@ type State<T> = RxProps<T> & {
// FIXME proper types for attributes
export default function withStorage<T> (key: Storage$Key, { onChange, params, propName = 'value', transform }: StorageOptions<T> = {}): HOC<T> {
export default function withStorage<T> (key: SectionItem<Storages>, { onChange, params, propName = 'value', transform }: StorageOptions<T> = {}): HOC<T> {
const keyCreator = storageKey(key);
const storageTransform = createTransform(key);
const createKey = (propParams?: Array<Storage$Key$Value>): Uint8Array => {

View File

@ -2,14 +2,15 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Key } from '@polkadot/storage/types';
import { SectionItem } from '@polkadot/params/types';
import { Storages } from '@polkadot/storage/types';
import { BaseProps } from '../types';
import { ComponentRenderer, DefaultProps, RenderFn, StorageOptions } from './types';
import Div from '../Div';
import withStorage from './storage';
export default function withStorageDiv<T, Props extends BaseProps<T>> (key: Storage$Key, options?: StorageOptions<T>): ComponentRenderer<T> {
export default function withStorageDiv<T, Props extends BaseProps<T>> (key: SectionItem<Storages>, options?: StorageOptions<T>): ComponentRenderer<T> {
return (render: RenderFn, defaultProps: DefaultProps<T> = {}): React.ComponentType<Props> =>
withStorage(key, options)(Div, {
...defaultProps,

View File

@ -2,13 +2,13 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Param$Values } from '@polkadot/params/types';
import { Storage$Key } from '@polkadot/storage/types';
import { Param$Values, SectionItem } from '@polkadot/params/types';
import { Storages } from '@polkadot/storage/types';
import { StorageTransform } from '../types';
import decodeParams from '@polkadot/params/decode';
export default function storageTransform ({ type }: Storage$Key): StorageTransform {
export default function storageTransform ({ type }: SectionItem<Storages>): StorageTransform {
return (input: Uint8Array = new Uint8Array(0), index: number): Param$Values | null => {
try {
// FIXME We don't do any conversion checks for the type, currently not an issue, but _could_ turn out to be problematic

View File

@ -2,7 +2,6 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Interface$Method } from '@polkadot/jsonrpc/types';
import { Param$Values } from '@polkadot/params/types';
import { Storage$Key$Value } from '@polkadot/storage/types';
import { OnChangeCb } from '../types';

View File

@ -16,7 +16,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/extrinsics": "^0.19.5",
"@polkadot/extrinsics": "^0.20.1",
"@polkadot/ui-app": "^0.18.1",
"@polkadot/ui-keyring": "^0.18.1"
},

View File

@ -23,7 +23,7 @@ type Props = I18nProps & {
};
function findExtrinsic (sectionId: number, methodId: number): { method: string | undefined, section: string | undefined } {
const section = [...extrinsics.values()].find(({ index }) =>
const section = Object.values(extrinsics).find(({ index }) =>
index[0] === sectionId
);
const methods = section

View File

@ -3,13 +3,14 @@
// of the ISC license. See the LICENSE file for details.
import { RxApiInterface } from '@polkadot/api-rx/types';
import { Interface$Method } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from '@polkadot/jsonrpc/types';
import { Param$Values } from '@polkadot/params/types';
import { QueueTx$Result } from './types';
export default async function submitMessage (api: RxApiInterface, params: Array<Param$Values>, { name, section }: Interface$Method): Promise<QueueTx$Result> {
export default async function submitMessage (api: RxApiInterface, params: Array<Param$Values>, { name, section }: SectionItem<Interfaces>): Promise<QueueTx$Result> {
try {
const result = await api[section][name].apply(null, params).toPromise();
const result = await api[section as Interface$Sections][name].apply(null, params).toPromise();
console.log(`${section}.${name}: result ::`, result);

View File

@ -3,7 +3,8 @@
// of the ISC license. See the LICENSE file for details.
import BN from 'bn.js';
import { Interface$Method } from '@polkadot/jsonrpc/types';
import { SectionItem } from '@polkadot/params/types';
import { Interfaces } from '@polkadot/jsonrpc/types';
import { Param$Values } from '@polkadot/params/types';
export type EncodedMessage = {
@ -22,7 +23,7 @@ export type QueueTx$Result = {
}
export type QueueTx$Base = EncodedMessage & {
rpc: Interface$Method,
rpc: SectionItem<Interfaces>,
nonce: BN,
publicKey?: Uint8Array | null
};

136
yarn.lock
View File

@ -871,22 +871,22 @@
version "1.0.2"
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.0.2.tgz#d056b68999769728a1cff8d643bc59eb6f0be436"
"@polkadot/api-format@^0.14.5":
version "0.14.5"
resolved "https://registry.yarnpkg.com/@polkadot/api-format/-/api-format-0.14.5.tgz#01defcba928f33944815286a9e5fcb8438c719b7"
"@polkadot/api-format@^0.14.6":
version "0.14.6"
resolved "https://registry.yarnpkg.com/@polkadot/api-format/-/api-format-0.14.6.tgz#3b275ab3678acb4c993c470ee80b4f5811403c40"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/jsonrpc" "^0.19.5"
"@polkadot/primitives-json" "^0.19.5"
"@polkadot/jsonrpc" "^0.20.1"
"@polkadot/primitives-json" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
"@polkadot/api-provider@^0.14.5":
version "0.14.5"
resolved "https://registry.yarnpkg.com/@polkadot/api-provider/-/api-provider-0.14.5.tgz#37bf002d54b31c66a5740f8e3984c771adbbc3ed"
"@polkadot/api-provider@^0.14.6":
version "0.14.6"
resolved "https://registry.yarnpkg.com/@polkadot/api-provider/-/api-provider-0.14.6.tgz#5853eec2cb4dbe58c959f84cd7e4fe84770a29aa"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/storage" "^0.19.5"
"@polkadot/storage" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
@ -895,25 +895,25 @@
isomorphic-fetch "^2.2.1"
websocket "^1.0.25"
"@polkadot/api-rx@^0.14.5":
version "0.14.5"
resolved "https://registry.yarnpkg.com/@polkadot/api-rx/-/api-rx-0.14.5.tgz#1adaaee768bf90bea74ad371cae9678d1cb55f49"
"@polkadot/api-rx@^0.14.6":
version "0.14.6"
resolved "https://registry.yarnpkg.com/@polkadot/api-rx/-/api-rx-0.14.6.tgz#4d9f7de4c1d85082c4ee089db319046716d71cf7"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/api" "^0.14.5"
"@polkadot/api-provider" "^0.14.5"
"@polkadot/api" "^0.14.6"
"@polkadot/api-provider" "^0.14.6"
"@types/rx" "^4.1.1"
rxjs "^5.5.10"
"@polkadot/api@^0.14.5":
version "0.14.5"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.14.5.tgz#3ec0172ae10edf85eb0699a3b7ef6591d85be6e6"
"@polkadot/api@^0.14.6":
version "0.14.6"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.14.6.tgz#141c2a9a2870c8ca83190eb97e723c493e7cd886"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/api-format" "^0.14.5"
"@polkadot/api-provider" "^0.14.5"
"@polkadot/jsonrpc" "^0.19.5"
"@polkadot/params" "^0.19.5"
"@polkadot/api-format" "^0.14.6"
"@polkadot/api-provider" "^0.14.6"
"@polkadot/jsonrpc" "^0.20.1"
"@polkadot/params" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/dev-react@^0.20.3":
@ -980,96 +980,96 @@
rimraf "^2.6.2"
typescript "^2.9.2"
"@polkadot/extrinsics-codec@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics-codec/-/extrinsics-codec-0.19.5.tgz#74c794b3caa696764be41b6a4317e3720bc11de3"
"@polkadot/extrinsics-codec@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics-codec/-/extrinsics-codec-0.20.1.tgz#970897bf836bd7e0de95a1ca1bfed1db021e4e3c"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/extrinsics" "^0.19.5"
"@polkadot/params" "^0.19.5"
"@polkadot/extrinsics" "^0.20.1"
"@polkadot/params" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
bn.js "^4.11.8"
"@polkadot/extrinsics@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.19.5.tgz#da7f25e3741354f0858c7b3bcfea6cc0ab646383"
"@polkadot/extrinsics@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.20.1.tgz#c1dcecf5e649a38a9da7ac6a6603746ebb954ce6"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/params" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/params" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/jsonrpc@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.19.5.tgz#7d7c9a36425812644f5cc469791e1b714956827c"
"@polkadot/jsonrpc@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.20.1.tgz#0026fdf3d56c9acf6890457bfad80fe11c27f29c"
dependencies:
"@polkadot/params" "^0.19.5"
"@polkadot/params" "^0.20.1"
babel-runtime "^6.26.0"
"@polkadot/params@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.19.5.tgz#ecfb93a5696e9d9423412a033897adcc18a8342c"
"@polkadot/params@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.20.1.tgz#b38863fed3f599b30d9ee23c0c1265b581edc090"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/extrinsics" "^0.19.5"
"@polkadot/extrinsics-codec" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/extrinsics" "^0.20.1"
"@polkadot/extrinsics-codec" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/primitives-builder@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.19.5.tgz#55330d20ed3924bfe23d951d8490cb2303577a5b"
"@polkadot/primitives-builder@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-builder/-/primitives-builder-0.20.1.tgz#c9e062f72b49d1237bfe256352453765210ea04e"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/extrinsics-codec" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/primitives-codec" "^0.19.5"
"@polkadot/extrinsics-codec" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/primitives-codec" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-triehash" "^0.24.6"
"@polkadot/primitives-codec@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.19.5.tgz#91649d66b212bb6f11ff466908f1b43006df8db5"
"@polkadot/primitives-codec@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-codec/-/primitives-codec-0.20.1.tgz#d57053e91d8362d22d52cb14835f9d78ff20394c"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/primitives" "^0.19.5"
"@polkadot/primitives-builder" "^0.19.5"
"@polkadot/primitives" "^0.20.1"
"@polkadot/primitives-builder" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
"@polkadot/primitives-json@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.19.5.tgz#452b6827e7f707211cd786b8a1362686a0cf27aa"
"@polkadot/primitives-json@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives-json/-/primitives-json-0.20.1.tgz#808e08cca3a99b4d61117da60d3119beb7c3d801"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/primitives" "^0.19.5"
"@polkadot/primitives-builder" "^0.19.5"
"@polkadot/primitives" "^0.20.1"
"@polkadot/primitives-builder" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/primitives@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.19.5.tgz#730b3750fe21bf84b7ef00b71aa72ebeb0138ce3"
"@polkadot/primitives@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.20.1.tgz#a63693b5e86eef19d9df8602da05d0a284d7bcf1"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/util" "^0.24.6"
"@polkadot/storage@^0.19.5":
version "0.19.5"
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.19.5.tgz#375a5a98718b24941a198f7e1833a62b7830ef22"
"@polkadot/storage@^0.20.1":
version "0.20.1"
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.20.1.tgz#84f5d1614eecdfca4cd7a5b577a1c29e095f95ed"
dependencies:
"@babel/runtime" "^7.0.0-beta.51"
"@polkadot/params" "^0.19.5"
"@polkadot/primitives" "^0.19.5"
"@polkadot/params" "^0.20.1"
"@polkadot/primitives" "^0.20.1"
"@polkadot/util" "^0.24.6"
"@polkadot/util-crypto" "^0.24.6"
"@polkadot/util-keyring" "^0.24.6"
"@polkadot/ts@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.2.tgz#816e9e2c419ce464357c135f61079f11c9c44488"
"@polkadot/ts@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.3.tgz#e277fb89c43a64b244a6d1ae03fc4ede128b155d"
"@polkadot/util-crypto@^0.24.6":
version "0.24.6"