Skip to content

Commit 2eb1ee8

Browse files
committed
chore(dev-docs): update entropy edits-2
1 parent 86c3dfb commit 2eb1ee8

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

apps/developer-hub/src/components/EntropyTable/entropy-api-data-fetcher.tsx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ const ApiChainConfigSchema = z.object({
1212
default_fee: z.number(),
1313
});
1414

15-
type ApiChainConfig = z.infer<typeof ApiChainConfigSchema>;
16-
17-
const entropyDeploymentsSchema = z.array(ApiChainConfigSchema);
18-
1915
export type EntropyDeployment = {
2016
address: string;
2117
delay: string;
@@ -26,13 +22,11 @@ export type EntropyDeployment = {
2622
nativeCurrency?: string;
2723
};
2824

29-
const getChainData = (network_id: number) => {
25+
function getChainData(network_id: number) {
3026
return Object.values(chains).find((chain) => chain.id === network_id);
31-
};
27+
}
3228

33-
const transformChainData = (
34-
chain: ApiChainConfig,
35-
): [string, EntropyDeployment] => {
29+
const apiChainConfigToEntrySchema = ApiChainConfigSchema.transform((chain) => {
3630
const viemChainData = getChainData(chain.network_id);
3731

3832
const configOverride = EntropyDeploymentsConfig[chain.network_id];
@@ -55,18 +49,15 @@ const transformChainData = (
5549
...(nativeCurrency ? { nativeCurrency } : {}),
5650
};
5751

58-
return [chain.name, deployment];
59-
};
52+
return [chain.name, deployment] as const;
53+
});
6054

61-
export const fetchEntropyDeployments = async (
62-
url: string,
63-
): Promise<Record<string, EntropyDeployment>> => {
64-
try {
65-
const response = await fetch(url);
66-
const apiData = entropyDeploymentsSchema.parse(await response.json());
55+
const entropyDeploymentsSchema = z.array(apiChainConfigToEntrySchema);
6756

68-
return Object.fromEntries(apiData.map((item) => transformChainData(item)));
69-
} catch (error_) {
70-
throw new Error(String(error_));
71-
}
72-
};
57+
export async function fetchEntropyDeployments(
58+
url: string,
59+
): Promise<Record<string, EntropyDeployment>> {
60+
const response = await fetch(url);
61+
const entries = entropyDeploymentsSchema.parse(await response.json());
62+
return Object.fromEntries(entries);
63+
}

apps/developer-hub/src/components/EntropyTable/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ export const EntropyTable = ({ isMainnet }: { isMainnet: boolean }) => {
4646
case StateType.Loaded: {
4747
return <EntropyTableContent chains={state.chains} />;
4848
}
49-
default: {
50-
throw new Error(`Unknown state type: ${typeof state}`);
51-
}
5249
}
5350
};
5451

0 commit comments

Comments
 (0)