@ocap/state 1.18.21 → 1.18.23
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/states/tx.js +23 -1
- package/package.json +8 -8
package/lib/states/tx.js
CHANGED
|
@@ -333,7 +333,7 @@ const mergeTxReceipts = (receipts) => {
|
|
|
333
333
|
*/
|
|
334
334
|
const getTxReceipts = ({ tx, code }, ctx = {}) => {
|
|
335
335
|
if (code !== 'OK') {
|
|
336
|
-
return [];
|
|
336
|
+
return ctx.gasPaid ? getReceiptsFromContext(ctx) : [];
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
let receipts = Array.isArray(ctx.receipts) ? ctx.receipts : [];
|
|
@@ -433,9 +433,30 @@ const create = (context, code = 'OK') => {
|
|
|
433
433
|
|
|
434
434
|
result.receipts = getTxReceipts(result, context);
|
|
435
435
|
|
|
436
|
+
// determine gasPaid
|
|
437
|
+
attachPaidTxGas(result);
|
|
438
|
+
|
|
436
439
|
return result;
|
|
437
440
|
};
|
|
438
441
|
|
|
442
|
+
const attachPaidTxGas = (tx) => {
|
|
443
|
+
if (tx.tx.gasPaid) {
|
|
444
|
+
return tx;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// determine gasPaid
|
|
448
|
+
let gasChange = null;
|
|
449
|
+
tx.receipts.forEach((r) => {
|
|
450
|
+
const tmp = r.changes.find((c) => c.action === 'gas' && c.value === tx.tx.gasFee);
|
|
451
|
+
if (tmp) {
|
|
452
|
+
gasChange = tmp;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
tx.tx.gasPaid = gasChange ? tx.tx.gasFee : '0';
|
|
456
|
+
|
|
457
|
+
return tx;
|
|
458
|
+
};
|
|
459
|
+
|
|
439
460
|
// Only a few props are allowed to be changed in tx state
|
|
440
461
|
const update = (state, updates) => merge(state, pick(updates, ['finalized', 'tx.itxJson.actualFee']));
|
|
441
462
|
|
|
@@ -446,4 +467,5 @@ module.exports = {
|
|
|
446
467
|
getTxSender,
|
|
447
468
|
getTxReceipts,
|
|
448
469
|
mergeTxReceipts,
|
|
470
|
+
attachPaidTxGas,
|
|
449
471
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.18.
|
|
6
|
+
"version": "1.18.23",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"coverage": "npm run test -- --coverage"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@arcblock/did": "1.18.
|
|
20
|
-
"@arcblock/validator": "1.18.
|
|
21
|
-
"@ocap/contract": "1.18.
|
|
22
|
-
"@ocap/mcrypto": "1.18.
|
|
23
|
-
"@ocap/message": "1.18.
|
|
24
|
-
"@ocap/util": "1.18.
|
|
19
|
+
"@arcblock/did": "1.18.23",
|
|
20
|
+
"@arcblock/validator": "1.18.23",
|
|
21
|
+
"@ocap/contract": "1.18.23",
|
|
22
|
+
"@ocap/mcrypto": "1.18.23",
|
|
23
|
+
"@ocap/message": "1.18.23",
|
|
24
|
+
"@ocap/util": "1.18.23",
|
|
25
25
|
"bloom-filters": "^1.3.9",
|
|
26
26
|
"lodash": "^4.17.21"
|
|
27
27
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"keywords": [],
|
|
32
32
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
33
33
|
"license": "MIT",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "bb57afdd756f4a9608e53e40c91060c32b97f2f8"
|
|
35
35
|
}
|