@ocap/tx-protocols 1.28.9 → 1.29.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/execute.d.mts +53 -0
- package/esm/execute.mjs +225 -0
- package/esm/index.d.mts +95 -0
- package/esm/index.mjs +100 -0
- package/esm/pipes/ensure-cost.d.mts +18 -0
- package/esm/pipes/ensure-cost.mjs +136 -0
- package/esm/pipes/ensure-gas.d.mts +14 -0
- package/esm/pipes/ensure-gas.mjs +38 -0
- package/esm/protocols/account/delegate.d.mts +4 -0
- package/esm/protocols/account/delegate.mjs +195 -0
- package/esm/protocols/account/migrate.d.mts +4 -0
- package/esm/protocols/account/migrate.mjs +130 -0
- package/esm/protocols/account/revoke-delegate.d.mts +4 -0
- package/esm/protocols/account/revoke-delegate.mjs +102 -0
- package/esm/protocols/asset/acquire-v2.d.mts +9 -0
- package/esm/protocols/asset/acquire-v2.mjs +213 -0
- package/esm/protocols/asset/acquire-v3.d.mts +17 -0
- package/esm/protocols/asset/acquire-v3.mjs +265 -0
- package/esm/protocols/asset/calls/transfer-token.d.mts +4 -0
- package/esm/protocols/asset/calls/transfer-token.mjs +36 -0
- package/esm/protocols/asset/calls/transfer.d.mts +4 -0
- package/esm/protocols/asset/calls/transfer.mjs +32 -0
- package/esm/protocols/asset/consume.d.mts +4 -0
- package/esm/protocols/asset/consume.mjs +92 -0
- package/esm/protocols/asset/create.d.mts +4 -0
- package/esm/protocols/asset/create.mjs +136 -0
- package/esm/protocols/asset/mint.d.mts +4 -0
- package/esm/protocols/asset/mint.mjs +156 -0
- package/esm/protocols/asset/pipes/exec-mint-hook.d.mts +24 -0
- package/esm/protocols/asset/pipes/exec-mint-hook.mjs +54 -0
- package/esm/protocols/asset/pipes/extract-factory-tokens.d.mts +21 -0
- package/esm/protocols/asset/pipes/extract-factory-tokens.mjs +22 -0
- package/esm/protocols/asset/pipes/verify-itx-address.d.mts +32 -0
- package/esm/protocols/asset/pipes/verify-itx-address.mjs +56 -0
- package/esm/protocols/asset/pipes/verify-itx-assets.d.mts +18 -0
- package/esm/protocols/asset/pipes/verify-itx-assets.mjs +27 -0
- package/esm/protocols/asset/pipes/verify-itx-variables.d.mts +17 -0
- package/esm/protocols/asset/pipes/verify-itx-variables.mjs +20 -0
- package/esm/protocols/asset/pipes/verify-mint-limit.d.mts +15 -0
- package/esm/protocols/asset/pipes/verify-mint-limit.mjs +14 -0
- package/esm/protocols/asset/update.d.mts +4 -0
- package/esm/protocols/asset/update.mjs +111 -0
- package/esm/protocols/factory/create.d.mts +29 -0
- package/esm/protocols/factory/create.mjs +155 -0
- package/esm/protocols/governance/claim-stake.d.mts +27 -0
- package/esm/protocols/governance/claim-stake.mjs +220 -0
- package/esm/protocols/governance/return-stake.d.mts +27 -0
- package/esm/protocols/governance/return-stake.mjs +211 -0
- package/esm/protocols/governance/revoke-stake.d.mts +27 -0
- package/esm/protocols/governance/revoke-stake.mjs +178 -0
- package/esm/protocols/governance/slash-stake.d.mts +17 -0
- package/esm/protocols/governance/slash-stake.mjs +213 -0
- package/esm/protocols/governance/stake.d.mts +15 -0
- package/esm/protocols/governance/stake.mjs +270 -0
- package/esm/protocols/rollup/claim-reward.d.mts +11 -0
- package/esm/protocols/rollup/claim-reward.mjs +322 -0
- package/esm/protocols/rollup/close.d.mts +4 -0
- package/esm/protocols/rollup/close.mjs +105 -0
- package/esm/protocols/rollup/create-block.d.mts +11 -0
- package/esm/protocols/rollup/create-block.mjs +303 -0
- package/esm/protocols/rollup/create.d.mts +4 -0
- package/esm/protocols/rollup/create.mjs +164 -0
- package/esm/protocols/rollup/join.d.mts +4 -0
- package/esm/protocols/rollup/join.mjs +152 -0
- package/esm/protocols/rollup/leave.d.mts +4 -0
- package/esm/protocols/rollup/leave.mjs +137 -0
- package/esm/protocols/rollup/migrate.d.mts +4 -0
- package/esm/protocols/rollup/migrate.mjs +85 -0
- package/esm/protocols/rollup/pause.d.mts +4 -0
- package/esm/protocols/rollup/pause.mjs +76 -0
- package/esm/protocols/rollup/pipes/ensure-validator.d.mts +6 -0
- package/esm/protocols/rollup/pipes/ensure-validator.mjs +12 -0
- package/esm/protocols/rollup/pipes/verify-evidence.d.mts +15 -0
- package/esm/protocols/rollup/pipes/verify-evidence.mjs +29 -0
- package/esm/protocols/rollup/pipes/verify-signers.d.mts +15 -0
- package/esm/protocols/rollup/pipes/verify-signers.mjs +36 -0
- package/esm/protocols/rollup/pipes/verify-status.d.mts +13 -0
- package/esm/protocols/rollup/pipes/verify-status.mjs +26 -0
- package/esm/protocols/rollup/resume.d.mts +4 -0
- package/esm/protocols/rollup/resume.mjs +79 -0
- package/esm/protocols/rollup/update.d.mts +4 -0
- package/esm/protocols/rollup/update.mjs +111 -0
- package/esm/protocols/token/create.d.mts +4 -0
- package/esm/protocols/token/create.mjs +150 -0
- package/esm/protocols/token/deposit-v2.d.mts +11 -0
- package/esm/protocols/token/deposit-v2.mjs +216 -0
- package/esm/protocols/token/withdraw-v2.d.mts +9 -0
- package/esm/protocols/token/withdraw-v2.mjs +222 -0
- package/esm/protocols/token-factory/burn.d.mts +15 -0
- package/esm/protocols/token-factory/burn.mjs +233 -0
- package/esm/protocols/token-factory/create.d.mts +4 -0
- package/esm/protocols/token-factory/create.mjs +254 -0
- package/esm/protocols/token-factory/mint.d.mts +15 -0
- package/esm/protocols/token-factory/mint.mjs +234 -0
- package/esm/protocols/token-factory/pipes/calc-reserve.d.mts +21 -0
- package/esm/protocols/token-factory/pipes/calc-reserve.mjs +34 -0
- package/esm/protocols/token-factory/pipes/verify-icon.d.mts +14 -0
- package/esm/protocols/token-factory/pipes/verify-icon.mjs +18 -0
- package/esm/protocols/token-factory/pipes/verify-ownership.d.mts +12 -0
- package/esm/protocols/token-factory/pipes/verify-ownership.mjs +63 -0
- package/esm/protocols/token-factory/pipes/verify-url.d.mts +12 -0
- package/esm/protocols/token-factory/pipes/verify-url.mjs +26 -0
- package/esm/protocols/token-factory/update.d.mts +10 -0
- package/esm/protocols/token-factory/update.mjs +152 -0
- package/esm/protocols/trade/exchange-v2.d.mts +9 -0
- package/esm/protocols/trade/exchange-v2.mjs +239 -0
- package/esm/protocols/trade/transfer-v2.d.mts +9 -0
- package/esm/protocols/trade/transfer-v2.mjs +226 -0
- package/esm/protocols/trade/transfer-v3.d.mts +17 -0
- package/esm/protocols/trade/transfer-v3.mjs +270 -0
- package/esm/util.d.mts +141 -0
- package/esm/util.mjs +278 -0
- package/lib/_virtual/rolldown_runtime.cjs +29 -0
- package/lib/execute.cjs +231 -0
- package/lib/execute.d.cts +53 -0
- package/lib/index.cjs +105 -0
- package/lib/index.d.cts +95 -0
- package/lib/pipes/ensure-cost.cjs +141 -0
- package/lib/pipes/ensure-cost.d.cts +18 -0
- package/lib/pipes/ensure-gas.cjs +41 -0
- package/lib/pipes/ensure-gas.d.cts +14 -0
- package/lib/protocols/account/delegate.cjs +201 -0
- package/lib/protocols/account/delegate.d.cts +4 -0
- package/lib/protocols/account/migrate.cjs +135 -0
- package/lib/protocols/account/migrate.d.cts +4 -0
- package/lib/protocols/account/revoke-delegate.cjs +107 -0
- package/lib/protocols/account/revoke-delegate.d.cts +4 -0
- package/lib/protocols/asset/acquire-v2.cjs +216 -0
- package/lib/protocols/asset/acquire-v2.d.cts +9 -0
- package/lib/protocols/asset/acquire-v3.cjs +269 -0
- package/lib/protocols/asset/acquire-v3.d.cts +17 -0
- package/lib/protocols/asset/calls/transfer-token.cjs +40 -0
- package/lib/protocols/asset/calls/transfer-token.d.cts +4 -0
- package/lib/protocols/asset/calls/transfer.cjs +35 -0
- package/lib/protocols/asset/calls/transfer.d.cts +4 -0
- package/lib/protocols/asset/consume.cjs +95 -0
- package/lib/protocols/asset/consume.d.cts +4 -0
- package/lib/protocols/asset/create.cjs +140 -0
- package/lib/protocols/asset/create.d.cts +4 -0
- package/lib/protocols/asset/mint.cjs +159 -0
- package/lib/protocols/asset/mint.d.cts +4 -0
- package/lib/protocols/asset/pipes/exec-mint-hook.cjs +57 -0
- package/lib/protocols/asset/pipes/exec-mint-hook.d.cts +24 -0
- package/lib/protocols/asset/pipes/extract-factory-tokens.cjs +25 -0
- package/lib/protocols/asset/pipes/extract-factory-tokens.d.cts +21 -0
- package/lib/protocols/asset/pipes/verify-itx-address.cjs +59 -0
- package/lib/protocols/asset/pipes/verify-itx-address.d.cts +32 -0
- package/lib/protocols/asset/pipes/verify-itx-assets.cjs +29 -0
- package/lib/protocols/asset/pipes/verify-itx-assets.d.cts +18 -0
- package/lib/protocols/asset/pipes/verify-itx-variables.cjs +22 -0
- package/lib/protocols/asset/pipes/verify-itx-variables.d.cts +17 -0
- package/lib/protocols/asset/pipes/verify-mint-limit.cjs +16 -0
- package/lib/protocols/asset/pipes/verify-mint-limit.d.cts +15 -0
- package/lib/protocols/asset/update.cjs +114 -0
- package/lib/protocols/asset/update.d.cts +4 -0
- package/lib/protocols/factory/create.cjs +161 -0
- package/lib/protocols/factory/create.d.cts +29 -0
- package/lib/protocols/governance/claim-stake.cjs +223 -0
- package/lib/protocols/governance/claim-stake.d.cts +27 -0
- package/lib/protocols/governance/return-stake.cjs +215 -0
- package/lib/protocols/governance/return-stake.d.cts +27 -0
- package/lib/protocols/governance/revoke-stake.cjs +182 -0
- package/lib/protocols/governance/revoke-stake.d.cts +27 -0
- package/lib/protocols/governance/slash-stake.cjs +217 -0
- package/lib/protocols/governance/slash-stake.d.cts +17 -0
- package/lib/protocols/governance/stake.cjs +275 -0
- package/lib/protocols/governance/stake.d.cts +15 -0
- package/lib/protocols/rollup/claim-reward.cjs +328 -0
- package/lib/protocols/rollup/claim-reward.d.cts +11 -0
- package/lib/protocols/rollup/close.cjs +107 -0
- package/lib/protocols/rollup/close.d.cts +4 -0
- package/lib/protocols/rollup/create-block.cjs +309 -0
- package/lib/protocols/rollup/create-block.d.cts +11 -0
- package/lib/protocols/rollup/create.cjs +169 -0
- package/lib/protocols/rollup/create.d.cts +4 -0
- package/lib/protocols/rollup/join.cjs +157 -0
- package/lib/protocols/rollup/join.d.cts +4 -0
- package/lib/protocols/rollup/leave.cjs +141 -0
- package/lib/protocols/rollup/leave.d.cts +4 -0
- package/lib/protocols/rollup/migrate.cjs +87 -0
- package/lib/protocols/rollup/migrate.d.cts +4 -0
- package/lib/protocols/rollup/pause.cjs +78 -0
- package/lib/protocols/rollup/pause.d.cts +4 -0
- package/lib/protocols/rollup/pipes/ensure-validator.cjs +14 -0
- package/lib/protocols/rollup/pipes/ensure-validator.d.cts +6 -0
- package/lib/protocols/rollup/pipes/verify-evidence.cjs +32 -0
- package/lib/protocols/rollup/pipes/verify-evidence.d.cts +15 -0
- package/lib/protocols/rollup/pipes/verify-signers.cjs +39 -0
- package/lib/protocols/rollup/pipes/verify-signers.d.cts +15 -0
- package/lib/protocols/rollup/pipes/verify-status.cjs +28 -0
- package/lib/protocols/rollup/pipes/verify-status.d.cts +13 -0
- package/lib/protocols/rollup/resume.cjs +81 -0
- package/lib/protocols/rollup/resume.d.cts +4 -0
- package/lib/protocols/rollup/update.cjs +114 -0
- package/lib/protocols/rollup/update.d.cts +4 -0
- package/lib/protocols/token/create.cjs +156 -0
- package/lib/protocols/token/create.d.cts +4 -0
- package/lib/protocols/token/deposit-v2.cjs +219 -0
- package/lib/protocols/token/deposit-v2.d.cts +11 -0
- package/lib/protocols/token/withdraw-v2.cjs +225 -0
- package/lib/protocols/token/withdraw-v2.d.cts +9 -0
- package/lib/protocols/token-factory/burn.cjs +236 -0
- package/lib/protocols/token-factory/burn.d.cts +15 -0
- package/lib/protocols/token-factory/create.cjs +260 -0
- package/lib/protocols/token-factory/create.d.cts +4 -0
- package/lib/protocols/token-factory/mint.cjs +237 -0
- package/lib/protocols/token-factory/mint.d.cts +15 -0
- package/lib/protocols/token-factory/pipes/calc-reserve.cjs +38 -0
- package/lib/protocols/token-factory/pipes/calc-reserve.d.cts +21 -0
- package/lib/protocols/token-factory/pipes/verify-icon.cjs +22 -0
- package/lib/protocols/token-factory/pipes/verify-icon.d.cts +14 -0
- package/lib/protocols/token-factory/pipes/verify-ownership.cjs +66 -0
- package/lib/protocols/token-factory/pipes/verify-ownership.d.cts +12 -0
- package/lib/protocols/token-factory/pipes/verify-url.cjs +29 -0
- package/lib/protocols/token-factory/pipes/verify-url.d.cts +12 -0
- package/lib/protocols/token-factory/update.cjs +155 -0
- package/lib/protocols/token-factory/update.d.cts +10 -0
- package/lib/protocols/trade/exchange-v2.cjs +243 -0
- package/lib/protocols/trade/exchange-v2.d.cts +9 -0
- package/lib/protocols/trade/transfer-v2.cjs +229 -0
- package/lib/protocols/trade/transfer-v2.d.cts +9 -0
- package/lib/protocols/trade/transfer-v3.cjs +274 -0
- package/lib/protocols/trade/transfer-v3.d.cts +17 -0
- package/lib/util.cjs +296 -0
- package/lib/util.d.cts +141 -0
- package/package.json +49 -22
- package/tools/fixtures.ts +564 -0
- package/lib/execute.js +0 -254
- package/lib/index.js +0 -117
- package/lib/pipes/ensure-cost.js +0 -193
- package/lib/pipes/ensure-gas.js +0 -48
- package/lib/protocols/account/delegate.js +0 -223
- package/lib/protocols/account/migrate.js +0 -153
- package/lib/protocols/account/revoke-delegate.js +0 -110
- package/lib/protocols/asset/acquire-v2.js +0 -262
- package/lib/protocols/asset/acquire-v3.js +0 -330
- package/lib/protocols/asset/calls/README.md +0 -5
- package/lib/protocols/asset/calls/transfer-token.js +0 -36
- package/lib/protocols/asset/calls/transfer.js +0 -28
- package/lib/protocols/asset/consume.js +0 -105
- package/lib/protocols/asset/create.js +0 -151
- package/lib/protocols/asset/mint.js +0 -199
- package/lib/protocols/asset/pipes/exec-mint-hook.js +0 -62
- package/lib/protocols/asset/pipes/extract-factory-tokens.js +0 -18
- package/lib/protocols/asset/pipes/verify-itx-address.js +0 -54
- package/lib/protocols/asset/pipes/verify-itx-assets.js +0 -51
- package/lib/protocols/asset/pipes/verify-itx-variables.js +0 -26
- package/lib/protocols/asset/pipes/verify-mint-limit.js +0 -13
- package/lib/protocols/asset/update.js +0 -131
- package/lib/protocols/factory/create.js +0 -191
- package/lib/protocols/governance/claim-stake.js +0 -266
- package/lib/protocols/governance/return-stake.js +0 -248
- package/lib/protocols/governance/revoke-stake.js +0 -172
- package/lib/protocols/governance/slash-stake.js +0 -271
- package/lib/protocols/governance/stake.js +0 -303
- package/lib/protocols/rollup/claim-reward.js +0 -342
- package/lib/protocols/rollup/close.js +0 -104
- package/lib/protocols/rollup/create-block.js +0 -413
- package/lib/protocols/rollup/create.js +0 -197
- package/lib/protocols/rollup/join.js +0 -182
- package/lib/protocols/rollup/leave.js +0 -145
- package/lib/protocols/rollup/migrate.js +0 -85
- package/lib/protocols/rollup/pause.js +0 -75
- package/lib/protocols/rollup/pipes/ensure-validator.js +0 -12
- package/lib/protocols/rollup/pipes/verify-evidence.js +0 -37
- package/lib/protocols/rollup/pipes/verify-signers.js +0 -87
- package/lib/protocols/rollup/pipes/verify-status.js +0 -30
- package/lib/protocols/rollup/resume.js +0 -75
- package/lib/protocols/rollup/update.js +0 -122
- package/lib/protocols/token/create.js +0 -199
- package/lib/protocols/token/deposit-v2.js +0 -290
- package/lib/protocols/token/withdraw-v2.js +0 -305
- package/lib/protocols/token-factory/burn.js +0 -371
- package/lib/protocols/token-factory/create.js +0 -342
- package/lib/protocols/token-factory/mint.js +0 -385
- package/lib/protocols/token-factory/pipes/calc-reserve.js +0 -37
- package/lib/protocols/token-factory/pipes/verify-icon.js +0 -27
- package/lib/protocols/token-factory/pipes/verify-ownership.js +0 -93
- package/lib/protocols/token-factory/pipes/verify-url.js +0 -32
- package/lib/protocols/token-factory/update.js +0 -208
- package/lib/protocols/trade/exchange-v2.js +0 -239
- package/lib/protocols/trade/transfer-v2.js +0 -233
- package/lib/protocols/trade/transfer-v3.js +0 -333
- package/lib/util.js +0 -442
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
2
|
-
const { Joi, schemas } = require('@arcblock/validator');
|
|
3
|
-
const { BN, fromUnitToToken } = require('@ocap/util');
|
|
4
|
-
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
5
|
-
const { account, tokenFactory, token } = require('@ocap/state');
|
|
6
|
-
const pick = require('lodash/pick');
|
|
7
|
-
|
|
8
|
-
const EnsureTxGas = require('../../pipes/ensure-gas');
|
|
9
|
-
const EnsureTxCost = require('../../pipes/ensure-cost');
|
|
10
|
-
const CalcReserve = require('./pipes/calc-reserve');
|
|
11
|
-
const { applyTokenChange, applyTokenUpdates } = require('../../util');
|
|
12
|
-
|
|
13
|
-
const runner = new Runner();
|
|
14
|
-
|
|
15
|
-
const schema = Joi.object({
|
|
16
|
-
tokenFactory: Joi.DID().prefix().role('ROLE_TOKEN_FACTORY').required(),
|
|
17
|
-
receiver: schemas.tokenHolder.required(),
|
|
18
|
-
amount: Joi.BN().greater(0).required(),
|
|
19
|
-
data: Joi.any().optional().allow(null),
|
|
20
|
-
inputsList: schemas.multiInput.optional(),
|
|
21
|
-
}).options({ stripUnknown: true, noDefaults: false });
|
|
22
|
-
|
|
23
|
-
// verify itx
|
|
24
|
-
runner.use(({ itx }, next) => {
|
|
25
|
-
const { error } = schema.validate(itx);
|
|
26
|
-
if (error) {
|
|
27
|
-
return next(new Error('INVALID_TX', `Invalid itx: ${error.message}`));
|
|
28
|
-
}
|
|
29
|
-
return next();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// ensure token factory state
|
|
33
|
-
runner.use(
|
|
34
|
-
pipes.ExtractState({
|
|
35
|
-
from: 'itx.tokenFactory',
|
|
36
|
-
to: 'tokenFactoryState',
|
|
37
|
-
status: 'INVALID_TOKEN_FACTORY',
|
|
38
|
-
table: 'tokenFactory',
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// ensure token state
|
|
43
|
-
runner.use(
|
|
44
|
-
pipes.ExtractState({
|
|
45
|
-
from: 'tokenFactoryState.tokenAddress',
|
|
46
|
-
to: 'tokenState',
|
|
47
|
-
status: 'INVALID_TOKEN',
|
|
48
|
-
table: 'token',
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
runner.use(
|
|
53
|
-
pipes.VerifyTxInput({
|
|
54
|
-
fieldKey: 'itx.inputs',
|
|
55
|
-
inputsKey: 'inputs',
|
|
56
|
-
sendersKey: 'senders',
|
|
57
|
-
tokensKey: 'tokens',
|
|
58
|
-
assetsKey: null,
|
|
59
|
-
}),
|
|
60
|
-
{ shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// verify itx size: set hard limit here because more inputs leads to longer tx execute time
|
|
64
|
-
runner.use(pipes.VerifyListSize({ listKey: ['inputs', 'senders', 'tokens', 'assets'] }), {
|
|
65
|
-
shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// verify multi sig
|
|
69
|
-
runner.use(pipes.VerifyMultiSigV2({ signersKey: 'senders' }), {
|
|
70
|
-
shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// verify inputs token
|
|
74
|
-
runner.use(
|
|
75
|
-
(context, next) => {
|
|
76
|
-
const { tokenFactoryState, inputs } = context;
|
|
77
|
-
|
|
78
|
-
const isAccepted = inputs.every(
|
|
79
|
-
(input) =>
|
|
80
|
-
input.tokensList.length &&
|
|
81
|
-
input.tokensList.every((x) => x.address === tokenFactoryState.reserveAddress) &&
|
|
82
|
-
!input.assetsList.length
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
if (!isAccepted) {
|
|
86
|
-
return next(new Error('INVALID_TX', `Inputs only accept ${tokenFactoryState.reserveAddress}`));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return next();
|
|
90
|
-
},
|
|
91
|
-
{ shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
// ensure sender
|
|
95
|
-
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
96
|
-
runner.use(
|
|
97
|
-
pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' }),
|
|
98
|
-
{ shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
|
|
99
|
-
);
|
|
100
|
-
runner.use(
|
|
101
|
-
pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }),
|
|
102
|
-
{ shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
// ensure receiver
|
|
106
|
-
runner.use(pipes.ExtractState({ from: 'itx.receiver', to: 'receiverState', status: 'OK', table: 'account' }));
|
|
107
|
-
runner.use(pipes.VerifyAccountMigration({ stateKey: 'receiverState', addressKey: 'itx.receiver' }));
|
|
108
|
-
|
|
109
|
-
// verify blocked
|
|
110
|
-
runner.use(pipes.VerifyBlocked({ stateKeys: ['signerStates', 'receiverState'] }));
|
|
111
|
-
|
|
112
|
-
// ensure owner
|
|
113
|
-
runner.use(
|
|
114
|
-
pipes.ExtractState({
|
|
115
|
-
from: 'tokenFactoryState.owner',
|
|
116
|
-
to: 'ownerState',
|
|
117
|
-
status: 'INVALID_OWNER_STATE',
|
|
118
|
-
table: 'account',
|
|
119
|
-
})
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
// verify minters restriction
|
|
123
|
-
runner.use(
|
|
124
|
-
pipes.verifyTokenAccess({
|
|
125
|
-
statesKey: 'tokenState',
|
|
126
|
-
listFieldKey: 'minters',
|
|
127
|
-
accountKeys: ['senderState'],
|
|
128
|
-
errorMessage: 'Account {address} is not allowed to mint token {tokenAddress}',
|
|
129
|
-
})
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
// calculate reserve amount
|
|
133
|
-
runner.use(
|
|
134
|
-
CalcReserve({
|
|
135
|
-
tokenFactoryKey: 'tokenFactoryState',
|
|
136
|
-
tokenStateKey: 'tokenState',
|
|
137
|
-
reserveKey: 'reserveAmount',
|
|
138
|
-
amountKey: 'itx.amount',
|
|
139
|
-
}),
|
|
140
|
-
{ shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
// verify max supply
|
|
144
|
-
runner.use((context, next) => {
|
|
145
|
-
const { tokenState, itx } = context;
|
|
146
|
-
|
|
147
|
-
if (tokenState.maxTotalSupply) {
|
|
148
|
-
const availableSupply = new BN(tokenState.maxTotalSupply).sub(new BN(tokenState.totalSupply));
|
|
149
|
-
|
|
150
|
-
if (new BN(itx.amount).gt(availableSupply)) {
|
|
151
|
-
return next(
|
|
152
|
-
new Error(
|
|
153
|
-
'INVALID_TOKEN',
|
|
154
|
-
`Maximum mintable tokens are ${fromUnitToToken(availableSupply, tokenState.decimal)} ${tokenState.symbol}`
|
|
155
|
-
)
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
next();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// verify slippage
|
|
164
|
-
runner.use(
|
|
165
|
-
(context, next) => {
|
|
166
|
-
const { reserveAmount, reserveFee, inputs, tokenFactoryState } = context;
|
|
167
|
-
|
|
168
|
-
const maxReserve = inputs.reduce((total, input) => {
|
|
169
|
-
const reserveToken = input.tokensList.find((x) => x.address === tokenFactoryState.reserveAddress);
|
|
170
|
-
if (reserveToken) {
|
|
171
|
-
return total.add(new BN(reserveToken.value));
|
|
172
|
-
}
|
|
173
|
-
return total;
|
|
174
|
-
}, new BN(0));
|
|
175
|
-
|
|
176
|
-
const actual = new BN(reserveAmount).add(new BN(reserveFee || '0'));
|
|
177
|
-
if (actual.gt(maxReserve)) {
|
|
178
|
-
return next(
|
|
179
|
-
new Error(
|
|
180
|
-
'SLIPPAGE_EXCEEDED',
|
|
181
|
-
`Mint token failed due to price movement. Expected maximum: ${fromUnitToToken(maxReserve)}, actual: ${fromUnitToToken(actual)}. Try increasing your inputs.`
|
|
182
|
-
)
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
next();
|
|
187
|
-
},
|
|
188
|
-
{ shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
// verify balance
|
|
192
|
-
runner.use(pipes.ExtractState({ from: 'tokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
|
|
193
|
-
runner.use(pipes.VerifyTokenBalance({ ownerKey: 'signerStates', conditionKey: 'inputs' }), {
|
|
194
|
-
shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Ensure tx fee and gas
|
|
198
|
-
runner.use(
|
|
199
|
-
EnsureTxGas((context) => {
|
|
200
|
-
const result = { create: 0, update: 2, payment: 0 };
|
|
201
|
-
|
|
202
|
-
if (context.senderState) {
|
|
203
|
-
result.update += 1;
|
|
204
|
-
} else {
|
|
205
|
-
result.create += 1;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (context.receiverState) {
|
|
209
|
-
result.update += 1;
|
|
210
|
-
} else {
|
|
211
|
-
result.create += 1;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (context.reserveFee) {
|
|
215
|
-
result.update += 1; // owner
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (context.signerStates) {
|
|
219
|
-
result.update += context.signerStates.length;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return result;
|
|
223
|
-
})
|
|
224
|
-
);
|
|
225
|
-
runner.use(EnsureTxCost({ attachSenderChanges: true }));
|
|
226
|
-
|
|
227
|
-
// Save context snapshot before updating states
|
|
228
|
-
runner.use(pipes.TakeStateSnapshot());
|
|
229
|
-
|
|
230
|
-
// update statedb: transfer tokens to new owner
|
|
231
|
-
runner.use(
|
|
232
|
-
async (context, next) => {
|
|
233
|
-
const {
|
|
234
|
-
tx,
|
|
235
|
-
senderState,
|
|
236
|
-
receiverState,
|
|
237
|
-
ownerState,
|
|
238
|
-
statedb,
|
|
239
|
-
senderChange,
|
|
240
|
-
updateVaults,
|
|
241
|
-
tokenFactoryState,
|
|
242
|
-
tokenState,
|
|
243
|
-
reserveAmount,
|
|
244
|
-
reserveFee,
|
|
245
|
-
itx,
|
|
246
|
-
} = context;
|
|
247
|
-
const { amount, receiver } = itx;
|
|
248
|
-
const { reserveAddress, tokenAddress } = tokenFactoryState;
|
|
249
|
-
|
|
250
|
-
// signerStates and inputs are not exist in context for credit token
|
|
251
|
-
const signerStates = tokenFactoryState.curve ? context.signerStates : [];
|
|
252
|
-
const inputs = tokenFactoryState.curve ? context.inputs : [];
|
|
253
|
-
|
|
254
|
-
const totalReserveCost = new BN(reserveAmount || '0').add(new BN(reserveFee || '0'));
|
|
255
|
-
let currentReserveCost = new BN('0');
|
|
256
|
-
|
|
257
|
-
const accountUpdates = {};
|
|
258
|
-
const inputChanges = [];
|
|
259
|
-
|
|
260
|
-
// update signer costs
|
|
261
|
-
inputs.forEach(({ owner, tokensList }) => {
|
|
262
|
-
const reserveTokenChange = tokensList.find((item) => item.address === reserveAddress);
|
|
263
|
-
let reserveValue = new BN(reserveTokenChange.value);
|
|
264
|
-
|
|
265
|
-
// The inputs represent the estimated maximum cost from the frontend.
|
|
266
|
-
// If the actual cost is less than the maximum cost, we need to adjust the deduction correctly.
|
|
267
|
-
if (currentReserveCost.add(reserveValue).gt(totalReserveCost)) {
|
|
268
|
-
reserveTokenChange.value = totalReserveCost.sub(currentReserveCost).toString();
|
|
269
|
-
reserveValue = new BN(reserveTokenChange.value);
|
|
270
|
-
}
|
|
271
|
-
currentReserveCost = currentReserveCost.add(reserveValue);
|
|
272
|
-
|
|
273
|
-
accountUpdates[owner] = applyTokenUpdates(
|
|
274
|
-
[reserveTokenChange],
|
|
275
|
-
signerStates.find((s) => s.address === owner),
|
|
276
|
-
'sub'
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
inputChanges.push({
|
|
280
|
-
address: owner,
|
|
281
|
-
token: reserveAddress,
|
|
282
|
-
delta: reserveValue.neg().toString(),
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// Ensure the sender exists in accountUpdates, because even if there is no balance change, we need to update his nonce
|
|
287
|
-
if (!accountUpdates[tx.from]) {
|
|
288
|
-
accountUpdates[tx.from] = senderState || {};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// update owner
|
|
292
|
-
if (reserveFee && new BN(reserveFee).gt(0)) {
|
|
293
|
-
accountUpdates[ownerState.address] = applyTokenChange(accountUpdates[ownerState.address] || ownerState, {
|
|
294
|
-
address: ownerState.address,
|
|
295
|
-
token: reserveAddress,
|
|
296
|
-
delta: reserveFee,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// update receiver
|
|
301
|
-
accountUpdates[receiver] = applyTokenChange(
|
|
302
|
-
accountUpdates[receiver] || receiverState || { address: receiver, tokens: {} },
|
|
303
|
-
{
|
|
304
|
-
address: receiver,
|
|
305
|
-
token: tokenAddress,
|
|
306
|
-
delta: amount,
|
|
307
|
-
}
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
// update sender
|
|
311
|
-
if (senderChange) {
|
|
312
|
-
accountUpdates[senderChange.address] = applyTokenChange(
|
|
313
|
-
accountUpdates[senderChange.address] || senderState,
|
|
314
|
-
senderChange
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const [newAccountStates, newTokenFactoryState, newTokenState] = await Promise.all([
|
|
319
|
-
// update accounts
|
|
320
|
-
Promise.all(
|
|
321
|
-
Object.entries(accountUpdates).map(([address, updates]) => {
|
|
322
|
-
// We can use updateOrCreate here because the owner and signer have already been validated to exist earlier,
|
|
323
|
-
// the sender and receiver are allowed to be created in the transaction.
|
|
324
|
-
const state = [senderState, receiverState, ownerState, ...signerStates].find((x) => x?.address === address);
|
|
325
|
-
|
|
326
|
-
const actualUpdates = state ? pick(updates, ['tokens']) : { ...updates, address };
|
|
327
|
-
|
|
328
|
-
// Should only update nonce and pk for sender
|
|
329
|
-
if (address === tx.from) {
|
|
330
|
-
actualUpdates.pk = tx.pk;
|
|
331
|
-
actualUpdates.nonce = tx.nonce;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return statedb.account.updateOrCreate(state, account.updateOrCreate(state, actualUpdates, context), context);
|
|
335
|
-
})
|
|
336
|
-
),
|
|
337
|
-
|
|
338
|
-
// Update token factory state
|
|
339
|
-
statedb.tokenFactory.update(
|
|
340
|
-
tokenFactoryState.address,
|
|
341
|
-
tokenFactory.update(
|
|
342
|
-
tokenFactoryState,
|
|
343
|
-
{
|
|
344
|
-
currentSupply: new BN(tokenFactoryState.currentSupply).add(new BN(amount)).toString(),
|
|
345
|
-
reserveBalance: new BN(tokenFactoryState.reserveBalance).add(new BN(reserveAmount || '0')).toString(),
|
|
346
|
-
},
|
|
347
|
-
context
|
|
348
|
-
),
|
|
349
|
-
context
|
|
350
|
-
),
|
|
351
|
-
|
|
352
|
-
statedb.token.update(
|
|
353
|
-
tokenAddress,
|
|
354
|
-
token.update(
|
|
355
|
-
tokenState,
|
|
356
|
-
{
|
|
357
|
-
totalSupply: new BN(tokenState.totalSupply).add(new BN(amount)).toString(),
|
|
358
|
-
},
|
|
359
|
-
context
|
|
360
|
-
),
|
|
361
|
-
context
|
|
362
|
-
),
|
|
363
|
-
]);
|
|
364
|
-
|
|
365
|
-
context.senderState = newAccountStates.find((x) => x.address === tx.from);
|
|
366
|
-
context.receiverState = newAccountStates.find((x) => x.address === receiver);
|
|
367
|
-
// owner maybe not updated
|
|
368
|
-
context.ownerState = newAccountStates.find((x) => x.address === ownerState.address) || ownerState;
|
|
369
|
-
context.signerStates = newAccountStates.filter((x) => signerStates.find((s) => s.address === x.address));
|
|
370
|
-
context.tokenFactoryState = newTokenFactoryState;
|
|
371
|
-
context.tokenState = newTokenState;
|
|
372
|
-
|
|
373
|
-
// save this for receipt generation
|
|
374
|
-
context.inputChanges = inputChanges;
|
|
375
|
-
|
|
376
|
-
await updateVaults();
|
|
377
|
-
|
|
378
|
-
next();
|
|
379
|
-
},
|
|
380
|
-
{ persistError: true }
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
runner.use(pipes.VerifyStateDiff());
|
|
384
|
-
|
|
385
|
-
module.exports = runner;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
2
|
-
const get = require('lodash/get');
|
|
3
|
-
const set = require('lodash/set');
|
|
4
|
-
const { calcCost, calcFee } = require('@ocap/util/lib/curve');
|
|
5
|
-
|
|
6
|
-
module.exports =
|
|
7
|
-
({
|
|
8
|
-
tokenFactoryKey = 'tokenFactoryState',
|
|
9
|
-
tokenStateKey = 'tokenState',
|
|
10
|
-
reserveKey = 'reserveAmount',
|
|
11
|
-
feeKey = 'reserveFee',
|
|
12
|
-
amountKey = 'itx.amount',
|
|
13
|
-
direction = 'mint',
|
|
14
|
-
} = {}) =>
|
|
15
|
-
(context, next) => {
|
|
16
|
-
const tokenFactoryState = get(context, tokenFactoryKey);
|
|
17
|
-
const tokenState = get(context, tokenStateKey);
|
|
18
|
-
const amount = get(context, amountKey);
|
|
19
|
-
|
|
20
|
-
if (!tokenFactoryState) {
|
|
21
|
-
return next(new Error('INVALID_TOKEN_FACTORY', 'Token factory state not found'));
|
|
22
|
-
}
|
|
23
|
-
if (!tokenState) {
|
|
24
|
-
return next(new Error('INVALID_TOKEN', 'Token state not found'));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { curve, currentSupply, feeRate } = tokenFactoryState;
|
|
28
|
-
const { decimal } = tokenState;
|
|
29
|
-
|
|
30
|
-
const reserveAmount = calcCost({ amount, decimal, currentSupply, direction, curve });
|
|
31
|
-
set(context, reserveKey, reserveAmount?.toString());
|
|
32
|
-
|
|
33
|
-
const reserveFee = calcFee({ reserveAmount, feeRate });
|
|
34
|
-
set(context, feeKey, reserveFee?.toString());
|
|
35
|
-
|
|
36
|
-
return next();
|
|
37
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const get = require('lodash/get');
|
|
2
|
-
const set = require('lodash/set');
|
|
3
|
-
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
4
|
-
const { isSvgFile, sanitizeSvg } = require('@blocklet/xss');
|
|
5
|
-
|
|
6
|
-
module.exports =
|
|
7
|
-
({ iconKey = 'itx.token.icon', size = 16 * 1024 } = {}) =>
|
|
8
|
-
(context, next) => {
|
|
9
|
-
const icon = get(context, iconKey);
|
|
10
|
-
|
|
11
|
-
if (!icon) return next();
|
|
12
|
-
|
|
13
|
-
if (!isSvgFile(icon)) {
|
|
14
|
-
return next(new Error('INVALID_ICON', 'Token Icon is not a valid SVG file'));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const buffer = Buffer.from(icon, 'utf8');
|
|
18
|
-
if (buffer.length > size) {
|
|
19
|
-
return next(new Error('INVALID_ICON', `Token Icon must be less than ${Math.floor(size / 1024)}k`));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const sanitizedIcon = sanitizeSvg(icon, { preserveCase: true });
|
|
23
|
-
|
|
24
|
-
set(context, iconKey, sanitizedIcon);
|
|
25
|
-
|
|
26
|
-
return next();
|
|
27
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
const get = require('lodash/get');
|
|
2
|
-
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
3
|
-
const { verifyUrl } = require('@ocap/util/lib/url');
|
|
4
|
-
const { verify: verifyVC } = require('@arcblock/vc');
|
|
5
|
-
|
|
6
|
-
const isTest = ['development', 'test'].includes(process.env.NODE_ENV) || !!process.env.CI;
|
|
7
|
-
|
|
8
|
-
module.exports =
|
|
9
|
-
({ tokenKey = 'itx.token' } = {}) =>
|
|
10
|
-
async (context, next) => {
|
|
11
|
-
const { symbol, address, website } = get(context, tokenKey) || {};
|
|
12
|
-
|
|
13
|
-
if (!website) return next();
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
await verifyUrl(
|
|
17
|
-
website,
|
|
18
|
-
isTest
|
|
19
|
-
? {
|
|
20
|
-
protocols: ['http:', 'https:'],
|
|
21
|
-
blockedHosts: [],
|
|
22
|
-
allowIp: true,
|
|
23
|
-
}
|
|
24
|
-
: {
|
|
25
|
-
checkDns: true,
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
return next(new Error('INVALID_WEBSITE', `Website ${website} must be a valid URL: ${error.message}`));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
tx: { from, delegator },
|
|
34
|
-
config: { chainId },
|
|
35
|
-
} = context;
|
|
36
|
-
|
|
37
|
-
const sender = delegator || from;
|
|
38
|
-
|
|
39
|
-
const { origin } = new URL(website);
|
|
40
|
-
const verificationUrl = `${origin}/.well-known/ocap/tokens.json`;
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const response = await fetch(verificationUrl, {
|
|
44
|
-
redirect: 'manual',
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (!response || !response.ok) {
|
|
48
|
-
context?.logger.info('Website verification failed', {
|
|
49
|
-
symbol,
|
|
50
|
-
website,
|
|
51
|
-
status: response?.status,
|
|
52
|
-
statusText: response?.statusText,
|
|
53
|
-
});
|
|
54
|
-
return next(new Error('INVALID_WEBSITE', `Website ${website} verification failed`));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const data = await response.json();
|
|
58
|
-
|
|
59
|
-
const valids = await Promise.all(
|
|
60
|
-
data
|
|
61
|
-
.filter(Boolean)
|
|
62
|
-
.filter((item) => {
|
|
63
|
-
if (item.type !== 'TokenIssueCredential') return false;
|
|
64
|
-
if (item.issuer.id !== sender) return false;
|
|
65
|
-
|
|
66
|
-
const { id, issued } = item.credentialSubject || {};
|
|
67
|
-
return (
|
|
68
|
-
id === sender &&
|
|
69
|
-
issued.address === address &&
|
|
70
|
-
issued.symbol === symbol &&
|
|
71
|
-
issued.chainId === chainId &&
|
|
72
|
-
issued.website === website
|
|
73
|
-
);
|
|
74
|
-
})
|
|
75
|
-
.map((item) => {
|
|
76
|
-
return verifyVC({
|
|
77
|
-
vc: item,
|
|
78
|
-
ownerDid: sender,
|
|
79
|
-
trustedIssuers: sender,
|
|
80
|
-
});
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
if (valids.some((valid) => valid)) {
|
|
85
|
-
return next();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
context.logger?.warn('Website verification failed', { address, symbol, website, data });
|
|
89
|
-
return next(new Error('INVALID_WEBSITE', `Website ${website} verification failed`));
|
|
90
|
-
} catch (error) {
|
|
91
|
-
return next(new Error('INVALID_WEBSITE', `Website ${website} verification failed: ${error.message}`));
|
|
92
|
-
}
|
|
93
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const get = require('lodash/get');
|
|
2
|
-
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
3
|
-
const { verifyUrl } = require('@ocap/util/lib/url');
|
|
4
|
-
|
|
5
|
-
const isTest = ['development', 'test'].includes(process.env.NODE_ENV) || !!process.env.CI;
|
|
6
|
-
|
|
7
|
-
module.exports =
|
|
8
|
-
({ urlKeys = ['itx.token.website', 'itx.token.metadata.value.communityUrl'] } = {}) =>
|
|
9
|
-
async (context, next) => {
|
|
10
|
-
for (const key of urlKeys) {
|
|
11
|
-
const url = get(context, key);
|
|
12
|
-
if (!url) continue;
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
await verifyUrl(
|
|
16
|
-
url,
|
|
17
|
-
isTest
|
|
18
|
-
? {
|
|
19
|
-
protocols: ['http:', 'https:'],
|
|
20
|
-
blockedHosts: [],
|
|
21
|
-
allowIp: true,
|
|
22
|
-
}
|
|
23
|
-
: {}
|
|
24
|
-
);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
const name = key.split('.').pop();
|
|
27
|
-
return next(new Error('INVALID_TX', `${name} is not valid: ${error.message}`));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return next();
|
|
32
|
-
};
|