Skip to content

Commit 6700cac

Browse files
committed
dashboard: add testnet NTT accountant
1 parent ae37cdb commit 6700cac

File tree

6 files changed

+59
-27
lines changed

6 files changed

+59
-27
lines changed

dashboard/src/components/Accountant.tsx

+24-12
Original file line numberDiff line numberDiff line change
@@ -263,25 +263,37 @@ const overviewColumns = [
263263
}),
264264
];
265265

266-
function Accountant({ governorInfo }: { governorInfo: CloudGovernorInfo }) {
267-
const pendingTransferInfo = useGetAccountantPendingTransfers();
266+
function Accountant({
267+
governorInfo,
268+
accountantAddress,
269+
isNTT,
270+
}: {
271+
governorInfo?: CloudGovernorInfo;
272+
accountantAddress: string;
273+
isNTT?: boolean;
274+
}) {
275+
const pendingTransferInfo = useGetAccountantPendingTransfers(accountantAddress);
268276

269-
const accountsInfo = useGetAccountantAccounts();
277+
const accountsInfo = useGetAccountantAccounts(accountantAddress);
270278

271-
const tokenData = useTokenData();
279+
const tokenData = useTokenData(isNTT);
280+
281+
const governorInfoIsDefined = !!governorInfo;
272282

273283
const pendingTransfersForAcct: PendingTransferForAcct[] = useMemo(
274284
() =>
275285
pendingTransferInfo.map((transfer) => ({
276286
...transfer,
277-
isEnqueuedInGov: !!governorInfo.enqueuedVAAs.find(
278-
(vaa) =>
279-
vaa.emitterChain === transfer.key.emitter_chain &&
280-
vaa.emitterAddress === transfer.key.emitter_address &&
281-
vaa.sequence === transfer.key.sequence.toString()
282-
),
287+
isEnqueuedInGov:
288+
governorInfoIsDefined &&
289+
!!governorInfo.enqueuedVAAs.find(
290+
(vaa) =>
291+
vaa.emitterChain === transfer.key.emitter_chain &&
292+
vaa.emitterAddress === transfer.key.emitter_address &&
293+
vaa.sequence === transfer.key.sequence.toString()
294+
),
283295
})),
284-
[pendingTransferInfo, governorInfo.enqueuedVAAs]
296+
[pendingTransferInfo, governorInfoIsDefined, governorInfo?.enqueuedVAAs]
285297
);
286298

287299
const guardianSigningStats: GuardianSigningStat[] = useMemo(() => {
@@ -424,7 +436,7 @@ function Accountant({ governorInfo }: { governorInfo: CloudGovernorInfo }) {
424436
paddingRight: 1,
425437
}}
426438
>
427-
<Box>Accountant</Box>
439+
<Box>{isNTT ? 'NTT ' : ''}Accountant</Box>
428440
<Box flexGrow={1} />
429441
<Box sx={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
430442
{Object.keys(pendingByChain)

dashboard/src/components/Home.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import Governor from './Governor';
1111
import Guardians from './Guardians';
1212
import MainnetGovernor from './MainnetGovernor';
1313
import Monitor from './Monitor';
14+
import {
15+
ACCOUNTANT_CONTRACT_ADDRESS,
16+
NTT_ACCOUNTANT_CONTRACT_ADDRESS_TESTNET,
17+
} from '../utils/consts';
1418

1519
function Home({
1620
heartbeats,
@@ -37,7 +41,7 @@ function Home({
3741
<>
3842
<MainnetGovernor governorInfo={governorInfo} />
3943
<Divider />
40-
<Accountant governorInfo={governorInfo} />
44+
<Accountant governorInfo={governorInfo} accountantAddress={ACCOUNTANT_CONTRACT_ADDRESS} />
4145
<Divider />
4246
<MonitorSettingsProvider>
4347
<CollapsibleSection header="Monitor">
@@ -47,6 +51,12 @@ function Home({
4751
</>
4852
) : currentNetwork.name === 'Testnet' ? (
4953
<>
54+
<Accountant
55+
governorInfo={governorInfo}
56+
accountantAddress={NTT_ACCOUNTANT_CONTRACT_ADDRESS_TESTNET}
57+
isNTT
58+
/>
59+
<Divider />
5060
<MonitorSettingsProvider>
5161
<CollapsibleSection header="Monitor">
5262
<Monitor />

dashboard/src/hooks/useGetAccountantAccounts.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate';
22
import { useEffect, useState } from 'react';
33
import { useNetworkContext } from '../contexts/NetworkContext';
4-
import { ACCOUNTANT_CONTRACT_ADDRESS, WORMCHAIN_URL } from '../utils/consts';
4+
import { TESTNET_WORMCHAIN_URL, WORMCHAIN_URL } from '../utils/consts';
55

66
const POLL_INTERVAL_MS = 1 * 60 * 1000;
77
const PAGE_LIMIT = 2000; // throws a gas limit error over this
@@ -15,24 +15,26 @@ export type Account = {
1515
balance: string;
1616
};
1717

18-
const useGetAccountantAccounts = (): Account[] => {
18+
const useGetAccountantAccounts = (contractAddress: string): Account[] => {
1919
const { currentNetwork } = useNetworkContext();
2020
const [accountantInfo, setAccountantInfo] = useState<Account[]>([]);
2121

2222
useEffect(() => {
23-
if (currentNetwork.name !== 'Mainnet') {
23+
if (currentNetwork.name !== 'Mainnet' && currentNetwork.name !== 'Testnet') {
2424
return;
2525
}
2626
let cancelled = false;
2727
(async () => {
2828
while (!cancelled) {
2929
try {
30-
const cosmWasmClient = await CosmWasmClient.connect(WORMCHAIN_URL);
30+
const cosmWasmClient = await CosmWasmClient.connect(
31+
currentNetwork.name === 'Mainnet' ? WORMCHAIN_URL : TESTNET_WORMCHAIN_URL
32+
);
3133
let accounts: Account[] = [];
3234
let response;
3335
let start_after = undefined;
3436
do {
35-
response = await cosmWasmClient.queryContractSmart(ACCOUNTANT_CONTRACT_ADDRESS, {
37+
response = await cosmWasmClient.queryContractSmart(contractAddress, {
3638
all_accounts: {
3739
limit: PAGE_LIMIT,
3840
start_after,
@@ -59,7 +61,7 @@ const useGetAccountantAccounts = (): Account[] => {
5961
return () => {
6062
cancelled = true;
6163
};
62-
}, [currentNetwork]);
64+
}, [currentNetwork, contractAddress]);
6365

6466
return accountantInfo;
6567
};

dashboard/src/hooks/useGetAccountantPendingTransfers.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate';
22
import { useEffect, useState } from 'react';
33
import { useNetworkContext } from '../contexts/NetworkContext';
4-
import { ACCOUNTANT_CONTRACT_ADDRESS, WORMCHAIN_URL } from '../utils/consts';
4+
import { TESTNET_WORMCHAIN_URL, WORMCHAIN_URL } from '../utils/consts';
55

66
const POLL_INTERVAL_MS = 10 * 1000;
77
const PAGE_LIMIT = 2000; // throws a gas limit error over this
@@ -25,24 +25,26 @@ export type PendingTransfer = {
2525
];
2626
};
2727

28-
const useGetAccountantPendingTransfers = (): PendingTransfer[] => {
28+
const useGetAccountantPendingTransfers = (contractAddress: string): PendingTransfer[] => {
2929
const { currentNetwork } = useNetworkContext();
3030
const [accountantInfo, setAccountantInfo] = useState<PendingTransfer[]>([]);
3131

3232
useEffect(() => {
33-
if (currentNetwork.name !== 'Mainnet') {
33+
if (currentNetwork.name !== 'Mainnet' && currentNetwork.name !== 'Testnet') {
3434
return;
3535
}
3636
let cancelled = false;
3737
(async () => {
3838
while (!cancelled) {
3939
try {
40-
const cosmWasmClient = await CosmWasmClient.connect(WORMCHAIN_URL);
40+
const cosmWasmClient = await CosmWasmClient.connect(
41+
currentNetwork.name === 'Mainnet' ? WORMCHAIN_URL : TESTNET_WORMCHAIN_URL
42+
);
4143
let pending: PendingTransfer[] = [];
4244
let response;
4345
let start_after = undefined;
4446
do {
45-
response = await cosmWasmClient.queryContractSmart(ACCOUNTANT_CONTRACT_ADDRESS, {
47+
response = await cosmWasmClient.queryContractSmart(contractAddress, {
4648
all_pending_transfers: {
4749
limit: PAGE_LIMIT,
4850
start_after,
@@ -69,7 +71,7 @@ const useGetAccountantPendingTransfers = (): PendingTransfer[] => {
6971
return () => {
7072
cancelled = true;
7173
};
72-
}, [currentNetwork]);
74+
}, [currentNetwork, contractAddress]);
7375

7476
return accountantInfo;
7577
};

dashboard/src/hooks/useTokenData.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ export type TokenDataByChainAddress = {
1717
[chainAddress: string]: TokenDataEntry;
1818
};
1919

20-
function useTokenData(): TokenDataByChainAddress | null {
20+
function useTokenData(skip?: boolean): TokenDataByChainAddress | null {
2121
const { currentNetwork } = useNetworkContext();
2222
const [tokenData, setTokenData] = useState<TokenDataByChainAddress | null>(null);
2323
useEffect(() => {
24+
if (skip) return;
2425
let cancelled = false;
2526
(async () => {
2627
while (!cancelled) {
@@ -41,7 +42,7 @@ function useTokenData(): TokenDataByChainAddress | null {
4142
return () => {
4243
cancelled = true;
4344
};
44-
}, [currentNetwork]);
45+
}, [currentNetwork, skip]);
4546
return tokenData;
4647
}
4748
export default useTokenData;

dashboard/src/utils/consts.ts

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import xplaIcon from '../images/xpla.svg';
4141
require('dotenv').config();
4242

4343
export const WORMCHAIN_URL = 'https://tncnt-eu-wormchain-main-01.rpc.p2p.world';
44+
export const TESTNET_WORMCHAIN_URL = `https://corsproxy.io/?${encodeURIComponent(
45+
'https://gateway.testnet.xlabs.xyz'
46+
)}`;
4447

4548
export const CHAIN_ICON_MAP: { [key: string]: string } = {
4649
1: solanaIcon,
@@ -92,6 +95,8 @@ export const CHAIN_ICON_MAP: { [key: string]: string } = {
9295
export const JUMP_GUARDIAN_ADDRESS = '58cc3ae5c097b213ce3c81979e1b9f9570746aa5';
9396
export const ACCOUNTANT_CONTRACT_ADDRESS =
9497
'wormhole14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9srrg465';
98+
export const NTT_ACCOUNTANT_CONTRACT_ADDRESS_TESTNET =
99+
'wormhole169tvyx49zmjqhlv7mzwj8j2weprascc0jq3rdglw9pynldqx34nscvhc7k';
95100

96101
export const GUARDIAN_SET_3 = [
97102
{

0 commit comments

Comments
 (0)