Skip to content

Commit

Permalink
Merge pull request #89 from polkawallet-io/develop0307
Browse files Browse the repository at this point in the history
change_name&Validators&Next_Up&Nominating&MyNominators&proposals
  • Loading branch information
0xthreebody authored Mar 7, 2019
2 parents 4131133 + 6f966af commit 7a73ec3
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 36 deletions.
2 changes: 1 addition & 1 deletion ios/Polkawallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.10</string>
<string>1.11</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Polkawallet",
"version": "0.0.10",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
Expand Down
29 changes: 27 additions & 2 deletions src/code/Democracy/proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Proposals=[
]
import { observer, inject } from "mobx-react";
import { async } from 'rxjs/internal/scheduler/async';
import { array } from 'prop-types';
@inject('rootStore')
@observer
export default class Polkawallet extends Component {
Expand Down Expand Up @@ -65,7 +66,31 @@ export default class Polkawallet extends Component {
})
for(i=0;i<this.state.Index.length;i++){
balance = await api.query.democracy.depositOf(this.state.Index[i])
this.state.balances.push((JSON.parse(balance))[0])
if(balance){
this.state.balances.push((JSON.parse(balance))[0])
}
this.setState({})
}
for(i=0;i<this.state.balances.length;i++){
for(j=0;j<this.state.balances.length-i-1;j++){
if(this.state.balances[j]<this.state.balances[j+1]){
// console.warn(this.state.publicProps[j+1])
tmp = this.state.balances[j]
this.state.balances[j] = this.state.balances[j+1]
this.state.balances[j+1] = tmp
tmp_publicProps = this.state.publicProps[j]
this.state.publicProps[j] = this.state.publicProps[j+1]
this.state.publicProps[j+1] = tmp_publicProps
tmp_Actives_Nofixed = this.state.Actives_Nofixed[j]
this.state.Actives_Nofixed[j] = this.state.Actives_Nofixed[j+1]
this.state.Actives_Nofixed[j+1] = tmp_Actives_Nofixed
tmp_Actives_Nofixedvalue = this.state.Actives_Nofixedvalue[j]
this.state.Actives_Nofixedvalue[j] = this.state.Actives_Nofixedvalue[j+1]
this.state.Actives_Nofixedvalue[j+1] = tmp_Actives_Nofixedvalue
this.setState({})
}
this.setState({})
}
this.setState({})
}
})();
Expand Down Expand Up @@ -106,7 +131,7 @@ export default class Polkawallet extends Component {
style={{marginLeft:ScreenWidth/40,height:ScreenHeight/50,width:ScreenHeight/50,resizeMode:'contain'}}
source={require('../../images/Democracy/time.png')}
/>
<Text style={{fontWeight:'500',marginLeft:ScreenWidth/80,color:'#90BD5B',fontSize:ScreenWidth/35}}>{this.state.launchCountdown}</Text>
<Text style={{fontWeight:'500',marginLeft:ScreenWidth/80,color:'#90BD5B',fontSize:ScreenWidth/35}}>{this.state.launchCountdown+9*index}</Text>
<Text style={{fontWeight:'500',color:'#90BD5B',fontSize:ScreenWidth/40}}> {' blocks launch'}</Text>
<View style={{flex:1}}></View>
<Text style={{marginRight:ScreenWidth/70,fontSize:ScreenWidth/26}}>{'#'+item[0]}</Text>
Expand Down
46 changes: 33 additions & 13 deletions src/code/Democracy/referendums/Active.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import Api from '@polkadot/api/promise';
import WsProvider from '@polkadot/rpc-provider/ws';
import { Method } from '@polkadot/types';
import formatBalance from '../../../util/formatBalance'

import { VictoryPie} from "victory-native";

Expand All @@ -37,7 +38,27 @@ export default class Polkawallet extends Component {
votingState:[],
votingStateIndex:[],
}
// this.votingState=this.votingState.bind(this)
this.votingState=this.votingState.bind(this)
this.Nay=this.Nay.bind(this)
this.Aye=this.Aye.bind(this)
}
Nay(votingState){
let balance = 0
for(i=0;i<votingState.msg.length;i++){
if(JSON.stringify(votingState.msg[i].vote) == '"0x00"'){
balance = balance + Number(votingState.msg[i].balance)
}
}
return balance
}
Aye(votingState){
let balance = 0
for(i=0;i<votingState.msg.length;i++){
if(JSON.stringify(votingState.msg[i].vote) == '"0xff"'){
balance = balance + Number(votingState.msg[i].balance)
}
}
return balance
}
votingState(){
(async()=>{
Expand Down Expand Up @@ -102,18 +123,18 @@ export default class Polkawallet extends Component {
info = item.unwrapOr(null)
if (info) {
let {meta, method, section } = Method.findFunction(info.proposal.callIndex)
have = 0
this.state.Actives_Title.push({section:section,method:method})
this.state.Actives_Nofixedvalue.push(info.proposal.args)
this.state.Actives_Nofixed.push(meta.arguments)
this.state.referendums.push(info)
this.state.votingIndex.push(info.index)
this.props.rootStore.stateStore.have = 0
for(i=0;i<this.state.votingState.length;i++){
if(this.state.votingState[i].index==index){
this.props.rootStore.stateStore.have=1
have = 1
}
}
if(this.props.rootStore.stateStore.have == 0){
if(have == 0){
this.state.votingState.push({index:info.index,msg:[]})
}
this.setState({})
Expand All @@ -130,9 +151,10 @@ export default class Polkawallet extends Component {
this.state.votingState[i].msg = result
}
}
alert(JSON.stringify(this.state.votingState))
// alert(JSON.stringify(this.state.votingState))
this.setState({})
})
// alert(JSON.stringify(this.state.votingState))
})()

// this.votingState()
Expand All @@ -149,8 +171,6 @@ export default class Polkawallet extends Component {
// })
// }
// console.warn(this.state.votingState)


})()

}
Expand Down Expand Up @@ -204,15 +224,15 @@ export default class Polkawallet extends Component {
style={{marginLeft:ScreenWidth/40,height:ScreenWidth/17.86*0.52,width:ScreenWidth/17.86,resizeMode:'cover'}}
source={require('../../../images/Democracy/green_ellipse.png')}
/>
<Text style={{marginLeft:ScreenWidth/100,fontSize:ScreenWidth/45}}>{'Aye '+item.Aye}</Text>
<Text style={{marginLeft:ScreenWidth/80,fontSize:ScreenWidth/45,color:'#7ad52a'}}>66.75%</Text>
<Text style={{marginLeft:ScreenWidth/100,fontSize:ScreenWidth/45}}>{'Aye '+formatBalance(this.Aye(this.state.votingState[index]))}</Text>
<Text style={{marginLeft:ScreenWidth/80,fontSize:ScreenWidth/45,color:'#7ad52a'}}>{(this.Aye(this.state.votingState[index])/(this.Aye(this.state.votingState[index])+this.Nay(this.state.votingState[index]))*100).toFixed(2)+'%'}</Text>
<Text style={{fontSize:ScreenWidth/45}}>{'('+item.aye+')'}</Text>
<Image
style={{marginLeft:ScreenWidth/40,height:ScreenWidth/17.86*0.52,width:ScreenWidth/17.86,resizeMode:'cover'}}
source={require('../../../images/Democracy/red_ellipse.png')}
/>
<Text style={{marginLeft:ScreenWidth/100,fontSize:ScreenWidth/45}}>{'Nay '+item.Nay}</Text>
<Text style={{marginLeft:ScreenWidth/80,fontSize:ScreenWidth/45,color:'#fb3232'}}>33.25%</Text>
<Text style={{marginLeft:ScreenWidth/100,fontSize:ScreenWidth/45}}>{'Nay '+formatBalance(this.Nay(this.state.votingState[index]))}</Text>
<Text style={{marginLeft:ScreenWidth/80,fontSize:ScreenWidth/45,color:'#fb3232'}}>{(this.Nay(this.state.votingState[index])/(this.Aye(this.state.votingState[index])+this.Nay(this.state.votingState[index]))*100).toFixed(2)+'%'}</Text>
<Text style={{fontSize:ScreenWidth/45}}>{'('+item.nay+')'}</Text>
</View>
<View style={{flexDirection:'row',marginLeft:ScreenWidth/6,marginVertical:ScreenHeight/70}}>
Expand All @@ -221,8 +241,8 @@ export default class Polkawallet extends Component {
colorScale={['#8fec41','#fb3232']}
innerRadius={ScreenWidth/30}
data={[
{ x: 1, y: 3, },
{ x: 2, y: 1, },
{ x: 1, y: this.Aye(this.state.votingState[index]), },
{ x: 2, y: this.Nay(this.state.votingState[index]), },
]}
height={ScreenWidth/5.86}
width={ScreenWidth/5.86}
Expand Down
2 changes: 1 addition & 1 deletion src/code/Profile/secondary/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class New extends Component {
{/* 版本 */}
<View style={{flex:1}}/>
<View style={[styles.msgView,{marginBottom:ScreenHeight/30}]}>
<Text style={{fontSize:ScreenWidth/25,color:'#808080'}}>Version: 0.0.10</Text>
<Text style={{fontSize:ScreenWidth/25,color:'#808080'}}>Version: 0.1.0</Text>
</View>
</View>
);
Expand Down
12 changes: 6 additions & 6 deletions src/code/Profile/secondary/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class New extends Component {
}

{/* Gesture */}
<View style={[styles.msgView,{marginTop:ScreenHeight/40}]}
{/* <View style={[styles.msgView,{marginTop:ScreenHeight/40}]}
>
<Text style={styles.msgText}>Gesture</Text>
<View style={{flex:1}}/>
Expand All @@ -121,9 +121,9 @@ export default class New extends Component {
value={this.state.Gesture}//默认状态
onValueChange={(e) => this.Gesture(e)} //当状态值发生变化值回调
/>
</View>
</View> */}
{/* Fingerprint */}
<View style={styles.msgView}
{/* <View style={styles.msgView}
>
<Text style={styles.msgText}>Fingerprint</Text>
<View style={{flex:1}}/>
Expand All @@ -132,9 +132,9 @@ export default class New extends Component {
value={this.state.Fingerprint}//默认状态
onValueChange={(e) => this.Fingerprint(e)} //当状态值发生变化值回调
/>
</View>
</View> */}
{/* Facial recognition */}
<View style={styles.msgView}
{/* <View style={styles.msgView}
>
<Text style={styles.msgText}>Facial recognition</Text>
<View style={{flex:1}}/>
Expand All @@ -143,7 +143,7 @@ export default class New extends Component {
value={this.state.Facial_Recognition}//默认状态
onValueChange={(e) => this.Facial_Recognition(e)} //当状态值发生变化值回调
/>
</View>
</View> */}
</View>
);
}
Expand Down
15 changes: 9 additions & 6 deletions src/code/Staking/Staking.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,13 @@ export default class IntegralMall extends Component {
this.props.rootStore.stateStore.nominatingBalance = nominatingBalance
this.props.rootStore.stateStore.sumnominatingBalance = sumnominatingBalance
}

if(this.props.rootStore.stateStore.StakingState==0){
this.props.rootStore.stateStore.StakingState=1
}

setTimeout(()=>{
if(this.props.rootStore.stateStore.StakingState==0){
this.props.rootStore.stateStore.StakingState=1
}
},1000)


//实时监控
setInterval(async()=>{
Expand Down Expand Up @@ -296,7 +299,7 @@ export default class IntegralMall extends Component {
sumnominatorsBalance2: sumnominatorsBalance2
})
}
},5000)
},30000)

// 找出Next up
_intentions=[]
Expand Down Expand Up @@ -567,7 +570,7 @@ export default class IntegralMall extends Component {
}}
>
<Text style={{color:this.state.titlebottomAA==1?'#005bae':'#696969',fontSize:ScreenWidth/30}}>
Staking Records
Slash Records
</Text>
</TouchableOpacity>
<TouchableOpacity
Expand Down
2 changes: 1 addition & 1 deletion src/code/Staking/secondary/Validator_Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default class IntegralMall extends Component {
}}
>
<Text style={{color:this.state.titlebottomAA==2?'#005bae':'#696969',fontSize:ScreenWidth/30}}>
Staking Records
Slash Records
</Text>
</TouchableOpacity>
<View
Expand Down
6 changes: 3 additions & 3 deletions src/code/Staking/secondary/unnominate.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ import { set } from 'mobx';
<View style={{flex:1,justifyContent:'center',alignItems:'flex-end'}}>
<View style={{marginRight:ScreenWidth*0.08-ScreenWidth/40,flexDirection:'row',height:ScreenHeight/20,width:ScreenWidth*0.7,alignItems:'center',justifyContent:'flex-end'}}>
<View style={{alignItems:'center',flexDirection:'row',justifyContent:'center'}}>
<TouchableOpacity style={{flexDirection:'row',alignItems:'center',justifyContent:'center',borderRadius:5,backgroundColor:'#FF4081',height:ScreenHeight/20,width:ScreenWidth*0.2}}
<TouchableOpacity style={{flexDirection:'row',alignItems:'center',justifyContent:'center',borderRadius:5,backgroundColor:'#FF4081',height:ScreenHeight/20,width:ScreenWidth*0.25}}
onPress={this.Cancel}
>

Expand All @@ -178,7 +178,7 @@ import { set } from 'mobx';
</TouchableOpacity>
{this.state.onlyone==0?
<TouchableOpacity
style={{flexDirection:'row',alignItems:'center',justifyContent:'center',borderRadius:5,backgroundColor:'#97BEC7',marginLeft:ScreenWidth/100,height:ScreenHeight/20,width:ScreenWidth*0.2}}
style={{flexDirection:'row',alignItems:'center',justifyContent:'center',borderRadius:5,backgroundColor:'#97BEC7',marginLeft:ScreenWidth/100,height:ScreenHeight/20,width:ScreenWidth*0.25}}
onPress={this.Nominate}
>

Expand All @@ -188,7 +188,7 @@ import { set } from 'mobx';
</TouchableOpacity>
:
<View
style={{flexDirection:'row',alignItems:'center',justifyContent:'center',borderRadius:5,backgroundColor:'#97BEC7',marginLeft:ScreenWidth/100,height:ScreenHeight/20,width:ScreenWidth*0.2}}
style={{flexDirection:'row',alignItems:'center',justifyContent:'center',borderRadius:5,backgroundColor:'#97BEC7',marginLeft:ScreenWidth/100,height:ScreenHeight/20,width:ScreenWidth*0.25}}
>

<Text style={{fontWeight:'500',fontSize:ScreenWidth/28,color:'white'}}>
Expand Down
4 changes: 2 additions & 2 deletions src/mobx/mobx.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class stateStore{

//wss
@observable
// ENDPOINT = 'wss://poc3-rpc.polkadot.io/';
ENDPOINT = 'wss://poc3-rpc.polkadot.io/';
// ENDPOINT = 'ws://107 .173.250.124:9944/';
ENDPOINT = 'ws://127.0.0.1:9944/';
// ENDPOINT = 'ws://127.0.0.1:9944/';

// 是否是第一次登陆
@observable
Expand Down

0 comments on commit 7a73ec3

Please sign in to comment.