Skip to content

Commit

Permalink
Merge pull request #27 from stabilitydao/develop
Browse files Browse the repository at this point in the history
#11 home treasure balance
  • Loading branch information
a17 authored Jan 3, 2022
2 parents fc39acf + 897cd42 commit 9e72736
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/components/view/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
updateIsWalletOption
} from "@/redux/slices/modalsSlice";
import {showAlert} from "@/src/components/alert";
import {tl} from "@/src/wallet";
const appEnabled = {
[POLYGON]: true,
[ROPSTEN]: true,
Expand All @@ -39,9 +40,33 @@ function Home() {
const network = chainId ? chainId : currentNetwork
const [stakedBalance, setstakedBalance] = useState(null)
const token = useSelector(state => state.token)
const [treasureBalances, setTreasureBalances] = useState({})

const dividends = payers;

useEffect(async () => {
let contract
const balances = {}

if (tl[network]) {
contract = new web3.eth.Contract(tokenAbi, addresses[network].weth);
const wethBal = await contract.methods.balanceOf(tl[network]).call()
if (wethBal > 0) {
balances.weth = web3.utils.fromWei(wethBal)
}

if (addresses[network].token) {
contract = new web3.eth.Contract(tokenAbi, addresses[network].token);
const profitBal = await contract.methods.balanceOf(tl[network]).call()
if (profitBal > 0) {
balances.profit = web3.utils.fromWei(profitBal)
}
}
}

setTreasureBalances(balances)
}, [network])

useEffect(() => {
if (web3 && web3.eth.net.isListening() && network) {
if (addresses[network].token) {
Expand Down Expand Up @@ -84,7 +109,7 @@ function Home() {
setpendingPayment(pending / 10 ** 18)
})
}
}, [network, active])
}, [network])


useEffect(() => {
Expand Down Expand Up @@ -355,7 +380,11 @@ function Home() {
<tbody>
<tr>
<td>Treasure</td>
<td className="text-right">-</td>
<td className="text-right">{Object.keys(treasureBalances).length ? Object.keys(treasureBalances).map(cur => {
return (
<span className="ml-2" key={cur}>{treasureBalances[cur]} {cur.toUpperCase()}</span>
)
}) : '-'}</td>
</tr>
<tr>
<td>Proposals</td>
Expand Down

1 comment on commit 9e72736

@vercel
Copy link

@vercel vercel bot commented on 9e72736 Jan 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.