From 0af703d5427b4d36f791dd2f4572e7f037d7da9a Mon Sep 17 00:00:00 2001 From: tom goriunov Date: Wed, 18 Oct 2023 12:03:09 -0300 Subject: [PATCH] filters counters and verify button (#1294) * add counter to filters * move verification button higher for partially verified contracts * [skip ci] support query params in external assets ENV urls * [skip ci] skip code checks if changes in tools folder * [skip ci] tweak eslint process.env rule --- .eslintignore | 3 ++- .eslintrc.js | 2 +- .github/workflows/checks.yml | 1 + configs/app/app.ts | 2 +- configs/app/utils.ts | 13 +++++++--- deploy/scripts/download_assets.sh | 10 ++++++-- middleware.ts | 1 - ui/address/AddressTxsFilter.tsx | 1 + ui/address/contract/ContractCode.tsx | 23 ++++++++++++++---- ...pw.tsx_default_verified-via-sourcify-1.png | Bin 13259 -> 15454 bytes .../VerifiedContractsFilter.tsx | 1 + 11 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.eslintignore b/.eslintignore index a5a69c23fa..37523e907c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,4 +4,5 @@ node_modules_linux playwright/envs.js deploy/tools/envs-validator/index.js deploy/tools/feature-reporter/build/** -deploy/tools/feature-reporter/index.js \ No newline at end of file +deploy/tools/feature-reporter/index.js +public/** \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index aa89d5081f..4cc0e2d97b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -305,7 +305,7 @@ module.exports = { }, }, { - files: [ 'configs/**/*.js', 'configs/**/*.ts', '*.config.ts', 'playwright/**/*.ts', 'deploy/tools/**' ], + files: [ '*.config.ts', 'playwright/**', 'deploy/tools/**', 'middleware.ts' ], rules: { // for configs allow to consume env variables from process.env directly 'no-restricted-properties': [ 0 ], diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d1c7eb66ac..5fa9b0ea95 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -12,6 +12,7 @@ on: - 'docs/**' - 'public/**' - 'stub/**' + - 'tools/**' # concurrency: # group: ${{ github.workflow }}__${{ github.job }}__${{ github.ref }} diff --git a/configs/app/app.ts b/configs/app/app.ts index be9a703c6b..f1b87b601d 100644 --- a/configs/app/app.ts +++ b/configs/app/app.ts @@ -9,7 +9,7 @@ const baseUrl = [ appHost, appPort && ':' + appPort, ].filter(Boolean).join(''); -const isDev = process.env.NODE_ENV === 'development'; +const isDev = getEnvValue('NODE_ENV') === 'development'; const app = Object.freeze({ isDev, diff --git a/configs/app/utils.ts b/configs/app/utils.ts index 147e415c02..5f24c8829f 100644 --- a/configs/app/utils.ts +++ b/configs/app/utils.ts @@ -4,6 +4,7 @@ import * as regexp from 'lib/regexp'; export const replaceQuotes = (value: string | undefined) => value?.replaceAll('\'', '"'); export const getEnvValue = (envName: string) => { + // eslint-disable-next-line no-restricted-properties const envs = isBrowser() ? window.__envs : process.env; if (isBrowser() && envs.NEXT_PUBLIC_APP_INSTANCE === 'pw') { @@ -36,8 +37,12 @@ export const getExternalAssetFilePath = (envName: string) => { }; export const buildExternalAssetFilePath = (name: string, value: string) => { - const fileName = name.replace(/^NEXT_PUBLIC_/, '').replace(/_URL$/, '').toLowerCase(); - const fileExtension = value.match(regexp.FILE_EXTENSION)?.[1]; - - return `/assets/${ fileName }.${ fileExtension }`; + try { + const fileName = name.replace(/^NEXT_PUBLIC_/, '').replace(/_URL$/, '').toLowerCase(); + const url = new URL(value); + const fileExtension = url.pathname.match(regexp.FILE_EXTENSION)?.[1]; + return `/assets/${ fileName }.${ fileExtension }`; + } catch (error) { + return; + } }; diff --git a/deploy/scripts/download_assets.sh b/deploy/scripts/download_assets.sh index c1c82d5b50..49bbe73b81 100755 --- a/deploy/scripts/download_assets.sh +++ b/deploy/scripts/download_assets.sh @@ -37,8 +37,14 @@ get_target_filename() { local name_suffix="${name_prefix%_URL}" local name_lc="$(echo "$name_suffix" | tr '[:upper:]' '[:lower:]')" - # Extract the extension from the URL - local extension="${url##*.}" + # Remove query parameters from the URL and get the filename + local filename=$(basename "${url%%\?*}") + + # Extract the extension from the filename + local extension="${filename##*.}" + + # Convert the extension to lowercase + extension=$(echo "$extension" | tr '[:upper:]' '[:lower:]') # Construct the custom file name echo "$name_lc.$extension" diff --git a/middleware.ts b/middleware.ts index 73829e33ba..17648c82f8 100644 --- a/middleware.ts +++ b/middleware.ts @@ -23,7 +23,6 @@ export function middleware(req: NextRequest) { const res = NextResponse.next(); res.headers.append('Content-Security-Policy', cspPolicy); res.headers.append('Server-Timing', `middleware;dur=${ end - start }`); - // eslint-disable-next-line no-restricted-properties res.headers.append('Docker-ID', process.env.HOSTNAME || ''); return res; diff --git a/ui/address/AddressTxsFilter.tsx b/ui/address/AddressTxsFilter.tsx index 5910b945e8..1b8ead77ff 100644 --- a/ui/address/AddressTxsFilter.tsx +++ b/ui/address/AddressTxsFilter.tsx @@ -31,6 +31,7 @@ const AddressTxsFilter = ({ onFilterChange, defaultFilter, isActive, isLoading } isActive={ isOpen || isActive } isLoading={ isInitialLoading } onClick={ onToggle } + appliedFiltersNum={ isActive ? 1 : 0 } as="div" /> diff --git a/ui/address/contract/ContractCode.tsx b/ui/address/contract/ContractCode.tsx index a96c969f33..465602befd 100644 --- a/ui/address/contract/ContractCode.tsx +++ b/ui/address/contract/ContractCode.tsx @@ -86,13 +86,23 @@ const ContractCode = ({ addressHash, noSocket }: Props) => { return ; } - const canBeVerified = !data?.is_self_destructed && (!data?.is_verified || data.is_partially_verified); + const canBeVerified = !data?.is_self_destructed && !data?.is_verified; - const verificationButton = isPlaceholderData ? : ( + const verificationButton = isPlaceholderData ? ( + + ) : (