diff --git a/.env.example b/.env.example index e57419a..dce5c0b 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ VITE_ENVIRONMENT=development VITE_PORT=8095 +VITE_API_URL='https://api.stage.solarity.dev' VITE_APP_NAME='Solarity' VITE_APP_COMPANY_URL='https://distributedlab.com' VITE_APP_DOCUMENTATION_URL='https://docs.stage.solarity.dev' diff --git a/api/index.ts b/api/index.ts new file mode 100644 index 0000000..27d29ff --- /dev/null +++ b/api/index.ts @@ -0,0 +1,6 @@ +import { config } from '@/config' +import { Fetcher, fetcher } from '@distributedlab/fetcher' + +const api = new Fetcher({ baseUrl: config.API_URL }) + +export { api, fetcher } diff --git a/assets/icons/check-double-icon.svg b/assets/icons/check-double-icon.svg new file mode 100644 index 0000000..df8323f --- /dev/null +++ b/assets/icons/check-double-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/styles/_mixins.scss b/assets/styles/_mixins.scss index 5248cb5..acc7535 100644 --- a/assets/styles/_mixins.scss +++ b/assets/styles/_mixins.scss @@ -139,6 +139,8 @@ $media-breakpoints: ( } @mixin solidity-tools-page-content { + position: relative; + overflow: hidden; display: flex; flex-direction: column; padding: toRem(40); @@ -150,6 +152,18 @@ $media-breakpoints: ( } } +@mixin solidity-tools-page-content-loader-wrp { + $z-index: 100; + + position: absolute; + inset: 0; + z-index: $z-index; + display: flex; + justify-content: center; + align-items: center; + background: var(--backdrop-modal); +} + @mixin solidity-tools-form { display: grid; grid-gap: toRem(40); @@ -173,6 +187,14 @@ $media-breakpoints: ( background: var(--border-primary-main); } +@mixin solidity-tools-form-share-btn-wrp { + display: flex; + justify-content: center; + border-top: toRem(1) solid var(--border-primary-main); + border-radius: 0 0 var(--border-radius-main) var(--border-radius-main); + padding: toRem(16) toRem(40); +} + @mixin page-msg { max-width: toRem(420); width: 100%; diff --git a/components/AppButton.vue b/components/AppButton.vue index 973dd07..a0c5ec1 100644 --- a/components/AppButton.vue +++ b/components/AppButton.vue @@ -80,8 +80,9 @@ diff --git a/components/AppLogo.vue b/components/AppLogo.vue index 549fb05..852275a 100644 --- a/components/AppLogo.vue +++ b/components/AppLogo.vue @@ -1,5 +1,5 @@ diff --git a/forms/AbiEncodeForm.vue b/forms/AbiEncodeForm.vue index 03e455d..96a4798 100644 --- a/forms/AbiEncodeForm.vue +++ b/forms/AbiEncodeForm.vue @@ -168,13 +168,31 @@ +
+ +
+
+ +
diff --git a/forms/HashFunctionForm.vue b/forms/HashFunctionForm.vue index 930e080..33ee75c 100644 --- a/forms/HashFunctionForm.vue +++ b/forms/HashFunctionForm.vue @@ -32,16 +32,41 @@ +
+ +
+
+ +
diff --git a/helpers/errors.helpers.ts b/helpers/errors.helpers.ts index fa31878..41c99ba 100644 --- a/helpers/errors.helpers.ts +++ b/helpers/errors.helpers.ts @@ -14,6 +14,13 @@ export function getErrorMessage(error: Error | unknown): string { return t('errors.failed-to-guess-param-types') case errors.AbiDecodeError: return t('errors.failed-to-decode-abi') + case errors.IncompatibleDataReceivedError: + return t('errors.incompatible-data-received') + + case errors.linkShortenerServiceErrors.CreateLinkFetchError: + return t('errors.failed-to-create-link') + case errors.linkShortenerServiceErrors.GetDataByLinkFetchError: + return t('errors.failed-to-get-data-by-link') } } diff --git a/pages/abi.vue b/pages/abi.vue index 4c0eafc..5c7b1f4 100644 --- a/pages/abi.vue +++ b/pages/abi.vue @@ -13,14 +13,14 @@ @@ -50,5 +50,11 @@ const tabsList = computed(() => [ .abi-page__content { @include solidity-tools-page-content; + + padding-bottom: 0; + + @include respond-to(medium) { + padding-bottom: 0; + } } diff --git a/pages/abi/decoder.vue b/pages/abi/decoder/[[id]].vue similarity index 100% rename from pages/abi/decoder.vue rename to pages/abi/decoder/[[id]].vue diff --git a/pages/abi/encoder.vue b/pages/abi/encoder/[[id]].vue similarity index 100% rename from pages/abi/encoder.vue rename to pages/abi/encoder/[[id]].vue diff --git a/pages/address-utils.vue b/pages/address-utils.vue index d3c1df6..c00bb4f 100644 --- a/pages/address-utils.vue +++ b/pages/address-utils.vue @@ -13,14 +13,14 @@ diff --git a/pages/converter.vue b/pages/converter.vue index 91e76fc..29b1232 100644 --- a/pages/converter.vue +++ b/pages/converter.vue @@ -13,14 +13,14 @@ diff --git a/pages/hash-function.vue b/pages/hash-function.vue index 4655e9d..2b4b86f 100644 --- a/pages/hash-function.vue +++ b/pages/hash-function.vue @@ -13,12 +13,12 @@ @@ -53,5 +53,11 @@ const TABS_LIST: Tab[] = [ .hash-functions-page__content { @include solidity-tools-page-content; + + padding-bottom: 0; + + @include respond-to(medium) { + padding-bottom: 0; + } } diff --git a/pages/hash-function/keccak256.vue b/pages/hash-function/keccak256/[[id]].vue similarity index 100% rename from pages/hash-function/keccak256.vue rename to pages/hash-function/keccak256/[[id]].vue diff --git a/pages/hash-function/ripemd160.vue b/pages/hash-function/ripemd160/[[id]].vue similarity index 100% rename from pages/hash-function/ripemd160.vue rename to pages/hash-function/ripemd160/[[id]].vue diff --git a/pages/hash-function/sha256.vue b/pages/hash-function/sha256/[[id]].vue similarity index 100% rename from pages/hash-function/sha256.vue rename to pages/hash-function/sha256/[[id]].vue diff --git a/pages/unix-epoch.vue b/pages/unix-epoch.vue index 07b049e..88d52b4 100644 --- a/pages/unix-epoch.vue +++ b/pages/unix-epoch.vue @@ -13,14 +13,14 @@ diff --git a/plugins/global-properties.plugin.ts b/plugins/global-properties.plugin.ts index 91b35c6..40a1e5d 100644 --- a/plugins/global-properties.plugin.ts +++ b/plugins/global-properties.plugin.ts @@ -1,12 +1,11 @@ import { defineNuxtPlugin } from '#imports' -import { ROUTE_PATH } from '@/constants' -import { ICON_NAMES } from '@/enums' +import { ICON_NAMES, ROUTE_NAMES } from '@/enums' export default defineNuxtPlugin(() => { return { provide: { icons: ICON_NAMES, - routes: ROUTE_PATH, + routes: ROUTE_NAMES, }, } }) diff --git a/plugins/localization/resources/en.json b/plugins/localization/resources/en.json index 3461d39..88658ec 100644 --- a/plugins/localization/resources/en.json +++ b/plugins/localization/resources/en.json @@ -96,7 +96,9 @@ "abi-decoding-copy-btn": "Copy decoding", "func-signature-label": "Function signature", "func-signature-placeholder": "Function signature", - "func-is-guessed-warning": "The function signature has been guessed" + "func-is-guessed-warning": "The function signature has been guessed", + "share-btn": "Copy link to share", + "share-btn--copied": "Link copied" }, "abi-encode-form": { "input-title": "Encoder", @@ -117,7 +119,9 @@ "encoding-placeholder--standard": "Abi encoding", "encoding-placeholder--packed": "Packed encoding", "func-signature-label": "Function signature", - "func-signature-placeholder": "Function signature" + "func-signature-placeholder": "Function signature", + "share-btn": "Copy link to share", + "share-btn--copied": "Link copied" }, "common-addresses-form": { "input-title": "Common addresses", @@ -173,7 +177,9 @@ "select-option-hex": "Hex", "text-title": "Input data", "output-title": "Output", - "decoded-hash-label": "Decoded Hash" + "decoded-hash-label": "Decoded Hash", + "share-btn": "Copy link to share", + "share-btn--copied": "Link copied" }, "create-address-form": { "input-title": "Create", @@ -200,7 +206,10 @@ "failed-to-fetch-func-signature": "Failed to get function signature", "failed-to-guess-func-fragment": "Failed to guess function signature", "failed-to-guess-param-types": "Failed to guess types", - "failed-to-decode-abi": "Failed to decode values with given types" + "failed-to-decode-abi": "Failed to decode values with given types", + "incompatible-data-received": "Incompatible data received", + "failed-to-create-link": "Failed to create link", + "failed-to-get-data-by-link": "Failed to get data by link" }, "app-logo": { "title": "Solarity" diff --git a/services/index.ts b/services/index.ts new file mode 100644 index 0000000..52f4ca6 --- /dev/null +++ b/services/index.ts @@ -0,0 +1 @@ +export * as linkShortener from './link-shortener.service' diff --git a/services/link-shortener.service.ts b/services/link-shortener.service.ts new file mode 100644 index 0000000..9f58c9a --- /dev/null +++ b/services/link-shortener.service.ts @@ -0,0 +1,37 @@ +import { api } from '@/api' +import { linkShortenerServiceErrors } from '@/errors' +import { type LinkShortener } from '@/types' + +export async function createLink( + value: unknown, + path: string, +): Promise { + const requestBody = { data: { attributes: { value, path } } } + + try { + const { data: responseData } = await api.post<{ data: LinkShortener.Data }>( + '/shortener', + { body: requestBody }, + ) + + // eslint-disable-next-line + // @ts-ignore + return responseData?.data + } catch { + throw new linkShortenerServiceErrors.CreateLinkFetchError() + } +} + +export async function getDataByLink(link: string): Promise { + try { + const { data: responseData } = await api.get<{ data: LinkShortener.Data }>( + `/shortener/${link}`, + ) + + // eslint-disable-next-line + // @ts-ignore + return responseData?.data + } catch { + throw new linkShortenerServiceErrors.GetDataByLinkFetchError() + } +} diff --git a/types/common.types.ts b/types/common.types.ts index 8375a3f..b8deb1c 100644 --- a/types/common.types.ts +++ b/types/common.types.ts @@ -1,4 +1,6 @@ import { ICON_NAMES } from '@/enums' +import { RouteLocationRaw } from 'vue-router' + export type CommonNotificationTypes = | 'success' | 'error' @@ -36,11 +38,13 @@ export type ProjectInfoCard = { message: string btnText: string href?: string - route?: string + route?: RouteLocationRaw } export type Tab = { title: string id: string - route?: string + route?: RouteLocationRaw } + +export { RouteLocationRaw } diff --git a/types/index.ts b/types/index.ts index 2f79589..b11bbc9 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,4 +1,6 @@ export * as AbiForm from './abi-encode-form.types' export * from './common.types' +export * from './services' + export type { AddressLike, BytesLike } from 'ethers' diff --git a/types/services/index.ts b/types/services/index.ts new file mode 100644 index 0000000..13eb9a6 --- /dev/null +++ b/types/services/index.ts @@ -0,0 +1 @@ +export * as LinkShortener from './link-shortener.type' diff --git a/types/services/link-shortener.type.ts b/types/services/link-shortener.type.ts new file mode 100644 index 0000000..dfb9b98 --- /dev/null +++ b/types/services/link-shortener.type.ts @@ -0,0 +1,9 @@ +export type Data = { + id: string + type: string + attributes: { + expired_at: string + path: string + value: unknown + } +}