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

Mintbase / mintbase-js / 4015446410

pending completion
4015446410

push

github

Sérgio
📝 Fixed main docs

483 of 648 branches covered (74.54%)

Branch coverage included in aggregate %.

721 of 780 relevant lines covered (92.44%)

4.23 hits per line

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

68.42
/packages/sdk/src/buy/buy.ts
1
/* eslint-disable @typescript-eslint/camelcase */
2
import { mbjs } from '../config/config';
1✔
3
import { GAS  } from '../constants';
1✔
4
import { ERROR_MESSAGES } from '../errorMessages';
1✔
5
import { NearContractCall } from '../execute';
6
import { MARKET_METHOD_NAMES } from '../types';
1✔
7

8
export type BuyArgs = {
9
    price: string;
10
    contractAddress?: string;
11
    tokenId: string;
12
    referrerId?: string;
13
    affiliateAccount?: string;
14
    marketId?: string;
15
  };
16

17
//todo make a buy at listed price method
18

19
/**
20
 * Buys a listed token for a specified price as long as its above the price for which is was listed
21
 * @param buyArguments {@link BuyArgs}
22
 * @returns contract call to be passed to @mintbase-js/sdk execute method
23
 */
24
export const buy = (args: BuyArgs): NearContractCall => {
1✔
25
  const {
26
    affiliateAccount,
27
    contractAddress = mbjs.keys.contractAddress,
×
28
    tokenId,
29
    referrerId = null,
×
30
    marketId = mbjs.keys.marketAddress,
1✔
31
    price,
32
  } = args;
1✔
33

34
  if (contractAddress == null) {
1!
35
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
36
  }
37

38
  return {
1✔
39
    contractAddress: marketId || mbjs.keys.marketAddress,
1!
40
    args: {
41
      nft_contract_id: contractAddress || mbjs.keys.contractAddress,
1!
42
      token_id: tokenId,
43
      referrer_id: affiliateAccount || referrerId,
2✔
44
    },
45
    methodName: MARKET_METHOD_NAMES.BUY,
46
    gas: GAS,
47
    deposit: price,
48
  };
49
};
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