@ocap/contract 1.18.39 → 1.18.41

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.
Files changed (2) hide show
  1. package/lib/index.js +8 -2
  2. package/package.json +5 -5
package/lib/index.js CHANGED
@@ -11,6 +11,12 @@ const isCallExpression = (x) =>
11
11
 
12
12
  const ZERO = new BN('0');
13
13
 
14
+ const TOKEN_RECEIVER_ROLE_TYPES = [
15
+ types.RoleType.ROLE_APPLICATION,
16
+ types.RoleType.ROLE_ACCOUNT,
17
+ types.RoleType.ROLE_BLOCKLET,
18
+ ];
19
+
14
20
  const SUPPORTED_CALLS = {
15
21
  // used to transfer primary token to someone
16
22
  transfer: {
@@ -167,7 +173,7 @@ const validate = (compiled, quota, ensureZeroSum = false) => {
167
173
  for (const item of compiled) {
168
174
  const { call, args } = item;
169
175
  if (call === 'transfer') {
170
- validateDid(args.to, [types.RoleType.ROLE_APPLICATION, types.RoleType.ROLE_ACCOUNT]);
176
+ validateDid(args.to, TOKEN_RECEIVER_ROLE_TYPES);
171
177
  const consumption = validateAmount(args.amount);
172
178
  if (consumption.lte(ZERO)) {
173
179
  throw new Error('transfer amount must be greater than 0');
@@ -180,7 +186,7 @@ const validate = (compiled, quota, ensureZeroSum = false) => {
180
186
  }
181
187
  } else if (call === 'transferToken') {
182
188
  validateDid(args.tokenAddress, [types.RoleType.ROLE_TOKEN]);
183
- validateDid(args.to, [types.RoleType.ROLE_APPLICATION, types.RoleType.ROLE_ACCOUNT]);
189
+ validateDid(args.to, TOKEN_RECEIVER_ROLE_TYPES);
184
190
 
185
191
  const token = args.tokenAddress;
186
192
  const consumption = validateAmount(args.amount);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/contract",
3
3
  "description": "Utility to compile/validate and run ocap contract",
4
- "version": "1.18.39",
4
+ "version": "1.18.41",
5
5
  "author": {
6
6
  "name": "wangshijun",
7
7
  "email": "shijun@arcblock.io",
@@ -18,9 +18,9 @@
18
18
  "wangshijun <shijun@arcblock.io> (https://github.com/wangshijun)"
19
19
  ],
20
20
  "dependencies": {
21
- "@arcblock/did": "1.18.39",
22
- "@ocap/mcrypto": "1.18.39",
23
- "@ocap/util": "1.18.39",
21
+ "@arcblock/did": "1.18.41",
22
+ "@ocap/mcrypto": "1.18.41",
23
+ "@ocap/util": "1.18.41",
24
24
  "debug": "^4.3.4",
25
25
  "esprima": "^4.0.1",
26
26
  "lodash": "^4.17.21"
@@ -67,5 +67,5 @@
67
67
  "test": "jest --forceExit --detectOpenHandles",
68
68
  "coverage": "yarn test -- --coverage"
69
69
  },
70
- "gitHead": "95f7a60030ed923ac83fed697f208a9b8d555f59"
70
+ "gitHead": "66c1bc10f6ba2724366252ed70932d75f327a17b"
71
71
  }