Skip to content

Commit 6cec3c9

Browse files
committed
update
1 parent 5314c26 commit 6cec3c9

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

apps/api-reference/src/components/EvmApi/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ export const EvmApi = <ParameterName extends string>({
251251
? {
252252
name: currentChain.name,
253253
rpcUrl: currentChain.rpcUrls.default.http[0] ?? "",
254-
contractAddress: getEvmPriceFeedContractAddress(chainId) ?? "",
254+
contractAddress:
255+
getEvmPriceFeedContractAddress(chainId) ?? "",
255256
}
256257
: { name: "", rpcUrl: "", contractAddress: "" },
257258
paramValues,

apps/api-reference/src/components/EvmApi/run-button.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { ContractFunctionExecutionError } from "viem";
1010
import { useAccount, useConfig } from "wagmi";
1111
import { readContract, simulateContract, writeContract } from "wagmi/actions";
1212

13-
1413
import type { Parameter } from "./parameter";
1514
import { TRANSFORMS } from "./parameter";
1615
import { useIsMounted } from "../../use-is-mounted";

apps/api-reference/src/components/EvmProvider/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
"use client";
22

3-
import { getEvmChainRpcUrl, getAllEvmChainsIds } from "@pythnetwork/contract-manager/utils/utils";
3+
import {
4+
getEvmChainRpcUrl,
5+
getAllEvmChainsIds,
6+
} from "@pythnetwork/contract-manager/utils/utils";
47
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
58
import { ConnectKitProvider, getDefaultConfig } from "connectkit";
69
import { useTheme } from "next-themes";
710
import type { ReactNode } from "react";
811
import * as chains from "viem/chains";
912
import { WagmiProvider, createConfig, http, useChainId } from "wagmi";
1013

11-
1214
import { metadata } from "../../metadata";
1315

14-
const CHAINS = getAllEvmChainsIds.map((id) =>
15-
Object.values(chains).find((chain) => chain.id === id),
16-
).filter((chain) => chain !== undefined) as unknown as readonly [
16+
const CHAINS = getAllEvmChainsIds
17+
.map((id) => Object.values(chains).find((chain) => chain.id === id))
18+
.filter((chain) => chain !== undefined) as unknown as readonly [
1719
chains.Chain,
1820
...chains.Chain[],
1921
];
@@ -34,7 +36,6 @@ const TRANSPORTS = Object.fromEntries(
3436
// chainEntries.filter((entry): entry is [number, ReturnType<typeof http>] => entry !== undefined)
3537
// ) as Record<number, ReturnType<typeof http>>;
3638

37-
3839
type EvmProviderProps = {
3940
children: ReactNode;
4041
walletConnectProjectId?: string | undefined;
Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,58 @@
1-
import evmChainsData from '../../store/chains/EvmChains.json';
2-
import evmPriceFeedContractsData from '../../store/contracts/EvmPriceFeedContracts.json';
3-
import evmWormholeContractsData from '../../store/contracts/EvmWormholeContracts.json';
1+
import evmChainsData from "../../store/chains/EvmChains.json";
2+
import evmPriceFeedContractsData from "../../store/contracts/EvmPriceFeedContracts.json";
3+
import evmWormholeContractsData from "../../store/contracts/EvmWormholeContracts.json";
44
import * as chains from "viem/chains";
55

6-
export const getEvmPriceFeedContractAddress = (chainId: number): `0x${string}` | undefined => {
6+
export const getEvmPriceFeedContractAddress = (
7+
chainId: number,
8+
): `0x${string}` | undefined => {
79
const chain = evmChainsData.find((c) => c.networkId === chainId);
810
if (!chain) {
911
return undefined;
1012
}
1113
const contract = evmPriceFeedContractsData.find((c) => c.chain === chain.id);
12-
if (!contract?.address || !contract.address.startsWith('0x')) {
14+
if (!contract?.address || !contract.address.startsWith("0x")) {
1315
return undefined;
1416
}
1517
return contract.address as `0x${string}`;
16-
}
18+
};
1719

18-
export const getEvmWormholeContractAddress = (chainId: number): `0x${string}` | undefined => {
20+
export const getEvmWormholeContractAddress = (
21+
chainId: number,
22+
): `0x${string}` | undefined => {
1923
const chain = evmChainsData.find((c) => c.networkId === chainId);
2024
if (!chain) {
2125
return undefined;
2226
}
2327
const contract = evmWormholeContractsData.find((c) => c.chain === chain.id);
24-
if (!contract?.address || !contract.address.startsWith('0x')) {
28+
if (!contract?.address || !contract.address.startsWith("0x")) {
2529
return undefined;
2630
}
2731
return contract.address as `0x${string}`;
28-
}
32+
};
2933

30-
export const getAllEvmChainsIds: number[] = evmChainsData.map((c) => c.networkId);
34+
export const getAllEvmChainsIds: number[] = evmChainsData.map(
35+
(c) => c.networkId,
36+
);
3137

3238
export const getEvmChainRpcUrl = (chainId: number): string | undefined => {
3339
const chain = evmChainsData.find((c) => c.networkId === chainId);
3440
if (!chain) {
3541
return undefined;
3642
}
37-
38-
43+
3944
// Let's try to use the viem chains without checking if they are working
40-
const viemChain = Object.values(chains).find((c: any) => c.id === chain.id);
45+
const viemChain = Object.values(chains).find(
46+
(c) => c.id === Number(chain.id),
47+
);
4148
if (viemChain && viemChain.rpcUrls && viemChain.rpcUrls.default) {
4249
return viemChain.rpcUrls.default.http[0];
43-
}
50+
}
4451

4552
// Now let's try to use the json rpc url
4653
if (chain.rpcUrl) {
4754
return chain.rpcUrl;
4855
}
49-
56+
5057
return undefined;
51-
}
58+
};

0 commit comments

Comments
 (0)