import { strategy as erc20BalanceOfStrategy } from '../erc20-balance-of' ; import { getDelegations } from '../../utils/delegation' ; export const author = 'bonustrack' ; export const version = '0.1.0' ; export async function strategy ( space , network , provider , addresses , options , snapshot ) { const delegations = await getDelegations ( space , network , addresses , snapshot ) ; if ( Object . keys ( delegations ) . length === 0 ) return { } ; console . debug ( 'Delegations' , delegations ) ; const score = await erc20BalanceOfStrategy ( space , network , provider , Object . values ( delegations ) . reduce ( ( a , b ) => a . concat ( b ) ) , options , snapshot ) ; console . debug ( 'Delegators score' , score ) ; return Object . fromEntries ( addresses . map ( ( address ) => { const addressScore = delegations [ address ] ? delegations [ address ] . reduce ( ( a , b ) => a + score [ b ] , 0 ) : 0 ; return [ address , addressScore ] ; } ) ) ; }