@ocap/state 1.27.2 → 1.27.4
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/lib/states/chain.js +17 -3
- package/package.json +9 -9
package/lib/states/chain.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const pick = require('lodash/pick');
|
|
2
2
|
const isEqual = require('lodash/isEqual');
|
|
3
|
+
const get = require('lodash/get');
|
|
3
4
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
4
5
|
|
|
5
6
|
const { create: createStateContext, update: updateStateContext } = require('../contexts/state');
|
|
@@ -15,10 +16,23 @@ const create = (attrs) => {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const update = (state, updates) => {
|
|
18
|
-
const immutableAttrs = ['chainId', 'token', '
|
|
19
|
+
const immutableAttrs = ['chainId', 'moderator', 'token.symbol', 'token.decimal'];
|
|
20
|
+
|
|
21
|
+
// should not update these attrs cause the token address is generated from these attrs
|
|
22
|
+
if (!process.env.CHAIN_TOKEN_ADDRESS) {
|
|
23
|
+
immutableAttrs.push(
|
|
24
|
+
'token.name',
|
|
25
|
+
'token.description',
|
|
26
|
+
'token.unit',
|
|
27
|
+
'token.totalSupply',
|
|
28
|
+
'token.initialSupply',
|
|
29
|
+
'token.foreignToken'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
// eslint-disable-next-line no-restricted-syntax
|
|
20
34
|
for (const attr of immutableAttrs) {
|
|
21
|
-
if (updates
|
|
35
|
+
if (get(updates, attr) && !isEqual(get(updates, attr), get(state, attr))) {
|
|
22
36
|
throw new Error('FORBIDDEN', `Cannot update ${attr} field on chain state`);
|
|
23
37
|
}
|
|
24
38
|
}
|
|
@@ -26,7 +40,7 @@ const update = (state, updates) => {
|
|
|
26
40
|
const context = { txTime: new Date().toISOString() };
|
|
27
41
|
const chain = {
|
|
28
42
|
...state,
|
|
29
|
-
...pick(updates, ['version', 'transaction', 'accounts', 'vaults']),
|
|
43
|
+
...pick(updates, ['version', 'transaction', 'accounts', 'vaults', 'token']),
|
|
30
44
|
context: updateStateContext(state.context, context),
|
|
31
45
|
};
|
|
32
46
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.27.
|
|
6
|
+
"version": "1.27.4",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"bloom-filters": "^1.3.9",
|
|
14
14
|
"lodash": "^4.17.21",
|
|
15
|
-
"@arcblock/did": "1.27.
|
|
16
|
-
"@arcblock/validator": "1.27.
|
|
17
|
-
"@ocap/
|
|
18
|
-
"@ocap/message": "1.27.
|
|
19
|
-
"@ocap/
|
|
20
|
-
"@ocap/
|
|
21
|
-
"@ocap/
|
|
15
|
+
"@arcblock/did": "1.27.4",
|
|
16
|
+
"@arcblock/validator": "1.27.4",
|
|
17
|
+
"@ocap/mcrypto": "1.27.4",
|
|
18
|
+
"@ocap/message": "1.27.4",
|
|
19
|
+
"@ocap/util": "1.27.4",
|
|
20
|
+
"@ocap/wallet": "1.27.4",
|
|
21
|
+
"@ocap/contract": "1.27.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"jest": "^29.7.0",
|
|
25
25
|
"start-server-and-test": "^1.14.0",
|
|
26
|
-
"@ocap/e2e-test": "1.27.
|
|
26
|
+
"@ocap/e2e-test": "1.27.4"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [],
|
|
29
29
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|