@ocap/tx-protocols 1.13.73 → 1.13.77

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.
@@ -107,7 +107,11 @@ runner.use(
107
107
  context
108
108
  ),
109
109
 
110
- statedb.token.create(itx.address, token.create({ ...itx, data, issuer: senderState.address }, context), context),
110
+ statedb.token.create(
111
+ itx.address,
112
+ token.create({ ...cloneDeep(itx), data, issuer: senderState.address }, context),
113
+ context
114
+ ),
111
115
 
112
116
  isEmpty(vaultUpdates)
113
117
  ? vaultState
package/lib/util.js CHANGED
@@ -197,20 +197,22 @@ const ensureBlockReward = (rollupState, minReward, txStates) => {
197
197
  const totalMissingFee = minRequiredReward.sub(totalFixedFee);
198
198
 
199
199
  // 2. calculate actual reward for each dynamic reward tx, mark tx to be updated
200
+ const minTxFee = minRequiredReward.div(new BN(txStates.length));
200
201
  const changes = { stake: [], account: [] };
201
202
  dynamicFeeTxs.forEach((x) => {
202
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
+
203
212
  let actualFee = new BN(0);
204
213
  // If totalMissingFee is less than 0, then the tx will be charged for fixedFee
205
214
  if (totalMissingFee.lt(ZERO)) {
206
- const fee = getTxFee({
207
- amount: x.tx.itxJson.token.value,
208
- feeRate: withdrawFeeRate,
209
- maxFee: maxWithdrawFee,
210
- minFee: minWithdrawFee,
211
- stringify: false,
212
- });
213
- actualFee = fee.reward;
215
+ actualFee = defaults.reward;
214
216
  } else {
215
217
  // Else the tx is charged for a portion of totalMissingFee
216
218
  actualFee = totalMissingFee.mul(maxFee).div(totalDynamicFee);
@@ -220,6 +222,16 @@ const ensureBlockReward = (rollupState, minReward, txStates) => {
220
222
  throw new Error('NEGATIVE_ACTUAL_FEE', 'Got negative actualFee for tx, abort!');
221
223
  }
222
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
+
230
+ // If the actualFee is less than minTxFee, user will be charged the minTxFee
231
+ if (actualFee.lt(minTxFee)) {
232
+ actualFee = minTxFee;
233
+ }
234
+
223
235
  // If the actualFee is less than the maxFee, user will have a refund
224
236
  if (actualFee.lt(maxFee)) {
225
237
  const refundFee = maxFee.sub(actualFee).toString(10);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.13.73",
6
+ "version": "1.13.77",
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.73",
23
- "@arcblock/did-util": "1.13.73",
24
- "@ocap/asset": "1.13.73",
25
- "@ocap/mcrypto": "1.13.73",
26
- "@ocap/merkle-tree": "1.13.73",
27
- "@ocap/message": "1.13.73",
28
- "@ocap/state": "1.13.73",
29
- "@ocap/tx-pipeline": "1.13.73",
30
- "@ocap/util": "1.13.73",
31
- "@ocap/validator": "1.13.73",
32
- "@ocap/wallet": "1.13.73",
22
+ "@arcblock/did": "1.13.77",
23
+ "@arcblock/did-util": "1.13.77",
24
+ "@ocap/asset": "1.13.77",
25
+ "@ocap/mcrypto": "1.13.77",
26
+ "@ocap/merkle-tree": "1.13.77",
27
+ "@ocap/message": "1.13.77",
28
+ "@ocap/state": "1.13.77",
29
+ "@ocap/tx-pipeline": "1.13.77",
30
+ "@ocap/util": "1.13.77",
31
+ "@ocap/validator": "1.13.77",
32
+ "@ocap/wallet": "1.13.77",
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": "ffce10eaa7c72fe6d6fdc534f7e15cbdb3e6a917"
45
+ "gitHead": "84967780822cbcb5a30e809ea4d39a84020d3e31"
46
46
  }