@blocklet/meta 1.6.0 → 1.6.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/constants.js CHANGED
@@ -140,8 +140,9 @@ module.exports = Object.freeze({
140
140
  BLOCKLET_DEFAULT_VERSION: '1.0.0',
141
141
  BLOCKLET_DEFAULT_PORT_NAME: 'BLOCKLET_PORT',
142
142
 
143
- BLOCKLET_LATEST_SPEC_VERSION: '1.2.0',
144
- BLOCKLET_LATEST_REQUIREMENT_ABTNODE: '>=1.5.15',
143
+ BLOCKLET_LATEST_SPEC_VERSION: '1.2.1',
144
+ BLOCKLET_LATEST_REQUIREMENT_SERVER: '>=1.6.2',
145
+ BLOCKLET_LATEST_REQUIREMENT_ABTNODE: '>=1.5.15', // Deprecated
145
146
 
146
147
  BLOCKLET_CONFIGURABLE_KEY: {
147
148
  BLOCKLET_CLUSTER_SIZE: 'BLOCKLET_CLUSTER_SIZE',
package/lib/info.js CHANGED
@@ -1,16 +1,30 @@
1
1
  const get = require('lodash/get');
2
2
  const getBlockletWallet = require('./wallet');
3
3
 
4
- module.exports = (state, nodeSk) => {
4
+ module.exports = (state, nodeSk, { returnWallet = true } = {}) => {
5
5
  if (!state || typeof state !== 'object' || !Array.isArray(state.environments) || !get(state, 'meta.did')) {
6
6
  throw new Error('Blocklet state must be an object');
7
7
  }
8
+
9
+ const customName = state.environments.find((x) => x.key === 'BLOCKLET_APP_NAME');
10
+ const customDescription = state.environments.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
11
+
12
+ const { did } = state.meta;
13
+ const name = get(customName, 'value', state.meta.title || state.meta.name);
14
+ const description = get(customDescription, 'value', state.meta.description);
15
+
16
+ if (!returnWallet) {
17
+ return {
18
+ did,
19
+ name,
20
+ description,
21
+ };
22
+ }
23
+
8
24
  if (!nodeSk || typeof nodeSk !== 'string') {
9
25
  throw new Error('Node secret key must be a string');
10
26
  }
11
27
 
12
- const customName = state.environments.find((x) => x.key === 'BLOCKLET_APP_NAME');
13
- const customDescription = state.environments.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
14
28
  const customSk = state.environments.find((x) => x.key === 'BLOCKLET_APP_SK');
15
29
  const customType = state.environments.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
16
30
 
@@ -31,9 +45,9 @@ module.exports = (state, nodeSk) => {
31
45
  }
32
46
 
33
47
  return {
34
- did: state.meta.did,
35
- name: get(customName, 'value', state.meta.title || state.meta.name),
36
- description: get(customDescription, 'value', state.meta.description),
48
+ did,
49
+ name,
50
+ description,
37
51
  wallet,
38
52
  };
39
53
  };
package/lib/payment.js CHANGED
@@ -5,14 +5,7 @@ const { isValidFactory } = require('@ocap/asset');
5
5
  const { toFactoryAddress } = require('@arcblock/did-util');
6
6
  const { getBlockletPurchaseTemplate } = require('@arcblock/nft/lib/templates');
7
7
 
8
- const isFreeBlocklet = (meta) => {
9
- if (!meta.payment) {
10
- return true;
11
- }
12
-
13
- const priceList = (meta.payment.price || []).map((x) => x.value || 0);
14
- return priceList.every((x) => x === 0);
15
- };
8
+ const { isFreeBlocklet } = require('./util');
16
9
 
17
10
  const createShareContract = ({ tokens = [], shares = [] }) => {
18
11
  const zeroBN = new BN(0);
package/lib/schema.js CHANGED
@@ -17,7 +17,7 @@ const {
17
17
  BLOCKLET_DEFAULT_PORT_NAME,
18
18
  BLOCKLET_DYNAMIC_PATH_PREFIX,
19
19
  BlockletGroup,
20
- BLOCKLET_LATEST_REQUIREMENT_ABTNODE,
20
+ BLOCKLET_LATEST_REQUIREMENT_SERVER,
21
21
  BLOCKLET_INTERFACE_TYPE_WEB,
22
22
  BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
23
23
  } = require('./constants');
@@ -274,7 +274,8 @@ const createBlockletSchema = (
274
274
  }).default({ start: 60 }),
275
275
 
276
276
  requirements: Joi.object({
277
- abtnode: Joi.semverRange().valid(),
277
+ abtnode: Joi.semverRange().valid(), // deprecated in v1.6.1
278
+ server: Joi.semverRange().valid(),
278
279
  os: Joi.alternatives().try(
279
280
  Joi.string().valid('*', ...BLOCKLET_PLATFORMS),
280
281
  Joi.array()
@@ -287,7 +288,7 @@ const createBlockletSchema = (
287
288
  .items(Joi.string().valid(...BLOCKLET_ARCHITECTURES))
288
289
  .min(1)
289
290
  ),
290
- }).default({ abtnode: BLOCKLET_LATEST_REQUIREMENT_ABTNODE, os: '*', cpu: '*' }),
291
+ }).default({ server: BLOCKLET_LATEST_REQUIREMENT_SERVER, os: '*', cpu: '*' }),
291
292
 
292
293
  // interfaces: https://github.com/blocklet/blocklet-specification/issues/2
293
294
  interfaces: Joi.array()
package/lib/util.js CHANGED
@@ -82,7 +82,17 @@ const getRequiredMissingConfigs = (blocklet) => {
82
82
  return missingConfigs;
83
83
  };
84
84
 
85
+ const isFreeBlocklet = (meta) => {
86
+ if (!meta.payment) {
87
+ return true;
88
+ }
89
+
90
+ const priceList = (meta.payment.price || []).map((x) => x.value || 0);
91
+ return priceList.every((x) => x === 0);
92
+ };
93
+
85
94
  module.exports = {
95
+ isFreeBlocklet,
86
96
  forEachBlocklet,
87
97
  isAuthServiceEnabled,
88
98
  getRequiredMissingConfigs,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.0",
6
+ "version": "1.6.4",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,14 +18,14 @@
18
18
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@arcblock/did": "^1.13.65",
22
- "@arcblock/did-ext": "^1.13.65",
23
- "@arcblock/did-util": "^1.13.65",
24
- "@arcblock/nft": "^1.13.65",
25
- "@ocap/asset": "^1.13.65",
26
- "@ocap/mcrypto": "^1.13.65",
27
- "@ocap/util": "^1.13.65",
28
- "@ocap/wallet": "^1.13.65",
21
+ "@arcblock/did": "^1.13.77",
22
+ "@arcblock/did-ext": "^1.13.77",
23
+ "@arcblock/did-util": "^1.13.77",
24
+ "@arcblock/nft": "^1.13.77",
25
+ "@ocap/asset": "^1.13.77",
26
+ "@ocap/mcrypto": "^1.13.77",
27
+ "@ocap/util": "^1.13.77",
28
+ "@ocap/wallet": "^1.13.77",
29
29
  "ajv": "^7.0.3",
30
30
  "debug": "^4.3.3",
31
31
  "fs-extra": "^10.0.0",
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "jest": "^27.3.1"
44
44
  },
45
- "gitHead": "5927d4780b21ce46406857575c44e1a8667eddaa"
45
+ "gitHead": "1c144cb9fb9a9952bc92f25cabbdb47a378cbd24"
46
46
  }