@ocap/tx-protocols 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/_virtual/rolldown_runtime.mjs +32 -0
- package/esm/node_modules/bn.js/lib/bn.mjs +2551 -0
- package/esm/node_modules/valibot/dist/index.mjs +663 -0
- package/esm/protocols/account/delegate.mjs +42 -36
- package/esm/protocols/account/migrate.mjs +7 -10
- package/esm/protocols/account/revoke-delegate.mjs +11 -11
- package/esm/protocols/asset/acquire-v2.mjs +19 -13
- package/esm/protocols/asset/acquire-v3.mjs +17 -14
- package/esm/protocols/asset/consume.mjs +9 -9
- package/esm/protocols/asset/create.mjs +2 -1
- package/esm/protocols/asset/mint.mjs +19 -13
- package/esm/protocols/asset/update.mjs +11 -11
- package/esm/protocols/governance/claim-stake.mjs +10 -10
- package/esm/protocols/governance/return-stake.mjs +11 -11
- package/esm/protocols/governance/revoke-stake.mjs +10 -10
- package/esm/protocols/governance/slash-stake.mjs +11 -11
- package/esm/protocols/governance/stake.mjs +16 -16
- package/esm/protocols/rollup/claim-reward.mjs +21 -18
- package/esm/protocols/rollup/close.mjs +16 -13
- package/esm/protocols/rollup/create-block.mjs +25 -22
- package/esm/protocols/rollup/join.mjs +14 -12
- package/esm/protocols/rollup/leave.mjs +12 -11
- package/esm/protocols/rollup/migrate.mjs +15 -12
- package/esm/protocols/rollup/pause.mjs +9 -9
- package/esm/protocols/rollup/resume.mjs +9 -9
- package/esm/protocols/rollup/update.mjs +31 -28
- package/esm/protocols/token/create.mjs +25 -22
- package/esm/protocols/token/deposit-v2.mjs +20 -14
- package/esm/protocols/token/withdraw-v2.mjs +20 -14
- package/esm/protocols/token-factory/burn.mjs +12 -12
- package/esm/protocols/token-factory/create.mjs +45 -37
- package/esm/protocols/token-factory/mint.mjs +13 -12
- package/esm/protocols/token-factory/update.mjs +21 -21
- package/esm/protocols/trade/exchange-v2.mjs +15 -15
- package/esm/protocols/trade/transfer-v2.mjs +12 -12
- package/esm/protocols/trade/transfer-v3.mjs +7 -10
- package/esm/util.d.mts +3 -1
- package/esm/util.mjs +16 -1
- package/lib/_virtual/rolldown_runtime.cjs +2 -0
- package/lib/node_modules/bn.js/lib/bn.cjs +2554 -0
- package/lib/node_modules/valibot/dist/index.cjs +683 -0
- package/lib/protocols/account/delegate.cjs +41 -35
- package/lib/protocols/account/migrate.cjs +6 -9
- package/lib/protocols/account/revoke-delegate.cjs +10 -10
- package/lib/protocols/asset/acquire-v2.cjs +18 -12
- package/lib/protocols/asset/acquire-v3.cjs +16 -13
- package/lib/protocols/asset/consume.cjs +8 -8
- package/lib/protocols/asset/create.cjs +2 -1
- package/lib/protocols/asset/mint.cjs +18 -12
- package/lib/protocols/asset/update.cjs +10 -10
- package/lib/protocols/governance/claim-stake.cjs +9 -9
- package/lib/protocols/governance/return-stake.cjs +10 -10
- package/lib/protocols/governance/revoke-stake.cjs +9 -9
- package/lib/protocols/governance/slash-stake.cjs +10 -10
- package/lib/protocols/governance/stake.cjs +15 -15
- package/lib/protocols/rollup/claim-reward.cjs +20 -17
- package/lib/protocols/rollup/close.cjs +15 -12
- package/lib/protocols/rollup/create-block.cjs +24 -21
- package/lib/protocols/rollup/join.cjs +13 -11
- package/lib/protocols/rollup/leave.cjs +11 -10
- package/lib/protocols/rollup/migrate.cjs +14 -11
- package/lib/protocols/rollup/pause.cjs +8 -8
- package/lib/protocols/rollup/resume.cjs +8 -8
- package/lib/protocols/rollup/update.cjs +29 -27
- package/lib/protocols/token/create.cjs +23 -20
- package/lib/protocols/token/deposit-v2.cjs +19 -13
- package/lib/protocols/token/withdraw-v2.cjs +19 -13
- package/lib/protocols/token-factory/burn.cjs +11 -11
- package/lib/protocols/token-factory/create.cjs +43 -35
- package/lib/protocols/token-factory/mint.cjs +12 -11
- package/lib/protocols/token-factory/update.cjs +19 -19
- package/lib/protocols/trade/exchange-v2.cjs +14 -14
- package/lib/protocols/trade/transfer-v2.cjs +11 -11
- package/lib/protocols/trade/transfer-v3.cjs +6 -9
- package/lib/util.cjs +17 -0
- package/lib/util.d.cts +3 -1
- package/package.json +16 -18
- package/tools/fixtures.ts +2 -1
|
@@ -22,48 +22,54 @@ let _arcblock_validator = require("@arcblock/validator");
|
|
|
22
22
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:delegate");
|
|
23
23
|
const runner = new _ocap_tx_pipeline.Runner("delegate");
|
|
24
24
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
25
|
-
const rateLimit = _arcblock_validator.
|
|
26
|
-
interval: _arcblock_validator.
|
|
27
|
-
anchor: _arcblock_validator.
|
|
25
|
+
const rateLimit = _arcblock_validator.v.object({
|
|
26
|
+
interval: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(1)),
|
|
27
|
+
anchor: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0))), 0)
|
|
28
28
|
});
|
|
29
|
-
const tokenLimit = _arcblock_validator.
|
|
30
|
-
address: _arcblock_validator.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const tokenLimit = _arcblock_validator.v.object({
|
|
30
|
+
address: (0, _arcblock_validator.vDID)({
|
|
31
|
+
prefix: true,
|
|
32
|
+
role: "ROLE_TOKEN"
|
|
33
|
+
}),
|
|
34
|
+
toList: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({ prefix: true })), _arcblock_validator.v.maxLength(32))), []),
|
|
35
|
+
txCount: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0))), 0),
|
|
36
|
+
txAllowance: _arcblock_validator.v.optional(_arcblock_validator.v.nullable((0, _arcblock_validator.vBN)()), "0"),
|
|
37
|
+
totalAllowance: _arcblock_validator.v.optional(_arcblock_validator.v.nullable((0, _arcblock_validator.vBN)()), "0"),
|
|
38
|
+
validUntil: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0))), 0),
|
|
39
|
+
rate: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(rateLimit))
|
|
37
40
|
});
|
|
38
|
-
const assetLimit = _arcblock_validator.
|
|
39
|
-
address: _arcblock_validator.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const assetLimit = _arcblock_validator.v.object({
|
|
42
|
+
address: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({
|
|
43
|
+
prefix: true,
|
|
44
|
+
role: "ROLE_ASSET"
|
|
45
|
+
})), _arcblock_validator.v.maxLength(1024))), []),
|
|
46
|
+
toList: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({ prefix: true })), _arcblock_validator.v.maxLength(32))), []),
|
|
47
|
+
txCount: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0))), 0),
|
|
48
|
+
validUntil: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0))), 0),
|
|
49
|
+
rate: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(rateLimit))
|
|
44
50
|
});
|
|
45
|
-
const schema = _arcblock_validator.
|
|
46
|
-
address: _arcblock_validator.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
52
|
+
address: (0, _arcblock_validator.vDID)({
|
|
53
|
+
prefix: true,
|
|
54
|
+
role: "ROLE_DELEGATION"
|
|
55
|
+
}),
|
|
56
|
+
to: (0, _arcblock_validator.vDID)({ prefix: true }),
|
|
57
|
+
opsList: _arcblock_validator.v.pipe(_arcblock_validator.v.array(_arcblock_validator.v.object({
|
|
58
|
+
typeUrl: _arcblock_validator.v.string(),
|
|
59
|
+
limit: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.object({
|
|
60
|
+
tokensList: _arcblock_validator.v.optional(_arcblock_validator.v.pipe(_arcblock_validator.v.array(tokenLimit), _arcblock_validator.v.maxLength(32)), []),
|
|
61
|
+
assetsList: _arcblock_validator.v.optional(_arcblock_validator.v.pipe(_arcblock_validator.v.array(assetLimit), _arcblock_validator.v.maxLength(32)), [])
|
|
62
|
+
})), {
|
|
54
63
|
tokensList: [],
|
|
55
64
|
assetsList: []
|
|
56
65
|
})
|
|
57
|
-
})).
|
|
58
|
-
denyList: _arcblock_validator.
|
|
59
|
-
validUntil: _arcblock_validator.
|
|
60
|
-
data: _arcblock_validator.
|
|
61
|
-
}).
|
|
62
|
-
stripUnknown: true,
|
|
63
|
-
noDefaults: false
|
|
64
|
-
});
|
|
66
|
+
})), _arcblock_validator.v.minLength(1), _arcblock_validator.v.check((arr) => new Set(arr.map((x) => x.typeUrl)).size === arr.length, "opsList must not contain duplicate typeUrl entries")),
|
|
67
|
+
denyList: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.array(_arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.regex(/^fg:/), _arcblock_validator.v.maxLength(256))), _arcblock_validator.v.maxLength(128), _arcblock_validator.v.check((arr) => new Set(arr).size === arr.length, "denyList must not contain duplicates"))), []),
|
|
68
|
+
validUntil: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0))), 0),
|
|
69
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
70
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
65
71
|
runner.use((context, next) => {
|
|
66
|
-
const { error, value } =
|
|
72
|
+
const { error, value } = (0, _arcblock_validator.vValidate)(schema, context.itx);
|
|
67
73
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
68
74
|
context.formattedItx = (0, _ocap_message.formatMessage)("DelegateTx", context.itx);
|
|
69
75
|
context.validatedItx = value;
|
|
@@ -22,16 +22,13 @@ const { RoleType } = _ocap_mcrypto.types;
|
|
|
22
22
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:migrate");
|
|
23
23
|
const runner = new _ocap_tx_pipeline.Runner("account_migrate");
|
|
24
24
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
25
|
-
const schema = _arcblock_validator.
|
|
26
|
-
address: _arcblock_validator.
|
|
27
|
-
pk: _arcblock_validator.
|
|
28
|
-
data: _arcblock_validator.
|
|
29
|
-
}).
|
|
30
|
-
stripUnknown: true,
|
|
31
|
-
noDefaults: false
|
|
32
|
-
});
|
|
25
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
26
|
+
address: (0, _arcblock_validator.vDID)({ prefix: true }),
|
|
27
|
+
pk: _arcblock_validator.v.any(),
|
|
28
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
29
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
33
30
|
runner.use((context, next) => {
|
|
34
|
-
const { error } =
|
|
31
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, context.itx);
|
|
35
32
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
36
33
|
return next();
|
|
37
34
|
});
|
|
@@ -19,17 +19,17 @@ let _arcblock_validator = require("@arcblock/validator");
|
|
|
19
19
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:delegate");
|
|
20
20
|
const runner = new _ocap_tx_pipeline.Runner("revoke_delegate");
|
|
21
21
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
22
|
-
const schema = _arcblock_validator.
|
|
23
|
-
address: _arcblock_validator.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
22
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
23
|
+
address: (0, _arcblock_validator.vDID)({
|
|
24
|
+
prefix: true,
|
|
25
|
+
role: "ROLE_DELEGATION"
|
|
26
|
+
}),
|
|
27
|
+
to: (0, _arcblock_validator.vDID)({ prefix: true }),
|
|
28
|
+
typeUrlsList: _arcblock_validator.v.pipe(_arcblock_validator.v.array(_arcblock_validator.v.string()), _arcblock_validator.v.minLength(1)),
|
|
29
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
30
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
31
31
|
runner.use((context, next) => {
|
|
32
|
-
const { error } =
|
|
32
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, context.itx);
|
|
33
33
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
34
34
|
return next();
|
|
35
35
|
});
|
|
@@ -25,19 +25,25 @@ const verifyTokenBalance = (0, node_util.promisify)(_ocap_tx_pipeline.pipes.Veri
|
|
|
25
25
|
}));
|
|
26
26
|
const runner = new _ocap_tx_pipeline.Runner("acquire_asset_v2");
|
|
27
27
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
28
|
-
const schema = _arcblock_validator.
|
|
29
|
-
factory: _arcblock_validator.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
29
|
+
factory: (0, _arcblock_validator.vDID)({
|
|
30
|
+
prefix: true,
|
|
31
|
+
role: "ROLE_FACTORY"
|
|
32
|
+
}),
|
|
33
|
+
address: (0, _arcblock_validator.vDID)({
|
|
34
|
+
prefix: true,
|
|
35
|
+
role: "ROLE_ASSET"
|
|
36
|
+
}),
|
|
37
|
+
assetsList: _arcblock_validator.v.optional(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({
|
|
38
|
+
prefix: true,
|
|
39
|
+
role: "ROLE_ASSET"
|
|
40
|
+
})), []),
|
|
41
|
+
variablesList: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.array(_arcblock_validator.schemas.variableInput)), []),
|
|
42
|
+
issuer: _arcblock_validator.schemas.nftIssuer,
|
|
43
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
44
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
39
45
|
runner.use(({ itx }, next) => {
|
|
40
|
-
const { error } =
|
|
46
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
41
47
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
42
48
|
return next();
|
|
43
49
|
});
|
|
@@ -28,20 +28,23 @@ const verifyAssetOwner = (0, node_util.promisify)(_ocap_tx_pipeline.pipes.Verify
|
|
|
28
28
|
ownerKey: "owner"
|
|
29
29
|
}));
|
|
30
30
|
const runner = new _ocap_tx_pipeline.Runner("acquire_asset_v3");
|
|
31
|
-
const schema = _arcblock_validator.
|
|
32
|
-
factory: _arcblock_validator.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
32
|
+
factory: (0, _arcblock_validator.vDID)({
|
|
33
|
+
prefix: true,
|
|
34
|
+
role: "ROLE_FACTORY"
|
|
35
|
+
}),
|
|
36
|
+
address: (0, _arcblock_validator.vDID)({
|
|
37
|
+
prefix: true,
|
|
38
|
+
role: "ROLE_ASSET"
|
|
39
|
+
}),
|
|
40
|
+
inputsList: _arcblock_validator.v.pipe(_arcblock_validator.schemas.multiInput, _arcblock_validator.v.minLength(1)),
|
|
41
|
+
owner: _arcblock_validator.schemas.tokenHolder,
|
|
42
|
+
variablesList: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.array(_arcblock_validator.schemas.variableInput)), []),
|
|
43
|
+
issuer: _arcblock_validator.schemas.nftIssuer,
|
|
44
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
45
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
43
46
|
runner.use(({ itx }, next) => {
|
|
44
|
-
const { error } =
|
|
47
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
45
48
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
46
49
|
return next();
|
|
47
50
|
});
|
|
@@ -12,16 +12,16 @@ let _arcblock_validator = require("@arcblock/validator");
|
|
|
12
12
|
//#region src/protocols/asset/consume.ts
|
|
13
13
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:consume-asset");
|
|
14
14
|
const runner = new _ocap_tx_pipeline.Runner("consume_asset");
|
|
15
|
-
const schema = _arcblock_validator.
|
|
16
|
-
address: _arcblock_validator.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
15
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
16
|
+
address: (0, _arcblock_validator.vDID)({
|
|
17
|
+
prefix: true,
|
|
18
|
+
role: "ROLE_ASSET"
|
|
19
|
+
}),
|
|
20
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
21
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
22
22
|
runner.use((context, next) => {
|
|
23
23
|
const { itx } = context;
|
|
24
|
-
const { error } =
|
|
24
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
25
25
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
26
26
|
return next();
|
|
27
27
|
});
|
|
@@ -13,13 +13,14 @@ let _ocap_message = require("@ocap/message");
|
|
|
13
13
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
14
14
|
let lodash_cloneDeep = require("lodash/cloneDeep");
|
|
15
15
|
lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
|
|
16
|
+
let _arcblock_validator = require("@arcblock/validator");
|
|
16
17
|
|
|
17
18
|
//#region src/protocols/asset/create.ts
|
|
18
19
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:create-asset");
|
|
19
20
|
const runner = new _ocap_tx_pipeline.Runner("create_asset");
|
|
20
21
|
runner.use((context, next) => {
|
|
21
22
|
const itx = (0, _ocap_message.formatMessage)("CreateAssetTx", context.itx);
|
|
22
|
-
const { error } =
|
|
23
|
+
const { error } = (0, _arcblock_validator.vValidate)(_arcblock_validator.schemas.assetSchema, itx);
|
|
23
24
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
24
25
|
return next();
|
|
25
26
|
});
|
|
@@ -17,19 +17,25 @@ let _arcblock_validator = require("@arcblock/validator");
|
|
|
17
17
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:mint-asset");
|
|
18
18
|
const runner = new _ocap_tx_pipeline.Runner("mint_asset");
|
|
19
19
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
20
|
-
const schema = _arcblock_validator.
|
|
21
|
-
factory: _arcblock_validator.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
21
|
+
factory: (0, _arcblock_validator.vDID)({
|
|
22
|
+
prefix: true,
|
|
23
|
+
role: "ROLE_FACTORY"
|
|
24
|
+
}),
|
|
25
|
+
address: (0, _arcblock_validator.vDID)({
|
|
26
|
+
prefix: true,
|
|
27
|
+
role: "ROLE_ASSET"
|
|
28
|
+
}),
|
|
29
|
+
assetsList: _arcblock_validator.v.optional(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({
|
|
30
|
+
prefix: true,
|
|
31
|
+
role: "ROLE_ASSET"
|
|
32
|
+
})), []),
|
|
33
|
+
variablesList: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.array(_arcblock_validator.schemas.variableInput)), []),
|
|
34
|
+
owner: _arcblock_validator.schemas.tokenHolder,
|
|
35
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
36
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
31
37
|
runner.use(({ itx }, next) => {
|
|
32
|
-
const { error } =
|
|
38
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
33
39
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
34
40
|
return next();
|
|
35
41
|
});
|
|
@@ -15,18 +15,18 @@ let deep_diff = require("deep-diff");
|
|
|
15
15
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:update-asset");
|
|
16
16
|
const runner = new _ocap_tx_pipeline.Runner("update_asset");
|
|
17
17
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
18
|
-
const schema = _arcblock_validator.
|
|
19
|
-
address: _arcblock_validator.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
18
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
19
|
+
address: (0, _arcblock_validator.vDID)({
|
|
20
|
+
prefix: true,
|
|
21
|
+
role: "ROLE_ASSET"
|
|
22
|
+
}),
|
|
23
|
+
moniker: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.maxLength(255)))),
|
|
24
|
+
consumed: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.boolean()), false),
|
|
25
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
26
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
27
27
|
runner.use((context, next) => {
|
|
28
28
|
const { itx } = context;
|
|
29
|
-
const { error } =
|
|
29
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
30
30
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
31
31
|
if (!itx.moniker && !itx.data) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "itx.moniker and itx.data can not be empty at the same time"));
|
|
32
32
|
context.newData = require_util.decodeAnySafe(itx.data ?? null);
|
|
@@ -16,16 +16,16 @@ let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr")
|
|
|
16
16
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:claim-stake");
|
|
17
17
|
const runner = new _ocap_tx_pipeline.Runner("claim_stake");
|
|
18
18
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
19
|
-
const schema = _arcblock_validator.
|
|
20
|
-
address: _arcblock_validator.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
19
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
20
|
+
address: (0, _arcblock_validator.vDID)({
|
|
21
|
+
prefix: true,
|
|
22
|
+
role: "ROLE_STAKE"
|
|
23
|
+
}),
|
|
24
|
+
evidence: _arcblock_validator.v.object({ hash: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.regex(_arcblock_validator.patterns.txHash)) }),
|
|
25
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
26
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
27
27
|
runner.use(({ itx }, next) => {
|
|
28
|
-
const { error } =
|
|
28
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
29
29
|
return next(error ? new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`) : void 0);
|
|
30
30
|
});
|
|
31
31
|
runner.use(_ocap_tx_pipeline.pipes.ExtractState({
|
|
@@ -19,17 +19,17 @@ lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
|
|
|
19
19
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:return-stake");
|
|
20
20
|
const runner = new _ocap_tx_pipeline.Runner("return_stake");
|
|
21
21
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
22
|
-
const schema = _arcblock_validator.
|
|
23
|
-
address: _arcblock_validator.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
22
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
23
|
+
address: (0, _arcblock_validator.vDID)({
|
|
24
|
+
prefix: true,
|
|
25
|
+
role: "ROLE_STAKE"
|
|
26
|
+
}),
|
|
27
|
+
message: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.trim(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(256)),
|
|
28
|
+
outputsList: _arcblock_validator.v.pipe(_arcblock_validator.schemas.multiInput, _arcblock_validator.v.minLength(1)),
|
|
29
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
30
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
31
31
|
runner.use(({ itx }, next) => {
|
|
32
|
-
const { error } =
|
|
32
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
33
33
|
return next(error ? new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`) : void 0);
|
|
34
34
|
});
|
|
35
35
|
runner.use(_ocap_tx_pipeline.pipes.VerifyTxInput({
|
|
@@ -19,16 +19,16 @@ lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
|
|
|
19
19
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:revoke-stake");
|
|
20
20
|
const runner = new _ocap_tx_pipeline.Runner("revoke_stake");
|
|
21
21
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
22
|
-
const schema = _arcblock_validator.
|
|
23
|
-
address: _arcblock_validator.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
22
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
23
|
+
address: (0, _arcblock_validator.vDID)({
|
|
24
|
+
prefix: true,
|
|
25
|
+
role: "ROLE_STAKE"
|
|
26
|
+
}),
|
|
27
|
+
outputsList: _arcblock_validator.v.pipe(_arcblock_validator.schemas.multiInput, _arcblock_validator.v.minLength(1)),
|
|
28
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
29
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
30
30
|
runner.use(({ itx }, next) => {
|
|
31
|
-
const { error } =
|
|
31
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
32
32
|
return next(error ? new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`) : void 0);
|
|
33
33
|
});
|
|
34
34
|
runner.use(_ocap_tx_pipeline.pipes.VerifyTxInput({
|
|
@@ -19,17 +19,17 @@ lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
|
|
|
19
19
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:slash-stake");
|
|
20
20
|
const runner = new _ocap_tx_pipeline.Runner("slash_stake");
|
|
21
21
|
runner.use(_ocap_tx_pipeline.pipes.VerifyMultiSig(0));
|
|
22
|
-
const schema = _arcblock_validator.
|
|
23
|
-
address: _arcblock_validator.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
22
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
23
|
+
address: (0, _arcblock_validator.vDID)({
|
|
24
|
+
prefix: true,
|
|
25
|
+
role: "ROLE_STAKE"
|
|
26
|
+
}),
|
|
27
|
+
message: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.trim(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(256)),
|
|
28
|
+
outputsList: _arcblock_validator.v.pipe(_arcblock_validator.schemas.multiInput, _arcblock_validator.v.minLength(1)),
|
|
29
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
30
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
31
31
|
runner.use(({ itx }, next) => {
|
|
32
|
-
const { error } =
|
|
32
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
33
33
|
return next(error ? new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`) : void 0);
|
|
34
34
|
});
|
|
35
35
|
runner.use(_ocap_tx_pipeline.pipes.VerifyTxInput({
|
|
@@ -25,22 +25,22 @@ const verifyAssetOwner = (0, node_util.promisify)(_ocap_tx_pipeline.pipes.Verify
|
|
|
25
25
|
ownerKey: "owner"
|
|
26
26
|
}));
|
|
27
27
|
const runner = new _ocap_tx_pipeline.Runner("stake");
|
|
28
|
-
const schema = _arcblock_validator.
|
|
29
|
-
address: _arcblock_validator.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
28
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
29
|
+
address: (0, _arcblock_validator.vDID)({
|
|
30
|
+
prefix: true,
|
|
31
|
+
role: "ROLE_STAKE"
|
|
32
|
+
}),
|
|
33
|
+
receiver: (0, _arcblock_validator.vDID)({ prefix: true }),
|
|
34
|
+
slashersList: _arcblock_validator.v.optional(_arcblock_validator.v.array((0, _arcblock_validator.vDID)({ prefix: true })), []),
|
|
35
|
+
locked: _arcblock_validator.v.optional(_arcblock_validator.v.boolean(), false),
|
|
36
|
+
inputsList: _arcblock_validator.v.pipe(_arcblock_validator.schemas.multiInput, _arcblock_validator.v.minLength(1)),
|
|
37
|
+
message: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.trim(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(256)),
|
|
38
|
+
revokeWaitingPeriod: _arcblock_validator.v.optional(_arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.minValue(0)), 0),
|
|
39
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any())),
|
|
40
|
+
nonce: _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.trim(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(256))])))
|
|
41
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
42
42
|
runner.use(({ itx }, next) => {
|
|
43
|
-
const { error } =
|
|
43
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
44
44
|
return next(error ? new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`) : void 0);
|
|
45
45
|
});
|
|
46
46
|
runner.use(_ocap_tx_pipeline.pipes.VerifyTxInput({
|
|
@@ -24,20 +24,23 @@ lodash_uniqBy = require_rolldown_runtime.__toESM(lodash_uniqBy);
|
|
|
24
24
|
//#region src/protocols/rollup/claim-reward.ts
|
|
25
25
|
const debug$1 = (0, debug.default)("@ocap/tx-protocols:claim-block-reward");
|
|
26
26
|
const runner = new _ocap_tx_pipeline.Runner("claim_block_reward");
|
|
27
|
-
const schema = _arcblock_validator.
|
|
28
|
-
rollup: _arcblock_validator.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
28
|
+
rollup: (0, _arcblock_validator.vDID)({
|
|
29
|
+
prefix: true,
|
|
30
|
+
role: "ROLE_ROLLUP"
|
|
31
|
+
}),
|
|
32
|
+
blockHeight: _arcblock_validator.v.pipe(_arcblock_validator.v.number(), _arcblock_validator.v.integer(), _arcblock_validator.v.check((n) => n > 0, "Must be > 0")),
|
|
33
|
+
blockHash: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.regex(_arcblock_validator.patterns.txHash)),
|
|
34
|
+
evidence: _arcblock_validator.v.object({ hash: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.regex(_arcblock_validator.patterns.txHash)) }),
|
|
35
|
+
publisher: (0, _arcblock_validator.vDID)({
|
|
36
|
+
prefix: true,
|
|
37
|
+
wallet: "ethereum"
|
|
38
|
+
}),
|
|
39
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
40
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
38
41
|
runner.use((context, next) => {
|
|
39
42
|
const { tx, itx } = context;
|
|
40
|
-
const { error } =
|
|
43
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
41
44
|
if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", error.message));
|
|
42
45
|
if (tx.from !== itx.publisher) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "itx.publisher must be same with tx.from"));
|
|
43
46
|
context.lockerAddress = require_util.getRewardLocker(itx.rollup);
|
|
@@ -192,8 +195,8 @@ runner.use((context, next) => {
|
|
|
192
195
|
const blockSignatures = blockState.signatures;
|
|
193
196
|
const validators = txSignatures.map((s) => s.signer).concat(blockSignatures.map((s) => s.signer));
|
|
194
197
|
const validatorShare = validator.div(new _ocap_util.BN(validators.length));
|
|
195
|
-
validators.forEach((v) => changes.account.push({
|
|
196
|
-
address: v,
|
|
198
|
+
validators.forEach((v$1) => changes.account.push({
|
|
199
|
+
address: v$1,
|
|
197
200
|
delta: validatorShare.toString(10),
|
|
198
201
|
action: "fee"
|
|
199
202
|
}));
|
|
@@ -212,9 +215,9 @@ runner.use((context, next) => {
|
|
|
212
215
|
}, {}),
|
|
213
216
|
rateBase: new _ocap_util.BN(validators.length)
|
|
214
217
|
});
|
|
215
|
-
Object.keys(validatorShares).forEach((v) => changes.account.push({
|
|
216
|
-
address: v,
|
|
217
|
-
delta: validatorShares[v],
|
|
218
|
+
Object.keys(validatorShares).forEach((v$1) => changes.account.push({
|
|
219
|
+
address: v$1,
|
|
220
|
+
delta: validatorShares[v$1],
|
|
218
221
|
action: "fee"
|
|
219
222
|
}));
|
|
220
223
|
}
|
|
@@ -13,20 +13,23 @@ let _arcblock_validator = require("@arcblock/validator");
|
|
|
13
13
|
|
|
14
14
|
//#region src/protocols/rollup/close.ts
|
|
15
15
|
const runner = new _ocap_tx_pipeline.Runner("close_rollup");
|
|
16
|
-
const schema = _arcblock_validator.
|
|
17
|
-
rollup: _arcblock_validator.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
address: _arcblock_validator.Joi.DID().prefix().wallet("ethereum").required(),
|
|
21
|
-
value: _arcblock_validator.Joi.BN().positive().required()
|
|
16
|
+
const schema = _arcblock_validator.v.pipe(_arcblock_validator.v.object({
|
|
17
|
+
rollup: (0, _arcblock_validator.vDID)({
|
|
18
|
+
prefix: true,
|
|
19
|
+
role: "ROLE_ROLLUP"
|
|
22
20
|
}),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
message: _arcblock_validator.v.pipe(_arcblock_validator.v.string(), _arcblock_validator.v.trim(), _arcblock_validator.v.minLength(1), _arcblock_validator.v.maxLength(512)),
|
|
22
|
+
token: _arcblock_validator.v.optional(_arcblock_validator.v.object({
|
|
23
|
+
address: (0, _arcblock_validator.vDID)({
|
|
24
|
+
prefix: true,
|
|
25
|
+
wallet: "ethereum"
|
|
26
|
+
}),
|
|
27
|
+
value: (0, _arcblock_validator.vBN)((0, _arcblock_validator.vBNPositive)())
|
|
28
|
+
})),
|
|
29
|
+
data: _arcblock_validator.v.optional(_arcblock_validator.v.nullable(_arcblock_validator.v.any()))
|
|
30
|
+
}), (0, _arcblock_validator.vStripUnknown)());
|
|
28
31
|
runner.use(({ itx }, next) => {
|
|
29
|
-
const { error } =
|
|
32
|
+
const { error } = (0, _arcblock_validator.vValidate)(schema, itx);
|
|
30
33
|
return next(error ? new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`) : void 0);
|
|
31
34
|
});
|
|
32
35
|
runner.use(_ocap_tx_pipeline.pipes.ExtractState({
|