Skip to content

Commit 645b089

Browse files
authored
chore: clarify hard fork phrasing (#59)
1 parent 47560c5 commit 645b089

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Diff for: src/components/diff/utils/format.tsx

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { MainnetHardfork } from '@/chains/mainnet/hardforks';
2+
import { CURRENT_OPTIMISM_HARDFORK, OptimismHardfork } from '@/chains/optimism/hardforks';
23
import { CURRENT_MAINNET_HARDFORK } from '@/lib/constants';
34
import { classNames, toUppercase } from '@/lib/utils';
45

@@ -7,26 +8,29 @@ export const formatHardfork = (array: string[]): JSX.Element => {
78
return <p>No information provided on supported hard forks.</p>;
89
}
910

10-
const [first, ...rest] = array;
11-
const last = rest.pop();
12-
const length = array.length;
11+
const first = array[0];
12+
const last = array[array.length - 1];
1313
const currentMainnetHardforkName = MainnetHardfork[CURRENT_MAINNET_HARDFORK];
14-
if (length == 1) {
14+
const currentOptimismHardforkName = OptimismHardfork[CURRENT_OPTIMISM_HARDFORK];
15+
if (array.length == 1) {
16+
const supportedText =
17+
first === currentMainnetHardforkName || first === currentOptimismHardforkName
18+
? `Supported since ${first} hard fork.`
19+
: `Supported only in ${first} hard fork.`;
1520
return (
1621
<p className='text-sm'>
17-
Supported only in <b>{first}</b> hard fork.
18-
</p>
19-
);
20-
} else if (length == CURRENT_MAINNET_HARDFORK + 1 || last === currentMainnetHardforkName) {
21-
return (
22-
<p className='text-sm'>
23-
Supported since <b>{first}</b> hard fork.
22+
<b>{supportedText}</b>
2423
</p>
2524
);
2625
}
26+
27+
const supportedText =
28+
last === currentMainnetHardforkName || last === currentOptimismHardforkName
29+
? `Supported since ${first} hard fork.`
30+
: `Supported between ${first} and ${last} hard forks.`;
2731
return (
2832
<p className='text-sm'>
29-
Supported between <b>{first}</b> and <b>{last}</b> hard forks.
33+
<b>{supportedText}</b>
3034
</p>
3135
);
3236
};

0 commit comments

Comments
 (0)