From 645ad407c64b380cc825c55475e94acf0314a069 Mon Sep 17 00:00:00 2001 From: Young Leo Date: Tue, 18 Dec 2018 17:04:52 +0800 Subject: [PATCH] fix translations && add new dapp action type --- ios/bitportal/Info.plist | 2 +- .../components/ActionModal/WhiteListTips.jsx | 2 +- .../components/ActionModal/index.native.jsx | 3 +- .../components/DappWebView/index.native.jsx | 4 +- shared/resources/messages/en/messages.json | 2 +- shared/sagas/dappBrwoser.ts | 44 +++++++++++++++++-- shared/sagas/whiteList.ts | 10 ++--- shared/screens/Account/AccountAdd/styles.js | 4 +- shared/screens/Assets/AssetChart/index.jsx | 4 +- shared/screens/Assets/AssetChart/styles.js | 4 +- shared/screens/Assets/BalanceList/styles.js | 2 +- shared/screens/DappBrowser/index.jsx | 2 +- .../screens/Profile/AccountManager/index.jsx | 4 +- .../screens/Profile/AccountManager/styles.js | 4 +- shared/utils/api.ts | 2 +- 15 files changed, 64 insertions(+), 29 deletions(-) diff --git a/ios/bitportal/Info.plist b/ios/bitportal/Info.plist index 57ce8c4f6..d3403c80c 100644 --- a/ios/bitportal/Info.plist +++ b/ios/bitportal/Info.plist @@ -30,7 +30,7 @@ CFBundleVersion - 7 + 9 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/shared/components/ActionModal/WhiteListTips.jsx b/shared/components/ActionModal/WhiteListTips.jsx index d9c20c5f1..f136f101d 100644 --- a/shared/components/ActionModal/WhiteListTips.jsx +++ b/shared/components/ActionModal/WhiteListTips.jsx @@ -80,7 +80,7 @@ export default class WhiteListTips extends PureComponent { - {messges[locale].transaction_detail_text_agree_whitelist} + {messges[locale].transaction_detail_text_enable_advanced_settings} diff --git a/shared/components/ActionModal/index.native.jsx b/shared/components/ActionModal/index.native.jsx index 1dd2828d4..a564edee8 100644 --- a/shared/components/ActionModal/index.native.jsx +++ b/shared/components/ActionModal/index.native.jsx @@ -185,7 +185,7 @@ const SignatureActionItems = ({ info, locale, value }) => ( dappBrowser: state.dappBrowser, messageType: messageTypeSelector(state), messageInfo: messageInfoSelector(state) - }) + }) ) export default class ActionModal extends Component { @@ -201,7 +201,6 @@ export default class ActionModal extends Component { } else if (messageType === 'requestSignature') { return () } else if (messageType === 'requestArbitrarySignature') { - console.log('###-yy eosAuthSign action modal: ', info) return () } diff --git a/shared/components/DappWebView/index.native.jsx b/shared/components/DappWebView/index.native.jsx index 0f78abef5..9e9f74734 100644 --- a/shared/components/DappWebView/index.native.jsx +++ b/shared/components/DappWebView/index.native.jsx @@ -149,7 +149,7 @@ export default class DappWebView extends Component { } componentDidUpdate(prevProps) { - console.log('###--yy sendingMessage: ', this.props.sendingMessage) + // console.log('###--yy sendingMessage: ', this.props.sendingMessage) if (this.props.sendingMessage && prevProps.sendingMessage !== this.props.sendingMessage && this.webviewbridge) { this.webviewbridge.sendToBridge(this.props.sendingMessage) } @@ -213,7 +213,7 @@ export default class DappWebView extends Component { } onBridgeMessage = message => { - console.log('###--yy receiveMessage: ', message) + // console.log('###--yy receiveMessage: ', message) if (message.includes('clickedURL')) this.handleHistory(message) this.props.actions.receiveMessage(message) } diff --git a/shared/resources/messages/en/messages.json b/shared/resources/messages/en/messages.json index 736de10f0..03198857f 100644 --- a/shared/resources/messages/en/messages.json +++ b/shared/resources/messages/en/messages.json @@ -250,7 +250,7 @@ "discovery_dapp_popup_text_redirect": "You will be redirected to third party DApp \"{app}\". Your actions and usage on third party DApp should apply to third party DApp's Terms of Service and Privacy Policy. \"{app}\" will directly and independently be responsible for your actions and usage.", "discovery_dapp_text_favourite_limit": "You can only add 8 favorites", "discovery_dapp_popup_button_cancel": "Cancel", - "discovery_dapp_popup_button_understand": "I've Acknowleged", + "discovery_dapp_popup_button_understand": "Understood", "discovery_dapp_list_title_more": "more", "dapp_title_dapp": "DApps", diff --git a/shared/sagas/dappBrwoser.ts b/shared/sagas/dappBrwoser.ts index 68b355ba8..4bd84a800 100644 --- a/shared/sagas/dappBrwoser.ts +++ b/shared/sagas/dappBrwoser.ts @@ -158,6 +158,42 @@ function* pendSignEOSData(messageActionType: string, payload: any, messageId: st })) } +function* pendArbitrarySignature(messageActionType: string, payload: any, messageId: string) { + const hasPendingMessage = yield select((state: RootState) => state.dappBrowser.get('hasPendingMessage')) + if (hasPendingMessage) { + const pendingMessageActionType = yield select((state: RootState) => state.dappBrowser.getIn(['pendingMessage', 'type'])) + yield put(actions.sendMessage({ + messageId, + type: 'actionFailed', + payload: { + error: { + message: `There's a pending request: ${pendingMessageActionType}` + } + } + })) + return + } + + const account = payload.account + const publicKey = payload.publicKey + const signData = payload.data + const isHash = payload.isHash || false + const blockchain = 'EOS' + + yield put(actions.pendMessage({ + messageId, + payload, + type: messageActionType, + info: { + account, + publicKey, + signData, + isHash, + blockchain + } + })) +} + function* pendRequestSignature(messageActionType: string, payload: any, messageId: string) { const hasPendingMessage = yield select((state: RootState) => state.dappBrowser.get('hasPendingMessage')) if (hasPendingMessage) { @@ -362,7 +398,7 @@ function* resolveRequestArbitrarySignature(password: string, info: any, messageI const publicKey = info.get('publicKey') const signData = info.get('signData') const isHash = info.get('isHash') - console.log('###--yy account: %s, publicKey: %s, signData: %s isHash: %s', account, publicKey, signData, isHash) + // console.log('###--yy account: %s, publicKey: %s, signData: %s isHash: %s', account, publicKey, signData, isHash) const signatures = yield call(eosAuthSign, { account, password, @@ -375,7 +411,7 @@ function* resolveRequestArbitrarySignature(password: string, info: any, messageI messageId, type: 'actionSucceeded', payload: { - data: { signatures, returnedFields: [] } + data: signatures } })) } catch (error) { @@ -669,13 +705,13 @@ function* receiveMessage(action: Action) { break case 'requestArbitrarySignature': { - // console.log('###--yy', messageActionType) + console.log('###--yy', messageActionType) const currentWallet = yield select((state: RootState) => currenctWalletSelector(state)) assert(currentWallet, 'No wallet in BitPortal!') payload.account = currentWallet.get('account') const publicKey = payload.publicKey assert(publicKey === currentWallet.get('publicKey'), 'Public key is not in BitPortal.') - yield pendSignEOSData(messageActionType, payload, messageId) + yield pendArbitrarySignature(messageActionType, payload, messageId) } break case 'forgetIdentity': diff --git a/shared/sagas/whiteList.ts b/shared/sagas/whiteList.ts index 966964dfc..954acab31 100644 --- a/shared/sagas/whiteList.ts +++ b/shared/sagas/whiteList.ts @@ -46,7 +46,7 @@ function* switchWhiteList(action: any) { function* getWhiteListStoreInfo(action: any) { try { const store = yield call(storage.getItem, 'bitportal_white_list', true) - console.log('###--yy getWhiteListStoreInfo', store) + // console.log('###--yy getWhiteListStoreInfo', store) if (!!store && !!store.dappList) { const index = store.dappList.findIndex((v: any) => { // 给每个dapp添加一个授权属性来判断是否有已经授权 @@ -56,9 +56,9 @@ function* getWhiteListStoreInfo(action: any) { return v.dappName === action.payload.dappName }) if (index !== -1) yield put(actions.initSelectedDapp(store.dappList[index])) - console.log('###--yy dappList', store.dappList) + // console.log('###--yy dappList', store.dappList) const dappList = yield select((state: RootState) => state.whiteList.get('dappList')) - console.log('###--yy dappList', dappList) + // console.log('###--yy dappList', dappList) if (!dappList.size) { yield put(actions.recordDappList({ dappList: Immutable.fromJS(store.dappList) })) } @@ -102,7 +102,7 @@ function* resetSettingEnabled(action: any) { const storeDappList: any = [] reducerDappList.forEach((v: any) => storeDappList.push(v.delete('authorized').toJS())) - console.log('###--yy updateWhiteListStoreInfo 107', storeDappList) + // console.log('###--yy updateWhiteListStoreInfo 107', storeDappList) yield call(storage.mergeItem, 'bitportal_white_list', { dappList: storeDappList }, true) } } catch (e) { @@ -134,7 +134,7 @@ function* updateWhiteListStoreInfo(action: any) { const dappInfo = action.payload.store const dappList = yield select((state: RootState) => state.whiteList.get('dappList')) - console.log('###--yy updateWhiteListStoreInfo 82', dappList.toJS(), dappInfo.toJS()) + // console.log('###--yy updateWhiteListStoreInfo 82', dappList.toJS(), dappInfo.toJS()) const index = dappList.findIndex((v: any) => v.get('dappName') === dappInfo.get('dappName')) const storeDappList: any = [] if (index === -1) { diff --git a/shared/screens/Account/AccountAdd/styles.js b/shared/screens/Account/AccountAdd/styles.js index ac913acc8..157c91593 100644 --- a/shared/screens/Account/AccountAdd/styles.js +++ b/shared/screens/Account/AccountAdd/styles.js @@ -1,5 +1,5 @@ import { StyleSheet } from 'react-native' -import { SCREEN_WIDTH, SCREEN_HEIGHT, NAV_BAR_HEIGHT, TAB_BAR_HEIGHT } from 'utils/dimens' +import { SCREEN_WIDTH, SCREEN_HEIGHT, NAV_BAR_HEIGHT } from 'utils/dimens' import Colors from 'resources/colors' const styles = StyleSheet.create({ @@ -11,7 +11,7 @@ const styles = StyleSheet.create({ }, scrollContainer: { width: SCREEN_WIDTH, - height: SCREEN_HEIGHT - NAV_BAR_HEIGHT - TAB_BAR_HEIGHT, + height: SCREEN_HEIGHT - NAV_BAR_HEIGHT, backgroundColor: Colors.mainThemeColor } }) diff --git a/shared/screens/Assets/AssetChart/index.jsx b/shared/screens/Assets/AssetChart/index.jsx index e16b56a08..2c5c4ce5a 100644 --- a/shared/screens/Assets/AssetChart/index.jsx +++ b/shared/screens/Assets/AssetChart/index.jsx @@ -206,7 +206,7 @@ export default class AssetChart extends Component { /> - + @@ -217,7 +217,7 @@ export default class AssetChart extends Component { - + diff --git a/shared/screens/Assets/AssetChart/styles.js b/shared/screens/Assets/AssetChart/styles.js index 10d369e3c..6b4f0f1fb 100644 --- a/shared/screens/Assets/AssetChart/styles.js +++ b/shared/screens/Assets/AssetChart/styles.js @@ -23,7 +23,7 @@ const styles = StyleSheet.create({ flexDirection: 'column' }, content: { - height: SCREEN_HEIGHT - NAV_BAR_HEIGHT - TAB_BAR_HEIGHT, + height: SCREEN_HEIGHT - NAV_BAR_HEIGHT - TAB_BAR_HEIGHT - 20, backgroundColor: Colors.mainThemeColor }, topContent: { @@ -45,7 +45,7 @@ const styles = StyleSheet.create({ }, btnContainer: { width: SCREEN_WIDTH, - height: TAB_BAR_HEIGHT, + height: TAB_BAR_HEIGHT+20, backgroundColor: Colors.mainThemeColor, ...ifIphoneX({ paddingBottom: 34 diff --git a/shared/screens/Assets/BalanceList/styles.js b/shared/screens/Assets/BalanceList/styles.js index 716660304..f02fd5905 100644 --- a/shared/screens/Assets/BalanceList/styles.js +++ b/shared/screens/Assets/BalanceList/styles.js @@ -54,7 +54,7 @@ const styles = StyleSheet.create({ width: FLOATING_CARD_WIDTH, backgroundColor: Colors.minorThemeColor, alignItems: 'center', - paddingBottom: 20, + paddingBottom: 8, borderBottomLeftRadius: FLOATING_CARD_BORDER_RADIUS, borderBottomRightRadius: FLOATING_CARD_BORDER_RADIUS }, diff --git a/shared/screens/DappBrowser/index.jsx b/shared/screens/DappBrowser/index.jsx index 0568dfb68..147e38d3b 100644 --- a/shared/screens/DappBrowser/index.jsx +++ b/shared/screens/DappBrowser/index.jsx @@ -92,7 +92,7 @@ export default class DappWebView extends Component { componentDidUpdate(prevProps) { if (this.props.sendingMessage && prevProps.sendingMessage !== this.props.sendingMessage && this.webviewbridge) { - console.log('###--yy sendingMessage: --', this.props.sendingMessage) + // console.log('###--yy sendingMessage: --', this.props.sendingMessage) this.webviewbridge.sendToBridge(this.props.sendingMessage) } } diff --git a/shared/screens/Profile/AccountManager/index.jsx b/shared/screens/Profile/AccountManager/index.jsx index 9ac16ec02..caae958d5 100644 --- a/shared/screens/Profile/AccountManager/index.jsx +++ b/shared/screens/Profile/AccountManager/index.jsx @@ -90,8 +90,8 @@ export default class AccountManager extends Component { } - - + + {messages[locale].account_change_button_add_account} diff --git a/shared/screens/Profile/AccountManager/styles.js b/shared/screens/Profile/AccountManager/styles.js index 7ead74f5e..f1556e653 100644 --- a/shared/screens/Profile/AccountManager/styles.js +++ b/shared/screens/Profile/AccountManager/styles.js @@ -10,11 +10,11 @@ const styles = StyleSheet.create({ }, scrollContainer: { width: SCREEN_WIDTH, - height: SCREEN_HEIGHT - NAV_BAR_HEIGHT - TAB_BAR_HEIGHT + height: SCREEN_HEIGHT - NAV_BAR_HEIGHT - TAB_BAR_HEIGHT -20 }, btnContainer: { width: SCREEN_WIDTH, - height: TAB_BAR_HEIGHT, + height: TAB_BAR_HEIGHT+20, backgroundColor: Colors.minorThemeColor, ...ifIphoneX({ paddingBottom: 34 diff --git a/shared/utils/api.ts b/shared/utils/api.ts index 09306c6d9..e1a062b35 100644 --- a/shared/utils/api.ts +++ b/shared/utils/api.ts @@ -52,7 +52,7 @@ export const fetchBase = async ( fetchOptions.body = JSON.stringify(params) } } - console.log('###---xx ', url) + // console.log('###---xx ', url) return fetch(url, fetchOptions).then((res: any) => { if (!res.ok) return res.json().then((e: any) => Promise.reject({ message: e }))