@ocap/tx-protocols 1.28.9 → 1.29.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.
Files changed (284) hide show
  1. package/esm/execute.d.mts +53 -0
  2. package/esm/execute.mjs +225 -0
  3. package/esm/index.d.mts +95 -0
  4. package/esm/index.mjs +100 -0
  5. package/esm/pipes/ensure-cost.d.mts +18 -0
  6. package/esm/pipes/ensure-cost.mjs +136 -0
  7. package/esm/pipes/ensure-gas.d.mts +14 -0
  8. package/esm/pipes/ensure-gas.mjs +38 -0
  9. package/esm/protocols/account/delegate.d.mts +4 -0
  10. package/esm/protocols/account/delegate.mjs +195 -0
  11. package/esm/protocols/account/migrate.d.mts +4 -0
  12. package/esm/protocols/account/migrate.mjs +130 -0
  13. package/esm/protocols/account/revoke-delegate.d.mts +4 -0
  14. package/esm/protocols/account/revoke-delegate.mjs +102 -0
  15. package/esm/protocols/asset/acquire-v2.d.mts +9 -0
  16. package/esm/protocols/asset/acquire-v2.mjs +213 -0
  17. package/esm/protocols/asset/acquire-v3.d.mts +17 -0
  18. package/esm/protocols/asset/acquire-v3.mjs +265 -0
  19. package/esm/protocols/asset/calls/transfer-token.d.mts +4 -0
  20. package/esm/protocols/asset/calls/transfer-token.mjs +36 -0
  21. package/esm/protocols/asset/calls/transfer.d.mts +4 -0
  22. package/esm/protocols/asset/calls/transfer.mjs +32 -0
  23. package/esm/protocols/asset/consume.d.mts +4 -0
  24. package/esm/protocols/asset/consume.mjs +92 -0
  25. package/esm/protocols/asset/create.d.mts +4 -0
  26. package/esm/protocols/asset/create.mjs +136 -0
  27. package/esm/protocols/asset/mint.d.mts +4 -0
  28. package/esm/protocols/asset/mint.mjs +156 -0
  29. package/esm/protocols/asset/pipes/exec-mint-hook.d.mts +24 -0
  30. package/esm/protocols/asset/pipes/exec-mint-hook.mjs +54 -0
  31. package/esm/protocols/asset/pipes/extract-factory-tokens.d.mts +21 -0
  32. package/esm/protocols/asset/pipes/extract-factory-tokens.mjs +22 -0
  33. package/esm/protocols/asset/pipes/verify-itx-address.d.mts +32 -0
  34. package/esm/protocols/asset/pipes/verify-itx-address.mjs +56 -0
  35. package/esm/protocols/asset/pipes/verify-itx-assets.d.mts +18 -0
  36. package/esm/protocols/asset/pipes/verify-itx-assets.mjs +27 -0
  37. package/esm/protocols/asset/pipes/verify-itx-variables.d.mts +17 -0
  38. package/esm/protocols/asset/pipes/verify-itx-variables.mjs +20 -0
  39. package/esm/protocols/asset/pipes/verify-mint-limit.d.mts +15 -0
  40. package/esm/protocols/asset/pipes/verify-mint-limit.mjs +14 -0
  41. package/esm/protocols/asset/update.d.mts +4 -0
  42. package/esm/protocols/asset/update.mjs +111 -0
  43. package/esm/protocols/factory/create.d.mts +29 -0
  44. package/esm/protocols/factory/create.mjs +155 -0
  45. package/esm/protocols/governance/claim-stake.d.mts +27 -0
  46. package/esm/protocols/governance/claim-stake.mjs +220 -0
  47. package/esm/protocols/governance/return-stake.d.mts +27 -0
  48. package/esm/protocols/governance/return-stake.mjs +211 -0
  49. package/esm/protocols/governance/revoke-stake.d.mts +27 -0
  50. package/esm/protocols/governance/revoke-stake.mjs +178 -0
  51. package/esm/protocols/governance/slash-stake.d.mts +17 -0
  52. package/esm/protocols/governance/slash-stake.mjs +213 -0
  53. package/esm/protocols/governance/stake.d.mts +15 -0
  54. package/esm/protocols/governance/stake.mjs +270 -0
  55. package/esm/protocols/rollup/claim-reward.d.mts +11 -0
  56. package/esm/protocols/rollup/claim-reward.mjs +322 -0
  57. package/esm/protocols/rollup/close.d.mts +4 -0
  58. package/esm/protocols/rollup/close.mjs +105 -0
  59. package/esm/protocols/rollup/create-block.d.mts +11 -0
  60. package/esm/protocols/rollup/create-block.mjs +303 -0
  61. package/esm/protocols/rollup/create.d.mts +4 -0
  62. package/esm/protocols/rollup/create.mjs +164 -0
  63. package/esm/protocols/rollup/join.d.mts +4 -0
  64. package/esm/protocols/rollup/join.mjs +152 -0
  65. package/esm/protocols/rollup/leave.d.mts +4 -0
  66. package/esm/protocols/rollup/leave.mjs +137 -0
  67. package/esm/protocols/rollup/migrate.d.mts +4 -0
  68. package/esm/protocols/rollup/migrate.mjs +85 -0
  69. package/esm/protocols/rollup/pause.d.mts +4 -0
  70. package/esm/protocols/rollup/pause.mjs +76 -0
  71. package/esm/protocols/rollup/pipes/ensure-validator.d.mts +6 -0
  72. package/esm/protocols/rollup/pipes/ensure-validator.mjs +12 -0
  73. package/esm/protocols/rollup/pipes/verify-evidence.d.mts +15 -0
  74. package/esm/protocols/rollup/pipes/verify-evidence.mjs +29 -0
  75. package/esm/protocols/rollup/pipes/verify-signers.d.mts +15 -0
  76. package/esm/protocols/rollup/pipes/verify-signers.mjs +36 -0
  77. package/esm/protocols/rollup/pipes/verify-status.d.mts +13 -0
  78. package/esm/protocols/rollup/pipes/verify-status.mjs +26 -0
  79. package/esm/protocols/rollup/resume.d.mts +4 -0
  80. package/esm/protocols/rollup/resume.mjs +79 -0
  81. package/esm/protocols/rollup/update.d.mts +4 -0
  82. package/esm/protocols/rollup/update.mjs +111 -0
  83. package/esm/protocols/token/create.d.mts +4 -0
  84. package/esm/protocols/token/create.mjs +150 -0
  85. package/esm/protocols/token/deposit-v2.d.mts +11 -0
  86. package/esm/protocols/token/deposit-v2.mjs +216 -0
  87. package/esm/protocols/token/withdraw-v2.d.mts +9 -0
  88. package/esm/protocols/token/withdraw-v2.mjs +222 -0
  89. package/esm/protocols/token-factory/burn.d.mts +15 -0
  90. package/esm/protocols/token-factory/burn.mjs +233 -0
  91. package/esm/protocols/token-factory/create.d.mts +4 -0
  92. package/esm/protocols/token-factory/create.mjs +254 -0
  93. package/esm/protocols/token-factory/mint.d.mts +15 -0
  94. package/esm/protocols/token-factory/mint.mjs +234 -0
  95. package/esm/protocols/token-factory/pipes/calc-reserve.d.mts +21 -0
  96. package/esm/protocols/token-factory/pipes/calc-reserve.mjs +34 -0
  97. package/esm/protocols/token-factory/pipes/verify-icon.d.mts +14 -0
  98. package/esm/protocols/token-factory/pipes/verify-icon.mjs +18 -0
  99. package/esm/protocols/token-factory/pipes/verify-ownership.d.mts +12 -0
  100. package/esm/protocols/token-factory/pipes/verify-ownership.mjs +63 -0
  101. package/esm/protocols/token-factory/pipes/verify-url.d.mts +12 -0
  102. package/esm/protocols/token-factory/pipes/verify-url.mjs +26 -0
  103. package/esm/protocols/token-factory/update.d.mts +10 -0
  104. package/esm/protocols/token-factory/update.mjs +152 -0
  105. package/esm/protocols/trade/exchange-v2.d.mts +9 -0
  106. package/esm/protocols/trade/exchange-v2.mjs +239 -0
  107. package/esm/protocols/trade/transfer-v2.d.mts +9 -0
  108. package/esm/protocols/trade/transfer-v2.mjs +226 -0
  109. package/esm/protocols/trade/transfer-v3.d.mts +17 -0
  110. package/esm/protocols/trade/transfer-v3.mjs +270 -0
  111. package/esm/util.d.mts +141 -0
  112. package/esm/util.mjs +278 -0
  113. package/lib/_virtual/rolldown_runtime.cjs +29 -0
  114. package/lib/execute.cjs +231 -0
  115. package/lib/execute.d.cts +53 -0
  116. package/lib/index.cjs +105 -0
  117. package/lib/index.d.cts +95 -0
  118. package/lib/pipes/ensure-cost.cjs +141 -0
  119. package/lib/pipes/ensure-cost.d.cts +18 -0
  120. package/lib/pipes/ensure-gas.cjs +41 -0
  121. package/lib/pipes/ensure-gas.d.cts +14 -0
  122. package/lib/protocols/account/delegate.cjs +201 -0
  123. package/lib/protocols/account/delegate.d.cts +4 -0
  124. package/lib/protocols/account/migrate.cjs +135 -0
  125. package/lib/protocols/account/migrate.d.cts +4 -0
  126. package/lib/protocols/account/revoke-delegate.cjs +107 -0
  127. package/lib/protocols/account/revoke-delegate.d.cts +4 -0
  128. package/lib/protocols/asset/acquire-v2.cjs +216 -0
  129. package/lib/protocols/asset/acquire-v2.d.cts +9 -0
  130. package/lib/protocols/asset/acquire-v3.cjs +269 -0
  131. package/lib/protocols/asset/acquire-v3.d.cts +17 -0
  132. package/lib/protocols/asset/calls/transfer-token.cjs +40 -0
  133. package/lib/protocols/asset/calls/transfer-token.d.cts +4 -0
  134. package/lib/protocols/asset/calls/transfer.cjs +35 -0
  135. package/lib/protocols/asset/calls/transfer.d.cts +4 -0
  136. package/lib/protocols/asset/consume.cjs +95 -0
  137. package/lib/protocols/asset/consume.d.cts +4 -0
  138. package/lib/protocols/asset/create.cjs +140 -0
  139. package/lib/protocols/asset/create.d.cts +4 -0
  140. package/lib/protocols/asset/mint.cjs +159 -0
  141. package/lib/protocols/asset/mint.d.cts +4 -0
  142. package/lib/protocols/asset/pipes/exec-mint-hook.cjs +57 -0
  143. package/lib/protocols/asset/pipes/exec-mint-hook.d.cts +24 -0
  144. package/lib/protocols/asset/pipes/extract-factory-tokens.cjs +25 -0
  145. package/lib/protocols/asset/pipes/extract-factory-tokens.d.cts +21 -0
  146. package/lib/protocols/asset/pipes/verify-itx-address.cjs +59 -0
  147. package/lib/protocols/asset/pipes/verify-itx-address.d.cts +32 -0
  148. package/lib/protocols/asset/pipes/verify-itx-assets.cjs +29 -0
  149. package/lib/protocols/asset/pipes/verify-itx-assets.d.cts +18 -0
  150. package/lib/protocols/asset/pipes/verify-itx-variables.cjs +22 -0
  151. package/lib/protocols/asset/pipes/verify-itx-variables.d.cts +17 -0
  152. package/lib/protocols/asset/pipes/verify-mint-limit.cjs +16 -0
  153. package/lib/protocols/asset/pipes/verify-mint-limit.d.cts +15 -0
  154. package/lib/protocols/asset/update.cjs +114 -0
  155. package/lib/protocols/asset/update.d.cts +4 -0
  156. package/lib/protocols/factory/create.cjs +161 -0
  157. package/lib/protocols/factory/create.d.cts +29 -0
  158. package/lib/protocols/governance/claim-stake.cjs +223 -0
  159. package/lib/protocols/governance/claim-stake.d.cts +27 -0
  160. package/lib/protocols/governance/return-stake.cjs +215 -0
  161. package/lib/protocols/governance/return-stake.d.cts +27 -0
  162. package/lib/protocols/governance/revoke-stake.cjs +182 -0
  163. package/lib/protocols/governance/revoke-stake.d.cts +27 -0
  164. package/lib/protocols/governance/slash-stake.cjs +217 -0
  165. package/lib/protocols/governance/slash-stake.d.cts +17 -0
  166. package/lib/protocols/governance/stake.cjs +275 -0
  167. package/lib/protocols/governance/stake.d.cts +15 -0
  168. package/lib/protocols/rollup/claim-reward.cjs +328 -0
  169. package/lib/protocols/rollup/claim-reward.d.cts +11 -0
  170. package/lib/protocols/rollup/close.cjs +107 -0
  171. package/lib/protocols/rollup/close.d.cts +4 -0
  172. package/lib/protocols/rollup/create-block.cjs +309 -0
  173. package/lib/protocols/rollup/create-block.d.cts +11 -0
  174. package/lib/protocols/rollup/create.cjs +169 -0
  175. package/lib/protocols/rollup/create.d.cts +4 -0
  176. package/lib/protocols/rollup/join.cjs +157 -0
  177. package/lib/protocols/rollup/join.d.cts +4 -0
  178. package/lib/protocols/rollup/leave.cjs +141 -0
  179. package/lib/protocols/rollup/leave.d.cts +4 -0
  180. package/lib/protocols/rollup/migrate.cjs +87 -0
  181. package/lib/protocols/rollup/migrate.d.cts +4 -0
  182. package/lib/protocols/rollup/pause.cjs +78 -0
  183. package/lib/protocols/rollup/pause.d.cts +4 -0
  184. package/lib/protocols/rollup/pipes/ensure-validator.cjs +14 -0
  185. package/lib/protocols/rollup/pipes/ensure-validator.d.cts +6 -0
  186. package/lib/protocols/rollup/pipes/verify-evidence.cjs +32 -0
  187. package/lib/protocols/rollup/pipes/verify-evidence.d.cts +15 -0
  188. package/lib/protocols/rollup/pipes/verify-signers.cjs +39 -0
  189. package/lib/protocols/rollup/pipes/verify-signers.d.cts +15 -0
  190. package/lib/protocols/rollup/pipes/verify-status.cjs +28 -0
  191. package/lib/protocols/rollup/pipes/verify-status.d.cts +13 -0
  192. package/lib/protocols/rollup/resume.cjs +81 -0
  193. package/lib/protocols/rollup/resume.d.cts +4 -0
  194. package/lib/protocols/rollup/update.cjs +114 -0
  195. package/lib/protocols/rollup/update.d.cts +4 -0
  196. package/lib/protocols/token/create.cjs +156 -0
  197. package/lib/protocols/token/create.d.cts +4 -0
  198. package/lib/protocols/token/deposit-v2.cjs +219 -0
  199. package/lib/protocols/token/deposit-v2.d.cts +11 -0
  200. package/lib/protocols/token/withdraw-v2.cjs +225 -0
  201. package/lib/protocols/token/withdraw-v2.d.cts +9 -0
  202. package/lib/protocols/token-factory/burn.cjs +236 -0
  203. package/lib/protocols/token-factory/burn.d.cts +15 -0
  204. package/lib/protocols/token-factory/create.cjs +260 -0
  205. package/lib/protocols/token-factory/create.d.cts +4 -0
  206. package/lib/protocols/token-factory/mint.cjs +237 -0
  207. package/lib/protocols/token-factory/mint.d.cts +15 -0
  208. package/lib/protocols/token-factory/pipes/calc-reserve.cjs +38 -0
  209. package/lib/protocols/token-factory/pipes/calc-reserve.d.cts +21 -0
  210. package/lib/protocols/token-factory/pipes/verify-icon.cjs +22 -0
  211. package/lib/protocols/token-factory/pipes/verify-icon.d.cts +14 -0
  212. package/lib/protocols/token-factory/pipes/verify-ownership.cjs +66 -0
  213. package/lib/protocols/token-factory/pipes/verify-ownership.d.cts +12 -0
  214. package/lib/protocols/token-factory/pipes/verify-url.cjs +29 -0
  215. package/lib/protocols/token-factory/pipes/verify-url.d.cts +12 -0
  216. package/lib/protocols/token-factory/update.cjs +155 -0
  217. package/lib/protocols/token-factory/update.d.cts +10 -0
  218. package/lib/protocols/trade/exchange-v2.cjs +243 -0
  219. package/lib/protocols/trade/exchange-v2.d.cts +9 -0
  220. package/lib/protocols/trade/transfer-v2.cjs +229 -0
  221. package/lib/protocols/trade/transfer-v2.d.cts +9 -0
  222. package/lib/protocols/trade/transfer-v3.cjs +274 -0
  223. package/lib/protocols/trade/transfer-v3.d.cts +17 -0
  224. package/lib/util.cjs +296 -0
  225. package/lib/util.d.cts +141 -0
  226. package/package.json +49 -22
  227. package/tools/fixtures.ts +564 -0
  228. package/lib/execute.js +0 -254
  229. package/lib/index.js +0 -117
  230. package/lib/pipes/ensure-cost.js +0 -193
  231. package/lib/pipes/ensure-gas.js +0 -48
  232. package/lib/protocols/account/delegate.js +0 -223
  233. package/lib/protocols/account/migrate.js +0 -153
  234. package/lib/protocols/account/revoke-delegate.js +0 -110
  235. package/lib/protocols/asset/acquire-v2.js +0 -262
  236. package/lib/protocols/asset/acquire-v3.js +0 -330
  237. package/lib/protocols/asset/calls/README.md +0 -5
  238. package/lib/protocols/asset/calls/transfer-token.js +0 -36
  239. package/lib/protocols/asset/calls/transfer.js +0 -28
  240. package/lib/protocols/asset/consume.js +0 -105
  241. package/lib/protocols/asset/create.js +0 -151
  242. package/lib/protocols/asset/mint.js +0 -199
  243. package/lib/protocols/asset/pipes/exec-mint-hook.js +0 -62
  244. package/lib/protocols/asset/pipes/extract-factory-tokens.js +0 -18
  245. package/lib/protocols/asset/pipes/verify-itx-address.js +0 -54
  246. package/lib/protocols/asset/pipes/verify-itx-assets.js +0 -51
  247. package/lib/protocols/asset/pipes/verify-itx-variables.js +0 -26
  248. package/lib/protocols/asset/pipes/verify-mint-limit.js +0 -13
  249. package/lib/protocols/asset/update.js +0 -131
  250. package/lib/protocols/factory/create.js +0 -191
  251. package/lib/protocols/governance/claim-stake.js +0 -266
  252. package/lib/protocols/governance/return-stake.js +0 -248
  253. package/lib/protocols/governance/revoke-stake.js +0 -172
  254. package/lib/protocols/governance/slash-stake.js +0 -271
  255. package/lib/protocols/governance/stake.js +0 -303
  256. package/lib/protocols/rollup/claim-reward.js +0 -342
  257. package/lib/protocols/rollup/close.js +0 -104
  258. package/lib/protocols/rollup/create-block.js +0 -413
  259. package/lib/protocols/rollup/create.js +0 -197
  260. package/lib/protocols/rollup/join.js +0 -182
  261. package/lib/protocols/rollup/leave.js +0 -145
  262. package/lib/protocols/rollup/migrate.js +0 -85
  263. package/lib/protocols/rollup/pause.js +0 -75
  264. package/lib/protocols/rollup/pipes/ensure-validator.js +0 -12
  265. package/lib/protocols/rollup/pipes/verify-evidence.js +0 -37
  266. package/lib/protocols/rollup/pipes/verify-signers.js +0 -87
  267. package/lib/protocols/rollup/pipes/verify-status.js +0 -30
  268. package/lib/protocols/rollup/resume.js +0 -75
  269. package/lib/protocols/rollup/update.js +0 -122
  270. package/lib/protocols/token/create.js +0 -199
  271. package/lib/protocols/token/deposit-v2.js +0 -290
  272. package/lib/protocols/token/withdraw-v2.js +0 -305
  273. package/lib/protocols/token-factory/burn.js +0 -371
  274. package/lib/protocols/token-factory/create.js +0 -342
  275. package/lib/protocols/token-factory/mint.js +0 -385
  276. package/lib/protocols/token-factory/pipes/calc-reserve.js +0 -37
  277. package/lib/protocols/token-factory/pipes/verify-icon.js +0 -27
  278. package/lib/protocols/token-factory/pipes/verify-ownership.js +0 -93
  279. package/lib/protocols/token-factory/pipes/verify-url.js +0 -32
  280. package/lib/protocols/token-factory/update.js +0 -208
  281. package/lib/protocols/trade/exchange-v2.js +0 -239
  282. package/lib/protocols/trade/transfer-v2.js +0 -233
  283. package/lib/protocols/trade/transfer-v3.js +0 -333
  284. package/lib/util.js +0 -442
@@ -1,197 +0,0 @@
1
- const isEmpty = require('empty-value');
2
- const cloneDeep = require('lodash/cloneDeep');
3
- const { CustomError: Error } = require('@ocap/util/lib/error');
4
- const { Runner, pipes } = require('@ocap/tx-pipeline');
5
- const { account, rollup, delegation } = require('@ocap/state');
6
- const { formatMessage } = require('@ocap/message');
7
- const { isFromPublicKey, isEthereumDid } = require('@arcblock/did');
8
- const { toRollupAddress } = require('@arcblock/did-util');
9
-
10
- const debug = require('debug')(`${require('../../../package.json').name}:create-rollup`);
11
-
12
- const { decodeAnySafe, getDelegationRequirements } = require('../../util');
13
- const EnsureTxGas = require('../../pipes/ensure-gas');
14
- const EnsureTxCost = require('../../pipes/ensure-cost');
15
-
16
- const runner = new Runner();
17
-
18
- runner.use(pipes.VerifyMultiSig(0));
19
-
20
- // 0. verify itx
21
- runner.use((context, next) => {
22
- const { itx } = context;
23
- context.formattedItx = formatMessage('CreateRollupTx', itx);
24
-
25
- try {
26
- rollup.create(context.formattedItx, context);
27
- } catch (err) {
28
- return next(new Error('INVALID_TX', err.message));
29
- }
30
-
31
- return next();
32
- });
33
- runner.use(
34
- pipes.VerifyInfo([
35
- {
36
- error: 'INVALID_TX',
37
- message: 'Sum of itx.proposerFeeShare and itx.publisherFeeShare must be less than 10000',
38
- fn: ({ itx }) => itx.proposerFeeShare + itx.publisherFeeShare < 10000,
39
- },
40
- {
41
- error: 'INVALID_TX',
42
- message: 'Seed validator pk and address not match',
43
- fn: ({ formattedItx }) => formattedItx.seedValidators.every(({ pk, address }) => isFromPublicKey(address, pk)),
44
- },
45
- {
46
- error: 'INVALID_TX',
47
- message: 'Seed validator must use ethereum compatible address',
48
- fn: ({ formattedItx }) => formattedItx.seedValidators.every(({ address }) => isEthereumDid(address)),
49
- },
50
- {
51
- error: 'INVALID_TX',
52
- message: 'Rollup address is not valid',
53
- fn: (context) => {
54
- const itx = cloneDeep(context.itx);
55
- itx.data = decodeAnySafe(itx.data);
56
- itx.address = '';
57
-
58
- // Save for later use
59
- context.rollupData = itx.data;
60
- context.seedValidators = itx.seedValidatorsList.map((x) => x.address);
61
-
62
- return toRollupAddress(itx) === context.itx.address;
63
- },
64
- },
65
- ])
66
- );
67
-
68
- // 1. ensure sender, validators, delegation
69
- runner.use(
70
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
71
- );
72
- runner.use(
73
- pipes.ExtractState({
74
- from: 'seedValidators',
75
- to: 'validatorStates',
76
- status: 'INVALID_VALIDATOR_STATE',
77
- table: 'account',
78
- })
79
- );
80
- runner.use(
81
- pipes.VerifyAccountMigration({ signerKey: 'validatorStates', stateKey: 'senderState', addressKey: 'tx.from' })
82
- );
83
- runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
84
- runner.use(pipes.VerifyAccountMigration({ stateKey: 'delegatorState', addressKey: 'tx.delegator' }));
85
- runner.use(
86
- pipes.VerifyDelegation({
87
- type: 'signature',
88
- signerKey: 'senderState',
89
- delegatorKey: 'delegatorState',
90
- getRequirements: getDelegationRequirements,
91
- })
92
- );
93
-
94
- // 2. ensure token exist and match
95
- runner.use(pipes.ExtractState({ from: 'itx.tokenAddress', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' }));
96
- runner.use(
97
- pipes.VerifyInfo([
98
- {
99
- error: 'INVALID_TOKEN',
100
- message: 'Token does not have foreignToken attached',
101
- fn: ({ tokenState }) => isEmpty(tokenState.foreignToken) === false,
102
- },
103
- ])
104
- );
105
-
106
- // 3. ensure only 1 rollup for a token
107
- runner.use(async (context, next) => {
108
- const { statedb, itx } = context;
109
- const exist = await statedb.rollup.existByToken(itx.tokenAddress, context);
110
- if (exist) {
111
- return next(new Error('DUPLICATE_ROLLUP', 'Only 1 active rollup can be created for the token'));
112
- }
113
-
114
- return next();
115
- });
116
-
117
- // 4. ensure rollup not exist
118
- runner.use(pipes.ExtractState({ from: 'itx.address', to: 'rollupState', status: 'OK', table: 'rollup' }));
119
- runner.use(
120
- pipes.VerifyInfo([
121
- {
122
- error: 'DUPLICATE_ROLLUP',
123
- message: 'This rollup already exist on chain',
124
- fn: (context) => isEmpty(context.rollupState),
125
- },
126
- ])
127
- );
128
-
129
- // Ensure tx fee and gas
130
- runner.use(EnsureTxGas(() => ({ create: 1, update: 2, payment: 0 })));
131
- runner.use(EnsureTxCost({ attachSenderChanges: true }));
132
-
133
- // Save context snapshot before updating states
134
- runner.use(pipes.TakeStateSnapshot());
135
-
136
- // 5. create rollup state
137
- runner.use(
138
- async (context, next) => {
139
- const {
140
- tx,
141
- formattedItx,
142
- rollupData,
143
- statedb,
144
- senderState,
145
- delegatorState,
146
- delegationState,
147
- senderUpdates,
148
- updateVaults,
149
- } = context;
150
-
151
- const issuer = delegatorState ? delegatorState.address : senderState.address;
152
- const [newSenderState, rollupState, newDelegationState] = await Promise.all([
153
- statedb.account.update(
154
- senderState.address,
155
- account.update(senderState, { nonce: tx.nonce, ...senderUpdates }, context),
156
- context
157
- ),
158
-
159
- statedb.rollup.create(
160
- formattedItx.address,
161
- rollup.create(
162
- {
163
- ...formattedItx,
164
- issuer,
165
- validators: formattedItx.seedValidators,
166
- data: rollupData,
167
- },
168
- context
169
- ),
170
- context
171
- ),
172
-
173
- // Update delegation state
174
- context.isDelegationChanged
175
- ? statedb.delegation.update(delegationState.address, delegation.update(delegationState, {}, context), context)
176
- : delegationState,
177
- ]);
178
-
179
- await updateVaults();
180
-
181
- // FIXME: create-rollup 的时候不能校验 stake,还是在这里创建 stake?如果在这里创建 stake,是否需要多签?
182
- // FIXME: account migration 也需要测试下
183
-
184
- context.senderState = newSenderState;
185
- context.rollupState = rollupState;
186
- context.delegationState = newDelegationState;
187
-
188
- debug('create-rollup', rollupState);
189
-
190
- next();
191
- },
192
- { persistError: true }
193
- );
194
-
195
- runner.use(pipes.VerifyStateDiff());
196
-
197
- module.exports = runner;
@@ -1,182 +0,0 @@
1
- const MerkleTree = require('@ocap/merkle-tree');
2
- const joinUrl = require('url-join');
3
- const { CustomError: Error } = require('@ocap/util/lib/error');
4
- const { Joi, schemas, patterns } = require('@arcblock/validator');
5
- const { BN, toHex } = require('@ocap/util');
6
- const { Runner, pipes } = require('@ocap/tx-pipeline');
7
- const { account, rollup, stake, evidence } = require('@ocap/state');
8
- const { toStakeAddress } = require('@arcblock/did-util');
9
- const { isEthereumDid } = require('@arcblock/did');
10
-
11
- const debug = require('debug')(`${require('../../../package.json').name}:join-rollup`);
12
-
13
- const VerifySigners = require('./pipes/verify-signers');
14
- const VerifyEvidence = require('./pipes/verify-evidence');
15
- const VerifyStatus = require('./pipes/verify-status');
16
- const EnsureTxGas = require('../../pipes/ensure-gas');
17
- const EnsureTxCost = require('../../pipes/ensure-cost');
18
-
19
- const runner = new Runner();
20
-
21
- // 1. verify itx
22
- const schema = Joi.object({
23
- rollup: Joi.DID().prefix().role('ROLE_ROLLUP').required(),
24
- endpoint: Joi.string()
25
- .uri({ scheme: [/https?/] })
26
- .required(),
27
- evidence: Joi.object({
28
- hash: Joi.string().regex(patterns.txHash).required(),
29
- }).required(),
30
- signaturesList: schemas.multiSig.min(1).required(),
31
- data: Joi.any().optional().allow(null),
32
- }).options({ stripUnknown: true, noDefaults: false });
33
- runner.use(({ itx }, next) => {
34
- const { error } = schema.validate(itx);
35
- return next(error ? new Error('INVALID_TX', `Invalid itx: ${error.message}`) : null);
36
- });
37
-
38
- // 2. verify rollup
39
- runner.use(pipes.ExtractState({ from: 'itx.rollup', to: 'rollupState', status: 'INVALID_ROLLUP', table: 'rollup' }));
40
- runner.use(VerifyStatus({ paused: false }));
41
-
42
- // 3. verify new validator
43
- runner.use((context, next) => {
44
- const { tx, itx, rollupState } = context;
45
- const validator = { pk: toHex(tx.pk), address: tx.from, endpoint: itx.endpoint };
46
- if (isEthereumDid(tx.from) === false) {
47
- return next(new Error('INVALID_TX', 'Invalid tx.from: only ethereum compatible address can join rollup'));
48
- }
49
-
50
- if (rollupState.validators.some((x) => x.address === validator.address)) {
51
- return next(new Error('INVALID_TX', `Address ${validator.address} already exist in validators`));
52
- }
53
-
54
- // The endpoint should not contain any pathname
55
- if (rollupState.validators.some((x) => joinUrl(x.endpoint, '/') === joinUrl(validator.endpoint, '/'))) {
56
- return next(new Error('INVALID_TX', `Endpoint ${validator.endpoint} already exist in validators`));
57
- }
58
-
59
- context.newValidator = validator;
60
- context.validatorsHash = MerkleTree.getListHash([validator.address]);
61
-
62
- return next();
63
- });
64
-
65
- // 4. verify evidence signers, signatures, state
66
- runner.use(VerifySigners({ signersKey: 'itx.signaturesList', allowSender: false }));
67
- runner.use(
68
- VerifyEvidence({ evidenceKey: 'validatorsHash', signaturesKey: 'itx.signaturesList', verifyMethod: 'ethVerify' })
69
- );
70
- runner.use(pipes.ExtractState({ from: 'itx.evidence.hash', to: 'evidenceState', status: 'OK', table: 'evidence' }));
71
- runner.use(({ evidenceState }, next) => {
72
- if (evidenceState) return next(new Error('INVALID_TX', 'Join evidence already seen on this chain'));
73
- return next();
74
- });
75
-
76
- // 5. verify tx signers and signatures
77
- runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: false }));
78
- runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
79
-
80
- // 6. verify staking: get address, extract state, verify amount
81
- runner.use((context, next) => {
82
- const { tx, itx } = context;
83
- context.stakeAddress = toStakeAddress(tx.from, itx.rollup);
84
- return next();
85
- });
86
- runner.use(
87
- pipes.ExtractState({ from: 'stakeAddress', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
88
- );
89
- runner.use((context, next) => {
90
- const { stakeState, rollupState } = context;
91
- if (stakeState.revocable === false) {
92
- return next(new Error('INVALID_STAKE_STATE', `Staking already locked: ${stakeState.address}`));
93
- }
94
-
95
- const actualStake = new BN(stakeState.tokens[rollupState.tokenAddress] || 0);
96
- const requiredStake = new BN(rollupState.minStakeAmount);
97
- if (actualStake.lt(requiredStake)) {
98
- return next(new Error('INVALID_STAKE_STATE', `Staking does not match min stake amount: ${requiredStake}`));
99
- }
100
-
101
- return next();
102
- });
103
-
104
- // 7. verify sender and signer states
105
- runner.use(
106
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
107
- );
108
- runner.use(
109
- pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
110
- );
111
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
112
-
113
- // Ensure tx fee and gas
114
- runner.use(EnsureTxGas(() => ({ create: 1, update: 3, payment: 0 })));
115
- runner.use(EnsureTxCost({ attachSenderChanges: true }));
116
-
117
- // Save context snapshot before updating states
118
- runner.use(pipes.TakeStateSnapshot());
119
-
120
- // 8. update state
121
- runner.use(
122
- async (context, next) => {
123
- const {
124
- tx,
125
- itx,
126
- rollupState,
127
- statedb,
128
- senderState,
129
- stakeState,
130
- newValidator,
131
- stakeAddress,
132
- senderUpdates,
133
- updateVaults,
134
- } = context;
135
- const newValidators = rollupState.validators.concat([newValidator]);
136
-
137
- const [newSenderState, newRollupState, newStakeState, evidenceState] = await Promise.all([
138
- statedb.account.update(
139
- senderState.address,
140
- account.update(senderState, { nonce: tx.nonce, ...senderUpdates }, context),
141
- context
142
- ),
143
-
144
- // persist new validators list
145
- statedb.rollup.update(
146
- rollupState.address,
147
- rollup.update(rollupState, { validators: newValidators }, context),
148
- context
149
- ),
150
-
151
- // lock the stake from the new validator for defined period
152
- statedb.stake.update(
153
- stakeAddress,
154
- stake.update(stakeState, { revocable: false, revokeWaitingPeriod: rollupState.leaveWaitingPeriod }, context),
155
- context
156
- ),
157
-
158
- // Create evidence state
159
- statedb.evidence.create(
160
- itx.evidence.hash,
161
- evidence.create({ hash: itx.evidence.hash, data: 'rollup-join' }, context),
162
- context
163
- ),
164
- ]);
165
-
166
- await updateVaults();
167
-
168
- context.senderState = newSenderState;
169
- context.rollupState = newRollupState;
170
- context.stakeState = newStakeState;
171
- context.evidenceState = evidenceState;
172
-
173
- debug('join-rollup', newValidators);
174
-
175
- next();
176
- },
177
- { persistError: true }
178
- );
179
-
180
- runner.use(pipes.VerifyStateDiff());
181
-
182
- module.exports = runner;
@@ -1,145 +0,0 @@
1
- const MerkleTree = require('@ocap/merkle-tree');
2
- const { CustomError: Error } = require('@ocap/util/lib/error');
3
- const { Joi, schemas, patterns } = require('@arcblock/validator');
4
- const { Runner, pipes } = require('@ocap/tx-pipeline');
5
- const { account, rollup, stake, evidence } = require('@ocap/state');
6
- const { toStakeAddress } = require('@arcblock/did-util');
7
-
8
- const debug = require('debug')(`${require('../../../package.json').name}:leave-rollup`);
9
-
10
- const VerifySigners = require('./pipes/verify-signers');
11
- const VerifyEvidence = require('./pipes/verify-evidence');
12
- const VerifyStatus = require('./pipes/verify-status');
13
- const EnsureValidator = require('./pipes/ensure-validator');
14
- const EnsureTxGas = require('../../pipes/ensure-gas');
15
- const EnsureTxCost = require('../../pipes/ensure-cost');
16
-
17
- const runner = new Runner();
18
-
19
- // 1. verify itx
20
- const schema = Joi.object({
21
- rollup: Joi.DID().prefix().role('ROLE_ROLLUP').required(),
22
- evidence: Joi.object({
23
- hash: Joi.string().regex(patterns.txHash).required(),
24
- }).required(),
25
- signaturesList: schemas.multiSig.min(1).required(),
26
- data: Joi.any().optional().allow(null),
27
- }).options({ stripUnknown: true, noDefaults: false });
28
- runner.use(({ itx }, next) => {
29
- const { error } = schema.validate(itx);
30
- return next(error ? new Error('INVALID_TX', `Invalid itx: ${error.message}`) : null);
31
- });
32
-
33
- // 2. verify rollup
34
- runner.use(pipes.ExtractState({ from: 'itx.rollup', to: 'rollupState', status: 'INVALID_ROLLUP', table: 'rollup' }));
35
- runner.use(EnsureValidator());
36
- runner.use(VerifyStatus({ paused: false }));
37
-
38
- // 3. verify evidence signers, signatures, state
39
- runner.use((context, next) => {
40
- context.validatorsHash = MerkleTree.getListHash([context.tx.from]);
41
- return next();
42
- });
43
- runner.use(VerifySigners({ signersKey: 'itx.signaturesList', allowSender: false, allowShrink: true }));
44
- runner.use(
45
- VerifyEvidence({ evidenceKey: 'validatorsHash', signaturesKey: 'itx.signaturesList', verifyMethod: 'ethVerify' })
46
- );
47
- runner.use(pipes.ExtractState({ from: 'itx.evidence.hash', to: 'evidenceState', status: 'OK', table: 'evidence' }));
48
- runner.use(({ evidenceState }, next) => {
49
- if (evidenceState) return next(new Error('INVALID_TX', 'Leave evidence already seen on this chain'));
50
- return next();
51
- });
52
-
53
- // 4. verify tx signers and signatures
54
- runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: false, allowShrink: true }));
55
- runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
56
-
57
- // 5. verify validator
58
- runner.use((context, next) => {
59
- const { tx, rollupState } = context;
60
- if (rollupState.seedValidators.some((x) => x.address === tx.from)) {
61
- return next(new Error('INVALID_TX', `Address ${tx.from} can not leave since it's seed validator`));
62
- }
63
-
64
- if (rollupState.validators.some((x) => x.address === tx.from) === false) {
65
- return next(new Error('INVALID_TX', `Address ${tx.from} not exist in validator whitelist`));
66
- }
67
-
68
- return next();
69
- });
70
-
71
- // 6. verify staking: get address, extract state
72
- runner.use((context, next) => {
73
- const { tx, itx } = context;
74
- context.stakeAddress = toStakeAddress(tx.from, itx.rollup);
75
- return next();
76
- });
77
- runner.use(
78
- pipes.ExtractState({ from: 'stakeAddress', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
79
- );
80
-
81
- // 7. verify sender state
82
- runner.use(
83
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
84
- );
85
- runner.use(
86
- pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
87
- );
88
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
89
-
90
- // Ensure tx fee and gas
91
- runner.use(EnsureTxGas(() => ({ create: 1, update: 3, payment: 0 })));
92
- runner.use(EnsureTxCost({ attachSenderChanges: true }));
93
-
94
- // Save context snapshot before updating states
95
- runner.use(pipes.TakeStateSnapshot());
96
-
97
- // 8. update state
98
- runner.use(
99
- async (context, next) => {
100
- const { tx, itx, rollupState, statedb, senderState, stakeState, stakeAddress, senderUpdates, updateVaults } =
101
- context;
102
- const newValidators = rollupState.validators.filter((x) => x.address !== tx.from);
103
-
104
- const [newSenderState, newRollupState, newStakeState, evidenceState] = await Promise.all([
105
- statedb.account.update(
106
- senderState.address,
107
- account.update(senderState, { nonce: tx.nonce, ...senderUpdates }, context),
108
- context
109
- ),
110
-
111
- // persist new validators list
112
- statedb.rollup.update(
113
- rollupState.address,
114
- rollup.update(rollupState, { validators: newValidators }, context),
115
- context
116
- ),
117
-
118
- // unlock the stake from the validator
119
- statedb.stake.update(stakeAddress, stake.update(stakeState, { revocable: true }, context), context),
120
-
121
- // Create evidence state
122
- statedb.evidence.create(
123
- itx.evidence.hash,
124
- evidence.create({ hash: itx.evidence.hash, data: 'rollup-leave' }, context),
125
- context
126
- ),
127
- ]);
128
-
129
- await updateVaults();
130
-
131
- context.senderState = newSenderState;
132
- context.rollupState = newRollupState;
133
- context.stakeState = newStakeState;
134
- context.evidenceState = evidenceState;
135
-
136
- debug('leave-rollup', newValidators);
137
-
138
- next();
139
- },
140
- { persistError: true }
141
- );
142
-
143
- runner.use(pipes.VerifyStateDiff());
144
-
145
- module.exports = runner;
@@ -1,85 +0,0 @@
1
- const { CustomError: Error } = require('@ocap/util/lib/error');
2
- const { Joi } = require('@arcblock/validator');
3
- const { Runner, pipes } = require('@ocap/tx-pipeline');
4
- const { account, rollup } = require('@ocap/state');
5
-
6
- const VerifySigners = require('./pipes/verify-signers');
7
- const VerifyStatus = require('./pipes/verify-status');
8
- const EnsureValidator = require('./pipes/ensure-validator');
9
- const EnsureTxGas = require('../../pipes/ensure-gas');
10
- const EnsureTxCost = require('../../pipes/ensure-cost');
11
-
12
- const runner = new Runner();
13
-
14
- // 1. verify itx
15
- const schema = Joi.object({
16
- rollup: Joi.DID().prefix().role('ROLE_ROLLUP').required(),
17
- to: Joi.DID().prefix().wallet('ethereum').required(),
18
- type: Joi.string().trim().valid('vault', 'contract').required(),
19
- message: Joi.string().trim().min(1).max(512).required(),
20
- data: Joi.any().optional().allow(null),
21
- }).options({ stripUnknown: true, noDefaults: false });
22
- runner.use(({ itx }, next) => {
23
- const { error } = schema.validate(itx);
24
- return next(error ? new Error('INVALID_TX', `Invalid itx: ${error.message}`) : null);
25
- });
26
-
27
- // 2. verify rollup
28
- runner.use(pipes.ExtractState({ from: 'itx.rollup', to: 'rollupState', status: 'INVALID_ROLLUP', table: 'rollup' }));
29
- runner.use(EnsureValidator(true));
30
- runner.use(VerifyStatus({ paused: true, closed: false }));
31
-
32
- // 3. verify tx signers and signatures
33
- runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true }));
34
- runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
35
-
36
- // 4. verify sender and signer states
37
- runner.use(
38
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
39
- );
40
- runner.use(
41
- pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
42
- );
43
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
44
-
45
- // Ensure tx fee and gas
46
- runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
47
- runner.use(EnsureTxCost({ attachSenderChanges: true }));
48
-
49
- // Save context snapshot before updating states
50
- runner.use(pipes.TakeStateSnapshot());
51
-
52
- // 5. update state
53
- runner.use(
54
- async (context, next) => {
55
- const { tx, itx, statedb, rollupState, senderState, senderUpdates, updateVaults } = context;
56
- let updates = {};
57
- if (itx.type === 'vault') {
58
- updates = rollup.migrateVault(rollupState, itx.to, context);
59
- }
60
- if (itx.type === 'contract') {
61
- updates = rollup.migrateContract(rollupState, itx.to, context);
62
- }
63
-
64
- const [newSenderState, newRollupState] = await Promise.all([
65
- statedb.account.update(
66
- senderState.address,
67
- account.update(senderState, { nonce: tx.nonce, ...senderUpdates }, context),
68
- context
69
- ),
70
- statedb.rollup.update(itx.rollup, updates, context),
71
- ]);
72
-
73
- await updateVaults();
74
-
75
- context.senderState = newSenderState;
76
- context.rollupState = newRollupState;
77
-
78
- next();
79
- },
80
- { persistError: true }
81
- );
82
-
83
- runner.use(pipes.VerifyStateDiff());
84
-
85
- module.exports = runner;
@@ -1,75 +0,0 @@
1
- const { CustomError: Error } = require('@ocap/util/lib/error');
2
- const { Joi } = require('@arcblock/validator');
3
- const { Runner, pipes } = require('@ocap/tx-pipeline');
4
- const { account, rollup } = require('@ocap/state');
5
-
6
- const VerifySigners = require('./pipes/verify-signers');
7
- const VerifyStatus = require('./pipes/verify-status');
8
- const EnsureValidator = require('./pipes/ensure-validator');
9
- const EnsureTxGas = require('../../pipes/ensure-gas');
10
- const EnsureTxCost = require('../../pipes/ensure-cost');
11
-
12
- const runner = new Runner();
13
-
14
- // 1. verify itx
15
- const schema = Joi.object({
16
- rollup: Joi.DID().prefix().role('ROLE_ROLLUP').required(),
17
- data: Joi.any().optional().allow(null),
18
- }).options({ stripUnknown: true, noDefaults: false });
19
- runner.use(({ itx }, next) => {
20
- const { error } = schema.validate(itx);
21
- return next(error ? new Error('INVALID_TX', `Invalid itx: ${error.message}`) : null);
22
- });
23
-
24
- // 2. verify rollup
25
- runner.use(pipes.ExtractState({ from: 'itx.rollup', to: 'rollupState', status: 'INVALID_ROLLUP', table: 'rollup' }));
26
- runner.use(EnsureValidator(true));
27
- runner.use(VerifyStatus({ paused: false }));
28
-
29
- // 3. verify tx signers and signatures
30
- runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true }));
31
- runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
32
-
33
- // 4. verify sender and signer states
34
- runner.use(
35
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
36
- );
37
- runner.use(
38
- pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
39
- );
40
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
41
-
42
- // Ensure tx fee and gas
43
- runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
44
- runner.use(EnsureTxCost({ attachSenderChanges: true }));
45
-
46
- // Save context snapshot before updating states
47
- runner.use(pipes.TakeStateSnapshot());
48
-
49
- // 5. update rollup state
50
- runner.use(
51
- async (context, next) => {
52
- const { tx, itx, rollupState, statedb, senderState, senderUpdates, updateVaults } = context;
53
-
54
- const [newSenderState, newRollupState] = await Promise.all([
55
- statedb.account.update(
56
- senderState.address,
57
- account.update(senderState, { nonce: tx.nonce, ...senderUpdates }, context),
58
- context
59
- ),
60
- statedb.rollup.update(itx.rollup, rollup.pause(rollupState, context), context),
61
- ]);
62
-
63
- await updateVaults();
64
-
65
- context.senderState = newSenderState;
66
- context.rollupState = newRollupState;
67
-
68
- next();
69
- },
70
- { persistError: true }
71
- );
72
-
73
- runner.use(pipes.VerifyStateDiff());
74
-
75
- module.exports = runner;
@@ -1,12 +0,0 @@
1
- const { CustomError: Error } = require('@ocap/util/lib/error');
2
-
3
- module.exports = (isSeed) => (context, next) => {
4
- const { rollupState, tx } = context;
5
-
6
- const validators = isSeed ? rollupState.seedValidators : rollupState.validators;
7
- if (validators.some((x) => x.address === tx.from) === false) {
8
- return next(new Error('INVALID_TX', 'Tx sender is not an expected validator'));
9
- }
10
-
11
- return next();
12
- };