Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Prevent repeated names on Accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Marcano committed Jul 12, 2022
1 parent 94a05b6 commit 6ce258d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ export class InternalMethods {
if (existingAccounts) {
for (let i = 0; i < existingAccounts.length; i++) {
if (existingAccounts[i].address === targetAddress) {
throw new Error(`Account already exists in ${ledger} wallet.`);
throw new Error(`An account with this address already exists in your ${ledger} wallet.`);
}
if (existingAccounts[i].name === name) {
throw new Error(`An account named '${name}' already exists in your ${ledger} wallet.`);
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions packages/ui/src/components/AccountPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,27 @@ const AccountPreview: FunctionalComponent = (props: any) => {
<div style="display: flex; justify-content: space-between;">
${account.isRef &&
html`<i
class="fas fa-link is-size-7 mx-1 mt-3 has-tooltip-arrow has-tooltip-bottom has-tooltip-bottom-left has-tooltip-fade"
style="line-height: 1.1; height: 15px; font-style: unset;"
class="fas fa-link is-size-7 has-tooltip-arrow has-tooltip-bottom has-tooltip-bottom-left has-tooltip-fade"
style="width: 1.5rem; display: flex; justify-content: center; align-items: center;"
data-tooltip="${REFERENCE_ACCOUNT_TOOLTIP}"
/>`}
<div style="width: 65%; overflow-wrap: break-word; line-height: 1.1;">
<b>${account.name}</b>
</div>
<div class="is-size-7 has-text-right is-flex-grow-1">
${results && results.assets && html` <b>${results.assets.length}</b> ASAs<br /> `}
${results && html` <b>${numFormat(results.amount / 1e6, 6)}</b> Algos `}
${results && results.assets && html`<b>${results.assets.length}</b> ASAs<br />`}
${results && html`<b>${numFormat(results.amount / 1e6, 6)}</b> Algos`}
${results === null && error && html`<span>${error}</span>`}
${results === null && !error && html`<span class="loader is-pulled-right"></span>`}
${results === null &&
!error &&
html`
<div
class="is-size-6 is-flex is-justify-content-flex-end"
style="min-height: 2.25em; align-items: center;"
>
<span class="loader"></span>
</div>
`}
</div>
</div>
</div>
Expand Down

0 comments on commit 6ce258d

Please sign in to comment.