import { ObjectMap } from '@0x/types'; import * as _ from 'lodash'; import { Actor, Constructor } from './base'; /** * Utility function to convert Actors into an object mapping readable names to addresses. * Useful for BalanceStore. */ export function actorAddressesByName(actors: Actor[]): ObjectMap { return _.zipObject( actors.map(actor => actor.name), actors.map(actor => actor.address), ); } /** * Filters the given actors by role, specified by the class exported by an actor mixin file, * e.g, 'Maker', 'Taker', etc. */ export function filterActorsByRole( actors: Actor[], role: TClass, ): Array> { return actors.filter(actor => actor.mixins.includes(role.name)) as Array>; }