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

Mintbase / mintbase-js / 3930349100

pending completion
3930349100

push

github

Ruben Marcus
Merge branch 'alpha' into fix-callback-test

461 of 611 branches covered (75.45%)

Branch coverage included in aggregate %.

676 of 726 relevant lines covered (93.11%)

4.32 hits per line

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

64.71
/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
    marketId?: string;
14
  };
15

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

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

26
  if (contractAddress == null) {
1!
27
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
28
  }
29

30
  return {
1✔
31
    contractAddress: marketId || mbjs.keys.marketAddress,
1!
32
    args: {
33
      CONTRACT_ADDRESS: contractAddress || mbjs.keys.contractAddress,
1!
34
      token_id: tokenId,
35
      referrer_id: referrerId,
36
    },
37
    methodName: MARKET_METHOD_NAMES.BUY,
38
    gas: GAS,
39
    deposit: price,
40
  };
41
};
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