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

Update/ Save account state errors in state, instead of emitting error in the accountAdder #1088

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/controllers/accountAdder/accountAdder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export class AccountAdderController extends EventEmitter {

linkedAccountsLoading: boolean = false

networksWithAccountStateError: NetworkId[] = []

#derivedAccounts: DerivedAccount[] = []

#linkedAccounts: { account: AccountWithNetworkMeta; isLinked: boolean }[] = []
Expand Down Expand Up @@ -299,6 +301,7 @@ export class AccountAdderController extends EventEmitter {
this.#derivedAccounts = []
this.#linkedAccounts = []
this.readyToAddAccounts = []
this.networksWithAccountStateError = []
this.readyToAddKeys = { internal: [], external: [] }
this.isInitialized = false
this.isInitializedWithSavedSeed = false
Expand Down Expand Up @@ -476,6 +479,7 @@ export class AccountAdderController extends EventEmitter {
this.#derivedAccounts = []
this.#linkedAccounts = []
this.accountsLoading = true
this.networksWithAccountStateError = []
this.emitUpdate()
try {
this.#derivedAccounts = await this.#deriveAccounts()
Expand Down Expand Up @@ -785,17 +789,9 @@ export class AccountAdderController extends EventEmitter {
network,
accounts.map((acc) => acc.account)
).catch(() => {
const message = `Failed to determine if accounts are used on ${network.name}.`
// Prevents toast spamming
if (this.emittedErrors.find((err) => err.message === message)) return

this.emitError({
level: 'major',
message,
error: new Error(
`accountAdder.#getAccountsUsedOnNetworks: failed to determine if accounts are used on ${network.name}`
)
})
console.error('accountAdder: failed to get account state on ', providerKey)
if (this.networksWithAccountStateError.includes(providerKey)) return
this.networksWithAccountStateError.push(providerKey)
})

if (!accountState) return
Expand Down
Loading