-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance account migration process and ensure complete before lo…
…ading keys
- Loading branch information
Showing
4 changed files
with
56 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,13 +1,32 @@ | ||
/* global chrome */ | ||
|
||
import { AccountsStore } from '@polkadot/extension-base/stores'; | ||
import { keyring } from '@polkadot/ui-keyring'; | ||
import { cryptoWaitReady } from '@polkadot/util-crypto'; | ||
|
||
import { fatalErrorHandler } from '@polymeshassociation/extension-core/utils'; | ||
|
||
import { checkForUpdateAndMigrate } from './migrations'; | ||
|
||
// Ensure crypto is ready and load all keyring data | ||
async function initializeCryptoAndKeyring () { | ||
await cryptoWaitReady(); | ||
console.log('crypto initialized'); | ||
|
||
keyring.loadAll({ store: new AccountsStore(), type: 'sr25519' }); | ||
console.log('initialization completed'); | ||
} | ||
|
||
/* | ||
This is placed in a separate file to ensure that the listener is registered immediately, | ||
avoiding any delays caused by other imports or initializations. When placed in background.ts | ||
it was not being registered before the event was emitted. | ||
*/ | ||
|
||
chrome.runtime.onInstalled.addListener((details) => { | ||
checkForUpdateAndMigrate(details).catch(console.error); | ||
checkForUpdateAndMigrate(details) | ||
.then(() => { | ||
return initializeCryptoAndKeyring(); | ||
}) | ||
.catch(fatalErrorHandler); | ||
}); |
This file contains 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
This file contains 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