Skip to content

Commit

Permalink
Merge pull request #109 from StevenJNPearce/master
Browse files Browse the repository at this point in the history
add option for 24 word mnemonic
  • Loading branch information
0xthreebody authored Apr 11, 2019
2 parents 0c328bc + 42c008f commit 3ca36b7
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/code/Assets/secondary/Create_Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,30 @@ export default class Polkawallet extends Component {
isModel:false,
way:this.state.way_change,
})
let key;
if(this.state.way_change == 'Keystore'){
this.setState({
key:'',
address:''
})
return;
}else if(this.state.way_change === 'Mnemonic'){
key = mnemonicGenerate()
}else if(this.state.way_change === 'Mnemonic24'){
key = mnemonicGenerate(24)

}else{
let key = this.state.way_change=='Mnemonic'?mnemonicGenerate():u8aToHex(randomAsU8a())
this.pair = keyring.addFromMnemonic(key)
this.setState({
key:key,
address:this.pair.address()
})
key = u8aToHex(randomAsU8a())
}
this.pair = keyring.addFromMnemonic(key)
this.setState({
key:key,
address:this.pair.address()
})
}

onChangekey(Changekey){
if(this.state.way=='Mnemonic')
if(this.state.way=='Mnemonic' || 'Mnemonic24')
{
// alert('1')
this.pair = keyring.addFromMnemonic(Changekey)
Expand Down Expand Up @@ -181,21 +188,27 @@ export default class Polkawallet extends Component {

}
Reset(){
if(this.state.way=='Keystore'){
let key;
if(this.state.way == 'Keystore'){
this.setState({
key:'',
address:'',
balance:0
balance: 0
})

return;
}else if(this.state.way === 'Mnemonic'){
key = mnemonicGenerate()
}else if(this.state.way === 'Mnemonic24'){
key = mnemonicGenerate(24)

}else{
let key = this.state.way=='Mnemonic'?mnemonicGenerate():u8aToHex(randomAsU8a())
this.pair = keyring.addFromMnemonic(key)
this.setState({
key:key,
address:this.pair.address()
})
key = u8aToHex(randomAsU8a())
}
this.pair = keyring.addFromMnemonic(key)
this.setState({
key:key,
address:this.pair.address()
})
}
unit(){
(async()=>{
Expand Down Expand Up @@ -386,7 +399,7 @@ export default class Polkawallet extends Component {
{/* 密钥 */}
<View style={[styles.NandP,{height:ScreenHeight/5.5}]}>
<View style={{alignItems:'center',flexDirection:'row',height:ScreenHeight/23}}>
<Text style={{fontSize:ScreenWidth/33}}>create from mnemonic,seed or import keystore</Text>
<Text style={{fontSize:ScreenWidth/33}}>Create from mnemonic,seed or import keystore</Text>
{/* 选择方式 */}
<TouchableOpacity style={styles.Choose_way}
onPress={()=>{
Expand Down Expand Up @@ -649,7 +662,8 @@ export default class Polkawallet extends Component {
onValueChange={(value) => this.setState({way_change: value})}
androidmode = {'dropdown'}
>
<Picker.Item label="Mnemonic" value="Mnemonic" />
<Picker.Item label="12 Word Mnemonic" value="Mnemonic" />
<Picker.Item label="24 Word Mnemonic" value="Mnemonic24" />
<Picker.Item label="Raw Seed" value="Raw Seed" />
<Picker.Item label="import keystore" value="Keystore" />
</Picker>
Expand Down

0 comments on commit 3ca36b7

Please sign in to comment.