@ocap/tx-pipeline 1.18.58 → 1.18.60
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.
@@ -4,25 +4,46 @@ const { getListField } = require('@ocap/util/lib/get-list-field');
|
|
4
4
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
5
5
|
|
6
6
|
// 因为 statedb 层读取数据时会自动获取迁移之后的账户,所以这里可以直接对比 state,而不用检查 migratedTo
|
7
|
-
module.exports = function CreateVerifyAccountMigrationPipe({
|
7
|
+
module.exports = function CreateVerifyAccountMigrationPipe({ stateKey = '', addressKey = '', signerKey = '' }) {
|
8
8
|
return function VerifyAccountMigration(context, next) {
|
9
|
-
|
9
|
+
if (stateKey && addressKey) {
|
10
|
+
let addressList = get(context, addressKey);
|
11
|
+
let stateList = get(context, stateKey);
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
13
|
+
if (addressList && stateList) {
|
14
|
+
stateList = (Array.isArray(stateList) ? stateList : [stateList]).filter(Boolean);
|
15
|
+
addressList = (Array.isArray(addressList) ? addressList : [addressList]).filter(Boolean);
|
15
16
|
|
16
|
-
|
17
|
-
if (Array.isArray(signers) && signers.length) {
|
18
|
-
const signatures = getListField(tx, 'signatures');
|
19
|
-
for (const signature of signatures) {
|
20
|
-
const state = signers.find((x) => x.address === signature.signer);
|
21
|
-
if (!state || state.address !== signature.signer) {
|
17
|
+
if (stateList.length !== addressList.length) {
|
22
18
|
return next(
|
23
|
-
new Error('
|
19
|
+
new Error('INVALID_TX', 'state and address list size mismatch for account migration verify', {
|
20
|
+
persist: false,
|
21
|
+
})
|
24
22
|
);
|
25
23
|
}
|
24
|
+
|
25
|
+
for (let i = 0; i < stateList.length; i += 1) {
|
26
|
+
const state = stateList[i];
|
27
|
+
const address = addressList[i];
|
28
|
+
if (state.address !== address) {
|
29
|
+
return next(new Error('ACCOUNT_MIGRATED', `account ${address} is migrated`, { persist: true }));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
if (signerKey) {
|
36
|
+
const signers = get(context, signerKey);
|
37
|
+
if (Array.isArray(signers) && signers.length) {
|
38
|
+
const signatures = getListField(context.tx, 'signatures');
|
39
|
+
for (const signature of signatures) {
|
40
|
+
const state = signers.find((x) => x.address === signature.signer);
|
41
|
+
if (!state || state.address !== signature.signer) {
|
42
|
+
return next(
|
43
|
+
new Error('ACCOUNT_MIGRATED', `Signer account ${signature.signer} is migrated`, { persist: true })
|
44
|
+
);
|
45
|
+
}
|
46
|
+
}
|
26
47
|
}
|
27
48
|
}
|
28
49
|
|
@@ -12,9 +12,9 @@ const debug = require('debug')(`${require('../../package.json').name}:pipe:verif
|
|
12
12
|
* - Verify the asset updater, can be the owner or the issuer
|
13
13
|
*
|
14
14
|
* @param {object} params
|
15
|
-
* @
|
16
|
-
* @
|
17
|
-
* @
|
15
|
+
* @param {string} params.assetKey key to extract assets from context
|
16
|
+
* @param {string} params.ownerKey key to extract owner from context
|
17
|
+
* @param {string} [params.updaterKey] key to extract updater address from asset
|
18
18
|
*/
|
19
19
|
module.exports = function CreateVerifyUpdaterPipe({ assetKey, ownerKey, updaterKey = 'owner' }) {
|
20
20
|
return function VerifyUpdater(context, next) {
|
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.60",
|
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.18.
|
33
|
-
"@arcblock/did-util": "1.18.
|
34
|
-
"@ocap/mcrypto": "1.18.
|
35
|
-
"@ocap/message": "1.18.
|
36
|
-
"@ocap/state": "1.18.
|
37
|
-
"@ocap/util": "1.18.
|
38
|
-
"@ocap/wallet": "1.18.
|
32
|
+
"@arcblock/did": "1.18.60",
|
33
|
+
"@arcblock/did-util": "1.18.60",
|
34
|
+
"@ocap/mcrypto": "1.18.60",
|
35
|
+
"@ocap/message": "1.18.60",
|
36
|
+
"@ocap/state": "1.18.60",
|
37
|
+
"@ocap/util": "1.18.60",
|
38
|
+
"@ocap/wallet": "1.18.60",
|
39
39
|
"debug": "^4.3.4",
|
40
40
|
"empty-value": "^1.0.1",
|
41
41
|
"lodash": "^4.17.21"
|
42
42
|
},
|
43
|
-
"gitHead": "
|
43
|
+
"gitHead": "0991b0393f9510fd1fe748be4776a9761ba3a831"
|
44
44
|
}
|