Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Mnemonic Wallet #659

Merged
merged 9 commits into from
Dec 28, 2017
Merged

Generate Mnemonic Wallet #659

merged 9 commits into from
Dec 28, 2017

Conversation

wbobeirne
Copy link
Contributor

Closes #109, and addresses a lot of #557. This PR looks a lot bigger than it really is, so don't let the line count fool ya. This reworks the generate flow to give users the option between a keystore file and a mnemonic phrase. You can see #109 for the discussion around all of the changes, or you can just watch the following example videos:

Gfycat - Mnemonic wallet generation

Gfycat - Updated keystore wallet generation


There were a few additional changes related to this:

  • Removed generateWallet redux stuff. Everything is handled in state now.
    • Rather than have two separate flows share the same reducer, or add a new reducer, I decided the extremely simple data related to this could be kept in state. If there ever comes a need to output actions, we can add some info-only actions that get fired.
  • Removed sidebar from generate altogether.
    • As @tayvano noted, we may want to add back in the guide links somewhere in the flow. Feedback is welcome on where they could fit!
  • Re-organized files and styles to better match other tabs.
    • That's where the bulk of the additions / removals come from.

@wbobeirne wbobeirne added the status: ready for review Open PR's that are ready for technical review. Replaced with "changes needed" or "ready to merge". label Dec 23, 2017
@dternyak
Copy link
Contributor

Tested, works great!

Implementation looks great as well.

I did notice that there is no way to reset or go back once you have selected a keystore / mnemonic based wallet generation. It would be nice to have a restart / back button, but it doesn't need to hold up the merge.

Copy link

@HenryNguyen5 HenryNguyen5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just from doing a code review it all looks really well done, but I'm not sure how I feel about multi-layer nested inline JSX vs having them outside of the return value / using smaller helper funcs

walletType: WalletType;
}

export default class FinalSteps extends React.Component<Props> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be an SFC instead, and then you can have all the logic in a separate function too

</p>

<div className="GenerateMnemonic-words">
{[firstHalf, lastHalf].map((ws, i) => (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider unrolling the first level array just to reduce complexity, with having a helper function / SFC generate the Word components

Copy link
Contributor Author

@wbobeirne wbobeirne Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on

unrolling the first level array

Not sure what that looks like

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I simplified this by making a makeWord helper function.

};

private handleConfirmChange = (index: number, value: string) => {
console.log(index, value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got some console logs here

const confirmValues = [...this.state.confirmValues];
confirmValues[index] = value;
console.log(confirmValues);
this.setState({ confirmValues });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could all be done with a setState cb that'll give you the previous state. Should be more clean.

<div className="MnemonicWord-word input-group">
<input
className={classnames({
'MnemonicWord-word-input': true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortened to

classnames(
               'MnemonicWord-word-input',
               'form-control',
               {'is-valid': word === value}
             )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or using the same style as LN 49 to keep it consistent

</div>
</div>
);
return <div className="GenerateWallet Tab-content-pane">{this.props.children}</div>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a SFC instead

onSelect(type: WalletType): void;
}

export default class WalletTypes extends React.Component<Props, {}> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be an SFC too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be dope if there was a linter rule or something that caught implementations of React.Component that only had a render method. I'll convert this, but lmk if you think that's out there.

@wbobeirne
Copy link
Contributor Author

Personally I find keeping the markup as together as possible makes reading the structure of the markup a little easier, but I can pretty easily convert some of those maps to helper functions.

@wbobeirne
Copy link
Contributor Author

@dternyak added a UI back button, but also refactored this so it no longer uses state to keep track of which wallet we're generating, but uses the router instead. This makes the back button work as well. Added routes for /generate, /generate/keystore, and /generate/mnemonic.

screen shot 2017-12-28 at 2 06 29 pm

@HenryNguyen5 I think I addressed everything! Let me know if I got any changes wrong.

@wbobeirne
Copy link
Contributor Author

wbobeirne commented Dec 28, 2017

I alertified the warning text upfront, and made the other wallets actual links:

screen shot 2017-12-28 at 2 40 39 pm

Copy link
Contributor

@dternyak dternyak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited to have this in 👍

@dternyak dternyak merged commit 6513acd into develop Dec 28, 2017
@dternyak dternyak deleted the generate-mnemonic branch December 28, 2017 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready for review Open PR's that are ready for technical review. Replaced with "changes needed" or "ready to merge".
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants