@polkadot/types-create 9.14.2 → 10.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/util/typeSplit.js CHANGED
@@ -1,70 +1,57 @@
1
- // Copyright 2017-2023 @polkadot/types-create authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // safely split a string on ', ' while taking care of any nested occurences
5
1
  export function typeSplit(type) {
6
- const result = [];
7
-
8
- // these are the depths of the various tokens: <, [, {, (
9
- let c = 0;
10
- let f = 0;
11
- let s = 0;
12
- let t = 0;
13
-
14
- // current start position
15
- let start = 0;
16
- for (let i = 0; i < type.length; i++) {
17
- switch (type[i]) {
18
- // if we are not nested, add the type
19
- case ',':
20
- {
21
- if (!(c || f || s || t)) {
22
- result.push(type.substring(start, i).trim());
23
- start = i + 1;
24
- }
25
- break;
2
+ const result = [];
3
+ // these are the depths of the various tokens: <, [, {, (
4
+ let c = 0;
5
+ let f = 0;
6
+ let s = 0;
7
+ let t = 0;
8
+ // current start position
9
+ let start = 0;
10
+ for (let i = 0; i < type.length; i++) {
11
+ switch (type[i]) {
12
+ // if we are not nested, add the type
13
+ case ',': {
14
+ if (!(c || f || s || t)) {
15
+ result.push(type.substring(start, i).trim());
16
+ start = i + 1;
17
+ }
18
+ break;
19
+ }
20
+ // adjust compact/vec (and friends) depth
21
+ case '<':
22
+ c++;
23
+ break;
24
+ case '>':
25
+ c--;
26
+ break;
27
+ // adjust fixed vec depths
28
+ case '[':
29
+ f++;
30
+ break;
31
+ case ']':
32
+ f--;
33
+ break;
34
+ // adjust struct depth
35
+ case '{':
36
+ s++;
37
+ break;
38
+ case '}':
39
+ s--;
40
+ break;
41
+ // adjust tuple depth
42
+ case '(':
43
+ t++;
44
+ break;
45
+ case ')':
46
+ t--;
47
+ break;
26
48
  }
27
-
28
- // adjust compact/vec (and friends) depth
29
- case '<':
30
- c++;
31
- break;
32
- case '>':
33
- c--;
34
- break;
35
-
36
- // adjust fixed vec depths
37
- case '[':
38
- f++;
39
- break;
40
- case ']':
41
- f--;
42
- break;
43
-
44
- // adjust struct depth
45
- case '{':
46
- s++;
47
- break;
48
- case '}':
49
- s--;
50
- break;
51
-
52
- // adjust tuple depth
53
- case '(':
54
- t++;
55
- break;
56
- case ')':
57
- t--;
58
- break;
59
49
  }
60
- }
61
-
62
- // ensure we have all the terminators taken care of
63
- if (c || f || s || t) {
64
- throw new Error(`Invalid definition (missing terminators) found in ${type}`);
65
- }
66
-
67
- // the final leg of the journey
68
- result.push(type.substring(start, type.length).trim());
69
- return result;
50
+ // ensure we have all the terminators taken care of
51
+ if (c || f || s || t) {
52
+ throw new Error(`Invalid definition (missing terminators) found in ${type}`);
53
+ }
54
+ // the final leg of the journey
55
+ result.push(type.substring(start, type.length).trim());
56
+ return result;
70
57
  }
package/util/xcm.js CHANGED
@@ -1,10 +1,5 @@
1
- // Copyright 2017-2023 @polkadot/types-create authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  import { objectSpread } from '@polkadot/util';
5
2
  export const XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions', 'MultiAsset', 'MultiAssetFilter', 'MultiLocation', 'Response', 'WildFungibility', 'WildMultiAsset', 'Xcm', 'XcmError', 'XcmOrder'];
6
3
  export function mapXcmTypes(version) {
7
- return XCM_MAPPINGS.reduce((all, key) => objectSpread(all, {
8
- [key]: `${key}${version}`
9
- }), {});
4
+ return XCM_MAPPINGS.reduce((all, key) => objectSpread(all, { [key]: `${key}${version}` }), {});
10
5
  }