@ocap/contract 1.17.23 → 1.18.1
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 +4 -4
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -173,7 +173,7 @@ const validate = (compiled, quota, ensureZeroSum = false) => {
|
|
|
173
173
|
throw new Error('transfer amount must be greater than 0');
|
|
174
174
|
}
|
|
175
175
|
if (quota) {
|
|
176
|
-
if (remaining.sub(consumption).
|
|
176
|
+
if (remaining.sub(consumption).isNeg()) {
|
|
177
177
|
throw new Error('transfer exceeded quota');
|
|
178
178
|
}
|
|
179
179
|
remaining = remaining.sub(consumption);
|
|
@@ -188,7 +188,7 @@ const validate = (compiled, quota, ensureZeroSum = false) => {
|
|
|
188
188
|
throw new Error('token transfer amount must be greater than 0');
|
|
189
189
|
}
|
|
190
190
|
if (quota) {
|
|
191
|
-
if (!tokenRemaining[token] || tokenRemaining[token].sub(consumption).
|
|
191
|
+
if (!tokenRemaining[token] || tokenRemaining[token].sub(consumption).isNeg()) {
|
|
192
192
|
throw new Error(`transferToken for ${args.tokenAddress} exceeded quota`);
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -198,10 +198,10 @@ const validate = (compiled, quota, ensureZeroSum = false) => {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
if (ensureZeroSum) {
|
|
201
|
-
if (remaining.
|
|
201
|
+
if (remaining.isZero() === false) {
|
|
202
202
|
throw new Error('transfer violates zero sum');
|
|
203
203
|
}
|
|
204
|
-
const invalidToken = Object.keys(tokenRemaining).find((x) => tokenRemaining[x].
|
|
204
|
+
const invalidToken = Object.keys(tokenRemaining).find((x) => tokenRemaining[x].isZero() === false);
|
|
205
205
|
if (invalidToken) {
|
|
206
206
|
throw new Error(`transferToken for ${invalidToken} violates zero sum`);
|
|
207
207
|
}
|
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.
|
|
4
|
+
"version": "1.18.1",
|
|
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.
|
|
22
|
-
"@ocap/mcrypto": "1.
|
|
23
|
-
"@ocap/util": "1.
|
|
21
|
+
"@arcblock/did": "1.18.1",
|
|
22
|
+
"@ocap/mcrypto": "1.18.1",
|
|
23
|
+
"@ocap/util": "1.18.1",
|
|
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": "7735e4243a1ba253eb14d960ca272974eaf94623"
|
|
71
71
|
}
|