From 7da71927566051e984e3669c684de62bc5c9c846 Mon Sep 17 00:00:00 2001 From: Arsenije Savic Date: Fri, 8 Sep 2023 08:53:26 -0600 Subject: [PATCH 1/2] fix(settings-token): add correct maping for decay --- src/components/dao/settings-tokens.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/dao/settings-tokens.vue b/src/components/dao/settings-tokens.vue index de004e64d..cdf25caa4 100644 --- a/src/components/dao/settings-tokens.vue +++ b/src/components/dao/settings-tokens.vue @@ -2,6 +2,7 @@ import { mapActions, mapGetters } from 'vuex' import { validation } from '~/mixins/validation' import currency from 'src/data/currency.json' +import map from '~/utils/map' const mapCurrency = (currency) => (_) => ({ label: `${currency[_]?.symbol} - ${currency[_]?.name}`, @@ -81,7 +82,10 @@ export default { try { const isValid = await this.validate(this.tokens) if (isValid) { - await this.createTokens({ ...this.tokens }) + await this.createTokens({ + ...this.tokens, + voiceDecayPercent: map(this.tokens.voiceDecayPercent, 0, 100, 0, 10000000) + }) } } catch (e) { const message = e.message || e.cause.message @@ -122,7 +126,7 @@ export default { voiceDigits: voiceDigits.split('.')[1].length, voiceTokenMultiplier: this.daoSettings.settings_voiceTokenMultiplier_i, voiceDecayPeriod: this.daoSettings.settings_voiceTokenDecayPeriod_i, - voiceDecayPercent: this.daoSettings.settings_voiceTokenDecayPerPeriodX10M_i + voiceDecayPercent: map(this.daoSettings.settings_voiceTokenDecayPerPeriodX10M_i, 0, 10000000, 0, 100) } } @@ -394,7 +398,7 @@ export default { :disable="selectedDao.hasCustomToken" :filled="selectedDao.hasCustomToken" :placeholder="$t('configuration.settings-tokens.voice.form.decayPercent.placeholder')" - :rules="[rules.required]" + :rules="[rules.required, rules.greaterThan(0), rules.lessOrEqualThan(100)]" color="accent" dense lazy-rules From fce65982e79f69949c466cf8fa4ee2742801728e Mon Sep 17 00:00:00 2001 From: Arsenije Savic Date: Mon, 11 Sep 2023 07:24:40 -0600 Subject: [PATCH 2/2] refactor(settings-token): add min max decay var --- src/components/dao/settings-tokens.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/dao/settings-tokens.vue b/src/components/dao/settings-tokens.vue index cdf25caa4..0efa8cf9a 100644 --- a/src/components/dao/settings-tokens.vue +++ b/src/components/dao/settings-tokens.vue @@ -10,6 +10,9 @@ const mapCurrency = (currency) => (_) => ({ ...currency[_] }) +const MIN_DECAY = 0 +const MAX_DECAY = 10000000 + export default { name: 'settings-token', mixins: [validation], @@ -84,7 +87,7 @@ export default { if (isValid) { await this.createTokens({ ...this.tokens, - voiceDecayPercent: map(this.tokens.voiceDecayPercent, 0, 100, 0, 10000000) + voiceDecayPercent: map(this.tokens.voiceDecayPercent, 0, 100, MIN_DECAY, MAX_DECAY) }) } } catch (e) { @@ -126,7 +129,7 @@ export default { voiceDigits: voiceDigits.split('.')[1].length, voiceTokenMultiplier: this.daoSettings.settings_voiceTokenMultiplier_i, voiceDecayPeriod: this.daoSettings.settings_voiceTokenDecayPeriod_i, - voiceDecayPercent: map(this.daoSettings.settings_voiceTokenDecayPerPeriodX10M_i, 0, 10000000, 0, 100) + voiceDecayPercent: map(this.daoSettings.settings_voiceTokenDecayPerPeriodX10M_i, MIN_DECAY, MAX_DECAY, 0, 100) } }