From 742f56da70b947778a62ec9931f6556ebebaad01 Mon Sep 17 00:00:00 2001 From: tomiir Date: Wed, 12 Jun 2024 11:28:14 -0600 Subject: [PATCH 1/2] fix: forbid registration if user already owns a name --- .../views/w3m-register-account-name-view/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/scaffold/src/views/w3m-register-account-name-view/index.ts b/packages/scaffold/src/views/w3m-register-account-name-view/index.ts index b6fcdd9d87..477dab3e07 100644 --- a/packages/scaffold/src/views/w3m-register-account-name-view/index.ts +++ b/packages/scaffold/src/views/w3m-register-account-name-view/index.ts @@ -33,6 +33,8 @@ export class W3mRegisterAccountNameView extends LitElement { @state() private registered = false + @state() private profileName = AccountController.state.profileName + public constructor() { super() this.usubscribe.push( @@ -40,6 +42,9 @@ export class W3mRegisterAccountNameView extends LitElement { EnsController.subscribe(val => { this.suggestions = val.suggestions this.loading = val.loading + }), + AccountController.subscribeKey('profileName', val => { + this.profileName = val }) ] ) @@ -170,7 +175,13 @@ export class W3mRegisterAccountNameView extends LitElement { } private isAllowedToSubmit() { - return !this.loading && !this.registered && !this.error && EnsController.validateName(this.name) + return ( + !this.loading && + !this.registered && + !this.error && + !this.profileName && + EnsController.validateName(this.name) + ) } private async onSubmitName() { From f7f0aaf5d2b93744929e5ebc9c6f64ff8d056f84 Mon Sep 17 00:00:00 2001 From: tomiir Date: Wed, 12 Jun 2024 11:47:58 -0600 Subject: [PATCH 2/2] chore: add error message --- .../scaffold/src/views/w3m-register-account-name-view/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/scaffold/src/views/w3m-register-account-name-view/index.ts b/packages/scaffold/src/views/w3m-register-account-name-view/index.ts index 477dab3e07..2c61f1494b 100644 --- a/packages/scaffold/src/views/w3m-register-account-name-view/index.ts +++ b/packages/scaffold/src/views/w3m-register-account-name-view/index.ts @@ -45,6 +45,9 @@ export class W3mRegisterAccountNameView extends LitElement { }), AccountController.subscribeKey('profileName', val => { this.profileName = val + if (val) { + this.error = 'You already own a name' + } }) ] )