Skip to content

Commit

Permalink
Merge pull request #326 from BitPortal/new_UI&bug_fixed
Browse files Browse the repository at this point in the history
New ui&bug fixed
  • Loading branch information
waterFallFlow authored Dec 17, 2018
2 parents ac32ae4 + 9109950 commit 7af4935
Show file tree
Hide file tree
Showing 31 changed files with 308 additions and 65 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
13 changes: 8 additions & 5 deletions shared/components/ActionModal/WhiteListTips.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as whiteListActions from 'actions/whiteList'
import { whiteListAuthorizedSelector } from 'selectors/whiteList'
import BPImage from 'components/BPNativeComponents/BPImage'
import Images from 'resources/images'
import messges from 'resources/messages'
import styles from './styles'

@connect(
Expand Down Expand Up @@ -49,7 +50,7 @@ export default class WhiteListTips extends PureComponent {
}

render() {
const { value, selectedDapp, authorized } = this.props
const { value, selectedDapp, authorized, locale } = this.props
const accept = selectedDapp.get('accept')
const settingDisplay = selectedDapp.get('settingDisplay')
const settingEnabled = selectedDapp.get('settingEnabled')
Expand All @@ -63,11 +64,11 @@ export default class WhiteListTips extends PureComponent {

<View style={styles.titleContainer}>
<Text style={styles.text15}>
{(authorized && accept) ? ' ' : '开启白名单'}
{(authorized && accept) ? ' ' : messges[locale].transaction_detail_label_enable_whitelist}
</Text>
<View style={styles.titleSetting}>
<Text onPress={this.switchSetting} style={[styles.text14, { marginTop: -4 }, signedColor]}>
高级设置
{messges[locale].transaction_detail_button_advanced_settings}
</Text>
<Ionicons name={settingDisplay ? 'md-arrow-dropdown' : "md-arrow-dropright"} size={18} color={arrowColor} />
</View>
Expand All @@ -78,7 +79,9 @@ export default class WhiteListTips extends PureComponent {
<View style={styles.settingContainer}>
<View style={styles.textSettingDes}>
<BPImage source={Images.whiteList_warning} style={[styles.image, { marginRight: 10 }]} />
<Text style={styles.text12}> 打开高级设置,下次进行该操作时,无需进行弹框确认直接执行,开启后可前往钱包管理中关闭 </Text>
<Text style={styles.text12}>
{messges[locale].transaction_detail_text_agree_whitelist}
</Text>
</View>
<View style={styles.switchContainer}>
<Switch
Expand All @@ -101,7 +104,7 @@ export default class WhiteListTips extends PureComponent {
</TouchableOpacity>
<View style={styles.textContentDes}>
<Text style={styles.text12}>
您可以将此操作列入白名单,下次就不必在此授权。
{messges[locale].transaction_detail_text_agree_whitelist}
</Text>
</View>
</View>
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
8 changes: 5 additions & 3 deletions shared/components/WalletCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import CurrencyText from 'components/CurrencyText'
import LinearGradientContainer from 'components/LinearGradientContainer'
import { View, Text, TouchableWithoutFeedback } from 'react-native'
import Ionicons from 'react-native-vector-icons/Ionicons'
import messages from 'resources/messages'
import Colors from 'resources/colors'
import styles from './styles'

export default ({ accountType, accountName, balanceTitle, eosValue, eosAmount, active, colors, imported, onPress }) => (
export default ({ locale, accountType, accountName, balanceTitle, eosValue, eosAmount, active, colors, imported, onPress }) => (
<TouchableWithoutFeedback disabled={imported} onPress={onPress}>
<View style={styles.cardContainer}>
<LinearGradientContainer type="right" colors={imported ? Colors.disabled : colors} style={[styles.contentContainer, styles.topRadius]}>
Expand All @@ -22,19 +23,20 @@ export default ({ accountType, accountName, balanceTitle, eosValue, eosAmount, a
imported &&
<View style={[styles.textRadius, { paddingHorizontal: 6, paddingVertical: 3, marginLeft: 10 }]}>
<Text style={[styles.text12, { color: Colors.textColor_255_76_118 }]}>
已导入
{messages[locale].add_import_success_label_imported}
</Text>
</View>
}
{
active &&
<View style={[styles.textRadius, { paddingHorizontal: 6, paddingVertical: 3, marginLeft: 10 }]}>
<Text style={[styles.text12, { color: Colors.textColor_255_76_118 }]}>
当前钱包
{messages[locale].add_import_success_label_current}
</Text>
</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
20 changes: 20 additions & 0 deletions shared/resources/messages/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@
"transaction_label_status_failed": "Failed",
"transaction_label_status_completed": "Completed",

"transaction_detail_label_enable_whitelist": "Enable whitelist",
"transaction_detail_button_advanced_settings": "Advanced",
"transaction_detail_text_agree_whitelist": "You can whitelist this action and don't have to authorize it next time.",
"transaction_detail_text_enable_advanced_settings": "You don't need to confirm transaction popup by enabling advanced. You can turn it off in wallet management.",

"wallet_mgmt_button_whitelist_detail": "Whitelist Details",
"wallet_mgmt_whitelist_title_whitelist": "Whitelist List",
"wallet_mgmt_whitelist_label_enabled_dapps": "Enabled DApps",
"wallet_mgmt_whitelist_label_advance_settings": "Advanced",
"wallet_mgmt_whitelist_text_no_enabled_dapps": "You have not authorized any whitelist DApps.",

"account_change_title_change": "Change Account",
"account_change_button_add_account": "Add",
"add_import_success_label_imported": "Imported",
"add_import_success_label_current": "Current",

"whitelist_title_tips": "Tips",
"whitelist_title_content": "DApp’s whitelist has moved to App Setting, meanwhile, we added an advanced mode to improve the experience. Do you wanna turn it on?",

"resource_label_available": "Available",
"resource_label_total": "Total",
"resource_label_used": "Used",
Expand Down Expand Up @@ -351,6 +370,7 @@
"settings_button_language": "Language",
"settings_button_currency": "Default Currency",
"settings_button_node": "Node Settings",
"settings_label_whitelist": "Whitelist",
"settings_node_label_default_node": "Default Node",
"settings_node_label_customized_node": "Custom Node",
"settings_node_button_add_node": "Add Node",
Expand Down
21 changes: 21 additions & 0 deletions shared/resources/messages/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@
"transaction_detail_button_confirm": "확인",
"transaction_label_status_failed": "실패",
"transaction_label_status_completed": "완료",

"transaction_detail_label_enable_whitelist": "Enable whitelist",
"transaction_detail_button_advanced_settings": "Advanced",
"transaction_detail_text_agree_whitelist": "You can whitelist this action and don't have to authorize it next time.",
"transaction_detail_text_enable_advanced_settings": "You don't need to confirm transaction popup by enabling advanced. You can turn it off in wallet management.",

"wallet_mgmt_button_whitelist_detail": "Whitelist Details",
"wallet_mgmt_whitelist_title_whitelist": "Whitelist List",
"wallet_mgmt_whitelist_label_enabled_dapps": "Enabled DApps",
"wallet_mgmt_whitelist_label_advance_settings": "Advanced",
"wallet_mgmt_whitelist_text_no_enabled_dapps": "You have not authorized any whitelist DApps.",

"account_change_title_change": "Change Account",
"account_change_button_add_account": "Add",
"add_import_success_label_imported": "Imported",
"add_import_success_label_current": "Current",

"whitelist_title_tips": "Tips",
"whitelist_title_content": "DApp’s whitelist has moved to App Setting, meanwhile, we added an advanced mode to improve the experience. Do you wanna turn it on?",

"resource_label_available": "Available",
"resource_label_total": "Total",
"resource_label_used": "사용됨",
Expand Down Expand Up @@ -329,6 +349,7 @@
"settings_button_language": "언어",
"settings_button_currency": "시스템 언어",
"settings_button_node": "노드 설정",
"settings_label_whitelist": "Whitelist",
"settings_node_label_default_node": "시스템 노드",
"settings_node_label_customized_node": "커스텀 노드",
"settings_node_button_add_node": "노드 추가",
Expand Down
20 changes: 20 additions & 0 deletions shared/resources/messages/zh/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@
"transaction_label_status_failed": "已失败",
"transaction_label_status_completed": "已确认",

"transaction_detail_label_enable_whitelist": "开启白名单",
"transaction_detail_button_advanced_settings": "高级设置",
"transaction_detail_text_agree_whitelist": "您可以将此操作列入白名单,下次就不必再次授权。",
"transaction_detail_text_enable_advanced_settings": "打开高级设置,下次进行该操作时,无需进行弹窗确认直接执行,开启后可前往钱包管理中关闭",

"wallet_mgmt_button_whitelist_detail": "白名单详情",
"wallet_mgmt_whitelist_title_whitelist": "白名单列表",
"wallet_mgmt_whitelist_label_enabled_dapps": "已开启应用",
"wallet_mgmt_whitelist_label_advance_settings": "高级设置",
"wallet_mgmt_whitelist_text_no_enabled_dapps": "暂无任何授权白名单的应用",

"account_change_title_change": "切换账户",
"account_change_button_add_account": "添加账户",
"add_import_success_label_imported": "已导入",
"add_import_success_label_current": "当前钱包",

"whitelist_title_tips": "提示",
"whitelist_title_content": "DApp白名单开关已经移置设置,新增了体验更流畅的高级模式,是否前往开启白名单功能?",

"resource_label_available": "可用",
"resource_label_total": "总量",
"resource_label_used": "已用",
Expand Down Expand Up @@ -350,6 +369,7 @@
"settings_button_language": "语言",
"settings_button_currency": "默认货币",
"settings_button_node": "节点设置",
"settings_label_whitelist": "白名单功能",
"settings_node_label_default_node": "默认节点",
"settings_node_label_customized_node": "自定义节点",
"settings_node_button_add_node": "添加节点",
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
Loading

0 comments on commit 7af4935

Please sign in to comment.