Skip to content

Commit

Permalink
Merge pull request PolkaGate#1377 from AMIRKHANEF/UpdateProxy
Browse files Browse the repository at this point in the history
Refactor Proxy Type Filter to Use PROXY_TYPE Constants
  • Loading branch information
Nick-1979 authored Jun 16, 2024
2 parents 29dd9cf + e8ac70e commit 3bfb4bf
Show file tree
Hide file tree
Showing 46 changed files with 104 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { amountToHuman } from '../../../util/utils';
import { DraggableModal } from '../../governance/components/DraggableModal';
import SelectProxyModal2 from '../../governance/components/SelectProxyModal2';
import WaitScreen from '../../governance/partials/WaitScreen';
import { GOVERNANCE_PROXY } from '../../governance/utils/consts';
import Confirmation from './Confirmation';
import { PROXY_TYPE } from '../../../util/constants';

interface Props {
address: string;
Expand Down Expand Up @@ -174,7 +174,7 @@ export default function Review({ address, api, classToUnlock, setDisplayPopup, s
isPasswordError={isPasswordError}
onSecondaryClick={onClose}
primaryBtnText={t('Confirm')}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
secondaryBtnText={t('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand All @@ -192,7 +192,7 @@ export default function Review({ address, api, classToUnlock, setDisplayPopup, s
closeSelectProxy={closeProxy}
height={500}
proxies={proxyItems}
proxyTypeFilter={['Any', 'NonTransfer']}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
selectedProxy={selectedProxy}
setSelectedProxy={setSelectedProxy}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Identity, Motion, ShowValue, SignArea2, WrongPasswordAlert } from '../../../components';
import { useIdentity, useInfo, useTracks, useTranslation } from '../../../hooks';
import { ThroughProxy } from '../../../partials';
import { PROXY_TYPE } from '../../../util/constants';
import DisplayValue from '../post/castVote/partial/DisplayValue';
import { GOVERNANCE_PROXY } from '../utils/consts';
import TracksList from './partial/TracksList';
import { DelegateInformation, STEPS } from '.';

Expand Down Expand Up @@ -152,7 +152,7 @@ export default function Review({ address, delegateInformation, estimatedFee, sel
isPasswordError={isPasswordError}
onSecondaryClick={onBackClick}
primaryBtnText={t('Confirm')}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
secondaryBtnText={t('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { BN, BN_ONE } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';

import { useAccountLocks, useBalances, useInfo, useProxies, useTracks, useTranslation } from '../../../hooks';
import { PROXY_TYPE } from '../../../util/constants';
import { DraggableModal } from '../components/DraggableModal';
import SelectProxyModal2 from '../components/SelectProxyModal2';
import WaitScreen from '../partials/WaitScreen';
import { GOVERNANCE_PROXY } from '../utils/consts';
import { DelegationInfo } from '../utils/types';
import { getMyDelegationInfo } from '../utils/util';
import ChooseDelegator from './delegate/ChooseDelegator';
Expand Down Expand Up @@ -358,7 +358,7 @@ export function Delegate({ address, open, setOpen, showDelegationNote }: Props):
closeSelectProxy={() => setStep(proxyStep)}
height={modalHeight}
proxies={proxyItems}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
selectedProxy={selectedProxy}
setSelectedProxy={setSelectedProxy}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { Identity, Motion, ShowValue, SignArea2, WrongPasswordAlert } from '../.
import { useCurrentBlockNumber, useIdentity, useInfo, useTracks, useTranslation } from '../../../../hooks';
import { Lock } from '../../../../hooks/useAccountLocks';
import { ThroughProxy } from '../../../../partials';
import { PROXY_TYPE } from '../../../../util/constants';
import { amountToHuman, amountToMachine } from '../../../../util/utils';
import DisplayValue from '../../post/castVote/partial/DisplayValue';
import { GOVERNANCE_PROXY } from '../../utils/consts';
import TracksList from '../partial/TracksList';
import { AlreadyDelegateInformation, DelegateInformation, STEPS } from '..';
import Modify from './Modify';
Expand Down Expand Up @@ -324,7 +324,7 @@ export default function ModifyDelegate({ accountLocks, address, balances, classi
isPasswordError={isPasswordError}
onSecondaryClick={onBackClick}
primaryBtnText={t('Confirm')}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
secondaryBtnText={t('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { BN_ONE, BN_ZERO } from '@polkadot/util';
import { Identity, Motion, ShowValue, SignArea2, WrongPasswordAlert } from '../../../../components';
import { useIdentity, useInfo, useTracks, useTranslation } from '../../../../hooks';
import { ThroughProxy } from '../../../../partials';
import { PROXY_TYPE } from '../../../../util/constants';
import DisplayValue from '../../post/castVote/partial/DisplayValue';
import { GOVERNANCE_PROXY } from '../../utils/consts';
import ReferendaTable from '../partial/ReferendaTable';
import TracksList from '../partial/TracksList';
import { AlreadyDelegateInformation, DelegateInformation, STEPS } from '..';
Expand Down Expand Up @@ -212,7 +212,7 @@ export default function RemoveDelegate({ address, classicDelegateInformation, fo
isPasswordError={isPasswordError}
onSecondaryClick={onBackClick}
primaryBtnText={t('Confirm')}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
secondaryBtnText={t('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { BN_ZERO } from '@polkadot/util';
import { Identity, Motion, ShowBalance, ShowValue, SignArea2, Warning, WrongPasswordAlert } from '../../../../components';
import { useInfo, useTranslation } from '../../../../hooks';
import { ThroughProxy } from '../../../../partials';
import { ENDED_STATUSES, GOVERNANCE_PROXY, STATUS_COLOR } from '../../utils/consts';
import { ENDED_STATUSES, STATUS_COLOR } from '../../utils/consts';
import { PROXY_TYPE } from '../../../../util/constants';
import DisplayValue from './partial/DisplayValue';
import { STEPS, VoteInformation } from '.';

Expand Down Expand Up @@ -184,7 +185,7 @@ export default function Review({ address, estimatedFee, selectedProxy, setModalH
params={params}
previousStep={txType === 'Vote' ? STEPS.REVIEW : STEPS.REMOVE}
primaryBtnText={t('Confirm')}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
secondaryBtnText={t('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { cryptoWaitReady } from '@polkadot/util-crypto';

import { useInfo, useProxies, useTranslation } from '../../../../hooks';
import { amountToHuman, amountToMachine } from '../../../../util/utils';
import { PROXY_TYPE } from '../../../../util/constants';
import { DraggableModal } from '../../components/DraggableModal';
import SelectProxyModal2 from '../../components/SelectProxyModal2';
import WaitScreen from '../../partials/WaitScreen';
import { GOVERNANCE_PROXY } from '../../utils/consts';
import { getVoteType } from '../../utils/util';
import { getConviction, Vote } from '../myVote/util';
import About from './About';
Expand Down Expand Up @@ -273,7 +273,7 @@ export default function Index({ address, cantModify, hasVoted, myVote, notVoted,
closeSelectProxy={() => setStep(alterType === 'remove' ? STEPS.REMOVE : STEPS.REVIEW)}
height={reviewModalHeight}
proxies={proxyItems}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
selectedProxy={selectedProxy}
setSelectedProxy={setSelectedProxy}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import { cryptoWaitReady } from '@polkadot/util-crypto';
import { Identity, ShowBalance, SignArea2, Warning } from '../../../../components';
import { useAccountDisplay, useBalances, useInfo, useProxies, useTranslation } from '../../../../hooks';
import { ThroughProxy } from '../../../../partials';
import { PROXY_TYPE } from '../../../../util/constants';
import type { Proxy, ProxyItem, TxInfo } from '../../../../util/types';
import { DraggableModal } from '../../components/DraggableModal';
import SelectProxyModal2 from '../../components/SelectProxyModal2';
import WaitScreen from '../../partials/WaitScreen';
import { GOVERNANCE_PROXY } from '../../utils/consts';
import { type Track } from '../../utils/types';
import DisplayValue from '../castVote/partial/DisplayValue';
import Confirmation from './Confirmation';
Expand Down Expand Up @@ -200,7 +200,7 @@ export default function DecisionDeposit({ address, open, refIndex, setOpen, trac
params={[refIndex]}
previousStep={STEPS.REVIEW}
primaryBtnText={t('Confirm')}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
secondaryBtnText={t('Close')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand All @@ -219,7 +219,7 @@ export default function DecisionDeposit({ address, open, refIndex, setOpen, trac
closeSelectProxy={() => setStep(STEPS.REVIEW)}
height={HEIGHT}
proxies={proxyItems}
proxyTypeFilter={GOVERNANCE_PROXY}
proxyTypeFilter={PROXY_TYPE.GOVERNANCE}
selectedProxy={selectedProxy}
setSelectedProxy={setSelectedProxy}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const TRACK_LIMIT_TO_LOAD_PER_REQUEST = LATEST_REFERENDA_LIMIT_TO_LOAD_PE
export const REFERENDA_LIMIT_SAVED_LOCAL = 2 * LATEST_REFERENDA_LIMIT_TO_LOAD_PER_REQUEST;

export const FINISHED_REFERENDUM_STATUSES = ['Cancelled', 'Confirmed', 'Executed', 'Rejected', 'TimedOut'];
export const GOVERNANCE_PROXY = ['Any', 'NonTransfer', 'Governance'];

export const REFERENDA_STATUS = [
['All'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ApiPromise } from '@polkadot/api';
import type { DeriveAccountRegistration } from '@polkadot/api-derive/types';
import type { Chain } from '@polkadot/extension-chains/types';

import { PEOPLE_CHAINS } from '@polkadot/extension-polkagate/src/util/constants';
import { PEOPLE_CHAINS, PROXY_TYPE } from '@polkadot/extension-polkagate/src/util/constants';
import { BN, BN_ONE } from '@polkadot/util';

import { CanPayErrorAlert, Identity, Motion, ShowBalance, SignArea2, Warning, WrongPasswordAlert } from '../../components';
Expand Down Expand Up @@ -359,7 +359,7 @@ export default function Review({ address, api, chain, depositToPay, depositValue
mayBeApi={api}
onSecondaryClick={handleClose}
primaryBtnText={t('Confirm')}
proxyTypeFilter={['Any', 'NonTransfer']}
proxyTypeFilter={PROXY_TYPE.GENERAL}
secondaryBtnText={t('Cancel')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down Expand Up @@ -387,7 +387,7 @@ export default function Review({ address, api, chain, depositToPay, depositValue
closeSelectProxy={() => setStep(STEPS.REVIEW)}
height={500}
proxies={proxyItems}
proxyTypeFilter={['Any', 'NonTransfer']}
proxyTypeFilter={PROXY_TYPE.GENERAL}
selectedProxy={selectedProxy}
setSelectedProxy={setSelectedProxy}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { BN, BN_ONE, BN_ZERO } from '@polkadot/util';
import { CanPayErrorAlert, ShowBalance, SignArea2, WrongPasswordAlert } from '../../components';
import { useCanPayFeeAndDeposit, useFormatted, useTranslation } from '../../hooks';
import { ThroughProxy } from '../../partials';
import { PROXY_TYPE } from '../../util/constants';
import { pgBoxShadow } from '../../util/utils';
import WaitScreen from '../governance/partials/WaitScreen';
import DisplayValue from '../governance/post/castVote/partial/DisplayValue';
Expand Down Expand Up @@ -221,7 +222,7 @@ function Review({ address, api, chain, depositedValue, newDepositValue, proxyIte
isPasswordError={isPasswordError}
onSecondaryClick={backToManage}
primaryBtnText={t('Confirm')}
proxyTypeFilter={['Any', 'NonTransfer']}
proxyTypeFilter={PROXY_TYPE.GENERAL}
secondaryBtnText={t('Cancel')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ChainLogo, Identity, Motion, ShowBalance, SignArea2, WrongPasswordAlert
import { useApi, useChain } from '../../hooks';
import useTranslation from '../../hooks/useTranslation';
import { ThroughProxy } from '../../partials';
import { PROXY_TYPE } from '../../util/constants';
import { amountToMachine, pgBoxShadow } from '../../util/utils';
import DisplayValue from '../governance/post/castVote/partial/DisplayValue';
import { STEPS } from '../stake/pool/stake';
Expand Down Expand Up @@ -137,7 +138,7 @@ export default function Review({ address, balances, inputs, setRefresh, setStep,
onSecondaryClick={handleClose}
params={inputs?.params}
primaryBtnText={t('Confirm')}
proxyTypeFilter={['Any']}
proxyTypeFilter={PROXY_TYPE.SEND_FUND}
secondaryBtnText={t('Cancel')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type { ActiveRecoveryFor } from '../../hooks/useActiveRecoveries';
import useTranslation from '../../hooks/useTranslation';
import { ThroughProxy } from '../../partials';
import blockToDate from '../../popup/crowdloans/partials/blockToDate';
import { PROXY_TYPE } from '../../util/constants';
import { pgBoxShadow } from '../../util/utils';
import WaitScreen from '../governance/partials/WaitScreen';
import DisplayValue from '../governance/post/castVote/partial/DisplayValue';
Expand Down Expand Up @@ -642,7 +643,7 @@ export default function Review({ activeLost, address, allActiveRecoveries, api,
? closeWindow
: handleClose}
primaryBtnText={t<string>('Confirm')}
proxyTypeFilter={['Any', 'NonTransfer']}
proxyTypeFilter={PROXY_TYPE.GENERAL}
secondaryBtnText={t<string>('Cancel')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import useTranslation from '../../../hooks/useTranslation';
import { ThroughProxy } from '../../../partials';
import ShowPool from '../../../popup/staking/partial/ShowPool';
import RewardsDestination from '../../../popup/staking/solo/stake/partials/RewardDestination';
import { SYSTEM_SUGGESTION_TEXT } from '../../../util/constants';
import { PROXY_TYPE, SYSTEM_SUGGESTION_TEXT } from '../../../util/constants';
import { amountToMachine, pgBoxShadow } from '../../../util/utils';
import DisplayValue from '../../governance/post/castVote/partial/DisplayValue';
import { STEPS } from '..';
Expand Down Expand Up @@ -160,7 +160,7 @@ export default function Review ({ address, balances, inputs, setRefresh, setStep
onSecondaryClick={handleCancel}
params={inputs?.params}
primaryBtnText={t('Confirm')}
proxyTypeFilter={inputs?.pool ? ['Any', 'NonTransfer', 'Staking', 'NominationPools'] : ['Any', 'NonTransfer', 'Staking']} // TODO: nomination pools needs test
proxyTypeFilter={inputs?.pool ? PROXY_TYPE.NOMINATION_POOLS : PROXY_TYPE.STAKING}
secondaryBtnText={t('Cancel')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { BN, BN_ZERO } from '@polkadot/util';
import { AccountHolderWithProxy, Identity, ShortAddress, ShowBalance, ShowValue, SignArea2, WrongPasswordAlert } from '../../../components';
import { useEstimatedFee, useInfo, useProxies, useTranslation } from '../../../hooks';
import { SubTitle } from '../../../partials';
import { PROXY_TYPE } from '../../../util/constants';
import type { MyPoolInfo, Payee, Proxy, ProxyItem, TxInfo } from '../../../util/types';
import type { Inputs } from '../Entry';
import { STEPS } from '../pool/stake';
Expand Down Expand Up @@ -95,8 +96,8 @@ export default function Review({ address, inputs, onClose, setRefresh, setStep,
const proxyTypeFilter = useMemo(
() =>
inputs?.extraInfo?.pool
? ['Any', 'NonTransfer', 'NominationPools']
: ['Any', 'NonTransfer', 'Staking']
? PROXY_TYPE.NOMINATION_POOLS
: PROXY_TYPE.STAKING
, [inputs]);

const closeProxy = useCallback(() => setStep(STEPS.REVIEW), [setStep]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SubmittableExtrinsicFunction } from '@polkadot/api/types/submittable';
import type { Chain } from '@polkadot/extension-chains/types';

import SelectProxyModal2 from '@polkadot/extension-polkagate/src/fullscreen/governance/components/SelectProxyModal2';
import { PROXY_TYPE } from '@polkadot/extension-polkagate/src/util/constants';
import type { Balance } from '@polkadot/types/interfaces';
import { BN_ONE } from '@polkadot/util';

Expand Down Expand Up @@ -222,7 +223,7 @@ export default function Review({ address, api, chain, changes, formatted, pool,
onSecondaryClick={onBackClick}
params={inputs?.params}
primaryBtnText={t<string>('Confirm')}
proxyTypeFilter={['Any', 'NonTransfer', 'NominationPools']}
proxyTypeFilter={PROXY_TYPE.NOMINATION_POOLS}
secondaryBtnText={t<string>('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand All @@ -243,7 +244,7 @@ export default function Review({ address, api, chain, changes, formatted, pool,
closeSelectProxy={closeProxy}
height={500}
proxies={proxyItems}
proxyTypeFilter={['Any', 'NonTransfer', 'NominationPools']}
proxyTypeFilter={PROXY_TYPE.NOMINATION_POOLS}
selectedProxy={selectedProxy}
setSelectedProxy={setSelectedProxy}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';

import { DeriveAccountInfo } from '@polkadot/api-derive/types';
import DisplayValue from '@polkadot/extension-polkagate/src/fullscreen/governance/post/castVote/partial/DisplayValue';
import { PROXY_TYPE } from '@polkadot/extension-polkagate/src/util/constants';
import type { Balance } from '@polkadot/types/interfaces';
import { BN, BN_ZERO } from '@polkadot/util';

Expand Down Expand Up @@ -96,7 +97,7 @@ export default function Review({ address, allValidatorsIdentities, inputs, setSt
onSecondaryClick={handleCancel}
params={params}
primaryBtnText={t('Confirm')}
proxyTypeFilter={['Any', 'NonTransfer', 'NominationPools']}
proxyTypeFilter={PROXY_TYPE.NOMINATION_POOLS}
secondaryBtnText={t('Back')}
selectedProxy={selectedProxy}
setIsPasswordError={setIsPasswordError}
Expand Down
Loading

0 comments on commit 3bfb4bf

Please sign in to comment.