Working on transfer feature

This commit is contained in:
Mustafa Buyukcelebi 2019-04-24 11:41:01 +03:00
parent 215368e888
commit 35864aea09
7 changed files with 33 additions and 31 deletions

View File

@ -52,6 +52,8 @@ class TransactionView extends PureComponent {
{transactions
&& transactions.map((item, index) => {
const transactionData = groomingTransactionData(item, steemPerMVests, formatNumber);
if (transactionData.length === 0) return null;
const value = transactionData.value.split(' ');
return (

View File

@ -26,16 +26,21 @@ class WalletContainer extends PureComponent {
// Component Life Cycle Functions
// Component Functions
_navigate = () => {
const { dispatch, setPinCodeState, navigation } = this.props;
_navigate = (a,b) => {
const { dispatch, setPinCodeState } = this.props;
navigation.navigate(ROUTES.SCREENS.TRANSFER, {
transferType: 'transferToSaving',
fundType: 'STEEM',
// navigation.navigate(ROUTES.SCREENS.TRANSFER, {
// transferType: 'withdrawToSaving',
// fundType: 'STEEM',
// });
console.log('a,b :', a,b);
setPinCodeState({
navigateTo: ROUTES.SCREENS.TRANSFER,
navigateParams: { transferType: 'transferToken', fundType: 'STEEM' },
});
// setPinCodeState({ navigateTo: ROUTES.SCREENS.TRANSFER, navigateParams: {transferType: 'sbd'} });
// dispatch(openPinCodeModal());
dispatch(openPinCodeModal());
};
render() {

View File

@ -40,7 +40,7 @@ class WalletDetailsView extends PureComponent {
isBoldText
dropdown
dropdownOptions={['Transfer']}
onDropdownSelect={test => navigate()}
onDropdownSelect={(a,b) => navigate(a,b)}
/>
<GrayWrapper isGray>
<WalletLineItem

View File

@ -544,7 +544,8 @@ export const transferToSavings = (currentAccount, pin, data) => {
if (key) {
const privateKey = PrivateKey.fromString(key);
const args = [
const args = [[
'transfer_to_savings',
{
from: data.from,
@ -552,9 +553,7 @@ export const transferToSavings = (currentAccount, pin, data) => {
amount: data.amount,
memo: data.memo,
},
];
console.log('args :', args);
]];
return new Promise((resolve, reject) => {
client.broadcast
@ -577,7 +576,7 @@ export const transferFromSavings = (currentAccount, pin, data) => {
if (key) {
const privateKey = PrivateKey.fromString(key);
const args = [
const args = [[
'transfer_from_savings',
{
from: data.from,
@ -586,7 +585,7 @@ export const transferFromSavings = (currentAccount, pin, data) => {
memo: data.memo,
request_id: data.requestId,
},
];
]];
return new Promise((resolve, reject) => {
client.broadcast
@ -609,14 +608,14 @@ export const transferToVesting = (currentAccount, pin, data) => {
if (key) {
const privateKey = PrivateKey.fromString(key);
const args = [
const args = [[
'transfer_to_vesting',
{
from: data.from,
to: data.destination,
amount: data.amount,
},
];
]];
return new Promise((resolve, reject) => {
client.broadcast

View File

@ -80,7 +80,7 @@ class PinCodeContainer extends Component {
_resetPinCode = pin => new Promise((resolve, reject) => {
const {
currentAccount, dispatch, accessToken, navigateTo, navigation, intl,
currentAccount, dispatch, accessToken, navigateTo, navigateParams, navigation, intl,
} = this.props;
const { isOldPinVerified, oldPinCode } = this.state;
@ -102,7 +102,7 @@ class PinCodeContainer extends Component {
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
navigation.navigate(navigateTo, navigateParams);
}
resolve();
});
@ -135,7 +135,7 @@ class PinCodeContainer extends Component {
_setFirstPinCode = pin => new Promise((resolve) => {
const {
currentAccount, dispatch, accessToken, navigateTo, navigation,
currentAccount, dispatch, accessToken, navigateTo, navigateParams, navigation,
} = this.props;
const pinData = {
@ -155,7 +155,7 @@ class PinCodeContainer extends Component {
this._savePinCode(pin);
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
navigation.navigate(navigateTo, navigateParams);
}
resolve();
});
@ -165,7 +165,7 @@ class PinCodeContainer extends Component {
_verifyPinCode = pin => new Promise((resolve, reject) => {
const {
currentAccount, dispatch, accessToken, navigateTo, navigation, intl,
currentAccount, dispatch, accessToken, navigateTo, navigateParams, navigation, intl,
} = this.props;
// If the user is exist, we are just checking to pin and navigating to home screen
@ -184,8 +184,9 @@ class PinCodeContainer extends Component {
[_currentAccount.local] = realmData;
dispatch(updateCurrentAccount({ ..._currentAccount }));
dispatch(closePinCodeModal());
console.log('navigateParams :', navigateParams);
if (navigateTo) {
navigation.navigate(navigateTo);
navigation.navigate(navigateTo, navigateParams);
}
})
.catch((err) => {

View File

@ -55,15 +55,14 @@ class ExampleContainer extends Component {
amount,
memo,
};
data.amount = `${data.amount} ${fundType}`;
switch (transferType) {
case 'transferToken':
func = transferToken;
data.amount = `${data.amount} ${fundType}`;
break;
case 'transferToSaving':
func = transferToSavings;
data.amount = `${data.amount} ${fundType}`;
break;
case 'powerUp':
func = transferToVesting;
@ -71,22 +70,18 @@ class ExampleContainer extends Component {
case 'withdrawToSaving':
func = transferFromSavings;
data.requestId = new Date().getTime() >>> 0;
data.amount = `${data.amount} ${fundType}`;
break;
default:
break;
}
console.log('func :', func);
return func(currentAccount, pinCode, data)
.then((res) => {
console.log('res :', res);
.then(() => {
dispatch(toastNotification('Successfull'));
navigation.goBack();
})
.catch((err) => {
console.log('err :', err);
dispatch(toastNotification(err.message));
});
};

View File

@ -95,7 +95,7 @@ export const groomingTransactionData = (transaction, steemPerMVests, formatNumbe
result.icon = 'reorder';
break;
default:
break;
return [];
}
return result;
};