@ocap/config 1.29.27 → 1.30.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/index.mjs +2 -1
- package/esm/schema.d.mts +71 -2
- package/esm/schema.mjs +74 -69
- package/lib/index.cjs +2 -1
- package/lib/schema.cjs +73 -68
- package/lib/schema.d.cts +71 -2
- package/package.json +6 -6
package/esm/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import default_default from "./default.mjs";
|
|
|
2
2
|
import schema_default from "./schema.mjs";
|
|
3
3
|
import { isValid, toTypeInfoStr } from "@arcblock/did";
|
|
4
4
|
import { toTokenAddress } from "@arcblock/did-util";
|
|
5
|
+
import { vValidate } from "@arcblock/validator";
|
|
5
6
|
import { fromTokenToUnit } from "@ocap/util";
|
|
6
7
|
import flatten from "lodash/flatten.js";
|
|
7
8
|
import merge from "lodash/merge.js";
|
|
@@ -9,7 +10,7 @@ import pick from "lodash/pick.js";
|
|
|
9
10
|
|
|
10
11
|
//#region src/index.ts
|
|
11
12
|
const validate = (config) => {
|
|
12
|
-
const { value, error } = schema_default
|
|
13
|
+
const { value, error } = vValidate(schema_default, config);
|
|
13
14
|
if (error) throw new Error(`Invalid config: ${error.details.map((x) => x.message).join(", ")}`);
|
|
14
15
|
const { vaults, transaction, accounts } = value;
|
|
15
16
|
if (flatten(Object.values(vaults)).some((a) => !accounts.find((x) => x.address === a))) throw new Error("Invalid config: vault address does not exist in accounts");
|
package/esm/schema.d.mts
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { v } from "@arcblock/validator";
|
|
2
2
|
|
|
3
3
|
//#region src/schema.d.ts
|
|
4
|
-
declare const configSchema:
|
|
4
|
+
declare const configSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
5
|
+
readonly chainId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
6
|
+
readonly version: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
7
|
+
readonly transaction: v.OptionalSchema<v.ObjectSchema<{
|
|
8
|
+
readonly maxAssetSize: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
9
|
+
readonly maxListSize: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
10
|
+
readonly maxMultisig: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
11
|
+
readonly maxTxSize: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.CheckAction<number, "Must be > 0">]>, undefined>;
|
|
12
|
+
readonly delegate: v.ObjectSchema<{
|
|
13
|
+
readonly deltaInterval: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>, undefined>;
|
|
14
|
+
readonly typeUrls: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
readonly supportedTxs: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
17
|
+
readonly multiSignV2Txs: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
18
|
+
readonly txFee: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
19
|
+
readonly txGas: v.OptionalSchema<v.ObjectSchema<{
|
|
20
|
+
readonly price: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
21
|
+
readonly createState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
22
|
+
readonly updateState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
23
|
+
readonly dataStorage: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
24
|
+
readonly minStake: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
25
|
+
readonly maxStake: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
26
|
+
readonly stakeLockPeriod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
27
|
+
}, undefined>, undefined>;
|
|
28
|
+
readonly txStake: v.OptionalSchema<v.ObjectSchema<{
|
|
29
|
+
readonly createToken: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
30
|
+
readonly createCreditToken: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
31
|
+
readonly createTokenLockPeriod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
32
|
+
}, undefined>, undefined>;
|
|
33
|
+
}, undefined>, any>;
|
|
34
|
+
readonly moderator: v.ObjectSchema<{
|
|
35
|
+
address: any;
|
|
36
|
+
pk: v.StringSchema<undefined>;
|
|
37
|
+
balance: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
38
|
+
moniker: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
39
|
+
}, undefined>;
|
|
40
|
+
readonly accounts: v.ArraySchema<v.ObjectSchema<{
|
|
41
|
+
address: any;
|
|
42
|
+
pk: v.StringSchema<undefined>;
|
|
43
|
+
balance: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
44
|
+
moniker: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
45
|
+
}, undefined>, undefined>;
|
|
46
|
+
readonly vaults: v.OptionalSchema<v.ObjectSchema<{
|
|
47
|
+
readonly slashedStake: any;
|
|
48
|
+
readonly txFee: v.OptionalSchema<any, undefined>;
|
|
49
|
+
readonly txFees: v.OptionalSchema<v.ArraySchema<any, undefined>, undefined>;
|
|
50
|
+
readonly txGas: v.OptionalSchema<v.ArraySchema<any, undefined>, undefined>;
|
|
51
|
+
}, undefined>, any>;
|
|
52
|
+
readonly token: v.OptionalSchema<v.ObjectSchema<{
|
|
53
|
+
readonly name: v.StringSchema<undefined>;
|
|
54
|
+
readonly description: v.StringSchema<undefined>;
|
|
55
|
+
readonly symbol: v.StringSchema<undefined>;
|
|
56
|
+
readonly unit: v.StringSchema<undefined>;
|
|
57
|
+
readonly decimal: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
58
|
+
readonly icon: v.StringSchema<undefined>;
|
|
59
|
+
readonly initialSupply: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
60
|
+
readonly totalSupply: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
61
|
+
readonly inflationRate: v.NumberSchema<undefined>;
|
|
62
|
+
readonly website: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.LiteralSchema<"", undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 256, undefined>, v.CheckAction<string, "Must be HTTPS URL">]>], undefined>, undefined>, undefined>;
|
|
63
|
+
readonly metadata: v.OptionalSchema<v.NullableSchema<v.AnySchema, undefined>, undefined>;
|
|
64
|
+
readonly foreignToken: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
65
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 32, undefined>]>;
|
|
66
|
+
readonly contractAddress: v.StringSchema<undefined>;
|
|
67
|
+
readonly chainType: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 32, undefined>]>;
|
|
68
|
+
readonly chainName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 32, undefined>]>;
|
|
69
|
+
readonly chainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
70
|
+
}, undefined>, undefined>, undefined>;
|
|
71
|
+
}, undefined>, any>;
|
|
72
|
+
readonly reservedSymbols: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
73
|
+
}, undefined>, any]>;
|
|
5
74
|
//#endregion
|
|
6
75
|
export { configSchema as default };
|
package/esm/schema.mjs
CHANGED
|
@@ -1,76 +1,81 @@
|
|
|
1
1
|
import default_default from "./default.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { v, vDID, vStripUnknown } from "@arcblock/validator";
|
|
3
3
|
|
|
4
4
|
//#region src/schema.ts
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const isHttpsUrl = (s) => {
|
|
6
|
+
try {
|
|
7
|
+
return new URL(s).protocol === "https:";
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
10
11
|
};
|
|
11
|
-
const
|
|
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
|
-
|
|
12
|
+
const txKeyPattern = v.pipe(v.string(), v.regex(/^(default|fg:t:[_a-z0-9]+)$/));
|
|
13
|
+
const accountSchemaEntries = {
|
|
14
|
+
address: vDID({ prefix: true }),
|
|
15
|
+
pk: v.string(),
|
|
16
|
+
balance: v.optional(v.number(), 0),
|
|
17
|
+
moniker: v.optional(v.string())
|
|
18
|
+
};
|
|
19
|
+
const configSchema = v.pipe(v.object({
|
|
20
|
+
chainId: v.pipe(v.string(), v.minLength(1)),
|
|
21
|
+
version: v.pipe(v.string(), v.minLength(1)),
|
|
22
|
+
transaction: v.optional(v.object({
|
|
23
|
+
maxAssetSize: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive")),
|
|
24
|
+
maxListSize: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive")),
|
|
25
|
+
maxMultisig: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive")),
|
|
26
|
+
maxTxSize: v.record(txKeyPattern, v.pipe(v.number(), v.integer(), v.check((n) => n > 0, "Must be > 0"))),
|
|
27
|
+
delegate: v.object({
|
|
28
|
+
deltaInterval: v.optional(v.pipe(v.number(), v.check((n) => n > 0, "Must be positive"))),
|
|
29
|
+
typeUrls: v.optional(v.array(v.string()))
|
|
30
|
+
}),
|
|
31
|
+
supportedTxs: v.pipe(v.array(v.string()), v.minLength(1)),
|
|
32
|
+
multiSignV2Txs: v.pipe(v.array(v.string()), v.minLength(1)),
|
|
33
|
+
txFee: v.record(txKeyPattern, v.pipe(v.number(), v.minValue(0))),
|
|
34
|
+
txGas: v.optional(v.object({
|
|
35
|
+
price: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
36
|
+
createState: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
37
|
+
updateState: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
38
|
+
dataStorage: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
39
|
+
minStake: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
40
|
+
maxStake: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
41
|
+
stakeLockPeriod: v.pipe(v.number(), v.integer(), v.minValue(1))
|
|
42
|
+
})),
|
|
43
|
+
txStake: v.optional(v.object({
|
|
44
|
+
createToken: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
45
|
+
createCreditToken: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
46
|
+
createTokenLockPeriod: v.pipe(v.number(), v.integer(), v.minValue(1))
|
|
47
|
+
}))
|
|
48
|
+
}), default_default.transaction),
|
|
49
|
+
moderator: v.object(accountSchemaEntries),
|
|
50
|
+
accounts: v.array(v.object(accountSchemaEntries)),
|
|
51
|
+
vaults: v.optional(v.object({
|
|
52
|
+
slashedStake: vDID({ prefix: true }),
|
|
53
|
+
txFee: v.optional(vDID({ prefix: true })),
|
|
54
|
+
txFees: v.optional(v.array(vDID({ prefix: true }))),
|
|
55
|
+
txGas: v.optional(v.array(vDID({ prefix: true })))
|
|
56
|
+
}), {}),
|
|
57
|
+
token: v.optional(v.object({
|
|
58
|
+
name: v.string(),
|
|
59
|
+
description: v.string(),
|
|
60
|
+
symbol: v.string(),
|
|
61
|
+
unit: v.string(),
|
|
62
|
+
decimal: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive")),
|
|
63
|
+
icon: v.string(),
|
|
64
|
+
initialSupply: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive")),
|
|
65
|
+
totalSupply: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive")),
|
|
66
|
+
inflationRate: v.number(),
|
|
67
|
+
website: v.optional(v.nullable(v.union([v.literal(""), v.pipe(v.string(), v.maxLength(256), v.check(isHttpsUrl, "Must be HTTPS URL"))]))),
|
|
68
|
+
metadata: v.optional(v.nullable(v.any())),
|
|
69
|
+
foreignToken: v.optional(v.nullable(v.object({
|
|
70
|
+
type: v.pipe(v.string(), v.minLength(1), v.maxLength(32)),
|
|
71
|
+
contractAddress: v.string(),
|
|
72
|
+
chainType: v.pipe(v.string(), v.minLength(1), v.maxLength(32)),
|
|
73
|
+
chainName: v.pipe(v.string(), v.minLength(1), v.maxLength(32)),
|
|
74
|
+
chainId: v.pipe(v.number(), v.check((n) => n > 0, "Must be positive"))
|
|
75
|
+
})))
|
|
76
|
+
}), default_default.token),
|
|
77
|
+
reservedSymbols: v.optional(v.array(v.string()))
|
|
78
|
+
}), vStripUnknown());
|
|
74
79
|
var schema_default = configSchema;
|
|
75
80
|
|
|
76
81
|
//#endregion
|
package/lib/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_default = require('./default.cjs');
|
|
|
3
3
|
const require_schema = require('./schema.cjs');
|
|
4
4
|
let _arcblock_did = require("@arcblock/did");
|
|
5
5
|
let _arcblock_did_util = require("@arcblock/did-util");
|
|
6
|
+
let _arcblock_validator = require("@arcblock/validator");
|
|
6
7
|
let _ocap_util = require("@ocap/util");
|
|
7
8
|
let lodash_flatten = require("lodash/flatten");
|
|
8
9
|
lodash_flatten = require_rolldown_runtime.__toESM(lodash_flatten);
|
|
@@ -13,7 +14,7 @@ lodash_pick = require_rolldown_runtime.__toESM(lodash_pick);
|
|
|
13
14
|
|
|
14
15
|
//#region src/index.ts
|
|
15
16
|
const validate = (config) => {
|
|
16
|
-
const { value, error } = require_schema.default
|
|
17
|
+
const { value, error } = (0, _arcblock_validator.vValidate)(require_schema.default, config);
|
|
17
18
|
if (error) throw new Error(`Invalid config: ${error.details.map((x) => x.message).join(", ")}`);
|
|
18
19
|
const { vaults, transaction, accounts } = value;
|
|
19
20
|
if ((0, lodash_flatten.default)(Object.values(vaults)).some((a) => !accounts.find((x) => x.address === a))) throw new Error("Invalid config: vault address does not exist in accounts");
|
package/lib/schema.cjs
CHANGED
|
@@ -4,75 +4,80 @@ const require_default = require('./default.cjs');
|
|
|
4
4
|
let _arcblock_validator = require("@arcblock/validator");
|
|
5
5
|
|
|
6
6
|
//#region src/schema.ts
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const isHttpsUrl = (s) => {
|
|
8
|
+
try {
|
|
9
|
+
return new URL(s).protocol === "https:";
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
12
13
|
};
|
|
13
|
-
const
|
|
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
|
-
|
|
14
|
+
const txKeyPattern = _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.regex(/^(default|fg:t:[_a-z0-9]+)$/));
|
|
15
|
+
const accountSchemaEntries = {
|
|
16
|
+
address: (0, _arcblock_validator.vDID)({ prefix: true }),
|
|
17
|
+
pk: _arcblock_validator.v.string(),
|
|
18
|
+
balance: _arcblock_validator.v.optional(_arcblock_validator.v.number(), 0),
|
|
19
|
+
moniker: _arcblock_validator.v.optional(_arcblock_validator.v.string())
|
|
20
|
+
};
|
|
21
|
+
const configSchema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
22
|
+
chainId: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.minLength(1)),
|
|
23
|
+
version: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.minLength(1)),
|
|
24
|
+
transaction: _arcblock_validator.v.optional(_arcblock_validator.v.object({
|
|
25
|
+
maxAssetSize: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive")),
|
|
26
|
+
maxListSize: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive")),
|
|
27
|
+
maxMultisig: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive")),
|
|
28
|
+
maxTxSize: _arcblock_validator.v.record(txKeyPattern, _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.check((n) => n > 0, "Must be > 0"))),
|
|
29
|
+
delegate: _arcblock_validator.v.object({
|
|
30
|
+
deltaInterval: _arcblock_validator.v.optional(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive"))),
|
|
31
|
+
typeUrls: _arcblock_validator.v.optional(_arcblock_validator.v.array(_arcblock_validator.v.string()))
|
|
32
|
+
}),
|
|
33
|
+
supportedTxs: _arcblock_validator.v.pipe(_arcblock_validator.v.array(_arcblock_validator.v.string()), _arcblock_validator.v.minLength(1)),
|
|
34
|
+
multiSignV2Txs: _arcblock_validator.v.pipe(_arcblock_validator.v.array(_arcblock_validator.v.string()), _arcblock_validator.v.minLength(1)),
|
|
35
|
+
txFee: _arcblock_validator.v.record(txKeyPattern, _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.minValue(0))),
|
|
36
|
+
txGas: _arcblock_validator.v.optional(_arcblock_validator.v.object({
|
|
37
|
+
price: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0)),
|
|
38
|
+
createState: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
39
|
+
updateState: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
40
|
+
dataStorage: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
41
|
+
minStake: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
42
|
+
maxStake: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
43
|
+
stakeLockPeriod: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1))
|
|
44
|
+
})),
|
|
45
|
+
txStake: _arcblock_validator.v.optional(_arcblock_validator.v.object({
|
|
46
|
+
createToken: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
47
|
+
createCreditToken: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0)),
|
|
48
|
+
createTokenLockPeriod: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1))
|
|
49
|
+
}))
|
|
50
|
+
}), require_default.default.transaction),
|
|
51
|
+
moderator: _arcblock_validator.v.object(accountSchemaEntries),
|
|
52
|
+
accounts: _arcblock_validator.v.array(_arcblock_validator.v.object(accountSchemaEntries)),
|
|
53
|
+
vaults: _arcblock_validator.v.optional(_arcblock_validator.v.object({
|
|
54
|
+
slashedStake: (0, _arcblock_validator.vDID)({ prefix: true }),
|
|
55
|
+
txFee: _arcblock_validator.v.optional((0, _arcblock_validator.vDID)({ prefix: true })),
|
|
56
|
+
txFees: _arcblock_validator.v.optional(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({ prefix: true }))),
|
|
57
|
+
txGas: _arcblock_validator.v.optional(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({ prefix: true })))
|
|
58
|
+
}), {}),
|
|
59
|
+
token: _arcblock_validator.v.optional(_arcblock_validator.v.object({
|
|
60
|
+
name: _arcblock_validator.v.string(),
|
|
61
|
+
description: _arcblock_validator.v.string(),
|
|
62
|
+
symbol: _arcblock_validator.v.string(),
|
|
63
|
+
unit: _arcblock_validator.v.string(),
|
|
64
|
+
decimal: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive")),
|
|
65
|
+
icon: _arcblock_validator.v.string(),
|
|
66
|
+
initialSupply: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive")),
|
|
67
|
+
totalSupply: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive")),
|
|
68
|
+
inflationRate: _arcblock_validator.v.number(),
|
|
69
|
+
website: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.union([_arcblock_validator.v.literal(""), _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.maxLength(256), _arcblock_validator.v.check(isHttpsUrl, "Must be HTTPS URL"))]))),
|
|
70
|
+
metadata: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any())),
|
|
71
|
+
foreignToken: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.object({
|
|
72
|
+
type: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(32)),
|
|
73
|
+
contractAddress: _arcblock_validator.v.string(),
|
|
74
|
+
chainType: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(32)),
|
|
75
|
+
chainName: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(32)),
|
|
76
|
+
chainId: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.check((n) => n > 0, "Must be positive"))
|
|
77
|
+
})))
|
|
78
|
+
}), require_default.default.token),
|
|
79
|
+
reservedSymbols: _arcblock_validator.v.optional(_arcblock_validator.v.array(_arcblock_validator.v.string()))
|
|
80
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
76
81
|
var schema_default = configSchema;
|
|
77
82
|
|
|
78
83
|
//#endregion
|
package/lib/schema.d.cts
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { v } from "@arcblock/validator";
|
|
2
2
|
|
|
3
3
|
//#region src/schema.d.ts
|
|
4
|
-
declare const configSchema:
|
|
4
|
+
declare const configSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
5
|
+
readonly chainId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
6
|
+
readonly version: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
7
|
+
readonly transaction: v.OptionalSchema<v.ObjectSchema<{
|
|
8
|
+
readonly maxAssetSize: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
9
|
+
readonly maxListSize: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
10
|
+
readonly maxMultisig: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
11
|
+
readonly maxTxSize: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.CheckAction<number, "Must be > 0">]>, undefined>;
|
|
12
|
+
readonly delegate: v.ObjectSchema<{
|
|
13
|
+
readonly deltaInterval: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>, undefined>;
|
|
14
|
+
readonly typeUrls: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
readonly supportedTxs: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
17
|
+
readonly multiSignV2Txs: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
18
|
+
readonly txFee: v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
19
|
+
readonly txGas: v.OptionalSchema<v.ObjectSchema<{
|
|
20
|
+
readonly price: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
21
|
+
readonly createState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
22
|
+
readonly updateState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
23
|
+
readonly dataStorage: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
24
|
+
readonly minStake: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
25
|
+
readonly maxStake: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
26
|
+
readonly stakeLockPeriod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
27
|
+
}, undefined>, undefined>;
|
|
28
|
+
readonly txStake: v.OptionalSchema<v.ObjectSchema<{
|
|
29
|
+
readonly createToken: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
30
|
+
readonly createCreditToken: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
31
|
+
readonly createTokenLockPeriod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
32
|
+
}, undefined>, undefined>;
|
|
33
|
+
}, undefined>, any>;
|
|
34
|
+
readonly moderator: v.ObjectSchema<{
|
|
35
|
+
address: any;
|
|
36
|
+
pk: v.StringSchema<undefined>;
|
|
37
|
+
balance: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
38
|
+
moniker: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
39
|
+
}, undefined>;
|
|
40
|
+
readonly accounts: v.ArraySchema<v.ObjectSchema<{
|
|
41
|
+
address: any;
|
|
42
|
+
pk: v.StringSchema<undefined>;
|
|
43
|
+
balance: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
44
|
+
moniker: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
45
|
+
}, undefined>, undefined>;
|
|
46
|
+
readonly vaults: v.OptionalSchema<v.ObjectSchema<{
|
|
47
|
+
readonly slashedStake: any;
|
|
48
|
+
readonly txFee: v.OptionalSchema<any, undefined>;
|
|
49
|
+
readonly txFees: v.OptionalSchema<v.ArraySchema<any, undefined>, undefined>;
|
|
50
|
+
readonly txGas: v.OptionalSchema<v.ArraySchema<any, undefined>, undefined>;
|
|
51
|
+
}, undefined>, any>;
|
|
52
|
+
readonly token: v.OptionalSchema<v.ObjectSchema<{
|
|
53
|
+
readonly name: v.StringSchema<undefined>;
|
|
54
|
+
readonly description: v.StringSchema<undefined>;
|
|
55
|
+
readonly symbol: v.StringSchema<undefined>;
|
|
56
|
+
readonly unit: v.StringSchema<undefined>;
|
|
57
|
+
readonly decimal: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
58
|
+
readonly icon: v.StringSchema<undefined>;
|
|
59
|
+
readonly initialSupply: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
60
|
+
readonly totalSupply: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
61
|
+
readonly inflationRate: v.NumberSchema<undefined>;
|
|
62
|
+
readonly website: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.LiteralSchema<"", undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 256, undefined>, v.CheckAction<string, "Must be HTTPS URL">]>], undefined>, undefined>, undefined>;
|
|
63
|
+
readonly metadata: v.OptionalSchema<v.NullableSchema<v.AnySchema, undefined>, undefined>;
|
|
64
|
+
readonly foreignToken: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
65
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 32, undefined>]>;
|
|
66
|
+
readonly contractAddress: v.StringSchema<undefined>;
|
|
67
|
+
readonly chainType: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 32, undefined>]>;
|
|
68
|
+
readonly chainName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 32, undefined>]>;
|
|
69
|
+
readonly chainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.CheckAction<number, "Must be positive">]>;
|
|
70
|
+
}, undefined>, undefined>, undefined>;
|
|
71
|
+
}, undefined>, any>;
|
|
72
|
+
readonly reservedSymbols: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
73
|
+
}, undefined>, any]>;
|
|
5
74
|
//#endregion
|
|
6
75
|
export { configSchema as default };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.30.1",
|
|
7
7
|
"description": "OCAP config parsing/validation and default",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"devDependencies": {},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@arcblock/did": "1.
|
|
51
|
-
"@arcblock/did-util": "1.
|
|
52
|
-
"@arcblock/validator": "1.
|
|
53
|
-
"@ocap/types": "1.
|
|
54
|
-
"@ocap/util": "1.
|
|
50
|
+
"@arcblock/did": "1.30.1",
|
|
51
|
+
"@arcblock/did-util": "1.30.1",
|
|
52
|
+
"@arcblock/validator": "1.30.1",
|
|
53
|
+
"@ocap/types": "1.30.1",
|
|
54
|
+
"@ocap/util": "1.30.1",
|
|
55
55
|
"lodash": "^4.17.23"
|
|
56
56
|
}
|
|
57
57
|
}
|