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

Mintbase / mintbase-js / 13994325548

21 Mar 2025 02:43PM CUT coverage: 77.007%. First build
13994325548

Pull #555

github

rubenmarcus
deprecate packages
Pull Request #555: deprecate react and wallet packages

890 of 1336 branches covered (66.62%)

Branch coverage included in aggregate %.

1153 of 1317 relevant lines covered (87.55%)

15.01 hits per line

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

70.37
/packages/sdk/src/setSplits/setSplits.ts
1
import { mbjs } from '../config/config';
3✔
2
import { GAS, STORAGE_BYTES, STORAGE_PRICE_PER_BYTE_EXPONENT } from '../constants';
3✔
3
import { ERROR_MESSAGES } from '../errorMessages';
3✔
4
import { SetSplitsArgs, SetSplitsArgsResponse, TOKEN_METHOD_NAMES, NearContractCall } from '../types';
3✔
5

6

7
/**
8
 * Set splits for a token
9
 * @param setSplitsArguments {@link SetSplitsArgs}
10
 * @returns contract call to be passed to @mintbase-js/sdk execute method
11
 */
12
export const setSplits = (args: SetSplitsArgs): NearContractCall<SetSplitsArgsResponse> => {
3✔
13
  const {
14
    contractAddress = mbjs.keys.contractAddress,
×
15
    tokenIds,
16
    splitOwners,
17
  } = args;
3✔
18

19
  if (!contractAddress) {
3!
20
    throw new Error(ERROR_MESSAGES.CONTRACT_ADDRESS);
×
21
  }
22

23
  if (tokenIds.length < 1) {
3!
24
    throw new Error(ERROR_MESSAGES.SET_SPLITS_NO_TOKEN_IDS);
×
25
  }
26

27
  const requiredBytes = Object.keys(splitOwners).length * tokenIds.length * STORAGE_BYTES.COMMON;
3✔
28
  const deposit = `${requiredBytes.toString()}${'0'.repeat(STORAGE_PRICE_PER_BYTE_EXPONENT)}`;
3✔
29

30
  let sum = 0;
3✔
31
  const intSplitOwners = {};
3✔
32
  Object.entries(splitOwners).forEach(([account, split]) => {
3✔
33
    const intSplit = split * 10000;
6✔
34
    intSplitOwners[account] = intSplit;
6✔
35
    sum += intSplit;
6✔
36
  });
37

38
  if (sum !== 10000) {
3!
39
    throw new Error(ERROR_MESSAGES.SPLITS_NOT_HUNDERT_PERCENT);
×
40
  }
41

42
  return {
3✔
43
    contractAddress: contractAddress || mbjs.keys.contractAddress,
2!
44
    args: {
45
      token_ids: tokenIds,
46
      split_between: intSplitOwners,
47
    },
48
    methodName: TOKEN_METHOD_NAMES.SET_SPLITS,
49
    deposit,
50
    gas: GAS,
51
  };
52
};
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