Skip to content

Commit 73c3db8

Browse files
committed
Restore TEE registry contract reads
1 parent e733f1d commit 73c3db8

14 files changed

Lines changed: 61 additions & 135 deletions

lib/opengradient/contracts/teeRegistry.ts

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,55 @@
11
import { ethers } from 'ethers';
22
import type { Address } from 'viem';
33

4-
import type { TEENodeWithStatus, TEEInfo, TEERegistryOverview, TEETypeInfo, TEETypeSummary } from 'lib/opengradient/teeRegistry';
5-
import { TEE_REGISTRY_ADDRESS } from 'lib/opengradient/teeRegistry';
6-
74
import TEERegistryAbi from './abi/TEERegistry.json';
85
import { ethDevnetProvider } from './providers';
96

7+
export const TEE_REGISTRY_ADDRESS = '0x4e72238852f3c918f4E4e57AeC9280dDB0c80248';
8+
109
const contract = new ethers.Contract(TEE_REGISTRY_ADDRESS, TEERegistryAbi, ethDevnetProvider);
1110

11+
export interface TEETypeInfo {
12+
typeId: number;
13+
name: string;
14+
addedAt: bigint;
15+
}
16+
17+
export interface TEEInfo {
18+
teeId: string;
19+
owner: Address;
20+
paymentAddress: Address;
21+
endpoint: string;
22+
publicKey: string;
23+
tlsCertificate: string;
24+
pcrHash: string;
25+
teeType: number;
26+
enabled: boolean;
27+
registeredAt: bigint;
28+
lastHeartbeatAt: bigint;
29+
}
30+
31+
export interface TEENodeWithStatus extends TEEInfo {
32+
isActive: boolean;
33+
}
34+
35+
export interface TEETypeSummary {
36+
typeId: number;
37+
name: string;
38+
totalNodes: number;
39+
enabledNodes: number;
40+
activeNodes: number;
41+
approvedPCRs: number;
42+
addedAt: bigint;
43+
}
44+
45+
export interface TEERegistryStats {
46+
totalTypes: number;
47+
totalNodes: number;
48+
activeNodes: number;
49+
enabledNodes: number;
50+
approvedPCRs: number;
51+
}
52+
1253
export const getTEETypes = async(): Promise<Array<TEETypeInfo>> => {
1354
const [ typeIds, infos ] = await contract.getTEETypes();
1455

@@ -68,7 +109,11 @@ export const getHeartbeatMaxAge = async(): Promise<bigint> => {
68109
/**
69110
* Fetch full registry overview: types, nodes per type with status, and global stats.
70111
*/
71-
export const getTEERegistryOverviewFromContract = async(): Promise<TEERegistryOverview> => {
112+
export const getTEERegistryOverview = async(): Promise<{
113+
types: Array<TEETypeSummary>;
114+
stats: TEERegistryStats;
115+
nodesByType: Record<number, Array<TEENodeWithStatus>>;
116+
}> => {
72117
// 1. Get all TEE types
73118
const types = await getTEETypes();
74119

@@ -141,3 +186,5 @@ export const getTEERegistryOverviewFromContract = async(): Promise<TEERegistryOv
141186
nodesByType,
142187
};
143188
};
189+
190+
export const TEE_REGISTRY_QUERY_KEY = [ 'opengradient', 'teeRegistry' ];

lib/opengradient/teeRegistry.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.

pages/api/opengradient/tee-registry.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

ui/home/HeroBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
import { route } from 'nextjs-routes';
66

77
import useApiQuery from 'lib/api/useApiQuery';
8-
import { getTEERegistryOverview, TEE_REGISTRY_QUERY_KEY } from 'lib/opengradient/teeRegistry';
8+
import { getTEERegistryOverview, TEE_REGISTRY_QUERY_KEY } from 'lib/opengradient/contracts/teeRegistry';
99
import { HOMEPAGE_STATS, HOMEPAGE_STATS_MICROSERVICE } from 'stubs/stats';
1010
import { LinkBox, LinkOverlay } from 'toolkit/chakra/link';
1111
import { Skeleton } from 'toolkit/chakra/skeleton';

ui/home/TrustedExecution.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
import { route } from 'nextjs-routes';
66

77
import dayjs from 'lib/date/dayjs';
8-
import { getTEERegistryOverview, TEE_REGISTRY_QUERY_KEY, TEE_REGISTRY_ADDRESS, type TEENodeWithStatus } from 'lib/opengradient/teeRegistry';
8+
import { getTEERegistryOverview, TEE_REGISTRY_QUERY_KEY, TEE_REGISTRY_ADDRESS, type TEENodeWithStatus } from 'lib/opengradient/contracts/teeRegistry';
99
import { Link } from 'toolkit/chakra/link';
1010
import { Skeleton } from 'toolkit/chakra/skeleton';
1111
import { PLACEHOLDER_TEE_REGISTRY_STATS, PLACEHOLDER_TEE_TYPES } from 'ui/opengradient/teeRegistry/placeholders';
@@ -143,6 +143,7 @@ const TrustedExecution = () => {
143143
.sort((a, b) => Number(b.lastHeartbeatAt - a.lastHeartbeatAt));
144144
}, [ query.data?.nodesByType ]);
145145
const primaryType = types[0];
146+
const visibleNodes = nodes.slice(0, 3);
146147
const isLoading = query.isPlaceholderData;
147148

148149
return (
@@ -308,7 +309,7 @@ const TrustedExecution = () => {
308309
</Text>
309310
</Flex>
310311
<VStack align="stretch" gap={ 0 }>
311-
{ nodes.length > 0 ? nodes.map((node) => (
312+
{ visibleNodes.length > 0 ? visibleNodes.map((node) => (
312313
<NodePreview key={ node.teeId } node={ node } loading={ isLoading }/>
313314
)) : (
314315
<Text py={ 5 } fontSize="13px" color={ text.muted }>
-106 KB
Loading
36.2 KB
Loading

ui/opengradient/teeRegistry/TEENodeDetailDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Box, Flex, Text, VStack } from '@chakra-ui/react';
22
import React from 'react';
33

44
import dayjs from 'lib/date/dayjs';
5-
import type { TEENodeWithStatus } from 'lib/opengradient/teeRegistry';
5+
import type { TEENodeWithStatus } from 'lib/opengradient/contracts/teeRegistry';
66
import { DrawerBackdrop, DrawerBody, DrawerCloseTrigger, DrawerContent, DrawerHeader, DrawerRoot, DrawerTitle } from 'toolkit/chakra/drawer';
77
import { OPENGRADIENT_BRAND } from 'ui/opengradient/brand';
88
import AddressEntity from 'ui/shared/entities/address/AddressEntity';

ui/opengradient/teeRegistry/TEENodesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Box, Flex, Text } from '@chakra-ui/react';
22
import React from 'react';
33

44
import dayjs from 'lib/date/dayjs';
5-
import type { TEENodeWithStatus, TEETypeSummary } from 'lib/opengradient/teeRegistry';
5+
import type { TEENodeWithStatus, TEETypeSummary } from 'lib/opengradient/contracts/teeRegistry';
66
import { Skeleton } from 'toolkit/chakra/skeleton';
77
import { TableBody, TableCell, TableColumnHeader, TableHeaderSticky, TableRoot, TableRow } from 'toolkit/chakra/table';
88
import { OPENGRADIENT_BRAND } from 'ui/opengradient/brand';

ui/opengradient/teeRegistry/TEETypeCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box, Flex, Grid, Text } from '@chakra-ui/react';
22
import React from 'react';
33

4-
import type { TEETypeSummary } from 'lib/opengradient/teeRegistry';
4+
import type { TEETypeSummary } from 'lib/opengradient/contracts/teeRegistry';
55
import { Skeleton } from 'toolkit/chakra/skeleton';
66
import { OPENGRADIENT_BRAND } from 'ui/opengradient/brand';
77

0 commit comments

Comments
 (0)