Commit 0af703d5 authored by tom goriunov's avatar tom goriunov Committed by GitHub

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
parent e930020e
...@@ -4,4 +4,5 @@ node_modules_linux ...@@ -4,4 +4,5 @@ node_modules_linux
playwright/envs.js playwright/envs.js
deploy/tools/envs-validator/index.js deploy/tools/envs-validator/index.js
deploy/tools/feature-reporter/build/** deploy/tools/feature-reporter/build/**
deploy/tools/feature-reporter/index.js deploy/tools/feature-reporter/index.js
\ No newline at end of file public/**
\ No newline at end of file
...@@ -305,7 +305,7 @@ module.exports = { ...@@ -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: { rules: {
// for configs allow to consume env variables from process.env directly // for configs allow to consume env variables from process.env directly
'no-restricted-properties': [ 0 ], 'no-restricted-properties': [ 0 ],
......
...@@ -12,6 +12,7 @@ on: ...@@ -12,6 +12,7 @@ on:
- 'docs/**' - 'docs/**'
- 'public/**' - 'public/**'
- 'stub/**' - 'stub/**'
- 'tools/**'
# concurrency: # concurrency:
# group: ${{ github.workflow }}__${{ github.job }}__${{ github.ref }} # group: ${{ github.workflow }}__${{ github.job }}__${{ github.ref }}
......
...@@ -9,7 +9,7 @@ const baseUrl = [ ...@@ -9,7 +9,7 @@ const baseUrl = [
appHost, appHost,
appPort && ':' + appPort, appPort && ':' + appPort,
].filter(Boolean).join(''); ].filter(Boolean).join('');
const isDev = process.env.NODE_ENV === 'development'; const isDev = getEnvValue('NODE_ENV') === 'development';
const app = Object.freeze({ const app = Object.freeze({
isDev, isDev,
......
...@@ -4,6 +4,7 @@ import * as regexp from 'lib/regexp'; ...@@ -4,6 +4,7 @@ import * as regexp from 'lib/regexp';
export const replaceQuotes = (value: string | undefined) => value?.replaceAll('\'', '"'); export const replaceQuotes = (value: string | undefined) => value?.replaceAll('\'', '"');
export const getEnvValue = (envName: string) => { export const getEnvValue = (envName: string) => {
// eslint-disable-next-line no-restricted-properties
const envs = isBrowser() ? window.__envs : process.env; const envs = isBrowser() ? window.__envs : process.env;
if (isBrowser() && envs.NEXT_PUBLIC_APP_INSTANCE === 'pw') { if (isBrowser() && envs.NEXT_PUBLIC_APP_INSTANCE === 'pw') {
...@@ -36,8 +37,12 @@ export const getExternalAssetFilePath = (envName: string) => { ...@@ -36,8 +37,12 @@ export const getExternalAssetFilePath = (envName: string) => {
}; };
export const buildExternalAssetFilePath = (name: string, value: string) => { export const buildExternalAssetFilePath = (name: string, value: string) => {
const fileName = name.replace(/^NEXT_PUBLIC_/, '').replace(/_URL$/, '').toLowerCase(); try {
const fileExtension = value.match(regexp.FILE_EXTENSION)?.[1]; const fileName = name.replace(/^NEXT_PUBLIC_/, '').replace(/_URL$/, '').toLowerCase();
const url = new URL(value);
return `/assets/${ fileName }.${ fileExtension }`; const fileExtension = url.pathname.match(regexp.FILE_EXTENSION)?.[1];
return `/assets/${ fileName }.${ fileExtension }`;
} catch (error) {
return;
}
}; };
...@@ -37,8 +37,14 @@ get_target_filename() { ...@@ -37,8 +37,14 @@ get_target_filename() {
local name_suffix="${name_prefix%_URL}" local name_suffix="${name_prefix%_URL}"
local name_lc="$(echo "$name_suffix" | tr '[:upper:]' '[:lower:]')" local name_lc="$(echo "$name_suffix" | tr '[:upper:]' '[:lower:]')"
# Extract the extension from the URL # Remove query parameters from the URL and get the filename
local extension="${url##*.}" 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 # Construct the custom file name
echo "$name_lc.$extension" echo "$name_lc.$extension"
......
...@@ -23,7 +23,6 @@ export function middleware(req: NextRequest) { ...@@ -23,7 +23,6 @@ export function middleware(req: NextRequest) {
const res = NextResponse.next(); const res = NextResponse.next();
res.headers.append('Content-Security-Policy', cspPolicy); res.headers.append('Content-Security-Policy', cspPolicy);
res.headers.append('Server-Timing', `middleware;dur=${ end - start }`); res.headers.append('Server-Timing', `middleware;dur=${ end - start }`);
// eslint-disable-next-line no-restricted-properties
res.headers.append('Docker-ID', process.env.HOSTNAME || ''); res.headers.append('Docker-ID', process.env.HOSTNAME || '');
return res; return res;
......
...@@ -31,6 +31,7 @@ const AddressTxsFilter = ({ onFilterChange, defaultFilter, isActive, isLoading } ...@@ -31,6 +31,7 @@ const AddressTxsFilter = ({ onFilterChange, defaultFilter, isActive, isLoading }
isActive={ isOpen || isActive } isActive={ isOpen || isActive }
isLoading={ isInitialLoading } isLoading={ isInitialLoading }
onClick={ onToggle } onClick={ onToggle }
appliedFiltersNum={ isActive ? 1 : 0 }
as="div" as="div"
/> />
</MenuButton> </MenuButton>
......
...@@ -86,13 +86,23 @@ const ContractCode = ({ addressHash, noSocket }: Props) => { ...@@ -86,13 +86,23 @@ const ContractCode = ({ addressHash, noSocket }: Props) => {
return <DataFetchAlert/>; return <DataFetchAlert/>;
} }
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 ? <Skeleton w="130px" h={ 8 } mr={ 3 } ml="auto" borderRadius="base"/> : ( const verificationButton = isPlaceholderData ? (
<Skeleton
w="130px"
h={ 8 }
mr={ data?.is_partially_verified ? 0 : 3 }
ml={ data?.is_partially_verified ? 0 : 'auto' }
borderRadius="base"
flexShrink={ 0 }
/>
) : (
<Button <Button
size="sm" size="sm"
ml="auto" mr={ data?.is_partially_verified ? 0 : 3 }
mr={ 3 } ml={ data?.is_partially_verified ? 0 : 'auto' }
flexShrink={ 0 }
as="a" as="a"
href={ route({ pathname: '/address/[hash]/contract-verification', query: { hash: addressHash || '' } }) } href={ route({ pathname: '/address/[hash]/contract-verification', query: { hash: addressHash || '' } }) }
> >
...@@ -164,7 +174,10 @@ const ContractCode = ({ addressHash, noSocket }: Props) => { ...@@ -164,7 +174,10 @@ const ContractCode = ({ addressHash, noSocket }: Props) => {
<Flex flexDir="column" rowGap={ 2 } mb={ 6 } _empty={{ display: 'none' }}> <Flex flexDir="column" rowGap={ 2 } mb={ 6 } _empty={{ display: 'none' }}>
{ data?.is_verified && ( { data?.is_verified && (
<Skeleton isLoaded={ !isPlaceholderData }> <Skeleton isLoaded={ !isPlaceholderData }>
<Alert status="success">Contract Source Code Verified ({ data.is_partially_verified ? 'Partial' : 'Exact' } Match)</Alert> <Alert status="success" flexWrap="wrap" rowGap={ 3 } columnGap={ 5 }>
<span>Contract Source Code Verified ({ data.is_partially_verified ? 'Partial' : 'Exact' } Match)</span>
{ data.is_partially_verified ? verificationButton : null }
</Alert>
</Skeleton> </Skeleton>
) } ) }
{ verificationAlert } { verificationAlert }
......
...@@ -26,6 +26,7 @@ const VerifiedContractsFilter = ({ onChange, defaultValue, isActive }: Props) => ...@@ -26,6 +26,7 @@ const VerifiedContractsFilter = ({ onChange, defaultValue, isActive }: Props) =>
<MenuButton> <MenuButton>
<FilterButton <FilterButton
isActive={ isOpen || isActive } isActive={ isOpen || isActive }
appliedFiltersNum={ isActive ? 1 : 0 }
onClick={ onToggle } onClick={ onToggle }
as="div" as="div"
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment