-
import type { ComponentType, Node } from 'react';
-
import type { $npm$ReactIntl$IntlFormat } from 'react-intl';
+
import { Component, Suspense, lazy } from 'react';
+
import type { Node } from 'react';
import type { GeneratedData as BannerContainerData } from '../../banners/BannerContainer';
import type { InjectedOrGenerated } from '../../../types/injectedPropsType';
import type { GeneratedData as SidebarContainerData } from '../../SidebarContainer';
import type { GeneratedData as NavBarContainerRevampData } from '../../NavBarContainerRevamp';
-
import type { LayoutComponentMap } from '../../../styles/context/layout';
import type { ConfigType } from '../../../../config/config-types';
-
import type { TxRequests } from '../../../stores/toplevel/TransactionsStore';
-
import type { DelegationRequests, PoolMeta } from '../../../stores/toplevel/DelegationStore';
-
import type { GeneratedData as UnmangleTxDialogContainerData } from '../../transfer/UnmangleTxDialogContainer';
-
import type { GeneratedData as DeregisterDialogContainerData } from '../../transfer/DeregisterDialogContainer';
-
import type { TokenInfoMap } from '../../../stores/toplevel/TokenInfoStore';
-
import type { NetworkRow } from '../../../api/ada/lib/storage/database/primitives/tables';
-
import type { UnitOfAccountSettingType } from '../../../types/unitOfAccountType';
-
import type { AdaDelegationRequests } from '../../../stores/ada/AdaDelegationStore';
-
import type { GeneratedData as WithdrawalTxDialogContainerData } from '../../transfer/WithdrawalTxDialogContainer';
-
import type { PoolRequest } from '../../../api/jormungandr/lib/storage/bridge/delegationUtils';
-
import type { TokenEntry } from '../../../api/common/lib/MultiToken';
-
} from '../../../stores/base/BaseCardanoTimeStore';
-
import { Component } from 'react';
+
import { intlShape } from 'react-intl';
+
import type { $npm$ReactIntl$IntlFormat } from 'react-intl';
import { computed } from 'mobx';
import { observer } from 'mobx-react';
-
import { intlShape } from 'react-intl';
-
import moment from 'moment';
import globalMessages from '../../../i18n/global-messages';
import BannerContainer from '../../banners/BannerContainer';
import SidebarContainer from '../../SidebarContainer';
import NavBarContainerRevamp from '../../NavBarContainerRevamp';
import TopBarLayout from '../../../components/layout/TopBarLayout';
import NavBarTitle from '../../../components/topbar/NavBarTitle';
-
import { PublicDeriver } from '../../../api/ada/lib/storage/models/PublicDeriver/index';
-
import { withLayout } from '../../../styles/context/layout';
-
import WalletEmptyBanner from '../WalletEmptyBanner';
-
import BuySellDialog from '../../../components/buySell/BuySellDialog';
-
import CardanoStakingPage from './CardanoStakingPage';
-
import { Box, styled } from '@mui/system';
-
import SummaryCard from '../../../components/wallet/staking/dashboard-revamp/SummaryCard';
-
import EpochProgressWrapper from '../../../components/wallet/staking/dashboard-revamp/EpochProgressWrapper';
-
import OverviewModal from '../../../components/wallet/staking/dashboard-revamp/OverviewDialog';
-
import LocalizableError from '../../../i18n/LocalizableError';
-
import { MultiToken } from '../../../api/common/lib/MultiToken';
-
import { genLookupOrFail } from '../../../stores/stateless/tokenHelpers';
-
import UnmangleTxDialogContainer from '../../transfer/UnmangleTxDialogContainer';
-
import DeregisterDialogContainer from '../../transfer/DeregisterDialogContainer';
-
import { calculateAndFormatValue } from '../../../utils/unit-of-account';
-
} from '../../../api/ada/lib/storage/database/prepackaged/networks';
-
import EpochProgressContainer from './EpochProgressContainer';
-
import WithdrawalTxDialogContainer from '../../transfer/WithdrawalTxDialogContainer';
-
import UndelegateDialog from '../../../components/wallet/staking/dashboard/UndelegateDialog';
-
import { generateGraphData } from '../../../utils/graph';
-
import { ApiOptions, getApiForNetwork } from '../../../api/common/utils';
-
import RewardHistoryDialog from '../../../components/wallet/staking/dashboard-revamp/RewardHistoryDialog';
-
import DelegatedStakePoolCard from '../../../components/wallet/staking/dashboard-revamp/DelegatedStakePoolCard';
+
export const StakingPageContentPromise: void => Promise<any> = () => import('./StakingPageContent');
+
const StakingPageContent = lazy(StakingPageContentPromise);
export type GeneratedData = typeof StakingPage.prototype.generated;
// populated by ConfigWebpackPlugin
declare var CONFIG: ConfigType;
-
...InjectedOrGenerated<GeneratedData>,
-
+renderLayoutComponent: LayoutComponentMap => Node,
+
type Props = {| ...InjectedOrGenerated<GeneratedData>, stores: any, actions: any |};
-
type AllProps = {| ...Props, ...InjectedProps |};
-
class StakingPage extends Component<AllProps> {
+
class StakingPage extends Component<Props> {
static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = {
intl: intlShape.isRequired,
-
onClose: void => void = () => {
-
this.generated.actions.dialogs.closeActiveDialog.trigger();
-
_isRegistered: (PublicDeriver<>) => ?boolean = publicDeriver => {
-
if (!isCardanoHaskell(publicDeriver.getParent().getNetworkInfo())) {
-
const adaDelegationRequests = this.generated.stores.substores.ada.delegation.getDelegationRequests(
-
if (adaDelegationRequests == null) return undefined;
-
return adaDelegationRequests.getRegistrationHistory.result?.current;
-
async componentDidMount() {
-
const timeStore = this.generated.stores.time;
-
const publicDeriver = this.generated.stores.wallets.selected;
-
if (publicDeriver == null) {
-
throw new Error(`${nameof(StakingPage)} no public deriver. Should never happen`);
-
const timeCalcRequests = timeStore.getTimeCalcRequests(publicDeriver);
-
await timeCalcRequests.requests.toAbsoluteSlot.execute().promise;
-
await timeCalcRequests.requests.toRealTime.execute().promise;
-
await timeCalcRequests.requests.currentEpochLength.execute().promise;
-
await timeCalcRequests.requests.currentSlotLength.execute().promise;
-
await timeCalcRequests.requests.timeSinceGenesis.execute().promise;
-
getErrorInFetch: (PublicDeriver<>) => void | {| error: LocalizableError |} = publicDeriver => {
-
const delegationStore = this.generated.stores.delegation;
-
const delegationRequests = delegationStore.getDelegationRequests(publicDeriver);
-
if (delegationRequests == null) {
-
throw new Error(`${nameof(StakingPage)} opened for non-reward wallet`);
-
if (delegationRequests.error != null) {
-
return { error: delegationRequests.error };
-
if (delegationRequests.getCurrentDelegation.result != null) {
-
const currentDelegation = delegationRequests.getCurrentDelegation.result;
-
const currEpochInfo = currentDelegation.currEpoch;
-
if (currEpochInfo == null) {
-
getEpochLengthInDays: (PublicDeriver<>) => ?number = publicDeriver => {
-
const timeStore = this.generated.stores.time;
-
const timeCalcRequests = timeStore.getTimeCalcRequests(publicDeriver);
-
const getEpochLength = timeCalcRequests.requests.currentEpochLength.result;
-
if (getEpochLength == null) return null;
-
const getSlotLength = timeCalcRequests.requests.currentSlotLength.result;
-
if (getSlotLength == null) return null;
-
const epochLengthInSeconds = getEpochLength() * getSlotLength();
-
const epochLengthInDays = epochLengthInSeconds / (60 * 60 * 24);
-
return epochLengthInDays;
-
delegationRequests: DelegationRequests,
-
publicDeriver: PublicDeriver<>,
-
errorIfPresent: void | {| error: LocalizableError |},
-
|}) => Node = request => {
-
const { actions, stores } = this.generated;
-
const showRewardAmount =
-
request.delegationRequests.getCurrentDelegation.wasExecuted &&
-
request.delegationRequests.getDelegatedBalance.wasExecuted &&
-
request.errorIfPresent == null;
-
const defaultToken = request.publicDeriver.getParent().getDefaultToken();
-
const currentlyDelegating =
-
(request.delegationRequests.getCurrentDelegation.result?.currEpoch?.pools ?? []).length > 0;
-
actions.dialogs.open.trigger({
-
unitOfAccount={this.toUnitOfAccount}
-
getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)}
-
shouldHideBalance={stores.profile.shouldHideBalance}
-
!showRewardAmount || request.delegationRequests.getDelegatedBalance.result == null
-
: request.delegationRequests.getDelegatedBalance.result.accountPart
-
totalDelegated={(() => {
-
if (!showRewardAmount) return undefined;
-
if (request.delegationRequests.getDelegatedBalance.result == null) return undefined;
-
return currentlyDelegating
-
? request.delegationRequests.getDelegatedBalance.result.utxoPart.joinAddCopy(
-
request.delegationRequests.getDelegatedBalance.result.accountPart
-
: new MultiToken([], defaultToken);
-
epochLength={this.getEpochLengthInDays(request.publicDeriver)}
-
graphData={generateGraphData({
-
delegationRequests: request.delegationRequests,