@ocap/contract 1.17.23 → 1.18.0

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 +4 -4
  2. 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).lt(ZERO)) {
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).lt(ZERO)) {
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.eq(ZERO) === false) {
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].eq(ZERO) === false);
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.17.23",
4
+ "version": "1.18.0",
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.17.23",
22
- "@ocap/mcrypto": "1.17.23",
23
- "@ocap/util": "1.17.23",
21
+ "@arcblock/did": "1.18.0",
22
+ "@ocap/mcrypto": "1.18.0",
23
+ "@ocap/util": "1.18.0",
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": "aecdce3fc6aaee32ea60db191d61962963f5e0bf"
70
+ "gitHead": "c48f928ee4f0deddf0f5e4bcb82fd6ffd7f2bc99"
71
71
  }