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) => {
const pin = getDigitPinCode(pinCode);
const key = getActiveKey(get(currentAccount, 'local'), pin);
const digitPinCode = getDigitPinCode(pinCode);
const key = getActiveKey(get(currentAccount, 'local'), digitPinCode);
const username = get(currentAccount, 'name');
const json = JSON.stringify([
@ -1883,16 +1883,24 @@ export const subscribeCommunity = (currentAccount, pinCode, data) => {
{ 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) {
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);
}
@ -1909,8 +1917,8 @@ export const pinCommunityPost = (
permlink,
unpinPost = false,
) => {
const pin = getDigitPinCode(pinCode);
const key = getActiveKey(get(currentAccount, 'local'), pin);
const digitPinCode = getDigitPinCode(pinCode);
const key = getActiveKey(get(currentAccount, 'local'), digitPinCode);
const username = get(currentAccount, 'name');
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) {
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);
}

View File

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

View File

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

View File

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