• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

decentraland / marketplace / 6970244998

23 Nov 2023 01:18PM UTC coverage: 43.312% (+2.4%) from 40.865%
6970244998

Pull #2042

github

juanmahidalgo
feat: add missing select token and chain events
Pull Request #2042: feat: use squid to calculate route between two chains and tokens

2626 of 7307 branches covered (0.0%)

Branch coverage included in aggregate %.

277 of 382 new or added lines in 20 files covered. (72.51%)

1 existing line in 1 file now uncovered.

4634 of 9455 relevant lines covered (49.01%)

23.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/webapp/src/components/AssetPage/SaleActionBox/BuyNFTButtons/BuyNFTButtons.tsx
1
import { memo, useCallback } from 'react'
2
import { Link } from 'react-router-dom'
3
import { Button, Icon, Mana } from 'decentraland-ui'
4
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
5
import { getAnalytics } from 'decentraland-dapps/dist/modules/analytics/utils'
6
import { locations } from '../../../../modules/routing/locations'
7
import { isNFT } from '../../../../modules/asset/utils'
8
import { Asset } from '../../../../modules/asset/types'
9
import { AssetProvider } from '../../../AssetProvider'
10
import * as events from '../../../../utils/events'
11
import styles from './BuyNFTButtons.module.css'
12
import { Props } from './BuyNFTButtons.types'
13

14
const BuyNFTButtons = ({
1✔
15
  asset,
16
  assetType,
17
  tokenId,
18
  buyWithCardClassName,
19
  isBuyCrossChainEnabled,
20
  onBuyWithCrypto,
21
  onExecuteOrderWithCard,
22
  onBuyItemWithCard
23
}: Props) => {
24
  const analytics = getAnalytics()
4✔
25
  const assetId = tokenId || asset.itemId
4✔
26

27
  const handleBuyWithCard = useCallback(
4✔
28
    (asset: Asset) => {
NEW
29
      analytics.track(events.CLICK_GO_TO_BUY_NFT_WITH_CARD)
×
NEW
30
      !isNFT(asset) ? onBuyItemWithCard(asset) : onExecuteOrderWithCard(asset)
×
31
    },
32
    [analytics, onBuyItemWithCard, onExecuteOrderWithCard]
33
  )
34

35
  return (
4✔
36
    <>
37
      <AssetProvider
38
        type={assetType}
39
        contractAddress={asset.contractAddress}
40
        tokenId={tokenId}
41
      >
42
        {(asset, order) => {
43
          if (!asset) return null
4!
NEW
44
          return (
×
45
            <>
46
              {isBuyCrossChainEnabled ? (
×
47
                <Button
NEW
48
                  onClick={() => onBuyWithCrypto(asset, order)}
×
49
                  primary
50
                  fluid
51
                >
52
                  <Mana
53
                    showTooltip
54
                    inline
55
                    size="small"
56
                    network={asset.network}
57
                  />
58
                  {t('asset_page.actions.buy_with_crypto')}
59
                </Button>
60
              ) : (
61
                <Button
62
                  as={Link}
63
                  to={locations.buy(
64
                    assetType,
65
                    asset.contractAddress,
66
                    assetId ?? undefined
×
67
                  )}
68
                  primary
69
                  fluid
70
                >
71
                  <Mana
72
                    showTooltip
73
                    inline
74
                    size="small"
75
                    network={asset.network}
76
                  />
77
                  {t('asset_page.actions.buy_with_mana')}
78
                </Button>
79
              )}
80

81
              <Button
82
                className={`${styles.buy_with_card} ${buyWithCardClassName}`}
NEW
83
                onClick={() => handleBuyWithCard(asset)}
×
84
                fluid
85
              >
86
                <Icon name="credit card outline" />
87
                {t('asset_page.actions.buy_with_card')}
88
              </Button>
89
            </>
90
          )
91
        }}
92
      </AssetProvider>
93
    </>
94
  )
95
}
96

97
export default memo(BuyNFTButtons)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc