Skip to content

Commit a954dc2

Browse files
authored
Added transfer direction indicator (#1409)
1 parent b582d47 commit a954dc2

File tree

6 files changed

+51
-18
lines changed

6 files changed

+51
-18
lines changed

packages/app/components/ReferralLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export function ReferralLink(props: ButtonProps) {
6868
flex={1}
6969
jc={'space-between'}
7070
height={'auto'}
71+
bw={0}
7172
hoverStyle={{
7273
backgroundColor: '$backgroundTransparent',
73-
borderColor: '$colorTransparent',
7474
}}
7575
pressStyle={{
7676
backgroundColor: 'transparent',

packages/app/features/activity/ActivityAvatar.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Avatar, LinkableAvatar, type LinkableAvatarProps, Spinner, XStack } from '@my/ui'
2-
import { Minus, Plus } from '@tamagui/lucide-icons'
2+
import { ArrowDown, ArrowUp, Minus, Plus } from '@tamagui/lucide-icons'
33
import { AvatarSendEarnDeposit } from 'app/components/avatars'
44
import { AvatarSendEarnWithdraw } from 'app/components/avatars/AvatarSendEarnWithdraw'
55
import { IconUpgrade } from 'app/components/icons'
@@ -50,13 +50,16 @@ export function ActivityAvatar({
5050
if (isActivitySwapTransfer(activity, swapRouters, liquidityPools)) {
5151
return <TradeActivityAvatar activity={activity} />
5252
}
53+
5354
if (user) {
5455
return (
5556
<XStack
5657
onPress={(e) => {
5758
e.stopPropagation()
5859
}}
60+
position={'relative'}
5961
>
62+
<TransferDirectionIndicator activity={activity} />
6063
<LinkableAvatar size="$4.5" br="$4" gap="$2" href={`/profile/${user.send_id}`} {...props}>
6164
{(() => {
6265
switch (true) {
@@ -165,8 +168,8 @@ export function ActivityAvatar({
165168

166169
const TradeActivityAvatar = ({ activity }: { activity: Activity }) => {
167170
const { data: swapRouters } = useSwapRouters()
168-
const isButTransfer = isSwapBuyTransfer(activity, swapRouters)
169-
const Icon = isButTransfer ? Plus : Minus
171+
const isBuyTransfer = isSwapBuyTransfer(activity, swapRouters)
172+
const Icon = isBuyTransfer ? Plus : Minus
170173

171174
return (
172175
<XStack w="$4.5" h={'$4.5'} br="$4" ai={'center'} jc={'center'} position={'relative'}>
@@ -176,7 +179,7 @@ const TradeActivityAvatar = ({ activity }: { activity: Activity }) => {
176179
top={'-5%'}
177180
right={'-5%'}
178181
size={'$1'}
179-
bc={isButTransfer ? '$olive' : '$error'}
182+
bc={isBuyTransfer ? '$olive' : '$error'}
180183
borderRadius={999}
181184
shadowColor={'$black'}
182185
shadowOffset={{ width: 0, height: 2 }}
@@ -186,3 +189,25 @@ const TradeActivityAvatar = ({ activity }: { activity: Activity }) => {
186189
</XStack>
187190
)
188191
}
192+
193+
const TransferDirectionIndicator = ({ activity }: { activity: Activity }) => {
194+
const { to_user } = activity
195+
196+
return (
197+
<XStack
198+
position={'absolute'}
199+
top={0}
200+
right={0}
201+
transform={'translate(30%, -30%)'}
202+
bc={'$olive'}
203+
borderRadius={999}
204+
shadowColor={'#000000'}
205+
shadowOffset={{ width: 0, height: 2 }}
206+
shadowOpacity={0.7}
207+
shadowRadius={8}
208+
zIndex={1}
209+
>
210+
{to_user?.id ? <ArrowDown size={'$1'} /> : <ArrowUp size={'$1'} />}
211+
</XStack>
212+
)
213+
}

packages/app/features/activity/utils/__mocks__/mock-activity-feed.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const mockSentTransfer = {
4848
block_num: '15164541',
4949
tx_idx: '0',
5050
log_idx: '2',
51+
note: 'Send gonna be $1 someday',
5152
},
5253
}
5354

@@ -210,6 +211,7 @@ export const mockSendAccountReceive = {
210211
tx_hash: '\\xeec33cc50042cbba53fc1de714bd99b206635f890dbe29771c7986df6da0f6af',
211212
log_addr: '\\xb2c21f54653531aa4affa80f63593913f0c70628',
212213
block_num: '15681483',
214+
note: 'Send gonna be $1 someday',
213215
},
214216
} as const
215217

packages/app/utils/activity.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,25 @@ describe('test eventNameFromActivity', () => {
6262
const activity = JSON.parse(JSON.stringify(mockReceivedTransfer))
6363
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe('Deposit')
6464
})
65-
it('should return the received when received eth and to user ID is present', () => {
65+
it('should return the note when received eth and to user ID is present', () => {
6666
const activity = JSON.parse(JSON.stringify(mockSendAccountReceive))
67-
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe('Received')
67+
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe(
68+
'Send gonna be $1 someday'
69+
)
6870
})
69-
it('should return the sent when received eth and from user ID is present', () => {
71+
it('should return the note when received eth and from user ID is present', () => {
7072
const activity = JSON.parse(JSON.stringify({ ...mockSendAccountReceive }))
7173
activity.from_user = { ...activity.from_user, id: '1234' }
7274
activity.to_user = { ...activity.to_user, id: null }
73-
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe('Sent')
75+
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe(
76+
'Send gonna be $1 someday'
77+
)
7478
})
75-
it('should return the sent when transfer and from user ID is present', () => {
79+
it('should return the note when transfer and from user ID is present', () => {
7680
const activity = JSON.parse(JSON.stringify(mockSentTransfer))
77-
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe('Sent')
81+
expect(eventNameFromActivity({ activity: EventSchema.parse(activity) })).toBe(
82+
'Send gonna be $1 someday'
83+
)
7884
})
7985
it('should return the sendtag registered when tag receipts event', () => {
8086
const activity = JSON.parse(JSON.stringify(mockTagReceipt))

packages/app/utils/activity.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export function eventNameFromActivity({
334334
case isSendEarnWithdrawEvent(activity):
335335
return 'Send Earn Withdraw'
336336
case isTemporalTransfer:
337-
return note || temporalEventNameFromStatus(data.status)
337+
return note || ''
338338
case isERC20Transfer && isAddressEqual(data.f, sendtagCheckoutAddress[baseMainnet.id]):
339339
return 'Revenue Share'
340340
case isSendTokenUpgradeEvent(activity):
@@ -350,9 +350,9 @@ export function eventNameFromActivity({
350350
}
351351
return 'Deposit'
352352
case isTransferOrReceive && !!to_user?.id:
353-
return note || 'Received'
353+
return note || ''
354354
case isTransferOrReceive && !!from_user?.id:
355-
return note || 'Sent'
355+
return note || ''
356356
case isTagReceiptsEvent(activity) || isTagReceiptUSDCEvent(activity):
357357
return 'Sendtag Registered'
358358
case isReferralsEvent(activity) && !!from_user?.id:
@@ -442,8 +442,6 @@ export function phraseFromActivity({
442442
return 'Deposited to Send Earn'
443443
case isSendEarnWithdrawEvent(activity):
444444
return 'Withdrew from Send Earn'
445-
case isTemporalTransfer:
446-
return temporalEventNameFromStatus(data.status)
447445
case isERC20Transfer && isAddressEqual(data.f, sendtagCheckoutAddress[baseMainnet.id]):
448446
return 'Earned revenue share'
449447
case isSendTokenUpgradeEvent(activity):
@@ -458,9 +456,9 @@ export function phraseFromActivity({
458456
return 'Trade'
459457
}
460458
return 'Deposited'
461-
case isTransferOrReceive && !!to_user?.id:
459+
case (isTransferOrReceive || isTemporalTransfer) && !!to_user?.id:
462460
return 'Sent you'
463-
case isTransferOrReceive && !!from_user?.id:
461+
case (isTransferOrReceive || isTemporalTransfer) && !!from_user?.id:
464462
return 'Received'
465463
case isTagReceiptsEvent(activity) || isTagReceiptUSDCEvent(activity):
466464
return data.tags?.length > 1 ? 'Sendtags created' : 'Sendtag created'

packages/app/utils/zod/activity/__snapshots__/index.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ exports[`EventArraySchema should parse a valid event array 1`] = `
165165
"f": "0x760E2928C3aa3aF87897bE52eb4833d42bbB27cf",
166166
"log_addr": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
167167
"log_idx": 2n,
168+
"note": "Send gonna be $1 someday",
168169
"t": "0xbf65EE06b43B9cA718216241f0b9F81b5ff30CC1",
169170
"tx_hash": "0xf1443b5abd14e6212dda2d9f5ff1d1d691599de3e8fa019ccc19b909d9bb46a4",
170171
"tx_idx": 0n,
@@ -206,6 +207,7 @@ exports[`EventArraySchema should parse a valid event array 1`] = `
206207
},
207208
"log_addr": "0xB2c21F54653531aa4AffA80F63593913f0C70628",
208209
"log_idx": 0n,
210+
"note": "Send gonna be $1 someday",
209211
"sender": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
210212
"tx_hash": "0xeec33cc50042cbba53fc1de714bd99b206635f890dbe29771c7986df6da0f6af",
211213
"tx_idx": 0n,

0 commit comments

Comments
 (0)