@arcblock/validator 1.27.15 → 1.28.0
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/esm/extension/bn.d.ts +93 -89
- package/esm/extension/bn.js +139 -129
- package/esm/extension/did.d.ts +76 -72
- package/esm/extension/did.js +145 -133
- package/esm/index.d.ts +52 -48
- package/esm/index.js +115 -109
- package/esm/lodash.d.ts +2 -0
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/extension/bn.d.ts +93 -89
- package/lib/extension/bn.js +140 -134
- package/lib/extension/did.d.ts +76 -72
- package/lib/extension/did.js +146 -138
- package/lib/index.d.ts +52 -48
- package/lib/index.js +128 -124
- package/lib/lodash.d.d.ts +0 -0
- package/lib/lodash.d.ts +2 -0
- package/package.json +22 -11
package/lib/index.js
CHANGED
|
@@ -1,139 +1,143 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const did_1 = require("./extension/did");
|
|
10
|
-
exports.Joi = joi_1.default.extend(did_1.DIDExtension).extend(bn_1.BNExtension);
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_extension_bn = require('./extension/bn.js');
|
|
3
|
+
const require_extension_did = require('./extension/did.js');
|
|
4
|
+
let joi = require("joi");
|
|
5
|
+
joi = require_rolldown_runtime.__toESM(joi);
|
|
6
|
+
|
|
7
|
+
//#region src/index.ts
|
|
8
|
+
const Joi = joi.default.extend(require_extension_did.DIDExtension).extend(require_extension_bn.BNExtension);
|
|
11
9
|
const txHash = /^(0x)?([A-Fa-f0-9]{64})$/;
|
|
12
|
-
const context =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const context = Joi.object({
|
|
11
|
+
genesisTime: Joi.date().iso().required().raw(),
|
|
12
|
+
genesisTx: Joi.string().regex(txHash).required().allow(""),
|
|
13
|
+
renaissanceTime: Joi.date().iso().required().raw(),
|
|
14
|
+
renaissanceTx: Joi.string().regex(txHash).required().allow("")
|
|
17
15
|
});
|
|
18
|
-
const tokenInput =
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const tokenInput = Joi.object({
|
|
17
|
+
address: Joi.DID().prefix().role("ROLE_TOKEN").required(),
|
|
18
|
+
value: Joi.BN().min(0).required()
|
|
21
19
|
});
|
|
22
|
-
const variableInput =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const variableInput = Joi.object({
|
|
21
|
+
name: Joi.string().min(1).max(256).required(),
|
|
22
|
+
value: Joi.string().min(1).max(1024).required(),
|
|
23
|
+
description: Joi.string().min(1).max(256).optional().allow(""),
|
|
24
|
+
required: Joi.boolean().optional().default(false)
|
|
27
25
|
});
|
|
28
|
-
const tokenHolder =
|
|
29
|
-
const multiInput =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const tokenHolder = Joi.alternatives().try(Joi.DID().prefix().role("ROLE_ACCOUNT"), Joi.DID().prefix().role("ROLE_APPLICATION"), Joi.DID().prefix().role("ROLE_BLOCKLET"), Joi.DID().prefix().wallet("ethereum"), Joi.DID().prefix().wallet("passkey"));
|
|
27
|
+
const multiInput = Joi.array().items(Joi.object({
|
|
28
|
+
owner: tokenHolder.required(),
|
|
29
|
+
tokensList: Joi.array().items(tokenInput).default([]),
|
|
30
|
+
assetsList: Joi.array().items(Joi.DID().prefix().role("ROLE_ASSET")).default([])
|
|
33
31
|
}));
|
|
34
|
-
const multiSig =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const multiSig = Joi.array().items({
|
|
33
|
+
signer: Joi.DID().prefix().required(),
|
|
34
|
+
pk: Joi.any().required(),
|
|
35
|
+
signature: Joi.any().required(),
|
|
36
|
+
delegator: Joi.DID().prefix().valid("").optional(),
|
|
37
|
+
data: Joi.any().optional()
|
|
40
38
|
});
|
|
41
|
-
const foreignToken =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const foreignToken = Joi.object({
|
|
40
|
+
type: Joi.string().min(1).max(32).required(),
|
|
41
|
+
contractAddress: Joi.DID().prefix().wallet("ethereum").required(),
|
|
42
|
+
chainType: Joi.string().min(1).max(32).required(),
|
|
43
|
+
chainName: Joi.string().min(1).max(32).required(),
|
|
44
|
+
chainId: Joi.number().positive().required()
|
|
47
45
|
});
|
|
48
|
-
const nftDisplay =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
const nftDisplay = Joi.object({
|
|
47
|
+
type: Joi.string().valid("svg", "url", "uri").required(),
|
|
48
|
+
content: Joi.string().when("type", {
|
|
49
|
+
is: "uri",
|
|
50
|
+
then: Joi.string().max(20480).dataUri().required()
|
|
51
|
+
}).when("type", {
|
|
52
|
+
is: "url",
|
|
53
|
+
then: Joi.string().max(2048).uri({ scheme: ["http", "https"] }).required()
|
|
54
|
+
})
|
|
53
55
|
});
|
|
54
|
-
const nftEndpoint =
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const nftEndpoint = Joi.object({
|
|
57
|
+
id: Joi.string().max(2048).uri({ scheme: ["http", "https"] }).required(),
|
|
58
|
+
scope: Joi.string().valid("public", "private").default("public")
|
|
57
59
|
});
|
|
58
|
-
const nftIssuer =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const nftIssuer = Joi.object({
|
|
61
|
+
id: Joi.DID().prefix().required(),
|
|
62
|
+
pk: Joi.string().required(),
|
|
63
|
+
name: Joi.string().min(1).max(256).required()
|
|
62
64
|
});
|
|
63
65
|
const assetProps = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
address: Joi.DID().prefix().role("ROLE_ASSET").required(),
|
|
67
|
+
moniker: Joi.string().min(2).max(255).required(),
|
|
68
|
+
data: Joi.any().required(),
|
|
69
|
+
readonly: Joi.boolean().default(false),
|
|
70
|
+
transferrable: Joi.boolean().default(false),
|
|
71
|
+
ttl: Joi.number().min(0).default(0),
|
|
72
|
+
parent: Joi.DID().prefix().optional().allow(""),
|
|
73
|
+
issuer: Joi.DID().prefix().optional().allow(""),
|
|
74
|
+
endpoint: nftEndpoint.optional().allow(null).default(null),
|
|
75
|
+
display: nftDisplay.optional().allow(null).default(null),
|
|
76
|
+
tags: Joi.array().items(Joi.string().min(1).max(64)).max(4).optional()
|
|
75
77
|
};
|
|
76
78
|
const factoryProps = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.items(exports.Joi.object({
|
|
114
|
-
name: exports.Joi.string().valid('mint', 'postMint', 'preMint').required(),
|
|
115
|
-
type: exports.Joi.string().valid('url', 'contract').required(),
|
|
116
|
-
hook: exports.Joi.string().min(1).max(4096).required(), // due to amazon qldb limit, 32 transfers
|
|
117
|
-
compiled: exports.Joi.array().items(exports.Joi.object()).optional(),
|
|
118
|
-
}))
|
|
119
|
-
.optional(),
|
|
120
|
-
};
|
|
121
|
-
exports.schemas = {
|
|
122
|
-
context,
|
|
123
|
-
tokenInput,
|
|
124
|
-
multiInput,
|
|
125
|
-
multiSig,
|
|
126
|
-
foreignToken,
|
|
127
|
-
variableInput,
|
|
128
|
-
nftDisplay,
|
|
129
|
-
nftEndpoint,
|
|
130
|
-
nftIssuer,
|
|
131
|
-
tokenHolder,
|
|
132
|
-
assetProps,
|
|
133
|
-
assetSchema: exports.Joi.object(assetProps).options({ stripUnknown: true, noDefaults: false }),
|
|
134
|
-
factoryProps,
|
|
135
|
-
factorySchema: exports.Joi.object(factoryProps).options({ stripUnknown: true, noDefaults: false }),
|
|
79
|
+
address: Joi.DID().prefix().role("ROLE_FACTORY").required(),
|
|
80
|
+
name: Joi.string().min(2).max(255).required(),
|
|
81
|
+
description: Joi.string().min(2).max(255).required(),
|
|
82
|
+
settlement: Joi.string().valid("instant", "periodic").default("instant"),
|
|
83
|
+
limit: Joi.number().integer().min(0).default(0),
|
|
84
|
+
trustedIssuers: Joi.array().items(Joi.DID().prefix()).max(8).optional(),
|
|
85
|
+
data: Joi.any().optional().allow(null).default(null),
|
|
86
|
+
display: nftDisplay.optional().allow(null).default(null),
|
|
87
|
+
input: Joi.object({
|
|
88
|
+
value: Joi.BN().positive().min("0").default("0"),
|
|
89
|
+
tokens: Joi.array().items(tokenInput).max(8).optional(),
|
|
90
|
+
assets: Joi.array().items(Joi.alternatives().try(Joi.DID().prefix().role("ROLE_ASSET"), Joi.DID().prefix().role("ROLE_FACTORY"))).max(8).optional(),
|
|
91
|
+
variables: Joi.array().items(Joi.object({
|
|
92
|
+
name: Joi.string().min(1).max(255).required(),
|
|
93
|
+
description: Joi.string().max(255).optional().allow(""),
|
|
94
|
+
required: Joi.boolean().required()
|
|
95
|
+
})).optional()
|
|
96
|
+
}),
|
|
97
|
+
output: Joi.object({
|
|
98
|
+
moniker: Joi.string().min(2).max(255).required(),
|
|
99
|
+
data: Joi.any().required(),
|
|
100
|
+
readonly: Joi.boolean().default(false),
|
|
101
|
+
transferrable: Joi.boolean().default(false),
|
|
102
|
+
ttl: Joi.number().min(0).default(0),
|
|
103
|
+
parent: Joi.string().max(255).required(),
|
|
104
|
+
issuer: Joi.string().max(255).required(),
|
|
105
|
+
endpoint: nftEndpoint.optional(),
|
|
106
|
+
display: nftDisplay.optional(),
|
|
107
|
+
tags: Joi.array().items(Joi.string().min(1).max(64)).max(4).optional()
|
|
108
|
+
}),
|
|
109
|
+
hooks: Joi.array().items(Joi.object({
|
|
110
|
+
name: Joi.string().valid("mint", "postMint", "preMint").required(),
|
|
111
|
+
type: Joi.string().valid("url", "contract").required(),
|
|
112
|
+
hook: Joi.string().min(1).max(4096).required(),
|
|
113
|
+
compiled: Joi.array().items(Joi.object()).optional()
|
|
114
|
+
})).optional()
|
|
136
115
|
};
|
|
137
|
-
|
|
138
|
-
|
|
116
|
+
const schemas = {
|
|
117
|
+
context,
|
|
118
|
+
tokenInput,
|
|
119
|
+
multiInput,
|
|
120
|
+
multiSig,
|
|
121
|
+
foreignToken,
|
|
122
|
+
variableInput,
|
|
123
|
+
nftDisplay,
|
|
124
|
+
nftEndpoint,
|
|
125
|
+
nftIssuer,
|
|
126
|
+
tokenHolder,
|
|
127
|
+
assetProps,
|
|
128
|
+
assetSchema: Joi.object(assetProps).options({
|
|
129
|
+
stripUnknown: true,
|
|
130
|
+
noDefaults: false
|
|
131
|
+
}),
|
|
132
|
+
factoryProps,
|
|
133
|
+
factorySchema: Joi.object(factoryProps).options({
|
|
134
|
+
stripUnknown: true,
|
|
135
|
+
noDefaults: false
|
|
136
|
+
})
|
|
139
137
|
};
|
|
138
|
+
const patterns = { txHash };
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.Joi = Joi;
|
|
142
|
+
exports.patterns = patterns;
|
|
143
|
+
exports.schemas = schemas;
|
|
File without changes
|
package/lib/lodash.d.ts
ADDED
package/package.json
CHANGED
|
@@ -3,10 +3,24 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.28.0",
|
|
7
7
|
"description": "",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"main": "./lib/index.js",
|
|
9
|
-
"
|
|
10
|
+
"module": "./esm/index.js",
|
|
11
|
+
"types": "./esm/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./esm/index.d.ts",
|
|
16
|
+
"default": "./esm/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
10
24
|
"files": [
|
|
11
25
|
"lib",
|
|
12
26
|
"esm"
|
|
@@ -15,9 +29,9 @@
|
|
|
15
29
|
"bn.js": "5.2.2",
|
|
16
30
|
"joi": "^17.7.0",
|
|
17
31
|
"lodash": "^4.17.21",
|
|
18
|
-
"@arcblock/did": "1.
|
|
19
|
-
"@ocap/mcrypto": "1.
|
|
20
|
-
"@ocap/util": "1.
|
|
32
|
+
"@arcblock/did": "1.28.0",
|
|
33
|
+
"@ocap/mcrypto": "1.28.0",
|
|
34
|
+
"@ocap/util": "1.28.0"
|
|
21
35
|
},
|
|
22
36
|
"resolutions": {
|
|
23
37
|
"bn.js": "5.2.2"
|
|
@@ -27,6 +41,7 @@
|
|
|
27
41
|
"eslint": "^8.57.0",
|
|
28
42
|
"jest": "^29.7.0",
|
|
29
43
|
"ts-jest": "^29.2.5",
|
|
44
|
+
"tsdown": "^0.18.4",
|
|
30
45
|
"type-fest": "^3.1.0",
|
|
31
46
|
"typescript": "^5.6.2"
|
|
32
47
|
},
|
|
@@ -39,11 +54,7 @@
|
|
|
39
54
|
"lint:fix": "eslint --fix tests src",
|
|
40
55
|
"test": "jest --forceExit --detectOpenHandles",
|
|
41
56
|
"coverage": "npm run test -- --coverage",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"build:watch": "npm run build -- -w",
|
|
45
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
46
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
47
|
-
"build": "npm run build:cjs && npm run build:esm"
|
|
57
|
+
"build": "tsdown",
|
|
58
|
+
"build:watch": "tsdown --watch"
|
|
48
59
|
}
|
|
49
60
|
}
|