Skip to content

Commit

Permalink
Fix loading imported tokens before the NNS account was created.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrasinskis committed Aug 21, 2024
1 parent 87042ae commit 9ddec40
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions frontend/src/lib/services/app.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ export const initAppPrivateData = async (): Promise<void> => {
// Reload the SNS projects even if they were loaded.
// Get latest data and create wrapper caches for the logged in identity.
const initSns: Promise<void>[] = [loadSnsProjects()];
const initImportedTokens: Promise<void>[] = get(ENABLE_IMPORT_TOKEN)
? [loadImportedTokens()]
: [];

// TODO: load imported tokens after Nns.
/**
* If Nns load but ImportedTokens or Sns load fails it is "fine" to go on because Nns are core features.
*/
await Promise.allSettled([
Promise.all(initNns),
Promise.all(initImportedTokens),
Promise.all(initNns).then(() =>
// When you log in with a new account for the first time, the account is created in the NNS dapp.
// If you request imported tokens before the account is created, an `AccountNotFound` error will be thrown.
// To avoid this, the imported tokens should only be requested after the NNS accounts have been initialized.
Promise.all(get(ENABLE_IMPORT_TOKEN) ? [loadImportedTokens()] : [])
),
Promise.all(initSns),
]);

Expand Down

0 comments on commit 9ddec40

Please sign in to comment.