Skip to content

Commit

Permalink
Merge branch 'main' into noves
Browse files Browse the repository at this point in the history
  • Loading branch information
NahuelNoves committed Mar 20, 2024
2 parents cb0d8e7 + 4a6ac17 commit d19d1f3
Show file tree
Hide file tree
Showing 142 changed files with 1,017 additions and 358 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v4
Expand All @@ -115,7 +117,7 @@ jobs:
run: yarn --frozen-lockfile --ignore-optional

- name: Run Jest
run: yarn test:jest --onlyChanged=${{ github.event_name == 'pull_request' }} --passWithNoTests
run: yarn test:jest ${{ github.event_name == 'pull_request' && '--changedSince=origin/main' || '' }} --passWithNoTests

pw_affected_tests:
name: Resolve affected Playwright tests
Expand Down
6 changes: 6 additions & 0 deletions configs/envs/.env.eth
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER=blockscout
NEXT_PUBLIC_AD_BANNER_PROVIDER=hype
NEXT_PUBLIC_SAFE_TX_SERVICE_URL=https://safe-transaction-mainnet.safe.global
NEXT_PUBLIC_NAME_SERVICE_API_HOST=https://bens.services.blockscout.com
NEXT_PUBLIC_MARKETPLACE_ENABLED=true
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-categories/default.json
NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-categories/default.json
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://airtable.com/appiy5yijZpMMSKjT/shr6uMGPKjj1DK7NL
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM=https://airtable.com/appiy5yijZpMMSKjT/pag3t82DUCyhGRZZO/form
NEXT_PUBLIC_VIEWS_CONTRACT_SOLIDITYSCAN_ENABLED=true

#meta
NEXT_PUBLIC_OG_IMAGE_URL=https://github.com/blockscout/frontend-configs/blob/main/configs/og-images/eth.jpg?raw=true
6 changes: 3 additions & 3 deletions configs/envs/.env.optimism_goerli
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://contracts-info.services.blockscout.com
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com
# rollup
NEXT_PUBLIC_IS_OPTIMISTIC_L2_NETWORK=true
NEXT_PUBLIC_OPTIMISTIC_L2_WITHDRAWAL_URL=https://app.optimism.io/bridge/withdraw
NEXT_PUBLIC_L1_BASE_URL=https://eth-goerli.blockscout.com/
NEXT_PUBLIC_ROLLUP_TYPE='optimistic'
NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL=https://app.optimism.io/bridge/withdraw
NEXT_PUBLIC_ROLLUP_L1_BASE_URL=https://eth-goerli.blockscout.com/
1 change: 1 addition & 0 deletions configs/envs/.env.sepolia
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ NEXT_PUBLIC_WEB3_WALLETS=['token_pocket','metamask']
NEXT_PUBLIC_VIEWS_CONTRACT_SOLIDITYSCAN_ENABLED=true
NEXT_PUBLIC_HAS_BEACON_CHAIN=true
NEXT_PUBLIC_HAS_USER_OPS=true
NEXT_PUBLIC_AD_BANNER_PROVIDER=getit

#meta
NEXT_PUBLIC_OG_IMAGE_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/og-images/sepolia-testnet.png
3 changes: 2 additions & 1 deletion deploy/values/review/values.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ frontend:
NEXT_PUBLIC_FEATURED_NETWORKS: https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/featured-networks/eth-goerli.json
NEXT_PUBLIC_NETWORK_LOGO: https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/goerli.svg
NEXT_PUBLIC_NETWORK_ICON: https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/goerli.svg
NEXT_PUBLIC_API_HOST: eth-goerli.blockscout.com
NEXT_PUBLIC_API_HOST: eth-sepolia.blockscout.com
NEXT_PUBLIC_STATS_API_HOST: https://stats-goerli.k8s-dev.blockscout.com/
NEXT_PUBLIC_VISUALIZE_API_HOST: http://visualizer-svc.visualizer-testing.svc.cluster.local/
NEXT_PUBLIC_CONTRACT_INFO_API_HOST: https://contracts-info-test.k8s-dev.blockscout.com
Expand Down Expand Up @@ -82,6 +82,7 @@ frontend:
NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER: noves
NEXT_PUBLIC_SWAP_BUTTON_URL: uniswap
NEXT_PUBLIC_HAS_CONTRACT_AUDIT_REPORTS: true
NEXT_PUBLIC_AD_BANNER_PROVIDER: getit
envFromSecret:
NEXT_PUBLIC_SENTRY_DSN: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_SENTRY_DSN
SENTRY_CSP_REPORT_URI: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/SENTRY_CSP_REPORT_URI
Expand Down
2 changes: 1 addition & 1 deletion docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ This feature is **enabled by default** with the `slise` ads provider. To switch

| Variable | Type| Description | Compulsoriness | Default value | Example value |
| --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_AD_BANNER_PROVIDER | `slise` \| `adbutler` \| `coinzilla` \| `hype` \| `none` | Ads provider | - | `slise` | `coinzilla` |
| NEXT_PUBLIC_AD_BANNER_PROVIDER | `slise` \| `adbutler` \| `coinzilla` \| `hype` \| `getit` \| `none` | Ads provider | - | `slise` | `coinzilla` |
| NEXT_PUBLIC_AD_ADBUTLER_CONFIG_DESKTOP | `{ id: string; width: string; height: string }` | Placement config for desktop Adbutler banner | - | - | `{'id':'123456','width':'728','height':'90'}` |
| NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE | `{ id: string; width: number; height: number }` | Placement config for mobile Adbutler banner | - | - | `{'id':'654321','width':'300','height':'100'}` |

Expand Down
9 changes: 9 additions & 0 deletions icons/brands/solidity_scan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions icons/up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion lib/blob/guessDataType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import filetype from 'magic-bytes.js';

import hexToBytes from 'lib/hexToBytes';

import removeNonSignificantZeroBytes from './removeNonSignificantZeroBytes';

export default function guessDataType(data: string) {
const bytes = new Uint8Array(hexToBytes(data));
const filteredBytes = removeNonSignificantZeroBytes(bytes);

return filetype(bytes)[0];
return filetype(filteredBytes)[0];
}
20 changes: 20 additions & 0 deletions lib/blob/removeNonSignificantZeroBytes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default function removeNonSignificantZeroBytes(bytes: Uint8Array) {
return shouldRemoveBytes(bytes) ? bytes.filter((item, index) => index % 32) : bytes;
}

// check if every 0, 32, 64, etc byte is 0 in the provided array
function shouldRemoveBytes(bytes: Uint8Array) {
let result = true;

for (let index = 0; index < bytes.length; index += 32) {
const element = bytes[index];
if (element === 0) {
continue;
} else {
result = false;
break;
}
}

return result;
}
10 changes: 10 additions & 0 deletions lib/bytesToBase64.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function bytesToBase64(bytes: Uint8Array) {
let binary = '';
for (const byte of bytes) {
binary += String.fromCharCode(byte);
}

const base64String = btoa(binary);

return base64String;
}
10 changes: 2 additions & 8 deletions lib/hexToBase64.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import bytesToBase64 from './bytesToBase64';
import hexToBytes from './hexToBytes';

export default function hexToBase64(hex: string) {
const bytes = new Uint8Array(hexToBytes(hex));

let binary = '';
for (const byte of bytes) {
binary += String.fromCharCode(byte);
}

const base64String = btoa(binary);

return base64String;
return bytesToBase64(bytes);
}
2 changes: 1 addition & 1 deletion lib/token/metadata/attributesParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function formatValue(value: string | number, display: string | undefined, trait:
}
case 'date': {
return {
value: dayjs(value).format('YYYY-MM-DD'),
value: dayjs(Number(value) * 1000).format('YYYY-MM-DD'),
};
}
default: {
Expand Down
11 changes: 11 additions & 0 deletions mocks/address/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export const erc20LongSymbol: AddressTokenBalance = {
token_instance: null,
};

export const erc20BigAmount: AddressTokenBalance = {
token: {
...tokens.tokenInfoERC20LongSymbol,
exchange_rate: '4200000000',
name: 'DuckDuckGoose Stable Coin',
},
token_id: null,
value: '39000000000000000000',
token_instance: null,
};

export const erc721a: AddressTokenBalance = {
token: tokens.tokenInfoERC721a,
token_id: null,
Expand Down
12 changes: 11 additions & 1 deletion mocks/blobs/blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ export const base2: Blob = {
],
};

export const withoutData: Blob = {
blob_data: null,
hash: '0x0197fdb17195c176b23160f335daabd4b6a231aaaadd73ec567877c66a3affd3',
kzg_commitment: null,
kzg_proof: null,
transaction_hashes: [
{ block_consensus: true, transaction_hash: '0x22d597ebcf3e8d60096dd0363bc2f0f5e2df27ba1dacd696c51aa7c9409f3193' },
],
};

export const txBlobs: TxBlobs = {
items: [ base1, base2 ],
items: [ base1, base2, withoutData ],
next_page_params: null,
};
6 changes: 0 additions & 6 deletions mocks/tokens/tokenHolders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ import type { TokenHolders } from 'types/api/token';

import { withName, withoutName } from 'mocks/address/address';

import { tokenInfoERC1155a, tokenInfoERC20a } from './tokenInfo';

export const tokenHoldersERC20: TokenHolders = {
items: [
{
address: withName,
token: tokenInfoERC20a,
value: '107014805905725000000',
},
{
address: withoutName,
token: tokenInfoERC20a,
value: '207014805905725000000',
},
],
Expand All @@ -27,13 +23,11 @@ export const tokenHoldersERC1155: TokenHolders = {
items: [
{
address: withName,
token: tokenInfoERC1155a,
value: '107014805905725000000',
token_id: '12345',
},
{
address: withoutName,
token: tokenInfoERC1155a,
value: '207014805905725000000',
token_id: '12345',
},
Expand Down
7 changes: 7 additions & 0 deletions mocks/user/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ export const base = {
name: 'tom goriunov',
nickname: 'tom2drum',
};

export const withoutEmail = {
avatar: 'https://avatars.githubusercontent.com/u/22130104',
email: null,
name: 'tom goriunov',
nickname: 'tom2drum',
};
4 changes: 4 additions & 0 deletions nextjs/csp/policies/ad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export function ad(): CspDev.DirectiveDescriptor {
// hype
'api.hypelab.com',
'*.ixncdn.com',

//getit
'v1.getittech.io',
'ipapi.co',
],
'frame-src': [
// coinzilla
Expand Down
10 changes: 0 additions & 10 deletions nextjs/getServerSideProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,3 @@ export const gasTracker: GetServerSideProps<Props> = async(context) => {

return base(context);
};

export const blobs: GetServerSideProps<Props> = async(context) => {
if (config.UI.views.tx.hiddenViews?.blob_txs) {
return {
notFound: true,
};
}

return base(context);
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"dom-to-image": "^2.6.0",
"focus-visible": "^5.2.0",
"framer-motion": "^6.5.1",
"getit-sdk": "^1.0.4",
"gradient-avatar": "^1.0.2",
"graphiql": "^2.2.0",
"graphql": "^16.8.1",
Expand Down
2 changes: 1 addition & 1 deletion pages/blobs/[hash].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const Page: NextPage<Props> = (props: Props) => {

export default Page;

export { blobs as getServerSideProps } from 'nextjs/getServerSideProps';
export { base as getServerSideProps } from 'nextjs/getServerSideProps';
1 change: 1 addition & 0 deletions playwright/TestApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const WALLET_CONNECT_PROJECT_ID = 'PROJECT_ID';
const wagmiConfig = defaultWagmiConfig({
chains,
projectId: WALLET_CONNECT_PROJECT_ID,
enableEmail: true,
});

createWeb3Modal({
Expand Down
2 changes: 2 additions & 0 deletions public/icons/name.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| "block_slim"
| "block"
| "brands/safe"
| "brands/solidity_scan"
| "burger"
| "check"
| "clock-light"
Expand Down Expand Up @@ -134,6 +135,7 @@
| "txn_batches"
| "unfinalized"
| "uniswap"
| "up"
| "user_op_slim"
| "user_op"
| "validator"
Expand Down
2 changes: 0 additions & 2 deletions stubs/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export const TOKEN_COUNTERS: TokenCounters = {

export const TOKEN_HOLDER_ERC_20: TokenHolder = {
address: ADDRESS_PARAMS,
token: TOKEN_INFO_ERC_20,
value: '1021378038331138520',
};

export const TOKEN_HOLDER_ERC_1155: TokenHolder = {
address: ADDRESS_PARAMS,
token: TOKEN_INFO_ERC_1155,
token_id: '12345',
value: '1021378038331138520',
};
Expand Down
6 changes: 3 additions & 3 deletions types/api/blobs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export interface TxBlob {
hash: string;
blob_data: string;
kzg_commitment: string;
kzg_proof: string;
blob_data: string | null;
kzg_commitment: string | null;
kzg_proof: string | null;
}

export type TxBlobs = {
Expand Down
5 changes: 1 addition & 4 deletions types/api/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ export type TokenHolderBase = {
value: string;
}

export type TokenHolderERC20ERC721 = TokenHolderBase & {
token: TokenInfo<'ERC-20'> | TokenInfo<'ERC-721'>;
}
export type TokenHolderERC20ERC721 = TokenHolderBase

export type TokenHolderERC1155 = TokenHolderBase & {
token: TokenInfo<'ERC-1155'>;
token_id: string;
}

Expand Down
2 changes: 1 addition & 1 deletion types/client/adProviders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ArrayElement } from 'types/utils';

export const SUPPORTED_AD_BANNER_PROVIDERS = [ 'slise', 'adbutler', 'coinzilla', 'hype', 'none' ] as const;
export const SUPPORTED_AD_BANNER_PROVIDERS = [ 'slise', 'adbutler', 'coinzilla', 'hype', 'getit', 'none' ] as const;
export type AdBannerProviders = ArrayElement<typeof SUPPORTED_AD_BANNER_PROVIDERS>;

export const SUPPORTED_AD_TEXT_PROVIDERS = [ 'coinzilla', 'none' ] as const;
Expand Down
20 changes: 11 additions & 9 deletions ui/address/AddressDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
import getQueryParamString from 'lib/router/getQueryParamString';
import AddressCounterItem from 'ui/address/details/AddressCounterItem';
import ServiceDegradationWarning from 'ui/shared/alerts/ServiceDegradationWarning';
import isCustomAppError from 'ui/shared/AppError/isCustomAppError';
import DataFetchAlert from 'ui/shared/DataFetchAlert';
import DetailsInfoItem from 'ui/shared/DetailsInfoItem';
import DetailsSponsoredItem from 'ui/shared/DetailsSponsoredItem';
Expand Down Expand Up @@ -59,15 +60,16 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
has_validated_blocks: false,
}), [ addressHash ]);

const is404Error = addressQuery.isError && 'status' in addressQuery.error && addressQuery.error.status === 404;
const is422Error = addressQuery.isError && 'status' in addressQuery.error && addressQuery.error.status === 422;

if (addressQuery.isError && is422Error) {
throwOnResourceLoadError(addressQuery);
}

if (addressQuery.isError && !is404Error) {
return <DataFetchAlert/>;
// error handling (except 404 codes)
if (addressQuery.isError) {
if (isCustomAppError(addressQuery.error)) {
const is404Error = addressQuery.isError && 'status' in addressQuery.error && addressQuery.error.status === 404;
if (!is404Error) {
throwOnResourceLoadError(addressQuery);
}
} else {
return <DataFetchAlert/>;
}
}

const data = addressQuery.isError ? error404Data : addressQuery.data;
Expand Down
Loading

0 comments on commit d19d1f3

Please sign in to comment.