Skip to content

Commit

Permalink
bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
waterFallFlow committed Dec 17, 2018
1 parent 6f28f1e commit d810014
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 44 deletions.
2 changes: 1 addition & 1 deletion ios/bitportal/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>6</string>
<string>7</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
3 changes: 3 additions & 0 deletions shared/components/ActionModal/index.native.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export default class ActionModal extends Component {
return (<PushActionItems info={info} locale={this.props.locale} />)
} else if (messageType === 'requestSignature') {
return (<SignatureActionItems info={info} locale={this.props.locale} />)
} else if (messageType === 'requestArbitrarySignature') {
console.log('###-yy eosAuthSign action modal: ', info)
return (<SignActionItems info={info} locale={this.props.locale} />)
}

return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TouchableOpacity style={styles.container} onPress={onPress} disabled={disabled}>
<LinearGradientContainer
type="right"
colors={disabled ? Colors.disabled : null}
colors={disabled ? Colors.disabled : colors}
style={[styles.center, { width: '100%', height: '100%', borderRadius: 3 }, extraStyle]}
>
{children}
Expand Down
15 changes: 7 additions & 8 deletions shared/components/DappWebView/index.native.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions shared/components/WalletCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default ({ accountType, accountName, balanceTitle, eosValue, eosAmount, a
</View>
}
</View>
{/* <Ionicons name="md-checkmark-circle" size={26} color={Colors.bgColor_FAFAFA} /> */}
<Ionicons name="ios-arrow-forward" size={26} color={Colors.bgColor_FAFAFA} />
</View>
</LinearGradientContainer>
Expand Down
1 change: 0 additions & 1 deletion shared/core/scatter/scatterdapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
})
}
Expand Down
2 changes: 2 additions & 0 deletions shared/navigators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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))
Expand Down
67 changes: 59 additions & 8 deletions shared/sagas/dappBrwoser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down Expand Up @@ -630,6 +667,17 @@ function* receiveMessage(action: Action<string>) {
}, 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':
{
Expand Down Expand Up @@ -729,6 +777,9 @@ function* resolveMessage(action: Action<any>) {
case 'requestSignature':
yield resolveRequestSignature(password, info, messageId)
break
case 'requestArbitrarySignature':
yield resolveRequestArbitrarySignature(password, info, messageId)
break
default:
break
}
Expand Down
10 changes: 8 additions & 2 deletions shared/sagas/eosAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,14 @@ function* getEOSKeyAccountsRequested(action: Action<GetEOSKeyAccountsParams>) {
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))
Expand Down
12 changes: 10 additions & 2 deletions shared/screens/Account/AccountSelection/index.jsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -109,8 +109,16 @@ export default class AccountSelection extends Component {
))
}
</ScrollView>
<Alert message={errorMessages(error, messages[locale])} dismiss={this.props.actions.clearEOSAccountError} />
</View>
{/* <View style={styles.btnContainer}>
<TouchableOpacity style={[{flex: 1}, styles.center]} onPress={this.routeToNewAccount} >
<Text style={styles.text14}>
导入账户
</Text>
</TouchableOpacity>
</View> */}

<Alert message={errorMessages(error, messages[locale])} dismiss={this.props.actions.clearEOSAccountError} />
<Loading isVisible={loading} text={messages[locale].export_private_key_text_exporting} />
</View>
)
Expand Down
18 changes: 16 additions & 2 deletions shared/screens/Account/AccountSelection/styles.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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: {
Expand All @@ -35,6 +35,10 @@ const styles = StyleSheet.create({
justifyContent: 'space-between',
flexDirection: 'row'
},
center: {
alignItems: 'center',
justifyContent: 'center'
},
paddingStyle: {
paddingHorizontal: 20
},
Expand All @@ -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
Expand Down
29 changes: 23 additions & 6 deletions shared/screens/Assets/AssetChart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down Expand Up @@ -203,13 +206,27 @@ export default class AssetChart extends Component {
/>
</View>
<View style={[styles.btnContainer, styles.between]}>
<TouchableOpacity style={[styles.center, styles.btn]} onPress={this.send}>
<Text style={styles.text14}><FormattedMessage id="transaction_list_button_send" /></Text>
</TouchableOpacity>
<View style={{ flex: 1, paddingVertical: 10, paddingHorizontal: 15, borderRadius: 8 }}>
<BPGradientButton onPress={this.send} extraStyle={{ marginHorizontal: 10 }}>
<View style={{ flexDirection: 'row' }}>
<BPImage source={Images.assets_send} style={styles.image} />
<Text style={[styles.text14, { color: Colors.textColor_255_255_238 }]}>
<FormattedMessage id="transaction_list_button_send" />
</Text>
</View>
</BPGradientButton>
</View>
<View style={styles.line} />
<TouchableOpacity style={[styles.center, styles.btn]} onPress={this.receive}>
<Text style={styles.text14}><FormattedMessage id="transaction_list_button_receive" /></Text>
</TouchableOpacity>
<View style={{ flex: 1, paddingVertical: 10, paddingHorizontal: 15, borderRadius: 8 }}>
<BPGradientButton onPress={this.receive} colors={Colors.ramColor} extraStyle={{ marginHorizontal: 10 }}>
<View style={{ flexDirection: 'row' }}>
<BPImage source={Images.assets_receive} style={styles.image} />
<Text style={[styles.text14, { color: Colors.textColor_255_255_238 }]}>
<FormattedMessage id="transaction_list_button_receive" />
</Text>
</View>
</BPGradientButton>
</View>
</View>
</View>
</View>
Expand Down
5 changes: 5 additions & 0 deletions shared/screens/Assets/AssetChart/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 5 additions & 2 deletions shared/screens/Assets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
})
}
Expand Down Expand Up @@ -363,7 +363,10 @@ export default class Assets extends Component {
)}
{!!walletCount && (
<View style={styles.scrollContainer}>
<ScrollView showsVerticalScrollIndicator={false}>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ alignItems: 'center' }}
>
<TotalAssetsCard
totalAssets={eosTotalAssetBalance}
accountName={activeEOSAccount.get('account_name')}
Expand Down
1 change: 1 addition & 0 deletions shared/screens/DappBrowser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,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)
this.webviewbridge.sendToBridge(this.props.sendingMessage)
}
}
Expand Down
Loading

0 comments on commit d810014

Please sign in to comment.