@arcblock/validator 1.27.16 → 1.28.1
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 +1 -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.ts +1 -0
- package/package.json +22 -11
package/esm/extension/did.js
CHANGED
|
@@ -1,136 +1,148 @@
|
|
|
1
|
-
import isEqual from
|
|
2
|
-
import { types } from
|
|
3
|
-
import {
|
|
1
|
+
import isEqual from "lodash/isEqual.js";
|
|
2
|
+
import { types } from "@ocap/mcrypto";
|
|
3
|
+
import { DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, isValid, toAddress, toTypeInfo, toTypeInfoStr } from "@arcblock/did";
|
|
4
|
+
|
|
5
|
+
//#region src/extension/did.ts
|
|
4
6
|
const ruleTypes = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
pk: Object.keys(types.KeyType),
|
|
8
|
+
hash: Object.keys(types.HashType),
|
|
9
|
+
role: Object.keys(types.RoleType)
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
11
|
+
function DIDExtension(root) {
|
|
12
|
+
return {
|
|
13
|
+
type: "DID",
|
|
14
|
+
base: root.string().trim(),
|
|
15
|
+
messages: {
|
|
16
|
+
"did.empty": "Expect {{#label}} to be non-empty string",
|
|
17
|
+
"did.invalid": "Expect {{#label}} to be valid did",
|
|
18
|
+
"did.wallet": "Expect wallet type of {{#label}} to be \"{{#expected}}\" wallet",
|
|
19
|
+
"did.pk": "Expect pk type of {{#label}} to be \"{{#expected}}\"",
|
|
20
|
+
"did.hash": "Expect hash type of {{#label}} to be \"{{#expected}}\"",
|
|
21
|
+
"did.role": "Expect role type of {{#label}} to be \"{{#expected}}\"",
|
|
22
|
+
"did.prefix": "Expect prefix of {{#label}} to be \"{{#expected}}\""
|
|
23
|
+
},
|
|
24
|
+
validate(value, helpers) {
|
|
25
|
+
if (!value || typeof value !== "string") return { errors: helpers.error("did.empty", { value }) };
|
|
26
|
+
if (isValid(value) === false) return { errors: helpers.error("did.invalid", { value }) };
|
|
27
|
+
return { value };
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
type: {
|
|
31
|
+
args: [{
|
|
32
|
+
name: "key",
|
|
33
|
+
ref: true,
|
|
34
|
+
assert: (v) => Object.keys(ruleTypes).includes(v),
|
|
35
|
+
message: `must be one of ${Object.keys(ruleTypes).join(", ")}`
|
|
36
|
+
}, {
|
|
37
|
+
name: "expected",
|
|
38
|
+
assert: (v) => Object.keys(ruleTypes).some((x) => ruleTypes[x].includes(v)),
|
|
39
|
+
message: "must be valid type"
|
|
40
|
+
}],
|
|
41
|
+
validate(value, helpers, args) {
|
|
42
|
+
const typeStr = toTypeInfoStr(value);
|
|
43
|
+
if (args.key === "pk" && typeStr.pk !== args.expected) return helpers.error("did.pk", {
|
|
44
|
+
...args,
|
|
45
|
+
actual: typeStr.pk
|
|
46
|
+
});
|
|
47
|
+
if (args.key === "hash" && typeStr.hash !== args.expected) return helpers.error("did.hash", {
|
|
48
|
+
...args,
|
|
49
|
+
actual: typeStr.hash
|
|
50
|
+
});
|
|
51
|
+
if (args.key === "role" && typeStr.role !== args.expected) return helpers.error("did.role", {
|
|
52
|
+
...args,
|
|
53
|
+
actual: typeStr.role
|
|
54
|
+
});
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
pk: { method(type) {
|
|
59
|
+
return this.$_addRule({
|
|
60
|
+
name: "type",
|
|
61
|
+
args: {
|
|
62
|
+
key: "pk",
|
|
63
|
+
expected: type
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
} },
|
|
67
|
+
hash: { method(type) {
|
|
68
|
+
return this.$_addRule({
|
|
69
|
+
name: "type",
|
|
70
|
+
args: {
|
|
71
|
+
key: "hash",
|
|
72
|
+
expected: type
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
} },
|
|
76
|
+
role: { method(type) {
|
|
77
|
+
return this.$_addRule({
|
|
78
|
+
name: "type",
|
|
79
|
+
args: {
|
|
80
|
+
key: "role",
|
|
81
|
+
expected: type
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
} },
|
|
85
|
+
wallet: {
|
|
86
|
+
method(type) {
|
|
87
|
+
return this.$_addRule({
|
|
88
|
+
name: "wallet",
|
|
89
|
+
args: { type }
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
args: [{
|
|
93
|
+
name: "type",
|
|
94
|
+
ref: true,
|
|
95
|
+
assert: (v) => [
|
|
96
|
+
"arcblock",
|
|
97
|
+
"ethereum",
|
|
98
|
+
"default",
|
|
99
|
+
"eth",
|
|
100
|
+
"passkey"
|
|
101
|
+
].includes(v),
|
|
102
|
+
message: "must be a string",
|
|
103
|
+
normalize: (v) => v.trim()
|
|
104
|
+
}],
|
|
105
|
+
validate(value, helpers, args = {}) {
|
|
106
|
+
const type = toTypeInfo(value);
|
|
107
|
+
const typeStr = toTypeInfoStr(value);
|
|
108
|
+
if (["ethereum", "eth"].includes(args.type) && isEqual(type, DID_TYPE_ETHEREUM) === false) return helpers.error("did.wallet", {
|
|
109
|
+
expected: args.type,
|
|
110
|
+
actual: JSON.stringify(typeStr)
|
|
111
|
+
});
|
|
112
|
+
if (["arcblock", "default"].includes(args.type) && isEqual(type, DID_TYPE_ARCBLOCK) === false) return helpers.error("did.wallet", {
|
|
113
|
+
expected: args.type,
|
|
114
|
+
actual: JSON.stringify(typeStr)
|
|
115
|
+
});
|
|
116
|
+
if (["passkey"].includes(args.type) && isEqual(type, DID_TYPE_PASSKEY) === false) return helpers.error("did.wallet", {
|
|
117
|
+
expected: args.type,
|
|
118
|
+
actual: JSON.stringify(typeStr)
|
|
119
|
+
});
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
prefix: {
|
|
124
|
+
method(str = "") {
|
|
125
|
+
return this.$_addRule({
|
|
126
|
+
name: "prefix",
|
|
127
|
+
args: { str }
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
args: [{
|
|
131
|
+
name: "str",
|
|
132
|
+
ref: true,
|
|
133
|
+
assert: (v) => ["", DID_PREFIX].includes(v),
|
|
134
|
+
message: "must be a string",
|
|
135
|
+
normalize: (v) => v.trim()
|
|
136
|
+
}],
|
|
137
|
+
validate(value, helpers, args = {}) {
|
|
138
|
+
if (args.str && value.startsWith(args.str) === false) return helpers.error("did.prefix", { expected: args.str });
|
|
139
|
+
if (!args.str && toAddress(value) !== value) return helpers.error("did.prefix", { expected: args.str });
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
136
145
|
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { DIDExtension };
|
package/esm/index.d.ts
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { BNSchema } from "./extension/bn.js";
|
|
2
|
+
import { DIDSchema } from "./extension/did.js";
|
|
3
|
+
import BaseJoi, { Root } from "joi";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
interface ExtendedRoot extends Root {
|
|
7
|
+
DID(): DIDSchema;
|
|
8
|
+
BN(): BNSchema;
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
10
|
+
declare const Joi: ExtendedRoot;
|
|
11
|
+
declare const schemas: {
|
|
12
|
+
context: BaseJoi.ObjectSchema<any>;
|
|
13
|
+
tokenInput: BaseJoi.ObjectSchema<any>;
|
|
14
|
+
multiInput: BaseJoi.ArraySchema<any[]>;
|
|
15
|
+
multiSig: BaseJoi.ArraySchema<any[]>;
|
|
16
|
+
foreignToken: BaseJoi.ObjectSchema<any>;
|
|
17
|
+
variableInput: BaseJoi.ObjectSchema<any>;
|
|
18
|
+
nftDisplay: BaseJoi.ObjectSchema<any>;
|
|
19
|
+
nftEndpoint: BaseJoi.ObjectSchema<any>;
|
|
20
|
+
nftIssuer: BaseJoi.ObjectSchema<any>;
|
|
21
|
+
tokenHolder: BaseJoi.AlternativesSchema<any>;
|
|
22
|
+
assetProps: {
|
|
23
|
+
address: DIDSchema;
|
|
24
|
+
moniker: BaseJoi.StringSchema<string>;
|
|
25
|
+
data: BaseJoi.AnySchema<any>;
|
|
26
|
+
readonly: BaseJoi.BooleanSchema<boolean>;
|
|
27
|
+
transferrable: BaseJoi.BooleanSchema<boolean>;
|
|
28
|
+
ttl: BaseJoi.NumberSchema<number>;
|
|
29
|
+
parent: DIDSchema;
|
|
30
|
+
issuer: DIDSchema;
|
|
31
|
+
endpoint: BaseJoi.ObjectSchema<any>;
|
|
32
|
+
display: BaseJoi.ObjectSchema<any>;
|
|
33
|
+
tags: BaseJoi.ArraySchema<any[]>;
|
|
34
|
+
};
|
|
35
|
+
assetSchema: BaseJoi.ObjectSchema<any>;
|
|
36
|
+
factoryProps: {
|
|
37
|
+
address: DIDSchema;
|
|
38
|
+
name: BaseJoi.StringSchema<string>;
|
|
39
|
+
description: BaseJoi.StringSchema<string>;
|
|
40
|
+
settlement: BaseJoi.StringSchema<string>;
|
|
41
|
+
limit: BaseJoi.NumberSchema<number>;
|
|
42
|
+
trustedIssuers: BaseJoi.ArraySchema<any[]>;
|
|
43
|
+
data: BaseJoi.AnySchema<any>;
|
|
44
|
+
display: BaseJoi.ObjectSchema<any>;
|
|
45
|
+
input: BaseJoi.ObjectSchema<any>;
|
|
46
|
+
output: BaseJoi.ObjectSchema<any>;
|
|
47
|
+
hooks: BaseJoi.ArraySchema<any[]>;
|
|
48
|
+
};
|
|
49
|
+
factorySchema: BaseJoi.ObjectSchema<any>;
|
|
48
50
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
declare const patterns: {
|
|
52
|
+
txHash: RegExp;
|
|
51
53
|
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ExtendedRoot, Joi, patterns, schemas };
|
package/esm/index.js
CHANGED
|
@@ -1,133 +1,139 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { BNExtension } from "./extension/bn.js";
|
|
2
|
+
import { DIDExtension } from "./extension/did.js";
|
|
3
|
+
import BaseJoi from "joi";
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
const Joi = BaseJoi.extend(DIDExtension).extend(BNExtension);
|
|
5
7
|
const txHash = /^(0x)?([A-Fa-f0-9]{64})$/;
|
|
6
8
|
const context = Joi.object({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
genesisTime: Joi.date().iso().required().raw(),
|
|
10
|
+
genesisTx: Joi.string().regex(txHash).required().allow(""),
|
|
11
|
+
renaissanceTime: Joi.date().iso().required().raw(),
|
|
12
|
+
renaissanceTx: Joi.string().regex(txHash).required().allow("")
|
|
11
13
|
});
|
|
12
14
|
const tokenInput = Joi.object({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
address: Joi.DID().prefix().role("ROLE_TOKEN").required(),
|
|
16
|
+
value: Joi.BN().min(0).required()
|
|
15
17
|
});
|
|
16
18
|
const variableInput = Joi.object({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
name: Joi.string().min(1).max(256).required(),
|
|
20
|
+
value: Joi.string().min(1).max(1024).required(),
|
|
21
|
+
description: Joi.string().min(1).max(256).optional().allow(""),
|
|
22
|
+
required: Joi.boolean().optional().default(false)
|
|
21
23
|
});
|
|
22
|
-
const tokenHolder = Joi.alternatives().try(Joi.DID().prefix().role(
|
|
24
|
+
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"));
|
|
23
25
|
const multiInput = Joi.array().items(Joi.object({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
owner: tokenHolder.required(),
|
|
27
|
+
tokensList: Joi.array().items(tokenInput).default([]),
|
|
28
|
+
assetsList: Joi.array().items(Joi.DID().prefix().role("ROLE_ASSET")).default([])
|
|
27
29
|
}));
|
|
28
30
|
const multiSig = Joi.array().items({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
signer: Joi.DID().prefix().required(),
|
|
32
|
+
pk: Joi.any().required(),
|
|
33
|
+
signature: Joi.any().required(),
|
|
34
|
+
delegator: Joi.DID().prefix().valid("").optional(),
|
|
35
|
+
data: Joi.any().optional()
|
|
34
36
|
});
|
|
35
37
|
const foreignToken = Joi.object({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
type: Joi.string().min(1).max(32).required(),
|
|
39
|
+
contractAddress: Joi.DID().prefix().wallet("ethereum").required(),
|
|
40
|
+
chainType: Joi.string().min(1).max(32).required(),
|
|
41
|
+
chainName: Joi.string().min(1).max(32).required(),
|
|
42
|
+
chainId: Joi.number().positive().required()
|
|
41
43
|
});
|
|
42
44
|
const nftDisplay = Joi.object({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
type: Joi.string().valid("svg", "url", "uri").required(),
|
|
46
|
+
content: Joi.string().when("type", {
|
|
47
|
+
is: "uri",
|
|
48
|
+
then: Joi.string().max(20480).dataUri().required()
|
|
49
|
+
}).when("type", {
|
|
50
|
+
is: "url",
|
|
51
|
+
then: Joi.string().max(2048).uri({ scheme: ["http", "https"] }).required()
|
|
52
|
+
})
|
|
47
53
|
});
|
|
48
54
|
const nftEndpoint = Joi.object({
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
id: Joi.string().max(2048).uri({ scheme: ["http", "https"] }).required(),
|
|
56
|
+
scope: Joi.string().valid("public", "private").default("public")
|
|
51
57
|
});
|
|
52
58
|
const nftIssuer = Joi.object({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
id: Joi.DID().prefix().required(),
|
|
60
|
+
pk: Joi.string().required(),
|
|
61
|
+
name: Joi.string().min(1).max(256).required()
|
|
56
62
|
});
|
|
57
63
|
const assetProps = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
address: Joi.DID().prefix().role("ROLE_ASSET").required(),
|
|
65
|
+
moniker: Joi.string().min(2).max(255).required(),
|
|
66
|
+
data: Joi.any().required(),
|
|
67
|
+
readonly: Joi.boolean().default(false),
|
|
68
|
+
transferrable: Joi.boolean().default(false),
|
|
69
|
+
ttl: Joi.number().min(0).default(0),
|
|
70
|
+
parent: Joi.DID().prefix().optional().allow(""),
|
|
71
|
+
issuer: Joi.DID().prefix().optional().allow(""),
|
|
72
|
+
endpoint: nftEndpoint.optional().allow(null).default(null),
|
|
73
|
+
display: nftDisplay.optional().allow(null).default(null),
|
|
74
|
+
tags: Joi.array().items(Joi.string().min(1).max(64)).max(4).optional()
|
|
69
75
|
};
|
|
70
76
|
const factoryProps = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
.items(Joi.object({
|
|
108
|
-
name: Joi.string().valid('mint', 'postMint', 'preMint').required(),
|
|
109
|
-
type: Joi.string().valid('url', 'contract').required(),
|
|
110
|
-
hook: Joi.string().min(1).max(4096).required(), // due to amazon qldb limit, 32 transfers
|
|
111
|
-
compiled: Joi.array().items(Joi.object()).optional(),
|
|
112
|
-
}))
|
|
113
|
-
.optional(),
|
|
77
|
+
address: Joi.DID().prefix().role("ROLE_FACTORY").required(),
|
|
78
|
+
name: Joi.string().min(2).max(255).required(),
|
|
79
|
+
description: Joi.string().min(2).max(255).required(),
|
|
80
|
+
settlement: Joi.string().valid("instant", "periodic").default("instant"),
|
|
81
|
+
limit: Joi.number().integer().min(0).default(0),
|
|
82
|
+
trustedIssuers: Joi.array().items(Joi.DID().prefix()).max(8).optional(),
|
|
83
|
+
data: Joi.any().optional().allow(null).default(null),
|
|
84
|
+
display: nftDisplay.optional().allow(null).default(null),
|
|
85
|
+
input: Joi.object({
|
|
86
|
+
value: Joi.BN().positive().min("0").default("0"),
|
|
87
|
+
tokens: Joi.array().items(tokenInput).max(8).optional(),
|
|
88
|
+
assets: Joi.array().items(Joi.alternatives().try(Joi.DID().prefix().role("ROLE_ASSET"), Joi.DID().prefix().role("ROLE_FACTORY"))).max(8).optional(),
|
|
89
|
+
variables: Joi.array().items(Joi.object({
|
|
90
|
+
name: Joi.string().min(1).max(255).required(),
|
|
91
|
+
description: Joi.string().max(255).optional().allow(""),
|
|
92
|
+
required: Joi.boolean().required()
|
|
93
|
+
})).optional()
|
|
94
|
+
}),
|
|
95
|
+
output: Joi.object({
|
|
96
|
+
moniker: Joi.string().min(2).max(255).required(),
|
|
97
|
+
data: Joi.any().required(),
|
|
98
|
+
readonly: Joi.boolean().default(false),
|
|
99
|
+
transferrable: Joi.boolean().default(false),
|
|
100
|
+
ttl: Joi.number().min(0).default(0),
|
|
101
|
+
parent: Joi.string().max(255).required(),
|
|
102
|
+
issuer: Joi.string().max(255).required(),
|
|
103
|
+
endpoint: nftEndpoint.optional(),
|
|
104
|
+
display: nftDisplay.optional(),
|
|
105
|
+
tags: Joi.array().items(Joi.string().min(1).max(64)).max(4).optional()
|
|
106
|
+
}),
|
|
107
|
+
hooks: Joi.array().items(Joi.object({
|
|
108
|
+
name: Joi.string().valid("mint", "postMint", "preMint").required(),
|
|
109
|
+
type: Joi.string().valid("url", "contract").required(),
|
|
110
|
+
hook: Joi.string().min(1).max(4096).required(),
|
|
111
|
+
compiled: Joi.array().items(Joi.object()).optional()
|
|
112
|
+
})).optional()
|
|
114
113
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
114
|
+
const schemas = {
|
|
115
|
+
context,
|
|
116
|
+
tokenInput,
|
|
117
|
+
multiInput,
|
|
118
|
+
multiSig,
|
|
119
|
+
foreignToken,
|
|
120
|
+
variableInput,
|
|
121
|
+
nftDisplay,
|
|
122
|
+
nftEndpoint,
|
|
123
|
+
nftIssuer,
|
|
124
|
+
tokenHolder,
|
|
125
|
+
assetProps,
|
|
126
|
+
assetSchema: Joi.object(assetProps).options({
|
|
127
|
+
stripUnknown: true,
|
|
128
|
+
noDefaults: false
|
|
129
|
+
}),
|
|
130
|
+
factoryProps,
|
|
131
|
+
factorySchema: Joi.object(factoryProps).options({
|
|
132
|
+
stripUnknown: true,
|
|
133
|
+
noDefaults: false
|
|
134
|
+
})
|
|
133
135
|
};
|
|
136
|
+
const patterns = { txHash };
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
export { Joi, patterns, schemas };
|