renamed transferTypes import to TransferTypes

This commit is contained in:
Nouman Tahir 2023-01-09 13:02:35 +05:00
parent 1d34e8e9d7
commit 11d511fc81
6 changed files with 36 additions and 32 deletions

View File

@ -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;

View File

@ -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 = ({
</TouchableOpacity>
)}
/>
{(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) && (
<TransferFormItem
label={intl.formatMessage({ id: 'transfer.memo' })}
rightComponent={() =>
@ -141,7 +141,7 @@ const TransferAmountInputSection = ({
containerStyle={{ height: 80 }}
/>
)}
{(transferType === transferTypes.POINTS || transferType === transferTypes.TRANSFER_TOKEN) && (
{(transferType === TransferTypes.POINTS || transferType === TransferTypes.TRANSFER_TOKEN) && (
<TransferFormItem
rightComponentStyle={styles.transferItemRightStyle}
containerStyle={styles.transferItemContainer}
@ -150,7 +150,7 @@ const TransferAmountInputSection = ({
}
/>
)}
{transferType === transferTypes.CONVERT && (
{transferType === TransferTypes.CONVERT && (
<TransferFormItem
rightComponent={() =>
_renderCenterDescription(intl.formatMessage({ id: 'transfer.convert_desc' }))

View File

@ -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

View File

@ -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:

View File

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

View File

@ -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}`,
)}`;