Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrum views #2024

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
type: choice
options:
- none
- arbitrum
- base
- gnosis
- eth
Expand Down
39 changes: 39 additions & 0 deletions configs/envs/.env.arbitrum
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Set of ENVs for Optimism (dev only)
# https://optimism.blockscout.com/

# app configuration
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000

# blockchain parameters
NEXT_PUBLIC_NETWORK_NAME=Arbitrum One Nitro
NEXT_PUBLIC_NETWORK_SHORT_NAME=Arbitrum One Nitro
NEXT_PUBLIC_NETWORK_ID=42161
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18

# api configuration
NEXT_PUBLIC_API_HOST=arbitrum.blockscout.com
NEXT_PUBLIC_API_BASE_PATH=/

# ui config
## homepage
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
## views
NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.ethereum.org/?address={hash}&blockscout={domain}','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}]
# app features
NEXT_PUBLIC_APP_INSTANCE=local
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0xf7d4972356e6ae44ae948d0cf19ef2beaf0e574c180997e969a2837da15e349d
NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true
NEXT_PUBLIC_AUTH_URL=http://localhost:3000/login
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
NEXT_PUBLIC_LOGOUT_URL=https://blockscoutcom.us.auth0.com/v2/logout
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER=blockscout
# rollup
NEXT_PUBLIC_ROLLUP_TYPE=arbitrum
NEXT_PUBLIC_ROLLUP_L1_BASE_URL=https://eth.blockscout.com
NEXT_PUBLIC_AD_BANNER_PROVIDER=hype
2 changes: 1 addition & 1 deletion docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ This feature is **enabled by default** with the `coinzilla` ads provider. To swi

| Variable | Type| Description | Compulsoriness | Default value | Example value | Version |
| --- | --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_ROLLUP_TYPE | `'optimistic' \| 'shibarium' \| 'zkEvm' \| 'zkSync' ` | Rollup chain type | Required | - | `'optimistic'` | v1.24.0+ |
| NEXT_PUBLIC_ROLLUP_TYPE | `'optimistic' \| 'arbitrum' \| 'shibarium' \| 'zkEvm' \| 'zkSync' ` | Rollup chain type | Required | - | `'optimistic'` | v1.24.0+ |
| NEXT_PUBLIC_ROLLUP_L1_BASE_URL | `string` | Blockscout base URL for L1 network | Required | - | `'http://eth-goerli.blockscout.com'` | v1.24.0+ |
| NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL | `string` | URL for L2 -> L1 withdrawals | Required only for `optimistic` rollups | - | `https://app.optimism.io/bridge/withdraw` | v1.24.0+ |
| NEXT_PUBLIC_FAULT_PROOF_ENABLED | `boolean` | Set to `true` for chains with fault proof system enabled (OP stack only) | - | - | `true` | v1.31.0+ |
Expand Down
53 changes: 53 additions & 0 deletions lib/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ import type {
} from 'types/api/address';
import type { AddressesResponse } from 'types/api/addresses';
import type { AddressMetadataInfo, PublicTagTypesResponse } from 'types/api/addressMetadata';
import type {
ArbitrumL2MessagesResponse,
ArbitrumL2TxnBatch,
ArbitrumL2TxnBatchesResponse,
ArbitrumL2BatchTxs,
ArbitrumL2BatchBlocks,
} from 'types/api/arbitrumL2';
import type { TxBlobs, Blob } from 'types/api/blobs';
import type { BlocksResponse, BlockTransactionsResponse, Block, BlockFilters, BlockWithdrawalsResponse } from 'types/api/block';
import type { ChartMarketResponse, ChartSecondaryCoinPriceResponse, ChartTransactionResponse } from 'types/api/charts';
Expand Down Expand Up @@ -660,6 +667,44 @@ export const RESOURCES = {
path: '/api/v2/optimism/games/count',
},

// arbitrum L2
arbitrum_l2_messages: {
path: '/api/v2/arbitrum/messages/:direction',
pathParams: [ 'direction' as const ],
filterFields: [],
},

arbitrum_l2_messages_count: {
path: '/api/v2/arbitrum/messages/:direction/count',
pathParams: [ 'direction' as const ],
},

arbitrum_l2_txn_batches: {
path: '/api/v2/arbitrum/batches',
filterFields: [],
},

arbitrum_l2_txn_batches_count: {
path: '/api/v2/arbitrum/batches/count',
},

arbitrum_l2_txn_batch: {
path: '/api/v2/arbitrum/batches/:number',
pathParams: [ 'number' as const ],
},

arbitrum_l2_txn_batch_txs: {
path: '/api/v2/transactions/arbitrum-batch/:number',
pathParams: [ 'number' as const ],
filterFields: [],
},

arbitrum_l2_txn_batch_blocks: {
path: '/api/v2/blocks/arbitrum-batch/:number',
pathParams: [ 'number' as const ],
filterFields: [],
},

// zkEvm L2
zkevm_l2_deposits: {
path: '/api/v2/zkevm/deposits',
Expand Down Expand Up @@ -865,6 +910,7 @@ export type PaginatedResources = 'blocks' | 'block_txs' |
'optimistic_l2_output_roots' | 'optimistic_l2_withdrawals' | 'optimistic_l2_txn_batches' | 'optimistic_l2_deposits' |
'optimistic_l2_dispute_games' |
'shibarium_deposits' | 'shibarium_withdrawals' |
'arbitrum_l2_messages' | 'arbitrum_l2_txn_batches' | 'arbitrum_l2_txn_batch_txs' | 'arbitrum_l2_txn_batch_blocks' |
'zkevm_l2_deposits' | 'zkevm_l2_withdrawals' | 'zkevm_l2_txn_batches' | 'zkevm_l2_txn_batch_txs' |
'zksync_l2_txn_batches' | 'zksync_l2_txn_batch_txs' |
'withdrawals' | 'address_withdrawals' | 'block_withdrawals' |
Expand Down Expand Up @@ -991,6 +1037,13 @@ Q extends 'shibarium_withdrawals' ? ShibariumWithdrawalsResponse :
Q extends 'shibarium_deposits' ? ShibariumDepositsResponse :
Q extends 'shibarium_withdrawals_count' ? number :
Q extends 'shibarium_deposits_count' ? number :
Q extends 'arbitrum_l2_messages' ? ArbitrumL2MessagesResponse :
Q extends 'arbitrum_l2_messages_count' ? number :
Q extends 'arbitrum_l2_txn_batches' ? ArbitrumL2TxnBatchesResponse :
Q extends 'arbitrum_l2_txn_batches_count' ? number :
Q extends 'arbitrum_l2_txn_batch' ? ArbitrumL2TxnBatch :
Q extends 'arbitrum_l2_txn_batch_txs' ? ArbitrumL2BatchTxs :
Q extends 'arbitrum_l2_txn_batch_blocks' ? ArbitrumL2BatchBlocks :
Q extends 'zkevm_l2_deposits' ? ZkEvmL2DepositsResponse :
Q extends 'zkevm_l2_deposits_count' ? number :
Q extends 'zkevm_l2_withdrawals' ? ZkEvmL2WithdrawalsResponse :
Expand Down
25 changes: 25 additions & 0 deletions lib/getArbitrumVerificationStepStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { ArbitrumBatchStatus, ArbitrumL2TxData } from 'types/api/arbitrumL2';

type Args = {
status: ArbitrumBatchStatus;
commitment_transaction: ArbitrumL2TxData;
confirmation_transaction: ArbitrumL2TxData;
}

export default function getArbitrumVerificationStepStatus({
status,
commitment_transaction: commitTx,
confirmation_transaction: confirmTx,
}: Args) {
if (status === 'Sent to base') {
if (commitTx.status === 'unfinalized') {
return 'pending';
}
}
if (status === 'Confirmed on base') {
if (confirmTx.status === 'unfinalized') {
return 'pending';
}
}
return 'finalized';
}
2 changes: 1 addition & 1 deletion lib/hooks/useNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function useNavItems(): ReturnType {

const rollupFeature = config.features.rollup;

if (rollupFeature.isEnabled && (rollupFeature.type === 'optimistic' || rollupFeature.type === 'zkEvm')) {
if (rollupFeature.isEnabled && (rollupFeature.type === 'optimistic' || rollupFeature.type === 'arbitrum' || rollupFeature.type === 'zkEvm')) {
blockchainNavItems = [
[
txs,
Expand Down
29 changes: 29 additions & 0 deletions mocks/arbitrum/deposits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { ArbitrumL2MessagesResponse } from 'types/api/arbitrumL2';

export const baseResponse: ArbitrumL2MessagesResponse = {
items: [
{
completion_transaction_hash: '0x0b7d58c0a6b4695ba28d99df928591fb931c812c0aab6d0093ff5040d2f9bc5e',
id: 181920,
origination_address: '0x2B51Ae4412F79c3c1cB12AA40Ea4ECEb4e80511a',
origination_transaction_block_number: 123456,
origination_transaction_hash: '0x210d9f70f411de1079e32a98473b04345a5ea6ff2340a8511ebc2df641274436',
origination_timestamp: '2023-06-01T14:46:48.000000Z',
status: 'initiated',
},
{
completion_transaction_hash: '0x0b7d58c0a6b4695ba28d99df928591fb931c812c0aab6d0093ff5040d2f9bc5e',
id: 181921,
origination_address: '0x2B51Ae4412F79c3c1cB12AA40Ea4ECEb4e80511a',
origination_transaction_block_number: 123400,
origination_transaction_hash: '0x210d9f70f411de1079e32a98473b04345a5ea6ff2340a8511ebc2df641274436',
origination_timestamp: '2023-06-01T14:46:48.000000Z',
status: 'relayed',
},
],
next_page_params: {
items_count: 50,
id: 123,
direction: 'to-rollup',
},
};
11 changes: 11 additions & 0 deletions mocks/arbitrum/txnBatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ArbitrumL2TxnBatch } from 'types/api/arbitrumL2';

import { finalized } from './txnBatches';

export const batchData: ArbitrumL2TxnBatch = {
...finalized,
after_acc: '0xcd064f3409015e8e6407e492e5275a185e492c6b43ccf127f22092d8057a9ffb',
before_acc: '0x2ed7c4985eb778d76ec400a43805e7feecc8c2afcdb492dbe5caf227de6d37bc',
start_block: 1245209,
end_block: 1245490,
};
36 changes: 36 additions & 0 deletions mocks/arbitrum/txnBatches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { ArbitrumL2TxnBatchesItem, ArbitrumL2TxnBatchesResponse } from 'types/api/arbitrumL2';

export const finalized: ArbitrumL2TxnBatchesItem = {
number: 12345,
block_count: 12345,
transactions_count: 10000,
commitment_transaction: {
block_number: 12345,
timestamp: '2022-04-17T08:51:58.000000Z',
hash: '0x262e7215739d6a7e33b2c20b45a838801a0f5f080f20bec8e54eb078420c4661',
status: 'finalized',
},
};

export const unfinalized: ArbitrumL2TxnBatchesItem = {
number: 12344,
block_count: 10000,
transactions_count: 103020,
commitment_transaction: {
block_number: 12340,
timestamp: '2022-04-17T08:51:58.000000Z',
hash: '0x262e7215739d6a7e33b2c20b45a838801a0f5f080f20bec8e54eb078420c4661',
status: 'unfinalized',
},
};

export const baseResponse: ArbitrumL2TxnBatchesResponse = {
items: [
finalized,
unfinalized,
],
next_page_params: {
items_count: 50,
number: 123,
},
};
29 changes: 29 additions & 0 deletions mocks/arbitrum/withdrawals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { ArbitrumL2MessagesResponse } from 'types/api/arbitrumL2';

export const baseResponse: ArbitrumL2MessagesResponse = {
items: [
{
completion_transaction_hash: '0x0b7d58c0a6b4695ba28d99df928591fb931c812c0aab6d0093ff5040d2f9bc5e',
id: 181920,
origination_address: '0x2B51Ae4412F79c3c1cB12AA40Ea4ECEb4e80511a',
origination_transaction_block_number: 123456,
origination_transaction_hash: '0x210d9f70f411de1079e32a98473b04345a5ea6ff2340a8511ebc2df641274436',
origination_timestamp: '2023-06-01T14:46:48.000000Z',
status: 'sent',
},
{
completion_transaction_hash: '0x0b7d58c0a6b4695ba28d99df928591fb931c812c0aab6d0093ff5040d2f9bc5e',
id: 181921,
origination_address: '0x2B51Ae4412F79c3c1cB12AA40Ea4ECEb4e80511a',
origination_transaction_block_number: 123400,
origination_transaction_hash: '0x210d9f70f411de1079e32a98473b04345a5ea6ff2340a8511ebc2df641274436',
origination_timestamp: '2023-06-01T14:46:48.000000Z',
status: 'confirmed',
},
],
next_page_params: {
items_count: 50,
id: 123,
direction: 'from-rollup',
},
};
10 changes: 7 additions & 3 deletions nextjs/getServerSideProps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { GetServerSideProps, GetServerSidePropsContext, GetServerSidePropsResult } from 'next';

import type { AdBannerProviders } from 'types/client/adProviders';
import type { RollupType } from 'types/client/rollup';

import type { Route } from 'nextjs-routes';

Expand Down Expand Up @@ -66,8 +67,9 @@ export const verifiedAddresses: GetServerSideProps<Props> = async(context) => {
return account(context);
};

const DEPOSITS_ROLLUP_TYPES: Array<RollupType> = [ 'optimistic', 'shibarium', 'zkEvm', 'arbitrum' ];
export const deposits: GetServerSideProps<Props> = async(context) => {
if (!(rollupFeature.isEnabled && (rollupFeature.type === 'optimistic' || rollupFeature.type === 'shibarium' || rollupFeature.type === 'zkEvm'))) {
if (!(rollupFeature.isEnabled && DEPOSITS_ROLLUP_TYPES.includes(rollupFeature.type))) {
return {
notFound: true,
};
Expand All @@ -76,10 +78,11 @@ export const deposits: GetServerSideProps<Props> = async(context) => {
return base(context);
};

const WITHDRAWALS_ROLLUP_TYPES: Array<RollupType> = [ 'optimistic', 'shibarium', 'zkEvm', 'arbitrum' ];
export const withdrawals: GetServerSideProps<Props> = async(context) => {
if (
!config.features.beaconChain.isEnabled &&
!(rollupFeature.isEnabled && (rollupFeature.type === 'optimistic' || rollupFeature.type === 'shibarium' || rollupFeature.type === 'zkEvm'))
!(rollupFeature.isEnabled && WITHDRAWALS_ROLLUP_TYPES.includes(rollupFeature.type))
) {
return {
notFound: true,
Expand Down Expand Up @@ -109,8 +112,9 @@ export const optimisticRollup: GetServerSideProps<Props> = async(context) => {
return base(context);
};

const BATCH_ROLLUP_TYPES: Array<RollupType> = [ 'zkEvm', 'zkSync', 'arbitrum' ];
export const batch: GetServerSideProps<Props> = async(context) => {
if (!(rollupFeature.isEnabled && (rollupFeature.type === 'zkEvm' || rollupFeature.type === 'zkSync'))) {
if (!(rollupFeature.isEnabled && BATCH_ROLLUP_TYPES.includes(rollupFeature.type))) {
return {
notFound: true,
};
Expand Down
2 changes: 2 additions & 0 deletions pages/batches/[number].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const Batch = dynamic(() => {
}

switch (rollupFeature.type) {
case 'arbitrum':
return import('ui/pages/ArbitrumL2TxnBatch');
case 'zkEvm':
return import('ui/pages/ZkEvmL2TxnBatch');
case 'zkSync':
Expand Down
2 changes: 2 additions & 0 deletions pages/batches/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const Batches = dynamic(() => {
return import('ui/pages/ZkSyncL2TxnBatches');
case 'optimistic':
return import('ui/pages/OptimisticL2TxnBatches');
case 'arbitrum':
return import('ui/pages/ArbitrumL2TxnBatches');
}
throw new Error('Txn batches feature is not enabled.');
}, { ssr: false });
Expand Down
4 changes: 4 additions & 0 deletions pages/deposits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const Deposits = dynamic(() => {
return import('ui/pages/OptimisticL2Deposits');
}

if (rollupFeature.isEnabled && rollupFeature.type === 'arbitrum') {
return import('ui/pages/ArbitrumL2Deposits');
}

if (rollupFeature.isEnabled && rollupFeature.type === 'shibarium') {
return import('ui/pages/ShibariumDeposits');
}
Expand Down
4 changes: 4 additions & 0 deletions pages/withdrawals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const Withdrawals = dynamic(() => {
return import('ui/pages/OptimisticL2Withdrawals');
}

if (rollupFeature.isEnabled && rollupFeature.type === 'arbitrum') {
return import('ui/pages/ArbitrumL2Withdrawals');
}

if (rollupFeature.isEnabled && rollupFeature.type === 'shibarium') {
return import('ui/pages/ShibariumWithdrawals');
}
Expand Down
4 changes: 4 additions & 0 deletions playwright/fixtures/mockEnvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const ENVS_MAP: Record<string, Array<[string, string]>> = {
[ 'NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL', 'https://localhost:3102' ],
[ 'NEXT_PUBLIC_FAULT_PROOF_ENABLED', 'true' ],
],
arbitrumRollup: [
[ 'NEXT_PUBLIC_ROLLUP_TYPE', 'arbitrum' ],
[ 'NEXT_PUBLIC_ROLLUP_L1_BASE_URL', 'https://localhost:3101' ],
],
shibariumRollup: [
[ 'NEXT_PUBLIC_ROLLUP_TYPE', 'shibarium' ],
[ 'NEXT_PUBLIC_ROLLUP_L1_BASE_URL', 'https://localhost:3101' ],
Expand Down
Loading
Loading