@ocap/contract 1.18.40 → 1.18.42
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/index.js +8 -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,
|
|
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,
|
|
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.
|
|
4
|
+
"version": "1.18.42",
|
|
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.
|
|
22
|
-
"@ocap/mcrypto": "1.18.
|
|
23
|
-
"@ocap/util": "1.18.
|
|
21
|
+
"@arcblock/did": "1.18.42",
|
|
22
|
+
"@ocap/mcrypto": "1.18.42",
|
|
23
|
+
"@ocap/util": "1.18.42",
|
|
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": "
|
|
70
|
+
"gitHead": "e4c81bf4891fd7b1b1ce3b8e1ccf7c4b7c004593"
|
|
71
71
|
}
|