Retrieve block information (#229)
* Retrieve block information * Render unknown addresses * Don't render extrinsics count (getBlock) if not needed * Fix dep versions
This commit is contained in:
parent
39397bad4a
commit
39fb78afd4
@ -11,7 +11,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/storage": "^0.28.15",
|
||||
"@polkadot/storage": "^0.28.16",
|
||||
"@polkadot/ui-react": "^0.19.35",
|
||||
"@polkadot/ui-react-rx": "^0.19.35",
|
||||
"@polkadot/util-keyring": "^0.28.3"
|
||||
|
||||
@ -8,12 +8,12 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import Card from '@polkadot/ui-app/Card';
|
||||
import Extrinsic from '@polkadot/ui-app/Extrinsic';
|
||||
import classes from '@polkadot/ui-app/util/classes';
|
||||
import numberFormat from '@polkadot/ui-react-rx/util/numberFormat';
|
||||
|
||||
// TODO This would be nice as a shared component, move to ui-app as soon as
|
||||
// we have actual "more-than-one-use" apps
|
||||
import Extrinsic from './Extrinsic';
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
@ -23,6 +23,7 @@ type Props = I18nProps & {
|
||||
idNumber: BN
|
||||
};
|
||||
|
||||
// FIXME Duplicated layout here and in explorer, clean up with extrinsics
|
||||
class Item extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { children, className, idNumber, proposal, proposalExtra, style } = this.props;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/storage": "^0.28.15",
|
||||
"@polkadot/storage": "^0.28.16",
|
||||
"@polkadot/ui-react": "^0.19.35",
|
||||
"@polkadot/ui-react-rx": "^0.19.35",
|
||||
"@polkadot/util-keyring": "^0.28.3"
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/primitives": "^0.28.15",
|
||||
"@polkadot/primitives": "^0.28.16",
|
||||
"@polkadot/ui-app": "^0.19.35",
|
||||
"@polkadot/util-crypto": "^0.28.3"
|
||||
}
|
||||
|
||||
74
packages/app-explorer/src/BlockByHash/BlockByHash.tsx
Normal file
74
packages/app-explorer/src/BlockByHash/BlockByHash.tsx
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { BareProps } from '@polkadot/ui-app/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import React from 'react';
|
||||
import withObservable from '@polkadot/ui-react-rx/with/observable';
|
||||
import AddressMini from '@polkadot/ui-app/AddressMini';
|
||||
import Card from '@polkadot/ui-app/Card';
|
||||
import Extrinsic from '@polkadot/ui-app/Extrinsic';
|
||||
|
||||
import BlockHeader from '../BlockHeader';
|
||||
import isHex from '@polkadot/util/is/hex';
|
||||
|
||||
type Props = ApiProps & BareProps & {
|
||||
chainGetBlock: any,
|
||||
value: string
|
||||
};
|
||||
|
||||
// FIXME Duplicated layout here and in democracy, clean up with extrinsics
|
||||
class BlockByHash extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { chainGetBlock, value } = this.props;
|
||||
|
||||
if (!chainGetBlock) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { extrinsics, header } = chainGetBlock;
|
||||
|
||||
// TODO Remove, debug info for reverse-engineering
|
||||
console.log('hash=', value);
|
||||
console.log('block=', chainGetBlock);
|
||||
|
||||
return (
|
||||
<div className='explorer--BlockByHash'>
|
||||
<BlockHeader
|
||||
value={header}
|
||||
withExtrinsics
|
||||
/>
|
||||
<div className='explorer--BlockByHash-extrinsics'>
|
||||
{extrinsics.map((extrinsic: any, index: number) => (
|
||||
<div
|
||||
className='explorer--BlockByHash-extrinsic'
|
||||
key={`${value}:extrinsic:${index}`}
|
||||
>
|
||||
<Card>
|
||||
<div className='explorer--BlockByHash-extrinsic-header'>
|
||||
<div className='explorer--BlockByHash-extrinsic-header-name'>
|
||||
{extrinsic.extrinsic.section}.{extrinsic.extrinsic.name}
|
||||
</div>
|
||||
<div className='explorer--BlockByHash-extrinsic-header-description'>
|
||||
{extrinsic.extrinsic.description}
|
||||
</div>
|
||||
<div className='explorer--BlockByHash-header-right'>
|
||||
{isHex(extrinsic.address)
|
||||
? extrinsic.address
|
||||
: <AddressMini value={extrinsic.address} />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<Extrinsic value={extrinsic} />
|
||||
</Card>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withObservable('chainGetBlock', { paramProp: 'value' })(BlockByHash);
|
||||
31
packages/app-explorer/src/BlockByHash/index.tsx
Normal file
31
packages/app-explorer/src/BlockByHash/index.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { BareProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import BlockByHash from './BlockByHash';
|
||||
|
||||
type Props = BareProps & {
|
||||
match: {
|
||||
params: {
|
||||
hash: string
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default class Entry extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { match: { params: { hash } } } = this.props;
|
||||
|
||||
if (!hash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<BlockByHash value={hash} />
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -4,28 +4,31 @@
|
||||
|
||||
import { Header } from '@polkadot/primitives/header';
|
||||
import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import './BlockHeader.css';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { Link } from 'react-router-dom';
|
||||
import headerHash from '@polkadot/primitives/codec/header/hash';
|
||||
import classes from '@polkadot/ui-app/util/classes';
|
||||
import numberFormat from '@polkadot/ui-react-rx/util/numberFormat';
|
||||
import withApi from '@polkadot/ui-react-rx/with/api';
|
||||
import u8aToHex from '@polkadot/util/u8a/toHex';
|
||||
|
||||
import translate from '../translate';
|
||||
import Extrinsics from './Extrinsics';
|
||||
|
||||
type Props = ApiProps & I18nProps & {
|
||||
value?: Header
|
||||
// NOTE This add unneeded load, for now just on click-through
|
||||
import Extrinsics from './Extrinsics';
|
||||
// <Extrinsics hash={hash} />
|
||||
|
||||
type Props = I18nProps & {
|
||||
value?: Header,
|
||||
withExtrinsics?: boolean,
|
||||
withLink?: boolean
|
||||
};
|
||||
|
||||
class BlockHeader extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, value, style } = this.props;
|
||||
const { className, value, style, withExtrinsics = false, withLink = false } = this.props;
|
||||
|
||||
if (!value) {
|
||||
return null;
|
||||
@ -34,6 +37,10 @@ class BlockHeader extends React.PureComponent<Props> {
|
||||
const hash = headerHash(value);
|
||||
// tslint:disable-next-line:variable-name
|
||||
const { extrinsicsRoot, number, parentHash, stateRoot } = value;
|
||||
const hashHex = u8aToHex(hash);
|
||||
const linkable = withLink
|
||||
? <Link to={`/explorer/hash/${hashHex}`}>{hashHex}</Link>
|
||||
: hashHex;
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -45,7 +52,7 @@ class BlockHeader extends React.PureComponent<Props> {
|
||||
</div>
|
||||
<div className='details'>
|
||||
<div className='hash'>
|
||||
{u8aToHex(hash)}
|
||||
{linkable}
|
||||
</div>
|
||||
<table className='contains'>
|
||||
<tbody>
|
||||
@ -67,27 +74,16 @@ class BlockHeader extends React.PureComponent<Props> {
|
||||
{u8aToHex(stateRoot)}
|
||||
</td>
|
||||
</tr>
|
||||
{this.renderExtrinsics(hash)}
|
||||
{withExtrinsics
|
||||
? <Extrinsics hash={hash} />
|
||||
: undefined
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
private renderExtrinsics (hash: Uint8Array) {
|
||||
const { apiMethods } = this.props;
|
||||
|
||||
if (!apiMethods['chain_getBlock']) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Extrinsics hash={hash} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withApi(
|
||||
translate(BlockHeader)
|
||||
);
|
||||
export default translate(BlockHeader);
|
||||
|
||||
@ -41,6 +41,7 @@ export default withObservableDiv('chainNewHead', apiOptions)(
|
||||
<BlockHeader
|
||||
key={value.number.toString()}
|
||||
value={value}
|
||||
withLink
|
||||
/>
|
||||
)),
|
||||
{ className: 'explorer--BlockHeaders' }
|
||||
|
||||
25
packages/app-explorer/src/Main.tsx
Normal file
25
packages/app-explorer/src/Main.tsx
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { BareProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Query from './Query';
|
||||
import Summary from './Summary';
|
||||
import BlockHeaders from './BlockHeaders';
|
||||
|
||||
type Props = BareProps & {
|
||||
basePath: string
|
||||
};
|
||||
|
||||
export default class Main extends React.PureComponent<Props> {
|
||||
render () {
|
||||
return [
|
||||
<Summary key='summary' />,
|
||||
<Query key='query' />,
|
||||
<BlockHeaders key='headers' />
|
||||
];
|
||||
}
|
||||
}
|
||||
73
packages/app-explorer/src/Query.tsx
Normal file
73
packages/app-explorer/src/Query.tsx
Normal file
@ -0,0 +1,73 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
import Button from '@polkadot/ui-app/Button';
|
||||
import Input from '@polkadot/ui-app/Input';
|
||||
import Labelled from '@polkadot/ui-app/Labelled';
|
||||
import isHex from '@polkadot/util/is/hex';
|
||||
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {};
|
||||
|
||||
type State = {
|
||||
hash: string
|
||||
isValid: boolean
|
||||
};
|
||||
|
||||
class Query extends React.PureComponent<Props, State> {
|
||||
state: State = {
|
||||
hash: '',
|
||||
isValid: false
|
||||
};
|
||||
|
||||
render () {
|
||||
const { t } = this.props;
|
||||
const { hash, isValid } = this.state;
|
||||
|
||||
return (
|
||||
<div className='explorer--Query'>
|
||||
<div className='ui--row'>
|
||||
<div className='small' />
|
||||
<div className='storage--Query-actionrow medium'>
|
||||
<Input
|
||||
className='storage--Query-actionrow-hash'
|
||||
isError={!isValid && hash.length !== 0}
|
||||
placeholder={t('query', {
|
||||
defaultValue: 'block hash to query'
|
||||
})}
|
||||
onChange={this.setHash}
|
||||
/>
|
||||
<Labelled className='storage--Query-actionrow-button'>
|
||||
<Button
|
||||
icon='play'
|
||||
isDisabled={!isValid}
|
||||
isPrimary
|
||||
onClick={this.onQuery}
|
||||
/>
|
||||
</Labelled>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
private setHash = (hash: string) => {
|
||||
this.setState({
|
||||
hash,
|
||||
isValid: isHex(hash, 256)
|
||||
});
|
||||
}
|
||||
|
||||
private onQuery = () => {
|
||||
const { hash } = this.state;
|
||||
|
||||
window.location.hash = `/explorer/hash/${hash}`;
|
||||
}
|
||||
}
|
||||
|
||||
export default translate(Query);
|
||||
@ -30,12 +30,42 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.explorer--BlockByHash-extrinsics {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.explorer--BlockByHash-extrinsic {
|
||||
flex: 0 0 50%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.explorer--BlockByHash-extrinsic-header {
|
||||
position: relative;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.explorer--BlockByHash-extrinsic-header-description {
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.explorer--BlockByHash-extrinsic-header-name {
|
||||
font-size: 1.2rem;
|
||||
line-height: 1.2rem;
|
||||
}
|
||||
|
||||
.explorer--BlockByHash-header-right {
|
||||
position: absolute;
|
||||
top: 0em;
|
||||
right: 1em;
|
||||
}
|
||||
|
||||
.explorer--Summary {
|
||||
align-items: stretch;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.explorer--Summary-column {
|
||||
@ -48,3 +78,21 @@
|
||||
flex: 0 1 auto;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.explorer--Query {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.storage--Query-actionrow {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.storage--Query-actionrow-hash {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.storage--Query-actionrow-button {
|
||||
flex: 0;
|
||||
padding: 0 0.25rem;
|
||||
}
|
||||
|
||||
@ -8,16 +8,17 @@ import './index.css';
|
||||
|
||||
import React from 'react';
|
||||
import Page from '@polkadot/ui-app/Page';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import classes from '@polkadot/ui-app/util/classes';
|
||||
|
||||
import Summary from './Summary';
|
||||
import BlockHeaders from './BlockHeaders';
|
||||
import BlockByHash from './BlockByHash';
|
||||
import Main from './Main';
|
||||
|
||||
type Props = BareProps & {
|
||||
basePath: string
|
||||
};
|
||||
|
||||
export default class ExplorerApp extends React.PureComponent<Props> {
|
||||
export default class ExplorerApp extends React.Component<Props> {
|
||||
render () {
|
||||
const { className, style } = this.props;
|
||||
|
||||
@ -26,8 +27,10 @@ export default class ExplorerApp extends React.PureComponent<Props> {
|
||||
className={classes('explorer--App', className)}
|
||||
style={style}
|
||||
>
|
||||
<Summary />
|
||||
<BlockHeaders />
|
||||
<Switch>
|
||||
<Route path='/explorer/hash/:hash' component={BlockByHash} />
|
||||
<Route component={Main} />
|
||||
</Switch>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/extrinsics": "^0.28.15",
|
||||
"@polkadot/extrinsics": "^0.28.16",
|
||||
"@polkadot/ui-app": "^0.19.35",
|
||||
"@polkadot/ui-signer": "^0.19.35",
|
||||
"react-dropzone": "^4.3.0"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/app-extrinsics": "^0.19.35",
|
||||
"@polkadot/storage": "^0.28.15",
|
||||
"@polkadot/storage": "^0.28.16",
|
||||
"@polkadot/ui-app": "^0.19.35",
|
||||
"@polkadot/ui-keyring": "^0.19.35",
|
||||
"@polkadot/ui-react": "^0.19.35",
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/extrinsics": "^0.28.15",
|
||||
"@polkadot/storage": "^0.28.15",
|
||||
"@polkadot/extrinsics": "^0.28.16",
|
||||
"@polkadot/storage": "^0.28.16",
|
||||
"@polkadot/ui-keyring": "^0.19.35",
|
||||
"@polkadot/ui-react": "^0.19.35",
|
||||
"@polkadot/ui-react-rx": "^0.19.35",
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { ExtrinsicDecoded } from '@polkadot/params/types';
|
||||
import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RawParam } from '@polkadot/ui-app/Params/types';
|
||||
import { I18nProps } from './types';
|
||||
import { RawParam } from './Params/types';
|
||||
|
||||
import React from 'react';
|
||||
import Params from '@polkadot/ui-app/Params';
|
||||
import classes from '@polkadot/ui-app/util/classes';
|
||||
|
||||
import classes from './util/classes';
|
||||
import Params from './Params';
|
||||
import translate from './translate';
|
||||
|
||||
export type Props = I18nProps & {
|
||||
@ -28,7 +28,7 @@ class Extrinsic extends React.PureComponent<Props> {
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classes('democracy--Extrinsic', className)}
|
||||
className={classes('ui--Extrinsic', className)}
|
||||
style={style}
|
||||
>
|
||||
{children}
|
||||
@ -12,6 +12,7 @@ import React from 'react';
|
||||
import keyring from '@polkadot/ui-keyring/index';
|
||||
import createOptionHeader from '@polkadot/ui-keyring/options/header';
|
||||
import addressDecode from '@polkadot/util-keyring/address/decode';
|
||||
import makeOption from '@polkadot/ui-keyring/options/item';
|
||||
|
||||
import Dropdown from '../Dropdown';
|
||||
import classes from '../util/classes';
|
||||
@ -71,6 +72,9 @@ export default class InputAddress extends React.Component<Props, State> {
|
||||
const { className, hideAddress = false, isDisabled = false, isError, label, onChange, type = 'all', style, withLabel } = this.props;
|
||||
const { defaultValue, value } = this.state;
|
||||
const options = keyring.getOptions(type);
|
||||
const hasValue = !!options.find(({ key }) =>
|
||||
key === defaultValue
|
||||
);
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
@ -85,7 +89,11 @@ export default class InputAddress extends React.Component<Props, State> {
|
||||
label={label}
|
||||
onChange={onChange}
|
||||
onSearch={this.onSearch}
|
||||
options={options}
|
||||
options={
|
||||
isDisabled && !hasValue && defaultValue
|
||||
? [makeOption(defaultValue)]
|
||||
: options
|
||||
}
|
||||
style={style}
|
||||
transform={transform}
|
||||
value={value}
|
||||
|
||||
43
packages/ui-app/src/Params/Param/Timestamp.tsx
Normal file
43
packages/ui-app/src/Params/Param/Timestamp.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright 2017-2018 @polkadot/ui-app authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { Props, RawParam$OnChange$Value } from '../types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import Amount from './Amount';
|
||||
import Static from '../../Static';
|
||||
|
||||
export default class Code extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, defaultValue, isDisabled, isError, label, style, withLabel } = this.props;
|
||||
const Component = isDisabled
|
||||
? Static
|
||||
: Amount;
|
||||
|
||||
return (
|
||||
<Component
|
||||
className={className}
|
||||
defaultValue={
|
||||
isDisabled
|
||||
? ((defaultValue && defaultValue.value) ? defaultValue.value.toString() : '')
|
||||
: defaultValue
|
||||
}
|
||||
isDisabled={isDisabled}
|
||||
isError={isError}
|
||||
label={label}
|
||||
onChange={this.onChange}
|
||||
style={style}
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Validate that we have actual proper WASM code
|
||||
onChange = (value: RawParam$OnChange$Value): void => {
|
||||
const { onChange } = this.props;
|
||||
|
||||
onChange && onChange(value);
|
||||
}
|
||||
}
|
||||
@ -8,16 +8,27 @@ import React from 'react';
|
||||
|
||||
import typeToString from '@polkadot/params/typeToString';
|
||||
|
||||
import Static from '../../Static';
|
||||
import translate from '../../translate';
|
||||
import Base from './Base';
|
||||
|
||||
type Props = BareProps & {
|
||||
isDiabled?: boolean,
|
||||
defaultValue: RawParam,
|
||||
t: any, // I18Next$Translate?
|
||||
withLabel?: boolean
|
||||
};
|
||||
|
||||
function Unknown ({ defaultValue: { type }, label, t, withLabel }: Props) {
|
||||
function Unknown ({ defaultValue: { value, type }, isDisabled, label, t, withLabel }: Props) {
|
||||
if (isDisabled) {
|
||||
return (
|
||||
<Static
|
||||
label={label}
|
||||
value={(value && value.toString()) || t('unknown.empty', { defaultValue: 'empty' })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Base
|
||||
size='full'
|
||||
|
||||
@ -14,6 +14,7 @@ import Hash from './Hash';
|
||||
import StorageKeyValue from './StorageKeyValue';
|
||||
import StorageKeyValueArray from './StorageKeyValueArray';
|
||||
import StringParam from './String';
|
||||
import Timestamp from './Timestamp';
|
||||
import Unknown from './Unknown';
|
||||
import VoteThreshold from './VoteThreshold';
|
||||
|
||||
@ -39,7 +40,7 @@ const components: ComponentMap = {
|
||||
'SessionKey': Amount,
|
||||
'Signature': Hash,
|
||||
'String': StringParam,
|
||||
'Timestamp': Amount,
|
||||
'Timestamp': Timestamp,
|
||||
'u32': Amount,
|
||||
'u64': Amount,
|
||||
'VoteIndex': Amount,
|
||||
|
||||
@ -10,6 +10,7 @@ import Labelled from './Labelled';
|
||||
|
||||
type Props = BareProps & {
|
||||
children?: React.ReactNode,
|
||||
defaultValue?: any,
|
||||
isHidden?: boolean,
|
||||
label?: any, // node?
|
||||
value?: any, // node?
|
||||
@ -18,7 +19,7 @@ type Props = BareProps & {
|
||||
|
||||
export default class Static extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, children, isHidden, label, style, value, withLabel } = this.props;
|
||||
const { className, children, defaultValue, isHidden, label, style, value, withLabel } = this.props;
|
||||
|
||||
return (
|
||||
<Labelled
|
||||
@ -29,7 +30,7 @@ export default class Static extends React.PureComponent<Props> {
|
||||
withLabel={withLabel}
|
||||
>
|
||||
<div className='ui dropdown selection disabled'>
|
||||
{value}
|
||||
{value || defaultValue}
|
||||
{children}
|
||||
</div>
|
||||
</Labelled>
|
||||
|
||||
@ -129,8 +129,8 @@
|
||||
}
|
||||
|
||||
.ui--Card {
|
||||
background: #fefefe;
|
||||
border: 1px solid #f5f5f5;
|
||||
background: #fcfcfc;
|
||||
border: 1px solid #fafafa;
|
||||
border-radius: 0.25rem;
|
||||
margin: 0.5rem;
|
||||
padding: 1.5rem;
|
||||
|
||||
@ -31,9 +31,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-react-rx#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/api-rx": "^0.28.15",
|
||||
"@polkadot/extrinsics": "^0.28.15",
|
||||
"@polkadot/storage": "^0.28.15",
|
||||
"@polkadot/api-rx": "^0.28.16",
|
||||
"@polkadot/extrinsics": "^0.28.16",
|
||||
"@polkadot/storage": "^0.28.16",
|
||||
"rxjs-compat": "^6.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -17,7 +17,6 @@ import defaults from '@polkadot/api-rx/defaults';
|
||||
|
||||
import ApiObservable from '../ApiObservable';
|
||||
import ApiContext from './Context';
|
||||
import isUndefined from '@polkadot/util/is/undefined';
|
||||
|
||||
type Props = {
|
||||
api?: RxApiInterface,
|
||||
@ -119,26 +118,8 @@ export default class Api extends React.PureComponent<Props, State> {
|
||||
private subscribeMethodCheck = (api: RxApiInterface): void => {
|
||||
api.chain
|
||||
.newHead()
|
||||
.subscribe(async (header?: Header) => {
|
||||
if (!header || !isUndefined(this.state.apiMethods['chain_getBlock'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
let isSupported = false;
|
||||
|
||||
try {
|
||||
await api.chain.getBlock(header.parentHash).toPromise();
|
||||
isSupported = true;
|
||||
} catch (error) {
|
||||
// console.error('chain_getBlock not supported, ignoring');
|
||||
}
|
||||
|
||||
this.setState(({ apiMethods }: State) => ({
|
||||
apiMethods: {
|
||||
...apiMethods,
|
||||
'chain_getBlock': isSupported
|
||||
}
|
||||
}));
|
||||
.subscribe((header?: Header) => {
|
||||
// here we can check for missing methods
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0-rc.1",
|
||||
"@polkadot/extrinsics": "^0.28.15",
|
||||
"@polkadot/extrinsics": "^0.28.16",
|
||||
"@polkadot/ui-app": "^0.19.35",
|
||||
"@polkadot/ui-keyring": "^0.19.35"
|
||||
},
|
||||
|
||||
88
yarn.lock
88
yarn.lock
@ -1291,22 +1291,22 @@
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.0.tgz#50c1e2260ac0ed9439a181de3725a0168d59c48a"
|
||||
|
||||
"@polkadot/api-format@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api-format/-/api-format-0.28.15.tgz#0ca2260e980026af402ffa89fa433278e69ba2a1"
|
||||
"@polkadot/api-format@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api-format/-/api-format-0.28.16.tgz#3642cac8f22b8af25715b2d6c27eee5c89982efa"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/jsonrpc" "^0.28.15"
|
||||
"@polkadot/primitives" "^0.28.15"
|
||||
"@polkadot/jsonrpc" "^0.28.16"
|
||||
"@polkadot/primitives" "^0.28.16"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
"@polkadot/util-keyring" "^0.28.3"
|
||||
|
||||
"@polkadot/api-provider@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api-provider/-/api-provider-0.28.15.tgz#d96ae577d3a4a4cfcc4b17f2fa2e400f2d046c63"
|
||||
"@polkadot/api-provider@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api-provider/-/api-provider-0.28.16.tgz#2c4073dfa86bb426371da5e2e29614785db373e5"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/storage" "^0.28.15"
|
||||
"@polkadot/storage" "^0.28.16"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
"@polkadot/util-crypto" "^0.28.3"
|
||||
"@polkadot/util-keyring" "^0.28.3"
|
||||
@ -1315,25 +1315,25 @@
|
||||
isomorphic-fetch "^2.2.1"
|
||||
websocket "^1.0.25"
|
||||
|
||||
"@polkadot/api-rx@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api-rx/-/api-rx-0.28.15.tgz#521cdd7753cc83dbed29b737014bfb55e88cd2c4"
|
||||
"@polkadot/api-rx@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api-rx/-/api-rx-0.28.16.tgz#fc8ff96815a57f5224490bcda3e4d0b80c98a579"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/api" "^0.28.15"
|
||||
"@polkadot/api-provider" "^0.28.15"
|
||||
"@polkadot/api" "^0.28.16"
|
||||
"@polkadot/api-provider" "^0.28.16"
|
||||
"@types/rx" "^4.1.1"
|
||||
rxjs "^6.2.2"
|
||||
|
||||
"@polkadot/api@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.28.15.tgz#763816de983118f013fd59444acbdfdba4086019"
|
||||
"@polkadot/api@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.28.16.tgz#44ff0f39925bf9d0d31b1914691eb25a0052770f"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/api-format" "^0.28.15"
|
||||
"@polkadot/api-provider" "^0.28.15"
|
||||
"@polkadot/jsonrpc" "^0.28.15"
|
||||
"@polkadot/params" "^0.28.15"
|
||||
"@polkadot/api-format" "^0.28.16"
|
||||
"@polkadot/api-provider" "^0.28.16"
|
||||
"@polkadot/jsonrpc" "^0.28.16"
|
||||
"@polkadot/params" "^0.28.16"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
|
||||
"@polkadot/dev-react@^0.20.16":
|
||||
@ -1401,48 +1401,48 @@
|
||||
typedoc "^0.11.1"
|
||||
typescript "^3.0.1"
|
||||
|
||||
"@polkadot/extrinsics@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.28.15.tgz#514331541b06198174db36a9a6d6bb888c4db13e"
|
||||
"@polkadot/extrinsics@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/extrinsics/-/extrinsics-0.28.16.tgz#d94a49de59ec7686db6c2e1dd80a0e10c4cbb199"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/params" "^0.28.15"
|
||||
"@polkadot/primitives" "^0.28.15"
|
||||
"@polkadot/params" "^0.28.16"
|
||||
"@polkadot/primitives" "^0.28.16"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
|
||||
"@polkadot/jsonrpc@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.28.15.tgz#a29a707cc8c6fa1c9443c533aea70a32f9128824"
|
||||
"@polkadot/jsonrpc@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.28.16.tgz#cf60e160e53aec10eb5cc605e16d8af3182ff344"
|
||||
dependencies:
|
||||
"@polkadot/params" "^0.28.15"
|
||||
"@polkadot/params" "^0.28.16"
|
||||
babel-runtime "^6.26.0"
|
||||
|
||||
"@polkadot/params@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.28.15.tgz#f75622235541ab6dd70733d124a7c25ce46ccb63"
|
||||
"@polkadot/params@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/params/-/params-0.28.16.tgz#79422f73266fb317e0327f5ce2c5d1303d883e93"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/extrinsics" "^0.28.15"
|
||||
"@polkadot/params" "^0.28.15"
|
||||
"@polkadot/primitives" "^0.28.15"
|
||||
"@polkadot/extrinsics" "^0.28.16"
|
||||
"@polkadot/params" "^0.28.16"
|
||||
"@polkadot/primitives" "^0.28.16"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
"@polkadot/util-keyring" "^0.28.3"
|
||||
|
||||
"@polkadot/primitives@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.28.15.tgz#cba54b01b440a938ae8d153aabb6098307cf3beb"
|
||||
"@polkadot/primitives@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/primitives/-/primitives-0.28.16.tgz#e44774c077ee3446bd26ac72e09f455ec6d34375"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/trie-hash" "^0.28.3"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
|
||||
"@polkadot/storage@^0.28.15":
|
||||
version "0.28.15"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.28.15.tgz#5778f7c16651d6eca7d2d4129edc4031e798fd8e"
|
||||
"@polkadot/storage@^0.28.16":
|
||||
version "0.28.16"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/storage/-/storage-0.28.16.tgz#7207d8a5aa4b21ecd31183ab734a8087458b7a85"
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.0.0-rc.1"
|
||||
"@polkadot/params" "^0.28.15"
|
||||
"@polkadot/primitives" "^0.28.15"
|
||||
"@polkadot/params" "^0.28.16"
|
||||
"@polkadot/primitives" "^0.28.16"
|
||||
"@polkadot/util" "^0.28.3"
|
||||
"@polkadot/util-crypto" "^0.28.3"
|
||||
"@polkadot/util-keyring" "^0.28.3"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user