@ocap/tx-protocols 1.18.77 → 1.18.79
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/protocols/asset/update.js +14 -10
- package/package.json +14 -14
|
@@ -20,6 +20,7 @@ runner.use(pipes.VerifyMultiSig(0));
|
|
|
20
20
|
const schema = Joi.object({
|
|
21
21
|
address: Joi.DID().prefix().role('ROLE_ASSET').required(),
|
|
22
22
|
moniker: Joi.string().min(2).max(255).optional().allow(''),
|
|
23
|
+
consumed: Joi.boolean().optional().default(false),
|
|
23
24
|
data: Joi.any().optional(),
|
|
24
25
|
}).options({ stripUnknown: true, noDefaults: false });
|
|
25
26
|
runner.use((context, next) => {
|
|
@@ -54,6 +55,12 @@ runner.use(
|
|
|
54
55
|
fn: ({ assetState }) => assetState.readonly === false,
|
|
55
56
|
persist: true,
|
|
56
57
|
},
|
|
58
|
+
{
|
|
59
|
+
error: 'CONSUMED_ASSET',
|
|
60
|
+
message: 'Can not consume an already consumed asset',
|
|
61
|
+
fn: ({ assetState, itx }) => !(itx.consumed && assetState.consumedTime),
|
|
62
|
+
persist: true,
|
|
63
|
+
},
|
|
57
64
|
])
|
|
58
65
|
);
|
|
59
66
|
|
|
@@ -84,7 +91,12 @@ runner.use(EnsureTxCost({ attachSenderChanges: true }));
|
|
|
84
91
|
// Update asset state
|
|
85
92
|
runner.use(
|
|
86
93
|
async (context, next) => {
|
|
87
|
-
const { tx, itx, newData, statedb, senderState, senderUpdates, assetState, updateVaults } = context;
|
|
94
|
+
const { tx, itx, txTime, newData, statedb, senderState, senderUpdates, assetState, updateVaults } = context;
|
|
95
|
+
|
|
96
|
+
const updates = { moniker: itx.moniker || assetState.moniker, data: newData || assetState.data };
|
|
97
|
+
if (itx.consumed && !assetState.consumedTime) {
|
|
98
|
+
updates.consumedTime = txTime;
|
|
99
|
+
}
|
|
88
100
|
|
|
89
101
|
const [newSenderState, newAssetState] = await Promise.all([
|
|
90
102
|
// update owner state
|
|
@@ -95,15 +107,7 @@ runner.use(
|
|
|
95
107
|
),
|
|
96
108
|
|
|
97
109
|
// update asset state
|
|
98
|
-
statedb.asset.update(
|
|
99
|
-
itx.address,
|
|
100
|
-
asset.update(
|
|
101
|
-
assetState,
|
|
102
|
-
{ moniker: itx.moniker || assetState.moniker, data: newData || assetState.data },
|
|
103
|
-
context
|
|
104
|
-
),
|
|
105
|
-
context
|
|
106
|
-
),
|
|
110
|
+
statedb.asset.update(itx.address, asset.update(assetState, updates, context), context),
|
|
107
111
|
|
|
108
112
|
updateVaults(),
|
|
109
113
|
]);
|
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.79",
|
|
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.79",
|
|
25
|
+
"@arcblock/did-util": "1.18.79",
|
|
26
|
+
"@arcblock/jwt": "1.18.79",
|
|
27
|
+
"@arcblock/validator": "1.18.79",
|
|
28
|
+
"@ocap/asset": "1.18.79",
|
|
29
|
+
"@ocap/mcrypto": "1.18.79",
|
|
30
|
+
"@ocap/merkle-tree": "1.18.79",
|
|
31
|
+
"@ocap/message": "1.18.79",
|
|
32
|
+
"@ocap/state": "1.18.79",
|
|
33
|
+
"@ocap/tx-pipeline": "1.18.79",
|
|
34
|
+
"@ocap/util": "1.18.79",
|
|
35
|
+
"@ocap/wallet": "1.18.79",
|
|
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": "158c6265a6746d9a7ddae8b68cb00f6667f5f248"
|
|
51
51
|
}
|