Skip to content

Commit

Permalink
feat: added total supply fetching, temporarily removed protocol history
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Dec 5, 2023
1 parent e63740b commit f9a54f6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/app/components/protocol-history/protocol-history.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Text, VStack } from "@chakra-ui/react";
// import { Text, VStack } from "@chakra-ui/react";

import { exampleProtocolHistoryItems } from "@shared/examples/example-protocol-history-items";
// import { exampleProtocolHistoryItems } from "@shared/examples/example-protocol-history-items";

import { ProtocolHistoryItem } from "./components/protocol-history-item";
// import { ProtocolHistoryItem } from "./components/protocol-history-item";
import { ProtocolHistoryLayout } from "./components/protocol-history.layout";
import { scrollBarCSS } from "../../../styles/css-styles";
// import { scrollBarCSS } from "../../../styles/css-styles";

export function ProtocolHistory(): React.JSX.Element {
return (
<ProtocolHistoryLayout>
<Text alignContent={"start"} color={"white.01"} fontSize={"lg"}>
{/* <Text alignContent={"start"} color={"white.01"} fontSize={"lg"}>
Protocol History
</Text>
<VStack
Expand All @@ -22,7 +22,7 @@ export function ProtocolHistory(): React.JSX.Element {
{exampleProtocolHistoryItems.map((item) => (
<ProtocolHistoryItem key={item.id} {...item} />
))}
</VStack>
</VStack> */}
</ProtocolHistoryLayout>
);
}
8 changes: 3 additions & 5 deletions src/app/hooks/use-ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ export function useEthereum(): UseEthereumReturnType {
}

async function getTotalSupply() {
const provider = ethers.providers.getDefaultProvider('https://testrpc.x1.tech')
const provider = ethers.providers.getDefaultProvider('https://ethereum-sepolia.publicnode.com/')
const branchName = import.meta.env.VITE_ETHEREUM_DEPLOYMENT_BRANCH;
const contractVersion = import.meta.env.VITE_ETHEREUM_DEPLOYMENT_VERSION;
const deploymentPlanURL = `https://raw.githubusercontent.com/DLC-link/dlc-solidity/${branchName}/deploymentFiles/x1test/v${contractVersion}/DLCBTC.json`;
const deploymentPlanURL = `https://raw.githubusercontent.com/DLC-link/dlc-solidity/${branchName}/deploymentFiles/sepolia/v${contractVersion}/DLCBTC.json`;

try {
const response = await fetch(deploymentPlanURL);
Expand All @@ -126,10 +126,8 @@ export function useEthereum(): UseEthereumReturnType {
true,
));
} catch (error) {
console.log('error', error)

throw new EthereumError(
`Could not fetch deployment info for ${'asdkasdkads'} on ${'asdasd'}`,
`Could not fetch total supply info: ${error}}`,
);
}}

Expand Down
11 changes: 5 additions & 6 deletions src/app/hooks/use-observer.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { Dispatch, useEffect } from "react";
import { useSelector } from "react-redux";
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";

import { VaultState } from "@models/vault";
import { RootState } from "@store/index";
import { mintUnmintActions } from "@store/slices/mintunmint/mintunmint.actions";
import { AnyAction } from "redux";
import { UseEthereumReturnType } from "./use-ethereum";
import { modalActions } from "@store/slices/modal/modal.actions";
import { VaultState } from "@models/vault";
import { UseEthereumReturnType } from "./use-ethereum";

export function useObserver(
ethereum: UseEthereumReturnType,
dispatch: Dispatch<AnyAction>,
): void {
const dispatch = useDispatch();
const { address, network } = useSelector((state: RootState) => state.account);
const {
protocolContract,
Expand Down
4 changes: 1 addition & 3 deletions src/app/providers/blockchain-context-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { createContext } from "react";
import { useDispatch } from "react-redux";

import { UseBitcoinReturnType, useBitcoin } from "@hooks/use-bitcoin";
import { UseEthereumReturnType, useEthereum } from "@hooks/use-ethereum";
Expand All @@ -17,11 +16,10 @@ export const BlockchainContext = createContext<BlockchainContextType | null>(
export function BlockchainContextProvider({
children,
}: HasChildren): React.JSX.Element {
const dispatch = useDispatch();
const ethereum = useEthereum();
const bitcoin = useBitcoin();

useObserver(ethereum, dispatch);
useObserver(ethereum);

return (
<BlockchainContext.Provider value={{ ethereum, bitcoin }}>
Expand Down
1 change: 0 additions & 1 deletion src/app/store/slices/modal/modal.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const modalSlice = createSlice({
state.isSelectWalletModalOpen = !state.isSelectWalletModalOpen;
},
toggleSuccessfulFlowModalVisibility: (state, action) => {
console.log(action.payload);
state.isSuccesfulFlowModalOpen = [
!state.isSuccesfulFlowModalOpen[0],
action.payload,
Expand Down

0 comments on commit f9a54f6

Please sign in to comment.