-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from dl-solarity/feature/convertors
merged feature/convertors into master
- Loading branch information
Showing
35 changed files
with
829 additions
and
72 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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 |
---|---|---|
|
@@ -52,5 +52,6 @@ export const useFormValidation = ( | |
getFieldErrorMessage, | ||
touchField, | ||
isFormValid, | ||
validationController, | ||
} | ||
} |
This file contains 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,2 @@ | ||
export const ZERO_BYTES_32 = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' |
This file contains 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 +1,2 @@ | ||
export * from './numbers.constant' | ||
export * from './bytes.constant' |
This file contains 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 |
---|---|---|
|
@@ -21,4 +21,5 @@ export enum ICON_NAMES { | |
refresh = 'refresh', | ||
xCircle = 'x-circle', | ||
x = 'x', | ||
squareRoot = 'square-root', | ||
} |
This file contains 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 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,17 @@ | ||
export enum PERIOD_IDS { | ||
seconds = 's', | ||
minutes = 'min', | ||
hours = 'h', | ||
days = 'd', | ||
weeks = 'w', | ||
months = 'mon', | ||
years = 'y', | ||
} | ||
|
||
export enum PERIOD_CONSTANTS { | ||
secondsInHour = 3600, | ||
hoursInDay = 24, | ||
daysInWeek = 7, | ||
daysInMonth = 30, | ||
daysInYear = 360, | ||
} |
This file contains 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 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 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,84 @@ | ||
<template> | ||
<form class="ascii-converter-form"> | ||
<div class="ascii-converter-form__input"> | ||
<h3>{{ $t('ascii-converter-form.input-title') }}</h3> | ||
<textarea-field | ||
v-for="(value, key) in form" | ||
size="small" | ||
:model-value="value" | ||
:key="key" | ||
:label="$t(`ascii-converter-form.${key}-label`)" | ||
:placeholder="$t(`ascii-converter-form.${key}-placeholder`)" | ||
:error-message="getFieldErrorMessage(key)" | ||
@update:model-value="formatInputs($event, key)" | ||
@blur="touchField(key)" | ||
> | ||
<template #nodeLeft> | ||
<!-- value || ' ' to keep the copy-button visible in input --> | ||
<app-copy :value="value || ' '" /> | ||
</template> | ||
</textarea-field> | ||
</div> | ||
</form> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { AppCopy } from '#components' | ||
import { useFormValidation } from '@/composables' | ||
import { TextareaField } from '@/fields' | ||
import { hexadecimal } from '@/helpers' | ||
import { isEmpty } from 'lodash-es' | ||
import { reactive } from 'vue' | ||
import { hexToASCII, asciiToHex } from '@/helpers' | ||
type AsciiConverterForm = { | ||
hexadecimal: string | ||
ascii: string | ||
} | ||
type AsciiConverterFormKeys = keyof AsciiConverterForm | ||
const form = reactive<AsciiConverterForm>({ | ||
hexadecimal: '', | ||
ascii: '', | ||
}) | ||
const { getFieldErrorMessage, touchField, isFormValid } = useFormValidation( | ||
form, | ||
{ | ||
hexadecimal: { hexadecimal }, | ||
ascii: {}, | ||
}, | ||
) | ||
const formatInputs = (value: string | number, key: AsciiConverterFormKeys) => { | ||
form[key] = String(value) | ||
const formKeys = Object.keys(form) as Array<AsciiConverterFormKeys> | ||
const filteredKeys = formKeys.filter(_key => _key !== key) | ||
const formattedValue = String(value).trim() | ||
if (isEmpty(formattedValue) || !isFormValid()) { | ||
for (key of filteredKeys) form[key] = '' | ||
return | ||
} | ||
switch (key) { | ||
case 'hexadecimal': | ||
form.ascii = hexToASCII(form.hexadecimal) | ||
break | ||
case 'ascii': | ||
form.hexadecimal = asciiToHex(form.ascii) | ||
break | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.ascii-converter-form { | ||
@include solidity-tools-form; | ||
} | ||
.ascii-converter-form__input { | ||
@include solidity-tools-form-part; | ||
} | ||
</style> |
This file contains 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.