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

feat: Show accounts with unknown network #392

Merged
merged 24 commits into from
Oct 7, 2019
Merged

feat: Show accounts with unknown network #392

merged 24 commits into from
Oct 7, 2019

Conversation

Tbaut
Copy link
Contributor

@Tbaut Tbaut commented Sep 17, 2019

closes #389

How to test:

  • create a Kusama account (1)
  • modify the genesisHash aka networkKey of Kusama in src/constants.js
  • reload the App

Because the genesisHash used to create (1) isn't known any more, we can't match the Kusama Network. Still this account can be seen, its backup retrieved with the pin and deleted.

edit:
This was quite a painful PR, trying to remove many weird things that were done. Now we use the same [key, value] mapping in the accountStore and in the db. This allows to show accounts which we have no corresponding NetworkKey. It also helps to seemlessly save or delete accounts (even if the network is not known) because the db and the store have the same keys.

This PR introduces the notion of selectedKey that corresponds to a selectedAccount (more broadly named selected in the app). I think it's quite straightforward, we should use this key as much as possible and only use accountId() when dealing with Data coming in (QR code scanning) or saving new accounts.

I tested the migration but please feel free to do it as well (as explained here)

image
image

@hanwencheng
Copy link
Contributor

Thanks for the PR! I have not start the part to change the account store, but basically I will change some state to the account, and will use promise to pipeline the authentication and account getter functions. I agree with the new way to access the account data, and I think merging will not be a big problem.

this.scrollToIndex = this.scrollToIndex.bind(this);
}

scrollToIndex() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is useless IMO, and barely working. Removing it (it was playing with accountIds as well)

@@ -51,10 +51,6 @@ export default class MessageDetails extends React.PureComponent {
message={isU8a(message) ? u8aToHex(message) : message}
dataToSign={isU8a(dataToSign) ? u8aToHex(dataToSign) : dataToSign}
isHash={scannerStore.getIsHash()}
onPressAccount={async account => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an unwanted behaviour that is not related to this PR. Users shouldn't be able to click on an account card in the message details view.

@@ -126,7 +126,7 @@ export default class ScannerStore extends Container<ScannerState> {
// all the frames are filled
if (Object.keys(this.state.multipartData.length) === frameCount) {
// fixme: this needs to be concated to a binary blob
const concatMultipartData = Object.keys(this.state.multipartData).reduce((result, data) => res.concat(this.state.multipartData[data]));
const concatMultipartData = Object.keys(this.state.multipartData).reduce((result, data) => result.concat(this.state.multipartData[data]));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also unrelated to this PR, and this code isn't used (yet) now that's a bug for sure :)

JSON.stringify(account, null, 0),
accountsStore
);

export const saveAccounts = accounts => accounts.forEach(saveAccount);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

never used

@Tbaut Tbaut marked this pull request as ready for review October 2, 2019 13:49
@hanwencheng
Copy link
Contributor

hanwencheng commented Oct 4, 2019

When creating new account, there is still the UNKNOWN NETWORK:

WechatIMG5

Need to be removed from AccountNetworkChooser.js

src/util/db.js Outdated Show resolved Hide resolved
@Tbaut Tbaut changed the title Show accounts with unknown network Feat: Show accounts with unknown network Oct 4, 2019
>
<Text
{ Object.entries(NETWORK_LIST)
.filter(([networkKey]) => networkKey !== UnKnownNetworkKeys.UNKNOWN )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The commit looks bigger than it is, all I did is add this filter to make sure Unkown network isn't showing up.

@Tbaut
Copy link
Contributor Author

Tbaut commented Oct 4, 2019

Nice catch, thanks for the review. Your comments were addressed :)

Copy link
Contributor

@pmespresso pmespresso left a comment

Choose a reason for hiding this comment

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

nits

src/screens/AccountList.js Show resolved Hide resolved
src/screens/AccountNetworkChooser.js Outdated Show resolved Hide resolved
src/screens/MessageDetails.js Outdated Show resolved Hide resolved
src/stores/AccountsStore.js Outdated Show resolved Hide resolved
src/stores/AccountsStore.js Outdated Show resolved Hide resolved
src/util/db.js Outdated Show resolved Hide resolved
src/util/db.js Outdated Show resolved Hide resolved
src/util/db.js Outdated Show resolved Hide resolved
Tbaut and others added 8 commits October 5, 2019 01:38
Co-Authored-By: YJ <yjkimjunior@gmail.com>
Co-Authored-By: YJ <yjkimjunior@gmail.com>
Co-Authored-By: YJ <yjkimjunior@gmail.com>
Co-Authored-By: YJ <yjkimjunior@gmail.com>
Co-Authored-By: YJ <yjkimjunior@gmail.com>
Co-Authored-By: YJ <yjkimjunior@gmail.com>
Co-Authored-By: YJ <yjkimjunior@gmail.com>
@Tbaut Tbaut changed the title Feat: Show accounts with unknown network feat: Show accounts with unknown network Oct 4, 2019
@pmespresso pmespresso merged commit eadd765 into master Oct 7, 2019
@pmespresso pmespresso deleted the tbaut-unknown branch October 7, 2019 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mechanism to prevent the worse
3 participants