Skip to content

Commit

Permalink
Merge pull request #29 from codingknite/wvm-archiver
Browse files Browse the repository at this point in the history
wvm archiver
  • Loading branch information
codingknite authored Oct 4, 2024
2 parents 0851e7f + fd0f34e commit 65a330f
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 38 deletions.
64 changes: 64 additions & 0 deletions lib/hooks/useWvmArchiver.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
interface Props {
address: string | undefined;
}

const wvmNetworks = [
{
archive_pool_address: '0x0000000000000000000000000000000000000000',
archiver_address: '0xE5e289FC97C63f64B1EC5e061d7f176e02eBE5A0',
backfill_address: '',
block_time: 2.0,
name: 'GOATDev',
network_chain_id: 2345,
network_rpc: 'http://3.15.141.150:8545',
start_block: 20902,
wvm_chain_id: 9496,
wvm_rpc: 'https://testnet-rpc.wvm.dev',
},
{
archive_pool_address: '0xa2A0D977847805fE224B789D8C4d3D711ab251e7',
archiver_address: '0x197f818c1313DC58b32D88078ecdfB40EA822614',
backfill_address: '0x123463a4B065722E99115D6c222f267d9cABb524',
block_time: 9.0,
name: 'Metis',
network_chain_id: 1088,
network_rpc: 'https://andromeda.metis.io/?owner=1088',
start_block: 18574702,
wvm_chain_id: 9496,
wvm_rpc: 'https://testnet-rpc.wvm.dev',
},
{
archive_pool_address: '0x0000000000000000000000000000000000000000',
archiver_address: '0xA6dC883ea2A6acb576A933B4d38D13d6069d9fBE',
backfill_address: '',
block_time: 2.0,
name: 'RSS3 VSL Mainnet',
network_chain_id: 12553,
network_rpc: 'https://rpc.rss3.io',
start_block: 6888111,
wvm_chain_id: 9496,
wvm_rpc: 'https://testnet-rpc.wvm.dev',
},
{
archive_pool_address: '0x0000000000000000000000000000000000000000',
archiver_address: '0x2D76d7B140d078C575eAAD109168c606FE9d506C',
backfill_address: '0x55dA54ee977FBe734d5250F0558bc4B2FBe36b2a',
block_time: 0.38999998569488525,
name: 'SEI',
network_chain_id: 1329,
network_rpc: 'https://evm-rpc.sei-apis.com',
start_block: 105238600,
wvm_chain_id: 9496,
wvm_rpc: 'https://testnet-rpc.wvm.dev',
},
];

export function useWvmArchiver({ address }: Props) {
const isWvmNetwork = wvmNetworks.find((network) => network.archiver_address === address);

if (isWvmNetwork) {
return true;
}

return false;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"react-identicons": "^1.2.5",
"react-intersection-observer": "^9.5.2",
"react-jazzicon": "^1.0.4",
"react-loader-spinner": "^6.1.6",
"react-number-format": "^5.3.1",
"react-scroll": "^1.8.7",
"swagger-ui-react": "^5.9.0",
Expand Down
47 changes: 32 additions & 15 deletions ui/block/BlockDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import BigNumber from 'bignumber.js';
import capitalize from 'lodash/capitalize';
import { useRouter } from 'next/router';
import React from 'react';
import { RotatingLines } from 'react-loader-spinner';
import { scroller, Element } from 'react-scroll';

import { ZKSYNC_L2_TX_BATCH_STATUSES } from 'types/api/zkSyncL2';
Expand Down Expand Up @@ -813,28 +814,44 @@ const BlockDetails = ({ query }: Props) => {
<DetailsInfoItem.Value>
<IconSvg
name={ wvmIconPath }
width="5"
height="5"
width="20px"
height="20px"
display="block"
marginLeft="5px"
marginRight="5px"
borderRadius="full"
/>
<Link
isExternal
href={ `https://arweave.net/${ arweaveId }` }
rel="noopener noreferrer"
color="#00B774"
>
<EntityBase.Content
text={ isSmallDevice ? truncateArweaveId(arweaveId) : arweaveId }
/>
</Link>
{ arweaveId === 'block_not_archived_or_backfilled' ? (
<>
<Text color={ colorMode === 'dark' ? '#1AFFB1' : '#00B774' } marginLeft="5px" marginRight="12px">Pending </Text>

<RotatingLines
strokeColor="grey"
strokeWidth="5"
animationDuration="0.75"
width="18"
visible={ true }
/>
</>
) : (
<>
<Link
isExternal
href={ `https://arweave.net/${ arweaveId }` }
rel="noopener noreferrer"
color={ colorMode === 'dark' ? '#1AFFB1' : '#00B774' }
marginLeft="3px"
>
<EntityBase.Content text={ isSmallDevice ? truncateArweaveId(arweaveId) : arweaveId }/>
</Link>

<CopyToClipboard text={ arweaveId }/>
<CopyToClipboard text={ arweaveId }/>
</>
) }
</DetailsInfoItem.Value>
</>
) : <Skeleton isLoaded={ !isLoading }/> }
) : (
<Skeleton>loading...</Skeleton>
) }

<DetailsInfoItemDivider/>

Expand Down
4 changes: 4 additions & 0 deletions ui/home/LatestTxsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import type { Transaction } from 'types/api/transaction';
import config from 'configs/app';
import getValueWithUnit from 'lib/getValueWithUnit';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import { useWvmArchiver } from 'lib/hooks/useWvmArchiver';
import { currencyUnits } from 'lib/units';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import WvmArchiverTag from 'ui/shared/statusTag/WvmArchiverTag';
import TxFeeStability from 'ui/shared/tx/TxFeeStability';
import TxWatchListTags from 'ui/shared/tx/TxWatchListTags';
import TxAdditionalInfo from 'ui/txs/TxAdditionalInfo';
Expand All @@ -28,6 +30,7 @@ type Props = {
}

const LatestTxsItem = ({ tx, isLoading }: Props) => {
const isWvmArchiver = useWvmArchiver({ address: tx.from.hash });
const dataTo = tx.to ? tx.to : tx.created_contract;
const timeAgo = useTimeAgoIncrement(tx.timestamp || '0', true);
const columnNum = config.UI.views.tx.hiddenFields?.value && config.UI.views.tx.hiddenFields?.tx_fee ? 2 : 3;
Expand All @@ -54,6 +57,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
<TxType types={ tx.tx_types } isLoading={ isLoading }/>
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
{ isWvmArchiver && <WvmArchiverTag/> }
</HStack>
<Flex
alignItems="center"
Expand Down
4 changes: 4 additions & 0 deletions ui/home/LatestTxsItemMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import type { Transaction } from 'types/api/transaction';
import config from 'configs/app';
import getValueWithUnit from 'lib/getValueWithUnit';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import { useWvmArchiver } from 'lib/hooks/useWvmArchiver';
import { currencyUnits } from 'lib/units';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import WvmArchiverTag from 'ui/shared/statusTag/WvmArchiverTag';
import TxFeeStability from 'ui/shared/tx/TxFeeStability';
import TxWatchListTags from 'ui/shared/tx/TxWatchListTags';
import TxAdditionalInfo from 'ui/txs/TxAdditionalInfo';
Expand All @@ -27,6 +29,7 @@ type Props = {
}

const LatestTxsItem = ({ tx, isLoading }: Props) => {
const isWvmArchiver = useWvmArchiver({ address: tx.from.hash });
const dataTo = tx.to ? tx.to : tx.created_contract;
const timeAgo = useTimeAgoIncrement(tx.timestamp || '0', true);

Expand All @@ -44,6 +47,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
<TxType types={ tx.tx_types } isLoading={ isLoading }/>
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
{ isWvmArchiver && <WvmArchiverTag/> }
</HStack>
<TxAdditionalInfo tx={ tx } isMobile isLoading={ isLoading }/>
</Flex>
Expand Down
24 changes: 24 additions & 0 deletions ui/shared/statusTag/WvmArchiverTag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TagLabel, Tooltip } from '@chakra-ui/react';
import React from 'react';

import Tag from 'ui/shared/chakra/Tag';
import IconSvg from 'ui/shared/IconSvg';

const WvmArchiverTag = () => {

return (
<Tooltip>
<Tag
color="#fff"
backgroundColor="#52224D"
display="flex"
padding="2px 5px"
>
<IconSvg name="gear_slim" boxSize={ 2.5 } mr={ 1 } flexShrink={ 0 }/>
<TagLabel display="block">wvm-archiver</TagLabel>
</Tag>
</Tooltip>
);
};

export default WvmArchiverTag;
60 changes: 47 additions & 13 deletions ui/tx/details/TxInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { useWindowSize } from '@uidotdev/usehooks';
import BigNumber from 'bignumber.js';
import React from 'react';
import { RotatingLines } from 'react-loader-spinner';
import { scroller, Element } from 'react-scroll';

import type { Transaction } from 'types/api/transaction';
Expand All @@ -26,6 +27,7 @@ import { route } from 'nextjs-routes';
import config from 'configs/app';
import { WEI, WEI_IN_GWEI } from 'lib/consts';
import { useArweaveId } from 'lib/hooks/useArweaveId';
import { useWvmArchiver } from 'lib/hooks/useWvmArchiver';
import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
import getConfirmationDuration from 'lib/tx/getConfirmationDuration';
import { currencyUnits } from 'lib/units';
Expand All @@ -45,6 +47,7 @@ import IconSvg from 'ui/shared/IconSvg';
import LogDecodedInputData from 'ui/shared/logs/LogDecodedInputData';
import RawInputData from 'ui/shared/RawInputData';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import WvmArchiverTag from 'ui/shared/statusTag/WvmArchiverTag';
import TextSeparator from 'ui/shared/TextSeparator';
import TxFeeStability from 'ui/shared/tx/TxFeeStability';
import Utilization from 'ui/shared/Utilization/Utilization';
Expand Down Expand Up @@ -72,6 +75,7 @@ interface Props {
const TxInfo = ({ data, isLoading, socketStatus }: Props) => {
const size = useWindowSize();
const { colorMode } = useColorMode();
const isWvmArchiver = useWvmArchiver({ address: data?.from.hash });
const isSmallDevice = size.width && size.width < 768;
const wvmIconPath =
colorMode === 'light' ? 'networks/arweave-dark' : 'networks/arweave-light';
Expand Down Expand Up @@ -310,6 +314,20 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => {
</>
) }

{ isWvmArchiver && (
<>
<DetailsInfoItem.Label
hint="The external application source that generated this transaction"
isLoading={ isLoading }
>
Application
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
<WvmArchiverTag/>
</DetailsInfoItem.Value>
</>
) }

<DetailsInfoItem.Label
hint="Block number containing the transaction"
isLoading={ isLoading }
Expand Down Expand Up @@ -425,23 +443,39 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => {
<DetailsInfoItem.Value>
<IconSvg
name={ wvmIconPath }
width="5"
height="5"
width="20px"
height="20px"
display="block"
marginLeft="5px"
marginRight="5px"
borderRadius="full"
/>
<Link
isExternal
href={ `https://arweave.net/${ arweaveId }` }
rel="noopener noreferrer"
color="#00B774"
>
<EntityBase.Content text={ isSmallDevice ? truncateArweaveId(arweaveId) : arweaveId }/>
</Link>

<CopyToClipboard text={ arweaveId }/>
{ arweaveId === 'block_not_archived_or_backfilled' ? (
<>
<Text color={ colorMode === 'dark' ? '#1AFFB1' : '#00B774' } marginLeft="5px" marginRight="12px">Pending </Text>

<RotatingLines
strokeColor="grey"
strokeWidth="5"
animationDuration="0.75"
width="18"
visible={ true }
/>
</>
) : (
<>
<Link
isExternal
href={ `https://arweave.net/${ arweaveId }` }
rel="noopener noreferrer"
color={ colorMode === 'dark' ? '#1AFFB1' : '#00B774' }
marginLeft="5px"
>
<EntityBase.Content text={ isSmallDevice ? truncateArweaveId(arweaveId) : arweaveId }/>
</Link>

<CopyToClipboard text={ arweaveId }/>
</>
) }
</DetailsInfoItem.Value>
</>
) : (
Expand Down
4 changes: 4 additions & 0 deletions ui/txs/TxsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import type { Transaction } from 'types/api/transaction';
import config from 'configs/app';
import getValueWithUnit from 'lib/getValueWithUnit';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import { useWvmArchiver } from 'lib/hooks/useWvmArchiver';
import { space } from 'lib/html-entities';
import { currencyUnits } from 'lib/units';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import BlockEntity from 'ui/shared/entities/block/BlockEntity';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import WvmArchiverTag from 'ui/shared/statusTag/WvmArchiverTag';
import TxFeeStability from 'ui/shared/tx/TxFeeStability';
import TxWatchListTags from 'ui/shared/tx/TxWatchListTags';
import TxAdditionalInfo from 'ui/txs/TxAdditionalInfo';
Expand All @@ -33,6 +35,7 @@ type Props = {
}

const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeIncrement }: Props) => {
const isWvmArchiver = useWvmArchiver({ address: tx.from.hash });
const dataTo = tx.to ? tx.to : tx.created_contract;

const timeAgo = useTimeAgoIncrement(tx.timestamp, enableTimeIncrement);
Expand All @@ -47,6 +50,7 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
}
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
{ isWvmArchiver && <WvmArchiverTag/> }
</HStack>
<TxAdditionalInfo tx={ tx } isMobile isLoading={ isLoading }/>
</Flex>
Expand Down
Loading

0 comments on commit 65a330f

Please sign in to comment.