From 75c5deabefd96ad3be5bb71908fbb494089070dd Mon Sep 17 00:00:00 2001 From: Arsenije Savic Date: Wed, 13 Sep 2023 10:05:09 -0600 Subject: [PATCH] fix(tokens): add correct mapping for multiplier --- src/components/dao/settings-tokens.vue | 18 +++++++++++++++--- .../login/register-user-with-captcha-view.vue | 8 +++++++- src/const.js | 3 +++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/components/dao/settings-tokens.vue b/src/components/dao/settings-tokens.vue index ea3e6a1f4..73dfe210a 100644 --- a/src/components/dao/settings-tokens.vue +++ b/src/components/dao/settings-tokens.vue @@ -3,6 +3,7 @@ import { mapActions, mapGetters } from 'vuex' import { validation } from '~/mixins/validation' import currency from 'src/data/currency.json' import map from '~/utils/map' +import { MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER } from '~/const' const mapCurrency = (currency) => (_) => ({ label: `${currency[_]?.symbol} - ${currency[_]?.name}`, @@ -85,6 +86,11 @@ export default { if (isValid) { await this.createTokens({ ...this.tokens, + + utilityTokenMultiplier: map(this.tokens.utilityTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER), + voiceTokenMultiplier: map(this.tokens.voiceTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER), + treasuryTokenMultiplier: map(this.tokens.treasuryTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER), + voiceDecayPercent: map(this.tokens.voiceDecayPercent, 0, 100, MIN_DECAY, MAX_DECAY) }) } @@ -236,8 +242,10 @@ export default { q-input.q-my-xs( :debounce="200" :disable="!selectedDao.hasCustomToken" + :max="100" + :min="0" :placeholder="$t('configuration.settings-tokens.tresury.form.value.placeholder')" - :rules="[rules.required]" + :rules="[rules.required, rules.greaterThan(0), rules.lessOrEqualThan(100)]" bg-color="white" color="accent" dense @@ -331,7 +339,9 @@ export default { :debounce="200" :disable="selectedDao.hasCustomToken || !isAdmin" :filled="selectedDao.hasCustomToken || !isAdmin" - :rules="[rules.required]" + :max="100" + :min="0" + :rules="[rules.required, rules.greaterThan(0), rules.lessOrEqualThan(100)]" color="accent" dense lazy-rules @@ -427,7 +437,9 @@ export default { :debounce="200" :disable="selectedDao.hasCustomToken || !isAdmin" :filled="selectedDao.hasCustomToken || !isAdmin" - :rules="[rules.required]" + :max="100" + :min="0" + :rules="[rules.required, rules.greaterThan(0), rules.lessOrEqualThan(100)]" color="accent" dense lazy-rules diff --git a/src/components/login/register-user-with-captcha-view.vue b/src/components/login/register-user-with-captcha-view.vue index 5f9750174..320ab8107 100644 --- a/src/components/login/register-user-with-captcha-view.vue +++ b/src/components/login/register-user-with-captcha-view.vue @@ -5,6 +5,8 @@ import QrcodeVue from 'qrcode.vue' import ipfsy from '~/utils/ipfsy' import { Notify } from 'quasar' import slugify from '~/utils/slugify' +import map from '~/utils/map' +import { MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER } from '~/const' const HELP_LINK = 'https://help.hypha.earth/hc/2431449449' @@ -171,10 +173,14 @@ export default { await this.createDAO({ data: { ...this.form, + + daoUrl, onboarder_account: this.account, parentId: this.$route.query.parentId, skipTokens: true, - daoUrl: daoUrl + utilityTokenMultiplier: map(this.form.utilityTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER), + voiceTokenMultiplier: map(this.form.voiceTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER), + treasuryTokenMultiplier: map(this.form.treasuryTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER) }, isDraft }) diff --git a/src/const.js b/src/const.js index bb2d171aa..f34a16653 100644 --- a/src/const.js +++ b/src/const.js @@ -90,3 +90,6 @@ export const PERIOD_NUMBERS = Object.freeze({ }) export const DEFAULT_TIER = 'Custom Reward' + +export const MIN_TOKEN_MULTIPLIER = 0 +export const MAX_TOKEN_MULTIPLIER = 1