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

decentraland / marketplace / 10009275479

19 Jul 2024 01:58PM UTC coverage: 66.647% (+0.08%) from 66.57%
10009275479

Pull #2269

github

meelrossi
Merge remote-tracking branch 'origin/feat/offchain-bids' into feat/cancel-bids
Pull Request #2269: feat: add cancel bids logic

2646 of 5154 branches covered (51.34%)

Branch coverage included in aggregate %.

40 of 48 new or added lines in 5 files covered. (83.33%)

13 existing lines in 6 files now uncovered.

7747 of 10440 relevant lines covered (74.2%)

77.8 hits per line

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

71.43
/webapp/src/modules/vendor/decentraland/trades/api.ts
1
import { Trade, TradeCreation } from '@dcl/schemas'
2
import { BaseClient } from 'decentraland-dapps/dist/lib'
33✔
3
import { sendTransaction } from 'decentraland-dapps/dist/modules/wallet/utils'
33✔
4
import { ContractName, getContract } from 'decentraland-transactions'
33✔
5
import { config } from '../../../../config'
33✔
6
import { getContractTrade } from '../../../../utils/trades'
33✔
7
import { retryParams } from '../utils'
33✔
8

9
export const MARKETPLACE_SERVER_URL = config.get('MARKETPLACE_SERVER_URL')
33✔
10

11
export class TradesAPI extends BaseClient {
254✔
12
  addTrade = async (trade: TradeCreation) => {
287✔
13
    return this.fetch<Trade>('/v1/trades', {
3✔
14
      method: 'POST',
15
      body: JSON.stringify(trade),
16
      metadata: { signer: 'dcl:marketplace', intent: 'dcl:marketplace:create-trade' },
17
      headers: {
18
        'Content-Type': 'application/json'
19
      }
20
    })
21
  }
22

23
  fetchTrade = async (tradeId: string) => {
287✔
24
    return this.fetch<Trade>(`/v1/trades/${tradeId}`, { method: 'GET' })
1✔
25
  }
26

27
  accept = async (trade: Trade) => {
287✔
NEW
28
    const offchainMarketplaceContract = getContract(ContractName.OffChainMarketplace, trade.chainId)
×
NEW
29
    const tradeToAccept = getContractTrade(trade)
×
NEW
30
    return sendTransaction(offchainMarketplaceContract, 'accept', [tradeToAccept])
×
31
  }
32

33
  cancel = async (trade: Trade) => {
287✔
NEW
34
    const offchainMarketplaceContract = getContract(ContractName.OffChainMarketplace, trade.chainId)
×
NEW
35
    const tradeToCancel = getContractTrade(trade)
×
NEW
36
    return sendTransaction(offchainMarketplaceContract, 'cancelSignature', [tradeToCancel])
×
37
  }
38
}
39

40
export const tradesAPI = new TradesAPI(MARKETPLACE_SERVER_URL, { retries: retryParams.attempts, retryDelay: retryParams.delay })
33✔
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