Skip to content

Commit

Permalink
(registry) feat: update address links to support mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanya-atatakai committed Oct 23, 2024
1 parent d8375c5 commit 25ddd7f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
8 changes: 7 additions & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,10 @@ c286a015e94a4abfa474749e6d0d38d944b25e8b:apps/govern/common-util/Contracts/addre
6cf8d7df061c4bdb1e3ccbb8dbf3585b715ad874:apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx:generic-api-key:53
dcc2ad3b708d9ac49cf82b6e0401fdf78531fa05:apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx:generic-api-key:53
bc71dcb01b1c2619cc3805ad410fabc6f97b6e6d:apps/bond/components/Paths/data.json:generic-api-key:208
613a7a61c1721d690c3ab3055e8fe97471c91a58:apps/bond/components/Paths/data.json:generic-api-key:168
613a7a61c1721d690c3ab3055e8fe97471c91a58:apps/bond/components/Paths/data.json:generic-api-key:168
d8375c535fba0ffcd1161714448dc92a84b17858:apps/autonolas-registry/common-util/Contracts/addresses.tsx:generic-api-key:63
d8375c535fba0ffcd1161714448dc92a84b17858:apps/autonolas-registry/common-util/Contracts/addresses.tsx:generic-api-key:65
d8375c535fba0ffcd1161714448dc92a84b17858:apps/autonolas-registry/common-util/Contracts/addresses.tsx:generic-api-key:125
d8375c535fba0ffcd1161714448dc92a84b17858:apps/autonolas-registry/common-util/Contracts/addresses.tsx:generic-api-key:127
d8375c535fba0ffcd1161714448dc92a84b17858:apps/autonolas-registry/common-util/Contracts/addresses.tsx:generic-api-key:131
d8375c535fba0ffcd1161714448dc92a84b17858:apps/autonolas-registry/common-util/Contracts/addresses.tsx:generic-api-key:133
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, Space } from 'antd';

import { AddressLink, NA, areAddressesEqual } from '@autonolas/frontend-library';
import { AddressLink as AddressLinkSimple } from 'libs/ui-components/src';

import {
HASH_PREFIX,
Expand Down Expand Up @@ -145,9 +146,9 @@ export const getTableColumns = (
dataIndex: 'owner',
key: 'owner',
width: 200,
render: (text) => {
render: (text, record) => {
if (!text || text === NA) return NA;
return <AddressLink {...addressLinkProps} text={text} chainName={chainName} />;
return <AddressLinkSimple address={record.owner} chainId={chainId} />;
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Space, Table } from 'antd';
import { Space, Table, Flex } from 'antd';
import PropTypes from 'prop-types';
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import { AddressLink } from '@autonolas/frontend-library';
import { AddressLink } from 'libs/ui-components/src';

import { SendTransactionButton } from 'common-util/TransactionHelpers/SendTransactionButton';
import { useHelpers } from 'common-util/hooks/useHelpers';
import { useScreen } from 'common-util/hooks/useScreen';

import { setAgentInstancesAndOperators } from '../../../../store/service';
import { useAgentInstanceAndOperator } from '../../hooks/useSvmService';
Expand All @@ -24,8 +23,7 @@ export const Deployed = ({
handleTerminate,
}) => {
const dispatch = useDispatch();
const { account, chainId, isSvm, chainName } = useHelpers();
const { isMobile } = useScreen();
const { account, chainId, isSvm } = useHelpers();
const data = useSelector((state) => state?.service?.agentInstancesAndOperators);
const [isTerminating, setIsTerminating] = useState(false);
const { getSvmAgentInstanceAndOperator } = useAgentInstanceAndOperator();
Expand Down Expand Up @@ -60,15 +58,6 @@ export const Deployed = ({
}
};

const addressLinkProps = useMemo(
() => ({
chainId,
chainName,
suffixCount: isMobile ? 4 : 6,
}),
[chainName, isMobile, chainId],
);

return (
<div className="step-4-deployed" data-testid="step-deployed">
<Space direction="vertical" size={10} className="full-width">
Expand All @@ -83,23 +72,23 @@ export const Deployed = ({
title: 'Agent Instances',
dataIndex: 'agentInstance',
key: 'agentInstance',
render: (text) => <AddressLink text={text} {...addressLinkProps} />,
render: (text) => <AddressLink address={text} chainId={chainId} />,
width: '50%',
},
{
title: 'Operators',
dataIndex: 'operatorAddress',
key: 'operatorAddress',
render: (text) => <AddressLink text={text} {...addressLinkProps} />,
render: (text) => <AddressLink address={text} chainId={chainId} />,
width: '50%',
},
]}
/>
)}
<div>
<Flex gap={8}>
{`${isSvm ? 'Squads' : 'Safe'} contract address:`}
<AddressLink text={multisig} {...addressLinkProps} />
</div>
<AddressLink address={multisig} chainId={chainId} />
</Flex>
{getButton(
<SendTransactionButton
onClick={onTerminate}
Expand Down
2 changes: 2 additions & 0 deletions libs/ui-components/src/lib/AddressLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EXPLORER_URLS, UNICODE_SYMBOLS } from 'libs/util-constants/src';
// eslint-disable-next-line @nx/enforce-module-boundaries
import { truncateAddress } from 'libs/util-functions/src';

export const AddressLink = ({
Expand All @@ -15,6 +16,7 @@ export const AddressLink = ({
target="_blank"
rel="noreferrer"
className={className}
title={address}
>
{`${truncateAddress(address)} ${UNICODE_SYMBOLS.EXTERNAL_LINK}`}
</a>
Expand Down
26 changes: 25 additions & 1 deletion libs/util-constants/src/lib/exploreUrls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import { arbitrum, base, celo, gnosis, mainnet, optimism, polygon } from 'viem/chains';
import {
arbitrum,
arbitrumSepolia,
base,
baseSepolia,
celo,
celoAlfajores,
gnosis,
gnosisChiado,
goerli,
mainnet,
mode,
optimism,
optimismSepolia,
polygon,
polygonMumbai,
} from 'viem/chains';

export const EXPLORER_URLS: Record<string, string> = {
[mainnet.id]: mainnet.blockExplorers.default.url,
Expand All @@ -8,4 +24,12 @@ export const EXPLORER_URLS: Record<string, string> = {
[base.id]: base.blockExplorers.default.url,
[arbitrum.id]: arbitrum.blockExplorers.default.url,
[celo.id]: celo.blockExplorers.default.url,
[mode.id]: mode.blockExplorers.default.url,
[goerli.id]: goerli.blockExplorers.default.url,
[gnosisChiado.id]: gnosisChiado.blockExplorers.default.url,
[polygonMumbai.id]: polygonMumbai.blockExplorers.default.url,
[baseSepolia.id]: baseSepolia.blockExplorers.default.url,
[arbitrumSepolia.id]: arbitrumSepolia.blockExplorers.default.url,
[optimismSepolia.id]: optimismSepolia.blockExplorers.default.url,
[celoAlfajores.id]: celoAlfajores.blockExplorers.default.url,
};

0 comments on commit 25ddd7f

Please sign in to comment.