@ocap/tx-protocols 1.13.28 → 1.13.32
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.
|
@@ -5,7 +5,7 @@ const Error = require('@ocap/util/lib/error');
|
|
|
5
5
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
6
6
|
const { account, rollup } = require('@ocap/state');
|
|
7
7
|
const { formatMessage } = require('@ocap/message');
|
|
8
|
-
const { isFromPublicKey } = require('@arcblock/did');
|
|
8
|
+
const { isFromPublicKey, isEthereumDid } = require('@arcblock/did');
|
|
9
9
|
const { toRollupAddress } = require('@arcblock/did-util');
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line global-require
|
|
@@ -37,6 +37,11 @@ runner.use(
|
|
|
37
37
|
message: 'Seed validator pk and address not match',
|
|
38
38
|
fn: ({ formattedItx }) => formattedItx.seedValidators.every(({ pk, address }) => isFromPublicKey(address, pk)),
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
error: 'INVALID_TX',
|
|
42
|
+
message: 'Seed validator must use ethereum compatible address',
|
|
43
|
+
fn: ({ formattedItx }) => formattedItx.seedValidators.every(({ address }) => isEthereumDid(address)),
|
|
44
|
+
},
|
|
40
45
|
{
|
|
41
46
|
error: 'INVALID_TX',
|
|
42
47
|
message: 'Rollup address is not valid',
|
|
@@ -6,6 +6,7 @@ const { BN, toHex } = require('@ocap/util');
|
|
|
6
6
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
7
7
|
const { account, rollup, stake, evidence, Joi } = require('@ocap/state');
|
|
8
8
|
const { toStakeAddress } = require('@arcblock/did-util');
|
|
9
|
+
const { isEthereumDid } = require('@arcblock/did');
|
|
9
10
|
|
|
10
11
|
// eslint-disable-next-line global-require
|
|
11
12
|
const debug = require('debug')(`${require('../../../package.json').name}:join-rollup`);
|
|
@@ -39,6 +40,10 @@ runner.use(pipes.ExtractState({ from: 'itx.rollup', to: 'rollupState', status: '
|
|
|
39
40
|
runner.use((context, next) => {
|
|
40
41
|
const { tx, itx, rollupState } = context;
|
|
41
42
|
const validator = { pk: toHex(tx.pk), address: tx.from, endpoint: itx.endpoint };
|
|
43
|
+
if (isEthereumDid(tx.from) === false) {
|
|
44
|
+
return next(new Error('INVALID_TX', 'Invalid tx.from: only ethereum compatible address can join rollup'));
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
if (rollupState.validators.some((x) => x.address === validator.address)) {
|
|
43
48
|
return next(new Error('INVALID_TX', `Address ${validator.address} already exist in validators`));
|
|
44
49
|
}
|
|
@@ -5,6 +5,7 @@ const { BN, fromUnitToToken } = require('@ocap/util');
|
|
|
5
5
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
6
6
|
const { account, stake, evidence, Joi } = require('@ocap/state');
|
|
7
7
|
const { toStakeAddress } = require('@arcblock/did-util');
|
|
8
|
+
const { isEthereumDid } = require('@arcblock/did');
|
|
8
9
|
|
|
9
10
|
// eslint-disable-next-line global-require
|
|
10
11
|
const debug = require('debug')(`${require('../../../package.json').name}:deposit-token`);
|
|
@@ -32,6 +33,10 @@ runner.use(({ tx, itx }, next) => {
|
|
|
32
33
|
return next(new Error('INVALID_TX', `Invalid itx: ${error.message}`));
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
if (isEthereumDid(itx.to) === false) {
|
|
37
|
+
return next(new Error('INVALID_TX', 'Invalid itx.to: only ethereum compatible address can deposit token'));
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
if (itx.to !== tx.from) {
|
|
36
41
|
return next(new Error('INVALID_TX', 'You can only deposit to tx sender account'));
|
|
37
42
|
}
|
|
@@ -4,6 +4,7 @@ const { BN, fromUnitToToken } = require('@ocap/util');
|
|
|
4
4
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
5
5
|
const { account, stake, Joi } = require('@ocap/state');
|
|
6
6
|
const { toStakeAddress } = require('@arcblock/did-util');
|
|
7
|
+
const { isEthereumDid } = require('@arcblock/did');
|
|
7
8
|
|
|
8
9
|
// eslint-disable-next-line global-require
|
|
9
10
|
const debug = require('debug')(`${require('../../../package.json').name}:withdraw-token`);
|
|
@@ -28,6 +29,10 @@ runner.use(({ tx, itx }, next) => {
|
|
|
28
29
|
return next(new Error('INVALID_TX', `Invalid itx: ${error.message}`));
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
if (isEthereumDid(itx.to) === false) {
|
|
33
|
+
return next(new Error('INVALID_TX', 'Invalid itx.to: only ethereum compatible address can withdraw token'));
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
if (itx.to !== tx.from) {
|
|
32
37
|
return next(new Error('INVALID_TX', 'You can only withdraw to tx sender account'));
|
|
33
38
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.13.
|
|
6
|
+
"version": "1.13.32",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@arcblock/did": "1.13.
|
|
23
|
-
"@arcblock/did-util": "1.13.
|
|
24
|
-
"@ocap/asset": "1.13.
|
|
25
|
-
"@ocap/mcrypto": "1.13.
|
|
26
|
-
"@ocap/merkle-tree": "1.13.
|
|
27
|
-
"@ocap/message": "1.13.
|
|
28
|
-
"@ocap/state": "1.13.
|
|
29
|
-
"@ocap/tx-pipeline": "1.13.
|
|
30
|
-
"@ocap/util": "1.13.
|
|
31
|
-
"@ocap/wallet": "1.13.
|
|
22
|
+
"@arcblock/did": "1.13.32",
|
|
23
|
+
"@arcblock/did-util": "1.13.32",
|
|
24
|
+
"@ocap/asset": "1.13.32",
|
|
25
|
+
"@ocap/mcrypto": "1.13.32",
|
|
26
|
+
"@ocap/merkle-tree": "1.13.32",
|
|
27
|
+
"@ocap/message": "1.13.32",
|
|
28
|
+
"@ocap/state": "1.13.32",
|
|
29
|
+
"@ocap/tx-pipeline": "1.13.32",
|
|
30
|
+
"@ocap/util": "1.13.32",
|
|
31
|
+
"@ocap/wallet": "1.13.32",
|
|
32
32
|
"debug": "^4.3.2",
|
|
33
33
|
"empty-value": "^1.0.1",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"jest": "^26.6.3"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "30a6554645478a0c3c29477e6e9954c8d42272e0"
|
|
45
45
|
}
|