@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.
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
@@ -0,0 +1,195 @@
1
+ import ensure_cost_default from "../../pipes/ensure-cost.mjs";
2
+ import ensure_gas_default from "../../pipes/ensure-gas.mjs";
3
+ import { Runner, pipes } from "@ocap/tx-pipeline";
4
+ import { CustomError } from "@ocap/util/lib/error";
5
+ import get from "lodash/get.js";
6
+ import pick from "lodash/pick.js";
7
+ import { toDelegateAddress } from "@arcblock/did-util";
8
+ import { account, delegation } from "@ocap/state";
9
+ import Debug from "debug";
10
+ import { formatMessage } from "@ocap/message";
11
+ import cloneDeep from "lodash/cloneDeep.js";
12
+ import { Joi } from "@arcblock/validator";
13
+
14
+ //#region src/protocols/account/delegate.ts
15
+ const debug = Debug("@ocap/tx-protocols:delegate");
16
+ const runner = new Runner("delegate");
17
+ runner.use(pipes.VerifyMultiSig(0));
18
+ const rateLimit = Joi.object({
19
+ interval: Joi.number().integer().greater(0).required(),
20
+ anchor: Joi.number().integer().min(0).optional().allow(null).default(0)
21
+ });
22
+ const tokenLimit = Joi.object({
23
+ address: Joi.DID().prefix().role("ROLE_TOKEN").required(),
24
+ toList: Joi.array().items(Joi.DID().prefix()).max(32).unique().optional().allow(null).default([]),
25
+ txCount: Joi.number().integer().min(0).empty("").optional().allow(null).default(0),
26
+ txAllowance: Joi.BN().optional().allow(null).default("0"),
27
+ totalAllowance: Joi.BN().optional().allow(null).default("0"),
28
+ validUntil: Joi.number().integer().min(0).empty("").optional().allow(null).default(0),
29
+ rate: rateLimit.optional().allow(null)
30
+ });
31
+ const assetLimit = Joi.object({
32
+ address: Joi.array().items(Joi.DID().prefix().role("ROLE_ASSET")).unique().max(1024).optional().allow(null).default([]),
33
+ toList: Joi.array().items(Joi.DID().prefix()).unique().max(32).optional().allow(null).default([]),
34
+ txCount: Joi.number().integer().min(0).empty("").optional().allow(null).default(0),
35
+ validUntil: Joi.number().integer().min(0).empty("").optional().allow(null).default(0),
36
+ rate: rateLimit.optional().allow(null)
37
+ });
38
+ const schema = Joi.object({
39
+ address: Joi.DID().prefix().role("ROLE_DELEGATION").required(),
40
+ to: Joi.DID().prefix().required(),
41
+ opsList: Joi.array().items(Joi.object({
42
+ typeUrl: Joi.string().required(),
43
+ limit: Joi.object({
44
+ tokensList: Joi.array().items(tokenLimit).unique((a, b) => a.address === b.address).max(32),
45
+ assetsList: Joi.array().items(assetLimit).max(32)
46
+ }).optional().allow(null).default({
47
+ tokensList: [],
48
+ assetsList: []
49
+ })
50
+ })).unique((a, b) => a.typeUrl === b.typeUrl).min(1).required(),
51
+ data: Joi.any().optional().allow(null)
52
+ }).options({
53
+ stripUnknown: true,
54
+ noDefaults: false
55
+ });
56
+ runner.use((context, next) => {
57
+ const { error, value } = schema.validate(context.itx);
58
+ if (error) return next(new CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
59
+ context.formattedItx = formatMessage("DelegateTx", context.itx);
60
+ context.validatedItx = value;
61
+ return next();
62
+ });
63
+ runner.use(pipes.VerifyInfo([{
64
+ error: "INVALID_TX",
65
+ message: "Delegation address does not match",
66
+ fn: (ctx) => {
67
+ const context = ctx;
68
+ return toDelegateAddress(context.tx.from, context.itx.to) === context.itx.address;
69
+ }
70
+ }, {
71
+ error: "INVALID_DELEGATION_TYPE_URL",
72
+ message: "Delegation type url is not allowed",
73
+ fn: (ctx) => {
74
+ const context = ctx;
75
+ const allowed = get(context.config, "transaction.delegate.typeUrls", []);
76
+ return (context.formattedItx?.ops || []).every((op) => allowed.includes(op.typeUrl));
77
+ }
78
+ }]));
79
+ runner.use(pipes.ExtractState({
80
+ from: "tx.from",
81
+ to: "senderState",
82
+ status: "OK",
83
+ table: "account"
84
+ }));
85
+ runner.use(pipes.VerifyAccountMigration({
86
+ stateKey: "senderState",
87
+ addressKey: "tx.from"
88
+ }));
89
+ runner.use(pipes.ExtractState({
90
+ from: "itx.to",
91
+ to: "receiverState",
92
+ status: "OK",
93
+ table: "account"
94
+ }));
95
+ runner.use(pipes.VerifyBlocked({ stateKeys: ["receiverState"] }));
96
+ runner.use(pipes.VerifyAccountMigration({
97
+ stateKey: "receiverState",
98
+ addressKey: "itx.to"
99
+ }));
100
+ runner.use(pipes.AntiLandAttack({
101
+ senderState: "senderState",
102
+ receiverState: "receiverState"
103
+ }));
104
+ runner.use(pipes.ExtractState({
105
+ from: "itx.address",
106
+ to: "delegationState",
107
+ table: "delegation",
108
+ status: "OK"
109
+ }));
110
+ runner.use(ensure_gas_default((context) => {
111
+ const result = {
112
+ create: 0,
113
+ update: 1,
114
+ payment: 0
115
+ };
116
+ if (context.receiverState) result.update += 1;
117
+ else result.create += 1;
118
+ if (context.delegationState) result.update += 1;
119
+ else result.create += 1;
120
+ return result;
121
+ }));
122
+ runner.use(ensure_cost_default({ attachSenderChanges: true }));
123
+ runner.use(pipes.TakeStateSnapshot());
124
+ runner.use(async (context, next) => {
125
+ const { tx: tx$1, itx, formattedItx, validatedItx, statedb, senderState, receiverState, delegationState, senderUpdates, updateVaults } = context;
126
+ const ops = formattedItx?.ops || [];
127
+ const opsList = validatedItx?.opsList || [];
128
+ const merged = cloneDeep(ops).reduce((acc, x, i) => {
129
+ const tokens = x.limit?.tokens || [];
130
+ const assets = x.limit?.assets || [];
131
+ acc[x.typeUrl] = { limit: {
132
+ tokens: tokens.map((y, j) => {
133
+ const input = opsList[i]?.limit?.tokensList?.[j] || {};
134
+ return Object.assign(y, pick(input, [
135
+ "txCount",
136
+ "txAllowance",
137
+ "totalAllowance",
138
+ "validUntil",
139
+ "rate"
140
+ ]), {
141
+ txSent: 0,
142
+ lastTx: y.rate ? y.rate.anchor : 0,
143
+ spentAllowance: "0"
144
+ });
145
+ }),
146
+ assets: assets.map((y, j) => {
147
+ const input = opsList[i]?.limit?.assetsList?.[j] || {};
148
+ return Object.assign(y, pick(input, [
149
+ "txCount",
150
+ "validUntil",
151
+ "rate"
152
+ ]), {
153
+ txSent: 0,
154
+ lastTx: y.rate ? y.rate.anchor : 0
155
+ });
156
+ })
157
+ } };
158
+ return acc;
159
+ }, delegationState ? delegationState.ops : {});
160
+ const sender = senderState ? senderState.address : tx$1.from;
161
+ const receiver = receiverState ? receiverState.address : itx.to;
162
+ const tokenAddress = context.config.token.address;
163
+ const [newSenderState, newReceiverState, newDelegationState] = await Promise.all([
164
+ statedb.account.updateOrCreate(senderState ?? null, account.updateOrCreate(senderState ?? null, {
165
+ ...senderUpdates,
166
+ address: sender,
167
+ nonce: tx$1.nonce,
168
+ pk: tx$1.pk
169
+ }, context), context),
170
+ receiverState ? Promise.resolve(receiverState) : statedb.account.create(receiver, account.create({
171
+ address: receiver,
172
+ tokens: { [tokenAddress]: "0" }
173
+ }, context), context),
174
+ delegationState ? statedb.delegation.update(itx.address, delegation.update(delegationState, {
175
+ ...itx,
176
+ from: sender,
177
+ ops: merged
178
+ }, context), context) : statedb.delegation.create(itx.address, delegation.create({
179
+ ...itx,
180
+ from: sender,
181
+ ops: merged
182
+ }, context), context)
183
+ ]);
184
+ if (updateVaults) await updateVaults();
185
+ debug(delegationState ? "update" : "create", newDelegationState);
186
+ context.senderState = newSenderState;
187
+ context.receiverState = newReceiverState;
188
+ context.delegationState = newDelegationState;
189
+ return next();
190
+ }, { persistError: true });
191
+ runner.use(pipes.VerifyStateDiff());
192
+ var delegate_default = runner;
193
+
194
+ //#endregion
195
+ export { delegate_default as default };
@@ -0,0 +1,4 @@
1
+ //#region src/protocols/account/migrate.d.ts
2
+ declare const runner: any;
3
+ //#endregion
4
+ export { runner as default };
@@ -0,0 +1,130 @@
1
+ import { decodeAnySafe } from "../../util.mjs";
2
+ import ensure_cost_default from "../../pipes/ensure-cost.mjs";
3
+ import ensure_gas_default from "../../pipes/ensure-gas.mjs";
4
+ import { Runner, pipes } from "@ocap/tx-pipeline";
5
+ import { CustomError } from "@ocap/util/lib/error";
6
+ import { fromPublicKey, toTypeInfo } from "@arcblock/did";
7
+ import { account } from "@ocap/state";
8
+ import Debug from "debug";
9
+ import { Joi } from "@arcblock/validator";
10
+ import { types } from "@ocap/mcrypto";
11
+ import { getRelatedAddresses } from "@ocap/util/lib/get-related-addr";
12
+ import flatten from "lodash/flatten.js";
13
+ import uniq from "lodash/uniq.js";
14
+
15
+ //#region src/protocols/account/migrate.ts
16
+ const { RoleType } = types;
17
+ const debug = Debug("@ocap/tx-protocols:migrate");
18
+ const runner = new Runner("account_migrate");
19
+ runner.use(pipes.VerifyMultiSig(0));
20
+ const schema = Joi.object({
21
+ address: Joi.DID().prefix().required(),
22
+ pk: Joi.any().required(),
23
+ data: Joi.any().optional().allow(null)
24
+ }).options({
25
+ stripUnknown: true,
26
+ noDefaults: false
27
+ });
28
+ runner.use((context, next) => {
29
+ const { error } = schema.validate(context.itx);
30
+ if (error) return next(new CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
31
+ return next();
32
+ });
33
+ runner.use(pipes.VerifyInfo([{
34
+ error: "INVALID_RECEIVER_STATE",
35
+ message: "Receiver pk and address does not match",
36
+ fn: (ctx) => {
37
+ const context = ctx;
38
+ return fromPublicKey(context.itx.pk, toTypeInfo(context.itx.address)) === context.itx.address && context.itx.address !== context.tx.from;
39
+ }
40
+ }]));
41
+ runner.use(pipes.ExtractState({
42
+ from: "tx.from",
43
+ to: "senderState",
44
+ status: "OK",
45
+ table: "account"
46
+ }));
47
+ runner.use(pipes.VerifyAccountMigration({
48
+ stateKey: "senderState",
49
+ addressKey: "tx.from"
50
+ }));
51
+ runner.use(ensure_gas_default((context) => {
52
+ const { senderState, tx: tx$1, itx } = context;
53
+ if ([senderState?.address || tx$1.from, itx.address].every((address) => toTypeInfo(address).role === RoleType.ROLE_APPLICATION)) {
54
+ Object.defineProperty(context, "txBaseGas", { value: false });
55
+ return {
56
+ create: 0,
57
+ update: 0,
58
+ payment: 0
59
+ };
60
+ }
61
+ if (itx.data) {
62
+ const decodedValue = decodeAnySafe(itx.data)?.value;
63
+ if (decodedValue && decodedValue.purpose === "connect-wallet") {
64
+ Object.defineProperty(context, "txBaseGas", { value: false });
65
+ return {
66
+ create: 0,
67
+ update: 0,
68
+ payment: 0
69
+ };
70
+ }
71
+ }
72
+ return {
73
+ create: context.senderState ? 1 : 2,
74
+ update: context.senderState ? getRelatedAddresses(context.senderState).length : 0,
75
+ payment: 0
76
+ };
77
+ }));
78
+ runner.use(ensure_cost_default({
79
+ attachSenderChanges: true,
80
+ throwOnInsufficientFund: false
81
+ }));
82
+ runner.use(pipes.TakeStateSnapshot());
83
+ runner.use(async (context, next) => {
84
+ const { statedb, tx: tx$1, itx, senderUpdates, updateVaults } = context;
85
+ const sender = context.senderState;
86
+ const receiver = await statedb.account.get(itx.address, context);
87
+ const tokenAddress = context.config.token.address;
88
+ const senderTokens = sender?.tokens || { [tokenAddress]: "0" };
89
+ const senderAddress = sender?.address || tx$1.from;
90
+ if (receiver) return next(new CustomError("INVALID_RECEIVER_STATE", "Can not migrate to an existing account"));
91
+ const newAccount = await statedb.account.create(itx.address, account.create({
92
+ ...sender || { tokens: senderTokens },
93
+ ...senderUpdates,
94
+ address: itx.address,
95
+ pk: itx.pk,
96
+ migratedFrom: sender ? uniq(flatten([sender.address, ...sender.migratedFrom || []])) : [senderAddress]
97
+ }, context), context);
98
+ debug("new account", newAccount);
99
+ const addresses = sender ? getRelatedAddresses(sender) : [senderAddress];
100
+ const states = await Promise.all(addresses.map(async (address) => {
101
+ let state;
102
+ if (address === senderAddress) {
103
+ state = account.updateOrCreate(sender ?? null, {
104
+ address,
105
+ tokens: senderTokens,
106
+ migratedTo: [itx.address],
107
+ nonce: tx$1.nonce
108
+ }, context);
109
+ await statedb.account.updateOrCreate(sender ?? null, state, context);
110
+ } else {
111
+ const old = await statedb.account.get(address, {
112
+ traceMigration: false,
113
+ txn: context.txn
114
+ });
115
+ state = account.update(old, { migratedTo: [itx.address] }, context);
116
+ await statedb.account.update(address, state, context);
117
+ }
118
+ return state;
119
+ }));
120
+ debug("old accounts", states);
121
+ if (updateVaults) await updateVaults();
122
+ context.receiverState = newAccount;
123
+ context.senderState = states.find((x) => x.address === senderAddress);
124
+ return next();
125
+ }, { persistError: true });
126
+ runner.use(pipes.VerifyStateDiff());
127
+ var migrate_default = runner;
128
+
129
+ //#endregion
130
+ export { migrate_default as default };
@@ -0,0 +1,4 @@
1
+ //#region src/protocols/account/revoke-delegate.d.ts
2
+ declare const runner: any;
3
+ //#endregion
4
+ export { runner as default };
@@ -0,0 +1,102 @@
1
+ import ensure_cost_default from "../../pipes/ensure-cost.mjs";
2
+ import ensure_gas_default from "../../pipes/ensure-gas.mjs";
3
+ import { Runner, pipes } from "@ocap/tx-pipeline";
4
+ import { CustomError } from "@ocap/util/lib/error";
5
+ import get from "lodash/get.js";
6
+ import { toDelegateAddress } from "@arcblock/did-util";
7
+ import { account, delegation } from "@ocap/state";
8
+ import Debug from "debug";
9
+ import { getListField } from "@ocap/util/lib/get-list-field";
10
+ import cloneDeep from "lodash/cloneDeep.js";
11
+ import { Joi } from "@arcblock/validator";
12
+
13
+ //#region src/protocols/account/revoke-delegate.ts
14
+ const debug = Debug("@ocap/tx-protocols:delegate");
15
+ const runner = new Runner("revoke_delegate");
16
+ runner.use(pipes.VerifyMultiSig(0));
17
+ const schema = Joi.object({
18
+ address: Joi.DID().prefix().role("ROLE_DELEGATION").required(),
19
+ to: Joi.DID().prefix().required(),
20
+ typeUrlsList: Joi.array().items(Joi.string().required()).min(1).required(),
21
+ data: Joi.any().optional().allow(null)
22
+ }).options({
23
+ stripUnknown: true,
24
+ noDefaults: false
25
+ });
26
+ runner.use((context, next) => {
27
+ const { error } = schema.validate(context.itx);
28
+ if (error) return next(new CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
29
+ return next();
30
+ });
31
+ runner.use(pipes.VerifyInfo([
32
+ {
33
+ error: "OK",
34
+ fn: (ctx) => {
35
+ const context = ctx;
36
+ context.typeUrls = getListField(context, "itx.typeUrls");
37
+ return true;
38
+ }
39
+ },
40
+ {
41
+ error: "INVALID_TX",
42
+ message: "Delegation address does not match",
43
+ fn: (ctx) => {
44
+ const context = ctx;
45
+ return toDelegateAddress(context.tx.from, context.itx.to) === context.itx.address;
46
+ }
47
+ },
48
+ {
49
+ error: "INVALID_DELEGATION_TYPE_URL",
50
+ message: "Delegation type url is not allowed",
51
+ fn: (ctx) => {
52
+ const context = ctx;
53
+ const allowed = get(context.config, "transaction.delegate.typeUrls", []);
54
+ return (context.typeUrls || []).every((x) => allowed.includes(x));
55
+ }
56
+ }
57
+ ]));
58
+ runner.use(pipes.ExtractState({
59
+ from: "itx.address",
60
+ to: "delegationState",
61
+ status: "INVALID_DELEGATION",
62
+ table: "delegation"
63
+ }));
64
+ runner.use(pipes.ExtractState({
65
+ from: "tx.from",
66
+ to: "senderState",
67
+ status: "INVALID_SENDER_STATE",
68
+ table: "account"
69
+ }));
70
+ runner.use(pipes.VerifyAccountMigration({
71
+ stateKey: "senderState",
72
+ addressKey: "tx.from"
73
+ }));
74
+ runner.use(ensure_gas_default(() => ({
75
+ create: 0,
76
+ update: 2,
77
+ payment: 0
78
+ })));
79
+ runner.use(ensure_cost_default({ attachSenderChanges: true }));
80
+ runner.use(pipes.TakeStateSnapshot());
81
+ runner.use(async (context, next) => {
82
+ const { tx: tx$1, itx, typeUrls, statedb, senderState, senderUpdates, delegationState, updateVaults } = context;
83
+ debug("update", {
84
+ address: itx.address,
85
+ typeUrls
86
+ });
87
+ const newOps = cloneDeep(delegationState.ops);
88
+ (typeUrls || []).forEach((x) => delete newOps[x]);
89
+ const [newSenderState, newDelegationState] = await Promise.all([statedb.account.update(senderState.address, account.update(senderState, {
90
+ ...senderUpdates,
91
+ nonce: tx$1.nonce
92
+ }, context), context), statedb.delegation.update(itx.address, delegation.update(delegationState, { ops: newOps }, context), context)]);
93
+ if (updateVaults) await updateVaults();
94
+ context.senderState = newSenderState;
95
+ context.delegationState = newDelegationState;
96
+ return next();
97
+ }, { persistError: true });
98
+ runner.use(pipes.VerifyStateDiff());
99
+ var revoke_delegate_default = runner;
100
+
101
+ //#endregion
102
+ export { revoke_delegate_default as default };
@@ -0,0 +1,9 @@
1
+ //#region src/protocols/asset/acquire-v2.d.ts
2
+ /** Token input type */
3
+ interface TokenInput {
4
+ address: string;
5
+ value: string;
6
+ }
7
+ declare const runner: any;
8
+ //#endregion
9
+ export { TokenInput, runner as default };
@@ -0,0 +1,213 @@
1
+ import { applyTokenChange, applyTokenUpdates } from "../../util.mjs";
2
+ import ensure_cost_default from "../../pipes/ensure-cost.mjs";
3
+ import ensure_gas_default from "../../pipes/ensure-gas.mjs";
4
+ import exec_mint_hook_default from "./pipes/exec-mint-hook.mjs";
5
+ import extract_factory_tokens_default from "./pipes/extract-factory-tokens.mjs";
6
+ import verify_itx_address_default from "./pipes/verify-itx-address.mjs";
7
+ import verify_itx_assets_default from "./pipes/verify-itx-assets.mjs";
8
+ import verify_itx_variables_default from "./pipes/verify-itx-variables.mjs";
9
+ import verify_mint_limit_default from "./pipes/verify-mint-limit.mjs";
10
+ import { Runner, pipes } from "@ocap/tx-pipeline";
11
+ import { CustomError } from "@ocap/util/lib/error";
12
+ import { account, asset, delegation, factory } from "@ocap/state";
13
+ import Debug from "debug";
14
+ import { Joi, schemas } from "@arcblock/validator";
15
+ import { promisify } from "node:util";
16
+
17
+ //#region src/protocols/asset/acquire-v2.ts
18
+ const debug = Debug("@ocap/tx-protocols:acquire-asset-v2");
19
+ const verifyTokenBalance = promisify(pipes.VerifyTokenBalance({
20
+ ownerKey: "senders",
21
+ conditionKey: "conditions"
22
+ }));
23
+ const runner = new Runner("acquire_asset_v2");
24
+ runner.use(pipes.VerifyMultiSig(0));
25
+ const schema = Joi.object({
26
+ factory: Joi.DID().prefix().role("ROLE_FACTORY").required(),
27
+ address: Joi.DID().prefix().role("ROLE_ASSET").required(),
28
+ assetsList: Joi.array().items(Joi.DID().prefix().role("ROLE_ASSET")).default([]),
29
+ variablesList: Joi.array().items(schemas.variableInput).optional().allow(null).default([]),
30
+ issuer: schemas.nftIssuer.required(),
31
+ data: Joi.any().optional().allow(null)
32
+ }).options({
33
+ stripUnknown: true,
34
+ noDefaults: false
35
+ });
36
+ runner.use(({ itx }, next) => {
37
+ const { error } = schema.validate(itx);
38
+ if (error) return next(new CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
39
+ return next();
40
+ });
41
+ runner.use(pipes.ExtractState({
42
+ from: "itx.address",
43
+ to: "duplicateAsset",
44
+ status: "OK",
45
+ table: "asset"
46
+ }));
47
+ runner.use(pipes.VerifyInfo([{
48
+ error: "FORBIDDEN",
49
+ message: "Asset with same address already exists",
50
+ fn: (ctx) => {
51
+ return !ctx.duplicateAsset;
52
+ },
53
+ persist: true
54
+ }]));
55
+ runner.use(pipes.ExtractState({
56
+ from: "tx.from",
57
+ to: "senderState",
58
+ status: "INVALID_SENDER_STATE",
59
+ table: "account"
60
+ }));
61
+ runner.use(pipes.VerifyAccountMigration({
62
+ stateKey: "senderState",
63
+ addressKey: "tx.from"
64
+ }));
65
+ runner.use(pipes.ExtractState({
66
+ from: "tx.delegator",
67
+ to: "delegatorState",
68
+ status: "OK"
69
+ }));
70
+ runner.use(pipes.ExtractState({
71
+ from: "itx.factory",
72
+ to: "factoryState",
73
+ status: "INVALID_FACTORY_STATE",
74
+ table: "factory"
75
+ }));
76
+ runner.use(pipes.VerifyDelegation({
77
+ type: "signature",
78
+ signerKey: "senderState",
79
+ delegatorKey: "delegatorState",
80
+ getRequirements: (context) => {
81
+ return context.factoryState.input.tokens.map((x) => ({
82
+ type: "token",
83
+ ...x
84
+ }));
85
+ }
86
+ }));
87
+ runner.use(pipes.ExtractState({
88
+ from: "factoryState.owner",
89
+ to: "factoryOwnerState",
90
+ status: "INVALID_OWNER_STATE",
91
+ table: "account"
92
+ }));
93
+ runner.use(pipes.ExtractState({
94
+ from: "factoryState.trustedIssuers",
95
+ to: "issuerStates",
96
+ status: "INVALID_ISSUER_STATE",
97
+ table: "account"
98
+ }));
99
+ runner.use(pipes.ExtractState({
100
+ from: "itx.issuer.id",
101
+ to: "issuerState",
102
+ status: "INVALID_ISSUER_STATE",
103
+ table: "account"
104
+ }));
105
+ runner.use(pipes.VerifyAccountMigration({
106
+ stateKey: "issuerState",
107
+ addressKey: "itx.issuer.id"
108
+ }));
109
+ runner.use(pipes.VerifyInfo([{
110
+ error: "FORBIDDEN",
111
+ message: "Only factory owner and trusted issuers are allowed",
112
+ fn: (ctx) => {
113
+ const { issuerState, factoryOwnerState, issuerStates = [] } = ctx;
114
+ return factoryOwnerState.address === issuerState.address || !!issuerStates.find((x) => x.address === issuerState.address);
115
+ },
116
+ persist: true
117
+ }]));
118
+ runner.use(pipes.ExtractState({
119
+ from: "itx.assetsList",
120
+ to: "assetStates",
121
+ status: "OK",
122
+ table: "asset"
123
+ }));
124
+ runner.use(pipes.ExtractState({
125
+ from: "factoryState.input.assets",
126
+ to: "expectedFactoryStates",
127
+ status: "OK",
128
+ table: "factory"
129
+ }));
130
+ runner.use(extract_factory_tokens_default);
131
+ runner.use(pipes.ExtractState({
132
+ from: "tokenAddress",
133
+ to: "tokenStates",
134
+ status: "INVALID_TOKEN",
135
+ table: "token"
136
+ }));
137
+ runner.use(verify_mint_limit_default);
138
+ runner.use(verify_itx_variables_default);
139
+ runner.use(verify_itx_address_default("acquire-v2"));
140
+ runner.use(pipes.VerifyBlocked({ stateKeys: ["assetOwner"] }));
141
+ runner.use(async (context, next) => {
142
+ const { factoryTokens = [], senderState } = context;
143
+ const condition = {
144
+ owner: senderState.address,
145
+ tokens: [...factoryTokens]
146
+ };
147
+ try {
148
+ await verifyTokenBalance({
149
+ senders: [senderState],
150
+ conditions: [condition]
151
+ });
152
+ return next();
153
+ } catch (err) {
154
+ return next(err);
155
+ }
156
+ });
157
+ runner.use(pipes.VerifyUpdater({
158
+ assetKey: "assetStates",
159
+ ownerKey: "assetOwner"
160
+ }));
161
+ runner.use(verify_itx_assets_default);
162
+ runner.use(ensure_gas_default((context) => {
163
+ const result = {
164
+ create: 1,
165
+ update: 3,
166
+ payment: 0
167
+ };
168
+ if (context.assetStates) result.update += context.assetStates.length;
169
+ if (context.delegatorState) result.update += 1;
170
+ return result;
171
+ }));
172
+ runner.use(ensure_cost_default({ attachSenderChanges: true }));
173
+ runner.use(pipes.TakeStateSnapshot());
174
+ runner.use(async (context, next) => {
175
+ const { tx: tx$1, itx, txTime, statedb, senderState, assetOwner, factoryState, factoryTokens = [], delegationState, mintedAsset, mintedAddress, senderChange, updateVaults, assetStates = [] } = context;
176
+ const senderUpdates = {
177
+ nonce: tx$1.nonce,
178
+ pk: tx$1.pk,
179
+ ...applyTokenUpdates(factoryTokens, senderChange ? applyTokenChange(senderState, senderChange) : senderState, "sub")
180
+ };
181
+ const ownerUpdates = {};
182
+ const factoryUpdates = { numMinted: factoryState.numMinted + 1 };
183
+ if (factoryState.settlement !== "instant") {
184
+ Object.assign(factoryUpdates, applyTokenUpdates(factoryTokens, factoryState, "add"));
185
+ context.tokenUpdates = applyTokenUpdates(factoryTokens, { tokens: {} }, "add");
186
+ }
187
+ const [newSenderState, assetState, newFactoryState, newAssetStates, newDelegationState] = await Promise.all([
188
+ statedb.account.update(senderState.address, account.update(senderState, senderUpdates, context), context),
189
+ statedb.asset.create(itx.address, asset.create({
190
+ ...mintedAsset,
191
+ owner: assetOwner.address,
192
+ address: mintedAddress
193
+ }, context), context),
194
+ statedb.factory.update(factoryState.address, factory.update(factoryState, factoryUpdates, context), context),
195
+ Promise.all(assetStates.map((x) => statedb.asset.update(x.address, asset.update(x, { consumedTime: txTime }, context), context))),
196
+ context.isDelegationChanged ? statedb.delegation.update(delegationState.address, delegation.update(delegationState, {}, context), context) : delegationState,
197
+ context.delegatorState ? statedb.account.update(assetOwner.address, account.update(assetOwner, ownerUpdates, context), context) : null
198
+ ]);
199
+ if (updateVaults) await updateVaults();
200
+ context.senderState = newSenderState;
201
+ context.assetState = assetState;
202
+ context.factoryState = newFactoryState;
203
+ context.assetStates = newAssetStates;
204
+ context.delegationState = newDelegationState ?? void 0;
205
+ debug("acquire-v2", assetState);
206
+ next();
207
+ }, { persistError: true });
208
+ runner.use(exec_mint_hook_default, { persistError: true });
209
+ runner.use(pipes.VerifyStateDiff());
210
+ var acquire_v2_default = runner;
211
+
212
+ //#endregion
213
+ export { acquire_v2_default as default };
@@ -0,0 +1,17 @@
1
+ //#region src/protocols/asset/acquire-v3.d.ts
2
+ /** Token input type */
3
+ interface TokenInput {
4
+ address: string;
5
+ value: string;
6
+ }
7
+ /** Multi-input type */
8
+ interface MultiInput {
9
+ owner: string;
10
+ tokensList?: TokenInput[];
11
+ tokens?: TokenInput[];
12
+ assetsList?: string[];
13
+ assets?: string[];
14
+ }
15
+ declare const runner: any;
16
+ //#endregion
17
+ export { MultiInput, TokenInput, runner as default };