Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(settings-token): add correct maping for decay #2427

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/components/dao/settings-tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
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}`,
value: currency[_].code,
...currency[_]
})

const MIN_DECAY = 0
const MAX_DECAY = 10000000

export default {
name: 'settings-token',
mixins: [validation],
Expand Down Expand Up @@ -81,7 +85,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, MIN_DECAY, MAX_DECAY)
})
}
} catch (e) {
const message = e.message || e.cause.message
Expand Down Expand Up @@ -122,7 +129,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, MIN_DECAY, MAX_DECAY, 0, 100)

}
}
Expand Down Expand Up @@ -394,7 +401,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
Expand Down
Loading