diff --git a/src/components/wallet/container/walletContainer.js b/src/components/wallet/container/walletContainer.js
index 4a42f104e..b9167bcda 100644
--- a/src/components/wallet/container/walletContainer.js
+++ b/src/components/wallet/container/walletContainer.js
@@ -138,7 +138,9 @@ class WalletContainer extends Component {
};
render() {
- const { currentAccount, selectedUser, isDarkTheme } = this.props;
+ const {
+ currentAccount, selectedUser, isDarkTheme, setPinCodeState,
+ } = this.props;
const { walletData, isClaiming, isRefreshing } = this.state;
return (
@@ -151,6 +153,7 @@ class WalletContainer extends Component {
handleOnWalletRefresh={this._handleOnWalletRefresh}
isRefreshing={isRefreshing}
isDarkTheme={isDarkTheme}
+ setPinCodeState={setPinCodeState}
/>
);
}
diff --git a/src/components/wallet/view/walletView.js b/src/components/wallet/view/walletView.js
index 772c1380b..9f96b5b06 100644
--- a/src/components/wallet/view/walletView.js
+++ b/src/components/wallet/view/walletView.js
@@ -55,6 +55,7 @@ class WalletView extends PureComponent {
selectedUsername,
walletData,
isDarkTheme,
+ setPinCodeState,
} = this.props;
return (
@@ -113,7 +114,11 @@ class WalletView extends PureComponent {
})}
expanded
>
-
+
diff --git a/src/components/walletDetails/container/walletDetailsContainer.js b/src/components/walletDetails/container/walletDetailsContainer.js
index 163f18f26..da03ff365 100644
--- a/src/components/walletDetails/container/walletDetailsContainer.js
+++ b/src/components/walletDetails/container/walletDetailsContainer.js
@@ -1,9 +1,12 @@
import React, { PureComponent } from 'react';
import { withNavigation } from 'react-navigation';
+import { connect } from 'react-redux';
// Constants
import ROUTES from '../../../constants/routeNames';
+import { openPinCodeModal } from '../../../redux/actions/applicationActions';
+
// Component
import WalletDetailsView from '../view/walletDetailsView';
@@ -24,11 +27,10 @@ class WalletContainer extends PureComponent {
// Component Functions
_navigate = () => {
- const { navigation } = this.props;
- console.log('navigation :', navigation);
- navigation.navigate({
- routeName: ROUTES.SCREENS.TRANSFER,
- });
+ const { dispatch, setPinCodeState } = this.props;
+
+ setPinCodeState({ navigateTo: ROUTES.SCREENS.TRANSFER });
+ dispatch(openPinCodeModal());
};
render() {
@@ -38,4 +40,4 @@ class WalletContainer extends PureComponent {
}
}
-export default withNavigation(WalletContainer);
+export default connect()(withNavigation(WalletContainer));
diff --git a/src/providers/steem/dsteem.js b/src/providers/steem/dsteem.js
index 695349c97..174c2fb99 100644
--- a/src/providers/steem/dsteem.js
+++ b/src/providers/steem/dsteem.js
@@ -388,13 +388,10 @@ export const getPostWithComments = async (user, permlink) => {
* @param postingKey private posting key
*/
-export const vote = (account, pin, author, permlink, weight) => _vote(
- account, pin, author, permlink, weight,
-)
- .then((resp) => {
- userActivity(account.username, 120, resp.block_num, resp.id);
- return resp;
- });
+export const vote = (account, pin, author, permlink, weight) => _vote(account, pin, author, permlink, weight).then((resp) => {
+ userActivity(account.username, 120, resp.block_num, resp.id);
+ return resp;
+});
const _vote = async (currentAccount, pin, author, permlink, weight) => {
const digitPinCode = getDigitPinCode(pin);
@@ -462,18 +459,69 @@ export const upvoteAmount = async (input) => {
return estimated;
};
-export const transferToken = (data, activeKey) => {
- const key = PrivateKey.fromString(activeKey);
- return new Promise((resolve, reject) => {
- client.broadcast
- .transfer(data, key)
- .then((result) => {
- resolve(result);
- })
- .catch((err) => {
- reject(err);
- });
- });
+export const transferToken = (currentAccount, pin, data) => {
+ const digitPinCode = getDigitPinCode(pin);
+ const key = getAnyPrivateKey({ activeKey: currentAccount.local.activeKey }, digitPinCode);
+
+ if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
+ const token = decryptKey(currentAccount.local.accessToken, digitPinCode);
+ console.log('currentAccount.local :', currentAccount.local);
+ console.log('token :', token);
+ const api = steemConnect.Initialize({
+ accessToken: token,
+ });
+ console.log('api :', api);
+ const opArr = [];
+
+ const e = [
+ 'transfer',
+ {
+ from: data.from,
+ to: data.destination,
+ amount: {
+ amount: data.amount,
+ precision: 3,
+ nai: '@@000000021',
+ },
+ memo: 'Thanks for all the fish.',
+ },
+ ];
+ opArr.push(e);
+ console.log('opArr :', opArr);
+ api
+ .broadcast(opArr)
+ .then(res => console.log('res1111111 :', res))
+ .catch(err => console.log('err1111111 :', Object.keys(err), err.name, err.error, err.error_description));
+
+ return api.broadcast(opArr);
+ }
+
+ if (key) {
+ const privateKey = PrivateKey.fromString(key);
+ const args = {
+ from: data.from,
+ to: data.destination,
+ amount: `${data.amount} STEEM`,
+ memo: data.memo,
+ };
+
+ console.log('args :', args);
+ console.log('privateKey :', privateKey);
+ console.log('key :', key);
+
+ return new Promise((resolve, reject) => {
+ client.broadcast
+ .transfer(args, privateKey)
+ .then((result) => {
+ resolve(result);
+ })
+ .catch((err) => {
+ reject(err);
+ });
+ });
+ }
+
+ return Promise.reject(new Error('You dont have permission!'));
};
export const followUser = async (currentAccount, pin, data) => {
@@ -786,9 +834,7 @@ const _postContent = async (
// Re-blog
// TODO: remove pinCode
-export const reblog = (account, pinCode, author, permlink) => _reblog(
- account, pinCode, author, permlink,
-).then((resp) => {
+export const reblog = (account, pinCode, author, permlink) => _reblog(account, pinCode, author, permlink).then((resp) => {
userActivity(account.name, 130, resp.block_num, resp.id);
return resp;
});
@@ -874,7 +920,7 @@ const getAnyPrivateKey = (local, pin) => {
}
if (activeKey) {
- return decryptKey(local.postingKey, pin);
+ return decryptKey(local.activeKey, pin);
}
return false;
diff --git a/src/screens/profile/container/profileContainer.js b/src/screens/profile/container/profileContainer.js
index 00f2460ae..36276adce 100644
--- a/src/screens/profile/container/profileContainer.js
+++ b/src/screens/profile/container/profileContainer.js
@@ -76,10 +76,7 @@ class ProfileContainer extends Component {
componentWillReceiveProps(nextProps) {
const {
- navigation,
- currentAccount,
- activeBottomTab,
- isLoggedIn,
+ navigation, currentAccount, activeBottomTab, isLoggedIn,
} = this.props;
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name;
@@ -201,19 +198,19 @@ class ProfileContainer extends Component {
const { username } = this.state;
if (error) {
- this.setState({
- error,
- }, () => alert(error));
+ this.setState(
+ {
+ error,
+ },
+ () => alert(error),
+ );
} else {
this._fetchProfile(username, true);
}
};
-
_fetchProfile = async (username = null, isProfileAction = false) => {
- const {
- username: _username, isFollowing, isMuted,
- } = this.state;
+ const { username: _username, isFollowing, isMuted } = this.state;
if (username) {
const { isLoggedIn, currentAccount } = this.props;
@@ -239,9 +236,9 @@ class ProfileContainer extends Component {
}
/**
- * This follow code totally a work arround
- * Ceated for server response delay.
- */
+ * This follow code totally a work arround
+ * Ceated for server response delay.
+ */
if (isProfileAction && (isFollowing === _isFollowing && isMuted === _isMuted)) {
this._fetchProfile(_username, true);
} else {
@@ -355,7 +352,7 @@ class ProfileContainer extends Component {
username,
} = this.state;
const {
- isDarkTheme, isLoggedIn, currency, navigation,
+ isDarkTheme, isLoggedIn, currency, navigation, setPinCodeState,
} = this.props;
const activePage = (navigation.state.params && navigation.state.params.activePage) || 0;
@@ -385,6 +382,7 @@ class ProfileContainer extends Component {
selectedQuickProfile={selectedQuickProfile}
selectedUser={user}
username={username}
+ setPinCodeState={setPinCodeState}
/>
);
}
diff --git a/src/screens/profile/screen/profileScreen.js b/src/screens/profile/screen/profileScreen.js
index 19b065418..2f4cd63bf 100644
--- a/src/screens/profile/screen/profileScreen.js
+++ b/src/screens/profile/screen/profileScreen.js
@@ -84,6 +84,7 @@ class ProfileScreen extends PureComponent {
selectedUser,
username,
activePage,
+ setPinCodeState,
} = this.props;
const {
@@ -249,6 +250,7 @@ class ProfileScreen extends PureComponent {
) : (
diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js
index 3ca60a266..d5ec992d4 100644
--- a/src/screens/settings/container/settingsContainer.js
+++ b/src/screens/settings/container/settingsContainer.js
@@ -12,9 +12,7 @@ import {
setCurrency as setCurrency2DB,
setServer,
setNotificationSettings,
- setDefaultFooter,
setLanguage as setLanguage2DB,
- setNotificationIsOpen,
setNsfw as setNsfw2DB,
setTheme,
} from '../../../realm/realm';
@@ -27,7 +25,6 @@ import {
setApi,
isDarkTheme,
isDefaultFooter,
- isNotificationOpen,
openPinCodeModal,
setNsfw,
} from '../../../redux/actions/applicationActions';
diff --git a/src/screens/transfer/container/transferContainer.js b/src/screens/transfer/container/transferContainer.js
index 45d8c0984..797b345b9 100644
--- a/src/screens/transfer/container/transferContainer.js
+++ b/src/screens/transfer/container/transferContainer.js
@@ -2,7 +2,8 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
// Services and Actions
-import { lookupAccounts } from '../../../providers/steem/dsteem';
+import { lookupAccounts, transferToken } from '../../../providers/steem/dsteem';
+import { toastNotification } from '../../../redux/actions/uiAction';
// Middleware
@@ -34,7 +35,23 @@ class ExampleContainer extends Component {
};
_transferToAccount = (from, destination, amount, memo) => {
- console.log('from, destination, amount, memo, :', from, destination, amount, memo);
+ const {
+ currentAccount, pinCode, navigation, dispatch,
+ } = this.props;
+
+ const data = {
+ from,
+ destination,
+ amount,
+ memo,
+ };
+
+ transferToken(currentAccount, pinCode, data)
+ .then((res) => {
+ dispatch(toastNotification('Successfull'));
+ navigation.goBack();
+ })
+ .catch(err => dispatch(toastNotification(err)));
};
render() {
@@ -52,6 +69,8 @@ class ExampleContainer extends Component {
const mapStateToProps = state => ({
accounts: state.account.otherAccounts,
+ currentAccount: state.account.currentAccount,
+ pinCode: state.account.pin,
});
export default connect(mapStateToProps)(ExampleContainer);