Skip to content

Commit

Permalink
fix(accounts-controller): prevent metadata from being overwritten dur…
Browse files Browse the repository at this point in the history
…ing updateAccounts
  • Loading branch information
ccharly committed Jan 16, 2025
1 parent 502e91a commit 49b28e1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/accounts-controller/src/AccountsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,16 @@ export class AccountsController extends BaseController<
metadata?: InternalAccount['metadata'],
): InternalAccount['metadata'] {
return {
// First, use all defaults metadata:
name: '', // This will be renamed by `updateAccounts`
// Expand the account's metadata first, and then adds default if they are not
// defined.
...metadata,

name: metadata?.name ?? '', // This will be renamed by `updateAccounts` if empty.
keyring: {
type: keyringType,
},
importTime: Date.now(),
lastSelected: 0, // This means the account has never been selected yet

// Then, expand the optional metadata (if defined) to override the default ones!
...metadata,
importTime: metadata?.importTime ?? Date.now(),
lastSelected: metadata?.lastSelected ?? 0, // This means the account has never been selected yet.
};
}

Expand Down

0 comments on commit 49b28e1

Please sign in to comment.