Commit 9ac71c58 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #756 from blockscout/tx-l2

tx l2 fields
parents 74c86bcb dae9125c
......@@ -15,6 +15,7 @@ NEXT_PUBLIC_NETWORK_LOGO=
NEXT_PUBLIC_NETWORK_SMALL_LOGO=
NEXT_PUBLIC_NETWORK_RPC_URL=https://core.poa.network
NEXT_PUBLIC_IS_TESTNET=true
NEXT_PUBLIC_IS_L2_NETWORK=false
# api config
NEXT_PUBLIC_API_HOST=blockscout.com
......
......@@ -242,3 +242,11 @@ export const withActionsUniswap: Transaction = {
},
],
};
export const l2tx: Transaction = {
...base,
l1_gas_price: '82702201886',
l1_fee_scalar: '1.0',
l1_gas_used: '17060',
l1_fee: '1584574188135760',
};
......@@ -50,6 +50,10 @@ export type Transaction = (
tx_types: Array<TransactionType>;
tx_tag: string | null;
actions: Array<TxAction>;
l1_fee?: string;
l1_fee_scalar?: string;
l1_gas_price?: string;
l1_gas_used?: string;
}
export type TransactionsResponse = TransactionsResponseValidated | TransactionsResponsePending;
......
......@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-react';
import React from 'react';
import * as txMock from 'mocks/txs/tx';
import contextWithEnvs from 'playwright/fixtures/contextWithEnvs';
import TestApp from 'playwright/TestApp';
import buildApiUrl from 'playwright/utils/buildApiUrl';
import insertAdPlaceholder from 'playwright/utils/insertAdPlaceholder';
......@@ -141,3 +142,28 @@ test('with actions uniswap +@mobile +@dark-mode', async({ mount, page }) => {
await insertAdPlaceholder(page);
await expect(component).toHaveScreenshot();
});
const l2Test = test.extend({
context: contextWithEnvs([
{ name: 'NEXT_PUBLIC_IS_L2_NETWORK', value: 'true' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
]) as any,
});
l2Test('l2', async({ mount, page }) => {
await page.route(API_URL, (route) => route.fulfill({
status: 200,
body: JSON.stringify(txMock.l2tx),
}));
const component = await mount(
<TestApp>
<TxDetails/>
</TestApp>,
{ hooksConfig },
);
await insertAdPlaceholder(page);
await expect(component).toHaveScreenshot();
});
......@@ -318,6 +318,49 @@ const TxDetails = () => {
/>
</DetailsInfoItem>
) }
{ appConfig.L2.isL2Network && (
<>
{ data.l1_gas_used && (
<DetailsInfoItem
title="L1 gas used by txn"
hint="L1 gas used by transaction"
>
<Text>{ BigNumber(data.l1_gas_used).toFormat() }</Text>
</DetailsInfoItem>
) }
{ data.l1_gas_price && (
<DetailsInfoItem
title="L1 gas price"
hint="L1 gas price"
>
<Text mr={ 1 }>{ BigNumber(data.l1_gas_price).dividedBy(WEI).toFixed() } { appConfig.network.currency.symbol }</Text>
<Text variant="secondary">({ BigNumber(data.l1_gas_price).dividedBy(WEI_IN_GWEI).toFixed() } Gwei)</Text>
</DetailsInfoItem>
) }
{ data.l1_fee && (
<DetailsInfoItem
title="L1 fee"
// eslint-disable-next-line max-len
hint={ `L1 Data Fee which is used to cover the L1 "security" cost from the batch submission mechanism. In combination with L2 execution fee, L1 fee makes the total amount of fees that a transaction pays.` }
>
<CurrencyValue
value={ data.l1_fee }
currency={ appConfig.network.currency.symbol }
exchangeRate={ data.exchange_rate }
flexWrap="wrap"
/>
</DetailsInfoItem>
) }
{ data.l1_fee_scalar && (
<DetailsInfoItem
title="L1 fee scalar"
hint="A Dynamic overhead (fee scalar) premium, which serves as a buffer in case L1 prices rapidly increase."
>
<Text>{ data.l1_fee_scalar }</Text>
</DetailsInfoItem>
) }
</>
) }
<GridItem colSpan={{ base: undefined, lg: 2 }}>
<Element name="TxDetails__cutLink">
<Link
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment