Show rotate keys (as available) (#1906)
This commit is contained in:
parent
7b2e29932b
commit
c337e4dacb
@ -39,7 +39,8 @@ interface Props extends ApiProps, I18nProps {
|
||||
interface State {
|
||||
controllerId: string | null;
|
||||
destination: number;
|
||||
hexSessionId: string | null;
|
||||
hexSessionIdNext: string | null;
|
||||
hexSessionIdQueue: string | null;
|
||||
isBondExtraOpen: boolean;
|
||||
isInjectOpen: boolean;
|
||||
isNominateOpen: boolean;
|
||||
@ -86,7 +87,8 @@ class Account extends React.PureComponent<Props, State> {
|
||||
public state: State = {
|
||||
controllerId: null,
|
||||
destination: 0,
|
||||
hexSessionId: null,
|
||||
hexSessionIdNext: null,
|
||||
hexSessionIdQueue: null,
|
||||
isBondExtraOpen: false,
|
||||
isInjectOpen: false,
|
||||
isNominateOpen: false,
|
||||
@ -116,11 +118,12 @@ class Account extends React.PureComponent<Props, State> {
|
||||
return {
|
||||
controllerId: toIdString(controllerId),
|
||||
destination: rewardDestination && rewardDestination.toNumber(),
|
||||
hexSessionId: u8aToHex(u8aConcat(...(
|
||||
hexSessionIdNext: u8aToHex(u8aConcat(...(
|
||||
nextSessionIds.length
|
||||
? nextSessionIds
|
||||
: sessionIds
|
||||
).map((id): Uint8Array => id.toU8a())), 48),
|
||||
hexSessionIdQueue: u8aToHex(u8aConcat(...(sessionIds).map((id): Uint8Array => id.toU8a())), 48),
|
||||
isStashNominating,
|
||||
isStashValidating,
|
||||
nominees: nominators && nominators.map(toIdString),
|
||||
@ -138,7 +141,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
|
||||
public render (): React.ReactNode {
|
||||
const { className, isSubstrateV2, t } = this.props;
|
||||
const { controllerId, hexSessionId, isBondExtraOpen, isInjectOpen, isStashValidating, isUnbondOpen, nominees, onlineStatus, sessionIds, stashId } = this.state;
|
||||
const { controllerId, hexSessionIdNext, hexSessionIdQueue, isBondExtraOpen, isInjectOpen, isStashValidating, isUnbondOpen, nominees, onlineStatus, sessionIds, stashId } = this.state;
|
||||
|
||||
if (!stashId) {
|
||||
return null;
|
||||
@ -225,7 +228,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
unlocking: true
|
||||
}}
|
||||
withRewardDestination
|
||||
withHexSessionId={ isSubstrateV2 && hexSessionId !== '0x' && hexSessionId}
|
||||
withHexSessionId={ isSubstrateV2 && hexSessionIdNext !== '0x' && [hexSessionIdQueue, hexSessionIdNext]}
|
||||
withValidatorPrefs={isStashValidating}
|
||||
/>
|
||||
</div>
|
||||
@ -287,7 +290,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
|
||||
private renderButtons (): React.ReactNode {
|
||||
const { isSubstrateV2, t } = this.props;
|
||||
const { controllerId, hexSessionId, isSettingPopupOpen, isStashNominating, isStashValidating, sessionIds } = this.state;
|
||||
const { controllerId, hexSessionIdNext, isSettingPopupOpen, isStashNominating, isStashValidating, sessionIds } = this.state;
|
||||
const buttons = [];
|
||||
|
||||
// if we are validating/nominating show stop
|
||||
@ -307,7 +310,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
if (!sessionIds.length || (isSubstrateV2 && hexSessionId === '0x')) {
|
||||
if (!sessionIds.length || (isSubstrateV2 && hexSessionIdNext === '0x')) {
|
||||
buttons.push(
|
||||
<Button
|
||||
isPrimary
|
||||
@ -370,7 +373,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
|
||||
private renderPopupMenu (): React.ReactNode {
|
||||
const { balances_all, isSubstrateV2, ownStash, t } = this.props;
|
||||
const { hexSessionId, isStashNominating, isStashValidating, sessionIds } = this.state;
|
||||
const { hexSessionIdNext, isStashNominating, isStashValidating, sessionIds } = this.state;
|
||||
|
||||
// only show a "Bond Additional" button if this stash account actually doesn't bond everything already
|
||||
// staking_ledger.total gives the total amount that can be slashed (any active amount + what is being unlocked)
|
||||
@ -407,7 +410,7 @@ class Account extends React.PureComponent<Props, State> {
|
||||
{t('Change validator preferences')}
|
||||
</Menu.Item>
|
||||
}
|
||||
{!isStashNominating && (!!sessionIds.length || (isSubstrateV2 && hexSessionId !== '0x')) &&
|
||||
{!isStashNominating && (!!sessionIds.length || (isSubstrateV2 && hexSessionIdNext !== '0x')) &&
|
||||
<Menu.Item onClick={this.toggleSetSessionAccount}>
|
||||
{isSubstrateV2 ? t('Change session keys') : t('Change session account')}
|
||||
</Menu.Item>
|
||||
|
||||
@ -99,11 +99,13 @@ function Validator ({ className, sessionRewards, t, validatorId }: Props): React
|
||||
});
|
||||
const [blocksLabels, setBlocksLabels] = useState<string[]>([]);
|
||||
const [blocksChart, setBlocksChart] = useState<LineData | null>(null);
|
||||
const [currency] = useState(formatBalance.getDefaults().unit);
|
||||
const [{ currency, divisor }] = useState<{ currency: string; divisor: BN }>({
|
||||
currency: formatBalance.getDefaults().unit,
|
||||
divisor: new BN('1'.padEnd(formatBalance.getDefaults().decimals + 1, '0'))
|
||||
});
|
||||
const [{ rewardsChart, rewardsLabels }, setRewardsInfo] = useState<{ rewardsChart: LineData | null; rewardsLabels: string[] }>({ rewardsChart: null, rewardsLabels: [] });
|
||||
const [{ splitChart, splitMax }, setSplitInfo] = useState<{ splitChart: SplitData | null; splitMax: number }>({ splitChart: null, splitMax: 100 });
|
||||
const [{ stakeChart, stakeLabels }, setStakeInfo] = useState<{ stakeChart: LineData | null; stakeLabels: string[]}>({ stakeChart: null, stakeLabels: [] });
|
||||
const divisor = new BN('1'.padEnd(formatBalance.getDefaults().decimals + 1, '0'));
|
||||
|
||||
useEffect((): void => {
|
||||
if (!splitChart) {
|
||||
|
||||
@ -49,7 +49,7 @@ interface Props extends BareProps, I18nProps {
|
||||
stakingInfo?: DerivedStaking;
|
||||
withBalance?: boolean | BalanceActiveType;
|
||||
withExtended?: boolean | CryptoActiveType;
|
||||
withHexSessionId: string | null;
|
||||
withHexSessionId?: [string | null][];
|
||||
withRewardDestination?: boolean;
|
||||
withValidatorPrefs?: boolean | ValidatorPrefsType;
|
||||
}
|
||||
@ -343,7 +343,13 @@ function AddressInfo (props: Props): React.ReactElement<Props> {
|
||||
{withHexSessionId && (
|
||||
<>
|
||||
<Label label={t('session keys')} />
|
||||
<div className='result'>{withHexSessionId}</div>
|
||||
<div className='result'>{withHexSessionId[0]}</div>
|
||||
</>
|
||||
)}
|
||||
{withHexSessionId && withHexSessionId[0] !== withHexSessionId[1] && (
|
||||
<>
|
||||
<Label label={t('session rotate')} />
|
||||
<div className='result'>{withHexSessionId[1]}</div>
|
||||
</>
|
||||
)}
|
||||
{renderValidatorPrefs(props)}
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Options, Params } from './types';
|
||||
import { Arg, Options, Params } from './types';
|
||||
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { extractParams, transformIdentity } from './util';
|
||||
|
||||
interface TrackFn <T> {
|
||||
(a: any, b: any, c: any): Promise<T>;
|
||||
(a: any, b: any): Promise<T>;
|
||||
(a: any): Promise<T>;
|
||||
(a: Arg, b: Arg, c: Arg): Promise<T>;
|
||||
(a: Arg, b: Arg): Promise<T>;
|
||||
(a: Arg): Promise<T>;
|
||||
(): Promise<T>;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Options, Params } from './types';
|
||||
import { Arg, Options, Params } from './types';
|
||||
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
@ -15,9 +15,9 @@ interface TrackFnCallback <T> {
|
||||
type Unsub = () => void;
|
||||
|
||||
interface TrackFn <T> {
|
||||
(a: any, b: any, c: any, cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
(a: any, b: any, cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
(a: any, cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
(a: Arg, cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
(a: Arg, b: Arg, cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
(a: Arg, b: Arg, c: Arg, cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
(cb: TrackFnCallback<T>): Promise<Unsub>;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export type Params = [] | [any] | [any, any] | [any, any, any];
|
||||
export type Arg = any;
|
||||
|
||||
export type Params = [] | [Arg] | [Arg, Arg] | [Arg, Arg, Arg];
|
||||
|
||||
export interface Options <T> {
|
||||
paramMap?: (params: any) => any;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
|
||||
import { I18nProps } from '@polkadot/react-components/types';
|
||||
import { DerivedFees, DerivedBalances, DerivedContractFees } from '@polkadot/api-derive/types';
|
||||
import { IExtrinsic } from '@polkadot/types/types';
|
||||
@ -40,7 +41,7 @@ interface Props extends I18nProps {
|
||||
balances_all?: DerivedBalances;
|
||||
contract_fees?: DerivedContractFees;
|
||||
accountId?: string | null;
|
||||
extrinsic?: IExtrinsic | null;
|
||||
extrinsic?: SubmittableExtrinsic | null;
|
||||
isSendable: boolean;
|
||||
onChange?: (hasAvailable: boolean) => void;
|
||||
tip?: BN;
|
||||
@ -86,6 +87,12 @@ export function FeeDisplay ({ accountId, balances_all = ZERO_BALANCE, balances_f
|
||||
return;
|
||||
}
|
||||
|
||||
// extrinsic
|
||||
// .paymentInfo(accountId, { tip })
|
||||
// .then((result): void => {
|
||||
// console.log(JSON.stringify(result));
|
||||
// });
|
||||
|
||||
const fn = api.findCall(extrinsic.callIndex);
|
||||
const extMethod = fn.method;
|
||||
const extSection = fn.section;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user