Commit b62b983d authored by Thibaut Sardan's avatar Thibaut Sardan
Browse files

fix(): init

parent ec2a44ee
......@@ -56,11 +56,12 @@ export default class AccountIconChooser extends React.PureComponent<{
.split(' ')
.map(async () => {
const seed = await words();
const { address } = await brainWalletAddress(seed);
const { address, bip39 } = await brainWalletAddress(seed);
return {
address,
seed,
address
bip39
};
})
);
......@@ -75,6 +76,7 @@ export default class AccountIconChooser extends React.PureComponent<{
renderIcon = ({ item, index }) => {
const { value, onChange } = this.props;
const { address, seed, bip39} = item;
const iSelected = item.address.toLowerCase() === value.toLowerCase();
const style = [styles.icon];
......@@ -84,8 +86,9 @@ export default class AccountIconChooser extends React.PureComponent<{
style={[styles.iconBorder, iSelected ? styles.selected : {}]}
onPress={() =>
onChange({
address: item.address,
seed: item.seed
address,
seed,
bip39
})
}
>
......
......@@ -73,8 +73,8 @@ class AccountNewView extends React.Component {
</Text>
<AccountIconChooser
value={selected && selected.seed && selected.address}
onChange={({ address, seed }) => {
accounts.updateNew({ address, seed });
onChange={({ address, seed, bip39 }) => {
accounts.updateNew({ address, seed, validBip39Seed: bip39 }, false);
}}
/>
<Text style={styles.title}>ACCOUNT NAME</Text>
......
......@@ -65,18 +65,35 @@ export default class AccountsStore extends Container<AccountsState> {
});
}
updateNew(accountUpdate: Object) {
Object.assign(this.state.newAccount, accountUpdate);
const { seed } = this.state.newAccount;
if (typeof seed === 'string') {
updateNew(accountUpdate: Object, recalculateAddress: boolean = true) {
// Object.assign(this.state.newAccount, accountUpdate);
// const { seed } = this.state.newAccount;
// if (typeof seed === 'string') {
// debounce(async () => {
// const { bip39, address } = await brainWalletAddress(seed);
// Object.assign(this.state.newAccount, { address, validBip39Seed: bip39 });
// this.setState({});
// }, 200)();
// }
// this.setState({});
const { newAccount } = this.state;
const { seed } = accountUpdate;
console.log('hop',accountUpdate)
if ( seed && recalculateAddress ){
this.setState({newAccount :{...newAccount, seed}});
debounce(async () => {
const { bip39, address } = await brainWalletAddress(seed);
Object.assign(this.state.newAccount, { address, validBip39Seed: bip39 });
this.setState({});
}, 200)();
console.log('back',{ newAccount : {...newAccount, ...accountUpdate, address, validBip39Seed: bip39} })
this.setState({ newAccount : {...newAccount, ...accountUpdate, address, validBip39Seed: bip39} })
console.log('we update to',{ newAccount : {...newAccount, ...accountUpdate, address, validBip39Seed: bip39} })
}, 200)()
} else {
this.setState({ newAccount : {...newAccount, ...accountUpdate} })
console.log('without calculation',{ newAccount : {...newAccount, ...accountUpdate} })
}
this.setState({});
}
getNew(): Account {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment