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

Mintbase / mintbase-js / 8845566891

26 Apr 2024 08:42AM UTC coverage: 77.325%. First build
8845566891

Pull #504

github

tifrel
Lint & test
Pull Request #504: Fix v2 contract deployment

893 of 1346 branches covered (66.34%)

Branch coverage included in aggregate %.

6 of 7 new or added lines in 1 file covered. (85.71%)

1211 of 1375 relevant lines covered (88.07%)

13.74 hits per line

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

62.5
/packages/sdk/src/buy/buy.ts
1
import { mbjs } from '../config/config';
3✔
2
import { MAX_GAS, ONE_YOCTO  } from '../constants';
3✔
3
import { ERROR_MESSAGES } from '../errorMessages';
3✔
4
import { BuyArgs, BuyArgsFtResponse, BuyArgsResponse, FT_METHOD_NAMES, MARKET_METHOD_NAMES, NearContractCall } from '../types';
3✔
5

6
//todo make a buy at listed price method
7

8
/**
9
 * Buys a listed token for a specified price as long as its above the price for which is was listed
10
 * @param buyArguments {@link BuyArgs}
11
 * @returns contract call to be passed to @mintbase-js/sdk execute method
12
 */
13
export const buy = (args: BuyArgs): NearContractCall<BuyArgsResponse | BuyArgsFtResponse> => {
3✔
14
  const { contractAddress = mbjs.keys.contractAddress, tokenId, referrerId = null, marketId = mbjs.keys.marketAddress, price, affiliateAccount } = args;
9!
15

16
  if (!contractAddress) {
9!
17
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
18
  }
19

20
  if (args.ftAddress) {
9✔
21
    if (!Object.values(mbjs.keys.ftAddresses).includes(args.ftAddress)) {
6!
22
      throw new Error(ERROR_MESSAGES.UNSUPPORTED_FT);
×
23
    }
24

25
    return {
6✔
26
      contractAddress: args.ftAddress,
27
      args: {
28
        receiver_id: marketId || mbjs.keys.marketAddress,
4!
29
        amount: price,
30
        msg: JSON.stringify({
31
          nft_contract_id: contractAddress || mbjs.keys.contractAddress,
4!
32
          token_id: tokenId,
33
        }),
34
      },
35
      methodName: FT_METHOD_NAMES.FT_TRANSFER_CALL,
36
      gas: MAX_GAS,
37
      deposit: ONE_YOCTO,
38
    };
39
  }
40

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