Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions packages/app-staking/src/Actions/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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;
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 4 additions & 2 deletions packages/app-staking/src/Query/Validator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions packages/react-components/src/AddressInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)}
Expand Down
8 changes: 4 additions & 4 deletions packages/react-hooks/src/track/trackPromise.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/react-hooks/src/track/trackStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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>;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/react-hooks/src/track/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion packages/react-signer/src/Checks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down