Skip to content

Commit

Permalink
fix translations && add new dapp action type
Browse files Browse the repository at this point in the history
  • Loading branch information
waterFallFlow committed Dec 18, 2018
1 parent 7af4935 commit 645ad40
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 29 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>7</string>
<string>9</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
2 changes: 1 addition & 1 deletion shared/components/ActionModal/WhiteListTips.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class WhiteListTips extends PureComponent {
<View style={styles.textSettingDes}>
<BPImage source={Images.whiteList_warning} style={[styles.image, { marginRight: 10 }]} />
<Text style={styles.text12}>
{messges[locale].transaction_detail_text_agree_whitelist}
{messges[locale].transaction_detail_text_enable_advanced_settings}
</Text>
</View>
<View style={styles.switchContainer}>
Expand Down
3 changes: 1 addition & 2 deletions shared/components/ActionModal/index.native.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const SignatureActionItems = ({ info, locale, value }) => (
dappBrowser: state.dappBrowser,
messageType: messageTypeSelector(state),
messageInfo: messageInfoSelector(state)
})
})
)

export default class ActionModal extends Component {
Expand All @@ -201,7 +201,6 @@ export default class ActionModal extends Component {
} 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} />)
}

Expand Down
4 changes: 2 additions & 2 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('###--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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion shared/resources/messages/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 40 additions & 4 deletions shared/sagas/dappBrwoser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -375,7 +411,7 @@ function* resolveRequestArbitrarySignature(password: string, info: any, messageI
messageId,
type: 'actionSucceeded',
payload: {
data: { signatures, returnedFields: [] }
data: signatures
}
}))
} catch (error) {
Expand Down Expand Up @@ -669,13 +705,13 @@ function* receiveMessage(action: Action<string>) {
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':
Expand Down
10 changes: 5 additions & 5 deletions shared/sagas/whiteList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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添加一个授权属性来判断是否有已经授权
Expand All @@ -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) }))
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions shared/screens/Account/AccountAdd/styles.js
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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
}
})
Expand Down
4 changes: 2 additions & 2 deletions shared/screens/Assets/AssetChart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default class AssetChart extends Component {
/>
</View>
<View style={[styles.btnContainer, styles.between]}>
<View style={{ flex: 1, paddingVertical: 10, paddingHorizontal: 15, borderRadius: 8 }}>
<View style={{ flex: 1, height: 40, paddingHorizontal: 15, borderRadius: 8 }}>
<BPGradientButton onPress={this.send} extraStyle={{ marginHorizontal: 10 }}>
<View style={{ flexDirection: 'row' }}>
<BPImage source={Images.assets_send} style={styles.image} />
Expand All @@ -217,7 +217,7 @@ export default class AssetChart extends Component {
</BPGradientButton>
</View>
<View style={styles.line} />
<View style={{ flex: 1, paddingVertical: 10, paddingHorizontal: 15, borderRadius: 8 }}>
<View style={{ flex: 1,height: 40, 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} />
Expand Down
4 changes: 2 additions & 2 deletions shared/screens/Assets/AssetChart/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion shared/screens/Assets/BalanceList/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion shared/screens/DappBrowser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions shared/screens/Profile/AccountManager/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export default class AccountManager extends Component {
}
</ScrollView>
</View>
<View style={styles.btnContainer}>
<View style={{ flex: 1, paddingVertical: 10, paddingHorizontal: 15, borderRadius: 8 }}>
<View style={[styles.btnContainer, styles.between]}>
<View style={{ flex: 1, height: 40, paddingHorizontal: 15, borderRadius: 8 }}>
<BPGradientButton onPress={this.routeToNewAccount} extraStyle={{ marginHorizontal: 10 }}>
<Text style={[styles.text14, { color: Colors.textColor_255_255_238 }]}>
{messages[locale].account_change_button_add_account}
Expand Down
4 changes: 2 additions & 2 deletions shared/screens/Profile/AccountManager/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion shared/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
Expand Down

0 comments on commit 645ad40

Please sign in to comment.