Skip to content

Commit

Permalink
fix(tokens): add correct mapping for multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenijesavic committed Sep 13, 2023
1 parent 3fc4b7e commit 75c5dea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/components/dao/settings-tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/components/login/register-user-with-captcha-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
})
Expand Down
3 changes: 3 additions & 0 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 75c5dea

Please sign in to comment.