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

Mintbase / mintbase-js / 3829221631

pending completion
3829221631

push

github

cif
fix(auth): :white_check_mark: Fix path on context test mock

273 of 348 branches covered (78.45%)

Branch coverage included in aggregate %.

458 of 506 relevant lines covered (90.51%)

3.13 hits per line

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

60.0
/packages/sdk/src/buy/buy.ts
1
/* eslint-disable @typescript-eslint/camelcase */
2
import { DEFAULT_CONTRACT_ADDRESS, GAS, MARKET_METHOD_NAMES, MB_MARKET_ADDRESS } from '../constants';
1✔
3
import { NearContractCall } from '../execute';
4

5
export type BuyArgs = {
6
    price: string;
7
    nftContractId?: string;
8
    tokenId: string;
9
    referrerId?: string;
10
    marketId?: string;
11
  };
12

13
//todo make a buy at listed price method
14

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

23
  if (nftContractId == null) {
1!
24
    throw new Error('You must provide a nftContractId or define a NFT_CONTRACT_ID environment variable to default to');
×
25
  }
26

27
  return {
1✔
28
    contractAddress: marketId,
29
    args: {
30
      nft_contract_id: nftContractId,
31
      token_id: tokenId,
32
      referrer_id: referrerId,
33
    },
34
    methodName: MARKET_METHOD_NAMES.BUY,
35
    gas: GAS,
36
    deposit: price,
37
  };
38
};
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