@ocap/tx-protocols 1.13.76 → 1.13.80

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.
@@ -101,7 +101,7 @@ runner.use((context, next) => {
101
101
  return next(new Error('INVALID_STAKE_STATE', `Staking not locked for deposit: ${stakeState.address}`));
102
102
  }
103
103
 
104
- const depositAmount = new BN(itx.token.value);
104
+ const depositAmount = new BN(itx.token.value).add(new BN(itx.actualFee));
105
105
  const minDepositAmount = new BN(rollupState.minDepositAmount);
106
106
  const maxDepositAmount = new BN(rollupState.maxDepositAmount);
107
107
  if (depositAmount.lt(minDepositAmount)) {
package/lib/util.js CHANGED
@@ -201,17 +201,18 @@ const ensureBlockReward = (rollupState, minReward, txStates) => {
201
201
  const changes = { stake: [], account: [] };
202
202
  dynamicFeeTxs.forEach((x) => {
203
203
  const maxFee = new BN(x.tx.itxJson.maxFee);
204
+ const defaults = getTxFee({
205
+ amount: x.tx.itxJson.token.value,
206
+ feeRate: withdrawFeeRate,
207
+ maxFee: maxWithdrawFee,
208
+ minFee: minWithdrawFee,
209
+ stringify: false,
210
+ });
211
+
204
212
  let actualFee = new BN(0);
205
213
  // If totalMissingFee is less than 0, then the tx will be charged for fixedFee
206
214
  if (totalMissingFee.lt(ZERO)) {
207
- const fee = getTxFee({
208
- amount: x.tx.itxJson.token.value,
209
- feeRate: withdrawFeeRate,
210
- maxFee: maxWithdrawFee,
211
- minFee: minWithdrawFee,
212
- stringify: false,
213
- });
214
- actualFee = fee.reward;
215
+ actualFee = defaults.reward;
215
216
  } else {
216
217
  // Else the tx is charged for a portion of totalMissingFee
217
218
  actualFee = totalMissingFee.mul(maxFee).div(totalDynamicFee);
@@ -221,6 +222,11 @@ const ensureBlockReward = (rollupState, minReward, txStates) => {
221
222
  throw new Error('NEGATIVE_ACTUAL_FEE', 'Got negative actualFee for tx, abort!');
222
223
  }
223
224
 
225
+ // If the actualFee is less than default fee, user will be charged the default fee
226
+ if (actualFee.lt(defaults.reward)) {
227
+ actualFee = defaults.reward;
228
+ }
229
+
224
230
  // If the actualFee is less than minTxFee, user will be charged the minTxFee
225
231
  if (actualFee.lt(minTxFee)) {
226
232
  actualFee = minTxFee;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.13.76",
6
+ "version": "1.13.80",
7
7
  "description": "Predefined tx pipeline sets to execute certain type of transactions",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,17 +19,17 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@arcblock/did": "1.13.76",
23
- "@arcblock/did-util": "1.13.76",
24
- "@ocap/asset": "1.13.76",
25
- "@ocap/mcrypto": "1.13.76",
26
- "@ocap/merkle-tree": "1.13.76",
27
- "@ocap/message": "1.13.76",
28
- "@ocap/state": "1.13.76",
29
- "@ocap/tx-pipeline": "1.13.76",
30
- "@ocap/util": "1.13.76",
31
- "@ocap/validator": "1.13.76",
32
- "@ocap/wallet": "1.13.76",
22
+ "@arcblock/did": "1.13.80",
23
+ "@arcblock/did-util": "1.13.80",
24
+ "@ocap/asset": "1.13.80",
25
+ "@ocap/mcrypto": "1.13.80",
26
+ "@ocap/merkle-tree": "1.13.80",
27
+ "@ocap/message": "1.13.80",
28
+ "@ocap/state": "1.13.80",
29
+ "@ocap/tx-pipeline": "1.13.80",
30
+ "@ocap/util": "1.13.80",
31
+ "@ocap/validator": "1.13.80",
32
+ "@ocap/wallet": "1.13.80",
33
33
  "debug": "^4.3.2",
34
34
  "empty-value": "^1.0.1",
35
35
  "lodash": "^4.17.21",
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "jest": "^27.3.1"
44
44
  },
45
- "gitHead": "8787d19bdde22c3085645a38dcaf16a0f5e8c660"
45
+ "gitHead": "7f41804dd27327380c984ed53d5056a7c97e15d5"
46
46
  }