From e6d46f9922586fed5943d4b80225dbd3981853bf Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 12 Apr 2019 18:05:14 +0200 Subject: [PATCH] Fix staking buttons to immediately show (#998) * Fix staking buttons to immediately show * Move back to params as a name, cleanup danglings --- packages/app-123code/src/AccountSelector.tsx | 6 +- packages/app-explorer/src/BlockHeaders.tsx | 5 +- packages/app-extrinsics/src/Balance.tsx | 2 +- packages/app-staking/src/Account/Bond.tsx | 5 +- .../app-staking/src/Account/Nominating.tsx | 3 +- .../app-staking/src/Account/Validating.tsx | 6 +- packages/app-staking/src/Account/index.tsx | 123 ++++++++---------- packages/app-staking/src/Accounts.tsx | 6 +- packages/app-staking/src/Overview/Address.tsx | 3 +- .../app-staking/src/Overview/CurrentList.tsx | 5 +- packages/app-staking/src/Overview/index.tsx | 3 +- packages/app-staking/src/index.tsx | 20 +-- packages/app-staking/src/types.ts | 3 +- packages/app-storage/src/Query.tsx | 6 +- packages/ui-api/src/types.ts | 7 +- packages/ui-api/src/with/call.tsx | 24 +++- packages/ui-api/src/with/types.ts | 1 + packages/ui-app/src/AddressMini.tsx | 4 +- packages/ui-app/src/AddressSummary.tsx | 4 +- packages/ui-app/src/Balance.tsx | 8 +- packages/ui-app/src/Bonded.tsx | 9 +- packages/ui-reactive/src/AccountIndex.tsx | 2 +- packages/ui-reactive/src/Balance.tsx | 2 +- packages/ui-reactive/src/Bonded.tsx | 10 +- packages/ui-reactive/src/Nonce.tsx | 2 +- 25 files changed, 122 insertions(+), 147 deletions(-) diff --git a/packages/app-123code/src/AccountSelector.tsx b/packages/app-123code/src/AccountSelector.tsx index 63aaf2087c..9960280b3b 100644 --- a/packages/app-123code/src/AccountSelector.tsx +++ b/packages/app-123code/src/AccountSelector.tsx @@ -30,13 +30,13 @@ export default class AccountSelector extends React.PureComponent { />
- + - + - +
diff --git a/packages/app-explorer/src/BlockHeaders.tsx b/packages/app-explorer/src/BlockHeaders.tsx index a648a7573b..6301119135 100644 --- a/packages/app-explorer/src/BlockHeaders.tsx +++ b/packages/app-explorer/src/BlockHeaders.tsx @@ -58,4 +58,7 @@ class BlockHeaders extends React.PureComponent { } } -export default withCall('derive.chain.subscribeNewHead', { propName: 'headers', transform })(BlockHeaders); +export default withCall('derive.chain.subscribeNewHead', { + propName: 'headers', + transform +})(BlockHeaders); diff --git a/packages/app-extrinsics/src/Balance.tsx b/packages/app-extrinsics/src/Balance.tsx index 0a585851f8..930d2741f7 100644 --- a/packages/app-extrinsics/src/Balance.tsx +++ b/packages/app-extrinsics/src/Balance.tsx @@ -30,4 +30,4 @@ class BalanceDisplay extends React.PureComponent { } } -export default withCall('query.balances.freeBalance')(BalanceDisplay); +export default withCall('query.balances.freeBalance', { paramName: 'params' })(BalanceDisplay); diff --git a/packages/app-staking/src/Account/Bond.tsx b/packages/app-staking/src/Account/Bond.tsx index a9ea0aca39..bd780d7b63 100644 --- a/packages/app-staking/src/Account/Bond.tsx +++ b/packages/app-staking/src/Account/Bond.tsx @@ -6,6 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import BN from 'bn.js'; import React from 'react'; +import { AccountId } from '@polkadot/types'; import { Button, InputAddress, InputBalance, Modal, TxButton, Dropdown } from '@polkadot/ui-app'; import translate from '../translate'; @@ -13,7 +14,7 @@ import ValidateController from './ValidateController'; type Props = I18nProps & { accountId: string, - controllerId: string | null, + controllerId?: AccountId | null, isOpen: boolean, onClose: () => void }; @@ -39,7 +40,7 @@ class Bond extends React.PureComponent { const { accountId, controllerId } = this.props; this.state = { - controllerId: controllerId || accountId, + controllerId: controllerId ? controllerId.toString() : accountId, destination: 0 }; } diff --git a/packages/app-staking/src/Account/Nominating.tsx b/packages/app-staking/src/Account/Nominating.tsx index 2a70f20a31..0fd2fef4cf 100644 --- a/packages/app-staking/src/Account/Nominating.tsx +++ b/packages/app-staking/src/Account/Nominating.tsx @@ -6,6 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { KeyringSectionOption } from '@polkadot/ui-keyring/options/types'; import React from 'react'; +import { AccountId } from '@polkadot/types'; import { Button, InputAddress, Modal, TxButton } from '@polkadot/ui-app'; import translate from '../translate'; @@ -14,7 +15,7 @@ type Props = I18nProps & { accountId: string, isOpen: boolean, onClose: () => void, - stashId: string, + stashId: AccountId, stashOptions: Array }; diff --git a/packages/app-staking/src/Account/Validating.tsx b/packages/app-staking/src/Account/Validating.tsx index d1008e9bfb..b9cea00f0d 100644 --- a/packages/app-staking/src/Account/Validating.tsx +++ b/packages/app-staking/src/Account/Validating.tsx @@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import BN from 'bn.js'; import React from 'react'; -import { ValidatorPrefs } from '@polkadot/types'; +import { AccountId, ValidatorPrefs } from '@polkadot/types'; import { Button, InputAddress, InputBalance, InputNumber, Modal, TxButton } from '@polkadot/ui-app'; import translate from '../translate'; @@ -16,7 +16,7 @@ type Props = I18nProps & { isOpen: boolean, onClose: () => void, preferences: ValidatorPrefs, - stashId: string + stashId: AccountId }; type State = { @@ -81,7 +81,7 @@ class Staking extends React.PureComponent { Array | undefined, - controllers: Array, + controllerId?: AccountId | null, filter: AccountFilter, isValidator: boolean, name: string, - nominators: Nominators, recentlyOffline: RecentlyOfflineMap, - session_nextKeyFor?: Option, - staking_bonded?: Option, - staking_ledger?: Option, + sessionId?: AccountId | null, + stashId?: AccountId | null, staking_stakers?: Exposure, + staking_nominators?: [Array], staking_validators?: [ValidatorPrefs], - stashes: Array, stashOptions: Array, validators: Array }; type State = { - controllerId: string | null, isBondOpen: boolean, isBondExtraOpen: boolean, isNominateOpen: boolean, isSessionKeyOpen: boolean, isValidatingOpen: boolean, - isUnbondOpen: boolean, - sessionId: string | null, - stashId: string | null + isUnbondOpen: boolean }; class Account extends React.PureComponent { state: State = { - controllerId: null, isBondOpen: false, isBondExtraOpen: false, isSessionKeyOpen: false, isNominateOpen: false, isValidatingOpen: false, - isUnbondOpen: false, - sessionId: null, - stashId: null + isUnbondOpen: false }; - static getDerivedStateFromProps ({ session_nextKeyFor, staking_bonded, staking_ledger }: Props, state: State): Partial { - return { - controllerId: staking_bonded && staking_bonded.isSome - ? staking_bonded.unwrap().toString() - : null, - sessionId: session_nextKeyFor && session_nextKeyFor.isSome - ? session_nextKeyFor.unwrap().toString() - : null, - stashId: staking_ledger && staking_ledger.isSome - ? staking_ledger.unwrap().stash.toString() - : null - }; - } - render () { - const { accountId, balanceArray, filter, name } = this.props; - const { controllerId, stashId } = this.state; + const { accountId, controllerId, filter, name, stashId } = this.props; if ((filter === 'controller' && !stashId) || (filter === 'stash' && !controllerId) || (filter === 'unbonded' && (controllerId || stashId))) { return null; @@ -95,7 +71,6 @@ class Account extends React.PureComponent { {this.renderSessionKey()} {this.renderValidating()} { } private renderBond () { - const { accountId } = this.props; - const { controllerId, isBondOpen } = this.state; + const { accountId, controllerId } = this.props; + const { isBondOpen } = this.state; return ( { } private renderValidating () { - const { accountId, staking_validators } = this.props; - const { isValidatingOpen, stashId } = this.state; + const { accountId, stashId, staking_validators } = this.props; + const { isValidatingOpen } = this.state; if (!staking_validators || !isValidatingOpen || !stashId) { return null; @@ -193,19 +168,10 @@ class Account extends React.PureComponent { // ); // } - private getNominees () { - const { nominators } = this.props; - const { stashId } = this.state; - - return stashId ? nominators[stashId] : null; - } - private renderNominee () { - const { recentlyOffline, t } = this.props; + const { recentlyOffline, staking_nominators, t } = this.props; - const nominees = this.getNominees(); - - if (!nominees || !nominees.length) { + if (!staking_nominators || !staking_nominators[0].length) { return null; } @@ -213,11 +179,11 @@ class Account extends React.PureComponent {
{ - nominees.map((nomineeId, index) => ( + staking_nominators[0].map((nomineeId, index) => ( @@ -252,8 +218,7 @@ class Account extends React.PureComponent { } private renderControllerId () { - const { recentlyOffline, t } = this.props; - const { controllerId } = this.state; + const { controllerId, recentlyOffline, t } = this.props; if (!controllerId) { return null; @@ -264,15 +229,14 @@ class Account extends React.PureComponent {
); } private renderSessionId () { - const { t } = this.props; - const { sessionId } = this.state; + const { sessionId, t } = this.props; if (!sessionId) { return null; @@ -287,8 +251,7 @@ class Account extends React.PureComponent { } private renderStashId () { - const { recentlyOffline, t } = this.props; - const { stashId } = this.state; + const { recentlyOffline, stashId, t } = this.props; if (!stashId) { return null; @@ -299,7 +262,7 @@ class Account extends React.PureComponent { @@ -308,8 +271,8 @@ class Account extends React.PureComponent { } private renderNominating () { - const { accountId, stashOptions } = this.props; - const { isNominateOpen, stashId } = this.state; + const { accountId, stashId, stashOptions } = this.props; + const { isNominateOpen } = this.state; if (!stashId) { return null; @@ -327,8 +290,7 @@ class Account extends React.PureComponent { } private renderButtons () { - const { accountId, controllers, t } = this.props; - const { sessionId, controllerId, stashId } = this.state; + const { accountId, controllerId, sessionId, stashId, staking_nominators, staking_validators, t } = this.props; const buttons = []; if (!stashId) { @@ -352,16 +314,19 @@ class Account extends React.PureComponent { ); } } else { - const nominees = this.getNominees(); - const isNominating = nominees && nominees.length; - const isValidating = controllers.indexOf(accountId) !== -1; + const isNominating = staking_nominators && staking_nominators[0].length; + const isValidating = staking_validators && !(staking_validators[0].isEmpty); if (isValidating || isNominating) { buttons.push( @@ -439,10 +404,26 @@ class Account extends React.PureComponent { export default translate( withCalls( 'query.staking.recentlyOffline', - ['query.session.nextKeyFor', { paramName: 'accountId' }], - ['query.staking.bonded', { paramName: 'accountId' }], - ['query.staking.ledger', { paramName: 'accountId' }], + ['query.session.nextKeyFor', { + paramName: 'accountId', + propName: 'sessionId', + transform: (session: Option) => + session.unwrapOr(null) + }], + ['query.staking.bonded', { + paramName: 'accountId', + propName: 'controllerId', + transform: (bonded: Option) => + bonded.unwrapOr(null) + }], + ['query.staking.ledger', { + paramName: 'accountId', + propName: 'stashId', + transform: (ledger: Option) => + ledger.unwrapOr({ stash: null }).stash + }], ['query.staking.stakers', { paramName: 'accountId' }], - ['query.staking.validators', { paramName: 'accountId' }] + ['query.staking.nominators', { paramName: 'stashId' }], + ['query.staking.validators', { paramName: 'stashId' }] )(Account) ); diff --git a/packages/app-staking/src/Accounts.tsx b/packages/app-staking/src/Accounts.tsx index 0c128838b9..3dcdf8ef3e 100644 --- a/packages/app-staking/src/Accounts.tsx +++ b/packages/app-staking/src/Accounts.tsx @@ -66,7 +66,7 @@ class Accounts extends React.PureComponent { } render () { - const { balances, balanceArray, controllers, nominators, recentlyOffline, stashes, t, validators } = this.props; + const { balances, recentlyOffline, t, validators } = this.props; const { filter, filterOptions } = this.state; const accounts = keyring.getAccounts(); @@ -90,15 +90,11 @@ class Accounts extends React.PureComponent { diff --git a/packages/app-staking/src/Overview/Address.tsx b/packages/app-staking/src/Overview/Address.tsx index fec2843dac..8aa507eab5 100644 --- a/packages/app-staking/src/Overview/Address.tsx +++ b/packages/app-staking/src/Overview/Address.tsx @@ -7,7 +7,7 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { Nominators, RecentlyOfflineMap } from '../types'; import React from 'react'; -import { AccountId, Balance, Option, StakingLedger } from '@polkadot/types'; +import { AccountId, Option, StakingLedger } from '@polkadot/types'; import { withCalls, withMulti } from '@polkadot/ui-api/with'; import { AddressMini, AddressRow, RecentlyOffline } from '@polkadot/ui-app'; import { getAddrName } from '@polkadot/ui-app/util'; @@ -18,7 +18,6 @@ import translate from '../translate'; type Props = I18nProps & { address: string, balances: DerivedBalancesMap, - balanceArray: (_address: AccountId | string) => Array | undefined, defaultName: string, lastAuthor: string, lastBlock: string, diff --git a/packages/app-staking/src/Overview/CurrentList.tsx b/packages/app-staking/src/Overview/CurrentList.tsx index 61d863b210..dda062053b 100644 --- a/packages/app-staking/src/Overview/CurrentList.tsx +++ b/packages/app-staking/src/Overview/CurrentList.tsx @@ -7,14 +7,12 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { Nominators, RecentlyOfflineMap } from '../types'; import React from 'react'; -import { AccountId, Balance } from '@polkadot/types'; import translate from '../translate'; import Address from './Address'; type Props = I18nProps & { balances: DerivedBalancesMap, - balanceArray: (_address: AccountId | string) => Array | undefined, current: Array, lastAuthor?: string, lastBlock: string, @@ -66,7 +64,7 @@ class CurrentList extends React.PureComponent { } private renderColumn (addresses: Array, defaultName: string) { - const { balances, balanceArray, lastAuthor, lastBlock, nominators, recentlyOffline, t } = this.props; + const { balances, lastAuthor, lastBlock, nominators, recentlyOffline, t } = this.props; if (addresses.length === 0) { return ( @@ -80,7 +78,6 @@ class CurrentList extends React.PureComponent {
{ render () { - const { balances, balanceArray, chain_subscribeNewHead, controllers, nominators, recentlyOffline, validators } = this.props; + const { balances, chain_subscribeNewHead, controllers, nominators, recentlyOffline, validators } = this.props; const nextSorted = this.sortByBalance( controllers.filter((address) => !validators.includes(address) @@ -50,7 +50,6 @@ class Overview extends React.PureComponent { /> { return ( { ); }; } - - private balanceArray = (_address: AccountId | string): Array | undefined => { - const { balances = {} } = this.props; - - if (!_address) { - return undefined; - } - - const address = _address.toString(); - - return balances[address] - ? [ - balances[address].stakingBalance, - balances[address].nominatedBalance - ] - : undefined; - } } export default withMulti( diff --git a/packages/app-staking/src/types.ts b/packages/app-staking/src/types.ts index af8cd5c460..33ecb92225 100644 --- a/packages/app-staking/src/types.ts +++ b/packages/app-staking/src/types.ts @@ -4,7 +4,7 @@ import BN from 'bn.js'; import { DerivedBalancesMap } from '@polkadot/api-derive/types'; -import { AccountId, Balance, BlockNumber } from '@polkadot/types'; +import { AccountId, BlockNumber } from '@polkadot/types'; export type Nominators = { // stash account and who is being nominated @@ -13,7 +13,6 @@ export type Nominators = { export type ComponentProps = { balances: DerivedBalancesMap, - balanceArray: (_address: AccountId | string) => Array | undefined, controllers: Array, nominators: Nominators, recentlyOffline: RecentlyOfflineMap, diff --git a/packages/app-storage/src/Query.tsx b/packages/app-storage/src/Query.tsx index b8eeafd21f..284c4f2b2a 100644 --- a/packages/app-storage/src/Query.tsx +++ b/packages/app-storage/src/Query.tsx @@ -51,7 +51,11 @@ class Query extends React.PureComponent { const defaultProps = { className: 'ui--output' }; // render function to create an element for the query results which is plugged to the api - const renderHelper = withCallDiv('subscribe', { params: [key, ...values] }); + const renderHelper = withCallDiv('subscribe', { + paramName: 'params', + paramValid: true, + 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), diff --git a/packages/ui-api/src/types.ts b/packages/ui-api/src/types.ts index 3c5e753702..80fd3feadb 100644 --- a/packages/ui-api/src/types.ts +++ b/packages/ui-api/src/types.ts @@ -31,11 +31,6 @@ export type OnChangeCb = OnChangeCb$Obs | OnChangeCb$Fn; export type ChangeProps = { callOnResult?: OnChangeCb }; - -export type ParamProps = { - params?: any -}; - export type CallState = { callResult?: any; callUpdated?: boolean; @@ -44,7 +39,7 @@ export type CallState = { export type CallProps = ApiProps & CallState; -export type BaseProps = BareProps & CallProps & ChangeProps & ParamProps & { +export type BaseProps = BareProps & CallProps & ChangeProps & { children?: React.ReactNode, label?: string, render?: (value?: T) => React.ReactNode diff --git a/packages/ui-api/src/with/call.tsx b/packages/ui-api/src/with/call.tsx index 3b021b5541..b98a13d47b 100644 --- a/packages/ui-api/src/with/call.tsx +++ b/packages/ui-api/src/with/call.tsx @@ -23,7 +23,7 @@ const NOOP = () => { // ignore }; -export default function withCall

(endpoint: string, { at, atProp, callOnResult, params = [], paramName = 'params', propName, transform = echoTransform }: Options = {}): (Inner: React.ComponentType) => React.ComponentType { +export default function withCall

(endpoint: string, { at, atProp, callOnResult, params = [], paramName, paramValid = false, propName, transform = echoTransform }: Options = {}): (Inner: React.ComponentType) => React.ComponentType { return (Inner: React.ComponentType): React.ComponentType> => { class WithPromise extends React.Component { state: State = { @@ -91,20 +91,30 @@ export default function withCall

(endpoint: string, { at, at } } - private getParams (props: any): Array { - const paramValue = props[paramName]; + private getParams (props: any): [boolean, Array] { + const paramValue = paramName + ? props[paramName] + : undefined; if (atProp) { at = props[atProp]; } - return isUndefined(paramValue) + // When we are specifying a param and have an invalid, don't use it. For 'params', + // we default to the original types, i.e. no validation (query app uses this) + if (!paramValid && paramName && (isUndefined(paramValue) || isNull(paramValue))) { + return [false, []]; + } + + const values = isUndefined(paramValue) ? params : params.concat( Array.isArray(paramValue) ? paramValue : [paramValue] ); + + return [true, values]; } private getApiMethod (newParams: Array): [Method, Array, boolean] { @@ -145,7 +155,11 @@ export default function withCall

(endpoint: string, { at, at ]; } - private async subscribe (newParams: Array) { + private async subscribe ([isValid, newParams]: [boolean, Array]) { + if (!isValid) { + return; + } + const { api } = this.props; await api.isReady; diff --git a/packages/ui-api/src/with/types.ts b/packages/ui-api/src/with/types.ts index 8f3fb9524e..f66fe8e0e1 100644 --- a/packages/ui-api/src/with/types.ts +++ b/packages/ui-api/src/with/types.ts @@ -19,6 +19,7 @@ export type Options = { callOnResult?: OnChangeCb, params?: Array, paramName?: string, + paramValid?: boolean, propName?: string, transform?: Transform }; diff --git a/packages/ui-app/src/AddressMini.tsx b/packages/ui-app/src/AddressMini.tsx index e04aca0fdb..23f2f10884 100644 --- a/packages/ui-app/src/AddressMini.tsx +++ b/packages/ui-app/src/AddressMini.tsx @@ -88,7 +88,7 @@ export default class AddressMini extends React.PureComponent { ); } @@ -104,7 +104,7 @@ export default class AddressMini extends React.PureComponent { ); } diff --git a/packages/ui-app/src/AddressSummary.tsx b/packages/ui-app/src/AddressSummary.tsx index 8d66956357..b61ad04bc0 100644 --- a/packages/ui-app/src/AddressSummary.tsx +++ b/packages/ui-app/src/AddressSummary.tsx @@ -149,7 +149,7 @@ class AddressSummary extends React.PureComponent { balance={balance} className='ui--AddressSummary-balance' label={t('balance ')} - value={accountId} + params={accountId} /> ); } @@ -167,7 +167,7 @@ class AddressSummary extends React.PureComponent { ); } diff --git a/packages/ui-app/src/Balance.tsx b/packages/ui-app/src/Balance.tsx index c65bbcb155..f9028fbcc9 100644 --- a/packages/ui-app/src/Balance.tsx +++ b/packages/ui-app/src/Balance.tsx @@ -15,15 +15,15 @@ import { classes } from './util'; export type Props = BareProps & { balance?: Balance | Array | BN, label?: string, - value?: AccountId | AccountIndex | Address | string | Uint8Array | null, + params?: AccountId | AccountIndex | Address | string | Uint8Array | null, withLabel?: boolean }; export default class BalanceDisplay extends React.PureComponent { render () { - const { balance, className, label, value, style } = this.props; + const { balance, className, label, params, style } = this.props; - if (!value) { + if (!params) { return null; } @@ -33,7 +33,7 @@ export default class BalanceDisplay extends React.PureComponent { ); diff --git a/packages/ui-app/src/Bonded.tsx b/packages/ui-app/src/Bonded.tsx index 1682ace296..e0ee752496 100644 --- a/packages/ui-app/src/Bonded.tsx +++ b/packages/ui-app/src/Bonded.tsx @@ -12,14 +12,15 @@ import { classes } from './util'; export type Props = BareProps & { label?: string, - value?: AccountId | AccountIndex | Address | string | Uint8Array | null, + params?: AccountId | AccountIndex | Address | string | Uint8Array | null, withLabel?: boolean }; export default class BondedDisplay extends React.PureComponent { render () { - const { value, className, label, style } = this.props; - if (!value) { + const { params, className, label, style } = this.props; + + if (!params) { return null; } @@ -27,7 +28,7 @@ export default class BondedDisplay extends React.PureComponent { ); diff --git a/packages/ui-reactive/src/AccountIndex.tsx b/packages/ui-reactive/src/AccountIndex.tsx index 0074cc72ba..7e6c0e7a11 100644 --- a/packages/ui-reactive/src/AccountIndex.tsx +++ b/packages/ui-reactive/src/AccountIndex.tsx @@ -34,4 +34,4 @@ export class AccountIndexDisplay extends React.PureComponent { } } -export default withCall('derive.accounts.idAndIndex', { paramName: 'value' })(AccountIndexDisplay); +export default withCall('derive.accounts.idAndIndex', { paramName: 'params' })(AccountIndexDisplay); diff --git a/packages/ui-reactive/src/Balance.tsx b/packages/ui-reactive/src/Balance.tsx index b802a210b8..fb1aa6ace5 100644 --- a/packages/ui-reactive/src/Balance.tsx +++ b/packages/ui-reactive/src/Balance.tsx @@ -34,4 +34,4 @@ export class BalanceDisplay extends React.PureComponent { } } -export default withCall('query.balances.freeBalance')(BalanceDisplay); +export default withCall('query.balances.freeBalance', { paramName: 'params' })(BalanceDisplay); diff --git a/packages/ui-reactive/src/Bonded.tsx b/packages/ui-reactive/src/Bonded.tsx index 6449ba88d3..cdd01b1b8b 100644 --- a/packages/ui-reactive/src/Bonded.tsx +++ b/packages/ui-reactive/src/Bonded.tsx @@ -12,7 +12,7 @@ import { formatBalance } from '@polkadot/util'; type Props = BareProps & CallProps & { children?: React.ReactNode, - value?: AccountId | AccountIndex | Address | string | Uint8Array | null, + params?: AccountId | AccountIndex | Address | string | Uint8Array | null, label?: string, staking_ledger?: Option }; @@ -44,8 +44,10 @@ export class BondedDisplay extends React.PureComponent { export default withCalls( ['query.staking.bonded', { - paramName: 'value', - transform: (value) => value.unwrapOr(null) + paramName: 'params', + propName: 'controllerId', + transform: (value) => + value.unwrapOr(null) }], - ['query.staking.ledger', { paramName: 'staking_bonded' }] + ['query.staking.ledger', { paramName: 'controllerId' }] )(BondedDisplay); diff --git a/packages/ui-reactive/src/Nonce.tsx b/packages/ui-reactive/src/Nonce.tsx index 9692f893e3..c1e8063099 100644 --- a/packages/ui-reactive/src/Nonce.tsx +++ b/packages/ui-reactive/src/Nonce.tsx @@ -34,4 +34,4 @@ export class Nonce extends React.PureComponent { } } -export default withCall('query.system.accountNonce')(Nonce); +export default withCall('query.system.accountNonce', { paramName: 'params' })(Nonce);