Skip to content

Commit 540d95e

Browse files
authored
Internal transactions list page (#2553)
* Internal transactions list page Fixes #2526 * update nav icon for internal txns route * fix ts error * fix external txs test
1 parent bb77f8f commit 540d95e

27 files changed

+209
-78
lines changed

icons/internal_txns.svg

+11
Loading

lib/api/resources.ts

+64-53
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ export const RESOURCES = {
544544
withdrawals_counters: {
545545
path: '/api/v2/withdrawals/counters',
546546
},
547+
internal_txs: {
548+
path: '/api/v2/internal-transactions',
549+
},
547550

548551
// ADDRESSES
549552
addresses: {
@@ -1273,7 +1276,7 @@ export interface ResourceError<T = unknown> {
12731276
export type ResourceErrorAccount<T> = ResourceError<{ errors: T }>;
12741277

12751278
export type PaginatedResources = 'blocks' | 'block_txs' | 'block_election_rewards' |
1276-
'txs_validated' | 'txs_pending' | 'txs_with_blobs' | 'txs_watchlist' | 'txs_execution_node' |
1279+
'txs_validated' | 'txs_pending' | 'txs_with_blobs' | 'txs_watchlist' | 'txs_execution_node' | 'internal_txs' |
12771280
'tx_internal_txs' | 'tx_logs' | 'tx_token_transfers' | 'tx_state_changes' | 'tx_blobs' |
12781281
'addresses' | 'addresses_metadata_search' |
12791282
'address_txs' | 'address_internal_txs' | 'address_token_transfers' | 'address_blocks_validated' | 'address_coin_balance' |
@@ -1342,6 +1345,7 @@ Q extends 'txs_pending' ? TransactionsResponsePending :
13421345
Q extends 'txs_with_blobs' ? TransactionsResponseWithBlobs :
13431346
Q extends 'txs_watchlist' ? TransactionsResponseWatchlist :
13441347
Q extends 'txs_execution_node' ? TransactionsResponseValidated :
1348+
Q extends 'internal_txs' ? InternalTransactionsResponse :
13451349
Q extends 'tx' ? Transaction :
13461350
Q extends 'tx_internal_txs' ? InternalTransactionsResponse :
13471351
Q extends 'tx_logs' ? LogsResponseTx :
@@ -1388,20 +1392,6 @@ Q extends 'verified_contracts' ? VerifiedContractsResponse :
13881392
Q extends 'verified_contracts_counters' ? VerifiedContractsCounters :
13891393
Q extends 'visualize_sol2uml' ? visualizer.VisualizeResponse :
13901394
Q extends 'contract_verification_config' ? SmartContractVerificationConfigRaw :
1391-
Q extends 'optimistic_l2_output_roots' ? OptimisticL2OutputRootsResponse :
1392-
Q extends 'optimistic_l2_withdrawals' ? OptimisticL2WithdrawalsResponse :
1393-
Q extends 'optimistic_l2_deposits' ? OptimisticL2DepositsResponse :
1394-
Q extends 'optimistic_l2_txn_batches' ? OptimisticL2TxnBatchesResponse :
1395-
Q extends 'optimistic_l2_txn_batches_count' ? number :
1396-
Q extends 'optimistic_l2_txn_batch' ? OptimismL2TxnBatch :
1397-
Q extends 'optimistic_l2_txn_batch_celestia' ? OptimismL2TxnBatch :
1398-
Q extends 'optimistic_l2_txn_batch_txs' ? OptimismL2BatchTxs :
1399-
Q extends 'optimistic_l2_txn_batch_blocks' ? OptimismL2BatchBlocks :
1400-
Q extends 'optimistic_l2_dispute_games' ? OptimisticL2DisputeGamesResponse :
1401-
Q extends 'optimistic_l2_output_roots_count' ? number :
1402-
Q extends 'optimistic_l2_withdrawals_count' ? number :
1403-
Q extends 'optimistic_l2_deposits_count' ? number :
1404-
Q extends 'optimistic_l2_dispute_games_count' ? number :
14051395
never;
14061396
// !!! IMPORTANT !!!
14071397
// See comment above
@@ -1422,34 +1412,6 @@ Q extends 'validators_blackfort' ? ValidatorsBlackfortResponse :
14221412
Q extends 'validators_blackfort_counters' ? ValidatorsBlackfortCountersResponse :
14231413
Q extends 'validators_zilliqa' ? ValidatorsZilliqaResponse :
14241414
Q extends 'validator_zilliqa' ? ValidatorZilliqa :
1425-
Q extends 'shibarium_withdrawals' ? ShibariumWithdrawalsResponse :
1426-
Q extends 'shibarium_deposits' ? ShibariumDepositsResponse :
1427-
Q extends 'shibarium_withdrawals_count' ? number :
1428-
Q extends 'shibarium_deposits_count' ? number :
1429-
Q extends 'arbitrum_l2_messages' ? ArbitrumL2MessagesResponse :
1430-
Q extends 'arbitrum_l2_messages_count' ? number :
1431-
Q extends 'arbitrum_l2_txn_batches' ? ArbitrumL2TxnBatchesResponse :
1432-
Q extends 'arbitrum_l2_txn_batches_count' ? number :
1433-
Q extends 'arbitrum_l2_txn_batch' ? ArbitrumL2TxnBatch :
1434-
Q extends 'arbitrum_l2_txn_batch_celestia' ? ArbitrumL2TxnBatch :
1435-
Q extends 'arbitrum_l2_txn_batch_txs' ? ArbitrumL2BatchTxs :
1436-
Q extends 'arbitrum_l2_txn_batch_blocks' ? ArbitrumL2BatchBlocks :
1437-
Q extends 'arbitrum_l2_txn_withdrawals' ? ArbitrumL2TxnWithdrawalsResponse :
1438-
Q extends 'arbitrum_l2_message_claim' ? ArbitrumL2MessageClaimResponse :
1439-
Q extends 'zkevm_l2_deposits' ? ZkEvmL2DepositsResponse :
1440-
Q extends 'zkevm_l2_deposits_count' ? number :
1441-
Q extends 'zkevm_l2_withdrawals' ? ZkEvmL2WithdrawalsResponse :
1442-
Q extends 'zkevm_l2_withdrawals_count' ? number :
1443-
Q extends 'zkevm_l2_txn_batches' ? ZkEvmL2TxnBatchesResponse :
1444-
Q extends 'zkevm_l2_txn_batches_count' ? number :
1445-
Q extends 'zkevm_l2_txn_batch' ? ZkEvmL2TxnBatch :
1446-
Q extends 'zkevm_l2_txn_batch_txs' ? ZkEvmL2TxnBatchTxs :
1447-
Q extends 'zksync_l2_txn_batches' ? ZkSyncBatchesResponse :
1448-
Q extends 'zksync_l2_txn_batches_count' ? number :
1449-
Q extends 'zksync_l2_txn_batch' ? ZkSyncBatch :
1450-
Q extends 'zksync_l2_txn_batch_txs' ? ZkSyncBatchTxs :
1451-
Q extends 'scroll_l2_txn_batch_txs' ? ScrollL2TxnBatchTxs :
1452-
Q extends 'scroll_l2_txn_batch_blocks' ? ScrollL2TxnBatchBlocks :
14531415
Q extends 'contract_security_audits' ? SmartContractSecurityAudits :
14541416
Q extends 'addresses_lookup' ? bens.LookupAddressResponse :
14551417
Q extends 'address_domain' ? bens.GetAddressResponse :
@@ -1485,13 +1447,6 @@ Q extends 'rewards_user_daily_claim' ? RewardsUserDailyClaimResponse :
14851447
Q extends 'rewards_user_referrals' ? RewardsUserReferralsResponse :
14861448
Q extends 'token_transfers_all' ? TokenTransferResponse :
14871449
Q extends 'address_xstar_score' ? AddressXStarResponse :
1488-
Q extends 'scroll_l2_txn_batches' ? ScrollL2BatchesResponse :
1489-
Q extends 'scroll_l2_txn_batches_count' ? number :
1490-
Q extends 'scroll_l2_txn_batch' ? ScrollL2TxnBatch :
1491-
Q extends 'scroll_l2_deposits' ? ScrollL2MessagesResponse :
1492-
Q extends 'scroll_l2_deposits_count' ? number :
1493-
Q extends 'scroll_l2_withdrawals' ? ScrollL2MessagesResponse :
1494-
Q extends 'scroll_l2_withdrawals_count' ? number :
14951450
Q extends 'advanced_filter' ? AdvancedFilterResponse :
14961451
Q extends 'advanced_filter_methods' ? AdvancedFilterMethodsResponse :
14971452
Q extends 'pools' ? PoolsResponse :
@@ -1502,10 +1457,66 @@ Q extends 'stats_contracts' ? stats.ContractsPageStats :
15021457
never;
15031458
/* eslint-enable @stylistic/indent */
15041459

1505-
export type ResourcePayload<Q extends ResourceName> = ResourcePayloadA<Q> | ResourcePayloadB<Q>;
1506-
export type PaginatedResponseItems<Q extends ResourceName> = Q extends PaginatedResources ? ResourcePayloadA<Q>['items'] | ResourcePayloadB<Q>['items'] : never;
1460+
/* eslint-disable @stylistic/indent */
1461+
export type ResourcePayloadRollups<Q extends ResourceName> =
1462+
Q extends 'optimistic_l2_output_roots' ? OptimisticL2OutputRootsResponse :
1463+
Q extends 'optimistic_l2_withdrawals' ? OptimisticL2WithdrawalsResponse :
1464+
Q extends 'optimistic_l2_deposits' ? OptimisticL2DepositsResponse :
1465+
Q extends 'optimistic_l2_txn_batches' ? OptimisticL2TxnBatchesResponse :
1466+
Q extends 'optimistic_l2_txn_batches_count' ? number :
1467+
Q extends 'optimistic_l2_txn_batch' ? OptimismL2TxnBatch :
1468+
Q extends 'optimistic_l2_txn_batch_celestia' ? OptimismL2TxnBatch :
1469+
Q extends 'optimistic_l2_txn_batch_txs' ? OptimismL2BatchTxs :
1470+
Q extends 'optimistic_l2_txn_batch_blocks' ? OptimismL2BatchBlocks :
1471+
Q extends 'optimistic_l2_dispute_games' ? OptimisticL2DisputeGamesResponse :
1472+
Q extends 'optimistic_l2_output_roots_count' ? number :
1473+
Q extends 'optimistic_l2_withdrawals_count' ? number :
1474+
Q extends 'optimistic_l2_deposits_count' ? number :
1475+
Q extends 'optimistic_l2_dispute_games_count' ? number :
1476+
Q extends 'shibarium_withdrawals' ? ShibariumWithdrawalsResponse :
1477+
Q extends 'shibarium_deposits' ? ShibariumDepositsResponse :
1478+
Q extends 'shibarium_withdrawals_count' ? number :
1479+
Q extends 'shibarium_deposits_count' ? number :
1480+
Q extends 'arbitrum_l2_messages' ? ArbitrumL2MessagesResponse :
1481+
Q extends 'arbitrum_l2_messages_count' ? number :
1482+
Q extends 'arbitrum_l2_txn_batches' ? ArbitrumL2TxnBatchesResponse :
1483+
Q extends 'arbitrum_l2_txn_batches_count' ? number :
1484+
Q extends 'arbitrum_l2_txn_batch' ? ArbitrumL2TxnBatch :
1485+
Q extends 'arbitrum_l2_txn_batch_celestia' ? ArbitrumL2TxnBatch :
1486+
Q extends 'arbitrum_l2_txn_batch_txs' ? ArbitrumL2BatchTxs :
1487+
Q extends 'arbitrum_l2_txn_batch_blocks' ? ArbitrumL2BatchBlocks :
1488+
Q extends 'arbitrum_l2_txn_withdrawals' ? ArbitrumL2TxnWithdrawalsResponse :
1489+
Q extends 'arbitrum_l2_message_claim' ? ArbitrumL2MessageClaimResponse :
1490+
Q extends 'zkevm_l2_deposits' ? ZkEvmL2DepositsResponse :
1491+
Q extends 'zkevm_l2_deposits_count' ? number :
1492+
Q extends 'zkevm_l2_withdrawals' ? ZkEvmL2WithdrawalsResponse :
1493+
Q extends 'zkevm_l2_withdrawals_count' ? number :
1494+
Q extends 'zkevm_l2_txn_batches' ? ZkEvmL2TxnBatchesResponse :
1495+
Q extends 'zkevm_l2_txn_batches_count' ? number :
1496+
Q extends 'zkevm_l2_txn_batch' ? ZkEvmL2TxnBatch :
1497+
Q extends 'zkevm_l2_txn_batch_txs' ? ZkEvmL2TxnBatchTxs :
1498+
Q extends 'zksync_l2_txn_batches' ? ZkSyncBatchesResponse :
1499+
Q extends 'zksync_l2_txn_batches_count' ? number :
1500+
Q extends 'zksync_l2_txn_batch' ? ZkSyncBatch :
1501+
Q extends 'zksync_l2_txn_batch_txs' ? ZkSyncBatchTxs :
1502+
Q extends 'scroll_l2_txn_batch_txs' ? ScrollL2TxnBatchTxs :
1503+
Q extends 'scroll_l2_txn_batch_blocks' ? ScrollL2TxnBatchBlocks :
1504+
Q extends 'scroll_l2_txn_batches' ? ScrollL2BatchesResponse :
1505+
Q extends 'scroll_l2_txn_batches_count' ? number :
1506+
Q extends 'scroll_l2_txn_batch' ? ScrollL2TxnBatch :
1507+
Q extends 'scroll_l2_deposits' ? ScrollL2MessagesResponse :
1508+
Q extends 'scroll_l2_deposits_count' ? number :
1509+
Q extends 'scroll_l2_withdrawals' ? ScrollL2MessagesResponse :
1510+
Q extends 'scroll_l2_withdrawals_count' ? number :
1511+
never;
1512+
/* eslint-enable @stylistic/indent */
1513+
1514+
export type ResourcePayload<Q extends ResourceName> = ResourcePayloadA<Q> | ResourcePayloadB<Q> | ResourcePayloadRollups<Q>;
1515+
export type PaginatedResponseItems<Q extends ResourceName> = Q extends PaginatedResources ?
1516+
ResourcePayloadA<Q>['items'] | ResourcePayloadB<Q>['items'] | ResourcePayloadRollups<Q>['items'] :
1517+
never;
15071518
export type PaginatedResponseNextPageParams<Q extends ResourceName> = Q extends PaginatedResources ?
1508-
ResourcePayloadA<Q>['next_page_params'] | ResourcePayloadB<Q>['next_page_params'] :
1519+
ResourcePayloadA<Q>['next_page_params'] | ResourcePayloadB<Q>['next_page_params'] | ResourcePayloadRollups<Q>['next_page_params'] :
15091520
never;
15101521

15111522
/* eslint-disable @stylistic/indent */

lib/hooks/useNavItems.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export default function useNavItems(): ReturnType {
4444
icon: 'transactions',
4545
isActive: pathname === '/txs' || pathname === '/tx/[hash]',
4646
};
47+
const internalTxs: NavItem | null = {
48+
text: 'Internal transactions',
49+
nextRoute: { pathname: '/internal-txs' as const },
50+
icon: 'internal_txns',
51+
isActive: pathname === '/internal-txs',
52+
};
4753
const userOps: NavItem | null = config.features.userOps.isEnabled ? {
4854
text: 'User operations',
4955
nextRoute: { pathname: '/ops' as const },
@@ -118,6 +124,7 @@ export default function useNavItems(): ReturnType {
118124
blockchainNavItems = [
119125
[
120126
txs,
127+
internalTxs,
121128
rollupDeposits,
122129
rollupWithdrawals,
123130
],
@@ -140,6 +147,7 @@ export default function useNavItems(): ReturnType {
140147
blockchainNavItems = [
141148
[
142149
txs,
150+
internalTxs,
143151
rollupDeposits,
144152
rollupWithdrawals,
145153
],
@@ -155,6 +163,7 @@ export default function useNavItems(): ReturnType {
155163
blockchainNavItems = [
156164
[
157165
txs,
166+
internalTxs,
158167
userOps,
159168
blocks,
160169
rollupTxnBatches,
@@ -169,6 +178,7 @@ export default function useNavItems(): ReturnType {
169178
} else {
170179
blockchainNavItems = [
171180
txs,
181+
internalTxs,
172182
userOps,
173183
blocks,
174184
topAccounts,

lib/metadata/getPageOgType.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type OGPageType = 'Homepage' | 'Root page' | 'Regular page';
55
const OG_TYPE_DICT: Record<Route['pathname'], OGPageType> = {
66
'/': 'Homepage',
77
'/txs': 'Root page',
8+
'/internal-txs': 'Root page',
89
'/txs/kettle/[hash]': 'Regular page',
910
'/tx/[hash]': 'Regular page',
1011
'/blocks': 'Root page',

lib/metadata/templates/description.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const DEFAULT_TEMPLATE = 'Open-source block explorer by Blockscout. Search trans
88
const TEMPLATE_MAP: Record<Route['pathname'], string> = {
99
'/': DEFAULT_TEMPLATE,
1010
'/txs': DEFAULT_TEMPLATE,
11+
'/internal-txs': DEFAULT_TEMPLATE,
1112
'/txs/kettle/[hash]': DEFAULT_TEMPLATE,
1213
'/tx/[hash]': 'View transaction %hash% on %network_title%',
1314
'/blocks': DEFAULT_TEMPLATE,

lib/metadata/templates/title.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import config from 'configs/app';
55
const TEMPLATE_MAP: Record<Route['pathname'], string> = {
66
'/': '%network_name% blockchain explorer - View %network_name% stats',
77
'/txs': '%network_name% transactions - %network_name% explorer',
8+
'/internal-txs': '%network_name% internal transactions - %network_name% explorer',
89
'/txs/kettle/[hash]': '%network_name% kettle %hash% transactions',
910
'/tx/[hash]': '%network_name% transaction %hash%',
1011
'/blocks': '%network_name% blocks',

lib/mixpanel/getPageType.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Route } from 'nextjs-routes';
33
export const PAGE_TYPE_DICT: Record<Route['pathname'], string> = {
44
'/': 'Homepage',
55
'/txs': 'Transactions',
6+
'/internal-txs': 'Internal transactions',
67
'/txs/kettle/[hash]': 'Kettle transactions',
78
'/tx/[hash]': 'Transaction details',
89
'/blocks': 'Blocks',

nextjs/nextjs-routes.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ declare module "nextjs-routes" {
4646
| StaticRoute<"/gas-tracker">
4747
| StaticRoute<"/graphiql">
4848
| StaticRoute<"/">
49+
| StaticRoute<"/internal-txs">
4950
| StaticRoute<"/login">
5051
| StaticRoute<"/mud-worlds">
5152
| DynamicRoute<"/name-domains/[name]", { "name": string }>

pages/internal-txs.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { NextPage } from 'next';
2+
import dynamic from 'next/dynamic';
3+
import React from 'react';
4+
5+
import PageNextJs from 'nextjs/PageNextJs';
6+
7+
const InternalTxs = dynamic(() => import('ui/pages/InternalTxs'), { ssr: false });
8+
9+
const Page: NextPage = () => {
10+
return (
11+
<PageNextJs pathname="/internal-txs">
12+
<InternalTxs/>
13+
</PageNextJs>
14+
);
15+
};
16+
17+
export default Page;
18+
19+
export { base as getServerSideProps } from 'nextjs/getServerSideProps';

public/icons/name.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
| "info"
8484
| "integration/full"
8585
| "integration/partial"
86+
| "internal_txns"
8687
| "key"
8788
| "lightning_navbar"
8889
| "lightning"

ui/address/AddressInternalTxs.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import { apos } from 'lib/html-entities';
1111
import getQueryParamString from 'lib/router/getQueryParamString';
1212
import { INTERNAL_TX } from 'stubs/internalTx';
1313
import { generateListStub } from 'stubs/utils';
14-
import AddressIntTxsTable from 'ui/address/internals/AddressIntTxsTable';
14+
import InternalTxsList from 'ui/internalTxs/InternalTxsList';
15+
import InternalTxsTable from 'ui/internalTxs/InternalTxsTable';
1516
import ActionBar from 'ui/shared/ActionBar';
1617
import DataListDisplay from 'ui/shared/DataListDisplay';
1718
import Pagination from 'ui/shared/pagination/Pagination';
1819
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
1920

2021
import AddressCsvExportLink from './AddressCsvExportLink';
2122
import AddressTxsFilter from './AddressTxsFilter';
22-
import AddressIntTxsList from './internals/AddressIntTxsList';
2323

2424
const getFilterValue = (getFilterValueFromQuery<AddressFromToFilter>).bind(null, AddressFromToFilterValues);
2525

@@ -71,10 +71,10 @@ const AddressInternalTxs = ({ scrollRef, shouldRender = true, isQueryEnabled = t
7171
const content = data?.items ? (
7272
<>
7373
<Show below="lg" ssr={ false }>
74-
<AddressIntTxsList data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/>
74+
<InternalTxsList data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/>
7575
</Show>
7676
<Hide below="lg" ssr={ false }>
77-
<AddressIntTxsTable data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/>
77+
<InternalTxsTable data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/>
7878
</Hide>
7979
</>
8080
) : null ;

ui/address/internals/AddressIntTxsList.tsx ui/internalTxs/InternalTxsList.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import React from 'react';
33

44
import type { InternalTransaction } from 'types/api/internalTransaction';
55

6-
import AddressIntTxsListItem from 'ui/address/internals/AddressIntTxsListItem';
6+
import InternalTxsListItem from './InternalTxsListItem';
77

88
type Props = {
99
data: Array<InternalTransaction>;
10-
currentAddress: string;
10+
currentAddress?: string;
1111
isLoading?: boolean;
1212
};
1313

14-
const AddressIntTxsList = ({ data, currentAddress, isLoading }: Props) => {
14+
const InternalTxsList = ({ data, currentAddress, isLoading }: Props) => {
1515
return (
1616
<Box>
1717
{ data.map((item, index) => (
18-
<AddressIntTxsListItem
18+
<InternalTxsListItem
1919
key={ item.transaction_hash + '_' + index }
2020
{ ...item }
2121
currentAddress={ currentAddress }
@@ -26,4 +26,4 @@ const AddressIntTxsList = ({ data, currentAddress, isLoading }: Props) => {
2626
);
2727
};
2828

29-
export default AddressIntTxsList;
29+
export default InternalTxsList;

0 commit comments

Comments
 (0)