This repository was archived by the owner on Oct 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 129
Fix: saving serialized keyring for which corresponding keyring class is not present #169
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d29aa3
Fix: adding null check to avoid error if KeyringClass for a keyring t…
jpuri 1010659
fix
jpuri fbea40f
fix
jpuri 3ac20f2
Adding unit test coverage
jpuri 3e36a68
fix
jpuri 3003ebc
Update index.js
jpuri 0bc0bc5
Update test/index.js
jpuri 14416d9
fix
jpuri e0b7b80
fix
jpuri 4927bbc
fix
jpuri 9b33800
Update test/index.js
jpuri f1e7a62
fixes
jpuri 9d0316d
Update test/index.js
jpuri 4769865
merge
jpuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ class KeyringController extends EventEmitter { | |
|
|
||
| this.encryptor = opts.encryptor || encryptor; | ||
| this.keyrings = []; | ||
| this._unsupportedKeyrings = []; | ||
|
|
||
| // This option allows the controller to cache an exported key | ||
| // for use in decrypting and encrypting data without password | ||
|
|
@@ -562,6 +563,8 @@ class KeyringController extends EventEmitter { | |
| }), | ||
| ); | ||
|
|
||
| serializedKeyrings.push(...this._unsupportedKeyrings); | ||
|
|
||
| let vault; | ||
| let newEncryptionKey; | ||
|
|
||
|
|
@@ -679,7 +682,9 @@ class KeyringController extends EventEmitter { | |
| */ | ||
| async restoreKeyring(serialized) { | ||
| const keyring = await this._restoreKeyring(serialized); | ||
| await this._updateMemStoreKeyrings(); | ||
| if (keyring) { | ||
| await this._updateMemStoreKeyrings(); | ||
| } | ||
| return keyring; | ||
| } | ||
|
|
||
|
|
@@ -690,12 +695,16 @@ class KeyringController extends EventEmitter { | |
| * On success, returns the resulting keyring instance. | ||
| * | ||
| * @param {Object} serialized - The serialized keyring. | ||
| * @returns {Promise<Keyring>} The deserialized keyring. | ||
| * @returns {Promise<Keyring|undefined>} The deserialized keyring or undefined if the keyring type is unsupported. | ||
| */ | ||
| async _restoreKeyring(serialized) { | ||
| const { type, data } = serialized; | ||
|
|
||
| const Keyring = this.getKeyringClassForType(type); | ||
| if (!Keyring) { | ||
| this._unsupportedKeyrings.push(serialized); | ||
| return undefined; | ||
jpuri marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi @jpuri, late question: when we support hard wallets for MV3, will this logic added in this PR still be needed? |
||
| } | ||
| const keyring = new Keyring(); | ||
| await keyring.deserialize(data); | ||
| // getAccounts also validates the accounts for some keyrings | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.