Add button to watch rep token in metamask
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 37s Details

This commit is contained in:
Ladd Hoffman 2024-03-14 21:26:31 -05:00
parent 753b54be70
commit 55d40c6c4e
1 changed files with 16 additions and 12 deletions

View File

@ -211,6 +211,10 @@ function App() {
setWork1(work1Contract);
setDAO(DAOContract);
/* -------------------------------------------------------------------------------- */
/* --------------------------- BEGIN EVENT HANDLERS ------------------------------- */
/* -------------------------------------------------------------------------------- */
DAOContract.events.PostAdded({ fromBlock: 'latest' }).on('data', (event) => {
console.log('event: post added', event);
fetchPost(event.returnValues.postIndex);
@ -281,17 +285,17 @@ function App() {
}
}, [sdk]);
// const watchReputationToken = useCallback(async () => {
// await provider.request({
// method: 'wallet_watchAsset',
// params: {
// type: 'ERC20',
// options: {
// address: DAOAddress,
// },
// },
// });
// }, [provider]);
const watchReputationToken = useCallback(async () => {
await provider.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: contracts[chainId].DAO,
},
},
});
}, [provider, chainId]);
const addPost = useCallback(async () => {
await DAO.methods.addPost(account).send({
@ -432,6 +436,7 @@ function App() {
</div>
<div>
<Button onClick={() => disconnect()}>Disconnect</Button>
<Button onClick={() => watchReputationToken()}>Watch REP in MetaMask</Button>
</div>
</Stack>
</Col>
@ -439,7 +444,6 @@ function App() {
</Container>
<Tabs>
<Tab eventKey="admin" title="Admin">
<div>
{`Posts count: ${posts.length}`}
</div>