-
Notifications
You must be signed in to change notification settings - Fork 42
feat: fees mechanism on/off #1266
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
Open
kstroobants
wants to merge
7
commits into
main
Choose a base branch
from
dxp-444-fees-mechanism-onoff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d70f618
feat: add maxAppealRound frontend
kstroobants 9304eba
feat: add inputs for fees
kstroobants 51177de
feat: add feesDistribution in deploy and write method calls to genlay…
kstroobants 37fb852
fix: add rabbitai remarks
kstroobants 673c828
feat: add on/off button; when off send undefined and do not show fee …
kstroobants 65b6624
fix: remove console log check
kstroobants 361da58
fix: add rabbitai remark
kstroobants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
frontend/src/components/Simulator/settings/ConsensusInputSection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <script setup lang="ts"> | ||
| import NumberInput from '@/components/global/inputs/NumberInput.vue'; | ||
| import type { ConsensusInput } from '@/types/store'; | ||
|
|
||
| interface Props { | ||
| title: string; | ||
| inputs: ConsensusInput[]; | ||
| } | ||
|
|
||
| defineProps<Props>(); | ||
|
|
||
| const isInputValid = (value: number) => { | ||
| return !isNaN(value) && Number.isInteger(value) && value >= 0; | ||
| }; | ||
|
|
||
| const handleValueUpdate = (value: number, setter: (value: number) => void) => { | ||
| if (isInputValid(value)) { | ||
| setter(value); | ||
| } | ||
| }; | ||
| </script> | ||
|
|
||
| <template> | ||
| <div> | ||
| <div class="mb-1 text-xs font-semibold opacity-50">{{ title }}</div> | ||
| <div | ||
| class="overflow-hidden rounded-md border border-gray-300 bg-slate-100 dark:border-gray-800 dark:bg-gray-700" | ||
| > | ||
| <div | ||
| v-for="input in inputs" | ||
| :key="input.id" | ||
| class="flex items-center justify-between px-2 py-1.5" | ||
| > | ||
| <div class="truncate text-sm font-medium">{{ input.label }}</div> | ||
| <NumberInput | ||
| :id="input.id" | ||
| :name="input.id" | ||
| :min="0" | ||
| :step="1" | ||
| :model-value="input.value" | ||
| @update:model-value=" | ||
| (val) => handleValueUpdate(Number(val), input.setter) | ||
| " | ||
| required | ||
| :testId="input.testId" | ||
| :invalid="!isInputValid(input.value)" | ||
| :disabled="false" | ||
| class="h-6 w-20" | ||
| tiny | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </template> |
121 changes: 88 additions & 33 deletions
121
frontend/src/components/Simulator/settings/ConsensusSection.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,104 @@ | ||
| <script setup lang="ts"> | ||
| import { ref, computed } from 'vue'; | ||
| import { computed } from 'vue'; | ||
| import PageSection from '@/components/Simulator/PageSection.vue'; | ||
| import FieldError from '@/components/global/fields/FieldError.vue'; | ||
| import NumberInput from '@/components/global/inputs/NumberInput.vue'; | ||
| import { useConsensusStore } from '@/stores'; | ||
| import MoreInfo from '@/components/global/MoreInfo.vue'; | ||
| import BooleanField from '@/components/global/fields/BooleanField.vue'; | ||
| import ConsensusInputSection from './ConsensusInputSection.vue'; | ||
| import type { ConsensusInput } from '@/types/store'; | ||
|
|
||
| const consensusStore = useConsensusStore(); | ||
| const maxRotations = computed({ | ||
| get: () => consensusStore.maxRotations, | ||
| set: (newTime) => { | ||
| if (isMaxRotationsValid(newTime)) { | ||
| consensusStore.setMaxRotations(newTime); | ||
| } | ||
| }, | ||
|
|
||
| const feesEnabled = computed({ | ||
| get: () => consensusStore.feesEnabled, | ||
| set: (value) => consensusStore.setFeesEnabled(value), | ||
| }); | ||
|
|
||
| function isMaxRotationsValid(value: number) { | ||
| return Number.isInteger(value) && value >= 0; | ||
| } | ||
| const createConsensusInput = ( | ||
| storeValue: number, | ||
| label: string, | ||
| id: string, | ||
| setter: (value: number) => void, | ||
| ): ConsensusInput => { | ||
| return { | ||
| value: storeValue, | ||
| label, | ||
| id, | ||
| testId: `input-${id}`, | ||
| setter, | ||
| }; | ||
| }; | ||
|
|
||
| const timeUnitsInputs = computed(() => [ | ||
| createConsensusInput( | ||
| consensusStore.leaderTimeoutFee, | ||
| 'Leader', | ||
| 'leaderTimeoutFee', | ||
| consensusStore.setLeaderTimeoutFee, | ||
| ), | ||
| createConsensusInput( | ||
| consensusStore.validatorsTimeoutFee, | ||
| 'Validators', | ||
| 'validatorsTimeoutFee', | ||
| consensusStore.setValidatorsTimeoutFee, | ||
| ), | ||
| ]); | ||
|
|
||
| const appealInputs = computed(() => [ | ||
| createConsensusInput( | ||
| consensusStore.appealRoundFee, | ||
| 'Rounds', | ||
| 'appealRoundFee', | ||
| consensusStore.setAppealRoundFee, | ||
| ), | ||
| ]); | ||
|
|
||
| const rotationInputs = computed(() => | ||
| consensusStore.rotationsFee.map((fee, index) => | ||
| createConsensusInput( | ||
| fee, | ||
| `Round ${index + 1}`, | ||
| `rotationsFee_${index}`, | ||
| (value: number) => consensusStore.setRotationsFee(index, value), | ||
| ), | ||
| ), | ||
| ); | ||
| </script> | ||
|
|
||
| <template> | ||
| <PageSection> | ||
| <template #title>Consensus</template> | ||
|
|
||
| <div class="p-2"> | ||
| <div class="flex flex-wrap items-center gap-2"> | ||
| <label for="maxRotations" class="text-xs">Max Rotations</label> | ||
| <NumberInput | ||
| id="maxRotations" | ||
| name="maxRotations" | ||
| :min="0" | ||
| :step="1" | ||
| v-model.number="maxRotations" | ||
| required | ||
| testId="input-maxRotations" | ||
| :disabled="false" | ||
| class="h-6 w-12" | ||
| tiny | ||
| <template #title> | ||
| Consensus | ||
| <MoreInfo | ||
| text="Configure consensus parameters for transaction processing and validation." | ||
| /> | ||
| </template> | ||
|
|
||
| <div class="space-y-2"> | ||
| <BooleanField | ||
| v-model="feesEnabled" | ||
| name="feesEnabled" | ||
| label="Enable Fees" | ||
| data-testid="toggle-fees" | ||
| /> | ||
|
|
||
| <template v-if="feesEnabled"> | ||
| <ConsensusInputSection | ||
| title="Time Units Allocation" | ||
| :inputs="timeUnitsInputs" | ||
| /> | ||
|
|
||
| <ConsensusInputSection | ||
| title="Appeal Configuration" | ||
| :inputs="appealInputs" | ||
| /> | ||
| </div> | ||
|
|
||
| <FieldError v-if="!isMaxRotationsValid" | ||
| >Please enter a positive integer.</FieldError | ||
| > | ||
| <ConsensusInputSection | ||
| v-if="rotationInputs.length > 0" | ||
| title="Rotations Per Round" | ||
| :inputs="rotationInputs" | ||
| /> | ||
| </template> | ||
| </div> | ||
| </PageSection> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.