import { getScoresDirect , multicall } from '../../utils' ; export const author = 'trizin' ; export const version = '0.1.0' ; const abi = [ 'function isVerifiedUser(address _user) external view returns (bool)' ] ; export async function strategy ( space , network , provider , addresses , options , snapshot ) { const ALLOWED_STRATEGIES = [ 'erc20-balance-of' , 'ocean-marketplace' , 'sushiswap' , 'uniswap' , 'contract-call' ] ; if ( options . strategies . length > 5 || options . strategies . some ( ( x ) => ! ALLOWED_STRATEGIES . includes ( x . name ) ) ) return [ ] ; const response = await multicall ( network , provider , abi , addresses . map ( ( address ) => [ options . registry , 'isVerifiedUser' , [ address ] ] ) , { blockTag : snapshot } ) ; let scores = await getScoresDirect ( space , options . strategies , network , provider , addresses , snapshot ) ; scores = scores . reduce ( ( finalScores , score ) => { for ( const [ address , value ] of Object . entries ( score ) ) { if ( ! finalScores [ address ] ) { finalScores [ address ] = 0 ; } finalScores [ address ] += value ; } return finalScores ; } , { } ) ; return Object . fromEntries ( addresses . map ( ( address , index ) => { let addressScore = scores [ address ] ; addressScore *= response [ index ] [ 0 ] ? options . brightIdMultiplier : options . notVerifiedMultiplier ; return [ address , addressScore ] ; } ) ) ; }