Skip to content

Commit

Permalink
fix: account name checks FE-724 (#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
nelitow authored Oct 11, 2024
1 parent 112e002 commit 8e42400
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-lions-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels-wallet": patch
---

Improve account name colision verification
12 changes: 9 additions & 3 deletions packages/app/src/systems/Account/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ export class AccountService {

static async checkAccountNameExists(name = '') {
const accounts = await AccountService.getAccounts();
// biome-ignore lint/complexity/noThisInStatic: <explanation>
const exitsAccountWithName = this.filterByName(accounts, name).length > 0;
return exitsAccountWithName;
const existsAccountWithName =
AccountService.existsAccountWithName(accounts, name).length > 0;
return existsAccountWithName;
}

static async generateAccountName() {
Expand All @@ -232,6 +232,12 @@ export class AccountService {
account.name.toLowerCase().includes(name.toLowerCase())
);
}

static existsAccountWithName(accounts: Account[], name = '') {
return accounts.filter((account) => {
return account.name === name;
});
}
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 8e42400

Please sign in to comment.