@ocap/tx-pipeline 1.18.102 → 1.18.104

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,12 +38,12 @@ const isDelegationSufficient = (requirements, limitation) => {
38
38
  }
39
39
 
40
40
  // Check tx_count exceeds
41
- if (limit.txSent >= limit.txCount) {
41
+ if (limit.txCount > 0 && limit.txSent >= limit.txCount) {
42
42
  return { sufficient: false, reason: 'tx count exceeds threshold' };
43
43
  }
44
44
 
45
45
  // Check valid_until
46
- if (limit.validUntil && limit.validUntil < now) {
46
+ if (limit.validUntil > 0 && limit.validUntil < now) {
47
47
  return { sufficient: false, reason: 'delegation expired' };
48
48
  }
49
49
 
@@ -59,8 +59,8 @@ const isDelegationSufficient = (requirements, limitation) => {
59
59
  // Check tx_allowance exceeds using BN
60
60
  const requirementValue = toBN(requirement.value || '0');
61
61
  const txAllowance = toBN(limit.txAllowance || '0');
62
- const isTxAllowanceExceed = txAllowance.eq(ZERO) || requirementValue.lte(txAllowance);
63
- if (isTxAllowanceExceed === false) {
62
+ const isTxAllowanceExceed = txAllowance.gt(ZERO) && requirementValue.gt(txAllowance);
63
+ if (isTxAllowanceExceed) {
64
64
  return { sufficient: false, reason: 'token amount exceeds tx allowance' };
65
65
  }
66
66
 
@@ -68,8 +68,8 @@ const isDelegationSufficient = (requirements, limitation) => {
68
68
  const totalAllowance = toBN(limit.totalAllowance || '0');
69
69
  const spentAllowance = toBN(limit.spentAllowance || '0');
70
70
  const isTotalAllowanceExceed =
71
- totalAllowance.eq(ZERO) || requirementValue.add(spentAllowance).lte(totalAllowance);
72
- if (isTotalAllowanceExceed === false) {
71
+ totalAllowance.gt(ZERO) && requirementValue.add(spentAllowance).gt(totalAllowance);
72
+ if (isTotalAllowanceExceed) {
73
73
  return { sufficient: false, reason: 'token amount exceeds total allowance' };
74
74
  }
75
75
 
@@ -97,12 +97,12 @@ const isDelegationSufficient = (requirements, limitation) => {
97
97
  }
98
98
 
99
99
  // Check tx_count exceeds
100
- if (limit.txSent >= limit.txCount) {
100
+ if (limit.txCount > 0 && limit.txSent >= limit.txCount) {
101
101
  return { sufficient: false, reason: 'tx count exceeds threshold' };
102
102
  }
103
103
 
104
104
  // Check valid_until
105
- if (limit.validUntil && limit.validUntil < now) {
105
+ if (limit.validUntil > 0 && limit.validUntil < now) {
106
106
  return { sufficient: false, reason: 'delegation expired' };
107
107
  }
108
108
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.102",
6
+ "version": "1.18.104",
7
7
  "description": "Pipeline runner and common pipelines to process transactions",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -29,16 +29,16 @@
29
29
  "elliptic": "6.5.3"
30
30
  },
31
31
  "dependencies": {
32
- "@arcblock/did": "1.18.102",
33
- "@arcblock/did-util": "1.18.102",
34
- "@ocap/mcrypto": "1.18.102",
35
- "@ocap/message": "1.18.102",
36
- "@ocap/state": "1.18.102",
37
- "@ocap/util": "1.18.102",
38
- "@ocap/wallet": "1.18.102",
32
+ "@arcblock/did": "1.18.104",
33
+ "@arcblock/did-util": "1.18.104",
34
+ "@ocap/mcrypto": "1.18.104",
35
+ "@ocap/message": "1.18.104",
36
+ "@ocap/state": "1.18.104",
37
+ "@ocap/util": "1.18.104",
38
+ "@ocap/wallet": "1.18.104",
39
39
  "debug": "^4.3.4",
40
40
  "empty-value": "^1.0.1",
41
41
  "lodash": "^4.17.21"
42
42
  },
43
- "gitHead": "f9735d521051d45331073b3e52c743ad01e3b8e5"
43
+ "gitHead": "c8092aee1964209446020c17fc7c648879e4309d"
44
44
  }