Skip to content

Commit

Permalink
Rename status labels for Arbitrum blocks and transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Nov 19, 2024
1 parent d1ccf10 commit 98816f3
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 36 deletions.
2 changes: 2 additions & 0 deletions configs/app/features/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config: Feature<{
homepage: { showLatestBlocks: boolean };
outputRootsEnabled: boolean;
L2WithdrawalUrl: string | undefined;
parentChainName: string | undefined;
}> = (() => {
if (type && L1BaseUrl) {
return Object.freeze({
Expand All @@ -31,6 +32,7 @@ const config: Feature<{
L1BaseUrl: stripTrailingSlash(L1BaseUrl),
L2WithdrawalUrl: type === 'optimistic' ? L2WithdrawalUrl : undefined,
outputRootsEnabled: type === 'optimistic' && getEnvValue('NEXT_PUBLIC_ROLLUP_OUTPUT_ROOTS_ENABLED') !== 'false',
parentChainName: type === 'arbitrum' ? getEnvValue('NEXT_PUBLIC_ROLLUP_PARENT_CHAIN_NAME') : undefined,
homepage: {
showLatestBlocks: getEnvValue('NEXT_PUBLIC_ROLLUP_HOMEPAGE_SHOW_LATEST_BLOCKS') === 'true',
},
Expand Down
13 changes: 12 additions & 1 deletion deploy/tools/envs-validator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ const rollupSchema = yup
then: (schema) => schema.test(urlTest).required(),
otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL can be used only if NEXT_PUBLIC_ROLLUP_TYPE is set to \'optimistic\' '),
}),
NEXT_PUBLIC_ROLLUP_OUTPUT_ROOTS_ENABLED: yup
NEXT_PUBLIC_ROLLUP_OUTPUT_ROOTS_ENABLED: yup
.boolean()
.when('NEXT_PUBLIC_ROLLUP_TYPE', {
is: 'optimistic',
Expand All @@ -298,6 +298,17 @@ const rollupSchema = yup
value => value === undefined,
),
}),
NEXT_PUBLIC_ROLLUP_PARENT_CHAIN_NAME: yup
.string()
.when('NEXT_PUBLIC_ROLLUP_TYPE', {
is: 'arbitrum',
then: (schema) => schema,
otherwise: (schema) => schema.test(
'not-exist',
'NEXT_PUBLIC_ROLLUP_PARENT_CHAIN_NAME can only be used if NEXT_PUBLIC_ROLLUP_TYPE is set to \'arbitrum\' ',
value => value === undefined,
),
}),
NEXT_PUBLIC_ROLLUP_HOMEPAGE_SHOW_LATEST_BLOCKS: yup
.boolean()
.when('NEXT_PUBLIC_ROLLUP_TYPE', {
Expand Down
4 changes: 4 additions & 0 deletions deploy/tools/envs-validator/test/.env.arbitrum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NEXT_PUBLIC_ROLLUP_TYPE=arbitrum
NEXT_PUBLIC_ROLLUP_L1_BASE_URL=https://example.com
NEXT_PUBLIC_ROLLUP_HOMEPAGE_SHOW_LATEST_BLOCKS=true
NEXT_PUBLIC_ROLLUP_PARENT_CHAIN_NAME=DuckChain
1 change: 1 addition & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ This feature is **enabled by default** with the `coinzilla` ads provider. To swi
| NEXT_PUBLIC_HAS_MUD_FRAMEWORK | `boolean` | Set to `true` for instances that use MUD framework (Optimistic stack only) | - | - | `true` | v1.33.0+ |
| NEXT_PUBLIC_ROLLUP_HOMEPAGE_SHOW_LATEST_BLOCKS | `boolean` | Set to `true` to display "Latest blocks" widget instead of "Latest batches" on the home page | - | - | `true` | v1.36.0+ |
| NEXT_PUBLIC_ROLLUP_OUTPUT_ROOTS_ENABLED | `boolean` | Enables "Output roots" page (Optimistic stack only) | - | `true` | `false` | v1.37.0+ |
| NEXT_PUBLIC_ROLLUP_PARENT_CHAIN_NAME | `string` | Set to customize L1 transaction status labels in the UI (e.g., "Sent to <chain-name>"). This setting is applicable only for Arbitrum-based chains. | - | - | `DuckChain` | v1.37.0+ |

&nbsp;

Expand Down
25 changes: 0 additions & 25 deletions lib/getArbitrumVerificationStepStatus.ts

This file was deleted.

41 changes: 41 additions & 0 deletions lib/rollups/arbitrum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ARBITRUM_L2_TX_BATCH_STATUSES, type ArbitrumBatchStatus, type ArbitrumL2TxData } from 'types/api/arbitrumL2';

import config from 'configs/app';

const rollupFeature = config.features.rollup;

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

export const VERIFICATION_STEPS_MAP: Record<ArbitrumBatchStatus, string> = {
'Processed on rollup': 'Processed on rollup',
'Sent to base': rollupFeature.isEnabled && rollupFeature.parentChainName ? `Sent to ${ rollupFeature.parentChainName }` : 'Sent to parent chain',
'Confirmed on base': rollupFeature.isEnabled && rollupFeature.parentChainName ?
`Confirmed on ${ rollupFeature.parentChainName }` :
'Confirmed on parent chain',
};

export const verificationSteps = (() => {
return ARBITRUM_L2_TX_BATCH_STATUSES.map((status) => VERIFICATION_STEPS_MAP[status]);
})();

export function getVerificationStepStatus({
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';
}
27 changes: 27 additions & 0 deletions mocks/txs/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,33 @@ export const celoTxn: Transaction = {
},
};

export const arbitrumTxn: Transaction = {
...base,
arbitrum: {
batch_number: 743991,
commitment_transaction: {
hash: '0x71a25e01dde129a308704de217d200ea42e0f5b8c221c8ba8b2b680ff347f708',
status: 'unfinalized',
timestamp: '2024-11-19T14:26:23.000000Z',
},
confirmation_transaction: {
hash: null,
status: null,
timestamp: null,
},
contains_message: null,
gas_used_for_l1: '129773',
gas_used_for_l2: '128313',
message_related_info: {
associated_l1_transaction: null,
message_status: 'Relayed',
},
network_fee: '1283130000000',
poster_fee: '1297730000000',
status: 'Sent to base',
},
};

export const base2 = {
...base,
hash: '0x02d597ebcf3e8d60096dd0363bc2f0f5e2df27ba1dacd696c51aa7c9409f3193',
Expand Down
1 change: 1 addition & 0 deletions playwright/fixtures/mockEnvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const ENVS_MAP: Record<string, Array<[string, string]>> = {
arbitrumRollup: [
[ 'NEXT_PUBLIC_ROLLUP_TYPE', 'arbitrum' ],
[ 'NEXT_PUBLIC_ROLLUP_L1_BASE_URL', 'https://localhost:3101' ],
[ 'NEXT_PUBLIC_ROLLUP_PARENT_CHAIN_NAME', 'DuckChain' ],
],
shibariumRollup: [
[ 'NEXT_PUBLIC_ROLLUP_TYPE', 'shibarium' ],
Expand Down
9 changes: 4 additions & 5 deletions ui/block/BlockDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ import { useRouter } from 'next/router';
import React from 'react';
import { scroller, Element } from 'react-scroll';

import { ARBITRUM_L2_TX_BATCH_STATUSES } from 'types/api/arbitrumL2';
import { ZKSYNC_L2_TX_BATCH_STATUSES } from 'types/api/zkSyncL2';

import { route } from 'nextjs-routes';

import config from 'configs/app';
import getBlockReward from 'lib/block/getBlockReward';
import { GWEI, WEI, WEI_IN_GWEI, ZERO } from 'lib/consts';
import getArbitrumVerificationStepStatus from 'lib/getArbitrumVerificationStepStatus';
import { space } from 'lib/html-entities';
import getNetworkValidationActionText from 'lib/networks/getNetworkValidationActionText';
import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
import * as arbitrum from 'lib/rollups/arbitrum';
import getQueryParamString from 'lib/router/getQueryParamString';
import { currencyUnits } from 'lib/units';
import OptimisticL2TxnBatchDA from 'ui/shared/batch/OptimisticL2TxnBatchDA';
Expand Down Expand Up @@ -317,9 +316,9 @@ const BlockDetails = ({ query }: Props) => {
<VerificationSteps steps={ ZKSYNC_L2_TX_BATCH_STATUSES } currentStep={ data.zksync.status } isLoading={ isPlaceholderData }/> }
{ rollupFeature.type === 'arbitrum' && data.arbitrum && (
<VerificationSteps
steps={ ARBITRUM_L2_TX_BATCH_STATUSES }
currentStep={ data.arbitrum.status }
currentStepPending={ getArbitrumVerificationStepStatus(data.arbitrum) === 'pending' }
steps={ arbitrum.verificationSteps }
currentStep={ arbitrum.VERIFICATION_STEPS_MAP[data.arbitrum.status] }
currentStepPending={ arbitrum.getVerificationStepStatus(data.arbitrum) === 'pending' }
isLoading={ isPlaceholderData }
/>
) }
Expand Down
9 changes: 9 additions & 0 deletions ui/tx/details/TxInfo.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,12 @@ test('stability customization', async({ render, page, mockEnvs }) => {
maskColor: pwConfig.maskColor,
});
});

test('arbitrum L1 status', async({ render, mockEnvs }) => {
await mockEnvs(ENVS_MAP.arbitrumRollup);
const component = await render(<TxInfo data={ txMock.arbitrumTxn } isLoading={ false }/>);

const statusElement = component.locator('div').filter({ hasText: 'Processed on rollup' }).nth(2);

await expect(statusElement).toHaveScreenshot();
});
9 changes: 4 additions & 5 deletions ui/tx/details/TxInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import BigNumber from 'bignumber.js';
import React from 'react';
import { scroller, Element } from 'react-scroll';

import { ARBITRUM_L2_TX_BATCH_STATUSES } from 'types/api/arbitrumL2';
import type { Transaction } from 'types/api/transaction';
import { ZKEVM_L2_TX_STATUSES } from 'types/api/transaction';
import { ZKSYNC_L2_TX_BATCH_STATUSES } from 'types/api/zkSyncL2';
Expand All @@ -25,8 +24,8 @@ import { route } from 'nextjs-routes';

import config from 'configs/app';
import { WEI, WEI_IN_GWEI } from 'lib/consts';
import getArbitrumVerificationStepStatus from 'lib/getArbitrumVerificationStepStatus';
import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
import * as arbitrum from 'lib/rollups/arbitrum';
import { MESSAGE_DESCRIPTIONS } from 'lib/tx/arbitrumMessageStatusDescription';
import getConfirmationDuration from 'lib/tx/getConfirmationDuration';
import { currencyUnits } from 'lib/units';
Expand Down Expand Up @@ -239,9 +238,9 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => {
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
<VerificationSteps
currentStep={ data.arbitrum.status }
currentStepPending={ getArbitrumVerificationStepStatus(data.arbitrum) === 'pending' }
steps={ ARBITRUM_L2_TX_BATCH_STATUSES }
currentStep={ arbitrum.VERIFICATION_STEPS_MAP[data.arbitrum.status] }
currentStepPending={ arbitrum.getVerificationStepStatus(data.arbitrum) === 'pending' }
steps={ arbitrum.verificationSteps }
isLoading={ isLoading }
/>
</DetailsInfoItem.Value>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98816f3

Please sign in to comment.