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

Mintbase / mintbase-js / 8845566891

26 Apr 2024 08:42AM CUT 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

70.27
/packages/sdk/src/updateMetadata/updateMetadata.ts
1
import BN from 'bn.js';
2
import { mbjs } from '../config/config';
3✔
3
import { GAS, STORAGE_BYTES, STORAGE_PRICE_PER_BYTE_EXPONENT } from '../constants';
3✔
4
import { ERROR_MESSAGES } from '../errorMessages';
3✔
5
import { UpdateMetadataArgs, UpdateMetadataArgsResponse, NearContractCall, TOKEN_METHOD_NAMES } from '../types';
3✔
6
import { isIntString, isStoreV2 } from '../utils';
3✔
7

8
/**
9
 * Mint a token given via reference json on a given contract with a specified owner, amount of copies as well and royalties can be specified via options
10
 * @param mintArguments {@link MintArgs}
11
 * @returns contract call to be passed to @mintbase-js/sdk execute method
12
 */
13
export const updateMetadata = (
3✔
14
  args: UpdateMetadataArgs,
15
): NearContractCall<UpdateMetadataArgsResponse> => {
16
  const {
17
    contractAddress = mbjs.keys.contractAddress,
×
18
    metadataId,
19
    metadata,
20
    noReference = false,
6✔
21
    noMedia = false,
6✔
22
  } = args;
9✔
23

24
  if (!contractAddress) {
9!
25
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
26
  }
27
  
28
  if (!isStoreV2(contractAddress)) {
9!
29
    throw new Error(ERROR_MESSAGES.ONLY_V2);
×
30
  }
31

32
  if (!isIntString(metadataId)) {
9!
33
    throw new Error(ERROR_MESSAGES.METADATA_ID_NOT_INT);
×
34
  }
35

36
  // Reference and media need to be present or explicitly opted out of
37
  if (!noReference && !metadata.reference) {
9✔
38
    throw new Error(ERROR_MESSAGES.NO_REFERENCE);
3✔
39
  }
40
  if (!noMedia && !metadata.media) {
6✔
41
    throw new Error(ERROR_MESSAGES.NO_MEDIA);
3✔
42
  }
43

44

45
  return {
3✔
46
    contractAddress: contractAddress || mbjs.keys.contractAddress,
2!
47
    args: {
48
      metadata_id: metadataId,
49
      metadata,
50
    },
51
    methodName: TOKEN_METHOD_NAMES.UPDATE_METADATA,
52
    gas: GAS,
53
    deposit: '1', // FIXME: should cover storage, not only 1 yocto.
54
  };
55
};
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