@blocklet/launcher-util 1.9.11 → 1.9.13

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/constant.js CHANGED
@@ -41,6 +41,12 @@ const SERVER_ACTIVITY_TYPE = Object.freeze({
41
41
  replacement: 'replacement',
42
42
  });
43
43
 
44
+ const SERVERLESS_INSTANCE_STATUS = {
45
+ launching: 10,
46
+ consumed: 20,
47
+ expired: 30,
48
+ };
49
+
44
50
  const toMap = (staus) =>
45
51
  Object.keys(staus).reduce((acc, cur) => {
46
52
  acc[staus[cur]] = cur;
@@ -55,6 +61,8 @@ const planStatusMap = toMap(PLAN_STATUS);
55
61
  const fromInstanceStatus = fromStatus(statusInstanceMap);
56
62
  const fromPlanStatus = fromStatus(planStatusMap);
57
63
 
64
+ const NFT_TYPE_SERVERLESS = 'BlockletServerServerlessNFT'; // TODO: 使用 abtnode/constant 包里的
65
+
58
66
  module.exports = Object.freeze({
59
67
  SKU_STATUS: Object.freeze({
60
68
  DISABLED: 0,
@@ -96,4 +104,6 @@ module.exports = Object.freeze({
96
104
  fiat: 'fiat',
97
105
  crypto: 'crypto',
98
106
  },
107
+ NFT_TYPE_SERVERLESS,
108
+ SERVERLESS_INSTANCE_STATUS,
99
109
  });
@@ -0,0 +1,48 @@
1
+ const joinUrl = require('url-join');
2
+ const axios = require('axios');
3
+ const get = require('lodash.get');
4
+
5
+ const getAsset = async (chainHost, address) => {
6
+ const url = joinUrl(new URL(chainHost).origin, '/api/gql/');
7
+
8
+ const result = await axios.post(
9
+ url,
10
+ JSON.stringify({
11
+ query: `{
12
+ getAssetState(address: "${address}") {
13
+ state {
14
+ address
15
+ data {
16
+ typeUrl
17
+ value
18
+ }
19
+ display {
20
+ type
21
+ content
22
+ }
23
+ issuer
24
+ owner
25
+ parent
26
+ tags
27
+ }
28
+ }
29
+ }`,
30
+ }),
31
+ {
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ Accept: 'application/json',
35
+ },
36
+ timeout: 60 * 1000,
37
+ }
38
+ );
39
+
40
+ const state = get(result, 'data.data.getAssetState.state');
41
+ if (state && state.data.typeUrl === 'json') {
42
+ state.data.value = JSON.parse(state.data.value);
43
+ }
44
+
45
+ return state;
46
+ };
47
+
48
+ module.exports = getAsset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-util",
3
- "version": "1.9.11",
3
+ "version": "1.9.13",
4
4
  "description": "Common constants",
5
5
  "keywords": [
6
6
  "constant"
@@ -31,10 +31,13 @@
31
31
  "url": "https://github.com/blocklet/launcher/issues"
32
32
  },
33
33
  "dependencies": {
34
- "@ocap/util": "^1.18.17",
34
+ "@ocap/util": "^1.18.23",
35
+ "axios": "^0.26.1",
36
+ "lodash.get": "^4.4.2",
35
37
  "lodash.pick": "^4.4.0",
36
38
  "moment": "^2.29.4",
37
- "moment-timezone": "^0.5.39"
39
+ "moment-timezone": "^0.5.39",
40
+ "url-join": "^4.0.1"
38
41
  },
39
- "gitHead": "379a297f8aa4ae9e508dc179fc4008821d145b81"
42
+ "gitHead": "c2192c94567e6b096096c82214da83d992ce988d"
40
43
  }