Skip to content

Commit c6ee0c8

Browse files
authored
Flashblocks for Base chains (#2919)
* flashblocks tab * add env variables * minor fixes * fix ts * change package for decompressing socket data * design updates * [skip ci] delete unused env * automatic mode switching for table * fix validator schema
1 parent ee81c2b commit c6ee0c8

33 files changed

+736
-68
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { Feature } from './types';
2+
3+
import { getEnvValue } from '../utils';
4+
5+
const title = 'Flashblocks';
6+
7+
const socketUrl = getEnvValue('NEXT_PUBLIC_FLASHBLOCKS_SOCKET_URL');
8+
9+
const config: Feature<{ socketUrl: string }> = (() => {
10+
11+
if (socketUrl) {
12+
return Object.freeze({
13+
title,
14+
isEnabled: true,
15+
socketUrl,
16+
});
17+
}
18+
19+
return Object.freeze({
20+
title,
21+
isEnabled: false,
22+
});
23+
})();
24+
25+
export default config;

configs/app/features/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export { default as easterEggBadge } from './easterEggBadge';
1717
export { default as easterEggPuzzleBadge } from './easterEggPuzzleBadge';
1818
export { default as externalTxs } from './externalTxs';
1919
export { default as faultProofSystem } from './faultProofSystem';
20+
export { default as flashblocks } from './flashblocks';
2021
export { default as gasTracker } from './gasTracker';
2122
export { default as getGasButton } from './getGasButton';
2223
export { default as googleAnalytics } from './googleAnalytics';

configs/envs/.env.base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ NEXT_PUBLIC_APP_PORT=3000
99
NEXT_PUBLIC_APP_ENV=development
1010
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
1111

12+
NEXT_PUBLIC_FLASHBLOCKS_SOCKET_URL=wss://mainnet.flashblocks.base.org/ws
13+
NEXT_PUBLIC_IS_TESTNET=false
14+
1215
# Instance ENVs
1316
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com
1417
NEXT_PUBLIC_API_BASE_PATH=/

decs.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
declare module 'react-identicons';
22
declare module 'use-font-face-observer';
3+
declare module 'brotli-compress/js';

deploy/tools/envs-validator/schema.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,12 @@ const address3rdPartyWidgetsConfigSchema = yup
705705
}),
706706
});
707707

708+
const flashblocksSchema = yup
709+
.object()
710+
.shape({
711+
NEXT_PUBLIC_FLASHBLOCKS_SOCKET_URL: yup.string().test(urlTest),
712+
});
713+
708714
const schema = yup
709715
.object()
710716
.noUnknown(true, (params) => {
@@ -1141,6 +1147,7 @@ const schema = yup
11411147
.concat(tacSchema)
11421148
.concat(address3rdPartyWidgetsConfigSchema)
11431149
.concat(addressMetadataSchema)
1144-
.concat(userOpsSchema);
1150+
.concat(userOpsSchema)
1151+
.concat(flashblocksSchema);
11451152

11461153
export default schema;

deploy/tools/envs-validator/test/.env.base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ NEXT_PUBLIC_REWARDS_SERVICE_API_HOST=https://example.com
9393
NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS=['widget-1', 'widget-2']
9494
NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS_CONFIG_URL=https://example.com
9595
NEXT_PUBLIC_NAVIGATION_PROMO_BANNER_CONFIG={'img_url': 'https://example.com/promo.svg', 'text': 'Promo text', 'bg_color': {'light': 'rgb(250, 245, 255)', 'dark': 'rgb(68, 51, 122)'}, 'text_color': {'light': 'rgb(107, 70, 193)', 'dark': 'rgb(233, 216, 253)'}, 'link_url': 'https://example.com'}
96+
NEXT_PUBLIC_FLASHBLOCKS_SOCKET_URL=wss://example.com/ws

docs/ENVS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ All json-like values should be single-quoted. If it contains a hash (`#`) or a d
7777
- [Save on gas with GasHawk](#save-on-gas-with-gashawk)
7878
- [Rewards service API](#rewards-service-api)
7979
- [DEX pools](#dex-pools)
80+
- [Flashblocks](#flashblocks)
8081
- [Address 3rd party widgets](#address-3rd-party-widgets)
8182
- [3rd party services configuration](#external-services-configuration)
8283

@@ -934,6 +935,16 @@ This feature enables Blockscout Merits program. It requires that the [My account
934935

935936
&nbsp;
936937

938+
### Flashblocks
939+
940+
This feature allows users to view [Flashblocks](https://docs.base.org/base-chain/flashblocks/apps)-related content in the explorer, including the Flashblocks real-time feed. It currently supports only Base chains.
941+
942+
| Variable | Type| Description | Compulsoriness | Default value | Example value | Version |
943+
| --- | --- | --- | --- | --- | --- | --- |
944+
| NEXT_PUBLIC_FLASHBLOCKS_SOCKET_URL | `string` | Public WebSocket endpoint to stream Flashblocks data | Required | - | `wss://mainnet.flashblocks.base.org/ws` | v2.3.0+ |
945+
946+
&nbsp;
947+
937948
### Address 3rd party widgets
938949

939950
This feature allows to display widgets on the address page with data from 3rd party services.

icons/flashblock.svg

Lines changed: 3 additions & 0 deletions
Loading

nextjs/csp/generateCspPolicy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function generateCspPolicy() {
66
descriptors.app(),
77
descriptors.ad(),
88
descriptors.cloudFlare(),
9+
descriptors.flashblocks(),
910
descriptors.gasHawk(),
1011
descriptors.googleAnalytics(),
1112
descriptors.googleFonts(),
@@ -17,6 +18,7 @@ function generateCspPolicy() {
1718
descriptors.monaco(),
1819
descriptors.multichain(),
1920
descriptors.rollbar(),
21+
descriptors.rollup(),
2022
descriptors.safe(),
2123
descriptors.usernameApi(),
2224
descriptors.walletConnect(),

nextjs/csp/policies/app.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type CspDev from 'csp-dev';
22

3-
import { getFeaturePayload } from 'configs/app/features/types';
4-
53
import config from 'configs/app';
64

75
import { KEY_WORDS } from '../utils';
@@ -45,7 +43,6 @@ export function app(): CspDev.DirectiveDescriptor {
4543

4644
// chain RPC server
4745
...config.chain.rpcUrls,
48-
...(getFeaturePayload(config.features.rollup)?.parentChain?.rpcUrls ?? []),
4946
'https://infragrid.v.network', // RPC providers
5047

5148
// github (spec for api-docs page)

0 commit comments

Comments
 (0)