@polkadot/types-codec 8.7.2-17 → 8.7.2-18

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/base/Option.js CHANGED
@@ -21,16 +21,23 @@ class None extends Null {
21
21
 
22
22
 
23
23
  function decodeOption(registry, Type, value) {
24
- // In the case of an option, unwrap the inner
25
- if (value instanceof Option) {
26
- value = value.value;
27
- }
28
-
29
- if (isNull(value) || isUndefined(value) || value === '0x' || value instanceof None) {
30
- return new None(registry);
31
- } else if (value instanceof Type) {
24
+ if (value instanceof Type) {
32
25
  // don't re-create, use as it (which also caters for derived types)
33
26
  return value;
27
+ } else if (value instanceof Option) {
28
+ if (value.value instanceof Type) {
29
+ // same instance, return it
30
+ return value.value;
31
+ } else if (value.isNone) {
32
+ // internal is None, we are also none
33
+ return new None(registry);
34
+ } // convert the actual value into known
35
+
36
+
37
+ return new Type(registry, value.value);
38
+ } else if (isNull(value) || isUndefined(value) || value === '0x' || value instanceof None) {
39
+ // anyhting empty we pass as-is
40
+ return new None(registry);
34
41
  } else if (isU8a(value)) {
35
42
  // the isU8a check happens last in the if-tree - since the wrapped value
36
43
  // may be an instance of it, so Type and Option checks go in first
@@ -30,16 +30,23 @@ class None extends _Null.Null {
30
30
 
31
31
 
32
32
  function decodeOption(registry, Type, value) {
33
- // In the case of an option, unwrap the inner
34
- if (value instanceof Option) {
35
- value = value.value;
36
- }
37
-
38
- if ((0, _util.isNull)(value) || (0, _util.isUndefined)(value) || value === '0x' || value instanceof None) {
39
- return new None(registry);
40
- } else if (value instanceof Type) {
33
+ if (value instanceof Type) {
41
34
  // don't re-create, use as it (which also caters for derived types)
42
35
  return value;
36
+ } else if (value instanceof Option) {
37
+ if (value.value instanceof Type) {
38
+ // same instance, return it
39
+ return value.value;
40
+ } else if (value.isNone) {
41
+ // internal is None, we are also none
42
+ return new None(registry);
43
+ } // convert the actual value into known
44
+
45
+
46
+ return new Type(registry, value.value);
47
+ } else if ((0, _util.isNull)(value) || (0, _util.isUndefined)(value) || value === '0x' || value instanceof None) {
48
+ // anyhting empty we pass as-is
49
+ return new None(registry);
43
50
  } else if ((0, _util.isU8a)(value)) {
44
51
  // the isU8a check happens last in the if-tree - since the wrapped value
45
52
  // may be an instance of it, so Type and Option checks go in first
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@polkadot/types-codec',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '8.7.2-17'
14
+ version: '8.7.2-18'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./cjs/detectPackage.js"
21
21
  ],
22
22
  "type": "module",
23
- "version": "8.7.2-17",
23
+ "version": "8.7.2-18",
24
24
  "main": "./cjs/index.js",
25
25
  "module": "./index.js",
26
26
  "types": "./index.d.ts",
package/packageInfo.js CHANGED
@@ -5,5 +5,5 @@ export const packageInfo = {
5
5
  name: '@polkadot/types-codec',
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.7.2-17'
8
+ version: '8.7.2-18'
9
9
  };