@arcblock/validator 1.17.11 → 1.17.12
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/index.d.ts +30 -0
- package/lib/index.js +79 -8
- package/package.json +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -11,6 +11,36 @@ export declare const schemas: {
|
|
|
11
11
|
tokenInput: BaseJoi.ObjectSchema<any>;
|
|
12
12
|
multiSig: BaseJoi.ArraySchema;
|
|
13
13
|
foreignToken: BaseJoi.ObjectSchema<any>;
|
|
14
|
+
nftDisplay: BaseJoi.ObjectSchema<any>;
|
|
15
|
+
nftEndpoint: BaseJoi.ObjectSchema<any>;
|
|
16
|
+
assetProps: {
|
|
17
|
+
address: DIDSchema;
|
|
18
|
+
moniker: BaseJoi.StringSchema;
|
|
19
|
+
data: BaseJoi.AnySchema<any>;
|
|
20
|
+
readonly: BaseJoi.BooleanSchema;
|
|
21
|
+
transferrable: BaseJoi.BooleanSchema;
|
|
22
|
+
ttl: BaseJoi.NumberSchema;
|
|
23
|
+
parent: DIDSchema;
|
|
24
|
+
issuer: DIDSchema;
|
|
25
|
+
endpoint: BaseJoi.ObjectSchema<any>;
|
|
26
|
+
display: BaseJoi.ObjectSchema<any>;
|
|
27
|
+
tags: BaseJoi.ArraySchema;
|
|
28
|
+
};
|
|
29
|
+
assetSchema: BaseJoi.ObjectSchema<any>;
|
|
30
|
+
factoryProps: {
|
|
31
|
+
address: DIDSchema;
|
|
32
|
+
name: BaseJoi.StringSchema;
|
|
33
|
+
description: BaseJoi.StringSchema;
|
|
34
|
+
settlement: BaseJoi.StringSchema;
|
|
35
|
+
limit: BaseJoi.NumberSchema;
|
|
36
|
+
trustedIssuers: BaseJoi.ArraySchema;
|
|
37
|
+
data: BaseJoi.AnySchema<any>;
|
|
38
|
+
display: BaseJoi.ObjectSchema<any>;
|
|
39
|
+
input: BaseJoi.ObjectSchema<any>;
|
|
40
|
+
output: BaseJoi.ObjectSchema<any>;
|
|
41
|
+
hooks: BaseJoi.ArraySchema;
|
|
42
|
+
};
|
|
43
|
+
factorySchema: BaseJoi.ObjectSchema<any>;
|
|
14
44
|
};
|
|
15
45
|
export declare const patterns: {
|
|
16
46
|
txHash: RegExp;
|
package/lib/index.js
CHANGED
|
@@ -9,35 +9,106 @@ const bn_1 = require("./extension/bn");
|
|
|
9
9
|
const did_1 = require("./extension/did");
|
|
10
10
|
exports.Joi = joi_1.default.extend(did_1.DIDExtension).extend(bn_1.BNExtension);
|
|
11
11
|
const txHash = /^(0x)?([A-Fa-f0-9]{64})$/;
|
|
12
|
-
const
|
|
12
|
+
const context = exports.Joi.object({
|
|
13
13
|
genesisTime: exports.Joi.date().iso().required().raw(),
|
|
14
14
|
genesisTx: exports.Joi.string().regex(txHash).required().allow(''),
|
|
15
15
|
renaissanceTime: exports.Joi.date().iso().required().raw(),
|
|
16
16
|
renaissanceTx: exports.Joi.string().regex(txHash).required().allow(''),
|
|
17
17
|
});
|
|
18
|
-
const
|
|
18
|
+
const tokenInput = exports.Joi.object({
|
|
19
19
|
address: exports.Joi.DID().role('ROLE_TOKEN').required(),
|
|
20
20
|
value: exports.Joi.BN().positive().required(),
|
|
21
21
|
});
|
|
22
|
-
const
|
|
22
|
+
const multiSig = exports.Joi.array().items({
|
|
23
23
|
signer: exports.Joi.DID().required(),
|
|
24
24
|
pk: exports.Joi.any().required(),
|
|
25
25
|
signature: exports.Joi.any().required(),
|
|
26
26
|
delegator: exports.Joi.DID().valid('').optional(),
|
|
27
27
|
data: exports.Joi.any().optional(),
|
|
28
28
|
});
|
|
29
|
-
const
|
|
29
|
+
const foreignToken = exports.Joi.object({
|
|
30
30
|
type: exports.Joi.string().min(1).max(32).required(),
|
|
31
31
|
contractAddress: exports.Joi.DID().wallet('ethereum').required(),
|
|
32
32
|
chainType: exports.Joi.string().min(1).max(32).required(),
|
|
33
33
|
chainName: exports.Joi.string().min(1).max(32).required(),
|
|
34
34
|
chainId: exports.Joi.number().positive().required(),
|
|
35
35
|
});
|
|
36
|
+
const nftDisplay = exports.Joi.object({
|
|
37
|
+
type: exports.Joi.string().valid('svg', 'url', 'uri').required(),
|
|
38
|
+
content: exports.Joi.string()
|
|
39
|
+
.when('type', { is: 'uri', then: exports.Joi.string().dataUri().required() })
|
|
40
|
+
.when('type', { is: 'url', then: exports.Joi.string().uri({ scheme: ['http', 'https'] }).required() }), // prettier-ignore
|
|
41
|
+
});
|
|
42
|
+
const nftEndpoint = exports.Joi.object({
|
|
43
|
+
id: exports.Joi.string().uri({ scheme: ['http', 'https'] }).required(),
|
|
44
|
+
scope: exports.Joi.string().valid('public', 'private').default('public'),
|
|
45
|
+
});
|
|
46
|
+
const assetProps = {
|
|
47
|
+
address: exports.Joi.DID().role('ROLE_ASSET').required(),
|
|
48
|
+
moniker: exports.Joi.string().min(2).max(255).required(),
|
|
49
|
+
data: exports.Joi.any().required(),
|
|
50
|
+
readonly: exports.Joi.boolean().default(false),
|
|
51
|
+
transferrable: exports.Joi.boolean().default(false),
|
|
52
|
+
ttl: exports.Joi.number().min(0).default(0),
|
|
53
|
+
parent: exports.Joi.DID().optional().allow(''),
|
|
54
|
+
issuer: exports.Joi.DID().optional().allow(''),
|
|
55
|
+
endpoint: nftEndpoint.optional().allow(null).default(null),
|
|
56
|
+
display: nftDisplay.optional().allow(null).default(null),
|
|
57
|
+
tags: exports.Joi.array().items(exports.Joi.string().min(1).max(36)).max(4).optional(),
|
|
58
|
+
};
|
|
59
|
+
const factoryProps = {
|
|
60
|
+
address: exports.Joi.DID().role('ROLE_FACTORY').required(),
|
|
61
|
+
name: exports.Joi.string().min(2).max(255).required(),
|
|
62
|
+
description: exports.Joi.string().min(2).max(255).required(),
|
|
63
|
+
settlement: exports.Joi.string().valid('instant', 'periodic').default('instant'),
|
|
64
|
+
limit: exports.Joi.number().integer().min(0).default(0),
|
|
65
|
+
trustedIssuers: exports.Joi.array().items(exports.Joi.DID()).max(8).optional(),
|
|
66
|
+
data: exports.Joi.any().optional().allow(null).default(null),
|
|
67
|
+
display: nftDisplay.optional().allow(null).default(null),
|
|
68
|
+
input: exports.Joi.object({
|
|
69
|
+
value: exports.Joi.BN().positive().min('0').default('0'),
|
|
70
|
+
tokens: exports.Joi.array().items(tokenInput).max(8).optional(),
|
|
71
|
+
assets: exports.Joi.array().items(exports.Joi.DID()).max(8).optional(),
|
|
72
|
+
variables: exports.Joi.array()
|
|
73
|
+
.items(exports.Joi.object({
|
|
74
|
+
name: exports.Joi.string().required(),
|
|
75
|
+
description: exports.Joi.string().min(2).max(255).required(),
|
|
76
|
+
required: exports.Joi.boolean().required(),
|
|
77
|
+
}))
|
|
78
|
+
.optional(),
|
|
79
|
+
}),
|
|
80
|
+
output: exports.Joi.object({
|
|
81
|
+
moniker: exports.Joi.string().min(2).max(255).required(),
|
|
82
|
+
data: exports.Joi.any().required(),
|
|
83
|
+
readonly: exports.Joi.boolean().default(false),
|
|
84
|
+
transferrable: exports.Joi.boolean().default(false),
|
|
85
|
+
ttl: exports.Joi.number().min(0).default(0),
|
|
86
|
+
parent: exports.Joi.string().required(),
|
|
87
|
+
issuer: exports.Joi.string().required(),
|
|
88
|
+
endpoint: nftEndpoint.optional(),
|
|
89
|
+
display: nftDisplay.optional(),
|
|
90
|
+
tags: exports.Joi.array().items(exports.Joi.string().min(1).max(36)).max(4).optional(),
|
|
91
|
+
}),
|
|
92
|
+
hooks: exports.Joi.array()
|
|
93
|
+
.items(exports.Joi.object({
|
|
94
|
+
name: exports.Joi.string().valid('mint', 'postMint').required(),
|
|
95
|
+
type: exports.Joi.string().valid('url', 'contract').required(),
|
|
96
|
+
hook: exports.Joi.string().min(1).required(),
|
|
97
|
+
compiled: exports.Joi.array().items(exports.Joi.object()).optional(),
|
|
98
|
+
}))
|
|
99
|
+
.optional(),
|
|
100
|
+
};
|
|
36
101
|
exports.schemas = {
|
|
37
|
-
context
|
|
38
|
-
tokenInput
|
|
39
|
-
multiSig
|
|
40
|
-
foreignToken
|
|
102
|
+
context,
|
|
103
|
+
tokenInput,
|
|
104
|
+
multiSig,
|
|
105
|
+
foreignToken,
|
|
106
|
+
nftDisplay,
|
|
107
|
+
nftEndpoint,
|
|
108
|
+
assetProps,
|
|
109
|
+
assetSchema: exports.Joi.object(assetProps).options({ stripUnknown: true, noDefaults: false }),
|
|
110
|
+
factoryProps,
|
|
111
|
+
factorySchema: exports.Joi.object(factoryProps).options({ stripUnknown: true, noDefaults: false }),
|
|
41
112
|
};
|
|
42
113
|
exports.patterns = {
|
|
43
114
|
txHash,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.17.
|
|
6
|
+
"version": "1.17.12",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"build": "tsc"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@arcblock/did": "1.17.
|
|
25
|
-
"@ocap/mcrypto": "1.17.
|
|
26
|
-
"@ocap/util": "1.17.
|
|
24
|
+
"@arcblock/did": "1.17.12",
|
|
25
|
+
"@ocap/mcrypto": "1.17.12",
|
|
26
|
+
"@ocap/util": "1.17.12",
|
|
27
27
|
"bn.js": "5.2.1",
|
|
28
28
|
"joi": "^17.6.0",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"bn.js": "5.2.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@arcblock/eslint-config-ts": "0.2.
|
|
36
|
+
"@arcblock/eslint-config-ts": "0.2.3",
|
|
37
37
|
"eslint": "^8.21.0",
|
|
38
38
|
"jest": "^28.1.3",
|
|
39
39
|
"ts-jest": "^28.0.7",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"keywords": [],
|
|
43
43
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
44
44
|
"license": "MIT",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9209d3e84008ba758810a607b1c6a4b4fd5e7bc0"
|
|
46
46
|
}
|