Skip to content

Commit

Permalink
Merge pull request blockscout#1051 from blockscout/withdrawals-curr
Browse files Browse the repository at this point in the history
beacon network currency symbol
  • Loading branch information
isstuev authored Aug 1, 2023
2 parents 6a2ec0e + db17f61 commit c41fef8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ NEXT_PUBLIC_L2_WITHDRAWAL_URL=__PLACEHOLDER_FOR_NEXT_PUBLIC_L2_WITHDRAWAL_URL__

# beacon chain config
NEXT_PUBLIC_HAS_BEACON_CHAIN=__PLACEHOLDER_FOR_NEXT_PUBLIC_HAS_BEACON_CHAIN__
NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL=__PLACEHOLDER_FOR_NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL__
1 change: 1 addition & 0 deletions configs/app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const config = Object.freeze({
},
beaconChain: {
hasBeaconChain: getEnvValue(process.env.NEXT_PUBLIC_HAS_BEACON_CHAIN) === 'true',
currencySymbol: getEnvValue(process.env.NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL) || getEnvValue(process.env.NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL),
},
statsApi: {
endpoint: getEnvValue(process.env.NEXT_PUBLIC_STATS_API_HOST),
Expand Down
1 change: 1 addition & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ In order to enable "My Account" feature you have to configure following set of v
| Variable | Type| Description | Is required | Default value | Example value |
| --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_HAS_BEACON_CHAIN | `boolean` | Set to true for networks with the beacon chain | - | - | `true` |
| NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL | `string` | Beacon network currency symbol | - | NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL | `ETH` |
14 changes: 12 additions & 2 deletions types/envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export type NextPublicEnvs = {
NEXT_PUBLIC_NETWORK_EXPLORERS?: string;
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE?: 'validation' | 'mining';
NEXT_PUBLIC_IS_TESTNET?: 'true' | '';
NEXT_PUBLIC_HAS_BEACON_CHAIN?: 'true' | '';

// UI config
NEXT_PUBLIC_FEATURED_NETWORKS?: string;
Expand Down Expand Up @@ -73,7 +72,8 @@ export type NextPublicEnvs = {
}
& NextPublicEnvsAccount
& NextPublicEnvsMarketplace
& NextPublicEnvsRollup;
& NextPublicEnvsRollup
& NextPublicEnvsBeacon;

type NextPublicEnvsAccount =
{
Expand Down Expand Up @@ -110,3 +110,13 @@ type NextPublicEnvsRollup =
NEXT_PUBLIC_L1_BASE_URL?: undefined;
NEXT_PUBLIC_L2_WITHDRAWAL_URL?: undefined;
}

type NextPublicEnvsBeacon =
{
NEXT_PUBLIC_HAS_BEACON_CHAIN: 'true';
NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL?: string;
} |
{
NEXT_PUBLIC_HAS_BEACON_CHAIN?: undefined;
NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL?: undefined;
}
3 changes: 2 additions & 1 deletion ui/pages/Withdrawals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Flex, Hide, Show, Skeleton, Text } from '@chakra-ui/react';
import BigNumber from 'bignumber.js';
import React from 'react';

import appConfig from 'configs/app/config';
import useApiQuery from 'lib/api/useApiQuery';
import getCurrencyValue from 'lib/getCurrencyValue';
import useIsMobile from 'lib/hooks/useIsMobile';
Expand Down Expand Up @@ -67,7 +68,7 @@ const Withdrawals = () => {
const { valueStr } = getCurrencyValue({ value: countersQuery.data.withdrawal_sum });
return (
<Text mb={{ base: 6, lg: pagination.isVisible ? 0 : 6 }} lineHeight={{ base: '24px', lg: '32px' }}>
{ BigNumber(countersQuery.data.withdrawal_count).toFormat() } withdrawals processed and { valueStr } ETH withdrawn
{ BigNumber(countersQuery.data.withdrawal_count).toFormat() } withdrawals processed and { valueStr } { appConfig.beaconChain.currencySymbol } withdrawn
</Text>
);
})();
Expand Down
2 changes: 1 addition & 1 deletion ui/withdrawals/WithdrawalsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const WithdrawalsListItem = ({ item, isLoading, view }: Props) => {

<ListItemMobileGrid.Label isLoading={ isLoading }>Value</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value>
<CurrencyValue value={ item.amount } currency={ appConfig.network.currency.symbol } isLoading={ isLoading }/>
<CurrencyValue value={ item.amount } currency={ appConfig.beaconChain.currencySymbol } isLoading={ isLoading }/>
</ListItemMobileGrid.Value>
</>
) }
Expand Down
2 changes: 1 addition & 1 deletion ui/withdrawals/WithdrawalsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const WithdrawalsTable = ({ items, isLoading, top, view = 'list' }: Props) => {
{ view !== 'block' && <Th w="25%">Block</Th> }
{ view !== 'address' && <Th w="25%">To</Th> }
{ view !== 'block' && <Th w="25%">Age</Th> }
<Th w="25%">{ `Value ${ appConfig.network.currency.symbol }` }</Th>
<Th w="25%">{ `Value ${ appConfig.beaconChain.currencySymbol }` }</Th>
</Tr>
</Thead>
<Tbody>
Expand Down

0 comments on commit c41fef8

Please sign in to comment.