Repository navigation
Use createNewVaultAndRestore from core KeyringController - #19816
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Builds ready [8314b41]
Page Load Metrics (1654 ± 37 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Codecov Report
@@ Coverage Diff @@
## develop #19816 +/- ##
===========================================
- Coverage 68.84% 68.69% -0.15%
===========================================
Files 993 990 -3
Lines 38258 38083 -175
Branches 10248 10201 -47
===========================================
- Hits 26338 26160 -178
- Misses 11920 11923 +3
|
c65c6b9 to
2d584d7
Compare
|
Depends on #19659 |
95313e3 to
1567ae0
Compare
8314b41 to
e23ac8a
Compare
Builds ready [e23ac8a]
Page Load Metrics (1758 ± 70 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
mcmire
left a comment
There was a problem hiding this comment.
Had a suggestion, but it's non-blocking.
Just checking but it seems there are no changes needed to tests, is this true?
| /** | ||
| * Get a Uint8Array mnemonic from Buffer. | ||
| * | ||
| * @param {Buffer} mnemonic - The mnemonic phrase as a Buffer | ||
| * @returns {Uint8Array} The mnemonic phrase as a Uint8Array | ||
| */ | ||
| _bufferToUint8Array(mnemonic) { | ||
| const indices = mnemonic | ||
| .toString() | ||
| .split(' ') | ||
| .map((word) => wordlist.indexOf(word)); | ||
| return new Uint8Array(new Uint16Array(indices).buffer); | ||
| } |
There was a problem hiding this comment.
This seems like almost the reverse of: #19817 (comment)
What do you think about:
| /** | |
| * Get a Uint8Array mnemonic from Buffer. | |
| * | |
| * @param {Buffer} mnemonic - The mnemonic phrase as a Buffer | |
| * @returns {Uint8Array} The mnemonic phrase as a Uint8Array | |
| */ | |
| _bufferToUint8Array(mnemonic) { | |
| const indices = mnemonic | |
| .toString() | |
| .split(' ') | |
| .map((word) => wordlist.indexOf(word)); | |
| return new Uint8Array(new Uint16Array(indices).buffer); | |
| } | |
| /** | |
| * Encodes a BIP-39 mnemonic as the indices of words in the English BIP-39 wordlist. | |
| * | |
| * @param {Buffer} mnenonic - The BIP-39 mnemonic. | |
| * @returns {Buffer} The Unicode code points for the seed phrase formed from the words in the wordlist. | |
| */ | |
| _convertMnemonicToWordlistIndices(mnemonic) { | |
| const indices = mnemonic | |
| .toString() | |
| .split(' ') | |
| .map((word) => wordlist.indexOf(word)); | |
| return new Uint8Array(indices); | |
| } |
It might be good to relocate this and the other function to some kind of utility file as they're related operations, but this seems fine for now.
There was a problem hiding this comment.
Makes sense! I just applied your suggestion.
Do you think that makes sense to merge the two PRs and then move the two methods to another file in a later PR?
There was a problem hiding this comment.
Uhm, it looks like this doesn't work. I noticed that also in @metamask/eth-hd-keyring we convert indices to Uint16Array before converting them finally to Uint8Array.
I'm not exactly sure why this is needed though
4e5b9a9 to
fc64a7b
Compare
@mcmire We already have test coverage for this method, but I've just refactored the tests to mock |
b672917 to
28be6d0
Compare
Builds ready [28be6d0]
Page Load Metrics (1689 ± 63 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
28be6d0 to
ae61eeb
Compare
Builds ready [ae61eeb]
Page Load Metrics (1484 ± 37 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
ae61eeb to
e8db201
Compare
Builds ready [e8db201]
Page Load Metrics (1466 ± 35 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Explanation
With this PR the extension starts using
createNewVaultAndRestorefrom coreKeyringController, instead of callingEthKeyringControllerdirectly.createNewVaultAndRestorefrom core KeyringController #18769Screenshots/Screencaps
Before
After
Manual Testing Steps
Pre-merge author checklist
Pre-merge reviewer checklist
If further QA is required (e.g. new feature, complex testing steps, large refactor), add the
Extension QA Boardlabel.In this case, a QA Engineer approval will be be required.