From d810014dd66e49ad81a2a2773007350047971334 Mon Sep 17 00:00:00 2001 From: Young Leo Date: Mon, 17 Dec 2018 16:56:50 +0800 Subject: [PATCH] bug fixed --- ios/bitportal/Info.plist | 2 +- .../components/ActionModal/index.native.jsx | 3 + .../BPGradientButton/index.jsx | 4 +- .../components/DappWebView/index.native.jsx | 15 ++--- shared/components/WalletCard/index.jsx | 1 + shared/core/scatter/scatterdapp.js | 1 - shared/navigators/index.js | 2 + shared/sagas/dappBrwoser.ts | 67 ++++++++++++++++--- shared/sagas/eosAccount.ts | 10 ++- .../Account/AccountSelection/index.jsx | 12 +++- .../Account/AccountSelection/styles.ts | 18 ++++- shared/screens/Assets/AssetChart/index.jsx | 29 ++++++-- shared/screens/Assets/AssetChart/styles.js | 5 ++ shared/screens/Assets/index.jsx | 7 +- shared/screens/DappBrowser/index.jsx | 1 + shared/screens/Market/MarketContent/index.jsx | 2 +- .../screens/Market/SystemResources/index.jsx | 3 +- .../screens/Profile/AccountManager/index.jsx | 13 ++-- shared/screens/Profile/Voting/index.jsx | 2 +- .../screens/Profile/WhiteListDetails/index.js | 2 +- shared/screens/Profile/index.jsx | 2 +- shared/screens/SystemResources/index.jsx | 45 +++++++++++++ shared/screens/SystemResources/styles.js | 20 ++++++ 23 files changed, 222 insertions(+), 44 deletions(-) create mode 100644 shared/screens/SystemResources/index.jsx create mode 100644 shared/screens/SystemResources/styles.js diff --git a/ios/bitportal/Info.plist b/ios/bitportal/Info.plist index 7d61870e3..57ce8c4f6 100644 --- a/ios/bitportal/Info.plist +++ b/ios/bitportal/Info.plist @@ -30,7 +30,7 @@ CFBundleVersion - 6 + 7 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/shared/components/ActionModal/index.native.jsx b/shared/components/ActionModal/index.native.jsx index 0896bd770..1dd2828d4 100644 --- a/shared/components/ActionModal/index.native.jsx +++ b/shared/components/ActionModal/index.native.jsx @@ -200,6 +200,9 @@ export default class ActionModal extends Component { return () } else if (messageType === 'requestSignature') { return () + } else if (messageType === 'requestArbitrarySignature') { + console.log('###-yy eosAuthSign action modal: ', info) + return () } return null diff --git a/shared/components/BPNativeComponents/BPGradientButton/index.jsx b/shared/components/BPNativeComponents/BPGradientButton/index.jsx index cdd7b958e..60b9e1321 100644 --- a/shared/components/BPNativeComponents/BPGradientButton/index.jsx +++ b/shared/components/BPNativeComponents/BPGradientButton/index.jsx @@ -6,12 +6,12 @@ import styles from './styles' export default class BPGradientButton extends Component{ render() { - const { onPress, disabled, children, extraStyle } = this.props + const { onPress, disabled, colors, children, extraStyle } = this.props return ( {children} diff --git a/shared/components/DappWebView/index.native.jsx b/shared/components/DappWebView/index.native.jsx index d7daeaef9..0f78abef5 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('###--xx 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('###--xx receiveMessage: ', message) + console.log('###--yy receiveMessage: ', message) if (message.includes('clickedURL')) this.handleHistory(message) this.props.actions.receiveMessage(message) } @@ -239,14 +239,13 @@ export default class DappWebView extends Component { showPrompt = () => { const { whiteList } = this.props const dappName = whiteList.getIn(['selectedDapp', 'dappName']) + const accepted = whiteList.getIn(['selectedDapp', 'accept']) const dappList = whiteList.get('dappList') + let authorized = false - dappList.forEach(v => { - if (v.get('dappName') === dappName) { - authorized = v.get('authorized') - } - }) - if (authorized) { + dappList.forEach(v => { if (v.get('dappName') === dappName) { authorized = v.get('authorized') } }) + + if (accepted && authorized) { const password = whiteList.get('password') this.props.actions.resolveMessage({ password }) } else { diff --git a/shared/components/WalletCard/index.jsx b/shared/components/WalletCard/index.jsx index 5c4078f91..17e194b52 100644 --- a/shared/components/WalletCard/index.jsx +++ b/shared/components/WalletCard/index.jsx @@ -35,6 +35,7 @@ export default ({ accountType, accountName, balanceTitle, eosValue, eosAmount, a } + {/* */} diff --git a/shared/core/scatter/scatterdapp.js b/shared/core/scatter/scatterdapp.js index 5a77af5bf..af095cf42 100644 --- a/shared/core/scatter/scatterdapp.js +++ b/shared/core/scatter/scatterdapp.js @@ -80,7 +80,6 @@ const throwIfNoIdentity = () => { const setupSigProviders = (context) => { PluginRepository.signatureProviders().map((sigProvider) => { context[sigProvider.name] = sigProvider.signatureProvider(_send, throwIfNoIdentity) - console.log('###--xx sigProvider:', context[sigProvider.name]) return context[sigProvider.name] }) } diff --git a/shared/navigators/index.js b/shared/navigators/index.js index 486b782c7..944c678dd 100644 --- a/shared/navigators/index.js +++ b/shared/navigators/index.js @@ -3,6 +3,7 @@ import screenComponent from 'components/ScreenComponent' import { Platform } from 'react-native' import Market from 'screens/Market' import TokenPage from 'screens/Market/Overview/TokenPage' +import SystemResources from 'screens/SystemResources' import Welcome from 'screens/Welcome' import LightBox from 'screens/LightBox' import QRCodeScanner from 'screens/QRCodeScanner' @@ -75,6 +76,7 @@ export const registerScreens = store => { Navigation.registerComponent('BitPortal.AssetsTransfer', () => screenComponent(AssetsTransfer, store)) Navigation.registerComponent('BitPortal.AvailableAssets', () => screenComponent(AvailableAssets, store)) Navigation.registerComponent('BitPortal.Market', () => screenComponent(Market, store)) + Navigation.registerComponent('BitPortal.SystemResources', () => screenComponent(SystemResources, store)) Navigation.registerComponent('BitPortal.Discovery', () => screenComponent(Discovery, store)) Navigation.registerComponent('BitPortal.DiscoveryArticle', () => screenComponent(ArticleWebView, store)) Navigation.registerComponent('BitPortal.Markdown', () => screenComponent(Markdown, store)) diff --git a/shared/sagas/dappBrwoser.ts b/shared/sagas/dappBrwoser.ts index 664a22ad8..68b355ba8 100644 --- a/shared/sagas/dappBrwoser.ts +++ b/shared/sagas/dappBrwoser.ts @@ -140,7 +140,7 @@ function* pendSignEOSData(messageActionType: string, payload: any, messageId: st const account = payload.account const publicKey = payload.publicKey - const signData = payload.signData + const signData = payload.signData || payload.data const isHash = payload.isHash || false const blockchain = 'EOS' @@ -324,7 +324,7 @@ function* resolveSignEOSData(password: string, info: any, messageId: string) { try { const account = info.get('account') const publicKey = info.get('publicKey') - const signData = info.get('signData') + const signData = info.get('signData') const isHash = info.get('isHash') const signedData = yield call(eosAuthSign, { @@ -356,16 +356,47 @@ function* resolveSignEOSData(password: string, info: any, messageId: string) { } } +function* resolveRequestArbitrarySignature(password: string, info: any, messageId: string) { + try { + const account = info.get('account') + 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) + const signatures = yield call(eosAuthSign, { + account, + password, + publicKey, + signData, + isHash + }) + yield put(actions.clearMessage()) + yield put(actions.sendMessage({ + messageId, + type: 'actionSucceeded', + payload: { + data: { signatures, returnedFields: [] } + } + })) + } catch (error) { + yield put(actions.clearMessage()) + yield put(actions.sendMessage({ + messageId, + type: 'actionFailed', + payload: { + error: { + message: error.message || error + } + } + })) + } +} + function* resolveRequestSignature(password: string, info: any, messageId: string) { try { const buf = info.get('buf').toJS() const publicKey = yield select((state: RootState) => state.wallet.get('data').get('publicKey')) const account = yield select((state: RootState) => eosAccountNameSelector(state)) - - // 存储dapp信息并绑定account到本地 - const selectedDapp = yield select((state: RootState) => state.whiteList.get('selectedDapp')) - const store = selectedDapp.set('authorized', true).set('accountName', account).set('info', info).delete('password') - yield put(whiteListActions.updateWhiteListStoreInfo({ store })) const signatures = yield call(signature, { account, @@ -374,7 +405,13 @@ function* resolveRequestSignature(password: string, info: any, messageId: string buf }) yield put(actions.clearMessage()) - // delay(350) + yield delay(500) + + // 存储dapp信息并绑定account到本地 + const selectedDapp = yield select((state: RootState) => state.whiteList.get('selectedDapp')) + const store = selectedDapp.set('authorized', true).set('accountName', account).set('info', info).delete('password') + yield put(whiteListActions.updateWhiteListStoreInfo({ store })) + yield put(actions.sendMessage({ messageId, type: 'actionSucceeded', @@ -630,6 +667,17 @@ function* receiveMessage(action: Action) { }, messageId) } break + case 'requestArbitrarySignature': + { + // 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) + } + break case 'forgetIdentity': case 'requestAddNetwork': { @@ -729,6 +777,9 @@ function* resolveMessage(action: Action) { case 'requestSignature': yield resolveRequestSignature(password, info, messageId) break + case 'requestArbitrarySignature': + yield resolveRequestArbitrarySignature(password, info, messageId) + break default: break } diff --git a/shared/sagas/eosAccount.ts b/shared/sagas/eosAccount.ts index b7212660d..5609eb741 100644 --- a/shared/sagas/eosAccount.ts +++ b/shared/sagas/eosAccount.ts @@ -240,8 +240,14 @@ function* getEOSKeyAccountsRequested(action: Action) { for (const accountName of keyAccounts) { const accountInfo = yield call(eos.getAccount, accountName) const permissions = getPermissionsByKey(publicKey, accountInfo) - // console.log('###--yy', permissions, accountInfo) - keyPermissions = [...keyPermissions, ...permissions] + if (permissions.length > 1) { + const newPermissions = permissions.filter((v: any) => ( v.permission == 'active')) + // console.log('###--yy', newPermissions) + keyPermissions = [...keyPermissions, ...newPermissions] + } else { + // console.log('###--yy', permissions, accountInfo) + keyPermissions = [...keyPermissions, ...permissions] + } } yield put(actions.getEOSKeyAccountsSucceeded(result)) diff --git a/shared/screens/Account/AccountSelection/index.jsx b/shared/screens/Account/AccountSelection/index.jsx index 9412f389c..b19efc866 100644 --- a/shared/screens/Account/AccountSelection/index.jsx +++ b/shared/screens/Account/AccountSelection/index.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import { View, ScrollView } from 'react-native' +import { Text, View, ScrollView, TouchableOpacity } from 'react-native' import { Navigation } from 'react-native-navigation' import NavigationBar, { CommonButton, CommonRightButton } from 'components/NavigationBar' import Colors from 'resources/colors' @@ -109,8 +109,16 @@ export default class AccountSelection extends Component { )) } - + {/* + + + 导入账户 + + + */} + + ) diff --git a/shared/screens/Account/AccountSelection/styles.ts b/shared/screens/Account/AccountSelection/styles.ts index 82c8942fb..d9d1beeab 100644 --- a/shared/screens/Account/AccountSelection/styles.ts +++ b/shared/screens/Account/AccountSelection/styles.ts @@ -1,6 +1,6 @@ import { StyleSheet } from 'react-native' import Colors from 'resources/colors' -import { SCREEN_WIDTH, SCREEN_HEIGHT, NAV_BAR_HEIGHT, FontScale } from 'utils/dimens' +import { SCREEN_WIDTH, SCREEN_HEIGHT, NAV_BAR_HEIGHT, TAB_BAR_HEIGHT, ifIphoneX, FontScale } from 'utils/dimens' const styles = StyleSheet.create({ container: { @@ -10,7 +10,7 @@ const styles = StyleSheet.create({ }, scrollContainer: { width: SCREEN_WIDTH, - height: SCREEN_HEIGHT - NAV_BAR_HEIGHT, + height: SCREEN_HEIGHT - NAV_BAR_HEIGHT - TAB_BAR_HEIGHT, alignItems: 'center' }, cardContainer: { @@ -35,6 +35,10 @@ const styles = StyleSheet.create({ justifyContent: 'space-between', flexDirection: 'row' }, + center: { + alignItems: 'center', + justifyContent: 'center' + }, paddingStyle: { paddingHorizontal: 20 }, @@ -43,6 +47,16 @@ const styles = StyleSheet.create({ paddingHorizontal: 10, backgroundColor: Colors.bgColor_FFFFFF }, + btnContainer: { + width: SCREEN_WIDTH, + height: TAB_BAR_HEIGHT, + backgroundColor: Colors.minorThemeColor, + ...ifIphoneX({ + paddingBottom: 34 + }, { + paddingBottom: 0 + }) + }, text12: { fontSize: FontScale(12), color: Colors.textColor_255_255_238 diff --git a/shared/screens/Assets/AssetChart/index.jsx b/shared/screens/Assets/AssetChart/index.jsx index fe097b0bc..867d69ae6 100644 --- a/shared/screens/Assets/AssetChart/index.jsx +++ b/shared/screens/Assets/AssetChart/index.jsx @@ -18,8 +18,11 @@ import { RecyclerListView, LayoutProvider } from 'recyclerlistview' import ImmutableDataProvider from 'utils/immutableDataProvider' import { SCREEN_WIDTH } from 'utils/dimens' import messages from 'resources/messages' +import Images from 'resources/images' +import { BPImage, BPGradientButton } from 'components/BPNativeComponents' import RecordItem from './RecordItem' import styles from './styles' +import Colors from 'resources/colors' const dataProvider = new ImmutableDataProvider((r1, r2) => r1.get('account_action_seq') !== r2.get('account_action_seq')) @@ -203,13 +206,27 @@ export default class AssetChart extends Component { /> - - - + + + + + + + + + + - - - + + + + + + + + + + diff --git a/shared/screens/Assets/AssetChart/styles.js b/shared/screens/Assets/AssetChart/styles.js index 0ae38f2ff..2cec38673 100644 --- a/shared/screens/Assets/AssetChart/styles.js +++ b/shared/screens/Assets/AssetChart/styles.js @@ -57,6 +57,11 @@ const styles = StyleSheet.create({ width: 1, backgroundColor: Colors.bgColor_FFFFFF }, + image: { + width: 16, + height: 16, + marginRight: 10, + }, btn: { width: (SCREEN_WIDTH - 1) / 2, ...ifIphoneX({ diff --git a/shared/screens/Assets/index.jsx b/shared/screens/Assets/index.jsx index 16ca5eebb..ad432220d 100644 --- a/shared/screens/Assets/index.jsx +++ b/shared/screens/Assets/index.jsx @@ -255,7 +255,7 @@ export default class Assets extends Component { onEventWithLabel(ASSETS_EOS_RESOURCE, '资产 - EOS资源管理') Navigation.push(this.props.componentId, { component: { - name: 'BitPortal.Resources' + name: 'BitPortal.SystemResources' } }) } @@ -363,7 +363,10 @@ export default class Assets extends Component { )} {!!walletCount && ( - + else if (category === 'DEXLIZE') return - else if (category === 'SYSTEM') return + else if (category === 'SYSTEM') return else return null } } diff --git a/shared/screens/Market/SystemResources/index.jsx b/shared/screens/Market/SystemResources/index.jsx index 148d2070a..4bfc015c6 100644 --- a/shared/screens/Market/SystemResources/index.jsx +++ b/shared/screens/Market/SystemResources/index.jsx @@ -55,12 +55,13 @@ export default class SystemResources extends React.Component { ) render() { + const { componentId } = this.props return ( , third: Net })} onIndexChange={index => { diff --git a/shared/screens/Profile/AccountManager/index.jsx b/shared/screens/Profile/AccountManager/index.jsx index dc4a7fc74..17a60176f 100644 --- a/shared/screens/Profile/AccountManager/index.jsx +++ b/shared/screens/Profile/AccountManager/index.jsx @@ -7,6 +7,7 @@ import { connect } from 'react-redux' import { IntlProvider } from 'react-intl' import messages from 'resources/messages' import WalletCard from 'components/WalletCard' +import { BPGradientButton } from 'components/BPNativeComponents' import { walletListSelector } from 'selectors/wallet' import { eosPriceSelector } from 'selectors/ticker' import styles from './styles' @@ -89,11 +90,13 @@ export default class AccountManager extends Component { - - - 添加新钱包 - - + + + + 添加新钱包 + + + diff --git a/shared/screens/Profile/Voting/index.jsx b/shared/screens/Profile/Voting/index.jsx index e964f11cd..48961a008 100644 --- a/shared/screens/Profile/Voting/index.jsx +++ b/shared/screens/Profile/Voting/index.jsx @@ -154,7 +154,7 @@ export default class Voting extends Component { } else { Navigation.push(this.props.componentId, { component: { - name: 'BitPortal.Resources' + name: 'BitPortal.SystemResources' } }) } diff --git a/shared/screens/Profile/WhiteListDetails/index.js b/shared/screens/Profile/WhiteListDetails/index.js index 6ce27979a..f8fdcac9d 100644 --- a/shared/screens/Profile/WhiteListDetails/index.js +++ b/shared/screens/Profile/WhiteListDetails/index.js @@ -92,7 +92,7 @@ export default class WhiteListDetails extends Component { 白名单列表 - + 高级设置 diff --git a/shared/screens/Profile/index.jsx b/shared/screens/Profile/index.jsx index 474678b07..806acfa6a 100644 --- a/shared/screens/Profile/index.jsx +++ b/shared/screens/Profile/index.jsx @@ -77,7 +77,7 @@ export default class Profile extends Component { break case 'Resources': if (this.props.hasEOSAccount) { - pageName = 'Resources' + pageName = 'SystemResources' } else { return this.dialog() } diff --git a/shared/screens/SystemResources/index.jsx b/shared/screens/SystemResources/index.jsx new file mode 100644 index 000000000..73c3ea465 --- /dev/null +++ b/shared/screens/SystemResources/index.jsx @@ -0,0 +1,45 @@ +import * as React from 'react' +import { View, Text } from 'react-native' +import { connect } from 'react-redux' +import { IntlProvider } from 'react-intl' +import NavigationBar, { CommonButton } from 'components/NavigationBar' +import { Navigation } from 'react-native-navigation' +import SystemResource from 'screens/Market/SystemResources' +import messages from 'resources/messages' +import styles from './styles' + +@connect( + state => ({ + locale: state.intl.get('locale') + }), + null, + null, + { withRef: true } +) + +export default class SystemResources extends React.Component { + static get options() { + return { + bottomTabs: { + visible: false + } + } + } + + render() { + const { locale, componentId } = this.props + return ( + + + Navigation.pop(this.props.componentId)} />} + /> + + + + + + ) + } +} diff --git a/shared/screens/SystemResources/styles.js b/shared/screens/SystemResources/styles.js new file mode 100644 index 000000000..d20b23654 --- /dev/null +++ b/shared/screens/SystemResources/styles.js @@ -0,0 +1,20 @@ +import Colors from 'resources/colors' +import { + SCREEN_WIDTH, + SCREEN_HEIGHT, + NAV_BAR_HEIGHT +} from 'utils/dimens' + +const styles = { + container: { + width: SCREEN_WIDTH, + height: SCREEN_HEIGHT, + backgroundColor: Colors.mainThemeColor + }, + scrollContainer: { + height: SCREEN_HEIGHT - NAV_BAR_HEIGHT, + flexDirection: 'column' + } +} + +export default styles