11const _ = require ( 'lodash' ) ;
22
3- const { ETH_TOKEN_DECIMALS } = require ( '../../../../constants' ) ;
3+ const {
4+ ETH_TOKEN_DECIMALS ,
5+ FILL_ATTRIBUTION_TYPE ,
6+ } = require ( '../../../../constants' ) ;
7+ const formatFillAttributionType = require ( '../../../../fills/format-fill-attribution-type' ) ;
48const formatFillStatus = require ( '../../../../fills/format-fill-status' ) ;
59const formatTokenAmount = require ( '../../../../tokens/format-token-amount' ) ;
610const getAssetsForFill = require ( '../../../../fills/get-assets-for-fill' ) ;
711const getFeesForFill = require ( '../../../../fills/get-fees-for-fill' ) ;
812
9- const formatRelayer = relayer =>
10- relayer === null ? null : _ . pick ( relayer , 'slug' , 'name' , 'imageUrl' ) ;
13+ const getRelayer = fill => {
14+ const relayerAttribution = fill . attributions . find (
15+ a => a . type === FILL_ATTRIBUTION_TYPE . RELAYER ,
16+ ) ;
17+
18+ if ( relayerAttribution === undefined ) {
19+ return null ;
20+ }
21+
22+ return {
23+ imageUrl : relayerAttribution . entity . logoUrl ,
24+ name : relayerAttribution . entity . name ,
25+ slug : relayerAttribution . entity . urlSlug ,
26+ } ;
27+ } ;
1128
1229const transformFill = fill => {
1330 const assets = getAssetsForFill ( fill ) ;
@@ -33,6 +50,20 @@ const transformFill = fill => {
3350 imageUrl : _ . get ( fill , 'affiliate.imageUrl' , null ) ,
3451 name : _ . get ( fill , 'affiliate.name' , null ) ,
3552 } ,
53+ apps : fill . attributions
54+ . filter ( a =>
55+ [
56+ FILL_ATTRIBUTION_TYPE . CONSUMER ,
57+ FILL_ATTRIBUTION_TYPE . RELAYER ,
58+ ] . includes ( a . type ) ,
59+ )
60+ . map ( attribution => ( {
61+ id : attribution . entityId ,
62+ logoUrl : attribution . entity . logoUrl ,
63+ name : attribution . entity . name ,
64+ type : formatFillAttributionType ( attribution . type ) ,
65+ urlSlug : attribution . entity . urlSlug ,
66+ } ) ) ,
3667 assets,
3768 date : fill . date ,
3869 fees,
@@ -42,7 +73,7 @@ const transformFill = fill => {
4273 orderHash : fill . orderHash ,
4374 protocolFee,
4475 protocolVersion : fill . protocolVersion ,
45- relayer : formatRelayer ( fill . relayer ) ,
76+ relayer : getRelayer ( fill ) ,
4677 senderAddress : fill . senderAddress ,
4778 status : formatFillStatus ( fill . status ) ,
4879 takerAddress : taker ,
0 commit comments