@ocap/tx-protocols 1.18.153 → 1.18.155
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/execute.js +9 -7
- package/lib/protocols/trade/transfer-v3.js +8 -1
- package/package.json +14 -14
package/lib/execute.js
CHANGED
|
@@ -24,7 +24,6 @@ const flushEvents = (context, extra = {}) => {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const shouldPersistTx = (err) => !err || get(err, 'props.persist');
|
|
27
|
-
const logError = (...args) => process.env.NODE_ENV !== 'test' && console.error(...args);
|
|
28
27
|
|
|
29
28
|
module.exports = ({ filter, runAsLambda }) => {
|
|
30
29
|
// pipeline before executing the transaction
|
|
@@ -69,7 +68,7 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
69
68
|
updateVaults(),
|
|
70
69
|
]);
|
|
71
70
|
} catch (err) {
|
|
72
|
-
|
|
71
|
+
context.logger?.error('Failed to charge gas fee for errored tx', err);
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
|
|
@@ -77,7 +76,7 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
77
76
|
new Promise((resolve, reject) => {
|
|
78
77
|
pre.run(context, (err) => {
|
|
79
78
|
if (err) {
|
|
80
|
-
|
|
79
|
+
context.logger?.error('Failed to prepare transaction', err);
|
|
81
80
|
return reject(err);
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -100,8 +99,9 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
100
99
|
try {
|
|
101
100
|
txState = context.states.tx.create(context, err ? err.code || 'INTERNAL' : 'OK');
|
|
102
101
|
await context.statedb.tx.create(txState.hash, txState, context);
|
|
102
|
+
context.logger?.info('Transaction has been saved to statedb', txState);
|
|
103
103
|
} catch (e) {
|
|
104
|
-
|
|
104
|
+
context.logger?.error('Failed to save transaction to statedb', e, txState);
|
|
105
105
|
return reject(e);
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -110,7 +110,7 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
110
110
|
|
|
111
111
|
// after executing the transaction
|
|
112
112
|
if (err) {
|
|
113
|
-
|
|
113
|
+
context.logger?.error('Failed to execute transaction', err);
|
|
114
114
|
return reject(err);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -148,11 +148,13 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
148
148
|
await context.statedb.tx.create(txState.hash, txState, newCtx);
|
|
149
149
|
flushEvents(newCtx, { txState });
|
|
150
150
|
});
|
|
151
|
+
ctx.logger?.info('Transaction has been saved to statedb', error, txState);
|
|
151
152
|
} catch (err) {
|
|
152
153
|
const txState = context.states.tx.create(ctx, error ? error.code || 'INTERNAL' : 'OK', false);
|
|
153
|
-
|
|
154
|
-
logError('failed to save invalid transaction to statedb', err);
|
|
154
|
+
ctx.logger?.error('Failed to save invalid transaction to statedb', err, txState);
|
|
155
155
|
}
|
|
156
|
+
} else {
|
|
157
|
+
ctx.logger?.error('Failed to execute transaction', error);
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
|
|
@@ -231,6 +231,12 @@ runner.use(
|
|
|
231
231
|
const isAlsoSigner = !!signerUpdates[sender];
|
|
232
232
|
const isAlsoReceiver = !!receiverUpdates[sender];
|
|
233
233
|
|
|
234
|
+
// When the sender is not in the inputs and outputs, we need to handle the gas fee update separately
|
|
235
|
+
const senderUpdates = {};
|
|
236
|
+
if (!isAlsoSigner && !isAlsoReceiver && senderState && senderChange) {
|
|
237
|
+
senderUpdates[sender] = applyTokenChange(senderState, senderChange);
|
|
238
|
+
}
|
|
239
|
+
|
|
234
240
|
debug('transfer-v3', { signerUpdates, receiverUpdates, assetUpdates, isAlsoSigner, isAlsoReceiver });
|
|
235
241
|
|
|
236
242
|
const [newSenderState, newSignerStates, newReceiverStates, newAssetStates] = await Promise.all([
|
|
@@ -242,7 +248,8 @@ runner.use(
|
|
|
242
248
|
Object.assign(
|
|
243
249
|
{ address: sender, nonce: tx.nonce, pk: tx.pk },
|
|
244
250
|
signerUpdates[sender] || {},
|
|
245
|
-
receiverUpdates[sender] || {}
|
|
251
|
+
receiverUpdates[sender] || {},
|
|
252
|
+
senderUpdates[sender] || {}
|
|
246
253
|
),
|
|
247
254
|
context
|
|
248
255
|
),
|
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.155",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@arcblock/did": "1.18.
|
|
25
|
-
"@arcblock/did-util": "1.18.
|
|
26
|
-
"@arcblock/jwt": "1.18.
|
|
27
|
-
"@arcblock/validator": "1.18.
|
|
28
|
-
"@ocap/asset": "1.18.
|
|
29
|
-
"@ocap/mcrypto": "1.18.
|
|
30
|
-
"@ocap/merkle-tree": "1.18.
|
|
31
|
-
"@ocap/message": "1.18.
|
|
32
|
-
"@ocap/state": "1.18.
|
|
33
|
-
"@ocap/tx-pipeline": "1.18.
|
|
34
|
-
"@ocap/util": "1.18.
|
|
35
|
-
"@ocap/wallet": "1.18.
|
|
24
|
+
"@arcblock/did": "1.18.155",
|
|
25
|
+
"@arcblock/did-util": "1.18.155",
|
|
26
|
+
"@arcblock/jwt": "1.18.155",
|
|
27
|
+
"@arcblock/validator": "1.18.155",
|
|
28
|
+
"@ocap/asset": "1.18.155",
|
|
29
|
+
"@ocap/mcrypto": "1.18.155",
|
|
30
|
+
"@ocap/merkle-tree": "1.18.155",
|
|
31
|
+
"@ocap/message": "1.18.155",
|
|
32
|
+
"@ocap/state": "1.18.155",
|
|
33
|
+
"@ocap/tx-pipeline": "1.18.155",
|
|
34
|
+
"@ocap/util": "1.18.155",
|
|
35
|
+
"@ocap/wallet": "1.18.155",
|
|
36
36
|
"debug": "^4.3.6",
|
|
37
37
|
"deep-diff": "^1.0.2",
|
|
38
38
|
"empty-value": "^1.0.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"jest": "^29.7.0",
|
|
48
48
|
"start-server-and-test": "^1.14.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3d0a23a37564c89d4cf8f374823835efdb6eb24b"
|
|
51
51
|
}
|