Files
explore/ui/apiDocs/utils.ts
T
tom goriunovandGitHub d02afe37b8 Add cross-chain transaction tracking and visualization (#3227)
* envs and feature setup

* home page layout

* cross-chain txs page

* cross-chain transfers page

* cross-chain transfers on tx page

* cross-chain messages on tx page

* cross-chain tx page

* cross-chain tx details token transfers

* stats and counters for lists

* migrate to new API version

* add swagger

* mobile lists

* placeholder views on address page

* tests

* fix adaptive tabs initial state when there is only one tab in the list

* tweaks

* bug fixes

* fix tests

* update screenshots

* migrate to new api version

* add chain label tooltip, copy button to txs in lists and same address highlight

* list views on address page

* fix tests

* fix links to current address in the list views

* update tooltips

* update tables layout

* review fixes

* fix spelling

* update screenshots

* update screenshot
2026-02-19 15:14:32 +01:00

103 lines
3.1 KiB
TypeScript

import type { SwaggerRequest } from './types';
import config from 'configs/app';
import type { ApiPropsBase } from 'configs/app/apis';
const feature = config.features.apiDocs;
const microserviceRequestInterceptorFactory = (api: ApiPropsBase) => (req: SwaggerRequest) => {
try {
const url = new URL(req.url);
if (api?.basePath && !url.pathname.includes(api.basePath)) {
url.pathname = (api?.basePath ?? '') + url.pathname;
}
req.url = url.toString();
} catch (error) {}
return req;
};
const getMicroserviceSwaggerUrl = (api: ApiPropsBase) => `${ api.endpoint }${ api.basePath ?? '' }/api/v1/docs/swagger.yaml`;
export const REST_API_SECTIONS = [
feature.isEnabled && {
id: 'blockscout-core-api',
title: 'Blockscout core API',
swagger: {
url: feature.coreApiSwaggerUrl,
requestInterceptor: (req: SwaggerRequest) => {
if (!config.apis.general) {
return req;
}
const DEFAULT_SERVER = 'blockscout.com/poa/core';
const DEFAULT_SERVER_NEW = 'eth.blockscout.com';
if (!req.loadSpec) {
const newUrl = new URL(
req.url.includes(DEFAULT_SERVER) ?
req.url.replace(DEFAULT_SERVER, config.apis.general.host) :
req.url.replace(DEFAULT_SERVER_NEW, config.apis.general.host),
);
newUrl.protocol = config.apis.general.protocol + ':';
if (config.apis.general.port) {
newUrl.port = config.apis.general.port;
}
req.url = newUrl.toString();
}
return req;
},
},
},
config.apis.stats && {
id: 'stats-api',
title: 'Stats API',
swagger: {
url: getMicroserviceSwaggerUrl(config.apis.stats),
requestInterceptor: microserviceRequestInterceptorFactory(config.apis.stats),
},
},
config.apis.bens && {
id: 'bens-api',
title: 'Name service API',
swagger: {
url: getMicroserviceSwaggerUrl(config.apis.bens),
requestInterceptor: microserviceRequestInterceptorFactory(config.apis.bens),
},
},
config.apis.userOps && {
id: 'user-ops-api',
title: 'User ops indexer API',
swagger: {
url: getMicroserviceSwaggerUrl(config.apis.userOps),
requestInterceptor: microserviceRequestInterceptorFactory(config.apis.userOps),
},
},
config.apis.tac && {
id: 'tac-api',
title: 'TAC operation lifecycle API',
swagger: {
url: getMicroserviceSwaggerUrl(config.apis.tac),
requestInterceptor: microserviceRequestInterceptorFactory(config.apis.tac),
},
},
config.apis.zetachain && {
id: 'zetachain-api',
title: 'Zetachain CCTX API',
swagger: {
url: getMicroserviceSwaggerUrl(config.apis.zetachain),
requestInterceptor: microserviceRequestInterceptorFactory(config.apis.zetachain),
},
},
config.apis.interchainIndexer && {
id: 'interchain-indexer-api',
title: 'Interchain indexer API',
swagger: {
url: getMicroserviceSwaggerUrl(config.apis.interchainIndexer),
requestInterceptor: microserviceRequestInterceptorFactory(config.apis.interchainIndexer),
},
},
].filter(Boolean);