import _strategies from '..' ; export const author = 'blakewest' ; export const version = '1.0.0' ; export async function strategy ( space , network , provider , addresses , options , snapshot ) { const validAddresses = await membershipCheck ( space , network , provider , addresses , options . membershipStrategy , snapshot ) ; const votingPowerStrategy = _strategies [ options . votingPowerStrategy . name ] . strategy ; const scores = await votingPowerStrategy ( space , network , provider , validAddresses , options . votingPowerStrategy . params , snapshot ) ; addresses . filter ( ( addr ) => ! validAddresses . includes ( addr ) ) . forEach ( ( addr ) => ( scores [ addr ] = 0 ) ) ; return scores ; } async function membershipCheck ( space , network , provider , addresses , strategy , snapshot ) { const strategyFn = _strategies [ strategy . name ] . strategy ; const result = await strategyFn ( space , network , provider , addresses , strategy . params , snapshot ) ; return Object . entries ( result ) . map ( ( [ address , val ] ) => { if ( val > 0 ) { return address ; } else { return '' ; } } ) . filter ( ( item ) => item ) ; }