wip on transfer func

This commit is contained in:
u-e 2019-06-14 01:04:42 +03:00
parent 792f85795b
commit f11020a2c4
6 changed files with 54 additions and 7 deletions

View File

@ -62,11 +62,16 @@ class PointsContainer extends Component {
_handleOnPressTransfer = () => {
const { dispatch } = this.props;
const { userPoints } = this.state;
dispatch(
openPinCodeModal({
navigateTo: ROUTES.SCREENS.TRANSFER,
navigateParams: { transferType: '', fundType: '', balance: '' },
navigateParams: {
transferType: 'points',
fundType: 'ESTM',
balance: Math.round(get(userPoints, 'points') * 1000) / 1000,
},
}),
);
};

View File

@ -283,6 +283,7 @@
"to_placeholder": "Username",
"memo_placeholder": "Enter your notes here",
"transfer_token": "Transfer",
"points": "Points Transfer",
"transfer_to_saving": "Transfer To Saving",
"powerUp": "Power Up",
"withdraw_to_saving": "Withdraw To Saving",

View File

@ -1,6 +1,12 @@
import { Alert } from 'react-native';
import { Client, PrivateKey } from 'dsteem';
import ePointApi from '../../config/ePoint';
// Utils
import { decryptKey } from '../../utils/crypto';
const client = new Client(getItem('server', 'https://api.steemit.com'));
export const userActivity = (us, ty, bl = '', tx = '') =>
new Promise(resolve => {
const params = { us, ty };
@ -39,6 +45,35 @@ export const transfer = (sender, receiver, amount) =>
});
});
export const transferPoint = (account, pin, to, amount, memo) => {
const { username: from } = account;
const json = JSON.stringify({
sender: from,
receiver: to,
amount,
memo,
});
if (account.type === 's' || true) {
const key = decryptKey(account.keys.active, pin);
const privateKey = PrivateKey.fromString(key);
const op = {
id: 'esteem_point_transfer',
json,
required_auths: [from],
required_posting_auths: [],
};
return Client.broadcast.json(op, privateKey);
}
if (account.type === 'sc') {
return sctTransferPoint(from, json);
}
};
export const getUser = username =>
new Promise(resolve => {
ePointApi

View File

@ -514,7 +514,7 @@ export const upvoteAmount = async input => {
return estimated;
};
export const transfer_token = (currentAccount, pin, data) => {
export const transferToken = (currentAccount, pin, data) => {
const digitPinCode = getDigitPinCode(pin);
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
@ -545,7 +545,7 @@ export const transfer_token = (currentAccount, pin, data) => {
return Promise.reject(new Error('You dont have permission!'));
};
export const transfer_to_savings = (currentAccount, pin, data) => {
export const transferToSavings = (currentAccount, pin, data) => {
const digitPinCode = getDigitPinCode(pin);
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);

View File

@ -5,9 +5,9 @@ import { injectIntl } from 'react-intl';
// Services and Actions
import {
lookupAccounts,
transfer_token,
transferToken,
transferFromSavings,
transfer_to_savings,
transferToSavings,
transferToVesting,
getAccount,
} from '../../../providers/steem/dsteem';
@ -55,6 +55,9 @@ class TransferContainer extends Component {
case 'SBD':
balance = account[0].sbd_balance.replace(fundType, '');
break;
case 'ESTM':
balance = navigation.getParam('balance', '');
break;
default:
break;
}
@ -90,10 +93,10 @@ class TransferContainer extends Component {
switch (transferType) {
case 'transfer_token':
func = transfer_token;
func = transferToken;
break;
case 'transfer_to_saving':
func = transfer_to_savings;
func = transferToSavings;
break;
case 'powerUp':
func = transferToVesting;
@ -102,6 +105,9 @@ class TransferContainer extends Component {
func = transferFromSavings;
data.requestId = new Date().getTime() >>> 0;
break;
case 'points':
alert('sss');
break;
default:
break;

0
src/utils/points.js Normal file
View File