From 626905bad6c3f920d976c9ef213aea26d3ae83b1 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Fri, 19 Apr 2024 18:07:48 -0500 Subject: [PATCH] add multi-author support to frontend --- frontend/{src => }/contract-addresses.json | 8 +-- frontend/src/App.jsx | 38 +++++++----- frontend/src/assets/DAO.json | 58 +++++++++++++++---- frontend/src/assets/Onboarding.json | 4 +- frontend/src/assets/Proposals.json | 4 +- frontend/src/assets/Work1.json | 4 +- .../src/components/posts/AddPostModal.jsx | 2 +- .../src/components/posts/ViewPostModal.jsx | 18 ++++-- frontend/src/utils/Post.js | 32 +++++----- frontend/src/utils/contract-config.js | 2 +- 10 files changed, 116 insertions(+), 54 deletions(-) rename frontend/{src => }/contract-addresses.json (53%) diff --git a/frontend/src/contract-addresses.json b/frontend/contract-addresses.json similarity index 53% rename from frontend/src/contract-addresses.json rename to frontend/contract-addresses.json index 75766ab..77cb51a 100644 --- a/frontend/src/contract-addresses.json +++ b/frontend/contract-addresses.json @@ -1,9 +1,9 @@ { "localhost": { - "DAO": "0x8d914D38dD301FC4606f5aa9fEcF8A76389020d3", - "Work1": "0xfe58B9EB03F75A603de1B286584f5E9532ab8fB5", - "Onboarding": "0x1d63FDe5B461106729fE1e5e38A02fc68C518Af5", - "Proposals": "0x050C420Cc4995B41217Eba1B54B82Fd5687e9139" + "DAO": "0xD60A1c64B96a133587A75C2771690072F238a549", + "Work1": "0xCF3f16D151052FA7b99a71E79EC3b0e6C793aa0b", + "Onboarding": "0xE148e864A646B8bFc95dcc9acd3dBcB52704EE60", + "Proposals": "0x981234BBBC1ec93200F5BB3a65e2F9711A6109aa" }, "sepolia": { "DAO": "0x241514DC94568e98222fBE66662b054b545A61AE", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index e1f2289..a06b2d3 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -82,9 +82,10 @@ function App() { }, [DAORef, account]); const fetchPost = useCallback(async (postId) => { - const p = await DAORef.current.methods.posts(postId).call(); - dispatchPost({ type: 'updateById', item: p }); - return p; + const post = await DAORef.current.methods.posts(postId).call(); + post.authors = await DAORef.current.methods.getPostAuthors(postId).call(); + dispatchPost({ type: 'updateById', item: post }); + return post; }, [DAORef, dispatchPost]); const fetchPostId = useCallback(async (postIndex) => { @@ -186,14 +187,14 @@ function App() { setWork1(Work1Contract); setOnboarding(OnboardingContract); - const fetchReputationInterval = setInterval(() => { - console.log('reputation', reputation); - if (reputation !== undefined) { - clearInterval(fetchReputationInterval); - return; - } - fetchReputation(); - }, 1000); + // const fetchReputationInterval = setInterval(() => { + // // console.log('reputation', reputation); + // if (reputation !== undefined) { + // clearInterval(fetchReputationInterval); + // return; + // } + // fetchReputation(); + // }, 1000); /* -------------------------------------------------------------------------------- */ /* --------------------------- BEGIN EVENT HANDLERS ------------------------------- */ @@ -414,7 +415,7 @@ function App() { ID - Author + Authors Sender Actions @@ -423,7 +424,18 @@ function App() { {posts.filter((x) => !!x).map((post) => ( {post.id.toString()} - {getAddressName(chainId, post.author)} + + + {post.authors.map(({ authorAddress, weightPercent }) => ( +
+ {getAddressName(chainId, authorAddress)} + {' '} + {weightPercent.toString()} + % +
+ ))} +
+ {getAddressName(chainId, post.sender)}