From c54c3c661e2771b3834f162cb7b048f0d72c6210 Mon Sep 17 00:00:00 2001 From: feruz Date: Thu, 13 Feb 2020 14:15:06 +0200 Subject: [PATCH] add get estm for steem and sbd --- .../walletDetails/view/walletDetailsView.js | 4 ++-- src/config/locales/en-US.json | 2 ++ src/containers/steemWalletContainer.js | 14 ++++++++++---- src/containers/transferContainer.js | 13 +++++++++++-- src/screens/transfer/index.js | 1 + src/screens/transfer/screen/transferScreen.js | 13 ++++++++++--- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/components/walletDetails/view/walletDetailsView.js b/src/components/walletDetails/view/walletDetailsView.js index 9c303c9a2..e143ae196 100644 --- a/src/components/walletDetails/view/walletDetailsView.js +++ b/src/components/walletDetails/view/walletDetailsView.js @@ -11,8 +11,8 @@ import { vestsToSp } from '../../../utils/conversions'; import styles from './walletDetailsStyles'; const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => { - const steemDropdown = ['transfer_token', 'transfer_to_saving', 'powerUp']; - const sbdDropdown = ['transfer_token', 'transfer_to_saving']; + const steemDropdown = ['purchase_estm', 'transfer_token', 'transfer_to_saving', 'powerUp']; + const sbdDropdown = ['purchase_estm', 'transfer_token', 'transfer_to_saving']; const savingSteemDropdown = ['withdraw_steem']; const savingSbdDropdown = ['withdraw_sbd']; const steemPowerDropdown = ['delegate', 'power_down']; diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 0a8653680..b47406c0d 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -59,6 +59,7 @@ "to_placeholder": "Username", "memo_placeholder": "Enter your notes here", "transfer_token": "Transfer", + "purchase_estm": "GET ESTM", "points": "Gift ESTM to someone", "transfer_to_saving": "To Saving", "powerUp": "Power Up", @@ -412,6 +413,7 @@ "to_placeholder": "Username", "memo_placeholder": "Enter your notes here", "transfer_token": "Transfer", + "purchase_estm": "Purchase ESTM", "points": "Gift ESTM to someone", "transfer_to_saving": "Transfer To Saving", "powerUp": "Power Up", diff --git a/src/containers/steemWalletContainer.js b/src/containers/steemWalletContainer.js index ca04a1135..1f8130298 100644 --- a/src/containers/steemWalletContainer.js +++ b/src/containers/steemWalletContainer.js @@ -21,8 +21,8 @@ import { getEstimatedAmount } from '../utils/vote'; // Constants import ROUTES from '../constants/routeNames'; -const STEEM_DROPDOWN = ['transfer_token', 'transfer_to_saving', 'powerUp']; -const SBD_DROPDOWN = ['transfer_token', 'transfer_to_saving']; +const STEEM_DROPDOWN = ['purchase_estm', 'transfer_token', 'transfer_to_saving', 'powerUp']; +const SBD_DROPDOWN = ['purchase_estm', 'transfer_token', 'transfer_to_saving']; const SAVING_STEEM_DROPDOWN = ['withdraw_steem']; const SAVING_SBD_DROPDOWN = ['withdraw_sbd']; const STEEM_POWER_DROPDOWN = ['delegate', 'power_down']; @@ -235,10 +235,16 @@ const WalletContainer = ({ const _navigate = async (transferType, fundType) => { let balance; - if (transferType === 'transfer_token' && fundType === 'STEEM') { + if ( + (transferType === 'transfer_token' || transferType === 'purchase_estm') && + fundType === 'STEEM' + ) { balance = Math.round(walletData.balance * 1000) / 1000; } - if (transferType === 'transfer_token' && fundType === 'SBD') { + if ( + (transferType === 'transfer_token' || transferType === 'purchase_estm') && + fundType === 'SBD' + ) { balance = Math.round(walletData.sbdBalance * 1000) / 1000; } if (transferType === 'withdraw_steem' && fundType === 'STEEM') { diff --git a/src/containers/transferContainer.js b/src/containers/transferContainer.js index 0b1106ab9..6252b0f2b 100644 --- a/src/containers/transferContainer.js +++ b/src/containers/transferContainer.js @@ -70,10 +70,16 @@ class TransferContainer extends Component { getAccount(username).then(async account => { let balance; - if (transferType === 'transfer_token' && fundType === 'STEEM') { + if ( + (transferType === 'purchase_estm' || transferType === 'transfer_token') && + fundType === 'STEEM' + ) { balance = account[0].balance.replace(fundType, ''); } - if (transferType === 'transfer_token' && fundType === 'SBD') { + if ( + (transferType === 'purchase_estm' || transferType === 'transfer_token') && + fundType === 'SBD' + ) { balance = account[0].sbd_balance.replace(fundType, ''); } if (transferType === 'points' && fundType === 'ESTM') { @@ -132,6 +138,9 @@ class TransferContainer extends Component { case 'transfer_token': func = transferToken; break; + case 'purchase_estm': + func = transferToken; + break; case 'transfer_to_saving': func = transferToSavings; break; diff --git a/src/screens/transfer/index.js b/src/screens/transfer/index.js index 8481556fe..ce6d1c57b 100644 --- a/src/screens/transfer/index.js +++ b/src/screens/transfer/index.js @@ -25,6 +25,7 @@ const Transfer = ({ navigation }) => ( }) => { switch (transferType) { case 'transfer_token': + case 'purchase_estm': case 'transfer_to_saving': case 'powerUp': case 'points': diff --git a/src/screens/transfer/screen/transferScreen.js b/src/screens/transfer/screen/transferScreen.js index f6405a8d3..1a816fd94 100644 --- a/src/screens/transfer/screen/transferScreen.js +++ b/src/screens/transfer/screen/transferScreen.js @@ -36,10 +36,13 @@ class TransferView extends Component { props.transferType === 'withdraw_steem' || props.transferType === 'withdraw_steem' ? props.currentAccountName + : props.transferType === 'purchase_estm' + ? 'esteem.app' : '', amount: '', - memo: '', + memo: props.transferType === 'purchase_estm' ? 'estm-purchase' : '', isUsernameValid: !!( + props.transferType === 'purchase_estm' || props.transferType === 'powerUp' || props.transferType === 'withdraw_steem' || (props.transferType === 'withdraw_steem' && props.currentAccountName) @@ -226,7 +229,9 @@ class TransferView extends Component { )} /> - {(transferType === 'points' || transferType === 'transfer_token') && ( + {(transferType === 'points' || + transferType === 'transfer_token' || + transferType === 'purchase_estm') && ( @@ -239,7 +244,9 @@ class TransferView extends Component { } /> )} - {(transferType === 'points' || transferType === 'transfer_token') && ( + {(transferType === 'points' || + transferType === 'transfer_token' || + transferType === 'purchase_estm') && ( this._renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' }))