From a6aa0e0150623e572e5dabfe5485e2fc55538026 Mon Sep 17 00:00:00 2001 From: Tushar Karkera <104358692+TusharKarkera22@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:26:14 +0530 Subject: [PATCH 1/3] Make testnet faucet page more efficient by adding input validation #259 --- src/pages/testnet/DevelopersPage.vue | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/pages/testnet/DevelopersPage.vue b/src/pages/testnet/DevelopersPage.vue index e191fdde..d7fa3626 100644 --- a/src/pages/testnet/DevelopersPage.vue +++ b/src/pages/testnet/DevelopersPage.vue @@ -16,6 +16,24 @@ export default { submitting: false, }; }, + computed: { + isCreateAccountButtonDisabled() { + return ( + !this.form.account_name || + !this.form.owner_key || + !this.form.active_key || + this.submitting + ); + }, + isAnyInputInvalid() { + return ( + !this.form.account_name || + !/^EOS[0-9A-Za-z]{50}$/.test(this.form.owner_key) || + !/^EOS[0-9A-Za-z]{50}$/.test(this.form.active_key) + + ); + }, + }, methods: { ...mapActions('testnet', ['faucet', 'evmFaucet', 'account']), async onFaucet() { @@ -85,6 +103,7 @@ q-page.flex.flex-center ref="owner_key" v-model="form.owner_key" color="accent" + :rules="[ val => /^EOS[0-9A-Za-z]{50}$/.test(val) || 'Please provide a valid Owner key']" label="Owner key" outlined ) @@ -92,6 +111,8 @@ q-page.flex.flex-center ref="active_key" v-model="form.active_key" color="accent" + :rules="[ val => /^EOS[0-9A-Za-z]{50}$/.test(val) || 'Please provide a valid Active key']" + label="Active key" outlined ) @@ -101,6 +122,7 @@ q-page.flex.flex-center size="lg" unelevated :loading="submitting" + :disable="isAnyInputInvalid" @click="onAccount" ) From 74e084e5a07cb4ad028c087d96c5d724bcb2fdda Mon Sep 17 00:00:00 2001 From: Tushar Karkera <104358692+TusharKarkera22@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:37:13 +0530 Subject: [PATCH 2/3] #259 Added validation for 2 supported public key formats --- src/pages/testnet/DevelopersPage.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/testnet/DevelopersPage.vue b/src/pages/testnet/DevelopersPage.vue index d7fa3626..f40561d9 100644 --- a/src/pages/testnet/DevelopersPage.vue +++ b/src/pages/testnet/DevelopersPage.vue @@ -28,8 +28,15 @@ export default { isAnyInputInvalid() { return ( !this.form.account_name || - !/^EOS[0-9A-Za-z]{50}$/.test(this.form.owner_key) || - !/^EOS[0-9A-Za-z]{50}$/.test(this.form.active_key) + ( + !/^EOS[0-9A-Za-z]{50}$/.test(this.form.owner_key) && + !/^PUB_K1_[0-9A-Za-z]{50}$/.test(this.form.owner_key) + ) || + ( + !/^EOS[0-9A-Za-z]{50}$/.test(this.form.active_key) && + !/^PUB_K1_[0-9A-Za-z]{50}$/.test(this.form.active_key) + ) + ); }, @@ -103,7 +110,7 @@ q-page.flex.flex-center ref="owner_key" v-model="form.owner_key" color="accent" - :rules="[ val => /^EOS[0-9A-Za-z]{50}$/.test(val) || 'Please provide a valid Owner key']" + :rules="[ val => (/^EOS[0-9A-Za-z]{50}$|^PUB_K1_[0-9A-Za-z]{50}$/i.test(val)) || 'Please provide a valid Owner key']" label="Owner key" outlined ) @@ -111,7 +118,7 @@ q-page.flex.flex-center ref="active_key" v-model="form.active_key" color="accent" - :rules="[ val => /^EOS[0-9A-Za-z]{50}$/.test(val) || 'Please provide a valid Active key']" + :rules="[ val => (/^EOS[0-9A-Za-z]{50}$|^PUB_K1_[0-9A-Za-z]{50}$/i.test(val)) || 'Please provide a valid Active key']" label="Active key" outlined From 349dc84b1b71219cba458ed58258104775241d4f Mon Sep 17 00:00:00 2001 From: Tushar Karkera <104358692+TusharKarkera22@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:44:28 +0530 Subject: [PATCH 3/3] Fixed indentation --- src/pages/testnet/DevelopersPage.vue | 42 +++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/pages/testnet/DevelopersPage.vue b/src/pages/testnet/DevelopersPage.vue index f40561d9..d8aa38f9 100644 --- a/src/pages/testnet/DevelopersPage.vue +++ b/src/pages/testnet/DevelopersPage.vue @@ -17,30 +17,26 @@ export default { }; }, computed: { - isCreateAccountButtonDisabled() { - return ( - !this.form.account_name || - !this.form.owner_key || - !this.form.active_key || - this.submitting - ); + isCreateAccountButtonDisabled() { + return ( + !this.form.account_name || + !this.form.owner_key || + !this.form.active_key || + this.submitting + ); + }, + isAnyInputInvalid() { + return ( + !this.form.account_name || + (!/^EOS[0-9A-Za-z]{50}$|^PUB_K1_[0-9A-Za-z]{50}$/i.test( + this.form.owner_key + )) || + (!/^EOS[0-9A-Za-z]{50}$|^PUB_K1_[0-9A-Za-z]{50}$/i.test( + this.form.active_key + )) + ); + }, }, - isAnyInputInvalid() { - return ( - !this.form.account_name || - ( - !/^EOS[0-9A-Za-z]{50}$/.test(this.form.owner_key) && - !/^PUB_K1_[0-9A-Za-z]{50}$/.test(this.form.owner_key) - ) || - ( - !/^EOS[0-9A-Za-z]{50}$/.test(this.form.active_key) && - !/^PUB_K1_[0-9A-Za-z]{50}$/.test(this.form.active_key) - ) - - - ); - }, - }, methods: { ...mapActions('testnet', ['faucet', 'evmFaucet', 'account']), async onFaucet() {