From d9de1a8b8d63144341b4539845eac403055cfa69 Mon Sep 17 00:00:00 2001 From: bojan07 Date: Tue, 17 Oct 2023 12:54:20 -0400 Subject: [PATCH] fix: build error and missed part in token-monitor --- .../dapp/components/monitor/token-monitor.tsx | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/dapp/components/monitor/token-monitor.tsx b/packages/dapp/components/monitor/token-monitor.tsx index ac059ec37..84500c0e7 100644 --- a/packages/dapp/components/monitor/token-monitor.tsx +++ b/packages/dapp/components/monitor/token-monitor.tsx @@ -2,7 +2,6 @@ import { useState } from "react"; import { formatEther } from "@/lib/format"; import useProtocolContracts from "@/components/lib/hooks/contracts/use-protocol-contracts"; -import useManagerManaged from "../lib/hooks/contracts/use-manager-managed"; // import Address from "./ui/Address"; import Balance from "./ui/balance"; import useEffectAsync from "../lib/hooks/use-effect-async"; @@ -17,27 +16,24 @@ type TokenMonitorProps = { const TokenMonitorContainer = () => { const protocolContracts = useProtocolContracts(); - const { creditNft, dollarToken } = useManagerManaged() || {}; const [tokenMonitorPRops, setTokenMonitorProps] = useState(null); useEffectAsync(async () => { const contracts = await protocolContracts; - if (contracts && contracts.creditNftManagerFacet) { - if (creditNft && dollarToken) { - const [totalOutstandingCredit, totalRedeemable] = await Promise.all([ - creditNft.getTotalOutstandingCredit(), - dollarToken.balanceOf(contracts.creditNftManagerFacet.address), - ]); - - setTokenMonitorProps({ - creditNftAddress: creditNft.address, - creditNftManagerAddress: contracts.creditNftManagerFacet.address, - totalOutstandingCredit: +formatEther(totalOutstandingCredit), - totalRedeemable: +formatEther(totalRedeemable), - }); - } + if (contracts && contracts.creditNft && contracts.creditNftManagerFacet) { + const [totalOutstandingCredit, totalRedeemable] = await Promise.all([ + contracts.creditNft?.getTotalOutstandingDebt(), + contracts.dollarToken?.balanceOf(contracts.creditNftManagerFacet.address), + ]); + + setTokenMonitorProps({ + creditNftAddress: contracts.creditNft.address, + creditNftManagerAddress: contracts.creditNftManagerFacet.address, + totalOutstandingCredit: +formatEther(totalOutstandingCredit), + totalRedeemable: +formatEther(totalRedeemable), + }); } - }, [creditNft, dollarToken]); + }, []); return tokenMonitorPRops && ; };