Skip to content

Commit 1de92c1

Browse files
committed
dashboard: override NTT token address to map to metadata
1 parent e0527d4 commit 1de92c1

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

dashboard/src/components/Accountant.tsx

+20-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import useGetAccountantAccounts, { Account } from '../hooks/useGetAccountantAcco
3535
import useGetAccountantPendingTransfers, {
3636
PendingTransfer,
3737
} from '../hooks/useGetAccountantPendingTransfers';
38-
import useTokenData, { TokenDataEntry } from '../hooks/useTokenData';
38+
import { TokenDataByChainAddress, TokenDataEntry } from '../hooks/useTokenData';
3939
import {
4040
ACCOUNTANT_CONTRACT_ADDRESS,
4141
CHAIN_ICON_MAP,
@@ -47,6 +47,15 @@ import CollapsibleSection from './CollapsibleSection';
4747
import { ExplorerTxHash } from './ExplorerTxHash';
4848
import Table from './Table';
4949

50+
const NTT_ACCOUNTANT_TOKEN_ADDRESS_OVERRIDE: {
51+
[chain: number]: { [tokenAddress: string]: string };
52+
} = {
53+
1: {
54+
cf5f3614e2cd9b374558f35c7618b25f0d306d5e749b7d29cc030a1a15686238:
55+
'6927fdc01ea906f96d7137874cdd7adad00ca35764619310e54196c781d84d5b',
56+
},
57+
};
58+
5059
type PendingTransferForAcct = PendingTransfer & { isEnqueuedInGov: boolean };
5160
type AccountWithTokenData = Account & {
5261
tokenData: TokenDataEntry;
@@ -382,10 +391,12 @@ const MemoizedAccountantSearch = memo(AccountantSearch);
382391

383392
function Accountant({
384393
governorInfo,
394+
tokenData,
385395
accountantAddress,
386396
isNTT,
387397
}: {
388398
governorInfo?: CloudGovernorInfo;
399+
tokenData: TokenDataByChainAddress | null;
389400
accountantAddress: string;
390401
isNTT?: boolean;
391402
}) {
@@ -402,8 +413,6 @@ function Accountant({
402413

403414
const accountsInfo = useGetAccountantAccounts(accountantAddress);
404415

405-
const tokenData = useTokenData(isNTT);
406-
407416
const governorInfoIsDefined = !!governorInfo;
408417

409418
const pendingTransfersForAcct: PendingTransferForAcct[] = useMemo(
@@ -441,7 +450,13 @@ function Accountant({
441450

442451
const accountsWithTokenData: AccountWithTokenData[] = useMemo(() => {
443452
return accountsInfo.map<AccountWithTokenData>((a) => {
444-
const thisTokenData = tokenData?.[`${a.key.token_chain}/${a.key.token_address}`];
453+
let token_chain = a.key.token_chain;
454+
let token_address = a.key.token_address;
455+
if (isNTT) {
456+
token_address =
457+
NTT_ACCOUNTANT_TOKEN_ADDRESS_OVERRIDE[token_chain]?.[token_address] || token_address;
458+
}
459+
const thisTokenData = tokenData?.[`${token_chain}/${token_address}`];
445460
if (!thisTokenData)
446461
return {
447462
...a,
@@ -467,7 +482,7 @@ function Accountant({
467482
tvlTvm,
468483
};
469484
});
470-
}, [accountsInfo, tokenData]);
485+
}, [accountsInfo, tokenData, isNTT]);
471486
const tvlTvmPerChain: ChainTvlTvm[] = useMemo(
472487
() =>
473488
Object.values(

dashboard/src/components/Home.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Governor from './Governor';
1414
import Guardians from './Guardians';
1515
import MainnetGovernor from './MainnetGovernor';
1616
import Monitor from './Monitor';
17+
import useTokenData from '../hooks/useTokenData';
1718

1819
function Home({
1920
heartbeats,
@@ -26,6 +27,7 @@ function Home({
2627
}) {
2728
const { currentNetwork } = useNetworkContext();
2829
const governorInfo = useCloudGovernorInfo();
30+
const tokenData = useTokenData();
2931
return (
3032
<>
3133
<Chains chainIdsToHeartbeats={chainIdsToHeartbeats} />
@@ -40,10 +42,15 @@ function Home({
4042
<>
4143
<MainnetGovernor governorInfo={governorInfo} />
4244
<Divider />
43-
<Accountant governorInfo={governorInfo} accountantAddress={ACCOUNTANT_CONTRACT_ADDRESS} />
45+
<Accountant
46+
governorInfo={governorInfo}
47+
tokenData={tokenData}
48+
accountantAddress={ACCOUNTANT_CONTRACT_ADDRESS}
49+
/>
4450
<Divider />
4551
<Accountant
4652
governorInfo={governorInfo}
53+
tokenData={tokenData}
4754
accountantAddress={NTT_ACCOUNTANT_CONTRACT_ADDRESS_MAINNET}
4855
isNTT
4956
/>
@@ -54,6 +61,7 @@ function Home({
5461
<>
5562
<Accountant
5663
governorInfo={governorInfo}
64+
tokenData={tokenData}
5765
accountantAddress={NTT_ACCOUNTANT_CONTRACT_ADDRESS_TESTNET}
5866
isNTT
5967
/>

dashboard/src/hooks/useTokenData.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function useTokenData(skip?: boolean): TokenDataByChainAddress | null {
2424
if (skip) return;
2525
let cancelled = false;
2626
(async () => {
27+
setTokenData(null);
2728
while (!cancelled) {
2829
const response = await axios.get<{ data: TokenDataEntry[] }>(
2930
`${currentNetwork.endpoint}/latest-tokendata`

0 commit comments

Comments
 (0)