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

fix keychain deserialize #735

Merged
merged 9 commits into from
Jul 10, 2023
Merged

fix keychain deserialize #735

merged 9 commits into from
Jul 10, 2023

Conversation

greg-schrammel
Copy link
Contributor

Fixes BX-####
Figma link (if any):

What changed (plus any additional context for devs)

Screen recordings / screenshots

What to test

Final checklist

  • I have tested my changes in a LavaMoat bundle (yarn build).
  • I have tested my changes in Chrome & Brave.
  • If your changes are visual, did you check both the light and dark themes?

Comment on lines 92 to 93
if (opts.accountsDeleted?.length)
privates.get(this).accountsDeleted = opts.accountsDeleted;
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 the bug fix, the rest I just replaced the ?. with a single check on top

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-6b2486525c46b3cc61572f01e95e6bf5a657e3e3.zip

@@ -140,7 +140,9 @@ export class HdKeychain implements IKeychain {

async removeAccount(address: Address): Promise<void> {
const accounts = await this.getAccounts();
console.log('accounts', accounts);
Copy link
Member

Choose a reason for hiding this comment

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

👀

Copy link
Member

Choose a reason for hiding this comment

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

+2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-af830a18a8f1088b10fdb8ab30e1b8c941c20770.zip

Copy link
Member

@brunobar79 brunobar79 left a comment

Choose a reason for hiding this comment

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

Good stuff! 💯

@@ -8,17 +9,36 @@ import { KeychainType } from '~/core/types/keychainTypes';
import { IKeychain, PrivateKey } from '../IKeychain';
import { autoDiscoverAccounts } from '../utils';

type SupportedHDPath = "m/44'/60'/0'/0";
Copy link
Member

Choose a reason for hiding this comment

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

We have this HD path hardcoded in like 3 different files now, we should probably move it to a common place.
(No need to do it right now)

`${privates.get(this).hdPath}/${index}`,
);
const _privates = privates.get(this)!;
if (!_privates.mnemonic) throw new Error('No mnemonic');
Copy link
Member

Choose a reason for hiding this comment

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

Would this ever happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only If it's called without calling init() first, I let the types guide me here, if ts said it can I it can, same for the others

pretty sure it should never happen in production, but these throws helped me find a bug I introduced elsewhere faster, so I think it's good for when we are changing code related

const wallet = privates.get(this).getWalletForAddress(address);
const _privates = privates.get(this)!;
const wallet = _privates.getWalletForAddress(address);
if (!wallet?._isSigner) throw new Error('Not a signer');
Copy link
Member

Choose a reason for hiding this comment

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

same here

return wallet;
}

async serialize(): Promise<SerializedHdKeychain> {
const _privates = privates.get(this)!;
if (!_privates.mnemonic) throw new Error('No mnemonic');
Copy link
Member

Choose a reason for hiding this comment

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

and here

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-7eadc26ef5803f6fcccac4547067da859d6f9593.zip

Copy link
Member

@derHowie derHowie left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@BrodyHughes BrodyHughes left a comment

Choose a reason for hiding this comment

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

creating + deleting wallets & viewing secrets seems to work as intended

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-4a052ce7e30d2b97acd09b84ccd8e4e71788b4ef.zip

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-c4c85ccb30ec92d3914be5f28eb9d94824f37a31.zip

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-ccdbccda5a1723223ecf65a0988dc9d2fa355503.zip

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-ccdbccda5a1723223ecf65a0988dc9d2fa355503.zip

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-ccdbccda5a1723223ecf65a0988dc9d2fa355503.zip

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-ccdbccda5a1723223ecf65a0988dc9d2fa355503.zip

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-ccdbccda5a1723223ecf65a0988dc9d2fa355503.zip

@github-actions
Copy link

github-actions bot commented Jul 9, 2023

Here's the packed extension for this build:
rainbowbx-ccdbccda5a1723223ecf65a0988dc9d2fa355503.zip

@github-actions
Copy link

github-actions bot commented Jul 9, 2023

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-4abbe88434834bf8e513e292135c2da0207034fe.zip

@github-actions
Copy link

Here's the packed extension for this build:
rainbowbx-302ffeecc0eb9c0960262112e3c0f26e57ef6169.zip

@greg-schrammel greg-schrammel merged commit d7da33f into master Jul 10, 2023
@greg-schrammel greg-schrammel deleted the fix-remove-account branch July 10, 2023 13:05
@github-actions
Copy link

Here's the packed extension for this build:
node_modules.tar.gz
rainbowbx-d7da33fb1d16eac9f9d7991b09d0e41cad84871c.zip

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.

4 participants