Skip to content

Commit

Permalink
Merge branch 'main' of github.com:blockscout/frontend into tom2drum/i…
Browse files Browse the repository at this point in the history
…ssue-1213
  • Loading branch information
tom2drum committed Oct 16, 2023
2 parents 5b6c581 + eae41d1 commit 2e303e4
Show file tree
Hide file tree
Showing 79 changed files with 950 additions and 590 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile --ignore-optional

- name: Run ESLint
run: yarn lint:eslint
Expand Down Expand Up @@ -74,10 +74,10 @@ jobs:

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile --ignore-optional

- name: Install script dependencies
run: cd ./deploy/tools/envs-validator && yarn --frozen-lockfile
run: cd ./deploy/tools/envs-validator && yarn --frozen-lockfile --ignore-optional

- name: Copy secrets file
run: cp ./.env.example ./configs/envs/.env.secrets
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile --ignore-optional

- name: Run Jest
run: yarn test:jest
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile --ignore-optional

- name: Run PlayWright
run: yarn test:pw:ci
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
state: 'all'
});
if (issues.length === 0) {
core.notice(`No issues with label "${ process.env.LABEL_NAME }" found.`);
return;
}

const issueIds = issues.map(({ node_id }) => node_id);
const labelId = issues[0].labels.find(({ name }) => name === process.env.LABEL_NAME).node_id;

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN apk add git
RUN yarn --frozen-lockfile
RUN yarn --frozen-lockfile --ignore-optional


### FEATURE REPORTER
Expand Down
24 changes: 20 additions & 4 deletions configs/app/ui/views/address.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import type { IdenticonType } from 'types/views/address';
import { IDENTICON_TYPES } from 'types/views/address';
import type { AddressViewId, IdenticonType } from 'types/views/address';
import { ADDRESS_VIEWS_IDS, IDENTICON_TYPES } from 'types/views/address';

import { getEnvValue } from 'configs/app/utils';
import { getEnvValue, parseEnvJson } from 'configs/app/utils';

const identiconType: IdenticonType = (() => {
const value = getEnvValue('NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE');

return IDENTICON_TYPES.find((type) => value === type) || 'jazzicon';
})();

const hiddenViews = (() => {
const parsedValue = parseEnvJson<Array<AddressViewId>>(getEnvValue('NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS')) || [];

if (!Array.isArray(parsedValue)) {
return undefined;
}

const result = ADDRESS_VIEWS_IDS.reduce((result, item) => {
result[item] = parsedValue.includes(item);
return result;
}, {} as Record<AddressViewId, boolean>);

return result;
})();

const config = Object.freeze({
identiconType: identiconType,
identiconType,
hiddenViews,
});

export default config;
3 changes: 2 additions & 1 deletion configs/app/ui/views/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as block } from './block';
export { default as address } from './address';
export { default as block } from './block';
export { default as nft } from './nft';
export { default as tx } from './tx';
41 changes: 41 additions & 0 deletions configs/app/ui/views/tx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { TxAdditionalFieldsId, TxFieldsId } from 'types/views/tx';
import { TX_ADDITIONAL_FIELDS_IDS, TX_FIELDS_IDS } from 'types/views/tx';

import { getEnvValue, parseEnvJson } from 'configs/app/utils';

const hiddenFields = (() => {
const parsedValue = parseEnvJson<Array<TxFieldsId>>(getEnvValue('NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS')) || [];

if (!Array.isArray(parsedValue)) {
return undefined;
}

const result = TX_FIELDS_IDS.reduce((result, item) => {
result[item] = parsedValue.includes(item);
return result;
}, {} as Record<TxFieldsId, boolean>);

return result;
})();

const additionalFields = (() => {
const parsedValue = parseEnvJson<Array<TxAdditionalFieldsId>>(getEnvValue('NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS')) || [];

if (!Array.isArray(parsedValue)) {
return undefined;
}

const result = TX_ADDITIONAL_FIELDS_IDS.reduce((result, item) => {
result[item] = parsedValue.includes(item);
return result;
}, {} as Record<TxAdditionalFieldsId, boolean>);

return result;
})();

const config = Object.freeze({
hiddenFields,
additionalFields,
});

export default config;
4 changes: 4 additions & 0 deletions configs/envs/.env.main
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-c
NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES=[{'name':'LooksRare','collection_url':'https://goerli.looksrare.org/collections/{hash}','instance_url':'https://goerli.looksrare.org/collections/{hash}/{id}','logo_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/nft-marketplace-logos/looks-rare.png'}]
## misc
NEXT_PUBLIC_NETWORK_EXPLORERS=[{'title':'Bitquery','baseUrl':'https://explorer.bitquery.io/','paths':{'tx':'/goerli/tx','address':'/goerli/address','token':'/goerli/token','block':'/goerli/block'}},{'title':'Etherscan','baseUrl':'https://goerli.etherscan.io/','paths':{'tx':'/tx','address':'/address','token':'/token','block':'/block'}}]
## views
# NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS=['top_accounts']
# NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS=['value','fee_currency','gas_price','tx_fee','gas_fees','burnt_fees']
# NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS=['fee_per_gas']

# app features
NEXT_PUBLIC_APP_ENV=development
Expand Down
5 changes: 4 additions & 1 deletion deploy/scripts/make_envs_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "🌀 Creating client script with ENV values..."

# Define the output file name
output_file="./public/envs.js"
output_file="${1:-./public/envs.js}"

touch $output_file;
truncate -s 0 $output_file;
Expand All @@ -21,6 +21,9 @@ for var in $(env | grep '^NEXT_PUBLIC_' | cut -d= -f1); do
# Get the value of the variable
value="${!var}"

# Replace double quotes with single quotes
value="${value//\"/\'}"

# Write the variable name and value to the output file
echo "${var}: \"${value}\"," >> "$output_file"
done
Expand Down
20 changes: 19 additions & 1 deletion deploy/tools/envs-validator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ import { SUPPORTED_WALLETS } from '../../../types/client/wallets';
import type { CustomLink, CustomLinksGroup } from '../../../types/footerLinks';
import type { ChainIndicatorId } from '../../../types/homepage';
import { type NetworkVerificationType, type NetworkExplorer, type FeaturedNetwork, NETWORK_GROUPS } from '../../../types/networks';
import { IDENTICON_TYPES } from '../../../types/views/address';
import type { AddressViewId } from '../../../types/views/address';
import { ADDRESS_VIEWS_IDS, IDENTICON_TYPES } from '../../../types/views/address';
import { BLOCK_FIELDS_IDS } from '../../../types/views/block';
import type { BlockFieldId } from '../../../types/views/block';
import type { NftMarketplaceItem } from '../../../types/views/nft';
import type { TxAdditionalFieldsId, TxFieldsId } from '../../../types/views/tx';
import { TX_ADDITIONAL_FIELDS_IDS, TX_FIELDS_IDS } from '../../../types/views/tx';

import { replaceQuotes } from '../../../configs/app/utils';
import * as regexp from '../../../lib/regexp';
Expand Down Expand Up @@ -369,6 +372,21 @@ const schema = yup
.json()
.of(yup.string<BlockFieldId>().oneOf(BLOCK_FIELDS_IDS)),
NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE: yup.string().oneOf(IDENTICON_TYPES),
NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS: yup
.array()
.transform(replaceQuotes)
.json()
.of(yup.string<AddressViewId>().oneOf(ADDRESS_VIEWS_IDS)),
NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS: yup
.array()
.transform(replaceQuotes)
.json()
.of(yup.string<TxFieldsId>().oneOf(TX_FIELDS_IDS)),
NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS: yup
.array()
.transform(replaceQuotes)
.json()
.of(yup.string<TxAdditionalFieldsId>().oneOf(TX_ADDITIONAL_FIELDS_IDS)),
NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES: yup
.array()
.transform(replaceQuotes)
Expand Down
10 changes: 7 additions & 3 deletions deploy/values/l2-optimism-goerli/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ blockscout:
ETHEREUM_JSONRPC_VARIANT: geth
MIX_ENV: prod
MICROSERVICE_SC_VERIFIER_ENABLED: 'true'
MICROSERVICE_SC_VERIFIER_TYPE: 'eth_bytecode_db'
MICROSERVICE_SC_VERIFIER_URL: https://sc-verifier-test.k8s-dev.blockscout.com
DISABLE_EXCHANGE_RATES: 'true'
APPS_MENU: 'true'
Expand Down Expand Up @@ -183,7 +184,6 @@ frontend:
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM: https://airtable.com/shrqUAcjgGJ4jU88C
NEXT_PUBLIC_LOGOUT_URL: https://blockscoutcom.us.auth0.com/v2/logout
NEXT_PUBLIC_MARKETPLACE_CONFIG_URL: https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/marketplace/base-goerli.json
NEXT_PUBLIC_NETWORK_EXPLORERS: ''
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND: "linear-gradient(136.9deg,rgb(107 94 236) 1.5%,rgb(0 82 255) 56.84%,rgb(82 62 231) 98.54%)"
NEXT_PUBLIC_NETWORK_RPC_URL: https://goerli.optimism.io
NEXT_PUBLIC_WEB3_WALLETS: "['coinbase']"
Expand All @@ -197,6 +197,10 @@ frontend:
NEXT_PUBLIC_L2_WITHDRAWAL_URL: https://app.optimism.io/bridge/withdraw
NEXT_PUBLIC_GRAPHIQL_TRANSACTION: 0x4a0ed8ddf751a7cb5297f827699117b0f6d21a0b2907594d300dc9fed75c7e62
envFromSecret:
NEXT_PUBLIC_AUTH0_CLIENT_ID: ref+vault://deployment-values/blockscout/dev/l2-optimism-goerli?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_AUTH0_CLIENT_ID
NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID: ref+vault://deployment-values/blockscout/dev/l2-optimism-goerli?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID
NEXT_PUBLIC_SENTRY_DSN: ref+vault://deployment-values/blockscout/dev/front-main?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_SENTRY_DSN
SENTRY_CSP_REPORT_URI: ref+vault://deployment-values/blockscout/dev/front-main?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/SENTRY_CSP_REPORT_URI
NEXT_PUBLIC_AUTH0_CLIENT_ID: ref+vault://deployment-values/blockscout/dev/front-main?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_AUTH0_CLIENT_ID
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: ref+vault://deployment-values/blockscout/dev/front-main?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY: ref+vault://deployment-values/blockscout/dev/front-main?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY
NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID: ref+vault://deployment-values/blockscout/dev/front-main?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID
NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY: ref+vault://deployment-values/blockscout/common?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY
1 change: 1 addition & 0 deletions deploy/values/main/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ blockscout:
DISPLAY_TOKEN_ICONS: 'true'
FETCH_REWARDS_WAY: manual
MICROSERVICE_SC_VERIFIER_ENABLED: 'true'
MICROSERVICE_SC_VERIFIER_TYPE: 'eth_bytecode_db'
MICROSERVICE_SC_VERIFIER_URL: http://eth-bytecode-db-svc.eth-bytecode-db-testing.svc.cluster.local:80
INDEXER_MEMORY_LIMIT: 5
APPS_MENU: 'true'
Expand Down
6 changes: 6 additions & 0 deletions deploy/values/review/values.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ frontend:
_default: "['token_pocket','coinbase','metamask']"
NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE:
_default: gradient_avatar
NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS:
_default: "['top_accounts']"
NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS:
_default: "['value','fee_currency','gas_price','gas_fees','burnt_fees']"
NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS:
_default: "['fee_per_gas']"
NEXT_PUBLIC_USE_NEXT_JS_PROXY:
_default: true
NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES:
Expand Down
32 changes: 32 additions & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The app instance could be customized by passing following variables to NodeJS en
- [Meta](ENVS.md#meta)
- [Views](ENVS.md#views)
- [Block](ENVS.md#block-views)
- [Address](ENVS.md#address-views)
- [Transaction](ENVS.md#transaction-views)
- [NFT](ENVS.md#nft-views)
- [Misc](ENVS.md#misc)
- [App features](ENVS.md#app-features)
Expand Down Expand Up @@ -185,6 +187,36 @@ Settings for meta tags and OG tags
| Variable | Type | Description | Compulsoriness | Default value | Example value |
| --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE | `"github" \| "jazzicon" \| "gradient_avatar" \| "blockie"` | Style of address identicon appearance. Choose between [GitHub](https://github.blog/2013-08-14-identicons/), [Metamask Jazzicon](https://metamask.github.io/jazzicon/), [Gradient Avatar](https://github.com/varld/gradient-avatar) and [Ethereum Blocky](https://mycryptohq.github.io/ethereum-blockies-base64/) | - | `jazzicon` | `gradient_avatar` |
| NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS | `Array<AddressViewId>` | Address views that should not be displayed. See below the list of the possible id values. | - | - | `'["top_accounts"]'` |

##### Address views list
| Id | Description |
| --- | --- |
| `top_accounts` | Top accounts |

&nbsp;

#### Transaction views

| Variable | Type | Description | Compulsoriness | Default value | Example value |
| --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS | `Array<TxFieldsId>` | Array of the transaction fields ids that should be hidden. See below the list of the possible id values. | - | - | `'["value","tx_fee"]'` |
| NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS | `Array<TxAdditionalFieldsId>` | Array of the additional fields ids that should be added to the transaction details. See below the list of the possible id values. | - | - | `'["fee_per_gas"]'` |

##### Transaction fields list
| Id | Description |
| --- | --- |
| `value` | Sent value |
| `fee_currency` | Fee currency |
| `gas_price` | Price per unit of gas |
| `tx_fee` | Total transaction fee |
| `gas_fees` | Gas fees breakdown |
| `burnt_fees` | Amount of native coin burnt for transaction |

##### Transaction additional fields list
| Id | Description |
| --- | --- |
| `fee_per_gas` | Amount of total fee divided by total amount of gas used by transaction |

&nbsp;

Expand Down
6 changes: 5 additions & 1 deletion lib/hooks/useIssueUrl.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { useRouter } from 'next/router';
import React from 'react';

import config from 'configs/app';

export default function useIssueUrl(backendVersion: string | undefined) {
const [ isLoading, setIsLoading ] = React.useState(true);
const router = useRouter();

React.useEffect(() => {
setIsLoading(false);
Expand All @@ -23,6 +25,8 @@ export default function useIssueUrl(backendVersion: string | undefined) {
'additional-information': `**User Agent:** ${ window.navigator.userAgent }`,
});
return `https://github.com/blockscout/blockscout/issues/new/?${ searchParams.toString() }`;
}, [ backendVersion, isLoading ]);
// we need to update link whenever page url changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ backendVersion, isLoading, router.asPath ]);

}
6 changes: 3 additions & 3 deletions lib/hooks/useNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export default function useNavItems(): ReturnType {
return React.useMemo(() => {
let blockchainNavItems: Array<NavItem> | Array<Array<NavItem>> = [];

const topAccounts = {
const topAccounts = !config.UI.views.address.hiddenViews?.top_accounts ? {
text: 'Top accounts',
nextRoute: { pathname: '/accounts' as const },
icon: topAccountsIcon,
isActive: pathname === '/accounts',
};
} : null;
const blocks = {
text: 'Blocks',
nextRoute: { pathname: '/blocks' as const },
Expand Down Expand Up @@ -90,7 +90,7 @@ export default function useNavItems(): ReturnType {
[
topAccounts,
verifiedContracts,
],
].filter(Boolean),
];
} else {
blockchainNavItems = [
Expand Down
2 changes: 2 additions & 0 deletions mocks/txs/internalTxs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const typeStaticCall: InternalTransaction = {
name: null,
},
gas_limit: '63424243',
transaction_hash: '0xe9e27dfeb183066e26cfe556f74b7219b08df6951e25d14003d4fc7af8bbff62',
};

export const withContractCreated: InternalTransaction = {
Expand All @@ -63,6 +64,7 @@ export const withContractCreated: InternalTransaction = {
},
value: '1420000000000000000',
gas_limit: '5433',
transaction_hash: '0xe9e27dfeb183066e26cfe556f74b7219b08df6951e25d14003d4fc7af8bbff63',
};

export const baseResponse: InternalTransactionsResponse = {
Expand Down
Loading

0 comments on commit 2e303e4

Please sign in to comment.