Use ApiPromise instance, replace ApiObservable (#540)
* Expose ApiPromise, cleanup API props * WIP * First component via ApiPromise * More items via ApiPromise * More robust availability handling * Disable routes based on API endpoint checks * Handle promises * Low-hanging fruit for call conversion * Remove extra params * Adjust rx components with children props * Start pulling in derived values * Additional derived * Bump * More derived values * Add derive.balances.fees * Additional account lookups * derive lookup for Id -> Index mappings * Cleanups, accountIdToIndex * Rework for new API * Update deps, all-ok after API bumps * Add voting and validating balances * Cleanup callback * Democracy wrap-up * 2019 * withApiPromise -> withApiCall * Calculate referendum number * Fix balances, withObservableBase -> withObservable * Cleanup with actual interfaces * withApiCall -> withCall * Bumps * api-observable types replaced * Half-effort to adjust extrinsic creation * No api-observable refs anymore * Cleanup storage query app * Cleanup call * Voting works... * Add Vote component * Update API
This commit is contained in:
parent
a26235d1f5
commit
fef9f61c65
@ -27,9 +27,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.2",
|
||||
"@polkadot/dev-react": "^0.23.3",
|
||||
"@polkadot/ts": "^0.1.44",
|
||||
"autoprefixer": "^9.4.3",
|
||||
"@polkadot/dev-react": "^0.23.7",
|
||||
"@polkadot/ts": "^0.1.47",
|
||||
"autoprefixer": "^9.4.4",
|
||||
"empty": "^0.10.1",
|
||||
"gh-pages": "^2.0.1",
|
||||
"postcss": "^7.0.7",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -12,7 +12,7 @@ import './index.css';
|
||||
import React from 'react';
|
||||
import accountObservable from '@polkadot/ui-keyring/observable/accounts';
|
||||
import { Tabs } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservableBase } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import Creator from './Creator';
|
||||
import Editor from './Editor';
|
||||
@ -131,5 +131,5 @@ class AccountsApp extends React.PureComponent<Props, State> {
|
||||
export default withMulti(
|
||||
AccountsApp,
|
||||
translate,
|
||||
withObservableBase(accountObservable.subject, { propName: 'allAccounts' })
|
||||
withObservable(accountObservable.subject, { propName: 'allAccounts' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-addresses authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-addresses authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-addresses authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-addresses authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-accounts authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-accounts authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-addresses authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-addresses authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-addresses authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-addresses authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -12,7 +12,7 @@ import React from 'react';
|
||||
|
||||
import addressObservable from '@polkadot/ui-keyring/observable/addresses';
|
||||
import Tabs, { TabItem } from '@polkadot/ui-app/Tabs';
|
||||
import { withMulti, withObservableBase } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import Creator from './Creator';
|
||||
import Editor from './Editor';
|
||||
@ -128,5 +128,5 @@ class AddressesApp extends React.PureComponent<Props, State> {
|
||||
export default withMulti(
|
||||
AddressesApp,
|
||||
translate,
|
||||
withObservableBase(addressObservable.subject, { propName: 'allAddresses' })
|
||||
withObservable(addressObservable.subject, { propName: 'allAddresses' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-addresses authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-addresses authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/keyring": "^0.33.27",
|
||||
"@polkadot/storage": "^0.35.19",
|
||||
"@polkadot/keyring": "^0.33.30",
|
||||
"@polkadot/storage": "^0.37.6",
|
||||
"@polkadot/ui-react-rx": "^0.21.17"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,46 +1,48 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RxProposal, RxProposalDeposits } from '@polkadot/api-observable/classes';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import { AccountId, Balance, Proposal } from '@polkadot/types';
|
||||
import { Tuple, Vector } from '@polkadot/types/codec';
|
||||
import { AddressMini, Labelled, Static } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
import { balanceFormat } from '@polkadot/ui-react-rx/util/index';
|
||||
|
||||
import Item from './Item';
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
proposalDeposits?: RxProposalDeposits,
|
||||
query_democracy_depositOf?: Tuple,
|
||||
idNumber: BN,
|
||||
value: RxProposal
|
||||
value: Tuple
|
||||
};
|
||||
|
||||
class Proposal extends React.PureComponent<Props> {
|
||||
class ProposalDisplay extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { idNumber, value } = this.props;
|
||||
|
||||
return (
|
||||
<Item
|
||||
idNumber={idNumber}
|
||||
proposal={value.proposal}
|
||||
proposal={value[1] as Proposal}
|
||||
proposalExtra={this.renderExtra()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
private renderExtra () {
|
||||
const { proposalDeposits, t } = this.props;
|
||||
const { query_democracy_depositOf, t } = this.props;
|
||||
|
||||
if (!proposalDeposits) {
|
||||
if (!query_democracy_depositOf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { balance, addresses } = proposalDeposits;
|
||||
const balance = query_democracy_depositOf[0] as Balance;
|
||||
const addresses = query_democracy_depositOf[1] as Vector<AccountId>;
|
||||
|
||||
return (
|
||||
<div className='democracy--Proposal-info'>
|
||||
@ -72,7 +74,7 @@ class Proposal extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
export default withMulti(
|
||||
Proposal,
|
||||
ProposalDisplay,
|
||||
translate,
|
||||
withObservable('proposalDeposits', { paramProp: 'idNumber' })
|
||||
withCall('query.democracy.depositOf', { paramProp: 'idNumber' })
|
||||
);
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RxProposal } from '@polkadot/api-observable/classes';
|
||||
|
||||
import React from 'react';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { Tuple } from '@polkadot/types/codec';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import Proposal from './Proposal';
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
publicProposals?: Array<RxProposal>
|
||||
query_democracy_publicProps?: Array<Tuple>
|
||||
};
|
||||
|
||||
class Proposals extends React.PureComponent<Props> {
|
||||
@ -30,9 +30,9 @@ class Proposals extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
private renderProposals () {
|
||||
const { publicProposals, t } = this.props;
|
||||
const { query_democracy_publicProps, t } = this.props;
|
||||
|
||||
if (!publicProposals || !publicProposals.length) {
|
||||
if (!query_democracy_publicProps || !query_democracy_publicProps.length) {
|
||||
return (
|
||||
<div className='ui disabled'>
|
||||
{t('proposals.none', {
|
||||
@ -42,10 +42,10 @@ class Proposals extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
return publicProposals.map((proposal) => (
|
||||
return query_democracy_publicProps.map((proposal) => (
|
||||
<Proposal
|
||||
idNumber={proposal.id}
|
||||
key={proposal.id.toString()}
|
||||
idNumber={proposal[0]}
|
||||
key={proposal[0].toString()}
|
||||
value={proposal}
|
||||
/>
|
||||
));
|
||||
@ -55,5 +55,5 @@ class Proposals extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
Proposals,
|
||||
translate,
|
||||
withObservable('publicProposals')
|
||||
withCall('query.democracy.publicProps')
|
||||
);
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RawParam } from '@polkadot/ui-app/Params/types';
|
||||
import { RxReferendumVote } from '@polkadot/api-observable/types';
|
||||
import { DerivedReferendumVote } from '@polkadot/ui-react-rx/derive/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import { ReferendumInfo } from '@polkadot/types';
|
||||
import { Chart, Static } from '@polkadot/ui-app/index';
|
||||
import VoteThreshold from '@polkadot/ui-app/Params/Param/VoteThreshold';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
import { balanceFormat, numberFormat } from '@polkadot/ui-react-rx/util/index';
|
||||
import settings from '@polkadot/ui-settings';
|
||||
|
||||
@ -27,8 +27,8 @@ const COLORS_NAY = settings.uiTheme === 'substrate'
|
||||
: ['#d75ea1', '#e189ba'];
|
||||
|
||||
type Props = I18nProps & {
|
||||
bestNumber?: BN,
|
||||
democracyReferendumVoters?: Array<RxReferendumVote>,
|
||||
derive_chain_bestNumber?: BN,
|
||||
derive_democracy_referendumVotesFor?: Array<DerivedReferendumVote>,
|
||||
idNumber: BN,
|
||||
value: ReferendumInfo
|
||||
};
|
||||
@ -58,13 +58,13 @@ class Referendum extends React.PureComponent<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps ({ democracyReferendumVoters }: Props, prevState: State): State | null {
|
||||
if (!democracyReferendumVoters) {
|
||||
static getDerivedStateFromProps ({ derive_democracy_referendumVotesFor }: Props, prevState: State): State | null {
|
||||
if (!derive_democracy_referendumVotesFor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const newState: State = democracyReferendumVoters.reduce((state, { balance, vote }) => {
|
||||
if (vote.valueOf() === true) {
|
||||
const newState: State = derive_democracy_referendumVotesFor.reduce((state, { balance, vote }) => {
|
||||
if (vote.ltn(0)) {
|
||||
state.voteCountYay++;
|
||||
state.votedYay = state.votedYay.add(balance);
|
||||
} else {
|
||||
@ -93,9 +93,9 @@ class Referendum extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { bestNumber, idNumber, value } = this.props;
|
||||
const { derive_chain_bestNumber, idNumber, value } = this.props;
|
||||
|
||||
if (!bestNumber || value.end.sub(bestNumber).lten(0)) {
|
||||
if (!derive_chain_bestNumber || value.end.sub(derive_chain_bestNumber).lten(0)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -112,9 +112,9 @@ class Referendum extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private renderExtra () {
|
||||
const { bestNumber, t, value: { end, threshold } } = this.props;
|
||||
const { derive_chain_bestNumber, t, value: { end, threshold } } = this.props;
|
||||
|
||||
if (!bestNumber) {
|
||||
if (!derive_chain_bestNumber) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ class Referendum extends React.PureComponent<Props, State> {
|
||||
defaultValue: '{{remaining}} blocks remaining, ending at block #{{blockNumber}}',
|
||||
replace: {
|
||||
blockNumber: numberFormat(end),
|
||||
remaining: numberFormat(end.sub(bestNumber).subn(1))
|
||||
remaining: numberFormat(end.sub(derive_chain_bestNumber).subn(1))
|
||||
}
|
||||
})}
|
||||
</Static>
|
||||
@ -177,6 +177,6 @@ class Referendum extends React.PureComponent<Props, State> {
|
||||
export default withMulti(
|
||||
Referendum,
|
||||
translate,
|
||||
withObservable('bestNumber'),
|
||||
withObservable('democracyReferendumVoters', { paramProp: 'idNumber' })
|
||||
withCall('derive.chain.bestNumber'),
|
||||
withCall('derive.democracy.referendumVotesFor', { paramProp: 'idNumber' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -7,15 +7,15 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import { ReferendumInfo } from '@polkadot/types';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import Referendum from './Referendum';
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
democracyNextTally?: BN,
|
||||
referendums?: Array<ReferendumInfo>,
|
||||
referendumCount?: BN
|
||||
query_democracy_nextTally?: BN,
|
||||
query_democracy_referendumCount?: BN,
|
||||
derive_democracy_referendums?: Array<ReferendumInfo>
|
||||
};
|
||||
|
||||
class Referendums extends React.PureComponent<Props> {
|
||||
@ -33,11 +33,10 @@ class Referendums extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
private renderReferendums () {
|
||||
const { democracyNextTally = new BN(0), referendums, referendumCount = new BN(0), t } = this.props;
|
||||
const { query_democracy_nextTally, derive_democracy_referendums, query_democracy_referendumCount, t } = this.props;
|
||||
const referendumCount = (query_democracy_referendumCount || new BN(0)).toNumber();
|
||||
|
||||
console.error('democracyNextTally', democracyNextTally.toString(), referendums, referendumCount.toString());
|
||||
|
||||
if (!referendums || !referendums.length || referendumCount.toNumber() === democracyNextTally.toNumber()) {
|
||||
if (!derive_democracy_referendums || !derive_democracy_referendums.length || (referendumCount === (query_democracy_nextTally || new BN(0)).toNumber())) {
|
||||
return (
|
||||
<div className='ui disabled'>
|
||||
{t('proposals.none', {
|
||||
@ -47,9 +46,11 @@ class Referendums extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
return referendums.map((referendum, index) => (
|
||||
const startIndex = referendumCount - derive_democracy_referendums.length;
|
||||
|
||||
return derive_democracy_referendums.map((referendum, index) => (
|
||||
<Referendum
|
||||
idNumber={index}
|
||||
idNumber={index + startIndex}
|
||||
key={index}
|
||||
value={referendum}
|
||||
/>
|
||||
@ -60,7 +61,7 @@ class Referendums extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
Referendums,
|
||||
translate,
|
||||
withObservable('referendums'),
|
||||
withObservable('referendumCount'),
|
||||
withObservable('democracyNextTally')
|
||||
withCall('query.democracy.nextTally'),
|
||||
withCall('query.democracy.referendumCount'),
|
||||
withCall('derive.democracy.referendums')
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -7,23 +7,23 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import { CardSummary } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
import { numberFormat } from '@polkadot/ui-react-rx/util/index';
|
||||
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
bestNumber?: BN,
|
||||
democracyLaunchPeriod?: BN,
|
||||
democracyNextTally?: BN,
|
||||
publicProposalCount?: BN,
|
||||
referendumCount?: BN,
|
||||
democracyVotingPeriod?: BN
|
||||
derive_chain_bestNumber?: BN,
|
||||
derive_democracy_publicPropCount?: BN,
|
||||
query_democracy_launchPeriod?: BN,
|
||||
query_democracy_nextTally?: BN,
|
||||
query_democracy_referendumCount?: BN,
|
||||
query_democracy_votingPeriod?: BN
|
||||
};
|
||||
|
||||
class Summary extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { bestNumber = new BN(0), democracyLaunchPeriod = new BN(1), democracyNextTally = new BN(0), publicProposalCount, referendumCount = new BN(0), democracyVotingPeriod = new BN(1), t } = this.props;
|
||||
const { derive_chain_bestNumber = new BN(0), query_democracy_launchPeriod, query_democracy_nextTally, derive_democracy_publicPropCount, query_democracy_referendumCount, query_democracy_votingPeriod, t } = this.props;
|
||||
|
||||
return (
|
||||
<summary>
|
||||
@ -33,21 +33,21 @@ class Summary extends React.PureComponent<Props> {
|
||||
defaultValue: 'proposals'
|
||||
})}
|
||||
>
|
||||
{numberFormat(publicProposalCount)}
|
||||
{numberFormat(derive_democracy_publicPropCount)}
|
||||
</CardSummary>
|
||||
<CardSummary
|
||||
label={t('summary.referendumCount', {
|
||||
defaultValue: 'referendums'
|
||||
})}
|
||||
>
|
||||
{numberFormat(referendumCount)}
|
||||
{numberFormat(query_democracy_referendumCount)}
|
||||
</CardSummary>
|
||||
<CardSummary
|
||||
label={t('summary.active', {
|
||||
defaultValue: 'active num'
|
||||
})}
|
||||
>
|
||||
{numberFormat(referendumCount.sub(democracyNextTally))}
|
||||
{numberFormat((query_democracy_referendumCount || new BN(0)).sub(query_democracy_nextTally || new BN(0)))}
|
||||
</CardSummary>
|
||||
</section>
|
||||
<section>
|
||||
@ -56,8 +56,8 @@ class Summary extends React.PureComponent<Props> {
|
||||
defaultValue: 'voting period'
|
||||
})}
|
||||
progress={{
|
||||
value: bestNumber.mod(democracyVotingPeriod).addn(1),
|
||||
total: democracyVotingPeriod
|
||||
value: derive_chain_bestNumber.mod(query_democracy_votingPeriod || new BN(1)).addn(1),
|
||||
total: query_democracy_votingPeriod || new BN(1)
|
||||
}}
|
||||
/>
|
||||
<CardSummary
|
||||
@ -65,8 +65,8 @@ class Summary extends React.PureComponent<Props> {
|
||||
defaultValue: 'launch period'
|
||||
})}
|
||||
progress={{
|
||||
value: bestNumber.mod(democracyLaunchPeriod).addn(1),
|
||||
total: democracyLaunchPeriod
|
||||
value: derive_chain_bestNumber.mod(query_democracy_launchPeriod || new BN(1)).addn(1),
|
||||
total: query_democracy_launchPeriod || new BN(1)
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
@ -78,10 +78,10 @@ class Summary extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
Summary,
|
||||
translate,
|
||||
withObservable('democracyLaunchPeriod'),
|
||||
withObservable('bestNumber'),
|
||||
withObservable('referendumCount'),
|
||||
withObservable('democracyNextTally'),
|
||||
withObservable('publicProposalCount'),
|
||||
withObservable('democracyVotingPeriod')
|
||||
withCall('query.democracy.launchPeriod'),
|
||||
withCall('query.democracy.nextTally'),
|
||||
withCall('query.democracy.publicPropCount'),
|
||||
withCall('query.democracy.referendumCount'),
|
||||
withCall('query.democracy.votingPeriod'),
|
||||
withCall('derive.chain.bestNumber')
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,24 +1,23 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { QueueTx$ExtrinsicAdd } from '@polkadot/ui-app/Status/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import Api from '@polkadot/api-observable';
|
||||
import { Extrinsic } from '@polkadot/types';
|
||||
import { Button } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
type Props = ApiProps & I18nProps & {
|
||||
accountId?: string,
|
||||
queueExtrinsic: QueueTx$ExtrinsicAdd,
|
||||
referendumId: BN,
|
||||
accountNonce?: BN
|
||||
query_system_accountNonce?: BN
|
||||
};
|
||||
|
||||
class VotingButton extends React.PureComponent<Props> {
|
||||
@ -49,17 +48,15 @@ class VotingButton extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
private doVote (vote: boolean) {
|
||||
const { accountId, queueExtrinsic, referendumId, accountNonce = new BN(0) } = this.props;
|
||||
const { accountId, apiPromise, queueExtrinsic, referendumId, query_system_accountNonce } = this.props;
|
||||
|
||||
if (!accountId) {
|
||||
return;
|
||||
}
|
||||
|
||||
queueExtrinsic({
|
||||
extrinsic: new Extrinsic({
|
||||
method: Api.extrinsics.democracy.vote(referendumId, vote)
|
||||
}),
|
||||
accountNonce,
|
||||
extrinsic: apiPromise.tx.democracy.vote(referendumId, vote ? -1 : 0),
|
||||
accountNonce: query_system_accountNonce,
|
||||
accountId
|
||||
});
|
||||
}
|
||||
@ -76,5 +73,5 @@ class VotingButton extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
VotingButton,
|
||||
translate,
|
||||
withObservable('accountNonce', { paramProp: 'accountId' })
|
||||
withCall('query.system.accountNonce', { paramProp: 'accountId' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-democracy authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-democracy authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-democracy authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/types": "^0.35.19",
|
||||
"@polkadot/types": "^0.37.6",
|
||||
"@polkadot/ui-app": "^0.21.17",
|
||||
"@polkadot/util-crypto": "^0.33.27"
|
||||
"@polkadot/util-crypto": "^0.33.30"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,35 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/ui-react-rx 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 } from '@polkadot/ui-react-rx//types';
|
||||
|
||||
import React from 'react';
|
||||
import { Header } from '@polkadot/types';
|
||||
import { withCall } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import { withObservableDiv } from '@polkadot/ui-react-rx/with/index';
|
||||
type Props = BareProps & {
|
||||
label?: string,
|
||||
rpc_chain_subscribeNewHead?: Header
|
||||
};
|
||||
|
||||
const Component: React.ComponentType<any> = withObservableDiv('subscribeNewHead')(
|
||||
(header?: Header): string | undefined =>
|
||||
header
|
||||
? header.hash.toHex()
|
||||
: undefined,
|
||||
{ className: 'explorer--BestHash' }
|
||||
);
|
||||
class BestHash extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, label = '', style, rpc_chain_subscribeNewHead } = this.props;
|
||||
|
||||
export default Component;
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
style={style}
|
||||
>
|
||||
{label}{
|
||||
rpc_chain_subscribeNewHead
|
||||
? rpc_chain_subscribeNewHead.hash.toHex()
|
||||
: undefined
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withCall('rpc.chain.subscribeNewHead', {})(BestHash);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -8,7 +8,7 @@ import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
import React from 'react';
|
||||
import { AddressMini, Call } from '@polkadot/ui-app/index';
|
||||
import { Extrinsic, Method, SignedBlock } from '@polkadot/types';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
import { numberFormat } from '@polkadot/ui-react-rx/util/index';
|
||||
|
||||
import BlockHeader from '../BlockHeader';
|
||||
@ -16,19 +16,19 @@ import translate from '../translate';
|
||||
import Logs from './Logs';
|
||||
|
||||
type Props = ApiProps & I18nProps & {
|
||||
getBlock: SignedBlock,
|
||||
rpc_chain_getBlock?: SignedBlock,
|
||||
value: string
|
||||
};
|
||||
|
||||
class BlockByHash extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { getBlock } = this.props;
|
||||
const { rpc_chain_getBlock } = this.props;
|
||||
|
||||
if (!getBlock || !getBlock.block) {
|
||||
if (!rpc_chain_getBlock || !rpc_chain_getBlock.block) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { block: { header } } = getBlock;
|
||||
const { block: { header } } = rpc_chain_getBlock;
|
||||
|
||||
return [
|
||||
<header key='header'>
|
||||
@ -47,8 +47,13 @@ class BlockByHash extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
private renderExtrinsics () {
|
||||
const { getBlock, t } = this.props;
|
||||
const { block: { extrinsics } } = getBlock;
|
||||
const { rpc_chain_getBlock, t } = this.props;
|
||||
|
||||
if (!rpc_chain_getBlock) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { block: { extrinsics } } = rpc_chain_getBlock;
|
||||
|
||||
return (
|
||||
<section key='extrinsics'>
|
||||
@ -145,5 +150,5 @@ class BlockByHash extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
BlockByHash,
|
||||
translate,
|
||||
withObservable('getBlock', { paramProp: 'value' })
|
||||
withCall('rpc.chain.getBlock', { paramProp: 'value' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -6,25 +6,24 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import jsonrpc from '@polkadot/jsonrpc';
|
||||
import { withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall } from '@polkadot/ui-react-rx/with/index';
|
||||
import { BlockNumber, Hash } from '@polkadot/types';
|
||||
|
||||
type Props = I18nProps & {
|
||||
blockNumber: BlockNumber,
|
||||
getBlockHash?: Hash,
|
||||
rpc_chain_getBlockHash?: Hash,
|
||||
withLink?: boolean
|
||||
};
|
||||
|
||||
class BlockHash extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { getBlockHash, withLink } = this.props;
|
||||
const { rpc_chain_getBlockHash, withLink } = this.props;
|
||||
|
||||
if (!getBlockHash) {
|
||||
if (!rpc_chain_getBlockHash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const hashHex = getBlockHash.toHex();
|
||||
const hashHex = rpc_chain_getBlockHash.toHex();
|
||||
|
||||
return (
|
||||
withLink
|
||||
@ -34,8 +33,6 @@ class BlockHash extends React.PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default withObservable('rawCall', {
|
||||
params: [jsonrpc.chain.methods.getBlockHash],
|
||||
paramProp: 'blockNumber',
|
||||
propName: 'getBlockHash'
|
||||
export default withCall('rpc.chain.getBlockHash', {
|
||||
paramProp: 'blockNumber'
|
||||
})(BlockHash);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
hash: Uint8Array,
|
||||
getBlock: any
|
||||
rpc_chain_getBlock: any
|
||||
};
|
||||
|
||||
class Extrinsics extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { getBlock, t } = this.props;
|
||||
const { rpc_chain_getBlock, t } = this.props;
|
||||
|
||||
if (!getBlock || !getBlock.extrinsics) {
|
||||
if (!rpc_chain_getBlock || !rpc_chain_getBlock.extrinsics) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ class Extrinsics extends React.PureComponent<Props> {
|
||||
{t('extrinsics.count', {
|
||||
defaultValue: '{{count}} in block',
|
||||
replace: {
|
||||
count: getBlock.extrinsics.length
|
||||
count: rpc_chain_getBlock.extrinsics.length
|
||||
}
|
||||
})}
|
||||
</td>
|
||||
@ -42,5 +42,5 @@ class Extrinsics extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
Extrinsics,
|
||||
translate,
|
||||
withObservable('getBlock', { paramProp: 'hash' })
|
||||
withCall('rpc.chain.getBlock', { paramProp: 'hash' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer 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 { Header } from '@polkadot/types';
|
||||
|
||||
import React from 'react';
|
||||
import { withObservableDiv } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import BlockHeader from './BlockHeader';
|
||||
|
||||
@ -13,37 +13,47 @@ export const MAX_ITEMS = 15;
|
||||
|
||||
let blockHeaders: Array<Header> = [];
|
||||
|
||||
const apiOptions = {
|
||||
transform: (header: Header): Array<Header> => {
|
||||
if (!header) {
|
||||
return blockHeaders;
|
||||
}
|
||||
|
||||
blockHeaders = blockHeaders
|
||||
.filter((old, index) =>
|
||||
index < MAX_ITEMS && old.blockNumber.lt(header.blockNumber)
|
||||
)
|
||||
.reduce((next, header) => {
|
||||
next.push(header);
|
||||
|
||||
return next;
|
||||
}, [header])
|
||||
.sort((a, b) =>
|
||||
b.blockNumber.cmp(a.blockNumber)
|
||||
);
|
||||
|
||||
const transform = (header: Header): Array<Header> => {
|
||||
if (!header) {
|
||||
return blockHeaders;
|
||||
}
|
||||
|
||||
blockHeaders = blockHeaders
|
||||
.filter((old, index) =>
|
||||
index < MAX_ITEMS && old.blockNumber.lt(header.blockNumber)
|
||||
)
|
||||
.reduce((next, header) => {
|
||||
next.push(header);
|
||||
|
||||
return next;
|
||||
}, [header])
|
||||
.sort((a, b) =>
|
||||
b.blockNumber.cmp(a.blockNumber)
|
||||
);
|
||||
|
||||
return blockHeaders;
|
||||
};
|
||||
|
||||
export default withObservableDiv('subscribeNewHead', apiOptions)(
|
||||
(value: Array<Header> = []) =>
|
||||
value.map((value) => (
|
||||
<BlockHeader
|
||||
key={value.blockNumber.toString()}
|
||||
value={value}
|
||||
withLink={!value.blockNumber.isZero()}
|
||||
/>
|
||||
)),
|
||||
{ className: 'explorer--BlockHeaders' }
|
||||
);
|
||||
type Props = {
|
||||
headers?: Array<Header>
|
||||
};
|
||||
|
||||
class BlockHeaders extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { headers = [] } = this.props;
|
||||
|
||||
return (
|
||||
<div className='explorer--BlockHeaders'>
|
||||
{headers.map((header) => (
|
||||
<BlockHeader
|
||||
key={header.blockNumber.toString()}
|
||||
value={header}
|
||||
withLink={!header.blockNumber.isZero()}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withCall('rpc.chain.subscribeNewHead', { propName: 'headers', transform })(BlockHeaders);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -11,7 +11,7 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import React from 'react';
|
||||
import { Event, EventRecord } from '@polkadot/types';
|
||||
import { Event as EventDisplay } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with';
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
import { xxhashAsHex } from '@polkadot/util-crypto';
|
||||
|
||||
@ -19,7 +19,7 @@ import { MAX_ITEMS } from './BlockHeaders';
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
systemEvents?: Array<EventRecord>
|
||||
query_system_events?: Array<EventRecord>
|
||||
};
|
||||
|
||||
type State = {
|
||||
@ -37,14 +37,14 @@ class EventsDisplay extends React.PureComponent<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps ({ systemEvents = [] }: Props, prevState: State): State | null {
|
||||
const prevEventHash = xxhashAsHex(stringToU8a(JSON.stringify(systemEvents)));
|
||||
static getDerivedStateFromProps ({ query_system_events = [] }: Props, prevState: State): State | null {
|
||||
const prevEventHash = xxhashAsHex(stringToU8a(JSON.stringify(query_system_events)));
|
||||
|
||||
if (prevEventHash === prevState.prevEventHash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const recentEvents = systemEvents
|
||||
const recentEvents = query_system_events
|
||||
.filter(({ event }) =>
|
||||
event.section !== 'system'
|
||||
)
|
||||
@ -108,5 +108,5 @@ class EventsDisplay extends React.PureComponent<Props, State> {
|
||||
export default withMulti(
|
||||
EventsDisplay,
|
||||
translate,
|
||||
withObservable('systemEvents')
|
||||
withCall('query.system.events')
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,24 +1,25 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import { BlockNumber } from '@polkadot/types';
|
||||
import { CardSummary } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
eraBlockLength?: BlockNumber,
|
||||
eraBlockProgress?: BlockNumber,
|
||||
sessionBlockProgress?: BlockNumber,
|
||||
derive_session_eraLength?: BN,
|
||||
derive_session_eraProgress?: BN,
|
||||
derive_session_sessionProgress?: BN,
|
||||
// FIXME Replaced in poc-3
|
||||
// sessionBrokenValue?: BN,
|
||||
// sessionBrokenPercentLate?: BN,
|
||||
sessionLength?: BlockNumber,
|
||||
query_session_sessionLength?: BlockNumber,
|
||||
withBroken?: boolean,
|
||||
withEra?: boolean,
|
||||
withSession?: boolean
|
||||
@ -58,7 +59,7 @@ class SummarySession extends React.PureComponent<Props> {
|
||||
// }
|
||||
|
||||
private renderEra () {
|
||||
const { eraBlockLength, eraBlockProgress, t, withEra = true } = this.props;
|
||||
const { derive_session_eraLength, derive_session_eraProgress, t, withEra = true } = this.props;
|
||||
|
||||
if (!withEra) {
|
||||
return null;
|
||||
@ -71,15 +72,15 @@ class SummarySession extends React.PureComponent<Props> {
|
||||
defaultValue: 'era'
|
||||
})}
|
||||
progress={{
|
||||
total: eraBlockLength,
|
||||
value: eraBlockProgress
|
||||
total: derive_session_eraLength,
|
||||
value: derive_session_eraProgress
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
private renderSession () {
|
||||
const { sessionBlockProgress, sessionLength, t, withSession = true } = this.props;
|
||||
const { derive_session_sessionProgress, query_session_sessionLength, t, withSession = true } = this.props;
|
||||
|
||||
if (!withSession) {
|
||||
return null;
|
||||
@ -92,8 +93,8 @@ class SummarySession extends React.PureComponent<Props> {
|
||||
defaultValue: 'session'
|
||||
})}
|
||||
progress={{
|
||||
total: sessionLength,
|
||||
value: sessionBlockProgress
|
||||
total: query_session_sessionLength || new BN(0),
|
||||
value: derive_session_sessionProgress
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@ -103,8 +104,8 @@ class SummarySession extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
SummarySession,
|
||||
translate,
|
||||
withObservable('eraBlockLength'),
|
||||
withObservable('eraBlockProgress'),
|
||||
withObservable('sessionBlockProgress'),
|
||||
withObservable('sessionLength')
|
||||
withCall('derive.session.eraLength'),
|
||||
withCall('derive.session.eraProgress'),
|
||||
withCall('derive.session.sessionProgress'),
|
||||
withCall('query.session.sessionLength')
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-explorer authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-explorer authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/types": "^0.35.19",
|
||||
"@polkadot/types": "^0.37.6",
|
||||
"@polkadot/ui-app": "^0.21.17",
|
||||
"@polkadot/ui-signer": "^0.21.17"
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,26 +1,35 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics 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 { Props } from '@polkadot/ui-app/Params/types';
|
||||
import { Props as BaseProps } from '@polkadot/ui-app/Params/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import React from 'react';
|
||||
import Api from '@polkadot/api-observable';
|
||||
import { withApi } from '@polkadot/ui-react-rx/with';
|
||||
|
||||
import Extrinsic from './Extrinsic';
|
||||
|
||||
export default function Call ({ className, isDisabled, isError, label, onChange, style, withLabel }: Props) {
|
||||
return (
|
||||
<Extrinsic
|
||||
className={className}
|
||||
defaultValue={Api.extrinsics.balances.transfer}
|
||||
isDisabled={isDisabled}
|
||||
isError={isError}
|
||||
isPrivate={false}
|
||||
label={label}
|
||||
onChange={onChange}
|
||||
style={style}
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
);
|
||||
type Props = ApiProps & BaseProps;
|
||||
|
||||
class Call extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { apiPromise, className, isDisabled, isError, label, onChange, style, withLabel } = this.props;
|
||||
|
||||
return (
|
||||
<Extrinsic
|
||||
className={className}
|
||||
defaultValue={apiPromise.tx.balances.transfer}
|
||||
isDisabled={isDisabled}
|
||||
isError={isError}
|
||||
isPrivate={false}
|
||||
label={label}
|
||||
onChange={onChange}
|
||||
style={style}
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withApi(Call);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,23 +1,26 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics 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 { Props, RawParam } from '@polkadot/ui-app/Params/types';
|
||||
import { Props as BaseProps, RawParam } from '@polkadot/ui-app/Params/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import React from 'react';
|
||||
import Api from '@polkadot/api-observable';
|
||||
import { Proposal } from '@polkadot/types';
|
||||
import { withApi } from '@polkadot/ui-react-rx/with';
|
||||
|
||||
import ExtrinsicDisplay from './Extrinsic';
|
||||
|
||||
export default class ProposalDisplay extends React.PureComponent<Props> {
|
||||
type Props = ApiProps & BaseProps;
|
||||
|
||||
class ProposalDisplay extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, isDisabled, isError, label, style, withLabel } = this.props;
|
||||
const { apiPromise, className, isDisabled, isError, label, style, withLabel } = this.props;
|
||||
|
||||
return (
|
||||
<ExtrinsicDisplay
|
||||
className={className}
|
||||
defaultValue={Api.extrinsics.consensus.setCode}
|
||||
defaultValue={apiPromise.tx.consensus.setCode}
|
||||
isDisabled={isDisabled}
|
||||
isError={isError}
|
||||
isPrivate
|
||||
@ -43,3 +46,5 @@ export default class ProposalDisplay extends React.PureComponent<Props> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default withApi(ProposalDisplay);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,22 +1,24 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics 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 BN from 'bn.js';
|
||||
import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { QueueTx$ExtrinsicAdd, QueueTx$Unclog } from '@polkadot/ui-app/Status/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import React from 'react';
|
||||
import Api from '@polkadot/api-observable';
|
||||
import { Extrinsic, Method } from '@polkadot/types';
|
||||
import SubmittableExtrinsic from '@polkadot/api/promise/SubmittableExtrinsic';
|
||||
import { Method } from '@polkadot/types';
|
||||
import { Button } from '@polkadot/ui-app/index';
|
||||
import { withApi, withMulti } from '@polkadot/ui-react-rx/with';
|
||||
|
||||
import Account from './Account';
|
||||
import ExtrinsicDisplay from './Extrinsic';
|
||||
import Nonce from './Nonce';
|
||||
import translate from './translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
type Props = ApiProps & I18nProps & {
|
||||
queueExtrinsic: QueueTx$ExtrinsicAdd,
|
||||
queueUnclog: QueueTx$Unclog
|
||||
};
|
||||
@ -34,7 +36,7 @@ class Selection extends React.PureComponent<Props, State> {
|
||||
} as State;
|
||||
|
||||
render () {
|
||||
const { t } = this.props;
|
||||
const { apiPromise, t } = this.props;
|
||||
const { isValid, accountId } = this.state;
|
||||
|
||||
return (
|
||||
@ -48,7 +50,7 @@ class Selection extends React.PureComponent<Props, State> {
|
||||
type='account'
|
||||
/>
|
||||
<ExtrinsicDisplay
|
||||
defaultValue={Api.extrinsics.balances.transfer}
|
||||
defaultValue={apiPromise.tx.balances.transfer}
|
||||
labelMethod={t('display.method', {
|
||||
defaultValue: 'submit the following extrinsic'
|
||||
})}
|
||||
@ -120,7 +122,7 @@ class Selection extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private onQueue (isUnsigned: boolean): void {
|
||||
const { queueExtrinsic } = this.props;
|
||||
const { apiPromise, queueExtrinsic } = this.props;
|
||||
const { accountNonce, method, isValid, accountId } = this.state;
|
||||
|
||||
if (!isValid || !method) {
|
||||
@ -130,7 +132,7 @@ class Selection extends React.PureComponent<Props, State> {
|
||||
queueExtrinsic({
|
||||
accountId,
|
||||
accountNonce,
|
||||
extrinsic: new Extrinsic({ method }),
|
||||
extrinsic: new SubmittableExtrinsic(apiPromise, method),
|
||||
isUnsigned
|
||||
});
|
||||
}
|
||||
@ -144,4 +146,8 @@ class Selection extends React.PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate(Selection);
|
||||
export default withMulti(
|
||||
Selection,
|
||||
translate,
|
||||
withApi
|
||||
);
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -11,7 +11,7 @@ import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { QueueConsumer } from '@polkadot/ui-app/Status/Context';
|
||||
import accountsObservable from '@polkadot/ui-keyring/observable/accounts';
|
||||
import { withMulti, withObservableBase } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import translate from './translate';
|
||||
|
||||
import Selection from './Selection';
|
||||
@ -57,5 +57,5 @@ export { ExtrinsicsApp };
|
||||
export default withMulti(
|
||||
ExtrinsicsApp,
|
||||
translate,
|
||||
withObservableBase(accountsObservable.subject, { propName: 'accountAll' })
|
||||
withObservable(accountsObservable.subject, { propName: 'accountAll' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-extrinsics authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-extrinsics authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/ui-app": "^0.21.17",
|
||||
"@polkadot/ui-keyring": "^0.24.18",
|
||||
"@polkadot/ui-keyring": "^0.24.25",
|
||||
"@polkadot/ui-signer": "^0.21.17"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-rpc authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-rpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-rpc authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-rpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-rpc authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-rpc authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-rpc authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-rpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-rpc authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-rpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -13,6 +13,6 @@
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/ui-app": "^0.21.17",
|
||||
"@polkadot/ui-react-rx": "^0.21.17",
|
||||
"@polkadot/ui-settings": "^0.24.18"
|
||||
"@polkadot/ui-settings": "^0.24.25"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-settings authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-settings authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-settings authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-settings authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-settings authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-settings authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/app-explorer": "^0.21.17",
|
||||
"@polkadot/keyring": "^0.33.27",
|
||||
"@polkadot/storage": "^0.35.19",
|
||||
"@polkadot/keyring": "^0.33.30",
|
||||
"@polkadot/storage": "^0.37.6",
|
||||
"@polkadot/ui-app": "^0.21.17",
|
||||
"@polkadot/ui-keyring": "^0.24.18",
|
||||
"@polkadot/ui-keyring": "^0.24.25",
|
||||
"@polkadot/ui-react-rx": "^0.21.17"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RxBalanceMap } from '@polkadot/api-observable/types';
|
||||
import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types';
|
||||
|
||||
import React from 'react';
|
||||
import { AccountId, Balance } from '@polkadot/types';
|
||||
@ -13,7 +13,7 @@ import keyring from '@polkadot/ui-keyring';
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
balances: RxBalanceMap,
|
||||
balances: DerivedBalancesMap,
|
||||
balanceArray: (_address: AccountId | string) => Array<Balance> | undefined,
|
||||
current: Array<string>,
|
||||
next: Array<string>
|
||||
@ -97,10 +97,10 @@ class CurrentList extends React.PureComponent<Props> {
|
||||
withCopy={false}
|
||||
withNonce={false}
|
||||
>
|
||||
{nominators.map(({ address }) =>
|
||||
{nominators.map(({ accountId }) =>
|
||||
<AddressMini
|
||||
key={address.toString()}
|
||||
value={address}
|
||||
key={accountId.toString()}
|
||||
value={accountId}
|
||||
withBalance
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RxBalance, RxBalanceMap } from '@polkadot/api-observable/types';
|
||||
import { DerivedBalances, DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import { CardSummary } from '@polkadot/ui-app/index';
|
||||
import SummarySession from '@polkadot/app-explorer/SummarySession';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
import { balanceFormat } from '@polkadot/ui-react-rx/util/index';
|
||||
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
balances: RxBalanceMap,
|
||||
balances: DerivedBalancesMap,
|
||||
intentions: Array<string>,
|
||||
lastLengthChange?: BN,
|
||||
validatorCount?: BN,
|
||||
query_staking_validatorCount?: BN,
|
||||
validators: Array<string>
|
||||
};
|
||||
|
||||
class Summary extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, intentions, style, t, validatorCount, validators } = this.props;
|
||||
const { className, intentions, style, t, query_staking_validatorCount, validators } = this.props;
|
||||
|
||||
return (
|
||||
<summary
|
||||
@ -37,7 +37,7 @@ class Summary extends React.PureComponent<Props> {
|
||||
defaultValue: 'validators'
|
||||
})}
|
||||
>
|
||||
{validators.length}/{validatorCount ? validatorCount.toString() : '-'}
|
||||
{validators.length}/{query_staking_validatorCount ? query_staking_validatorCount.toString() : '-'}
|
||||
</CardSummary>
|
||||
<CardSummary
|
||||
label={t('summary.intentions', {
|
||||
@ -96,10 +96,10 @@ class Summary extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
private calcIntentionsHigh (): RxBalance | null {
|
||||
private calcIntentionsHigh (): DerivedBalances | null {
|
||||
const { balances, intentions, validators } = this.props;
|
||||
|
||||
return intentions.reduce((high: RxBalance | null, addr) => {
|
||||
return intentions.reduce((high: DerivedBalances | null, addr) => {
|
||||
const balance = validators.includes(addr) || !balances[addr]
|
||||
? null
|
||||
: balances[addr];
|
||||
@ -112,10 +112,10 @@ class Summary extends React.PureComponent<Props> {
|
||||
}, null);
|
||||
}
|
||||
|
||||
private calcValidatorLow (): RxBalance | null {
|
||||
private calcValidatorLow (): DerivedBalances | null {
|
||||
const { balances, validators } = this.props;
|
||||
|
||||
return validators.reduce((low: RxBalance | null, addr) => {
|
||||
return validators.reduce((low: DerivedBalances | null, addr) => {
|
||||
const balance = balances[addr] || null;
|
||||
|
||||
if (low === null || (balance && low.stakingBalance.gt(balance.stakingBalance))) {
|
||||
@ -130,5 +130,5 @@ class Summary extends React.PureComponent<Props> {
|
||||
export default withMulti(
|
||||
Summary,
|
||||
translate,
|
||||
withObservable('validatorCount')
|
||||
withCall('query.staking.validatorCount')
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
/* 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. */
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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 { RxBalanceMap } from '@polkadot/api-observable/types';
|
||||
import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types';
|
||||
import { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import './index.css';
|
||||
@ -14,7 +14,7 @@ import CurrentList from './CurrentList';
|
||||
import Summary from './Summary';
|
||||
|
||||
type Props = I18nProps & {
|
||||
balances: RxBalanceMap,
|
||||
balances: DerivedBalancesMap,
|
||||
balanceArray: (_address: AccountId | string) => Array<Balance> | undefined,
|
||||
intentions: Array<string>,
|
||||
validators: Array<string>
|
||||
|
||||
@ -1,30 +1,31 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { QueueTx$ExtrinsicAdd } from '@polkadot/ui-app/Status/types';
|
||||
import { RxBalanceMap } from '@polkadot/api-observable/types';
|
||||
import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import Api from '@polkadot/api-observable';
|
||||
import { AccountId, Balance, Extrinsic, Method } from '@polkadot/types';
|
||||
import SubmittableExtrinsic from '@polkadot/api/promise/SubmittableExtrinsic';
|
||||
import { AccountId, Balance } from '@polkadot/types';
|
||||
import { AddressMini, AddressSummary, Button } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import Nominating from './Nominating';
|
||||
import UnnominateButton from './UnnominateButton';
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
accountNonce?: BN,
|
||||
type Props = ApiProps & I18nProps & {
|
||||
query_system_accountNonce?: BN,
|
||||
accountId: string,
|
||||
balances: RxBalanceMap,
|
||||
balances: DerivedBalancesMap,
|
||||
balanceArray: (_address: AccountId | string) => Array<Balance> | undefined,
|
||||
name: string,
|
||||
stakingNominating?: AccountId,
|
||||
stakingNominatorsFor?: Array<string>,
|
||||
query_staking_nominating?: AccountId,
|
||||
query_staking_nominatorsFor?: Array<string>,
|
||||
intentions: Array<string>,
|
||||
isValidator: boolean,
|
||||
queueExtrinsic: QueueTx$ExtrinsicAdd,
|
||||
@ -73,31 +74,31 @@ class Account extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private renderNominee () {
|
||||
const { stakingNominating, balanceArray } = this.props;
|
||||
const { query_staking_nominating, balanceArray } = this.props;
|
||||
|
||||
if (!stakingNominating) {
|
||||
if (!query_staking_nominating) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AddressMini
|
||||
balance={balanceArray(stakingNominating)}
|
||||
value={stakingNominating}
|
||||
balance={balanceArray(query_staking_nominating)}
|
||||
value={query_staking_nominating}
|
||||
withBalance
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
private renderNominators () {
|
||||
const { stakingNominatorsFor } = this.props;
|
||||
const { query_staking_nominatorsFor } = this.props;
|
||||
|
||||
if (!stakingNominatorsFor) {
|
||||
if (!query_staking_nominatorsFor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='ui--Nominators'>
|
||||
{stakingNominatorsFor.map((nominator) => (
|
||||
{query_staking_nominatorsFor.map((nominator) => (
|
||||
<AddressMini
|
||||
isPadded={false}
|
||||
key={nominator}
|
||||
@ -110,9 +111,9 @@ class Account extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private renderButtons () {
|
||||
const { accountId, intentions, stakingNominating, t } = this.props;
|
||||
const { accountId, intentions, query_staking_nominating, t } = this.props;
|
||||
const isIntending = intentions.includes(accountId);
|
||||
const isNominating = !!stakingNominating;
|
||||
const isNominating = !!query_staking_nominating;
|
||||
const canStake = !isIntending && !isNominating;
|
||||
|
||||
if (canStake) {
|
||||
@ -142,7 +143,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
<Button.Group>
|
||||
<UnnominateButton
|
||||
accountId={accountId || ''}
|
||||
nominating={stakingNominating || ''}
|
||||
nominating={query_staking_nominating || ''}
|
||||
onClick={this.unnominate}
|
||||
/>
|
||||
</Button.Group>
|
||||
@ -162,12 +163,12 @@ class Account extends React.PureComponent<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
private send (method: Method) {
|
||||
const { accountNonce, accountId, queueExtrinsic } = this.props;
|
||||
private send (extrinsic: SubmittableExtrinsic) {
|
||||
const { query_system_accountNonce, accountId, queueExtrinsic } = this.props;
|
||||
|
||||
queueExtrinsic({
|
||||
extrinsic: new Extrinsic({ method }),
|
||||
accountNonce: accountNonce || new BN(0),
|
||||
extrinsic,
|
||||
accountNonce: query_system_accountNonce,
|
||||
accountId
|
||||
});
|
||||
}
|
||||
@ -181,30 +182,38 @@ class Account extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private nominate = (nominee: string) => {
|
||||
this.send(Api.extrinsics.staking.nominate(nominee));
|
||||
const { apiPromise } = this.props;
|
||||
|
||||
this.send(apiPromise.tx.staking.nominate(nominee));
|
||||
|
||||
this.toggleNominate();
|
||||
}
|
||||
|
||||
private unnominate = (index: number) => {
|
||||
this.send(Api.extrinsics.staking.unnominate(index));
|
||||
const { apiPromise } = this.props;
|
||||
|
||||
this.send(apiPromise.tx.staking.unnominate(index));
|
||||
}
|
||||
|
||||
private stake = () => {
|
||||
this.send(Api.extrinsics.staking.stake());
|
||||
const { apiPromise } = this.props;
|
||||
|
||||
this.send(apiPromise.tx.staking.stake());
|
||||
}
|
||||
|
||||
private unstake = () => {
|
||||
const { apiPromise } = this.props;
|
||||
|
||||
const { accountId, intentions } = this.props;
|
||||
|
||||
this.send(Api.extrinsics.staking.unstake(intentions.indexOf(accountId)));
|
||||
this.send(apiPromise.tx.staking.unstake(intentions.indexOf(accountId)));
|
||||
}
|
||||
}
|
||||
|
||||
export default withMulti(
|
||||
Account,
|
||||
translate,
|
||||
withObservable('stakingNominatorsFor', { paramProp: 'accountId' }),
|
||||
withObservable('stakingNominating', { paramProp: 'accountId' }),
|
||||
withObservable('accountNonce', { paramProp: 'accountId' })
|
||||
withCall('query.staking.nominatorsFor', { paramProp: 'accountId' }),
|
||||
withCall('query.staking.nominating', { paramProp: 'accountId' }),
|
||||
withCall('query.system.accountNonce', { paramProp: 'accountId' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/ui-staking authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/ui-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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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.
|
||||
|
||||
@ -6,22 +6,22 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
import { Button } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
accountId: string,
|
||||
nominating: string,
|
||||
stakingNominatorsFor: Array<string>,
|
||||
query_staking_nominatorsFor: Array<string>,
|
||||
onClick: (index: number) => void
|
||||
};
|
||||
|
||||
class UnnominateButton extends React.Component<Props> {
|
||||
render () {
|
||||
const { nominating, stakingNominatorsFor, style, t } = this.props;
|
||||
const { nominating, query_staking_nominatorsFor, style, t } = this.props;
|
||||
|
||||
if (!nominating || !stakingNominatorsFor) {
|
||||
if (!nominating || !query_staking_nominatorsFor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -39,10 +39,10 @@ class UnnominateButton extends React.Component<Props> {
|
||||
}
|
||||
|
||||
onClick = () => {
|
||||
const { accountId, stakingNominatorsFor, onClick } = this.props;
|
||||
const { accountId, query_staking_nominatorsFor, onClick } = this.props;
|
||||
|
||||
onClick(
|
||||
stakingNominatorsFor
|
||||
query_staking_nominatorsFor
|
||||
.map((accountId) =>
|
||||
accountId.toString()
|
||||
)
|
||||
@ -53,5 +53,5 @@ class UnnominateButton extends React.Component<Props> {
|
||||
export default withMulti(
|
||||
UnnominateButton,
|
||||
translate,
|
||||
withObservable('stakingNominatorsFor', { paramProp: 'nominating' })
|
||||
withCall('query.staking.nominatorsFor', { paramProp: 'nominating' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
/* 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. */
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { QueueProps } from '@polkadot/ui-app/Status/types';
|
||||
import { RxBalanceMap } from '@polkadot/api-observable/types';
|
||||
import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types';
|
||||
import { AccountId, Balance } from '@polkadot/types';
|
||||
|
||||
import React from 'react';
|
||||
@ -15,7 +15,7 @@ import Account from './Account';
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
balances: RxBalanceMap,
|
||||
balances: DerivedBalancesMap,
|
||||
balanceArray: (_address: AccountId | string) => Array<Balance> | undefined,
|
||||
intentions: Array<string>,
|
||||
validators: Array<string>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
/* 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. */
|
||||
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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 { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { ActionStatus } from '@polkadot/ui-app/Status/types';
|
||||
import { RxBalanceMap } from '@polkadot/api-observable/types';
|
||||
import { DerivedBalancesMap } from '@polkadot/ui-react-rx/derive/types';
|
||||
|
||||
import React from 'react';
|
||||
import { AccountId, Balance } from '@polkadot/types';
|
||||
import { Tabs } from '@polkadot/ui-app/index';
|
||||
import { withMulti, withObservable } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCall, withMulti } from '@polkadot/ui-react-rx/with/index';
|
||||
|
||||
import './index.css';
|
||||
|
||||
@ -22,9 +22,9 @@ type Actions = 'actions' | 'overview';
|
||||
type Props = I18nProps & {
|
||||
basePath: string,
|
||||
onStatusChange: (status: ActionStatus) => void,
|
||||
stakingIntentions?: Array<AccountId>,
|
||||
sessionValidators?: Array<AccountId>,
|
||||
validatingBalances?: RxBalanceMap
|
||||
query_staking_intentions?: Array<AccountId>,
|
||||
query_session_validators?: Array<AccountId>,
|
||||
derive_balances_validatingBalances?: DerivedBalancesMap
|
||||
};
|
||||
|
||||
type State = {
|
||||
@ -51,12 +51,12 @@ class App extends React.PureComponent<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps ({ sessionValidators = [], stakingIntentions = [] }: Props): State {
|
||||
static getDerivedStateFromProps ({ query_session_validators, query_staking_intentions }: Props): State {
|
||||
return {
|
||||
intentions: stakingIntentions.map((accountId) =>
|
||||
intentions: (query_staking_intentions || []).map((accountId) =>
|
||||
accountId.toString()
|
||||
),
|
||||
validators: sessionValidators.map((authorityId) =>
|
||||
validators: (query_session_validators || []).map((authorityId) =>
|
||||
authorityId.toString()
|
||||
)
|
||||
} as State;
|
||||
@ -64,7 +64,7 @@ class App extends React.PureComponent<Props, State> {
|
||||
|
||||
render () {
|
||||
const { action, intentions, validators } = this.state;
|
||||
const { t, validatingBalances = {} } = this.props;
|
||||
const { t, derive_balances_validatingBalances = {} } = this.props;
|
||||
const Component = Components[action];
|
||||
const items = [
|
||||
{
|
||||
@ -87,7 +87,7 @@ class App extends React.PureComponent<Props, State> {
|
||||
/>
|
||||
</header>
|
||||
<Component
|
||||
balances={validatingBalances}
|
||||
balances={derive_balances_validatingBalances}
|
||||
balanceArray={this.balanceArray}
|
||||
intentions={intentions}
|
||||
validators={validators}
|
||||
@ -101,7 +101,7 @@ class App extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private balanceArray = (_address: AccountId | string): Array<Balance> | undefined => {
|
||||
const { validatingBalances = {} } = this.props;
|
||||
const { derive_balances_validatingBalances = {} } = this.props;
|
||||
|
||||
if (!_address) {
|
||||
return undefined;
|
||||
@ -109,8 +109,11 @@ class App extends React.PureComponent<Props, State> {
|
||||
|
||||
const address = _address.toString();
|
||||
|
||||
return validatingBalances[address]
|
||||
? [validatingBalances[address].stakingBalance, validatingBalances[address].nominatedBalance]
|
||||
return derive_balances_validatingBalances[address]
|
||||
? [
|
||||
derive_balances_validatingBalances[address].stakingBalance,
|
||||
derive_balances_validatingBalances[address].nominatedBalance
|
||||
]
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
@ -118,7 +121,7 @@ class App extends React.PureComponent<Props, State> {
|
||||
export default withMulti(
|
||||
App,
|
||||
translate,
|
||||
withObservable('stakingIntentions'),
|
||||
withObservable('sessionValidators'),
|
||||
withObservable('validatingBalances', { paramProp: 'stakingIntentions' })
|
||||
withCall('query.staking.intentions'),
|
||||
withCall('query.session.validators'),
|
||||
withCall('derive.balances.validatingBalances', { paramProp: 'stakingIntentions' })
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-staking authors & contributors
|
||||
// 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.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -10,7 +10,7 @@ import React from 'react';
|
||||
import { Compact } from '@polkadot/types/codec';
|
||||
import { Button, Labelled } from '@polkadot/ui-app/index';
|
||||
import valueToText from '@polkadot/ui-app/Params/valueToText';
|
||||
import { withObservableDiv } from '@polkadot/ui-react-rx/with/index';
|
||||
import { withCallDiv } from '@polkadot/ui-react-rx/with/index';
|
||||
import { isU8a, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
|
||||
import translate from './translate';
|
||||
@ -51,31 +51,28 @@ class Query extends React.PureComponent<Props, State> {
|
||||
const defaultProps = { className: 'ui--output' };
|
||||
|
||||
// render function to create an element for the query results which is plugged to the api
|
||||
const fetchAndRenderHelper = withObservableDiv('rawStorage', { params: [key, ...values] });
|
||||
const pluggedComponent = fetchAndRenderHelper(
|
||||
const renderHelper = withCallDiv('subscribe', { params: [key, ...values] });
|
||||
const Component = renderHelper(
|
||||
// By default we render a simple div node component with the query results in it
|
||||
(value: any) => valueToText(type, value, true, true),
|
||||
defaultProps
|
||||
);
|
||||
cache[query.id] = Query.createComponentCacheInstance(type, pluggedComponent, defaultProps, fetchAndRenderHelper);
|
||||
cache[query.id] = Query.createComponent(type, Component, defaultProps, renderHelper);
|
||||
}
|
||||
|
||||
return cache[id];
|
||||
}
|
||||
|
||||
static createComponentCacheInstance (type: string, pluggedComponent: React.ComponentType<any>, defaultProps: DefaultProps<any>, fetchAndRenderHelper: ComponentRenderer<any>) {
|
||||
static createComponent (type: string, Component: React.ComponentType<any>, defaultProps: DefaultProps<any>, renderHelper: ComponentRenderer<any>) {
|
||||
return {
|
||||
Component: pluggedComponent,
|
||||
Component,
|
||||
// In order to replace the default component during runtime we can provide a RenderFn to create a new 'plugged' component
|
||||
render: (createComponent: RenderFn) => {
|
||||
return fetchAndRenderHelper(
|
||||
createComponent,
|
||||
defaultProps
|
||||
);
|
||||
return renderHelper(createComponent, defaultProps);
|
||||
},
|
||||
// In order to modify the parameters which are used to render the default component, we can use this method
|
||||
refresh: (swallowErrors: boolean, contentShorten: boolean) => {
|
||||
return fetchAndRenderHelper(
|
||||
return renderHelper(
|
||||
(value: any) => valueToText(type, value, swallowErrors, contentShorten),
|
||||
defaultProps
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@ -6,16 +6,17 @@ import { TypeDef, getTypeDef } from '@polkadot/types/codec';
|
||||
import { StorageFunction } from '@polkadot/types/StorageKey';
|
||||
import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { RawParams } from '@polkadot/ui-app/Params/types';
|
||||
import { ApiProps } from '@polkadot/ui-react-rx/types';
|
||||
import { PartialModuleQuery } from '../types';
|
||||
|
||||
import React from 'react';
|
||||
import Api from '@polkadot/api-observable';
|
||||
import { Button, InputStorage, Labelled, Params } from '@polkadot/ui-app/index';
|
||||
import { withApi, withMulti } from '@polkadot/ui-react-rx/with';
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
import translate from '../translate';
|
||||
|
||||
type Props = I18nProps & {
|
||||
type Props = ApiProps & I18nProps & {
|
||||
onAdd: (query: PartialModuleQuery) => void
|
||||
};
|
||||
|
||||
@ -33,7 +34,9 @@ class Modules extends React.PureComponent<Props, State> {
|
||||
constructor (props: Props) {
|
||||
super(props);
|
||||
|
||||
this.defaultValue = Api.storage.timestamp.now;
|
||||
const { apiPromise } = this.props;
|
||||
|
||||
this.defaultValue = apiPromise.query.timestamp.now;
|
||||
this.state = {
|
||||
isValid: true,
|
||||
key: this.defaultValue,
|
||||
@ -124,4 +127,8 @@ class Modules extends React.PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate(Modules);
|
||||
export default withMulti(
|
||||
Modules,
|
||||
translate,
|
||||
withApi
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-storage authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-storage authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -12,6 +12,6 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/ui-app": "^0.21.17",
|
||||
"@polkadot/ui-keyring": "^0.24.18"
|
||||
"@polkadot/ui-keyring": "^0.24.25"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
/* Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
/* This software may be modified and distributed under the terms
|
||||
/* of the Apache-2.0 license. See the LICENSE file for details. */
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2018 @polkadot/app-toolbox authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/app-toolbox authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user