Skip to content

Commit

Permalink
Feature/Сommon addresses (#38)
Browse files Browse the repository at this point in the history
* kebab-case in template in app.vue

* renamed address predicator -> address utils

* added common addresses tab in address utils

* added common-addresses page

* added random address

---------

Co-authored-by: Yehor Podporinov <[email protected]>
  • Loading branch information
yehor-podporinov and Yehor Podporinov authored Oct 13, 2023
1 parent cd75cd9 commit a09a138
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 21 deletions.
6 changes: 3 additions & 3 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
<nuxt-layout>
<nuxt-page />
</nuxt-layout>
<div id="app-modals" />
</template>

Expand Down
4 changes: 2 additions & 2 deletions components/ToolsSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ const navLinks = computed(() => [
route: ROUTE_PATH.unixEpoch,
},
{
title: t('tools-sidebar.address-predictor-title'),
title: t('tools-sidebar.address-utils-title'),
icon: ICON_NAMES.locationMarker,
route: ROUTE_PATH.addressPredicator,
route: ROUTE_PATH.addressUtils,
},
])
Expand Down
7 changes: 4 additions & 3 deletions constants/route-names.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const ROUTE_PATH = {
hashFunctionKeccak256: '/hash-function/keccak256',
hashFunctionSha256: '/hash-function/sha256',
hashFunctionRipemd160: '/hash-function/ripemd160',
addressPredicator: '/address-predictor',
addressPredicatorCreate: '/address-predictor/create',
addressPredicatorCreate2: '/address-predictor/create2',
addressUtils: '/address-utils',
addressUtilsCommonAddresses: '/address-utils/common-addresses',
addressUtilsCreate: '/address-utils/create',
addressUtilsCreate2: '/address-utils/create2',
}
4 changes: 4 additions & 0 deletions fields/InputField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ $z-index-side-nodes: 1;
color: inherit;
max-height: 100%;
z-index: $z-index-side-nodes;
display: flex;
gap: toRem(8);
}
.input-field__node-right-wrp {
Expand All @@ -280,6 +282,8 @@ $z-index-side-nodes: 1;
transform: translateY(-50%);
color: inherit;
z-index: $z-index-side-nodes;
display: flex;
gap: toRem(8);
}
.input-field__icon {
Expand Down
63 changes: 63 additions & 0 deletions forms/CommonAddressesForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<form class="common-addresses-form" @submit.prevent>
<div class="common-addresses-form__input">
<h3>{{ $t('common-addresses-form.input-title') }}</h3>
<input-field
v-for="(_, key) in form"
:key="key"
readonly
:label="$t(`common-addresses-form.${key}-label`)"
:model-value="form[key]"
>
<template #nodeLeft>
<app-copy :value="form[key]" />
<button
v-if="key === 'randomAddress'"
@click="form.randomAddress = generateRandomAddress()"
>
<app-icon
class="common-addresses-form__btn-icon"
:name="$icons.refresh"
/>
</button>
</template>
</input-field>
</div>
</form>
</template>

<script lang="ts" setup>
import { AppCopy, AppIcon } from '#components'
import { InputField } from '@/fields'
import { Wallet } from 'ethers'
import { onMounted, reactive } from 'vue'
const generateRandomAddress = (): string => Wallet.createRandom().address
const form = reactive({
zeroAddress: '0x0000000000000000000000000000000000000000',
allFsAddress: '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF',
allEsAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
randomAddress: '',
})
onMounted(() => {
form.randomAddress = generateRandomAddress()
})
</script>

<style lang="scss" scoped>
.common-addresses-form {
@include solidity-tools-form;
}
.common-addresses-form__input {
@include solidity-tools-form-part;
}
.common-addresses-form .common-addresses-form__btn-icon {
height: toRem(16);
width: toRem(16);
color: var(--primary-main);
}
</style>
1 change: 1 addition & 0 deletions forms/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as AbiDecodeForm } from './AbiDecodeForm.vue'
export { default as AbiEncodeForm } from './AbiEncodeForm.vue'
export { default as CommonAddressesForm } from './CommonAddressesForm.vue'
export { default as CreateAddressForm } from './CreateAddressForm.vue'
export { default as Create2AddressForm } from './Create2AddressForm.vue'
export { default as DateForm } from './DateForm.vue'
Expand Down
26 changes: 16 additions & 10 deletions pages/address-predictor.vue → pages/address-utils.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div class="address-predictor-page">
<h2>{{ $t('address-predictor-page.main-title') }}</h2>
<div class="address-utils-page">
<h2>{{ $t('address-utils-page.main-title') }}</h2>
<div>
<app-tabs :tabs="tabsList" />
<div class="address-predictor-page__content">
<div class="address-utils-page__content">
<nuxt-page keepalive />
</div>
</div>
Expand All @@ -20,35 +20,41 @@ import { i18n } from '~/plugins/localization'
definePageMeta({
layout: 'solidity-tools',
redirect: ROUTE_PATH.addressPredicatorCreate,
redirect: ROUTE_PATH.addressUtilsCommonAddresses,
})
enum TABS_IDS {
commonAddressesForm = 'common-addresses-form',
createAddressForm = 'create-address-form',
create2AddressForm = 'create2-address-form',
}
const { t } = i18n.global
const tabsList = computed<Tab[]>(() => [
{
title: t('address-predictor-page.create-address-form-tab'),
title: t('address-utils-page.common-addresses-form-tab'),
id: TABS_IDS.commonAddressesForm,
route: ROUTE_PATH.addressUtilsCommonAddresses,
},
{
title: t('address-utils-page.create-address-form-tab'),
id: TABS_IDS.createAddressForm,
route: ROUTE_PATH.addressPredicatorCreate,
route: ROUTE_PATH.addressUtilsCreate,
},
{
title: t('address-predictor-page.create2-address-form-tab'),
title: t('address-utils-page.create2-address-form-tab'),
id: TABS_IDS.create2AddressForm,
route: ROUTE_PATH.addressPredicatorCreate2,
route: ROUTE_PATH.addressUtilsCreate2,
},
])
</script>

<style lang="scss" scoped>
.address-predictor-page {
.address-utils-page {
@include solidity-tools-page-base;
}
.address-predictor-page__content {
.address-utils-page__content {
@include solidity-tools-page-content;
}
</style>
7 changes: 7 additions & 0 deletions pages/address-utils/common-addresses.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<common-addresses-form />
</template>

<script lang="ts" setup>
import { CommonAddressesForm } from '@/forms'
</script>
File renamed without changes.
File renamed without changes.
14 changes: 11 additions & 3 deletions plugins/localization/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@
"hash-functions-title": "Hash functions",
"converter-title": "Converter",
"unix-epoch-title": "Unix epoch",
"address-predictor-title": "Address predictor"
"address-utils-title": "Address utils"
},
"abi-page": {
"main-title": "ABI Encoder/Decoder",
"encoder-tab": "Encoder",
"decoder-tab": "Decoder"
},
"address-predictor-page": {
"main-title": "Address predictor",
"address-utils-page": {
"main-title": "Address utils",
"common-addresses-form-tab": "Common addresses",
"create-address-form-tab": "Create",
"create2-address-form-tab": "Create2"
},
Expand Down Expand Up @@ -110,6 +111,13 @@
"func-signature-label": "Function signature",
"func-signature-placeholder": "Function signature"
},
"common-addresses-form": {
"input-title": "Common addresses",
"zeroAddress-label": "Zero Address",
"allFsAddress-label": "All Fs Address",
"allEsAddress-label": "All Es Address",
"randomAddress-label": "Random address"
},
"date-form": {
"input-title": "Enter Date and Time",
"year-label": "Year",
Expand Down

0 comments on commit a09a138

Please sign in to comment.