Skip to content

Commit

Permalink
Merge pull request #87 from elysia-dev/fix/approve-box
Browse files Browse the repository at this point in the history
allwonce가 허용되있는 경우에 approve step box 숨김
  • Loading branch information
JUNG-gyucheol authored Oct 22, 2021
2 parents 3569f53 + f29233a commit 0b0de93
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 26 deletions.
28 changes: 25 additions & 3 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,18 @@
"transaction": {
"pending": "Transaction now in progress.",
"fail": "Transaction failed",
"created": "Completed transaction"
"created": "Completed transaction",
"create_transaction": "Transaction has been sent.",
"success_transaction": "{{transferType}} has been completed.",
"purchase_transaction": "{{transferType}} has been completed.",
"failed_withdrawal": "Asset token withdrawal failed.",
"failed_purchase": "Failed to purchase real estate tokens.",
"failed_refund": "Failed to refund real estate tokens.",
"failed_productReward": "Failed to receive interest.",
"failed_stake": "Staking failed.",
"failed_unstake": "Unstaking failed.",
"failed_migrate": "Migration failed.",
"failed_stakingReward": "Failed to receive compensation."
},
"main": {
"total_assets": "Total assets",
Expand All @@ -313,7 +324,10 @@
"my_staking": "My staking and rewards",
"staking_by_crypto": "{{stakingCrypto}} staking and {{rewardCrypto}} rewards",
"staking_amount": "{{round}}$t(ordinal_suffix.{{round}}) round staking",
"reward_amount": "{{round}}$t(ordinal_suffix.{{round}}) round rewards"
"reward_amount": "{{round}}$t(ordinal_suffix.{{round}}) round rewards",
"pending_transaction": "Pending transactions",
"pending_transaction_count": "There is currently {{count}} transaction pending.",
"pending_transaction_counts": "There are currently {{count}} transactions pending."
},
"recovery_key": {
"keep": "Save your recovery key",
Expand Down Expand Up @@ -483,6 +497,14 @@
"refund_notice": "Refunds for real estate properties previously purchased through our website may take up to 3 business days and the dedicated account manager will contact you by email."
},
"ordinal_suffix": ["", "st", "nd", "rd", "th", "th", "th"],
"datetime_format": "MM.DD.YYYY HH:mm:ss"
"datetime_format": "MM.DD.YYYY HH:mm:ss",
"withdrawal": "Asset token withdrawal",
"purchase": "The real estate token purchase",
"refund": "The real estate token refund",
"productReward": "Interest payment",
"stake": "Staking",
"unstake": "Unstaking",
"migrate": "Migration",
"stakingReward": "Compensation receipt"
}
}
2 changes: 1 addition & 1 deletion src/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@
"refund_notice": "기존 상품의 경우 환불은 3영업일 이내에 완료되며, 담당 팀이 이메일로 연락을 드립니다."
},
"datetime_format": "YYYY.MM.DD HH:mm:ss",
"withdrawal": "자산 출금",
"withdrawal": "자산 토큰 출금",
"purchase": "부동산 토큰 구매",
"refund": "부동산 토큰 환불",
"productReward": "이자 출금",
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
},
"numeral_character": ["", "", "", "", "", "", ""],
"datetime_format": "YYYY.MM.DD HH:mm:ss",
"withdrawal": "资产出金",
"withdrawal": "资产代币出金",
"purchase": "购买房地产代币",
"refund": "房地产代币退款",
"productReward": "利息出金",
Expand Down
3 changes: 3 additions & 0 deletions src/modules/asset/Purchase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const Purchase: FunctionComponent = () => {
const balanceInToken = (balanceInCrypto * cryptoPrice) / tokenPrice;
const { elContract } = useErcContract();
const [approvalGasPrice, setApprovalGasPrice] = useState('');
const [isAllowanced, setIsAllowanced] = useState(false);
const { addCount, isApproved, setIsApproved, isLoading, setIsLoading } =
useCountingEstimatedGas(setEstimatedGas);
const maxValueInToken = remainingSupplyInToken
Expand Down Expand Up @@ -178,6 +179,7 @@ const Purchase: FunctionComponent = () => {
step: TxStep.None,
});
setIsApproved(Number(utils.formatEther(res)) > balanceInCrypto);
setIsAllowanced(Number(utils.formatEther(res)) > balanceInCrypto);
})
.catch((e: any) => {
afterTxFailed(e.message);
Expand Down Expand Up @@ -233,6 +235,7 @@ const Purchase: FunctionComponent = () => {
estimatedGas={estimagedGasPrice}
isApproved={isApproved}
approve={approve}
isAllowanced={isAllowanced}
isLoading={isLoading}
approvalGasPrice={approvalGasPrice}
createTx={() => {
Expand Down
1 change: 1 addition & 0 deletions src/modules/asset/Refund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const Refund: FunctionComponent = () => {
setValues={setValues}
estimatedGas={state.estimateGas}
isApproved={true}
isAllowanced={true}
isLoading={isLoading}
isRefund={PurposeType.Refund}
approve={() => ''}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/asset/components/TxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface ITxInput {
setCurrent: Dispatch<SetStateAction<'token' | 'fiat'>>;
setValues: Dispatch<SetStateAction<{ inFiat: string; inToken: string }>>;
approve: () => void;
isAllowanced: boolean;
isLoading: boolean;
approvalGasPrice?: string;
createTx: () => void;
Expand Down Expand Up @@ -96,6 +97,7 @@ const TxInput: React.FC<ITxInput> = ({
setCurrent,
setValues,
approve,
isAllowanced,
isLoading,
approvalGasPrice,
createTx,
Expand Down Expand Up @@ -355,6 +357,7 @@ const TxInput: React.FC<ITxInput> = ({
},
]}
isApproved={isApproved}
isAllowanced={isAllowanced}
isLoading={isLoading}
approvalGasPrice={approvalGasPrice || ''}
assetTypeOrRefund={isRefund || assetInCrypto.type}
Expand Down
23 changes: 16 additions & 7 deletions src/modules/dashboard/components/WaitingTxBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const WaitingTxBox: React.FC<{
isFocused: boolean;
}> = ({ isFocused }) => {
const navigation = useNavigation();
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const { waitingTxs } = useContext(TransactionContext);

return (
Expand Down Expand Up @@ -47,12 +47,21 @@ const WaitingTxBox: React.FC<{
label={t('main.pending_transaction')}
style={{ color: AppColors.SUB_BLACK }}
/>
<H4Text
label={t('main.pending_transaction_count', {
count: waitingTxs.length,
})}
style={{ fontSize: 15 }}
/>
{waitingTxs.length >= 2 && i18n.language === 'en' ? (
<H4Text
label={t('main.pending_transaction_counts', {
count: waitingTxs.length,
})}
style={{ fontSize: 15 }}
/>
) : (
<H4Text
label={t('main.pending_transaction_count', {
count: waitingTxs.length,
})}
style={{ fontSize: 15 }}
/>
)}
</TouchableOpacity>
</View>
)}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/staking/Stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const Stake: React.FC = () => {
const [totalPrincipal, setTotalPrincipal] = useState<BigNumber>(
constants.Zero,
);
const [isAllowanced, setIsAllowanced] = useState(false);
const { addCount, isApproved, setIsApproved, isLoading, setIsLoading } =
useCountingEstimatedGas(setEstimatedGas, StakingType.Stake);
const currentStakingRound = getCurrentStakingRound();
Expand Down Expand Up @@ -329,6 +330,7 @@ const Stake: React.FC = () => {
if (isWalletUser) {
getApproveGasPrice();
setIsApproved(isAllowanceForApprove());
setIsAllowanced(isAllowanceForApprove());
setModalVisible(true);
setEstimatedGas(StakingType.Stake, selectedRound, value);
} else {
Expand Down Expand Up @@ -369,6 +371,7 @@ const Stake: React.FC = () => {
},
]}
isApproved={isApproved}
isAllowanced={isAllowanced}
submitButtonText={t('staking.nth_staking', { round: selectedRound })}
handler={() => onPressStaking()}
isLoading={isLoading}
Expand Down
1 change: 1 addition & 0 deletions src/modules/staking/Unstake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const Unstake: React.FC = () => {
subtitle={t('staking.confirmation_title')}
list={confirmationList}
isApproved={true}
isAllowanced={true}
submitButtonText={t('staking.nth_unstaking', {
round: selectedRound,
})}
Expand Down
1 change: 1 addition & 0 deletions src/modules/staking/UnstakeAndMigrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ const UnstakeAndMigrate: React.FC = () => {
subtitle={t('staking.confirmation_title')}
list={confirmationList}
isApproved={true}
isAllowanced={true}
submitButtonText={t('staking.nth_unstaking', {
round: selectedRound,
})}
Expand Down
4 changes: 3 additions & 1 deletion src/shared/components/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface Props {
subtitle: string;
list: { label: string; value: string; subvalue?: string }[];
isApproved: boolean;
isAllowanced: boolean;
isLoading?: boolean;
approvalGasPrice: string;
assetTypeOrRefund?: CryptoType | string;
Expand All @@ -35,6 +36,7 @@ const ConfirmationModal: React.FC<Props> = ({
subtitle,
list,
isApproved,
isAllowanced,
isLoading,
approvalGasPrice,
assetTypeOrRefund,
Expand Down Expand Up @@ -96,7 +98,7 @@ const ConfirmationModal: React.FC<Props> = ({
backgroundColor: AppColors.WHITE,
}}>
<View>
{assetTypeOrRefund === CryptoType.EL && (
{assetTypeOrRefund === CryptoType.EL && !isAllowanced && (
<ConfirmBox isApprove={isApproved} />
)}
{isApproved ? (
Expand Down
4 changes: 3 additions & 1 deletion src/shared/components/StakingConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface Props {
subtitle: string;
list: { label: string; value: string; subvalue?: string }[];
isApproved: boolean;
isAllowanced: boolean;
submitButtonText: string;
handler: () => void;
isLoading: boolean;
Expand All @@ -35,6 +36,7 @@ const StakingConfirmModal: React.FC<Props> = ({
subtitle,
list,
isApproved,
isAllowanced,
submitButtonText,
handler,
isLoading,
Expand Down Expand Up @@ -96,7 +98,7 @@ const StakingConfirmModal: React.FC<Props> = ({
backgroundColor: AppColors.WHITE,
}}>
<View>
{stakingType === StakingType.Stake && (
{stakingType === StakingType.Stake && !isAllowanced && (
<ConfirmBox isApprove={isApproved} />
)}
{isApproved ? (
Expand Down
37 changes: 25 additions & 12 deletions src/shared/components/ToastMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Props = {

const ToastMessage: React.FC<Props> = ({ waitingTx, toastHide }) => {
const fadeAnim = useRef(new Animated.Value(0)).current;
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const [isVisible, setIsVisible] = useState(true);

const fadeIn = () => {
Expand Down Expand Up @@ -81,9 +81,11 @@ const ToastMessage: React.FC<Props> = ({ waitingTx, toastHide }) => {
})
}
style={{
fontSize: 14,
textAlign: 'center',
fontSize: i18n.language === 'en' ? 11 : 14,
fontFamily: 'NanumSquareEB',
color: AppColors.WHITE,
width: 220,
}}
/>
</>
Expand All @@ -96,16 +98,27 @@ const ToastMessage: React.FC<Props> = ({ waitingTx, toastHide }) => {
height: 20,
}}
/>
<P3Text
label={t('transaction.fail_transaction', {
transferType: `${t(waitingTx.transferType)}`,
})}
style={{
fontSize: 14,
fontFamily: 'NanumSquareEB',
color: AppColors.WHITE,
}}
/>
{i18n.language === 'en' ? (
<P3Text
label={t(`transaction.failed_${waitingTx.transferType}`)}
style={{
fontSize: 12,
fontFamily: 'NanumSquareEB',
color: AppColors.WHITE,
}}
/>
) : (
<P3Text
label={t('transaction.fail_transaction', {
transferType: `${t(waitingTx.transferType)}`,
})}
style={{
fontSize: 14,
fontFamily: 'NanumSquareEB',
color: AppColors.WHITE,
}}
/>
)}
</>
) : (
<>
Expand Down

0 comments on commit 0b0de93

Please sign in to comment.