Merge remote-tracking branch 'upstream/development' into nt/navigation

This commit is contained in:
Nouman Tahir 2022-08-18 16:49:45 +05:00
commit bbbb2ce3b7
4 changed files with 75 additions and 60 deletions

View File

@ -1874,8 +1874,8 @@ export const profileUpdate = async (params, pin, currentAccount) => {
}; };
export const subscribeCommunity = (currentAccount, pinCode, data) => { export const subscribeCommunity = (currentAccount, pinCode, data) => {
const pin = getDigitPinCode(pinCode); const digitPinCode = getDigitPinCode(pinCode);
const key = getActiveKey(get(currentAccount, 'local'), pin); const key = getActiveKey(get(currentAccount, 'local'), digitPinCode);
const username = get(currentAccount, 'name'); const username = get(currentAccount, 'name');
const json = JSON.stringify([ const json = JSON.stringify([
@ -1883,16 +1883,24 @@ export const subscribeCommunity = (currentAccount, pinCode, data) => {
{ community: data.communityId }, { community: data.communityId },
]); ]);
const op = {
id: 'community',
json,
required_auths: [],
required_posting_auths: [username],
};
const opArray = [['custom_json', op]];
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
const token = decryptKey(currentAccount.local.accessToken, digitPinCode);
const api = new hsClient({
accessToken: token,
});
return api.broadcast(opArray);
}
if (key) { if (key) {
const privateKey = PrivateKey.fromString(key); const privateKey = PrivateKey.fromString(key);
const op = {
id: 'community',
json,
required_auths: [],
required_posting_auths: [username],
};
const opArray = [['custom_json', op]];
return sendHiveOperations(opArray, privateKey); return sendHiveOperations(opArray, privateKey);
} }
@ -1909,8 +1917,8 @@ export const pinCommunityPost = (
permlink, permlink,
unpinPost = false, unpinPost = false,
) => { ) => {
const pin = getDigitPinCode(pinCode); const digitPinCode = getDigitPinCode(pinCode);
const key = getActiveKey(get(currentAccount, 'local'), pin); const key = getActiveKey(get(currentAccount, 'local'), digitPinCode);
const username = get(currentAccount, 'name'); const username = get(currentAccount, 'name');
const json = JSON.stringify([ const json = JSON.stringify([
@ -1922,16 +1930,24 @@ export const pinCommunityPost = (
}, },
]); ]);
const op = {
id: 'community',
json,
required_auths: [],
required_posting_auths: [username],
};
const opArray = [['custom_json', op]];
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
const token = decryptKey(currentAccount.local.accessToken, digitPinCode);
const api = new hsClient({
accessToken: token,
});
return api.broadcast(opArray);
}
if (key) { if (key) {
const privateKey = PrivateKey.fromString(key); const privateKey = PrivateKey.fromString(key);
const op = {
id: 'community',
json,
required_auths: [],
required_posting_auths: [username],
};
const opArray = [['custom_json', op]];
return sendHiveOperations(opArray, privateKey); return sendHiveOperations(opArray, privateKey);
} }

View File

@ -74,11 +74,11 @@ const ProfileScreen = () => (
isProfileLoading={isProfileLoading} isProfileLoading={isProfileLoading}
isReady={isReady} isReady={isReady}
quickProfile={quickProfile} quickProfile={quickProfile}
resourceCredits={resourceCredits} resourceCredits={resourceCredits || 0}
selectedUser={selectedUser} selectedUser={selectedUser}
setEstimatedWalletValue={setEstimatedWalletValue} setEstimatedWalletValue={setEstimatedWalletValue}
username={username} username={username}
votingPower={votingPower} votingPower={votingPower || 0}
isHideImage={isHideImage} isHideImage={isHideImage}
reverseHeader={reverseHeader} reverseHeader={reverseHeader}
deepLinkFilter={deepLinkFilter} deepLinkFilter={deepLinkFilter}

View File

@ -25,7 +25,7 @@ import {
} from '../../../components'; } from '../../../components';
// Styles // Styles
import styles from './transferStyles'; import styles from './transferStyles';
import { OptionsModal } from '../../../components/atoms';
// Redux // Redux
import { showActionModal } from '../../../redux/actions/uiAction'; import { showActionModal } from '../../../redux/actions/uiAction';
// Utils // Utils
@ -63,9 +63,9 @@ class DelegateScreen extends Component {
usersResult: [], usersResult: [],
step: 1, step: 1,
delegatedHP: 0, delegatedHP: 0,
confirmModalOpen: true,
}; };
this.startActionSheet = React.createRef();
this.destinationTextInput = React.createRef(); this.destinationTextInput = React.createRef();
this.amountTextInput = React.createRef(); this.amountTextInput = React.createRef();
} }
@ -144,11 +144,10 @@ class DelegateScreen extends Component {
const { transferToAccount, accountType } = this.props; const { transferToAccount, accountType } = this.props;
const { from, destination, amount } = this.state; const { from, destination, amount } = this.state;
this.setState({ isTransfering: true });
if (accountType === AUTH_TYPE.STEEM_CONNECT) { if (accountType === AUTH_TYPE.STEEM_CONNECT) {
this.setState({ steemConnectTransfer: true }); this.setState({ steemConnectTransfer: true });
} else { } else {
this.setState({ isTransfering: true });
transferToAccount(from, destination, amount, ''); transferToAccount(from, destination, amount, '');
} }
}; };
@ -254,6 +253,7 @@ class DelegateScreen extends Component {
: ''); : '');
if (amountValid) { if (amountValid) {
this.setState({ confirmModalOpen: true });
dispatch( dispatch(
showActionModal({ showActionModal({
title: intl.formatMessage({ id: 'transfer.confirm' }), title: intl.formatMessage({ id: 'transfer.confirm' }),
@ -269,6 +269,7 @@ class DelegateScreen extends Component {
}, },
], ],
headerContent: this._renderToFromAvatars(), headerContent: this._renderToFromAvatars(),
onClosed: () => this.setState({ confirmModalOpen: false }),
}), }),
); );
} else { } else {
@ -447,6 +448,7 @@ class DelegateScreen extends Component {
step, step,
delegatedHP, delegatedHP,
hp, hp,
confirmModalOpen,
isAmountValid, isAmountValid,
} = this.state; } = this.state;
let availableVestingShares = 0; let availableVestingShares = 0;
@ -588,26 +590,18 @@ class DelegateScreen extends Component {
</View> </View>
</ScrollView> </ScrollView>
</KeyboardAvoidingView> </KeyboardAvoidingView>
<OptionsModal
ref={this.startActionSheet} {path && !confirmModalOpen && (
options={[ <Modal
intl.formatMessage({ id: 'alert.confirm' }), isOpen={steemConnectTransfer}
intl.formatMessage({ id: 'alert.cancel' }), isFullScreen
]} isCloseButton
title={intl.formatMessage({ id: 'transfer.information' })} handleOnModalClose={handleOnModalClose}
cancelButtonIndex={1} title={intl.formatMessage({ id: 'transfer.steemconnect_title' })}
destructiveButtonIndex={0} >
onPress={(index) => (index === 0 ? this._handleTransferAction() : null)} <WebView source={{ uri: `${hsOptions.base_url}${path}` }} />
/> </Modal>
<Modal )}
isOpen={steemConnectTransfer}
isFullScreen
isCloseButton
handleOnModalClose={handleOnModalClose}
title={intl.formatMessage({ id: 'transfer.steemconnect_title' })}
>
<WebView source={{ uri: `${hsOptions.base_url}${path}` }} />
</Modal>
</Fragment> </Fragment>
); );
} }

View File

@ -75,20 +75,25 @@ const TransferView = ({
let path; let path;
if (hsTransfer) { if (hsTransfer) {
if (transferType !== transferTypes.CONVERT) { //NOTE: Keepping point purchase url here for referemnce in case we have to put it back again,
const json = JSON.stringify({ //the path formatting seems quite complex so perhaps it's better to just let it live here
sender: get(selectedAccount, 'name'), //as comment
receiver: destination, // if (transferType === transferTypes.PURCHASE_ESTM) {
amount: `${Number(amount).toFixed(3)} ${fundType}`, // const json = JSON.stringify({
memo, // sender: get(selectedAccount, 'name'),
}); // receiver: destination,
path = `sign/custom-json?authority=active&required_auths=%5B%22${get( // amount: `${Number(amount).toFixed(3)} ${fundType}`,
selectedAccount, // memo,
'name', // });
)}%22%5D&required_posting_auths=%5B%5D&id=ecency_point_transfer&json=${encodeURIComponent( // path = `sign/custom-json?authority=active&required_auths=%5B%22${get(
json, // selectedAccount,
)}`; // 'name',
} else if (transferType === transferTypes.TRANSFER_TO_SAVINGS) { // )}%22%5D&required_posting_auths=%5B%5D&id=ecency_point_transfer&json=${encodeURIComponent(
// json,
// )}`;
// } else
if (transferType === transferTypes.TRANSFER_TO_SAVINGS) {
path = `sign/transfer_to_savings?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent( path = `sign/transfer_to_savings?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent(
`${amount} ${fundType}`, `${amount} ${fundType}`,
)}&memo=${encodeURIComponent(memo)}`; )}&memo=${encodeURIComponent(memo)}`;