Skip to content

Commit

Permalink
fix: build error and missed part in token-monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
bojan07 committed Oct 17, 2023
1 parent 5198378 commit d9de1a8
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions packages/dapp/components/monitor/token-monitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -17,27 +16,24 @@ type TokenMonitorProps = {

const TokenMonitorContainer = () => {
const protocolContracts = useProtocolContracts();
const { creditNft, dollarToken } = useManagerManaged() || {};
const [tokenMonitorPRops, setTokenMonitorProps] = useState<State>(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 && <TokenMonitor {...tokenMonitorPRops} />;
};
Expand Down

0 comments on commit d9de1a8

Please sign in to comment.