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

Mintbase / mintbase-js / 7929488522

16 Feb 2024 10:48AM UTC coverage: 77.204%. First build
7929488522

Pull #476

github

rubenmarcus
fix attributes by contract
Pull Request #476: fix attributes by contract

839 of 1269 branches covered (66.12%)

Branch coverage included in aggregate %.

1149 of 1306 relevant lines covered (87.98%)

12.91 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
  
19
  if (contractAddress == null) {
6!
20
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
21
  }
22

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

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

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

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

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

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