diff --git a/src/components/transferAccountSelector/transferAccountSelector.tsx b/src/components/transferAccountSelector/transferAccountSelector.tsx index 322e69369..7bb6208c6 100644 --- a/src/components/transferAccountSelector/transferAccountSelector.tsx +++ b/src/components/transferAccountSelector/transferAccountSelector.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useMemo, useRef } from 'react'; import { useIntl } from 'react-intl'; import { Text, View } from 'react-native'; import { debounce } from 'lodash'; -import transferTypes from '../../constants/transferTypes'; +import TransferTypes from '../../constants/transferTypes'; import DropdownButton from '../dropdownButton'; import Icon from '../icon'; import TextInput from '../textInput'; @@ -52,9 +52,9 @@ const TransferAccountSelector = ({ const destinationLocked = useMemo(() => { switch (transferType) { - case transferTypes.CONVERT: - case transferTypes.PURCHASE_ESTM: - case transferTypes.UNSTAKE_ENGINE: + case TransferTypes.CONVERT: + case TransferTypes.PURCHASE_ESTM: + case TransferTypes.UNSTAKE_ENGINE: return true; default: return false; diff --git a/src/components/transferAmountInputSection/transferAmountInputSection.tsx b/src/components/transferAmountInputSection/transferAmountInputSection.tsx index 0aa7712fc..42bf6bb60 100644 --- a/src/components/transferAmountInputSection/transferAmountInputSection.tsx +++ b/src/components/transferAmountInputSection/transferAmountInputSection.tsx @@ -6,7 +6,7 @@ import { TransferFormItem } from '../transferFormItem'; // Styles import styles from './transferAmountInputSectionStyles'; -import transferTypes from '../../constants/transferTypes'; +import TransferTypes from '../../constants/transferTypes'; export interface TransferAmountInputSectionProps { balance: number; @@ -124,10 +124,10 @@ const TransferAmountInputSection = ({ )} /> - {(transferType === transferTypes.POINTS || - transferType === transferTypes.TRANSFER_TOKEN || - transferType === transferTypes.TRANSFER_TO_SAVINGS || - transferType === transferTypes.TRANSFER_ENGINE) && ( + {(transferType === TransferTypes.POINTS || + transferType === TransferTypes.TRANSFER_TOKEN || + transferType === TransferTypes.TRANSFER_TO_SAVINGS || + transferType === TransferTypes.TRANSFER_ENGINE) && ( @@ -141,7 +141,7 @@ const TransferAmountInputSection = ({ containerStyle={{ height: 80 }} /> )} - {(transferType === transferTypes.POINTS || transferType === transferTypes.TRANSFER_TOKEN) && ( + {(transferType === TransferTypes.POINTS || transferType === TransferTypes.TRANSFER_TOKEN) && ( )} - {transferType === transferTypes.CONVERT && ( + {transferType === TransferTypes.CONVERT && ( _renderCenterDescription(intl.formatMessage({ id: 'transfer.convert_desc' })) diff --git a/src/constants/transferTypes.ts b/src/constants/transferTypes.ts index 7052402a0..fff54b182 100644 --- a/src/constants/transferTypes.ts +++ b/src/constants/transferTypes.ts @@ -13,9 +13,10 @@ const DELEGATE_VESTING_SHARES = 'delegate_vesting_shares'; const WITHDRAW_VESTING = 'withdraw_vesting'; const TRANSFER_ENGINE = 'transfer_engine'; const UNSTAKE_ENGINE = 'unstake_engine'; +const STAKE_ENGINE = 'stake_engine'; const UNDELEGATE_ENGINE = 'undelegate_engine'; -export default { +const TransferTypes = { TRANSFER_TOKEN, PURCHASE_ESTM, CONVERT, @@ -32,4 +33,7 @@ export default { TRANSFER_ENGINE, UNSTAKE_ENGINE, UNDELEGATE_ENGINE, + STAKE_ENGINE }; + +export default TransferTypes diff --git a/src/containers/transferContainer.js b/src/containers/transferContainer.js index 66d072114..b51919264 100644 --- a/src/containers/transferContainer.js +++ b/src/containers/transferContainer.js @@ -33,7 +33,7 @@ import { unstakeHiveEngine, } from '../providers/hive-engine/hiveEngineActions'; import { fetchTokenBalances } from '../providers/hive-engine/hiveEngine'; -import transferTypes from '../constants/transferTypes'; +import TransferTypes from '../constants/transferTypes'; /* * Props Name Description Value @@ -90,10 +90,10 @@ class TransferContainer extends Component { tokenBalances.forEach((tokenBalance) => { if (tokenBalance.symbol === fundType) { switch (transferType) { - case transferTypes.UNDELEGATE_ENGINE: + case TransferTypes.UNDELEGATE_ENGINE: balance = tokenBalance.delegationsOut; break; - case transferTypes.UNSTAKE_ENGINE: + case TransferTypes.UNSTAKE_ENGINE: balance = tokenBalance.stake; break; default: diff --git a/src/screens/assetDetails/screen/assetDetailsScreen.tsx b/src/screens/assetDetails/screen/assetDetailsScreen.tsx index 36db91bb2..7e1928d92 100644 --- a/src/screens/assetDetails/screen/assetDetailsScreen.tsx +++ b/src/screens/assetDetails/screen/assetDetailsScreen.tsx @@ -18,7 +18,7 @@ import RootNavigation from '../../../navigation/rootNavigation'; import ROUTES from '../../../constants/routeNames'; import { ASSET_IDS } from '../../../constants/defaultAssets'; import { DelegationsModal, MODES } from '../children/delegationsModal'; -import transferTypes from '../../../constants/transferTypes'; +import TransferTypes from '../../../constants/transferTypes'; import { useGetAssetsQuery } from '../../../providers/queries'; export interface AssetDetailsScreenParams { @@ -157,21 +157,21 @@ const AssetDetailsScreen = ({ navigation, route }: AssetDetailsScreenProps) => { let { balance } = coinData; switch (transferType) { - case transferTypes.UNSTAKE_ENGINE: + case TransferTypes.UNSTAKE_ENGINE: balance = coinData.extraDataPairs?.reduce( (bal, data) => (data.dataKey === 'staked' ? Number(data.value) : bal), 0, ) ?? 0; break; - case transferTypes.UNDELEGATE_ENGINE: + case TransferTypes.UNDELEGATE_ENGINE: balance = coinData.extraDataPairs?.reduce( (bal, data) => (data.dataKey === 'delegations_out' ? Number(data.value) : bal), 0, ) ?? 0; - case transferTypes.WITHDRAW_HIVE: - case transferTypes.WITHDRAW_HBD: + case TransferTypes.WITHDRAW_HIVE: + case TransferTypes.WITHDRAW_HBD: balance = coinData.savings ?? 0; break; } diff --git a/src/screens/transfer/screen/transferScreen.js b/src/screens/transfer/screen/transferScreen.js index 8b04c3575..18f657165 100644 --- a/src/screens/transfer/screen/transferScreen.js +++ b/src/screens/transfer/screen/transferScreen.js @@ -17,7 +17,7 @@ import { } from '../../../components'; import styles from './transferStyles'; -import transferTypes from '../../../constants/transferTypes'; +import TransferTypes from '../../../constants/transferTypes'; import { getEngineActionJSON } from '../../../providers/hive-engine/hiveEngineActions'; import { useAppDispatch } from '../../../hooks'; import { showActionModal } from '../../../redux/actions/uiAction'; @@ -46,8 +46,8 @@ const TransferView = ({ transferType === 'withdraw_hive' || transferType === 'withdraw_hbd' || transferType === 'convert' || - transferType === transferTypes.UNSTAKE_ENGINE || - transferType === transferTypes.STAKE_ENGINE + transferType === TransferTypes.UNSTAKE_ENGINE || + transferType === TransferTypes.STAKE_ENGINE ? currentAccountName : transferType === 'purchase_estm' ? 'esteem.app' @@ -63,8 +63,8 @@ const TransferView = ({ transferType === 'withdraw_vesting' || transferType === 'withdraw_hive' || transferType === 'withdraw_hbd' || - transferType === transferTypes.UNSTAKE_ENGINE || - transferType === transferTypes.STAKE_ENGINE || + transferType === TransferTypes.UNSTAKE_ENGINE || + transferType === TransferTypes.STAKE_ENGINE || (transferType === 'convert' && currentAccountName) ), ); @@ -102,30 +102,30 @@ const TransferView = ({ // )}`; // } else - if (transferType === transferTypes.TRANSFER_TO_SAVINGS) { + if (transferType === TransferTypes.TRANSFER_TO_SAVINGS) { path = `sign/transfer_to_savings?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent( `${amount} ${fundType}`, )}&memo=${encodeURIComponent(memo)}`; - } else if (transferType === transferTypes.DELEGATE_VESTING_SHARES) { + } else if (transferType === TransferTypes.DELEGATE_VESTING_SHARES) { path = `sign/delegate_vesting_shares?delegator=${currentAccountName}&delegatee=${destination}&vesting_shares=${encodeURIComponent( `${amount} ${fundType}`, )}`; - } else if (transferType === transferTypes.TRANSFER_TO_VESTING) { + } else if (transferType === TransferTypes.TRANSFER_TO_VESTING) { path = `sign/transfer_to_vesting?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent( `${amount} ${fundType}`, )}`; } else if ( - transferType === transferTypes.WITHDRAW_HIVE || - transferType === transferTypes.WITHDRAW_HBD + transferType === TransferTypes.WITHDRAW_HIVE || + transferType === TransferTypes.WITHDRAW_HBD ) { path = `sign/transfer_from_savings?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent( `${amount} ${fundType}`, )}&request_id=${new Date().getTime() >>> 0}`; - } else if (transferType === transferTypes.CONVERT) { + } else if (transferType === TransferTypes.CONVERT) { path = `sign/convert?owner=${currentAccountName}&amount=${encodeURIComponent( `${amount} ${fundType}`, )}&requestid=${new Date().getTime() >>> 0}`; - } else if (transferType === transferTypes.WITHDRAW_VESTING) { + } else if (transferType === TransferTypes.WITHDRAW_VESTING) { path = `sign/withdraw_vesting?account=${currentAccountName}&vesting_shares=${encodeURIComponent( `${amount} ${fundType}`, )}`;