-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mobile): refund && scam fixes (#883)
* fix(mobile): Button colors * fix(mobile): Mark transactions with spam NFTs, update naming
- Loading branch information
1 parent
dce544a
commit e1c06ea
Showing
11 changed files
with
191 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/shared/components/ActivityList/ActionListItemWithNFT.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { memo } from 'react'; | ||
import { NftPreviewContent } from './NftPreviewContent'; | ||
import { ListItemContentText } from '@tonkeeper/uikit'; | ||
import { ListItemEncryptedComment } from '@tonkeeper/uikit/src/components/List/ListItemEncryptedComment'; | ||
import { ActionListItem, ActionListItemProps } from './ActionListItem'; | ||
import { ActionType } from '@tonkeeper/mobile/src/wallet/models/ActivityModel'; | ||
import { useNftItemByAddress } from '../../query/hooks/useNftItemByAddress'; | ||
import { TrustType } from '@tonkeeper/core/src/TonAPI'; | ||
import { Address } from '../../Address'; | ||
import { TokenApprovalStatus } from '@tonkeeper/mobile/src/wallet/managers/TokenApprovalManager'; | ||
import { useTokenApproval } from '../../hooks'; | ||
|
||
export interface ActionListItemWithNftProps | ||
extends ActionListItemProps<ActionType.NftPurchase | ActionType.NftItemTransfer> {} | ||
|
||
export const ActionListItemWithNft = memo<ActionListItemWithNftProps>((props) => { | ||
const { action } = props; | ||
const { payload, type } = action; | ||
|
||
const nftAddress = type === ActionType.NftPurchase ? payload.nft.address : payload.nft; | ||
const nftItem = type === ActionType.NftPurchase ? payload.nft : undefined; | ||
|
||
const { data: nft } = useNftItemByAddress(nftAddress, { | ||
existingNft: nftItem, | ||
}); | ||
|
||
const approvalStatuses = useTokenApproval((state) => state.tokens); | ||
const approvalIdentifier = nft | ||
? Address.parse(nft?.collection?.address ?? nft?.address).toRaw() | ||
: ''; | ||
const nftApprovalStatus = approvalStatuses[approvalIdentifier]; | ||
|
||
const isScam = | ||
nft && | ||
((nft.trust === TrustType.Blacklist && | ||
nftApprovalStatus?.current !== TokenApprovalStatus.Approved) || | ||
nftApprovalStatus?.current === TokenApprovalStatus.Spam); | ||
|
||
switch (type) { | ||
case ActionType.NftItemTransfer: | ||
return ( | ||
<ActionListItem {...props} isScam={isScam}> | ||
{nft && !isScam && ( | ||
<NftPreviewContent | ||
nft={nft} | ||
disabled={props.disableNftPreview || props.disablePressable} | ||
/> | ||
)} | ||
{!!payload.comment && <ListItemContentText text={payload.comment.trim()} />} | ||
{!!payload.encrypted_comment && ( | ||
<ListItemEncryptedComment | ||
encryptedComment={payload.encrypted_comment} | ||
actionId={action.action_id} | ||
sender={action.payload.sender!} | ||
/> | ||
)} | ||
</ActionListItem> | ||
); | ||
case ActionType.NftPurchase: | ||
return ( | ||
<ActionListItem {...props} isScam={isScam}> | ||
{nft && !isScam && ( | ||
<NftPreviewContent | ||
nft={nft} | ||
disabled={props.disableNftPreview || props.disablePressable} | ||
/> | ||
)} | ||
</ActionListItem> | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.