@blocklet/sdk 1.16.6-beta-08670107 → 1.16.6-beta-56be9f01

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.
@@ -12,16 +12,18 @@ const wallet_1 = __importDefault(require("../wallet"));
12
12
  // wraps value in closure or returns closure
13
13
  const closure = (value) => (typeof value === 'function' ? value : () => value);
14
14
  const getDelegator = () => {
15
- const { BLOCKLET_APP_SK, BLOCKLET_APP_PSK, BLOCKLET_WALLET_TYPE } = process.env;
15
+ // BLOCKLET_WALLET_TYPE is for backward compatibility
16
+ const { BLOCKLET_APP_SK, BLOCKLET_APP_PSK, BLOCKLET_WALLET_TYPE, CHAIN_TYPE } = process.env;
16
17
  if (BLOCKLET_APP_SK && BLOCKLET_APP_PSK && BLOCKLET_APP_SK !== BLOCKLET_APP_PSK) {
17
- return (0, wallet_1.default)(BLOCKLET_WALLET_TYPE, BLOCKLET_APP_PSK);
18
+ return (0, wallet_1.default)(CHAIN_TYPE || BLOCKLET_WALLET_TYPE, BLOCKLET_APP_PSK);
18
19
  }
19
20
  return null;
20
21
  };
21
22
  exports.getDelegator = getDelegator;
22
23
  const getDelegatee = () => {
23
- const { BLOCKLET_APP_SK, BLOCKLET_WALLET_TYPE } = process.env;
24
- return (0, wallet_1.default)(BLOCKLET_WALLET_TYPE, BLOCKLET_APP_SK);
24
+ // BLOCKLET_WALLET_TYPE is for backward compatibility
25
+ const { BLOCKLET_APP_SK, BLOCKLET_WALLET_TYPE, CHAIN_TYPE } = process.env;
26
+ return (0, wallet_1.default)(CHAIN_TYPE || BLOCKLET_WALLET_TYPE, BLOCKLET_APP_SK);
25
27
  };
26
28
  exports.getDelegatee = getDelegatee;
27
29
  const getDelegation = (delegator, delegatee) => {
@@ -16,7 +16,9 @@ const wallet_2 = __importDefault(require("../wallet"));
16
16
  const { NODE_SERVICES, WELLKNOWN_SERVICE_PATH_PREFIX, USER_AVATAR_URL_PREFIX, USER_AVATAR_PATH_PREFIX } = constant_1.default;
17
17
  const VERSION = version_1.version; // version of notification sdk
18
18
  const isNotNullOrUndefined = (x) => ![null, undefined].includes(x);
19
- const type = process.env.BLOCKLET_WALLET_TYPE !== 'eth'
19
+ // BLOCKLET_WALLET_TYPE is for backward compatibility
20
+ const chainType = process.env.CHAIN_TYPE || process.env.BLOCKLET_WALLET_TYPE;
21
+ const type = chainType !== 'ethereum' && chainType !== 'eth'
20
22
  ? (0, wallet_1.WalletType)({ role: mcrypto_1.types.RoleType.ROLE_APPLICATION, pk: mcrypto_1.types.KeyType.ED25519, hash: mcrypto_1.types.HashType.SHA3 })
21
23
  : 'eth';
22
24
  const fixAvatar = (user) => {
package/lib/wallet.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { WalletObject } from '@ocap/wallet';
2
2
  import { DIDTypeShortcut } from '@arcblock/did';
3
3
  /**
4
- * @param {string} [type=process.env.BLOCKLET_WALLET_TYPE] can only be 'eth|ethereum' or 'default|arcblock'
4
+ * @param {string} [type=process.env.CHAIN_TYPE] can only be 'eth|ethereum' or 'default|arcblock'
5
5
  * @param {string} [appSk=process.env.BLOCKLET_APP_SK] must be hex
6
6
  * @return {WalletObject} {WalletObject}
7
7
  */
package/lib/wallet.js CHANGED
@@ -3,13 +3,16 @@ const wallet_1 = require("@ocap/wallet");
3
3
  const mcrypto_1 = require("@ocap/mcrypto");
4
4
  const did_1 = require("@arcblock/did");
5
5
  /**
6
- * @param {string} [type=process.env.BLOCKLET_WALLET_TYPE] can only be 'eth|ethereum' or 'default|arcblock'
6
+ * @param {string} [type=process.env.CHAIN_TYPE] can only be 'eth|ethereum' or 'default|arcblock'
7
7
  * @param {string} [appSk=process.env.BLOCKLET_APP_SK] must be hex
8
8
  * @return {WalletObject} {WalletObject}
9
9
  */
10
- const getWallet = (type = process.env.BLOCKLET_WALLET_TYPE, appSk = process.env.BLOCKLET_APP_SK) => {
10
+ const getWallet = (type, appSk = process.env.BLOCKLET_APP_SK) => {
11
11
  let t;
12
12
  let sk;
13
+ // BLOCKLET_WALLET_TYPE is for backward compatibility
14
+ // eslint-disable-next-line no-param-reassign
15
+ type = type || process.env.CHAIN_TYPE || process.env.BLOCKLET_WALLET_TYPE;
13
16
  if ((0, did_1.isEthereumType)((0, did_1.DidType)(type))) {
14
17
  sk = appSk.slice(0, 66);
15
18
  t = (0, wallet_1.WalletType)(type);
@@ -20,7 +23,8 @@ const getWallet = (type = process.env.BLOCKLET_WALLET_TYPE, appSk = process.env.
20
23
  }
21
24
  return (0, wallet_1.fromSecretKey)(sk, t);
22
25
  };
23
- const getPermanentWallet = () => getWallet(process.env.BLOCKLET_WALLET_TYPE, process.env.BLOCKLET_APP_PSK);
26
+ // BLOCKLET_WALLET_TYPE is for backward compatibility
27
+ const getPermanentWallet = () => getWallet(process.env.CHAIN_TYPE || process.env.BLOCKLET_WALLET_TYPE, process.env.BLOCKLET_APP_PSK);
24
28
  const getEthereumWallet = (permanent = false) => getWallet('ethereum', permanent ? process.env.BLOCKLET_APP_PSK : process.env.BLOCKLET_APP_SK);
25
29
  getWallet.getPermanentWallet = getPermanentWallet;
26
30
  getWallet.getEthereumWallet = getEthereumWallet;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.6-beta-08670107",
6
+ "version": "1.16.6-beta-56be9f01",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
@@ -26,15 +26,15 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.16.6-beta-08670107",
30
- "@abtnode/constant": "1.16.6-beta-08670107",
29
+ "@abtnode/client": "1.16.6-beta-56be9f01",
30
+ "@abtnode/constant": "1.16.6-beta-56be9f01",
31
31
  "@arcblock/did": "1.18.76",
32
32
  "@arcblock/did-auth": "1.18.76",
33
33
  "@arcblock/jwt": "1.18.76",
34
34
  "@arcblock/ws": "1.18.76",
35
- "@blocklet/constant": "1.16.6-beta-08670107",
36
- "@blocklet/env": "1.16.6-beta-08670107",
37
- "@blocklet/meta": "1.16.6-beta-08670107",
35
+ "@blocklet/constant": "1.16.6-beta-56be9f01",
36
+ "@blocklet/env": "1.16.6-beta-56be9f01",
37
+ "@blocklet/meta": "1.16.6-beta-56be9f01",
38
38
  "@did-connect/authenticator": "^2.1.53",
39
39
  "@did-connect/handler": "^2.1.53",
40
40
  "@nedb/core": "^2.1.5",
@@ -72,5 +72,5 @@
72
72
  "ts-node": "^10.9.1",
73
73
  "typescript": "^4.8.4"
74
74
  },
75
- "gitHead": "11bbd8ea245fdb5920338f104cbe059e90a0e1b5"
75
+ "gitHead": "f93c24693ed27c4a2821ec33c345696afe6f001a"
76
76
  }