@polkadot/types-create 8.5.1 → 8.5.2-0

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.
@@ -183,5 +183,8 @@ function getTypeClass(registry, typeDef) {
183
183
  }
184
184
 
185
185
  function createClassUnsafe(registry, type) {
186
- return getTypeClass(registry, registry.isLookupType(type) ? registry.lookup.getTypeDef(type) : (0, _getTypeDef.getTypeDef)(type));
186
+ return (// just retrieve via name, no creation via typeDef
187
+ registry.getUnsafe(type) || // we don't have an existing type, create the class via typeDef
188
+ getTypeClass(registry, registry.isLookupType(type) ? registry.lookup.getTypeDef(type) : (0, _getTypeDef.getTypeDef)(type))
189
+ );
187
190
  }
@@ -27,14 +27,11 @@ function checkInstance(created, matcher) {
27
27
 
28
28
  function checkPedantic(created, _ref) {
29
29
  let [value] = _ref;
30
- let isPedantic = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
31
30
 
32
- if (isPedantic) {
33
- if ((0, _util.isU8a)(value)) {
34
- checkInstance(created, value);
35
- } else if ((0, _util.isHex)(value)) {
36
- checkInstance(created, (0, _util.u8aToU8a)(value));
37
- }
31
+ if ((0, _util.isU8a)(value)) {
32
+ checkInstance(created, value);
33
+ } else if ((0, _util.isHex)(value)) {
34
+ checkInstance(created, (0, _util.u8aToU8a)(value));
38
35
  }
39
36
  } // Initializes a type with a value. This also checks for fallbacks and in the cases
40
37
  // where isPedantic is specified (storage decoding), also check the format/structure
@@ -48,7 +45,7 @@ function initType(registry, Type) {
48
45
  isPedantic
49
46
  } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
50
47
  const created = new (isOptional ? _typesCodec.Option.with(Type) : Type)(registry, ...params);
51
- checkPedantic(created, params, isPedantic);
48
+ isPedantic && checkPedantic(created, params);
52
49
 
53
50
  if (blockHash) {
54
51
  created.createdAtHash = createTypeUnsafe(registry, 'Hash', [blockHash]);
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@polkadot/types-create',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '8.5.1'
14
+ version: '8.5.2-0'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
package/create/class.js CHANGED
@@ -158,5 +158,8 @@ export function getTypeClass(registry, typeDef) {
158
158
  return registry.getUnsafe(typeDef.type, false, typeDef);
159
159
  }
160
160
  export function createClassUnsafe(registry, type) {
161
- return getTypeClass(registry, registry.isLookupType(type) ? registry.lookup.getTypeDef(type) : getTypeDef(type));
161
+ return (// just retrieve via name, no creation via typeDef
162
+ registry.getUnsafe(type) || // we don't have an existing type, create the class via typeDef
163
+ getTypeClass(registry, registry.isLookupType(type) ? registry.lookup.getTypeDef(type) : getTypeDef(type))
164
+ );
162
165
  }
package/create/type.js CHANGED
@@ -15,13 +15,11 @@ function checkInstance(created, matcher) {
15
15
  assert(isOk, () => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(matcher, 512)} (${matcher.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`);
16
16
  }
17
17
 
18
- function checkPedantic(created, [value], isPedantic = false) {
19
- if (isPedantic) {
20
- if (isU8a(value)) {
21
- checkInstance(created, value);
22
- } else if (isHex(value)) {
23
- checkInstance(created, u8aToU8a(value));
24
- }
18
+ function checkPedantic(created, [value]) {
19
+ if (isU8a(value)) {
20
+ checkInstance(created, value);
21
+ } else if (isHex(value)) {
22
+ checkInstance(created, u8aToU8a(value));
25
23
  }
26
24
  } // Initializes a type with a value. This also checks for fallbacks and in the cases
27
25
  // where isPedantic is specified (storage decoding), also check the format/structure
@@ -33,7 +31,7 @@ function initType(registry, Type, params = [], {
33
31
  isPedantic
34
32
  } = {}) {
35
33
  const created = new (isOptional ? Option.with(Type) : Type)(registry, ...params);
36
- checkPedantic(created, params, isPedantic);
34
+ isPedantic && checkPedantic(created, params);
37
35
 
38
36
  if (blockHash) {
39
37
  created.createdAtHash = createTypeUnsafe(registry, 'Hash', [blockHash]);
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./cjs/detectPackage.js"
21
21
  ],
22
22
  "type": "module",
23
- "version": "8.5.1",
23
+ "version": "8.5.2-0",
24
24
  "main": "./cjs/index.js",
25
25
  "module": "./index.js",
26
26
  "types": "./index.d.ts",
@@ -121,7 +121,7 @@
121
121
  },
122
122
  "dependencies": {
123
123
  "@babel/runtime": "^7.18.0",
124
- "@polkadot/types-codec": "8.5.1",
124
+ "@polkadot/types-codec": "8.5.2-0",
125
125
  "@polkadot/util": "^9.2.1"
126
126
  }
127
127
  }
package/packageInfo.js CHANGED
@@ -5,5 +5,5 @@ export const packageInfo = {
5
5
  name: '@polkadot/types-create',
6
6
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
7
7
  type: 'esm',
8
- version: '8.5.1'
8
+ version: '8.5.2-0'
9
9
  };