@ocap/config 1.13.63 → 1.13.67
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/default.js +8 -5
- package/lib/index.js +12 -2
- package/lib/schema.js +9 -8
- package/package.json +6 -6
package/lib/default.js
CHANGED
@@ -30,17 +30,19 @@ module.exports = {
|
|
30
30
|
'fg:t:create_rollup_block': 4096,
|
31
31
|
'fg:t:claim_block_reward': 1691,
|
32
32
|
},
|
33
|
+
txFee: {
|
34
|
+
default: 0, // in ABT
|
35
|
+
'fg:t:create_asset': 1,
|
36
|
+
'fg:t:create_factory': 100,
|
37
|
+
'fg:t:create_token': 1000,
|
38
|
+
'fg:t:create_rollup': 10000,
|
39
|
+
},
|
33
40
|
delegate: {
|
34
41
|
deltaInterval: 18000,
|
35
42
|
// list transaction protocols that can work with delegation
|
36
43
|
// the transaction protocol must enable VerifyDelegation pipe before added here
|
37
44
|
typeUrls: ['fg:t:transfer', 'fg:t:transfer_v2', 'fg:t:exchange_v2', 'fg:t:acquire_asset_v2'],
|
38
45
|
},
|
39
|
-
declare: {
|
40
|
-
cost: 0,
|
41
|
-
hierarchy: 5,
|
42
|
-
restricted: false,
|
43
|
-
},
|
44
46
|
supportedTxs: [
|
45
47
|
'fg:t:transfer',
|
46
48
|
'fg:t:transfer_v2',
|
@@ -82,6 +84,7 @@ module.exports = {
|
|
82
84
|
'fg:t:claim_block_reward',
|
83
85
|
],
|
84
86
|
},
|
87
|
+
vaults: {},
|
85
88
|
accounts: [],
|
86
89
|
token: {
|
87
90
|
name: 'TestChainToken',
|
package/lib/index.js
CHANGED
@@ -10,8 +10,18 @@ const schema = require('./schema');
|
|
10
10
|
const validate = (config) => {
|
11
11
|
const { value, error } = schema.validate(config);
|
12
12
|
if (error) {
|
13
|
-
console.error('Invalid
|
14
|
-
throw new Error(`Invalid
|
13
|
+
console.error('Invalid config', error.details.map((x) => x.message).join(', '));
|
14
|
+
throw new Error(`Invalid config: ${error.details.map((x) => x.message).join(', ')}`);
|
15
|
+
}
|
16
|
+
|
17
|
+
const { vaults, transaction, accounts } = value;
|
18
|
+
if (Object.keys(vaults).some((v) => !accounts.find((x) => x.address === vaults[v]))) {
|
19
|
+
throw new Error('Invalid config: vault address does not exist in accounts');
|
20
|
+
}
|
21
|
+
|
22
|
+
const hasPaidTx = Object.keys(transaction.txFee).some((x) => transaction.txFee[x] > 0);
|
23
|
+
if (hasPaidTx && !vaults.txFee) {
|
24
|
+
throw new Error('Invalid config: vaults.txFee can not be empty when there are paid transactions');
|
15
25
|
}
|
16
26
|
|
17
27
|
return value;
|
package/lib/schema.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
const Joi = require('
|
1
|
+
const Joi = require('@ocap/validator');
|
2
2
|
|
3
3
|
const defaultConfig = require('./default');
|
4
4
|
|
5
5
|
const accountSchema = {
|
6
|
-
address: Joi.
|
6
|
+
address: Joi.DID().required(),
|
7
7
|
pk: Joi.string().allow('').required(),
|
8
8
|
balance: Joi.number().optional().default(0),
|
9
9
|
};
|
@@ -15,23 +15,24 @@ const configSchema = Joi.object({
|
|
15
15
|
maxAssetSize: Joi.number().positive().required(),
|
16
16
|
maxListSize: Joi.number().positive().required(),
|
17
17
|
maxMultisig: Joi.number().positive().required(),
|
18
|
-
maxTxSize: Joi.
|
18
|
+
maxTxSize: Joi.object()
|
19
|
+
.pattern(Joi.string().pattern(/^(default|fg:t:[_a-z0-9]+)$/), Joi.number().integer().greater(0))
|
20
|
+
.required(),
|
19
21
|
delegate: Joi.object({
|
20
22
|
deltaInterval: Joi.number().positive(),
|
21
23
|
typeUrls: Joi.array().items(Joi.string()),
|
22
24
|
}).required(),
|
23
|
-
declare: Joi.object({
|
24
|
-
cost: Joi.number().positive().allow(0),
|
25
|
-
hierarchy: Joi.number().positive(),
|
26
|
-
restricted: Joi.boolean(),
|
27
|
-
}).required(),
|
28
25
|
supportedTxs: Joi.array().items(Joi.string()).min(1).required(),
|
29
26
|
multiSignV2Txs: Joi.array().items(Joi.string()).min(1).required(),
|
27
|
+
txFee: Joi.object()
|
28
|
+
.pattern(Joi.string().pattern(/^(default|fg:t:[_a-z0-9]+)$/), Joi.number().precision(6).min(0))
|
29
|
+
.required(),
|
30
30
|
})
|
31
31
|
.optional()
|
32
32
|
.default(defaultConfig.transaction),
|
33
33
|
moderator: Joi.object(accountSchema).required(),
|
34
34
|
accounts: Joi.array().items(accountSchema).required(),
|
35
|
+
vaults: Joi.object().pattern(Joi.string().allow('quotaSlash', 'txFee'), Joi.DID()).default({}),
|
35
36
|
token: Joi.object({
|
36
37
|
name: Joi.string().required(),
|
37
38
|
description: Joi.string().required(),
|
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.67",
|
7
7
|
"description": "OCAP config parsing/validation and default",
|
8
8
|
"main": "lib/index.js",
|
9
9
|
"files": [
|
@@ -22,11 +22,11 @@
|
|
22
22
|
"jest": "^27.3.1"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@arcblock/did": "1.13.
|
26
|
-
"@arcblock/did-util": "1.13.
|
27
|
-
"@ocap/util": "1.13.
|
28
|
-
"
|
25
|
+
"@arcblock/did": "1.13.67",
|
26
|
+
"@arcblock/did-util": "1.13.67",
|
27
|
+
"@ocap/util": "1.13.67",
|
28
|
+
"@ocap/validator": "1.13.67",
|
29
29
|
"lodash": "^4.17.21"
|
30
30
|
},
|
31
|
-
"gitHead": "
|
31
|
+
"gitHead": "866f6a0dbf4fc22425b8583d84610880472a3109"
|
32
32
|
}
|