diff --git a/packages/page-explorer/src/BlockInfo/ByHash.tsx b/packages/page-explorer/src/BlockInfo/ByHash.tsx
index f006feff43..d3e7e736bc 100644
--- a/packages/page-explorer/src/BlockInfo/ByHash.tsx
+++ b/packages/page-explorer/src/BlockInfo/ByHash.tsx
@@ -73,7 +73,7 @@ function BlockByHash ({ className = '', error, value }: Props): React.ReactEleme
[t('parent'), 'start'],
[t('extrinsics'), 'start'],
[t('state'), 'start'],
- []
+ [undefined, 'media--1200']
]
: [['...', 'start', 6]]
}
@@ -96,7 +96,7 @@ function BlockByHash ({ className = '', error, value }: Props): React.ReactEleme
}
{getHeader.extrinsicsRoot.toHex()} |
{getHeader.stateRoot.toHex()} |
-
+ |
phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(index));
+function filterEvents (index: number, events: KeyedEvent[] = [], maxBlockWeight?: Weight): [DispatchInfo | undefined, number, KeyedEvent[]] {
+ const filtered = events.filter(({ record: { phase } }) =>
+ phase.isApplyExtrinsic &&
+ phase.asApplyExtrinsic.eq(index)
+ );
+ const withInfo = filtered.filter(({ record: { event: { method, section } } }) =>
+ section === 'system' &&
+ ['ExtrinsicFailed', 'ExtrinsicSuccess'].includes(method)
+ );
+ const dispatchInfo = withInfo.length
+ ? withInfo[0].record.event.data[0] as DispatchInfo
+ : undefined;
+
+ return [
+ dispatchInfo,
+ dispatchInfo && maxBlockWeight
+ ? dispatchInfo.weight.mul(BN_TEN_THOUSAND).div(maxBlockWeight).toNumber() / 100
+ : 0,
+ filtered
+ ];
}
-function ExtrinsicDisplay ({ blockNumber, className = '', events, index, value }: Props): React.ReactElement {
+function ExtrinsicDisplay ({ blockNumber, className = '', events, index, maxBlockWeight, value }: Props): React.ReactElement {
const { t } = useTranslation();
const { meta, method, section } = useMemo(
@@ -63,9 +85,9 @@ function ExtrinsicDisplay ({ blockNumber, className = '', events, index, value }
[blockNumber, t, value]
);
- const thisEvents = useMemo(
- () => filterEvents(index, events),
- [index, events]
+ const [dispatchInfo, weightPercentage, thisEvents] = useMemo(
+ () => filterEvents(index, events, maxBlockWeight),
+ [index, events, maxBlockWeight]
);
return (
@@ -92,7 +114,7 @@ function ExtrinsicDisplay ({ blockNumber, className = '', events, index, value }
|
{thisEvents.map(({ key, record }) =>
@@ -103,7 +125,15 @@ function ExtrinsicDisplay ({ blockNumber, className = '', events, index, value }
/>
)}
|
-
+ |
+ {dispatchInfo && (
+ <>
+ <>{formatNumber(dispatchInfo.weight)}>
+ {weightPercentage.toFixed(2)}%
+ >
+ )}
+ |
+
{value.isSigned && (
<>
diff --git a/packages/page-explorer/src/BlockInfo/Extrinsics.tsx b/packages/page-explorer/src/BlockInfo/Extrinsics.tsx
index d2261de4d5..3ba33fb8aa 100644
--- a/packages/page-explorer/src/BlockInfo/Extrinsics.tsx
+++ b/packages/page-explorer/src/BlockInfo/Extrinsics.tsx
@@ -7,6 +7,7 @@ import type { BlockNumber, Extrinsic } from '@polkadot/types/interfaces';
import React, { useMemo } from 'react';
import { Table } from '@polkadot/react-components';
+import { useApi } from '@polkadot/react-hooks';
import { useTranslation } from '../translate';
import ExtrinsicDisplay from './Extrinsic';
@@ -21,11 +22,13 @@ interface Props {
function Extrinsics ({ blockNumber, className = '', events, label, value }: Props): React.ReactElement {
const { t } = useTranslation();
+ const { api } = useApi();
const header = useMemo(() => [
[label || t('extrinsics'), 'start', 2],
- [t('events'), 'start', 2],
- [t('signer'), 'address']
+ [t('events'), 'start media--1000', 2],
+ [t('weight'), 'media--1400'],
+ [t('signer'), 'address media--1200']
], [label, t]);
return (
@@ -41,6 +44,7 @@ function Extrinsics ({ blockNumber, className = '', events, label, value }: Prop
events={events}
index={index}
key={`extrinsic:${index}`}
+ maxBlockWeight={api.consts.system.blockWeights?.maxBlock}
value={extrinsic}
/>
)}
|