@@ -72,7 +72,7 @@ export default function EpochPage() {
7272 </ div >
7373
7474 < div id = 'content' className = 'mt-8' >
75- < ContributionCount priorityAddress = { address } epochIndex = { epochIndex } />
75+ < Contributions priorityAddress = { address } epochIndex = { epochIndex } />
7676 </ div >
7777 </ main >
7878 </ WagmiConfig >
@@ -209,36 +209,11 @@ function Priority({ address }: any) {
209209 )
210210}
211211
212- function ContributionCount ( { priorityAddress, epochIndex } : any ) {
213- console . log ( 'ContributionCount' )
214-
215- console . log ( 'priorityAddress:' , priorityAddress )
216- console . log ( 'epochIndex:' , epochIndex )
217-
218- const { data : contributionCount , isError, isLoading } = useContractRead ( {
219- address : priorityAddress ,
220- abi : Sector3DAOPriority . abi ,
221- functionName : 'getContributionCount'
222- } )
223- console . log ( 'contributionCount:' , contributionCount )
224-
225- if ( ! useIsMounted ( ) || ( contributionCount == undefined ) ) {
226- return (
227- < div className = "flex items-center text-gray-400" >
228- < div className = "inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-r-transparent border-gray-400 align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]" > </ div >
229- Loading...
230- </ div >
231- )
232- }
233- return < Contributions priorityAddress = { priorityAddress } epochIndex = { epochIndex } contributionCount = { contributionCount } />
234- }
235-
236- function Contributions ( { priorityAddress, epochIndex, contributionCount } : any ) {
212+ function Contributions ( { priorityAddress, epochIndex } : any ) {
237213 console . log ( 'Contributions' )
238214
239215 console . log ( 'priorityAddress:' , priorityAddress )
240216 console . log ( 'epochIndex:' , epochIndex )
241- console . log ( 'contributionCount:' , contributionCount )
242217
243218 const { isConnected } = useAccount ( )
244219 console . log ( 'isConnected:' , isConnected )
@@ -262,49 +237,15 @@ function Contributions({ priorityAddress, epochIndex, contributionCount }: any)
262237 }
263238 console . log ( 'priorityTitle:' , priorityTitle )
264239
265- let contracts : any = [ contributionCount ]
266- let i = 0
267- for ( i = 0 ; i < Number ( contributionCount ) ; i ++ ) {
268- console . log ( 'i:' , i )
269- contracts [ i ] = {
270- ...priorityContract ,
271- functionName : 'getContribution' ,
272- args : [ i ]
273- }
274- }
275- console . log ( 'contracts:' , contracts )
276-
277- const { data : contributionsData , isError, isLoading } = useContractReads ( {
278- contracts : contracts
240+ const { data : contributionsData , isError, isLoading } = useContractRead ( {
241+ ...priorityContract ,
242+ functionName : 'getContributions'
279243 } )
280244 console . log ( 'contributionsData:' , contributionsData )
281245
282246 let contributions : any = null
283- if ( contributionCount == 0 ) {
284- contributions = [ ]
285- } else {
286- if ( contributionsData != undefined ) {
287- contributions = [ ]
288- let contributionIndex = contributionCount - 1
289- while ( contributionIndex >= 0 ) {
290- console . log ( 'contributionIndex:' , contributionIndex )
291-
292- const contributionData : any = contributionsData [ contributionIndex ]
293- console . log ( 'contributionData:' , contributionData )
294- if ( contributionData . epochIndex == epochIndex ) {
295- const contribution = {
296- contributor : contributionData . contributor ,
297- description : contributionData . description ,
298- proofURL : contributionData . proofURL ,
299- alignment : contributionData . alignment ,
300- hoursSpent : contributionData . hoursSpent
301- }
302- contributions [ contributions . length ] = contribution
303- }
304-
305- contributionIndex --
306- }
307- }
247+ if ( contributionsData != undefined ) {
248+ contributions = contributionsData
308249 }
309250 console . log ( 'contributions:' , contributions )
310251
@@ -346,7 +287,7 @@ function Contributions({ priorityAddress, epochIndex, contributionCount }: any)
346287 No data
347288 </ div >
348289 ) : (
349- contributions . map ( ( contribution : any , index : number ) => (
290+ contributions . slice ( 0 ) . reverse ( ) . map ( ( contribution : any , index : number ) => (
350291 < div key = { index } className = { `md:flex md:space-x-6 p-6 mt-4 bg-gray-800 rounded-xl border-4 border-gray-800 ${ alignmentBorderColors [ contribution . alignment ] } ` } >
351292 < div className = 'md:w-1/2' >
352293 < div >
0 commit comments