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

Mintbase / mintbase-js / 8233788221

11 Mar 2024 01:38PM UTC coverage: 76.955%. First build
8233788221

Pull #486

github

sainthiago
add condition
Pull Request #486: Add allKeys param to mintbase-wallet

860 of 1307 branches covered (65.8%)

Branch coverage included in aggregate %.

1177 of 1340 relevant lines covered (87.84%)

13.24 hits per line

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

58.33
/packages/sdk/src/delist/delist.ts
1
import { mbjs } from '../config/config';
3✔
2
import {  GAS, ONE_YOCTO } from '../constants';
3✔
3
import { ERROR_MESSAGES } from '../errorMessages';
3✔
4
import { TOKEN_METHOD_NAMES, MARKET_METHOD_NAMES, NearContractCall, ContractCall, DelistArgs, DelistArgsResponse, DelistMultipleArgsResponse } from '../types';
3✔
5

6

7
/**
8
 * Delist a token
9
 * @param args {@link DelistArgs}
10
 * @returns contract call to be passed to @mintbase-js/sdk execute method
11
 */
12

13
export const delist = (
3✔
14
  args: DelistArgs,
15
): NearContractCall<DelistArgsResponse> => {
16
  const { contractAddress = mbjs.keys.contractAddress, tokenIds, marketAddress = mbjs.keys.marketAddress, oldMarket = false } = args;
6!
17
  
18
  if (!contractAddress) {
6!
19
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
20
  }
21

22
  if (!(tokenIds instanceof Array)) {
6!
23
    throw new Error(ERROR_MESSAGES.TOKEN_NOT_ARRAY);
×
24
  }
25

26
  if (!(tokenIds.length >0)) {
6!
27
    throw new Error(ERROR_MESSAGES.TOKEN_LENGTH);
×
28
  }
29

30
  const result: NearContractCall<DelistArgsResponse> = [];
6✔
31

32
  //revoke ownership for all tokens
33
  for (const tokenId of tokenIds) {
6✔
34
    result.push ({
6✔
35
      contractAddress: contractAddress || mbjs.keys.marketAddress,
4!
36
      args: {
37
        token_id: tokenId,
38
        account_id: marketAddress || mbjs.keys.marketAddress,
4!
39
      },
40
      methodName: TOKEN_METHOD_NAMES.TOKEN_ACCOUNT_REVOKE,
41
      gas: GAS,
42
      deposit: ONE_YOCTO,
43
    }as ContractCall<DelistArgsResponse>) ;
44
  }
45
  
46

47
  result.push( {
6✔
48
    contractAddress: marketAddress || mbjs.keys.marketAddress,
4!
49
    methodName: oldMarket? MARKET_METHOD_NAMES.UNLIST_OLD_MARKET: MARKET_METHOD_NAMES.UNLIST,
4!
50
    args: {
51
      token_ids: tokenIds,
52
      nft_contract_id: contractAddress || mbjs.keys.marketAddress,
4!
53
    },
54
    gas: GAS,
55
    deposit: ONE_YOCTO,
56
  } as ContractCall<DelistMultipleArgsResponse>);
57

58
  return result as NearContractCall<DelistMultipleArgsResponse>; 
6✔
59
};
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