@abtnode/core 1.16.6-beta-7c9b42cc → 1.16.6-beta-9e9fec72
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.
|
@@ -576,7 +576,7 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
576
576
|
logger.info('blocklet stopped successfully', { processId, did });
|
|
577
577
|
|
|
578
578
|
if (updateStatus) {
|
|
579
|
-
const res = await
|
|
579
|
+
const res = await states.blocklet.setBlockletStatus(did, BlockletStatus.stopped);
|
|
580
580
|
// send notification to websocket channel
|
|
581
581
|
this.emit(BlockletEvents.statusChange, res);
|
|
582
582
|
|
|
@@ -669,10 +669,9 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
669
669
|
|
|
670
670
|
await states.blocklet.setBlockletStatus(did, BlockletStatus.stopping);
|
|
671
671
|
await reloadBlockletProcess(blocklet);
|
|
672
|
-
await states.blocklet.setBlockletStatus(did, BlockletStatus.running);
|
|
672
|
+
const res = await states.blocklet.setBlockletStatus(did, BlockletStatus.running);
|
|
673
673
|
logger.info('blocklet reload successfully', { did });
|
|
674
674
|
|
|
675
|
-
const res = await this.status(did);
|
|
676
675
|
this.emit(BlockletEvents.statusChange, res);
|
|
677
676
|
return res;
|
|
678
677
|
}
|
|
@@ -2351,7 +2350,11 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2351
2350
|
await states.blockletExtras.setConfigs([...ancestors.map((x) => x.meta.did), b.meta.did], environments);
|
|
2352
2351
|
|
|
2353
2352
|
// chain config
|
|
2354
|
-
await this._ensureAppChainConfig(
|
|
2353
|
+
await this._ensureAppChainConfig(
|
|
2354
|
+
blocklet.meta.did,
|
|
2355
|
+
environments.map((x) => ({ key: x.name, value: x.default })),
|
|
2356
|
+
{ force: false }
|
|
2357
|
+
);
|
|
2355
2358
|
});
|
|
2356
2359
|
} else {
|
|
2357
2360
|
const child = blocklet.children.find((x) => x.meta.did === childDid);
|
|
@@ -2362,7 +2365,11 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2362
2365
|
);
|
|
2363
2366
|
|
|
2364
2367
|
// chain config
|
|
2365
|
-
await this._ensureAppChainConfig(
|
|
2368
|
+
await this._ensureAppChainConfig(
|
|
2369
|
+
blocklet.meta.did,
|
|
2370
|
+
get(b.meta, 'environments', []).map((x) => ({ key: x.name, value: x.default })),
|
|
2371
|
+
{ force: false }
|
|
2372
|
+
);
|
|
2366
2373
|
});
|
|
2367
2374
|
}
|
|
2368
2375
|
}
|
|
@@ -2719,12 +2726,24 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2719
2726
|
}
|
|
2720
2727
|
}
|
|
2721
2728
|
|
|
2722
|
-
async _ensureAppChainConfig(metaDid, configs,
|
|
2723
|
-
const
|
|
2729
|
+
async _ensureAppChainConfig(metaDid, configs, { force = true } = {}) {
|
|
2730
|
+
const appConfigs = await states.blockletExtras.getConfigs([metaDid]);
|
|
2731
|
+
|
|
2732
|
+
const chainConfigs = configs
|
|
2733
|
+
.filter((x) => ['CHAIN_HOST', 'CHAIN_ID', 'CHAIN_TYPE'].includes(x.key))
|
|
2734
|
+
.filter((x) => {
|
|
2735
|
+
if (force) {
|
|
2736
|
+
return true;
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
const appConfig = appConfigs.find((y) => y.key === CHAIN_PROP_MAP_REVERSE[x.key]);
|
|
2740
|
+
return !appConfig || !appConfig.value;
|
|
2741
|
+
});
|
|
2724
2742
|
if (chainConfigs.length) {
|
|
2725
2743
|
const items = chainConfigs.map((x) => ({
|
|
2726
2744
|
...omit(x, ['description', 'validation']),
|
|
2727
|
-
|
|
2745
|
+
key: CHAIN_PROP_MAP_REVERSE[x.key],
|
|
2746
|
+
value: x.value,
|
|
2728
2747
|
shared: true,
|
|
2729
2748
|
secure: false,
|
|
2730
2749
|
required: false,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
/* eslint-disable no-continue */
|
|
3
|
+
|
|
4
|
+
const props = {
|
|
5
|
+
description: '',
|
|
6
|
+
validation: '',
|
|
7
|
+
shared: true,
|
|
8
|
+
secure: false,
|
|
9
|
+
required: false,
|
|
10
|
+
custom: false,
|
|
11
|
+
};
|
|
12
|
+
module.exports = async ({ states, printInfo }) => {
|
|
13
|
+
printInfo('Try to update app chain info...');
|
|
14
|
+
|
|
15
|
+
const blockletExtras = await states.blockletExtras.find({});
|
|
16
|
+
|
|
17
|
+
for (const extra of blockletExtras || []) {
|
|
18
|
+
const appConfigs = extra.configs || [];
|
|
19
|
+
|
|
20
|
+
const hasChainHostInApp = appConfigs.find((x) => x.key === 'BLOCKLET_APP_CHAIN_HOST');
|
|
21
|
+
const hasChainIdInApp = appConfigs.find((x) => x.key === 'BLOCKLET_APP_CHAIN_ID');
|
|
22
|
+
const hasChainTypeInApp = appConfigs.find((x) => x.key === 'BLOCKLET_APP_CHAIN_TYPE');
|
|
23
|
+
let shouldUpdate = false;
|
|
24
|
+
let hasSetChainHost = false;
|
|
25
|
+
let hasSetChainId = false;
|
|
26
|
+
let hasSetChainType = false;
|
|
27
|
+
|
|
28
|
+
const components = [];
|
|
29
|
+
for (const child of extra.children || []) {
|
|
30
|
+
components.push(child);
|
|
31
|
+
}
|
|
32
|
+
components.push(extra); // root component
|
|
33
|
+
|
|
34
|
+
for (const component of components) {
|
|
35
|
+
for (const config of component.configs || []) {
|
|
36
|
+
const { value } = config;
|
|
37
|
+
|
|
38
|
+
if (config.key === 'CHAIN_HOST' && value && !hasChainHostInApp && !hasSetChainHost) {
|
|
39
|
+
appConfigs.push({
|
|
40
|
+
key: 'BLOCKLET_APP_CHAIN_HOST',
|
|
41
|
+
value,
|
|
42
|
+
...props,
|
|
43
|
+
});
|
|
44
|
+
shouldUpdate = true;
|
|
45
|
+
hasSetChainHost = true;
|
|
46
|
+
printInfo(`Should update blocklet ${extra.did}, CHAIN_HOST: ${value}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (config.key === 'CHAIN_ID' && value && !hasChainIdInApp && !hasSetChainId) {
|
|
50
|
+
appConfigs.push({
|
|
51
|
+
key: 'BLOCKLET_APP_CHAIN_ID',
|
|
52
|
+
value,
|
|
53
|
+
...props,
|
|
54
|
+
});
|
|
55
|
+
shouldUpdate = true;
|
|
56
|
+
hasSetChainId = true;
|
|
57
|
+
printInfo(`Should update blocklet ${extra.did}, CHAIN_ID: ${value}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (config.key === 'CHAIN_TYPE' && value && !hasChainTypeInApp && !hasSetChainType) {
|
|
61
|
+
appConfigs.push({
|
|
62
|
+
key: 'BLOCKLET_APP_CHAIN_TYPE',
|
|
63
|
+
value,
|
|
64
|
+
...props,
|
|
65
|
+
});
|
|
66
|
+
shouldUpdate = true;
|
|
67
|
+
hasSetChainType = true;
|
|
68
|
+
printInfo(`Should update blocklet ${extra.did}, CHAIN_TYPE: ${value}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (shouldUpdate) {
|
|
74
|
+
await states.blockletExtras.update({ _id: extra._id }, { $set: { configs: appConfigs } });
|
|
75
|
+
printInfo(`Blocklet in blocklet_extra.db updated: ${extra.did}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -148,6 +148,7 @@ class BlockletExtrasState extends BaseState {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// CAUTION: setConfig() 方法中非必要 **不要** 传入 [{ name: xxx }], 要传入 [{ key: xxx }]. 前者会导致某些配置被自动删掉
|
|
151
152
|
generateSetFn(extra) {
|
|
152
153
|
return async (dids, data) => {
|
|
153
154
|
// eslint-disable-next-line no-param-reassign
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.6-beta-
|
|
6
|
+
"version": "1.16.6-beta-9e9fec72",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.16.6-beta-
|
|
23
|
-
"@abtnode/certificate-manager": "1.16.6-beta-
|
|
24
|
-
"@abtnode/constant": "1.16.6-beta-
|
|
25
|
-
"@abtnode/cron": "1.16.6-beta-
|
|
26
|
-
"@abtnode/db": "1.16.6-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.6-beta-
|
|
28
|
-
"@abtnode/queue": "1.16.6-beta-
|
|
29
|
-
"@abtnode/rbac": "1.16.6-beta-
|
|
30
|
-
"@abtnode/router-provider": "1.16.6-beta-
|
|
31
|
-
"@abtnode/static-server": "1.16.6-beta-
|
|
32
|
-
"@abtnode/timemachine": "1.16.6-beta-
|
|
33
|
-
"@abtnode/util": "1.16.6-beta-
|
|
22
|
+
"@abtnode/auth": "1.16.6-beta-9e9fec72",
|
|
23
|
+
"@abtnode/certificate-manager": "1.16.6-beta-9e9fec72",
|
|
24
|
+
"@abtnode/constant": "1.16.6-beta-9e9fec72",
|
|
25
|
+
"@abtnode/cron": "1.16.6-beta-9e9fec72",
|
|
26
|
+
"@abtnode/db": "1.16.6-beta-9e9fec72",
|
|
27
|
+
"@abtnode/logger": "1.16.6-beta-9e9fec72",
|
|
28
|
+
"@abtnode/queue": "1.16.6-beta-9e9fec72",
|
|
29
|
+
"@abtnode/rbac": "1.16.6-beta-9e9fec72",
|
|
30
|
+
"@abtnode/router-provider": "1.16.6-beta-9e9fec72",
|
|
31
|
+
"@abtnode/static-server": "1.16.6-beta-9e9fec72",
|
|
32
|
+
"@abtnode/timemachine": "1.16.6-beta-9e9fec72",
|
|
33
|
+
"@abtnode/util": "1.16.6-beta-9e9fec72",
|
|
34
34
|
"@arcblock/did": "1.18.75",
|
|
35
35
|
"@arcblock/did-auth": "1.18.75",
|
|
36
36
|
"@arcblock/did-ext": "^1.18.75",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@arcblock/jwt": "^1.18.75",
|
|
41
41
|
"@arcblock/pm2-events": "^0.0.5",
|
|
42
42
|
"@arcblock/vc": "1.18.75",
|
|
43
|
-
"@blocklet/constant": "1.16.6-beta-
|
|
44
|
-
"@blocklet/meta": "1.16.6-beta-
|
|
45
|
-
"@blocklet/sdk": "1.16.6-beta-
|
|
43
|
+
"@blocklet/constant": "1.16.6-beta-9e9fec72",
|
|
44
|
+
"@blocklet/meta": "1.16.6-beta-9e9fec72",
|
|
45
|
+
"@blocklet/sdk": "1.16.6-beta-9e9fec72",
|
|
46
46
|
"@did-space/client": "^0.2.80",
|
|
47
47
|
"@fidm/x509": "^1.2.1",
|
|
48
48
|
"@ocap/client": "1.18.75",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"express": "^4.18.2",
|
|
99
99
|
"jest": "^27.5.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "a30731223bc19231bac0dea7bd0d01a3bbf8e84c"
|
|
102
102
|
}
|