Skip to content

Commit

Permalink
arbitrum
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev committed Jun 13, 2024
1 parent f550077 commit 527bdec
Show file tree
Hide file tree
Showing 39 changed files with 1,538 additions and 33 deletions.
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
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
34 changes: 34 additions & 0 deletions stubs/arbitrumL2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { ArbitrumL2TxnBatchesItem, ArbitrumL2TxnBatch, ArbitrumL2MessagesItem } from 'types/api/arbitrumL2';

import { ADDRESS_HASH } from './addressParams';
import { TX_HASH } from './tx';

export const ARBITRUM_MESSAGES_ITEM: ArbitrumL2MessagesItem = {
completion_transaction_hash: TX_HASH,
id: 181920,
origination_address: ADDRESS_HASH,
origination_transaction_block_number: 123456,
origination_transaction_hash: TX_HASH,
origination_timestamp: '2023-06-01T14:46:48.000000Z',
status: 'relayed',
};

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

export const ARBITRUM_L2_TXN_BATCH: ArbitrumL2TxnBatch = {
...ARBITRUM_L2_TXN_BATCHES_ITEM,
after_acc: '0xcd064f3409015e8e6407e492e5275a185e492c6b43ccf127f22092d8057a9ffb',
before_acc: '0x2ed7c4985eb778d76ec400a43805e7feecc8c2afcdb492dbe5caf227de6d37bc',
start_block: 1245209,
end_block: 1245490,
};
86 changes: 86 additions & 0 deletions types/api/arbitrumL2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import type { Block } from './block';
import type { Transaction } from './transaction';

export type ArbitrumL2MessagesItem = {
completion_transaction_hash: string | null;
id: number;
origination_address: string;
origination_timestamp: string | null;
origination_transaction_block_number: number;
origination_transaction_hash: string;
status: string;
}

export type ArbitrumL2MessagesResponse = {
items: Array<ArbitrumL2MessagesItem>;
next_page_params: {
direction: string;
id: number;
items_count: number;
};
}

export type ArbitrumL2TxData = {
hash: string | null;
status: string | null;
timestamp: string | null;
}

type ArbitrumL2BatchCommitmentTx = {
block_number: number;
hash: string;
status: string;
timestamp: string;
}

export type ArbitrumL2TxnBatchesItem = {
block_count: number;
commitment_transaction: ArbitrumL2BatchCommitmentTx;
number: number;
transactions_count: number;
}

export type ArbitrumL2TxnBatchesResponse = {
items: Array<ArbitrumL2TxnBatchesItem>;
next_page_params: {
number: number;
items_count: number;
} | null;
}

export type ArbitrumL2TxnBatch = {
after_acc: string;
before_acc: string;
commitment_transaction: ArbitrumL2BatchCommitmentTx;
end_block: number;
start_block: number;
number: number;
transactions_count: number;
}

export type ArbitrumL2BatchTxs = {
items: Array<Transaction>;
next_page_params: {
batch_number: string;
block_number: number;
index: number;
items_count: number;
} | null;
}

export type ArbitrumL2BatchBlocks = {
items: Array<Block>;
next_page_params: {
batch_number: string;
block_number: number;
items_count: number;
} | null;
}

export const ARBITRUM_L2_TX_BATCH_STATUSES = [
'Processed on rollup' as const,
'Sent to base' as const,
'Confirmed on base' as const,
];

export type ArbitrumBatchStatus = typeof ARBITRUM_L2_TX_BATCH_STATUSES[number];
Loading

0 comments on commit 527bdec

Please sign in to comment.