@ocap/state 1.18.100 → 1.18.102

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.
@@ -3,6 +3,7 @@ const { toAddress } = require('@ocap/util');
3
3
 
4
4
  // FIXME: add better validation
5
5
  const { create: createStateContext, update: updateStateContext } = require('../contexts/state');
6
+ const { nullify } = require('../util');
6
7
 
7
8
  const create = (attrs, context) => {
8
9
  const delegation = {
@@ -36,6 +37,8 @@ const update = (state, attrs, context) => {
36
37
  delegation.from = toAddress(attrs.from);
37
38
  }
38
39
 
40
+ delegation.ops = nullify(delegation.ops);
41
+
39
42
  return delegation;
40
43
  };
41
44
 
package/lib/util.js ADDED
@@ -0,0 +1,30 @@
1
+ /* eslint-disable no-prototype-builtins */
2
+ /* eslint-disable no-restricted-syntax */
3
+ function nullify(obj) {
4
+ if (typeof obj === 'undefined') {
5
+ return null;
6
+ }
7
+ if (typeof obj === 'object' && obj !== null) {
8
+ if (Array.isArray(obj)) {
9
+ obj.forEach((item, index) => {
10
+ obj[index] = nullify(item);
11
+ });
12
+ } else {
13
+ for (const key in obj) {
14
+ if (obj.hasOwnProperty(key)) {
15
+ if (typeof obj[key] === 'undefined') {
16
+ obj[key] = null;
17
+ } else if (typeof obj[key] === 'object') {
18
+ obj[key] = nullify(obj[key]);
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
24
+
25
+ return obj;
26
+ }
27
+
28
+ module.exports = {
29
+ nullify,
30
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.100",
6
+ "version": "1.18.102",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -16,12 +16,12 @@
16
16
  "coverage": "npm run test -- --coverage"
17
17
  },
18
18
  "dependencies": {
19
- "@arcblock/did": "1.18.100",
20
- "@arcblock/validator": "1.18.100",
21
- "@ocap/contract": "1.18.100",
22
- "@ocap/mcrypto": "1.18.100",
23
- "@ocap/message": "1.18.100",
24
- "@ocap/util": "1.18.100",
19
+ "@arcblock/did": "1.18.102",
20
+ "@arcblock/validator": "1.18.102",
21
+ "@ocap/contract": "1.18.102",
22
+ "@ocap/mcrypto": "1.18.102",
23
+ "@ocap/message": "1.18.102",
24
+ "@ocap/util": "1.18.102",
25
25
  "bloom-filters": "^1.3.9",
26
26
  "lodash": "^4.17.21"
27
27
  },
@@ -31,5 +31,5 @@
31
31
  "keywords": [],
32
32
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
33
33
  "license": "MIT",
34
- "gitHead": "600fdfe8e06f2c4db05739d541c47202c92a3c9e"
34
+ "gitHead": "f9735d521051d45331073b3e52c743ad01e3b8e5"
35
35
  }