Skip to content

Commit

Permalink
removed deprecated & commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
gruvin committed Sep 11, 2024
1 parent e774c6e commit 8b7d05c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 58 deletions.
18 changes: 0 additions & 18 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,6 @@ function App() {
type: "function",
},
];
// useQuery([networkName, "UsdHex"], getMainnetUsdHex, {
// enabled: chainId == 1,
// refetchInterval: 10000,
// retry: 5,
// retryDelay: 5000,
// onSuccess: (data) => setUSDHEX(data),
// });

const { data: price } = useContractRead({
address: "0xF6DCdce0ac3001B2f67F750bc64ea5beB37B5824", // Uniswap v2 HEX / USDC
Expand All @@ -293,17 +286,6 @@ function App() {
setUSDHEX(price || 0.00);
}, [price]);

// Refetch Mainnet Price every 10 seconds
// useEffect(() => {
// let interval: NodeJS.Timer | undefined = undefined;
// if (chainId == 1) {
// interval = setInterval(() => {
// refetchMainnetPrice();
// }, 10000);
// return () => clearInterval(interval);
// } else if (interval) clearInterval(interval);
// }, [refetchMainnetPrice, chainId]);

// start the show when walletAddress appears
// Lo and behold! Hardhat (Viem) appears to come with Multicall3 built in.
useContractReads({
Expand Down
31 changes: 14 additions & 17 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,21 @@ const chains = [mainnet, goerli, pulsechain, pulsechainV4, hardhat]

// ref: https://wagmi.sh/react/providers/configuring-chains
const projectId = import.meta.env.VITE_WALLET_CONNECT_ID
const { publicClient } = configureChains(
chains,
[
// jsonRpcProvider({
// rpc: (chain) => {
// if (chain.id == 943) return {
// http: "http://pulsechainv4.local:8545",
// webSocket: `ws://pulsechainv4.local:8546`,
// }
// return null
// }
// }),
const { publicClient } = configureChains(chains, [
// jsonRpcProvider({
// rpc: (chain) => {
// if (chain.id == 943) return {
// http: "http://pulsechainv4.local:8545",
// webSocket: `ws://pulsechainv4.local:8546`,
// }
// return null
// }
// }),

// it seems to matter that w3wmprovider comes FIRST
w3mProvider({ projectId }),
infuraProvider({ apiKey: import.meta.env.VITE_INFURA_ID }),
],
)
// it seems to matter that w3wmprovider comes FIRST. Probably due to rate limiting with Infura free account?
w3mProvider({ projectId }),
infuraProvider({ apiKey: import.meta.env.VITE_INFURA_ID }), // apparently not used, because w3mProvider takes precedence?
]);

const wagmiConfig = createConfig({
autoConnect: true,
Expand Down
23 changes: 0 additions & 23 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,6 @@ import _debug from 'debug'
const debug = _debug("util")
debug("loaded")

// export const getMainnetUsdHex = async () => {
// const response = await axios.get("https://uniswapdataapi.azurewebsites.net/api/hexPrice")
// debug("HEX-USD: ", response.data?.hexUsd)
// return parseFloat(response.data?.hexUsd || "?.??")
// }

export const getMainnetUsdHex = async () => {
const response = await axios.post(
"https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2",
{
query: '{pair(id:"0xF6DCdce0ac3001B2f67F750bc64ea5beB37B5824"){token1Price}}' // HEX-USDC, where token1Price => USDC per HEX
},
{
headers: {
"Content-Type": "application/json",
},
responseType: "json",
}
)
debug("HEX-USDC: ", response.data.data.pair.token1Price)
return parseFloat(response.data.data.pair?.token1Price || "?.??")
}

export const getPulseXDaiHex = async () => {
const response = await axios.post("https://graph.pulsechain.com/subgraphs/name/pulsechain/pulsex", {
query: '{pair(id:"0x6f1747370b1cacb911ad6d4477b718633db328c8"){token1Price}}' // HEX/DAI, where token1Price => DAI per HEX
Expand Down

0 comments on commit 8b7d05c

Please sign in to comment.