Skip to content

Commit

Permalink
Merge pull request #2200 from blockscout/release/v1-34-0
Browse files Browse the repository at this point in the history
Fixes for Release v1.34.0
  • Loading branch information
tom2drum authored Sep 9, 2024
2 parents d37205b + 758ca37 commit 73fd6c2
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 122 deletions.
16 changes: 14 additions & 2 deletions configs/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,22 @@ export const getExternalAssetFilePath = (envName: string) => {
export const buildExternalAssetFilePath = (name: string, value: string) => {
try {
const fileName = name.replace(/^NEXT_PUBLIC_/, '').replace(/_URL$/, '').toLowerCase();
const url = new URL(value);
const fileExtension = url.pathname.match(regexp.FILE_EXTENSION)?.[1];

const fileExtension = getAssetFileExtension(value);
if (!fileExtension) {
throw new Error('Cannot get file path');
}
return `/assets/configs/${ fileName }.${ fileExtension }`;
} catch (error) {
return;
}
};

function getAssetFileExtension(value: string) {
try {
const url = new URL(value);
return url.pathname.match(regexp.FILE_EXTENSION)?.[1];
} catch (error) {
return parseEnvJson(value) ? 'json' : undefined;
}
}
35 changes: 27 additions & 8 deletions deploy/scripts/download_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ get_target_filename() {
# Extract the extension from the filename
local extension="${filename##*.}"
else
# Remove query parameters from the URL and get the filename
local filename=$(basename "${url%%\?*}")
# Extract the extension from the filename
local extension="${filename##*.}"
if [[ "$url" == http* ]]; then
# Remove query parameters from the URL and get the filename
local filename=$(basename "${url%%\?*}")
# Extract the extension from the filename
local extension="${filename##*.}"
else
local extension="json"
fi
fi

# Convert the extension to lowercase
Expand Down Expand Up @@ -80,16 +84,31 @@ download_and_save_asset() {
# Copy the local file to the destination
cp "${url#file://}" "$destination"
else
# Download the asset using curl
curl -s -o "$destination" "$url"
# Check if the value is a URL
if [[ "$url" == http* ]]; then
# Download the asset using curl
curl -s -o "$destination" "$url"
else
# Convert single-quoted JSON-like content to valid JSON
json_content=$(echo "${!env_var}" | sed "s/'/\"/g")

# Save the JSON content to a file
echo "$json_content" > "$destination"
fi
fi

if [[ "$url" == file://* ]] || [[ "$url" == http* ]]; then
local source_name=$url
else
local source_name="raw input"
fi

# Check if the download was successful
if [ $? -eq 0 ]; then
echo " [+] $env_var: Successfully saved file from $url to $destination."
echo " [+] $env_var: Successfully saved file from $source_name to $destination."
return 0
else
echo " [-] $env_var: Failed to save file from $url."
echo " [-] $env_var: Failed to save file from $source_name."
return 1
fi
}
Expand Down
4 changes: 2 additions & 2 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ _Note_ Here, all values are arrays of up to two strings. The first string repres
| NEXT_PUBLIC_NETWORK_LOGO_DARK | `string` | Network logo for dark color mode; if not provided, **inverted** regular logo will be used instead | - | - | `https://placekitten.com/240/40` | v1.0.x+ |
| NEXT_PUBLIC_NETWORK_ICON | `string` | Network icon; used as a replacement for regular network logo when nav bar is collapsed; if not provided, placeholder will be shown; *Note* the icon size should be at least 60px by 60px | - | - | `https://placekitten.com/60/60` | v1.0.x+ |
| NEXT_PUBLIC_NETWORK_ICON_DARK | `string` | Network icon for dark color mode; if not provided, **inverted** regular icon will be used instead | - | - | `https://placekitten.com/60/60` | v1.0.x+ |
| NEXT_PUBLIC_FEATURED_NETWORKS | `string` | URL of configuration file (`.json` format only) which contains list of featured networks that will be shown in the network menu. See [below](#featured-network-configuration-properties) list of available properties for particular network | - | - | `https://example.com/featured_networks_config.json` | v1.0.x+ |
| NEXT_PUBLIC_FEATURED_NETWORKS | `string` | URL of configuration file (`.json` format only) or file content string representation. It contains list of featured networks that will be shown in the network menu. See [below](#featured-network-configuration-properties) list of available properties for particular network | - | - | `https://example.com/featured_networks_config.json` \| `[{'title':'Astar(EVM)','url':'https://astar.blockscout.com/','group':'Mainnets','icon':'https://example.com/astar.svg'}]` | v1.0.x+ |
| NEXT_PUBLIC_OTHER_LINKS | `Array<{url: string; text: string}>` | List of links for the "Other" navigation menu | - | - | `[{'url':'https://blockscout.com','text':'Blockscout'}]` | v1.0.x+ |
| NEXT_PUBLIC_NAVIGATION_HIDDEN_LINKS | `Array<LinkId>` | List of external links hidden in the navigation. Supported ids are `eth_rpc_api`, `rpc_api` | - | - | `['eth_rpc_api']` | v1.16.0+ |
| NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES | `Array<string>` | List of menu item routes that should have a lightning label | - | - | `['/accounts']` | v1.31.0+ |
Expand All @@ -167,7 +167,7 @@ _Note_ Here, all values are arrays of up to two strings. The first string repres

| Variable | Type| Description | Compulsoriness | Default value | Example value | Version |
| --- | --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_FOOTER_LINKS | `string` | URL of configuration file (`.json` format only) which contains list of link groups to be displayed in the footer. See [below](#footer-links-configuration-properties) list of available properties for particular group | - | - | `https://example.com/footer_links_config.json` | v1.1.1+ |
| NEXT_PUBLIC_FOOTER_LINKS | `string` | URL of configuration file (`.json` format only) or file content string representation. It contains list of link groups to be displayed in the footer. See [below](#footer-links-configuration-properties) list of available properties for particular group | - | - | `https://example.com/footer_links_config.json` \| `[{'title':'My chain','links':[{'text':'About','url':'https://example.com/about'},{'text':'Contacts','url':'https://example.com/contacts'}]}]` | v1.1.1+ |

The app version shown in the footer is derived from build-time ENV variables `NEXT_PUBLIC_GIT_TAG` and `NEXT_PUBLIC_GIT_COMMIT_SHA` and cannot be overwritten at run-time.

Expand Down
1 change: 1 addition & 0 deletions lib/address/parseMetaPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function parseMetaPayload(meta: AddressMetadataTag['meta']): Addr
'data',
'alertBgColor',
'alertTextColor',
'alertStatus',
];

for (const stringField of stringFields) {
Expand Down
3 changes: 3 additions & 0 deletions types/api/addressMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { AlertStatus } from '@chakra-ui/react';

export interface AddressMetadataInfo {
addresses: Record<string, {
tags: Array<AddressMetadataTag>;
Expand Down Expand Up @@ -35,6 +37,7 @@ export interface AddressMetadataTagApi extends Omit<AddressMetadataTag, 'meta'>
data?: string;
alertBgColor?: string;
alertTextColor?: string;
alertStatus?: AlertStatus;
} | null;
}

Expand Down
11 changes: 5 additions & 6 deletions ui/address/AddressDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import React from 'react';

import config from 'configs/app';
import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
import useIsMounted from 'lib/hooks/useIsMounted';
import getNetworkValidationActionText from 'lib/networks/getNetworkValidationActionText';
import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
import getQueryParamString from 'lib/router/getQueryParamString';
import AddressCounterItem from 'ui/address/details/AddressCounterItem';
import ServiceDegradationWarning from 'ui/shared/alerts/ServiceDegradationWarning';
Expand Down Expand Up @@ -63,8 +64,6 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
has_validated_blocks: false,
}), [ addressHash ]);

const isMounted = useIsMounted();

// error handling (except 404 codes)
if (addressQuery.isError) {
if (isCustomAppError(addressQuery.error)) {
Expand All @@ -79,7 +78,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {

const data = addressQuery.isError ? error404Data : addressQuery.data;

if (!data || !isMounted) {
if (!data) {
return null;
}

Expand Down Expand Up @@ -219,10 +218,10 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
{ data.has_validated_blocks && (
<>
<DetailsInfoItem.Label
hint="Number of blocks validated by this validator"
hint={ `Number of blocks ${ getNetworkValidationActionText() } by this ${ getNetworkValidatorTitle() }` }
isLoading={ addressQuery.isPlaceholderData || countersQuery.isPlaceholderData }
>
Blocks validated
{ `Blocks ${ getNetworkValidationActionText() }` }
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
{ addressQuery.data ? (
Expand Down
3 changes: 1 addition & 2 deletions ui/address/details/AddressMetadataAlert.pw.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Box } from '@chakra-ui/react';
import React from 'react';

import * as metadataMock from 'mocks/metadata/address';
Expand All @@ -7,7 +6,7 @@ import { test, expect } from 'playwright/lib';
import AddressMetadataAlert from './AddressMetadataAlert';

test('base view', async({ render }) => {
const component = await render(<Box mt={ 1 }><AddressMetadataAlert tags={ [ metadataMock.noteTag ] }/></Box>);
const component = await render(<AddressMetadataAlert tags={ [ metadataMock.noteTag ] }/>);

await expect(component).toHaveScreenshot();
});
13 changes: 7 additions & 6 deletions ui/address/details/AddressMetadataAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Alert } from '@chakra-ui/react';
import { Alert, chakra } from '@chakra-ui/react';
import React from 'react';

import type { AddressMetadataTagFormatted } from 'types/client/addressMetadata';

interface Props {
tags: Array<AddressMetadataTagFormatted> | undefined;
className?: string;
}

const AddressMetadataAlert = ({ tags }: Props) => {
const AddressMetadataAlert = ({ tags, className }: Props) => {
const noteTag = tags?.find(({ tagType }) => tagType === 'note');
if (!noteTag) {
return null;
Expand All @@ -21,12 +22,12 @@ const AddressMetadataAlert = ({ tags }: Props) => {

return (
<Alert
mt="-4px"
mb={ 6 }
status="error"
className={ className }
status={ noteTag.meta?.alertStatus ?? 'error' }
bgColor={ noteTag.meta?.alertBgColor }
color={ noteTag.meta?.alertTextColor }
whiteSpace="pre-wrap"
display="inline-block"
sx={{
'& a': {
color: 'link',
Expand All @@ -40,4 +41,4 @@ const AddressMetadataAlert = ({ tags }: Props) => {
);
};

export default React.memo(AddressMetadataAlert);
export default React.memo(chakra(AddressMetadataAlert));
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ContractVerificationFieldCompiler from '../fields/ContractVerificationFie
import ContractVerificationFieldName from '../fields/ContractVerificationFieldName';
import ContractVerificationFieldSources from '../fields/ContractVerificationFieldSources';
import ContractVerificationFieldZkCompiler from '../fields/ContractVerificationFieldZkCompiler';
import ContractVerificationFieldZkOptimization from '../fields/ContractVerificationFieldZkOptimization';

const FILE_TYPES = [ '.json' as const ];
const rollupFeature = config.features.rollup;
Expand All @@ -27,7 +26,6 @@ const ContractVerificationStandardInput = ({ config }: { config: SmartContractVe
hint="Upload the standard input JSON file created during contract compilation."
required
/>
{ rollupFeature.isEnabled && rollupFeature.type === 'zkSync' && <ContractVerificationFieldZkOptimization config={ config }/> }
{ !config?.is_rust_verifier_microservice_enabled && <ContractVerificationFieldAutodetectArgs/> }
</ContractVerificationMethod>
);
Expand Down
2 changes: 0 additions & 2 deletions ui/contractVerification/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export interface FormFieldsStandardInputZk {
autodetect_constructor_args: boolean;
constructor_args: string;
license_type: LicenseOption | null;
is_optimization_enabled: boolean;
optimization_mode: string | undefined;
}

export interface FormFieldsSourcify {
Expand Down
6 changes: 0 additions & 6 deletions ui/contractVerification/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,6 @@ export function prepareRequestBody(data: FormFields): FetchParams['body'] {

// zkSync fields
'zk_compiler' in _data && _data.zk_compiler && body.set('zk_compiler_version', _data.zk_compiler.value);
if ('is_optimization_enabled' in _data) {
body.set('is_optimization_enabled', String(Boolean(_data.is_optimization_enabled)));
if (_data.is_optimization_enabled && 'optimization_mode' in _data && _data.optimization_mode) {
body.set('optimization_runs', _data.optimization_mode);
}
}

return body;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ const AddressPageContent = () => {
isLoading={ isLoading }
/>
{ !addressMetadataQuery.isPending &&
<AddressMetadataAlert tags={ addressMetadataQuery.data?.addresses?.[hash.toLowerCase()]?.tags }/> }
<AddressMetadataAlert tags={ addressMetadataQuery.data?.addresses?.[hash.toLowerCase()]?.tags } mt="-4px" mb={ 6 }/> }
{ config.features.metasuites.isEnabled && <Box display="none" id="meta-suites__address" data-ready={ !isLoading }/> }
<AddressDetails addressQuery={ addressQuery } scrollRef={ tabsScrollRef }/>
{ /* should stay before tabs to scroll up with pagination */ }
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/Marketplace.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { test, expect, devices } from 'playwright/lib';

import Marketplace from './Marketplace';

const MARKETPLACE_CONFIG_URL = 'http://localhost/marketplace-config.json';
const MARKETPLACE_SECURITY_REPORTS_URL = 'https://marketplace-security-reports.json';
const MARKETPLACE_CONFIG_URL = 'http://localhost:4000/marketplace-config.json';
const MARKETPLACE_SECURITY_REPORTS_URL = 'https://localhost:4000/marketplace-security-reports.json';

test.beforeEach(async({ mockConfigResponse, mockEnvs, mockAssetResponse, page }) => {
await mockEnvs([
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/MarketplaceApp.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const hooksConfig = {
},
};

const MARKETPLACE_CONFIG_URL = 'https://marketplace-config.json';
const MARKETPLACE_SECURITY_REPORTS_URL = 'https://marketplace-security-reports.json';
const MARKETPLACE_CONFIG_URL = 'http://localhost:4000/marketplace-config.json';
const MARKETPLACE_SECURITY_REPORTS_URL = 'http://localhost:4000/marketplace-security-reports.json';

const testFn: Parameters<typeof test>[1] = async({ render, mockConfigResponse, mockAssetResponse, mockEnvs, mockRpcResponse, page }) => {
await mockEnvs([
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/SearchResults.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ test('search by user op hash +@mobile', async({ render, mockApiResponse, mockEnv

test.describe('with apps', () => {
test('default view +@mobile', async({ render, mockApiResponse, mockConfigResponse, mockAssetResponse, mockEnvs }) => {
const MARKETPLACE_CONFIG_URL = 'https://marketplace-config.json';
const MARKETPLACE_CONFIG_URL = 'https://localhost:4000/marketplace-config.json';
const hooksConfig = {
router: {
query: { q: 'o' },
Expand Down
2 changes: 1 addition & 1 deletion ui/snippets/searchBar/SearchBar.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ test('recent keywords suggest +@mobile', async({ render, page }, { project }) =>
});

test.describe('with apps', () => {
const MARKETPLACE_CONFIG_URL = 'https://marketplace-config.json';
const MARKETPLACE_CONFIG_URL = 'http://localhost:4000/marketplace-config.json';

test('default view +@mobile', async({ render, page, mockApiResponse, mockConfigResponse, mockAssetResponse, mockEnvs }) => {
await mockEnvs([
Expand Down
2 changes: 1 addition & 1 deletion ui/tx/details/TxInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => {
<>
<GridItem colSpan={{ base: undefined, lg: 2 }} mt={{ base: 1, lg: 4 }}/>

{ data.arbitrum?.message_related_info && (
{ data.arbitrum?.contains_message && data.arbitrum?.message_related_info && (
<>
<DetailsInfoItem.Label
hint={ data.arbitrum.contains_message === 'incoming' ?
Expand Down

0 comments on commit 73fd6c2

Please sign in to comment.