@ocap/tx-protocols 1.18.23 → 1.18.24
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.
|
@@ -39,17 +39,18 @@ runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
|
|
|
39
39
|
// Ensure factory exist
|
|
40
40
|
runner.use(pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })); // prettier-ignore
|
|
41
41
|
|
|
42
|
-
//
|
|
43
|
-
runner.use(pipes.ExtractState({ from: 'factoryState.
|
|
42
|
+
// Ensure issuer exist: read them here because some maybe migrated
|
|
43
|
+
runner.use(pipes.ExtractState({ from: 'factoryState.trustedIssuers', to: 'issuerStates', status: 'INVALID_ISSUER_STATE' , table: 'account'})); // prettier-ignore
|
|
44
44
|
|
|
45
45
|
// Ensure factory owner exist and equal to sender
|
|
46
46
|
runner.use(pipes.ExtractState({ from: 'itx.owner', to: 'ownerState', status: 'OK', table: 'account' }));
|
|
47
47
|
runner.use(
|
|
48
48
|
pipes.VerifyInfo([
|
|
49
49
|
{
|
|
50
|
-
error: '
|
|
51
|
-
message: 'Only factory owner
|
|
52
|
-
fn: ({ factoryState, senderState }) =>
|
|
50
|
+
error: 'FORBIDDEN',
|
|
51
|
+
message: 'Only factory owner and trusted issuers are allowed to mint',
|
|
52
|
+
fn: ({ factoryState, senderState, issuerStates }) =>
|
|
53
|
+
senderState.address === factoryState.owner || issuerStates.find((x) => x.address === senderState.address),
|
|
53
54
|
persist: true,
|
|
54
55
|
},
|
|
55
56
|
])
|
|
@@ -2,7 +2,7 @@ const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
|
2
2
|
const { mintFromFactory } = require('@ocap/asset');
|
|
3
3
|
|
|
4
4
|
module.exports = (mode) => (context, next) => {
|
|
5
|
-
const { itx, senderState, ownerState, factoryState, delegatorState,
|
|
5
|
+
const { itx, senderState, ownerState, factoryState, delegatorState, factoryInputs } = context;
|
|
6
6
|
|
|
7
7
|
let issuer = null;
|
|
8
8
|
let owner = null;
|
|
@@ -17,9 +17,9 @@ module.exports = (mode) => (context, next) => {
|
|
|
17
17
|
} else if (mode === 'mint') {
|
|
18
18
|
owner = ownerState || { address: itx.owner };
|
|
19
19
|
issuer = {
|
|
20
|
-
id:
|
|
21
|
-
pk:
|
|
22
|
-
name:
|
|
20
|
+
id: senderState.address,
|
|
21
|
+
pk: senderState.pk,
|
|
22
|
+
name: senderState.moniker,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -107,6 +107,9 @@ runner.use((context, next) => {
|
|
|
107
107
|
return next(new Error('INVALID_FACTORY_INPUT', 'Not all input.assets exist on chain'));
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
// ensure issuer exists
|
|
111
|
+
runner.use(pipes.ExtractState({ from: 'factoryProps.trustedIssuers', to: 'issuerStates', table: 'account', status: 'INVALID_ISSUER_STATE' })); // prettier-ignore
|
|
112
|
+
|
|
110
113
|
// Ensure tx fee and gas
|
|
111
114
|
runner.use(EnsureTxGas(() => ({ create: 1, update: 1, payment: 0 })));
|
|
112
115
|
runner.use(EnsureTxCost({ attachSenderChanges: true }));
|
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.24",
|
|
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.24",
|
|
25
|
+
"@arcblock/did-util": "1.18.24",
|
|
26
|
+
"@arcblock/jwt": "1.18.24",
|
|
27
|
+
"@arcblock/validator": "1.18.24",
|
|
28
|
+
"@ocap/asset": "1.18.24",
|
|
29
|
+
"@ocap/mcrypto": "1.18.24",
|
|
30
|
+
"@ocap/merkle-tree": "1.18.24",
|
|
31
|
+
"@ocap/message": "1.18.24",
|
|
32
|
+
"@ocap/state": "1.18.24",
|
|
33
|
+
"@ocap/tx-pipeline": "1.18.24",
|
|
34
|
+
"@ocap/util": "1.18.24",
|
|
35
|
+
"@ocap/wallet": "1.18.24",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"deep-diff": "^1.0.2",
|
|
38
38
|
"empty-value": "^1.0.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"jest": "^27.5.1",
|
|
48
48
|
"start-server-and-test": "^1.14.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2b3c7ab2de31bd3ef55ae32cec5c007d5e13d306"
|
|
51
51
|
}
|