11import React from 'react' ;
2- import styled from 'styled-components' ;
2+ import styled , { useTheme } from 'styled-components' ;
33import Big from 'big.js' ;
44import { deriveAccountInfo } from '../../utils/account' ;
55import { isValidPublicKey } from 'casper-js-sdk' ;
@@ -28,17 +28,22 @@ import Link from '../link/link';
2828import {
2929 formatHash ,
3030 formatNumber ,
31+ formatTimestamp ,
3132 formatTimestampAge ,
3233 HashLength ,
3334} from '../../utils/formatters' ;
3435import Tooltip from '../tooltip/tooltip' ;
3536import Avatar from '../avatar/avatar' ;
3637import TruncateBox from '../truncate-box/truncate-box' ;
37- import { isWASMProxyTransaction } from '../deploy-actions/utils/contract' ;
38+ import {
39+ isContractTypeCep18 ,
40+ isWASMProxyTransaction ,
41+ } from '../deploy-actions/utils/contract' ;
3842import { useMatchMedia } from '../../utils/match-media' ;
3943import { DeployStatus , DeployStatusSize } from '../deploy-status/deploy-status' ;
4044import { WasmProxyBadge } from './wasm-proxy-badge' ;
4145import Address from '../address/address' ;
46+ import Badge from '../badge/badge' ;
4247
4348const StyledPageTile = styled ( PageTile ) ( ( ) => ( {
4449 marginBottom : 8 ,
@@ -106,6 +111,25 @@ const StyledFlexColumn = styled(FlexColumn)(({ theme }) =>
106111 } ) ,
107112) ;
108113
114+ const FacilitatorBadge = ( ) => {
115+ const theme = useTheme ( ) ;
116+ return (
117+ < Tooltip
118+ tooltipContent = {
119+ 'Account that submitted and paid for this transaction. Account that authorized this transaction can be checked on Transaction Details page.'
120+ }
121+ >
122+ < FlexRow gap = { 3 } align = { 'center' } >
123+ < Badge
124+ lineHeight = { 'xxs' }
125+ label = { 'FACILITATOR' }
126+ variation = { theme . styleguideColors . contentLightBlue }
127+ />
128+ </ FlexRow >
129+ </ Tooltip >
130+ ) ;
131+ } ;
132+
109133const BlockFeedInfo = ( { deploy, path } : { deploy : Deploy ; path : string } ) => (
110134 < FlexRow itemsSpacing = { 8 } align = { 'center' } >
111135 < BodyText
@@ -150,9 +174,7 @@ export interface ActivityFeedItemProps {
150174 loading : boolean ;
151175 actionIdentificationHashes : ActionIdentificationHashesType ;
152176 csprLiveDomainPath : string ;
153- getAccountInfo : (
154- publicKey : string ,
155- ) => AccountInfoResult | null | undefined ;
177+ getAccountInfo : ( publicKey : string ) => AccountInfoResult | null | undefined ;
156178 getContractInfoByHash ?: (
157179 contractHash : string ,
158180 ) => ContractResult | null | undefined ;
@@ -171,15 +193,17 @@ export const ActivityFeedItem = ({
171193 csprLiveDomainPath,
172194} : ActivityFeedItemProps ) => {
173195 const {
174- callerPublicKey,
175196 callerHash,
176197 deployHash,
177198 paymentAmount,
178199 refundAmount,
179200 callerCsprName,
201+ entryPoint,
202+ contractPackage,
180203 } = deploy ;
181204
182- const accountInfo = getAccountInfo (
205+ const callerPublicKey = deploy . callerPublicKey || deploy . callerHash ;
206+ const accountInfo = getAccountInfo < AccountInfoResult > (
183207 callerPublicKey || callerHash ,
184208 ) ;
185209
@@ -199,12 +223,21 @@ export const ActivityFeedItem = ({
199223 . minus ( refundAmount || '0' )
200224 . toString ( ) ;
201225
226+ const isCep18 = isContractTypeCep18 ( contractPackage ) ;
227+ const isAuthorizedTransfer =
228+ isCep18 && entryPoint ?. name === 'transfer_with_authorization' ;
229+
202230 const onAbove = (
203231 < DesktopFeedItemContainer itemsSpacing = { 12 } >
204232 < CommonDataContainer >
205233 < FlexRow align = { 'center' } >
206234 < DeployStatus deployResult = { deploy } size = { DeployStatusSize . Small } />
207- < Tooltip scale = { 'xs' } lineHeight = { 'xs' } tooltipContent = { deployHash } >
235+ < Tooltip
236+ scale = { 'xs' }
237+ lineHeight = { 'xs' }
238+ tooltipContent = { deployHash }
239+ caption = { 'Transaction Hash' }
240+ >
208241 < BodyText size = { 3 } scale = { 'sm' } monotype >
209242 < Link
210243 href = { `${ csprLiveDomainPath } /transaction/${ deploy . deployHash } ` }
@@ -217,15 +250,17 @@ export const ActivityFeedItem = ({
217250 </ Tooltip >
218251 </ FlexRow >
219252 < FlexRow justify = { 'flex-end' } itemsSpacing = { 8 } align = { 'baseline' } >
220- < BodyText
221- scale = { 'xs' }
222- lineHeight = { 'xs' }
223- size = { 3 }
224- noWrap
225- variation = { 'darkGray' }
226- >
227- { formatTimestampAge ( deploy . timestamp ) }
228- </ BodyText >
253+ < Tooltip tooltipContent = { formatTimestamp ( deploy . timestamp ) } >
254+ < BodyText
255+ scale = { 'xs' }
256+ lineHeight = { 'xs' }
257+ size = { 3 }
258+ noWrap
259+ variation = { 'darkGray' }
260+ >
261+ { formatTimestampAge ( deploy . timestamp ) }
262+ </ BodyText >
263+ </ Tooltip >
229264 < BodyText scale = { 'xs' } lineHeight = { 'xs' } size = { 3 } noWrap >
230265 ·
231266 </ BodyText >
@@ -284,7 +319,10 @@ export const ActivityFeedItem = ({
284319 < FlexRow justify = { 'space-between' } >
285320 < FlexRow itemsSpacing = { 8 } >
286321 < TooltipWithExtendedInfo
287- extendedLine = { { title : csprName ?? undefined , caption : 'CSPR.name' } }
322+ extendedLine = { {
323+ title : csprName ?? undefined ,
324+ caption : 'CSPR.name' ,
325+ } }
288326 tooltipCaption = { keyTooltipCaption }
289327 hash = { callerPublicKey || callerHash }
290328 >
@@ -305,13 +343,16 @@ export const ActivityFeedItem = ({
305343 </ BodyText >
306344 </ FlexColumn >
307345 </ TooltipWithExtendedInfo >
308- < FlexRow >
309- < TruncateBox size = { 5 } >
310- < BodyText size = { 3 } variation = "darkGray" noWrap >
311- { name }
312- </ BodyText >
313- </ TruncateBox >
314- </ FlexRow >
346+ { name ? (
347+ < FlexRow >
348+ < TruncateBox size = { 5 } >
349+ < BodyText size = { 3 } variation = "darkGray" noWrap >
350+ { name }
351+ </ BodyText >
352+ </ TruncateBox >
353+ </ FlexRow >
354+ ) : null }
355+ { isAuthorizedTransfer ? < FacilitatorBadge /> : null }
315356 </ FlexRow >
316357 </ FlexRow >
317358 < FlexRow >
@@ -354,7 +395,12 @@ export const ActivityFeedItem = ({
354395 < FlexRow justify = { 'space-between' } >
355396 < FlexRow align = { 'center' } >
356397 < DeployStatus deployResult = { deploy } size = { DeployStatusSize . Small } />
357- < Tooltip tooltipContent = { deployHash } scale = { 'xs' } lineHeight = { 'xs' } >
398+ < Tooltip
399+ tooltipContent = { deployHash }
400+ scale = { 'xs' }
401+ lineHeight = { 'xs' }
402+ caption = { 'Transaction Hash' }
403+ >
358404 < BodyText scale = { 'xs' } lineHeight = { 'xs' } size = { 3 } monotype >
359405 < Link
360406 href = { `${ csprLiveDomainPath } /transaction/${ deploy . deployHash } ` }
@@ -384,18 +430,20 @@ export const ActivityFeedItem = ({
384430 </ FlexRow >
385431 </ FlexRow >
386432 < FlexColumn itemsSpacing = { 12 } >
387- < Address
388- logo = { logo }
389- name = { name }
390- hash = { callerPublicKey || callerHash }
391- csprName = { callerCsprName || csprName || undefined }
392- loading = { loading }
393- navigateToPath = { `${ csprLiveDomainPath } /account/${ callerPublicKey || callerHash } ` }
394- avatarSize = { 'small' }
395- hashFontSize = { 'sm' }
396- minifiedCopyNotification
397- />
398-
433+ < FlexRow itemsSpacing = { 4 } align = { 'center' } wrap = { 'wrap' } >
434+ < Address
435+ logo = { logo }
436+ name = { name }
437+ hash = { callerPublicKey || callerHash }
438+ csprName = { callerCsprName || csprName || undefined }
439+ loading = { loading }
440+ navigateToPath = { `${ csprLiveDomainPath } /account/${ callerPublicKey || callerHash } ` }
441+ avatarSize = { 'small' }
442+ hashFontSize = { 'sm' }
443+ minifiedCopyNotification
444+ />
445+ { isAuthorizedTransfer ? < FacilitatorBadge /> : null }
446+ </ FlexRow >
399447 < FlexRow itemsSpacing = { 8 } >
400448 { isWASMProxyTransaction ( deploy . executionTypeId ) && (
401449 < WasmProxyBadge lineHeight = { 'xxs' } />
0 commit comments