mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 10:52:16 +03:00
wip on transfer func
This commit is contained in:
parent
792f85795b
commit
f11020a2c4
@ -62,11 +62,16 @@ class PointsContainer extends Component {
|
|||||||
|
|
||||||
_handleOnPressTransfer = () => {
|
_handleOnPressTransfer = () => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
const { userPoints } = this.state;
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
openPinCodeModal({
|
openPinCodeModal({
|
||||||
navigateTo: ROUTES.SCREENS.TRANSFER,
|
navigateTo: ROUTES.SCREENS.TRANSFER,
|
||||||
navigateParams: { transferType: '', fundType: '', balance: '' },
|
navigateParams: {
|
||||||
|
transferType: 'points',
|
||||||
|
fundType: 'ESTM',
|
||||||
|
balance: Math.round(get(userPoints, 'points') * 1000) / 1000,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -283,6 +283,7 @@
|
|||||||
"to_placeholder": "Username",
|
"to_placeholder": "Username",
|
||||||
"memo_placeholder": "Enter your notes here",
|
"memo_placeholder": "Enter your notes here",
|
||||||
"transfer_token": "Transfer",
|
"transfer_token": "Transfer",
|
||||||
|
"points": "Points Transfer",
|
||||||
"transfer_to_saving": "Transfer To Saving",
|
"transfer_to_saving": "Transfer To Saving",
|
||||||
"powerUp": "Power Up",
|
"powerUp": "Power Up",
|
||||||
"withdraw_to_saving": "Withdraw To Saving",
|
"withdraw_to_saving": "Withdraw To Saving",
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import { Alert } from 'react-native';
|
import { Alert } from 'react-native';
|
||||||
|
import { Client, PrivateKey } from 'dsteem';
|
||||||
import ePointApi from '../../config/ePoint';
|
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 = '') =>
|
export const userActivity = (us, ty, bl = '', tx = '') =>
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
const params = { us, ty };
|
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 =>
|
export const getUser = username =>
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
ePointApi
|
ePointApi
|
||||||
|
@ -514,7 +514,7 @@ export const upvoteAmount = async input => {
|
|||||||
return estimated;
|
return estimated;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const transfer_token = (currentAccount, pin, data) => {
|
export const transferToken = (currentAccount, pin, data) => {
|
||||||
const digitPinCode = getDigitPinCode(pin);
|
const digitPinCode = getDigitPinCode(pin);
|
||||||
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
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!'));
|
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 digitPinCode = getDigitPinCode(pin);
|
||||||
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import { injectIntl } from 'react-intl';
|
|||||||
// Services and Actions
|
// Services and Actions
|
||||||
import {
|
import {
|
||||||
lookupAccounts,
|
lookupAccounts,
|
||||||
transfer_token,
|
transferToken,
|
||||||
transferFromSavings,
|
transferFromSavings,
|
||||||
transfer_to_savings,
|
transferToSavings,
|
||||||
transferToVesting,
|
transferToVesting,
|
||||||
getAccount,
|
getAccount,
|
||||||
} from '../../../providers/steem/dsteem';
|
} from '../../../providers/steem/dsteem';
|
||||||
@ -55,6 +55,9 @@ class TransferContainer extends Component {
|
|||||||
case 'SBD':
|
case 'SBD':
|
||||||
balance = account[0].sbd_balance.replace(fundType, '');
|
balance = account[0].sbd_balance.replace(fundType, '');
|
||||||
break;
|
break;
|
||||||
|
case 'ESTM':
|
||||||
|
balance = navigation.getParam('balance', '');
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -90,10 +93,10 @@ class TransferContainer extends Component {
|
|||||||
|
|
||||||
switch (transferType) {
|
switch (transferType) {
|
||||||
case 'transfer_token':
|
case 'transfer_token':
|
||||||
func = transfer_token;
|
func = transferToken;
|
||||||
break;
|
break;
|
||||||
case 'transfer_to_saving':
|
case 'transfer_to_saving':
|
||||||
func = transfer_to_savings;
|
func = transferToSavings;
|
||||||
break;
|
break;
|
||||||
case 'powerUp':
|
case 'powerUp':
|
||||||
func = transferToVesting;
|
func = transferToVesting;
|
||||||
@ -102,6 +105,9 @@ class TransferContainer extends Component {
|
|||||||
func = transferFromSavings;
|
func = transferFromSavings;
|
||||||
data.requestId = new Date().getTime() >>> 0;
|
data.requestId = new Date().getTime() >>> 0;
|
||||||
break;
|
break;
|
||||||
|
case 'points':
|
||||||
|
alert('sss');
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
0
src/utils/points.js
Normal file
0
src/utils/points.js
Normal file
Loading…
Reference in New Issue
Block a user