ghost-portal/packages/ui-reactive/src/AccountIndex.tsx
Jaco Greeff b4de745cda
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
2019-07-29 12:24:43 +02:00

42 lines
1.2 KiB
TypeScript

/* eslint-disable @typescript-eslint/camelcase */
// Copyright 2017-2019 @polkadot/ui-reactive 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 { BareProps, CallProps } from '@polkadot/ui-api/types';
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import React from 'react';
import { withCalls } from '@polkadot/ui-api';
type Props = BareProps & CallProps & {
children?: React.ReactNode;
label?: React.ReactNode;
params?: string;
accounts_idAndIndex?: [AccountId?, AccountIndex?];
};
export class AccountIndexDisplay extends React.PureComponent<Props> {
public render (): React.ReactNode {
const { children, className, label = '', style, accounts_idAndIndex = [] } = this.props;
const [, accountIndex] = accounts_idAndIndex;
return (
<div
className={className}
style={style}
>
{label}{
accountIndex
? accountIndex.toString()
: '-'
}{children}
</div>
);
}
}
export default withCalls<Props>(
['derive.accounts.idAndIndex', { paramName: 'params' }]
)(AccountIndexDisplay);