@ocap/tx-pipeline 1.19.6 → 1.19.8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.js +2 -0
- package/lib/pipes/verify-gas-payer.js +30 -0
- package/lib/pipes/verify-sender.js +0 -8
- package/package.json +9 -9
package/lib/index.js
CHANGED
@@ -24,6 +24,7 @@ const VerifyTxInput = require('./pipes/verify-tx-input');
|
|
24
24
|
const VerifyUpdater = require('./pipes/verify-updater');
|
25
25
|
const VerifyTokenBalance = require('./pipes/verify-token-balance');
|
26
26
|
const VerifyStateDiff = require('./pipes/verify-state-diff');
|
27
|
+
const VerifyGasPayer = require('./pipes/verify-gas-payer');
|
27
28
|
const TakeStateSnapshot = require('./pipes/take-state-snapshot');
|
28
29
|
|
29
30
|
module.exports = {
|
@@ -54,6 +55,7 @@ module.exports = {
|
|
54
55
|
VerifyTxInput,
|
55
56
|
VerifyTokenBalance,
|
56
57
|
VerifyStateDiff,
|
58
|
+
VerifyGasPayer,
|
57
59
|
TakeStateSnapshot,
|
58
60
|
},
|
59
61
|
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
2
|
+
const get = require('lodash/get');
|
3
|
+
const { CustomError: Error } = require('@ocap/util/lib/error');
|
4
|
+
const { BN } = require('@ocap/util');
|
5
|
+
|
6
|
+
module.exports = function CreateVerifyGasPayerPipe({ gasPayer = 'senderState' } = {}) {
|
7
|
+
return function VerifyGasPayer(context, next) {
|
8
|
+
// From ensureTxCost
|
9
|
+
// Pass if someone has staked for this tx
|
10
|
+
const { gasStake } = context;
|
11
|
+
if (gasStake?.valid) {
|
12
|
+
return next();
|
13
|
+
}
|
14
|
+
|
15
|
+
// From ensureTxCost
|
16
|
+
// Pass if gas is free
|
17
|
+
const { gasVaultChange } = context;
|
18
|
+
if (!gasVaultChange || new BN(gasVaultChange.value ?? 0).isZero()) {
|
19
|
+
return next();
|
20
|
+
}
|
21
|
+
|
22
|
+
// Pass if payer on chain
|
23
|
+
const gasPayerState = get(context, gasPayer);
|
24
|
+
if (gasPayerState) {
|
25
|
+
return next();
|
26
|
+
}
|
27
|
+
|
28
|
+
return next(new Error('INVALID_GAS_PAYER', 'Gas payer does not exist on chain'));
|
29
|
+
};
|
30
|
+
};
|
@@ -5,14 +5,6 @@ const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
5
5
|
module.exports = function CreateVerifySenderPipe({ state = 'senderState' } = {}) {
|
6
6
|
return function VerifySender(context, next) {
|
7
7
|
const sender = get(context, state);
|
8
|
-
if (context.txType === 'fg:t:declare') {
|
9
|
-
if (sender) {
|
10
|
-
return next(new Error('INVALID_SENDER_STATE', 'Sender account already exist in ledger', { persist: true }));
|
11
|
-
}
|
12
|
-
|
13
|
-
return next();
|
14
|
-
}
|
15
|
-
|
16
8
|
if (sender) {
|
17
9
|
return next();
|
18
10
|
}
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"publishConfig": {
|
4
4
|
"access": "public"
|
5
5
|
},
|
6
|
-
"version": "1.19.
|
6
|
+
"version": "1.19.8",
|
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.19.
|
33
|
-
"@arcblock/did-util": "1.19.
|
34
|
-
"@ocap/mcrypto": "1.19.
|
35
|
-
"@ocap/message": "1.19.
|
36
|
-
"@ocap/state": "1.19.
|
37
|
-
"@ocap/util": "1.19.
|
38
|
-
"@ocap/wallet": "1.19.
|
32
|
+
"@arcblock/did": "1.19.8",
|
33
|
+
"@arcblock/did-util": "1.19.8",
|
34
|
+
"@ocap/mcrypto": "1.19.8",
|
35
|
+
"@ocap/message": "1.19.8",
|
36
|
+
"@ocap/state": "1.19.8",
|
37
|
+
"@ocap/util": "1.19.8",
|
38
|
+
"@ocap/wallet": "1.19.8",
|
39
39
|
"debug": "^4.3.6",
|
40
40
|
"empty-value": "^1.0.1",
|
41
41
|
"lodash": "^4.17.21"
|
42
42
|
},
|
43
|
-
"gitHead": "
|
43
|
+
"gitHead": "c64c55f04a40357501cc3ecf4e5e7531aee15ffe"
|
44
44
|
}
|