@0xtorch/evm 0.0.11 → 0.0.12

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 (410) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/analyzer/analyze.js.map +1 -1
  3. package/_cjs/analyzer/axieMarketplace/analyze.js +37 -130
  4. package/_cjs/analyzer/axieMarketplace/analyze.js.map +1 -1
  5. package/_cjs/analyzer/gasFee/analyze.js +22 -21
  6. package/_cjs/analyzer/gasFee/analyze.js.map +1 -1
  7. package/_cjs/analyzer/index.js +2 -1
  8. package/_cjs/analyzer/index.js.map +1 -1
  9. package/_cjs/analyzer/json/analyze.js +21 -29
  10. package/_cjs/analyzer/json/analyze.js.map +1 -1
  11. package/_cjs/analyzer/json/components/comment.js +47 -0
  12. package/_cjs/analyzer/json/components/comment.js.map +1 -0
  13. package/_cjs/analyzer/json/components/erc1155.js +93 -0
  14. package/_cjs/analyzer/json/components/erc1155.js.map +1 -0
  15. package/_cjs/analyzer/json/components/erc1155Raw.js +31 -0
  16. package/_cjs/analyzer/json/components/erc1155Raw.js.map +1 -0
  17. package/_cjs/analyzer/json/components/erc20.js +90 -0
  18. package/_cjs/analyzer/json/components/erc20.js.map +1 -0
  19. package/_cjs/analyzer/json/components/erc20Raw.js +28 -0
  20. package/_cjs/analyzer/json/components/erc20Raw.js.map +1 -0
  21. package/_cjs/analyzer/json/components/erc721.js +78 -0
  22. package/_cjs/analyzer/json/components/erc721.js.map +1 -0
  23. package/_cjs/analyzer/json/components/erc721Raw.js +29 -0
  24. package/_cjs/analyzer/json/components/erc721Raw.js.map +1 -0
  25. package/_cjs/analyzer/json/components/id.js +47 -0
  26. package/_cjs/analyzer/json/components/id.js.map +1 -0
  27. package/_cjs/analyzer/json/components/internal.js +78 -0
  28. package/_cjs/analyzer/json/components/internal.js.map +1 -0
  29. package/_cjs/analyzer/json/components/internalRaw.js +26 -0
  30. package/_cjs/analyzer/json/components/internalRaw.js.map +1 -0
  31. package/_cjs/analyzer/json/components/logArgument.js +67 -0
  32. package/_cjs/analyzer/json/components/logArgument.js.map +1 -0
  33. package/_cjs/analyzer/json/components/logArgumentRaw.js +41 -0
  34. package/_cjs/analyzer/json/components/logArgumentRaw.js.map +1 -0
  35. package/_cjs/analyzer/json/components/transfer.js +435 -0
  36. package/_cjs/analyzer/json/components/transfer.js.map +1 -0
  37. package/_cjs/analyzer/json/condition/address.js +106 -0
  38. package/_cjs/analyzer/json/condition/address.js.map +1 -0
  39. package/_cjs/analyzer/json/condition/argumentValue.js +31 -0
  40. package/_cjs/analyzer/json/condition/argumentValue.js.map +1 -0
  41. package/_cjs/analyzer/json/condition/index.js +10 -0
  42. package/_cjs/analyzer/json/condition/index.js.map +1 -0
  43. package/_cjs/analyzer/json/condition/value.js +65 -0
  44. package/_cjs/analyzer/json/condition/value.js.map +1 -0
  45. package/_cjs/analyzer/json/generator.js +774 -0
  46. package/_cjs/analyzer/json/generator.js.map +1 -0
  47. package/_cjs/analyzer/json/index.js +3 -1
  48. package/_cjs/analyzer/json/index.js.map +1 -1
  49. package/_cjs/analyzer/json/schemas/generator.js +279 -0
  50. package/_cjs/analyzer/json/schemas/generator.js.map +1 -0
  51. package/_cjs/analyzer/json/schemas/index.js +303 -0
  52. package/_cjs/analyzer/json/schemas/index.js.map +1 -0
  53. package/_cjs/analyzer/json/schemas/utils.js +14 -0
  54. package/_cjs/analyzer/json/schemas/utils.js.map +1 -0
  55. package/_cjs/analyzer/parsers/transfer.js +149 -0
  56. package/_cjs/analyzer/parsers/transfer.js.map +1 -0
  57. package/_cjs/analyzer/seaport/analyze.js +165 -157
  58. package/_cjs/analyzer/seaport/analyze.js.map +1 -1
  59. package/_cjs/analyzer/spam/analyze.js +61 -90
  60. package/_cjs/analyzer/spam/analyze.js.map +1 -1
  61. package/_cjs/analyzer/swap/analyze.js +50 -75
  62. package/_cjs/analyzer/swap/analyze.js.map +1 -1
  63. package/_cjs/analyzer/transfer/analyze.js +37 -84
  64. package/_cjs/analyzer/transfer/analyze.js.map +1 -1
  65. package/_cjs/index.js +3 -2
  66. package/_cjs/index.js.map +1 -1
  67. package/_cjs/utils/create.js +28 -0
  68. package/_cjs/utils/create.js.map +1 -0
  69. package/_cjs/utils/index.js +3 -1
  70. package/_cjs/utils/index.js.map +1 -1
  71. package/_esm/analyzer/analyze.js.map +1 -1
  72. package/_esm/analyzer/axieMarketplace/analyze.js +37 -130
  73. package/_esm/analyzer/axieMarketplace/analyze.js.map +1 -1
  74. package/_esm/analyzer/gasFee/analyze.js +23 -21
  75. package/_esm/analyzer/gasFee/analyze.js.map +1 -1
  76. package/_esm/analyzer/index.js +1 -1
  77. package/_esm/analyzer/index.js.map +1 -1
  78. package/_esm/analyzer/json/analyze.js +22 -29
  79. package/_esm/analyzer/json/analyze.js.map +1 -1
  80. package/_esm/analyzer/json/components/comment.js +43 -0
  81. package/_esm/analyzer/json/components/comment.js.map +1 -0
  82. package/_esm/analyzer/json/components/erc1155.js +88 -0
  83. package/_esm/analyzer/json/components/erc1155.js.map +1 -0
  84. package/_esm/analyzer/json/components/erc1155Raw.js +27 -0
  85. package/_esm/analyzer/json/components/erc1155Raw.js.map +1 -0
  86. package/_esm/analyzer/json/components/erc20.js +85 -0
  87. package/_esm/analyzer/json/components/erc20.js.map +1 -0
  88. package/_esm/analyzer/json/components/erc20Raw.js +24 -0
  89. package/_esm/analyzer/json/components/erc20Raw.js.map +1 -0
  90. package/_esm/analyzer/json/components/erc721.js +73 -0
  91. package/_esm/analyzer/json/components/erc721.js.map +1 -0
  92. package/_esm/analyzer/json/components/erc721Raw.js +25 -0
  93. package/_esm/analyzer/json/components/erc721Raw.js.map +1 -0
  94. package/_esm/analyzer/json/components/id.js +43 -0
  95. package/_esm/analyzer/json/components/id.js.map +1 -0
  96. package/_esm/analyzer/json/components/internal.js +73 -0
  97. package/_esm/analyzer/json/components/internal.js.map +1 -0
  98. package/_esm/analyzer/json/components/internalRaw.js +22 -0
  99. package/_esm/analyzer/json/components/internalRaw.js.map +1 -0
  100. package/_esm/analyzer/json/components/logArgument.js +62 -0
  101. package/_esm/analyzer/json/components/logArgument.js.map +1 -0
  102. package/_esm/analyzer/json/components/logArgumentRaw.js +37 -0
  103. package/_esm/analyzer/json/components/logArgumentRaw.js.map +1 -0
  104. package/_esm/analyzer/json/components/transfer.js +431 -0
  105. package/_esm/analyzer/json/components/transfer.js.map +1 -0
  106. package/_esm/analyzer/json/condition/address.js +102 -0
  107. package/_esm/analyzer/json/condition/address.js.map +1 -0
  108. package/_esm/analyzer/json/condition/argumentValue.js +27 -0
  109. package/_esm/analyzer/json/condition/argumentValue.js.map +1 -0
  110. package/_esm/analyzer/json/condition/index.js +4 -0
  111. package/_esm/analyzer/json/condition/index.js.map +1 -0
  112. package/_esm/analyzer/json/condition/value.js +61 -0
  113. package/_esm/analyzer/json/condition/value.js.map +1 -0
  114. package/_esm/analyzer/json/generator.js +825 -0
  115. package/_esm/analyzer/json/generator.js.map +1 -0
  116. package/_esm/analyzer/json/index.js +1 -0
  117. package/_esm/analyzer/json/index.js.map +1 -1
  118. package/_esm/analyzer/json/schemas/generator.js +340 -0
  119. package/_esm/analyzer/json/schemas/generator.js.map +1 -0
  120. package/_esm/analyzer/json/schemas/index.js +299 -0
  121. package/_esm/analyzer/json/schemas/index.js.map +1 -0
  122. package/_esm/analyzer/json/schemas/utils.js +11 -0
  123. package/_esm/analyzer/json/schemas/utils.js.map +1 -0
  124. package/_esm/analyzer/parsers/transfer.js +129 -0
  125. package/_esm/analyzer/parsers/transfer.js.map +1 -0
  126. package/_esm/analyzer/seaport/analyze.js +166 -157
  127. package/_esm/analyzer/seaport/analyze.js.map +1 -1
  128. package/_esm/analyzer/spam/analyze.js +62 -92
  129. package/_esm/analyzer/spam/analyze.js.map +1 -1
  130. package/_esm/analyzer/swap/analyze.js +51 -75
  131. package/_esm/analyzer/swap/analyze.js.map +1 -1
  132. package/_esm/analyzer/transfer/analyze.js +38 -86
  133. package/_esm/analyzer/transfer/analyze.js.map +1 -1
  134. package/_esm/index.js +1 -1
  135. package/_esm/index.js.map +1 -1
  136. package/_esm/utils/create.js +21 -0
  137. package/_esm/utils/create.js.map +1 -0
  138. package/_esm/utils/index.js +1 -0
  139. package/_esm/utils/index.js.map +1 -1
  140. package/_types/analyzer/analyze.d.ts +11 -16
  141. package/_types/analyzer/analyze.d.ts.map +1 -1
  142. package/_types/analyzer/analyzer.d.ts +9 -1
  143. package/_types/analyzer/analyzer.d.ts.map +1 -1
  144. package/_types/analyzer/axieMarketplace/analyze.d.ts +9 -2
  145. package/_types/analyzer/axieMarketplace/analyze.d.ts.map +1 -1
  146. package/_types/analyzer/gasFee/analyze.d.ts +9 -2
  147. package/_types/analyzer/gasFee/analyze.d.ts.map +1 -1
  148. package/_types/analyzer/index.d.ts +1 -1
  149. package/_types/analyzer/index.d.ts.map +1 -1
  150. package/_types/analyzer/json/analyze.d.ts +9 -2
  151. package/_types/analyzer/json/analyze.d.ts.map +1 -1
  152. package/_types/analyzer/json/components/comment.d.ts +20 -0
  153. package/_types/analyzer/json/components/comment.d.ts.map +1 -0
  154. package/_types/analyzer/json/components/erc1155.d.ts +32 -0
  155. package/_types/analyzer/json/components/erc1155.d.ts.map +1 -0
  156. package/_types/analyzer/json/components/erc1155Raw.d.ts +18 -0
  157. package/_types/analyzer/json/components/erc1155Raw.d.ts.map +1 -0
  158. package/_types/analyzer/json/components/erc20.d.ts +32 -0
  159. package/_types/analyzer/json/components/erc20.d.ts.map +1 -0
  160. package/_types/analyzer/json/components/erc20Raw.d.ts +18 -0
  161. package/_types/analyzer/json/components/erc20Raw.d.ts.map +1 -0
  162. package/_types/analyzer/json/components/erc721.d.ts +32 -0
  163. package/_types/analyzer/json/components/erc721.d.ts.map +1 -0
  164. package/_types/analyzer/json/components/erc721Raw.d.ts +18 -0
  165. package/_types/analyzer/json/components/erc721Raw.d.ts.map +1 -0
  166. package/_types/analyzer/json/components/id.d.ts +20 -0
  167. package/_types/analyzer/json/components/id.d.ts.map +1 -0
  168. package/_types/analyzer/json/components/internal.d.ts +32 -0
  169. package/_types/analyzer/json/components/internal.d.ts.map +1 -0
  170. package/_types/analyzer/json/components/internalRaw.d.ts +18 -0
  171. package/_types/analyzer/json/components/internalRaw.d.ts.map +1 -0
  172. package/_types/analyzer/json/components/logArgument.d.ts +32 -0
  173. package/_types/analyzer/json/components/logArgument.d.ts.map +1 -0
  174. package/_types/analyzer/json/components/logArgumentRaw.d.ts +18 -0
  175. package/_types/analyzer/json/components/logArgumentRaw.d.ts.map +1 -0
  176. package/_types/analyzer/json/components/transfer.d.ts +20 -0
  177. package/_types/analyzer/json/components/transfer.d.ts.map +1 -0
  178. package/_types/analyzer/json/condition/address.d.ts +18 -0
  179. package/_types/analyzer/json/condition/address.d.ts.map +1 -0
  180. package/_types/analyzer/json/condition/argumentValue.d.ts +18 -0
  181. package/_types/analyzer/json/condition/argumentValue.d.ts.map +1 -0
  182. package/_types/analyzer/json/condition/index.d.ts +4 -0
  183. package/_types/analyzer/json/condition/index.d.ts.map +1 -0
  184. package/_types/analyzer/json/condition/value.d.ts +18 -0
  185. package/_types/analyzer/json/condition/value.d.ts.map +1 -0
  186. package/_types/analyzer/json/generator.d.ts +20 -0
  187. package/_types/analyzer/json/generator.d.ts.map +1 -0
  188. package/_types/analyzer/json/index.d.ts +1 -0
  189. package/_types/analyzer/json/index.d.ts.map +1 -1
  190. package/_types/analyzer/json/schemas/generator.d.ts +56942 -0
  191. package/_types/analyzer/json/schemas/generator.d.ts.map +1 -0
  192. package/_types/analyzer/json/schemas/index.d.ts +1348 -0
  193. package/_types/analyzer/json/schemas/index.d.ts.map +1 -0
  194. package/_types/analyzer/json/schemas/utils.d.ts +4 -0
  195. package/_types/analyzer/json/schemas/utils.d.ts.map +1 -0
  196. package/_types/analyzer/json/types.d.ts +42 -172
  197. package/_types/analyzer/json/types.d.ts.map +1 -1
  198. package/_types/analyzer/parsers/transfer.d.ts +46 -0
  199. package/_types/analyzer/parsers/transfer.d.ts.map +1 -0
  200. package/_types/analyzer/seaport/analyze.d.ts +9 -2
  201. package/_types/analyzer/seaport/analyze.d.ts.map +1 -1
  202. package/_types/analyzer/seaport/orderFulfilled.d.ts +8 -8
  203. package/_types/analyzer/spam/analyze.d.ts +9 -2
  204. package/_types/analyzer/spam/analyze.d.ts.map +1 -1
  205. package/_types/analyzer/swap/analyze.d.ts +9 -2
  206. package/_types/analyzer/swap/analyze.d.ts.map +1 -1
  207. package/_types/analyzer/transfer/analyze.d.ts +9 -2
  208. package/_types/analyzer/transfer/analyze.d.ts.map +1 -1
  209. package/_types/analyzer/types.d.ts +6 -6
  210. package/_types/analyzer/types.d.ts.map +1 -1
  211. package/_types/decoder/tests.d.ts +2 -2
  212. package/_types/explorers/definitions/blockscout.d.ts +60 -4
  213. package/_types/explorers/definitions/blockscout.d.ts.map +1 -1
  214. package/_types/explorers/definitions/etherscan.d.ts +60 -4
  215. package/_types/explorers/definitions/etherscan.d.ts.map +1 -1
  216. package/_types/explorers/definitions/roninExplorer.d.ts +60 -4
  217. package/_types/explorers/definitions/roninExplorer.d.ts.map +1 -1
  218. package/_types/explorers/externals/blockscout/getInternalTransactionsByAddress.d.ts +2 -2
  219. package/_types/getAccountsTransactionFulls/getAccountsTransactionFulls.d.ts +9 -1
  220. package/_types/getAccountsTransactionFulls/getAccountsTransactionFulls.d.ts.map +1 -1
  221. package/_types/getTransactionFull/getTransactionFull.d.ts +9 -1
  222. package/_types/getTransactionFull/getTransactionFull.d.ts.map +1 -1
  223. package/_types/index.d.ts +1 -1
  224. package/_types/index.d.ts.map +1 -1
  225. package/_types/types/log.d.ts +6 -6
  226. package/_types/types/transaction.d.ts +3 -4
  227. package/_types/types/transaction.d.ts.map +1 -1
  228. package/_types/utils/create.d.ts +23 -0
  229. package/_types/utils/create.d.ts.map +1 -0
  230. package/_types/utils/index.d.ts +1 -0
  231. package/_types/utils/index.d.ts.map +1 -1
  232. package/analyzer/analyze.ts +6 -30
  233. package/analyzer/axieMarketplace/analyze.ts +67 -150
  234. package/analyzer/gasFee/analyze.ts +29 -36
  235. package/analyzer/index.ts +1 -1
  236. package/analyzer/json/analyze.ts +32 -53
  237. package/analyzer/json/components/comment.ts +62 -0
  238. package/analyzer/json/components/erc1155.ts +132 -0
  239. package/analyzer/json/components/erc1155Raw.ts +46 -0
  240. package/analyzer/json/components/erc20.ts +129 -0
  241. package/analyzer/json/components/erc20Raw.ts +43 -0
  242. package/analyzer/json/components/erc721.ts +117 -0
  243. package/analyzer/json/components/erc721Raw.ts +46 -0
  244. package/analyzer/json/components/id.ts +62 -0
  245. package/analyzer/json/components/internal.ts +117 -0
  246. package/analyzer/json/components/internalRaw.ts +39 -0
  247. package/analyzer/json/components/logArgument.ts +99 -0
  248. package/analyzer/json/components/logArgumentRaw.ts +57 -0
  249. package/analyzer/json/components/transfer.ts +531 -0
  250. package/analyzer/json/condition/address.ts +124 -0
  251. package/analyzer/json/condition/argumentValue.ts +43 -0
  252. package/analyzer/json/condition/index.ts +3 -0
  253. package/analyzer/json/condition/value.ts +76 -0
  254. package/analyzer/json/generator.ts +1166 -0
  255. package/analyzer/json/index.ts +1 -0
  256. package/analyzer/json/schemas/generator.ts +387 -0
  257. package/analyzer/json/schemas/index.ts +363 -0
  258. package/analyzer/json/schemas/utils.ts +12 -0
  259. package/analyzer/json/types.ts +111 -207
  260. package/analyzer/parsers/transfer.ts +301 -0
  261. package/analyzer/seaport/analyze.ts +228 -195
  262. package/analyzer/spam/analyze.ts +79 -112
  263. package/analyzer/swap/analyze.ts +67 -101
  264. package/analyzer/transfer/analyze.ts +54 -100
  265. package/analyzer/types.ts +5 -21
  266. package/index.ts +1 -0
  267. package/package.json +2 -2
  268. package/types/transaction.ts +2 -14
  269. package/utils/create.ts +57 -0
  270. package/utils/index.ts +1 -0
  271. package/_cjs/analyzer/createAccountActionByAction/addLiquidity.js +0 -28
  272. package/_cjs/analyzer/createAccountActionByAction/addLiquidity.js.map +0 -1
  273. package/_cjs/analyzer/createAccountActionByAction/atomicArbitrage.js +0 -79
  274. package/_cjs/analyzer/createAccountActionByAction/atomicArbitrage.js.map +0 -1
  275. package/_cjs/analyzer/createAccountActionByAction/bridgeFrom.js +0 -38
  276. package/_cjs/analyzer/createAccountActionByAction/bridgeFrom.js.map +0 -1
  277. package/_cjs/analyzer/createAccountActionByAction/bridgeTo.js +0 -38
  278. package/_cjs/analyzer/createAccountActionByAction/bridgeTo.js.map +0 -1
  279. package/_cjs/analyzer/createAccountActionByAction/buyNft.js +0 -59
  280. package/_cjs/analyzer/createAccountActionByAction/buyNft.js.map +0 -1
  281. package/_cjs/analyzer/createAccountActionByAction/createAccountActionByAction.js +0 -69
  282. package/_cjs/analyzer/createAccountActionByAction/createAccountActionByAction.js.map +0 -1
  283. package/_cjs/analyzer/createAccountActionByAction/deposit.js +0 -41
  284. package/_cjs/analyzer/createAccountActionByAction/deposit.js.map +0 -1
  285. package/_cjs/analyzer/createAccountActionByAction/depositWithBond.js +0 -28
  286. package/_cjs/analyzer/createAccountActionByAction/depositWithBond.js.map +0 -1
  287. package/_cjs/analyzer/createAccountActionByAction/freeMintNft.js +0 -32
  288. package/_cjs/analyzer/createAccountActionByAction/freeMintNft.js.map +0 -1
  289. package/_cjs/analyzer/createAccountActionByAction/index.js +0 -6
  290. package/_cjs/analyzer/createAccountActionByAction/index.js.map +0 -1
  291. package/_cjs/analyzer/createAccountActionByAction/removeLiquidity.js +0 -28
  292. package/_cjs/analyzer/createAccountActionByAction/removeLiquidity.js.map +0 -1
  293. package/_cjs/analyzer/createAccountActionByAction/spam.js +0 -58
  294. package/_cjs/analyzer/createAccountActionByAction/spam.js.map +0 -1
  295. package/_cjs/analyzer/createAccountActionByAction/trade.js +0 -59
  296. package/_cjs/analyzer/createAccountActionByAction/trade.js.map +0 -1
  297. package/_cjs/analyzer/createAccountActionByAction/transactionFee.js +0 -29
  298. package/_cjs/analyzer/createAccountActionByAction/transactionFee.js.map +0 -1
  299. package/_cjs/analyzer/createAccountActionByAction/transfer.js +0 -74
  300. package/_cjs/analyzer/createAccountActionByAction/transfer.js.map +0 -1
  301. package/_cjs/analyzer/createAccountActionByAction/withdraw.js +0 -38
  302. package/_cjs/analyzer/createAccountActionByAction/withdraw.js.map +0 -1
  303. package/_cjs/analyzer/createAccountActionByAction/withdrawWithBond.js +0 -28
  304. package/_cjs/analyzer/createAccountActionByAction/withdrawWithBond.js.map +0 -1
  305. package/_cjs/analyzer/json/generatorAnyLog.js +0 -163
  306. package/_cjs/analyzer/json/generatorAnyLog.js.map +0 -1
  307. package/_cjs/analyzer/json/generatorAnyTokenTransfer.js +0 -102
  308. package/_cjs/analyzer/json/generatorAnyTokenTransfer.js.map +0 -1
  309. package/_cjs/analyzer/json/generatorSpecificTokenTransfer.js +0 -343
  310. package/_cjs/analyzer/json/generatorSpecificTokenTransfer.js.map +0 -1
  311. package/_esm/analyzer/createAccountActionByAction/addLiquidity.js +0 -24
  312. package/_esm/analyzer/createAccountActionByAction/addLiquidity.js.map +0 -1
  313. package/_esm/analyzer/createAccountActionByAction/atomicArbitrage.js +0 -79
  314. package/_esm/analyzer/createAccountActionByAction/atomicArbitrage.js.map +0 -1
  315. package/_esm/analyzer/createAccountActionByAction/bridgeFrom.js +0 -34
  316. package/_esm/analyzer/createAccountActionByAction/bridgeFrom.js.map +0 -1
  317. package/_esm/analyzer/createAccountActionByAction/bridgeTo.js +0 -34
  318. package/_esm/analyzer/createAccountActionByAction/bridgeTo.js.map +0 -1
  319. package/_esm/analyzer/createAccountActionByAction/buyNft.js +0 -59
  320. package/_esm/analyzer/createAccountActionByAction/buyNft.js.map +0 -1
  321. package/_esm/analyzer/createAccountActionByAction/createAccountActionByAction.js +0 -80
  322. package/_esm/analyzer/createAccountActionByAction/createAccountActionByAction.js.map +0 -1
  323. package/_esm/analyzer/createAccountActionByAction/deposit.js +0 -38
  324. package/_esm/analyzer/createAccountActionByAction/deposit.js.map +0 -1
  325. package/_esm/analyzer/createAccountActionByAction/depositWithBond.js +0 -24
  326. package/_esm/analyzer/createAccountActionByAction/depositWithBond.js.map +0 -1
  327. package/_esm/analyzer/createAccountActionByAction/freeMintNft.js +0 -28
  328. package/_esm/analyzer/createAccountActionByAction/freeMintNft.js.map +0 -1
  329. package/_esm/analyzer/createAccountActionByAction/index.js +0 -2
  330. package/_esm/analyzer/createAccountActionByAction/index.js.map +0 -1
  331. package/_esm/analyzer/createAccountActionByAction/removeLiquidity.js +0 -24
  332. package/_esm/analyzer/createAccountActionByAction/removeLiquidity.js.map +0 -1
  333. package/_esm/analyzer/createAccountActionByAction/spam.js +0 -54
  334. package/_esm/analyzer/createAccountActionByAction/spam.js.map +0 -1
  335. package/_esm/analyzer/createAccountActionByAction/trade.js +0 -59
  336. package/_esm/analyzer/createAccountActionByAction/trade.js.map +0 -1
  337. package/_esm/analyzer/createAccountActionByAction/transactionFee.js +0 -25
  338. package/_esm/analyzer/createAccountActionByAction/transactionFee.js.map +0 -1
  339. package/_esm/analyzer/createAccountActionByAction/transfer.js +0 -70
  340. package/_esm/analyzer/createAccountActionByAction/transfer.js.map +0 -1
  341. package/_esm/analyzer/createAccountActionByAction/withdraw.js +0 -34
  342. package/_esm/analyzer/createAccountActionByAction/withdraw.js.map +0 -1
  343. package/_esm/analyzer/createAccountActionByAction/withdrawWithBond.js +0 -24
  344. package/_esm/analyzer/createAccountActionByAction/withdrawWithBond.js.map +0 -1
  345. package/_esm/analyzer/json/generatorAnyLog.js +0 -159
  346. package/_esm/analyzer/json/generatorAnyLog.js.map +0 -1
  347. package/_esm/analyzer/json/generatorAnyTokenTransfer.js +0 -98
  348. package/_esm/analyzer/json/generatorAnyTokenTransfer.js.map +0 -1
  349. package/_esm/analyzer/json/generatorSpecificTokenTransfer.js +0 -339
  350. package/_esm/analyzer/json/generatorSpecificTokenTransfer.js.map +0 -1
  351. package/_types/analyzer/createAccountActionByAction/addLiquidity.d.ts +0 -59
  352. package/_types/analyzer/createAccountActionByAction/addLiquidity.d.ts.map +0 -1
  353. package/_types/analyzer/createAccountActionByAction/atomicArbitrage.d.ts +0 -59
  354. package/_types/analyzer/createAccountActionByAction/atomicArbitrage.d.ts.map +0 -1
  355. package/_types/analyzer/createAccountActionByAction/bridgeFrom.d.ts +0 -59
  356. package/_types/analyzer/createAccountActionByAction/bridgeFrom.d.ts.map +0 -1
  357. package/_types/analyzer/createAccountActionByAction/bridgeTo.d.ts +0 -59
  358. package/_types/analyzer/createAccountActionByAction/bridgeTo.d.ts.map +0 -1
  359. package/_types/analyzer/createAccountActionByAction/buyNft.d.ts +0 -59
  360. package/_types/analyzer/createAccountActionByAction/buyNft.d.ts.map +0 -1
  361. package/_types/analyzer/createAccountActionByAction/createAccountActionByAction.d.ts +0 -59
  362. package/_types/analyzer/createAccountActionByAction/createAccountActionByAction.d.ts.map +0 -1
  363. package/_types/analyzer/createAccountActionByAction/deposit.d.ts +0 -59
  364. package/_types/analyzer/createAccountActionByAction/deposit.d.ts.map +0 -1
  365. package/_types/analyzer/createAccountActionByAction/depositWithBond.d.ts +0 -59
  366. package/_types/analyzer/createAccountActionByAction/depositWithBond.d.ts.map +0 -1
  367. package/_types/analyzer/createAccountActionByAction/freeMintNft.d.ts +0 -53
  368. package/_types/analyzer/createAccountActionByAction/freeMintNft.d.ts.map +0 -1
  369. package/_types/analyzer/createAccountActionByAction/index.d.ts +0 -2
  370. package/_types/analyzer/createAccountActionByAction/index.d.ts.map +0 -1
  371. package/_types/analyzer/createAccountActionByAction/removeLiquidity.d.ts +0 -59
  372. package/_types/analyzer/createAccountActionByAction/removeLiquidity.d.ts.map +0 -1
  373. package/_types/analyzer/createAccountActionByAction/spam.d.ts +0 -59
  374. package/_types/analyzer/createAccountActionByAction/spam.d.ts.map +0 -1
  375. package/_types/analyzer/createAccountActionByAction/trade.d.ts +0 -59
  376. package/_types/analyzer/createAccountActionByAction/trade.d.ts.map +0 -1
  377. package/_types/analyzer/createAccountActionByAction/transactionFee.d.ts +0 -59
  378. package/_types/analyzer/createAccountActionByAction/transactionFee.d.ts.map +0 -1
  379. package/_types/analyzer/createAccountActionByAction/transfer.d.ts +0 -59
  380. package/_types/analyzer/createAccountActionByAction/transfer.d.ts.map +0 -1
  381. package/_types/analyzer/createAccountActionByAction/withdraw.d.ts +0 -59
  382. package/_types/analyzer/createAccountActionByAction/withdraw.d.ts.map +0 -1
  383. package/_types/analyzer/createAccountActionByAction/withdrawWithBond.d.ts +0 -59
  384. package/_types/analyzer/createAccountActionByAction/withdrawWithBond.d.ts.map +0 -1
  385. package/_types/analyzer/json/generatorAnyLog.d.ts +0 -55
  386. package/_types/analyzer/json/generatorAnyLog.d.ts.map +0 -1
  387. package/_types/analyzer/json/generatorAnyTokenTransfer.d.ts +0 -54
  388. package/_types/analyzer/json/generatorAnyTokenTransfer.d.ts.map +0 -1
  389. package/_types/analyzer/json/generatorSpecificTokenTransfer.d.ts +0 -55
  390. package/_types/analyzer/json/generatorSpecificTokenTransfer.d.ts.map +0 -1
  391. package/analyzer/createAccountActionByAction/addLiquidity.ts +0 -60
  392. package/analyzer/createAccountActionByAction/atomicArbitrage.ts +0 -115
  393. package/analyzer/createAccountActionByAction/bridgeFrom.ts +0 -61
  394. package/analyzer/createAccountActionByAction/bridgeTo.ts +0 -61
  395. package/analyzer/createAccountActionByAction/buyNft.ts +0 -106
  396. package/analyzer/createAccountActionByAction/createAccountActionByAction.ts +0 -181
  397. package/analyzer/createAccountActionByAction/deposit.ts +0 -64
  398. package/analyzer/createAccountActionByAction/depositWithBond.ts +0 -60
  399. package/analyzer/createAccountActionByAction/freeMintNft.ts +0 -54
  400. package/analyzer/createAccountActionByAction/index.ts +0 -1
  401. package/analyzer/createAccountActionByAction/removeLiquidity.ts +0 -60
  402. package/analyzer/createAccountActionByAction/spam.ts +0 -79
  403. package/analyzer/createAccountActionByAction/trade.ts +0 -105
  404. package/analyzer/createAccountActionByAction/transactionFee.ts +0 -51
  405. package/analyzer/createAccountActionByAction/transfer.ts +0 -95
  406. package/analyzer/createAccountActionByAction/withdraw.ts +0 -61
  407. package/analyzer/createAccountActionByAction/withdrawWithBond.ts +0 -60
  408. package/analyzer/json/generatorAnyLog.ts +0 -207
  409. package/analyzer/json/generatorAnyTokenTransfer.ts +0 -118
  410. package/analyzer/json/generatorSpecificTokenTransfer.ts +0 -425
@@ -0,0 +1,1166 @@
1
+ import type {
2
+ CryptoCurrencyPrice,
3
+ NormalAction,
4
+ NormalActionAddLiquidity,
5
+ NormalActionApprove,
6
+ NormalActionAtomicArbitrage,
7
+ NormalActionBorrow,
8
+ NormalActionBorrowWithDebt,
9
+ NormalActionBridgeFrom,
10
+ NormalActionBridgeTo,
11
+ NormalActionBuyCrypto,
12
+ NormalActionBuyNft,
13
+ NormalActionCrossReplace,
14
+ NormalActionCrossTrade,
15
+ NormalActionDeposit,
16
+ NormalActionDepositWithBond,
17
+ NormalActionFailTx,
18
+ NormalActionFee,
19
+ NormalActionFreeMintNft,
20
+ NormalActionIncome,
21
+ NormalActionMintNft,
22
+ NormalActionReceiveFromCex,
23
+ NormalActionRemoveLiquidity,
24
+ NormalActionRepayment,
25
+ NormalActionRepaymentWithDebt,
26
+ NormalActionReplace,
27
+ NormalActionRevoke,
28
+ NormalActionSellCrypto,
29
+ NormalActionSellNft,
30
+ NormalActionSendToCex,
31
+ NormalActionSpam,
32
+ NormalActionStake,
33
+ NormalActionSwapNft,
34
+ NormalActionTrade,
35
+ NormalActionTransactionFee,
36
+ NormalActionTransfer,
37
+ NormalActionUnstake,
38
+ NormalActionUnwrap,
39
+ NormalActionWithdraw,
40
+ NormalActionWithdrawWithBond,
41
+ NormalActionWrap,
42
+ Transfer,
43
+ TransferCryptoCurrencyIn,
44
+ TransferCryptoCurrencyOut,
45
+ TransferFiatCurrencyIn,
46
+ TransferFiatCurrencyOut,
47
+ TransferNftIn,
48
+ TransferNftOut,
49
+ } from '@0xtorch/core'
50
+ import {
51
+ isTransferCryptoCurrencyIn,
52
+ isTransferCryptoCurrencyOut,
53
+ isTransferFiatCurrencyIn,
54
+ isTransferFiatCurrencyOut,
55
+ isTransferNftIn,
56
+ isTransferNftOut,
57
+ } from '@0xtorch/core'
58
+ import type { Chain } from '../../chains'
59
+ import type {
60
+ Erc1155Transfer,
61
+ Erc20Transfer,
62
+ Erc721Transfer,
63
+ InternalTransaction,
64
+ LogData,
65
+ TransactionDecoded,
66
+ } from '../../types'
67
+ import { createCommentByCommentComponent } from './components/comment'
68
+ import { isMatchErc1155Component } from './components/erc1155'
69
+ import { isMatchErc20Component } from './components/erc20'
70
+ import { isMatchErc721Component } from './components/erc721'
71
+ import { createIdByIdComponent } from './components/id'
72
+ import { isMatchInternalComponent } from './components/internal'
73
+ import { isMatchLogArgumentComponent } from './components/logArgument'
74
+ import { createTransfersByTransferComponent } from './components/transfer'
75
+ import type { ActionGenerator } from './types'
76
+
77
+ type GenerateActionsByGeneratorParameters<
78
+ Price extends CryptoCurrencyPrice | undefined,
79
+ > = {
80
+ readonly generator: ActionGenerator
81
+ readonly chain: Chain
82
+ readonly transaction: TransactionDecoded<Price>
83
+ }
84
+
85
+ type Target<Price extends CryptoCurrencyPrice | undefined> = {
86
+ readonly targetsErc20?: readonly Erc20Transfer<Price>[]
87
+ readonly targetsErc721?: readonly Erc721Transfer[]
88
+ readonly targetsErc1155?: readonly Erc1155Transfer[]
89
+ readonly targetsInternal?: readonly InternalTransaction<Price>[]
90
+ readonly targetsLog?: readonly LogData[]
91
+ }
92
+
93
+ export const generateActionsByGenerator = <
94
+ Price extends CryptoCurrencyPrice | undefined,
95
+ >({
96
+ generator,
97
+ chain,
98
+ transaction,
99
+ }: GenerateActionsByGeneratorParameters<Price>): NormalAction[] => {
100
+ const { target } = generator
101
+ // target=undefined の場合は単一 action 生成
102
+ if (target === undefined) {
103
+ return [
104
+ generateActionByGeneratorWithTargets({
105
+ generator,
106
+ chain,
107
+ transaction,
108
+ }),
109
+ ]
110
+ }
111
+
112
+ // target が undefined でない場合は target 毎に action 生成
113
+ const mut_erc20Transfers = [...transaction.erc20Transfers]
114
+ const mut_erc721Transfers = [...transaction.erc721Transfers]
115
+ const mut_erc1155Transfers = [...transaction.erc1155Transfers]
116
+ const mut_internalTransactions = [...transaction.internalTransactions]
117
+ const mut_logs = [...transaction.logs]
118
+ const mut_targets: Target<Price>[] = []
119
+ let repeat = true
120
+ while (repeat) {
121
+ const mut_targetsErc20: Erc20Transfer<Price>[] = []
122
+ const mut_targetsErc721: Erc721Transfer[] = []
123
+ const mut_targetsErc1155: Erc1155Transfer[] = []
124
+ const mut_targetsInternal: InternalTransaction<Price>[] = []
125
+ const mut_targetsLog: LogData[] = []
126
+ for (const component of target) {
127
+ switch (component.type) {
128
+ case 'erc20': {
129
+ const erc20Index = mut_erc20Transfers.findIndex((transfer) =>
130
+ isMatchErc20Component({
131
+ component: {
132
+ ...component,
133
+ index: 0,
134
+ },
135
+ transfer,
136
+ transaction,
137
+ }),
138
+ )
139
+ if (erc20Index === -1) {
140
+ repeat = false
141
+ break
142
+ }
143
+ mut_targetsErc20.push(mut_erc20Transfers[erc20Index])
144
+ mut_erc20Transfers.splice(erc20Index, 1)
145
+ break
146
+ }
147
+ case 'erc721': {
148
+ const erc721Index = mut_erc721Transfers.findIndex((transfer) =>
149
+ isMatchErc721Component({
150
+ component: {
151
+ ...component,
152
+ index: 0,
153
+ },
154
+ transfer,
155
+ transaction,
156
+ }),
157
+ )
158
+ if (erc721Index === -1) {
159
+ repeat = false
160
+ break
161
+ }
162
+ mut_targetsErc721.push(mut_erc721Transfers[erc721Index])
163
+ mut_erc721Transfers.splice(erc721Index, 1)
164
+ break
165
+ }
166
+ case 'erc1155': {
167
+ const erc1155Index = mut_erc1155Transfers.findIndex((transfer) =>
168
+ isMatchErc1155Component({
169
+ component: {
170
+ ...component,
171
+ index: 0,
172
+ },
173
+ transfer,
174
+ transaction,
175
+ }),
176
+ )
177
+ if (erc1155Index === -1) {
178
+ repeat = false
179
+ break
180
+ }
181
+ mut_targetsErc1155.push(mut_erc1155Transfers[erc1155Index])
182
+ mut_erc1155Transfers.splice(erc1155Index, 1)
183
+ break
184
+ }
185
+ case 'internal': {
186
+ const internalIndex = mut_internalTransactions.findIndex((internal) =>
187
+ isMatchInternalComponent({
188
+ component: {
189
+ ...component,
190
+ index: 0,
191
+ },
192
+ internal,
193
+ transaction,
194
+ }),
195
+ )
196
+ if (internalIndex === -1) {
197
+ repeat = false
198
+ break
199
+ }
200
+ mut_targetsInternal.push(mut_internalTransactions[internalIndex])
201
+ mut_internalTransactions.splice(internalIndex, 1)
202
+ break
203
+ }
204
+ case 'log': {
205
+ const logIndex = mut_logs.findIndex((log) =>
206
+ isMatchLogArgumentComponent({
207
+ component: {
208
+ ...component,
209
+ index: 0,
210
+ argIndex: 0,
211
+ valueType: 'other',
212
+ },
213
+ log,
214
+ transaction,
215
+ }),
216
+ )
217
+ if (logIndex === -1) {
218
+ repeat = false
219
+ break
220
+ }
221
+ mut_targetsLog.push(mut_logs[logIndex])
222
+ mut_logs.splice(logIndex, 1)
223
+ break
224
+ }
225
+ }
226
+ if (!repeat) {
227
+ break
228
+ }
229
+ }
230
+ if (!repeat) {
231
+ break
232
+ }
233
+ mut_targets.push({
234
+ targetsErc20: mut_targetsErc20,
235
+ targetsErc721: mut_targetsErc721,
236
+ targetsErc1155: mut_targetsErc1155,
237
+ targetsInternal: mut_targetsInternal,
238
+ targetsLog: mut_targetsLog,
239
+ })
240
+ }
241
+
242
+ const actions = mut_targets.map((target) =>
243
+ generateActionByGeneratorWithTargets({
244
+ generator,
245
+ chain,
246
+ transaction,
247
+ ...target,
248
+ }),
249
+ )
250
+ return actions
251
+ }
252
+
253
+ type GenerateActionsByGeneratorWithTargetsParameters<
254
+ Price extends CryptoCurrencyPrice | undefined,
255
+ > = GenerateActionsByGeneratorParameters<Price> & Target<Price>
256
+
257
+ type BaseAction = Omit<NormalAction, 'transfers' | 'crossId' | 'loanId'> & {
258
+ readonly transfers: readonly Transfer[]
259
+ readonly crossId: string | undefined
260
+ readonly loanId: string | undefined
261
+ }
262
+
263
+ const generateActionByGeneratorWithTargets = <
264
+ Price extends CryptoCurrencyPrice | undefined,
265
+ >({
266
+ generator,
267
+ chain,
268
+ transaction,
269
+ targetsErc20,
270
+ targetsErc721,
271
+ targetsErc1155,
272
+ targetsInternal,
273
+ targetsLog,
274
+ }: GenerateActionsByGeneratorWithTargetsParameters<Price>): NormalAction => {
275
+ // generator に基づいて action 生成
276
+ const action: BaseAction = {
277
+ type: 'NormalAction',
278
+ action: generator.action,
279
+ evidence: 'contract',
280
+ timestamp: Number(transaction.block.timestamp) * 1000,
281
+ comment:
282
+ generator.comment === undefined
283
+ ? undefined
284
+ : generator.comment
285
+ .map((component) =>
286
+ createCommentByCommentComponent({
287
+ component,
288
+ transaction,
289
+ chain,
290
+ targetsLog,
291
+ }),
292
+ )
293
+ .join(''),
294
+ app: transaction.app,
295
+ transfers: generator.transfers.flatMap((component) =>
296
+ createTransfersByTransferComponent({
297
+ component,
298
+ transaction,
299
+ chain,
300
+ targetsErc20,
301
+ targetsErc721,
302
+ targetsErc1155,
303
+ targetsInternal,
304
+ targetsLog,
305
+ }),
306
+ ),
307
+ crossId:
308
+ generator.crossId === undefined
309
+ ? undefined
310
+ : generator.crossId
311
+ .map((component) =>
312
+ createIdByIdComponent({
313
+ component,
314
+ transaction,
315
+ chain,
316
+ targetsLog,
317
+ }),
318
+ )
319
+ .join(''),
320
+ loanId:
321
+ generator.loanId === undefined
322
+ ? undefined
323
+ : generator.loanId
324
+ .map((component) =>
325
+ createIdByIdComponent({
326
+ component,
327
+ transaction,
328
+ chain,
329
+ targetsLog,
330
+ }),
331
+ )
332
+ .join(''),
333
+ }
334
+
335
+ switch (action.action) {
336
+ case 'add-liquidity': {
337
+ const transfers = action.transfers.filter(
338
+ (
339
+ transfer,
340
+ ): transfer is
341
+ | TransferCryptoCurrencyIn
342
+ | TransferNftIn
343
+ | TransferCryptoCurrencyOut
344
+ | TransferNftOut =>
345
+ isTransferCryptoCurrencyIn(transfer) ||
346
+ isTransferNftIn(transfer) ||
347
+ isTransferCryptoCurrencyOut(transfer) ||
348
+ isTransferNftOut(transfer),
349
+ )
350
+ if (transfers.length !== action.transfers.length) {
351
+ throw new Error('Invalid action.transfers for add-liquidity')
352
+ }
353
+ if (action.loanId === undefined) {
354
+ throw new Error('action.loandId is required for add-liquidity')
355
+ }
356
+ return {
357
+ ...action,
358
+ type: 'LoanNormalAction',
359
+ action: 'add-liquidity',
360
+ loanId: action.loanId,
361
+ transfers,
362
+ } satisfies NormalActionAddLiquidity
363
+ }
364
+ case 'approve': {
365
+ if (action.transfers.length > 0) {
366
+ throw new Error('Invalid action.transfers for approve')
367
+ }
368
+ return {
369
+ ...action,
370
+ type: 'NormalAction',
371
+ action: 'approve',
372
+ transfers: [],
373
+ } satisfies NormalActionApprove
374
+ }
375
+ case 'atomic-arbitrage': {
376
+ const transfers = action.transfers.filter(
377
+ (
378
+ transfer,
379
+ ): transfer is TransferCryptoCurrencyIn | TransferCryptoCurrencyOut =>
380
+ isTransferCryptoCurrencyIn(transfer) ||
381
+ isTransferCryptoCurrencyOut(transfer),
382
+ )
383
+ if (transfers.length !== action.transfers.length) {
384
+ throw new Error('Invalid action.transfers for atomic-arbitrage')
385
+ }
386
+ return {
387
+ ...action,
388
+ type: 'NormalAction',
389
+ action: 'atomic-arbitrage',
390
+ transfers,
391
+ } satisfies NormalActionAtomicArbitrage
392
+ }
393
+ case 'borrow': {
394
+ const transfers = action.transfers.filter(
395
+ (transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
396
+ isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
397
+ )
398
+ if (transfers.length !== action.transfers.length) {
399
+ throw new Error('Invalid action.transfers for borrow')
400
+ }
401
+ if (action.loanId === undefined) {
402
+ throw new Error('action.loandId is required for borrow')
403
+ }
404
+ return {
405
+ ...action,
406
+ type: 'LoanNormalAction',
407
+ action: 'borrow',
408
+ loanId: action.loanId,
409
+ transfers,
410
+ } satisfies NormalActionBorrow
411
+ }
412
+ case 'borrow-with-debt': {
413
+ const transfers = action.transfers.filter(
414
+ (
415
+ transfer,
416
+ ): transfer is
417
+ | TransferCryptoCurrencyIn
418
+ | TransferNftIn
419
+ | TransferCryptoCurrencyOut
420
+ | TransferNftOut =>
421
+ isTransferCryptoCurrencyIn(transfer) ||
422
+ isTransferNftIn(transfer) ||
423
+ isTransferCryptoCurrencyOut(transfer) ||
424
+ isTransferNftOut(transfer),
425
+ )
426
+ if (transfers.length !== action.transfers.length) {
427
+ throw new Error('Invalid action.transfers for borrow-with-debt')
428
+ }
429
+ if (action.loanId === undefined) {
430
+ throw new Error('action.loandId is required for borrow-with-debt')
431
+ }
432
+ return {
433
+ ...action,
434
+ type: 'LoanNormalAction',
435
+ action: 'borrow-with-debt',
436
+ loanId: action.loanId,
437
+ transfers,
438
+ } satisfies NormalActionBorrowWithDebt
439
+ }
440
+ case 'bridge-from': {
441
+ const transfers = action.transfers.filter(
442
+ (transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
443
+ isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
444
+ )
445
+ if (transfers.length !== action.transfers.length) {
446
+ throw new Error('Invalid action.transfers for bridge-from')
447
+ }
448
+ if (action.crossId === undefined) {
449
+ throw new Error('action.crossId is required for bridge-from')
450
+ }
451
+ return {
452
+ ...action,
453
+ type: 'CrossNormalAction',
454
+ action: 'bridge-from',
455
+ crossId: action.crossId,
456
+ transfers,
457
+ } satisfies NormalActionBridgeFrom
458
+ }
459
+ case 'bridge-to': {
460
+ const transfers = action.transfers.filter(
461
+ (transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
462
+ isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
463
+ )
464
+ if (transfers.length !== action.transfers.length) {
465
+ throw new Error('Invalid action.transfers for bridge-to')
466
+ }
467
+ if (action.crossId === undefined) {
468
+ throw new Error('action.crossId is required for bridge-to')
469
+ }
470
+ return {
471
+ ...action,
472
+ type: 'CrossNormalAction',
473
+ action: 'bridge-to',
474
+ crossId: action.crossId,
475
+ transfers,
476
+ } satisfies NormalActionBridgeTo
477
+ }
478
+ case 'buy-crypto': {
479
+ const transfers = action.transfers.filter(
480
+ (
481
+ transfer,
482
+ ): transfer is TransferCryptoCurrencyIn | TransferFiatCurrencyOut =>
483
+ isTransferCryptoCurrencyIn(transfer) ||
484
+ isTransferFiatCurrencyOut(transfer),
485
+ )
486
+ if (transfers.length !== action.transfers.length) {
487
+ throw new Error('Invalid action.transfers for buy-crypto')
488
+ }
489
+ return {
490
+ ...action,
491
+ type: 'NormalAction',
492
+ action: 'buy-crypto',
493
+ transfers,
494
+ } satisfies NormalActionBuyCrypto
495
+ }
496
+ case 'buy-nft': {
497
+ const transfers = action.transfers.filter(
498
+ (
499
+ transfer,
500
+ ): transfer is
501
+ | TransferNftIn
502
+ | TransferFiatCurrencyOut
503
+ | TransferCryptoCurrencyOut =>
504
+ isTransferNftIn(transfer) ||
505
+ isTransferFiatCurrencyOut(transfer) ||
506
+ isTransferCryptoCurrencyOut(transfer),
507
+ )
508
+ if (transfers.length !== action.transfers.length) {
509
+ throw new Error('Invalid action.transfers for buy-nft')
510
+ }
511
+ return {
512
+ ...action,
513
+ type: 'NormalAction',
514
+ action: 'buy-nft',
515
+ transfers,
516
+ } satisfies NormalActionBuyNft
517
+ }
518
+ case 'cross-replace': {
519
+ // transferInSchema, transferOutSchema
520
+ const transfers = action.transfers.filter(
521
+ (
522
+ transfer,
523
+ ): transfer is
524
+ | TransferCryptoCurrencyIn
525
+ | TransferNftIn
526
+ | TransferFiatCurrencyIn
527
+ | TransferCryptoCurrencyOut
528
+ | TransferNftOut
529
+ | TransferFiatCurrencyOut =>
530
+ isTransferCryptoCurrencyIn(transfer) ||
531
+ isTransferNftIn(transfer) ||
532
+ isTransferFiatCurrencyIn(transfer) ||
533
+ isTransferCryptoCurrencyOut(transfer) ||
534
+ isTransferNftOut(transfer) ||
535
+ isTransferFiatCurrencyOut(transfer),
536
+ )
537
+ if (transfers.length !== action.transfers.length) {
538
+ throw new Error('Invalid action.transfers for cross-replace')
539
+ }
540
+ if (action.crossId === undefined) {
541
+ throw new Error('action.crossId is required for cross-replace')
542
+ }
543
+ return {
544
+ ...action,
545
+ type: 'CrossNormalAction',
546
+ action: 'cross-replace',
547
+ crossId: action.crossId,
548
+ transfers,
549
+ } satisfies NormalActionCrossReplace
550
+ }
551
+ case 'deposit': {
552
+ // transferCryptoCurrencyOutSchema, transferNftOutSchema
553
+ const transfers = action.transfers.filter(
554
+ (transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
555
+ isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
556
+ )
557
+ if (transfers.length !== action.transfers.length) {
558
+ throw new Error('Invalid action.transfers for deposit')
559
+ }
560
+ if (action.loanId === undefined) {
561
+ throw new Error('action.loandId is required for deposit')
562
+ }
563
+ return {
564
+ ...action,
565
+ type: 'LoanNormalAction',
566
+ action: 'deposit',
567
+ loanId: action.loanId,
568
+ transfers,
569
+ } satisfies NormalActionDeposit
570
+ }
571
+ case 'cross-trade': {
572
+ // transferInSchema, transferOutSchema
573
+ const transfers = action.transfers.filter(
574
+ (
575
+ transfer,
576
+ ): transfer is
577
+ | TransferCryptoCurrencyIn
578
+ | TransferNftIn
579
+ | TransferFiatCurrencyIn
580
+ | TransferCryptoCurrencyOut
581
+ | TransferNftOut
582
+ | TransferFiatCurrencyOut =>
583
+ isTransferCryptoCurrencyIn(transfer) ||
584
+ isTransferNftIn(transfer) ||
585
+ isTransferFiatCurrencyIn(transfer) ||
586
+ isTransferCryptoCurrencyOut(transfer) ||
587
+ isTransferNftOut(transfer) ||
588
+ isTransferFiatCurrencyOut(transfer),
589
+ )
590
+ if (transfers.length !== action.transfers.length) {
591
+ throw new Error('Invalid action.transfers for cross-trade')
592
+ }
593
+ if (action.crossId === undefined) {
594
+ throw new Error('action.crossId is required for cross-trade')
595
+ }
596
+ return {
597
+ ...action,
598
+ type: 'CrossNormalAction',
599
+ action: 'cross-trade',
600
+ crossId: action.crossId,
601
+ transfers,
602
+ } satisfies NormalActionCrossTrade
603
+ }
604
+ case 'deposit-with-bond': {
605
+ // transferCryptoCurrencyInSchema,
606
+ // transferNftInSchema,
607
+ // transferCryptoCurrencyOutSchema,
608
+ // transferNftOutSchema,
609
+ const transfers = action.transfers.filter(
610
+ (
611
+ transfer,
612
+ ): transfer is
613
+ | TransferCryptoCurrencyIn
614
+ | TransferNftIn
615
+ | TransferCryptoCurrencyOut
616
+ | TransferNftOut =>
617
+ isTransferCryptoCurrencyIn(transfer) ||
618
+ isTransferNftIn(transfer) ||
619
+ isTransferCryptoCurrencyOut(transfer) ||
620
+ isTransferNftOut(transfer),
621
+ )
622
+ if (transfers.length !== action.transfers.length) {
623
+ throw new Error('Invalid action.transfers for deposit-with-bond')
624
+ }
625
+ if (action.loanId === undefined) {
626
+ throw new Error('action.loandId is required for deposit-with-bond')
627
+ }
628
+ return {
629
+ ...action,
630
+ type: 'LoanNormalAction',
631
+ action: 'deposit-with-bond',
632
+ loanId: action.loanId,
633
+ transfers,
634
+ } satisfies NormalActionDepositWithBond
635
+ }
636
+ case 'fail-tx': {
637
+ if (action.transfers.length > 0) {
638
+ throw new Error('Invalid action.transfers for fail-tx')
639
+ }
640
+ return {
641
+ ...action,
642
+ type: 'NormalAction',
643
+ action: 'fail-tx',
644
+ transfers: [],
645
+ } satisfies NormalActionFailTx
646
+ }
647
+ case 'fee': {
648
+ // transferCryptoCurrencyOutSchema, transferFiatCurrencyOutSchema
649
+ const transfers = action.transfers.filter(
650
+ (
651
+ transfer,
652
+ ): transfer is TransferCryptoCurrencyOut | TransferFiatCurrencyOut =>
653
+ isTransferCryptoCurrencyOut(transfer) ||
654
+ isTransferFiatCurrencyOut(transfer),
655
+ )
656
+ if (transfers.length !== action.transfers.length) {
657
+ throw new Error('Invalid action.transfers for fee')
658
+ }
659
+ return {
660
+ ...action,
661
+ type: 'NormalAction',
662
+ action: 'fee',
663
+ transfers,
664
+ } satisfies NormalActionFee
665
+ }
666
+ case 'free-mint-nft': {
667
+ // transferNftInSchema
668
+ const transfers = action.transfers.filter(
669
+ (transfer): transfer is TransferNftIn => isTransferNftIn(transfer),
670
+ )
671
+ if (transfers.length !== action.transfers.length) {
672
+ throw new Error('Invalid action.transfers for free-mint-nft')
673
+ }
674
+ return {
675
+ ...action,
676
+ type: 'NormalAction',
677
+ action: 'free-mint-nft',
678
+ transfers,
679
+ } satisfies NormalActionFreeMintNft
680
+ }
681
+ case 'income': {
682
+ // transferInSchema
683
+ const transfers = action.transfers.filter(
684
+ (
685
+ transfer,
686
+ ): transfer is
687
+ | TransferCryptoCurrencyIn
688
+ | TransferNftIn
689
+ | TransferFiatCurrencyIn =>
690
+ isTransferCryptoCurrencyIn(transfer) ||
691
+ isTransferNftIn(transfer) ||
692
+ isTransferFiatCurrencyIn(transfer),
693
+ )
694
+ if (transfers.length !== action.transfers.length) {
695
+ throw new Error('Invalid action.transfers for income')
696
+ }
697
+ return {
698
+ ...action,
699
+ type: 'NormalAction',
700
+ action: 'income',
701
+ transfers,
702
+ } satisfies NormalActionIncome
703
+ }
704
+ case 'mint-nft': {
705
+ // transferNftInSchema,
706
+ // transferFiatCurrencyOutSchema,
707
+ // transferCryptoCurrencyOutSchema,
708
+ const transfers = action.transfers.filter(
709
+ (
710
+ transfer,
711
+ ): transfer is
712
+ | TransferNftIn
713
+ | TransferFiatCurrencyOut
714
+ | TransferCryptoCurrencyOut =>
715
+ isTransferNftIn(transfer) ||
716
+ isTransferFiatCurrencyOut(transfer) ||
717
+ isTransferCryptoCurrencyOut(transfer),
718
+ )
719
+ if (transfers.length !== action.transfers.length) {
720
+ throw new Error('Invalid action.transfers for mint-nft')
721
+ }
722
+ return {
723
+ ...action,
724
+ type: 'NormalAction',
725
+ action: 'mint-nft',
726
+ transfers,
727
+ } satisfies NormalActionMintNft
728
+ }
729
+ case 'receive-from-cex': {
730
+ // transferCryptoCurrencyInSchema, transferNftInSchema
731
+ const transfers = action.transfers.filter(
732
+ (transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
733
+ isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
734
+ )
735
+ if (transfers.length !== action.transfers.length) {
736
+ throw new Error('Invalid action.transfers for receive-from-cex')
737
+ }
738
+ return {
739
+ ...action,
740
+ type: 'NormalAction',
741
+ action: 'receive-from-cex',
742
+ transfers,
743
+ } satisfies NormalActionReceiveFromCex
744
+ }
745
+ case 'remove-liquidity': {
746
+ // transferCryptoCurrencyInSchema,
747
+ // transferNftInSchema,
748
+ // transferCryptoCurrencyOutSchema,
749
+ // transferNftOutSchema,
750
+ const transfers = action.transfers.filter(
751
+ (
752
+ transfer,
753
+ ): transfer is
754
+ | TransferCryptoCurrencyIn
755
+ | TransferNftIn
756
+ | TransferCryptoCurrencyOut
757
+ | TransferNftOut =>
758
+ isTransferCryptoCurrencyIn(transfer) ||
759
+ isTransferNftIn(transfer) ||
760
+ isTransferCryptoCurrencyOut(transfer) ||
761
+ isTransferNftOut(transfer),
762
+ )
763
+ if (transfers.length !== action.transfers.length) {
764
+ throw new Error('Invalid action.transfers for remove-liquidity')
765
+ }
766
+ if (action.loanId === undefined) {
767
+ throw new Error('action.loandId is required for remove-liquidity')
768
+ }
769
+ return {
770
+ ...action,
771
+ type: 'LoanNormalAction',
772
+ action: 'remove-liquidity',
773
+ loanId: action.loanId,
774
+ transfers,
775
+ } satisfies NormalActionRemoveLiquidity
776
+ }
777
+ case 'repayment': {
778
+ // transferCryptoCurrencyOutSchema, transferNftOutSchema
779
+ const transfers = action.transfers.filter(
780
+ (transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
781
+ isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
782
+ )
783
+ if (transfers.length !== action.transfers.length) {
784
+ throw new Error('Invalid action.transfers for repayment')
785
+ }
786
+ if (action.loanId === undefined) {
787
+ throw new Error('action.loandId is required for repayment')
788
+ }
789
+ return {
790
+ ...action,
791
+ type: 'LoanNormalAction',
792
+ action: 'repayment',
793
+ loanId: action.loanId,
794
+ transfers,
795
+ } satisfies NormalActionRepayment
796
+ }
797
+ case 'repayment-with-debt': {
798
+ // transferCryptoCurrencyInSchema,
799
+ // transferNftInSchema,
800
+ // transferCryptoCurrencyOutSchema,
801
+ // transferNftOutSchema,
802
+ const transfers = action.transfers.filter(
803
+ (
804
+ transfer,
805
+ ): transfer is
806
+ | TransferCryptoCurrencyIn
807
+ | TransferNftIn
808
+ | TransferCryptoCurrencyOut
809
+ | TransferNftOut =>
810
+ isTransferCryptoCurrencyIn(transfer) ||
811
+ isTransferNftIn(transfer) ||
812
+ isTransferCryptoCurrencyOut(transfer) ||
813
+ isTransferNftOut(transfer),
814
+ )
815
+ if (transfers.length !== action.transfers.length) {
816
+ throw new Error('Invalid action.transfers for repayment-with-debt')
817
+ }
818
+ if (action.loanId === undefined) {
819
+ throw new Error('action.loandId is required for repayment-with-debt')
820
+ }
821
+ return {
822
+ ...action,
823
+ type: 'LoanNormalAction',
824
+ action: 'repayment-with-debt',
825
+ loanId: action.loanId,
826
+ transfers,
827
+ } satisfies NormalActionRepaymentWithDebt
828
+ }
829
+ case 'replace': {
830
+ // transferCryptoCurrencyInSchema,
831
+ // transferNftInSchema,
832
+ // transferCryptoCurrencyOutSchema,
833
+ // transferNftOutSchema,
834
+ const transfers = action.transfers.filter(
835
+ (
836
+ transfer,
837
+ ): transfer is
838
+ | TransferCryptoCurrencyIn
839
+ | TransferNftIn
840
+ | TransferCryptoCurrencyOut
841
+ | TransferNftOut =>
842
+ isTransferCryptoCurrencyIn(transfer) ||
843
+ isTransferNftIn(transfer) ||
844
+ isTransferCryptoCurrencyOut(transfer) ||
845
+ isTransferNftOut(transfer),
846
+ )
847
+ if (transfers.length !== action.transfers.length) {
848
+ throw new Error('Invalid action.transfers for replace')
849
+ }
850
+ return {
851
+ ...action,
852
+ type: 'NormalAction',
853
+ action: 'replace',
854
+ transfers,
855
+ } satisfies NormalActionReplace
856
+ }
857
+ case 'revoke': {
858
+ if (action.transfers.length > 0) {
859
+ throw new Error('Invalid action.transfers for revoke')
860
+ }
861
+ return {
862
+ ...action,
863
+ type: 'NormalAction',
864
+ action: 'revoke',
865
+ transfers: [],
866
+ } satisfies NormalActionRevoke
867
+ }
868
+ case 'sell-crypto': {
869
+ // transferFiatCurrencyInSchema, transferCryptoCurrencyOutSchema
870
+ const transfers = action.transfers.filter(
871
+ (
872
+ transfer,
873
+ ): transfer is TransferFiatCurrencyIn | TransferCryptoCurrencyOut =>
874
+ isTransferFiatCurrencyIn(transfer) ||
875
+ isTransferCryptoCurrencyOut(transfer),
876
+ )
877
+ if (transfers.length !== action.transfers.length) {
878
+ throw new Error('Invalid action.transfers for sell-crypto')
879
+ }
880
+ return {
881
+ ...action,
882
+ type: 'NormalAction',
883
+ action: 'sell-crypto',
884
+ transfers,
885
+ } satisfies NormalActionSellCrypto
886
+ }
887
+ case 'sell-nft': {
888
+ // transferFiatCurrencyInSchema,
889
+ // transferCryptoCurrencyInSchema,
890
+ // transferNftOutSchema,
891
+ const transfers = action.transfers.filter(
892
+ (
893
+ transfer,
894
+ ): transfer is
895
+ | TransferFiatCurrencyIn
896
+ | TransferCryptoCurrencyIn
897
+ | TransferNftOut =>
898
+ isTransferFiatCurrencyIn(transfer) ||
899
+ isTransferCryptoCurrencyIn(transfer) ||
900
+ isTransferNftOut(transfer),
901
+ )
902
+ if (transfers.length !== action.transfers.length) {
903
+ throw new Error('Invalid action.transfers for sell-nft')
904
+ }
905
+ return {
906
+ ...action,
907
+ type: 'NormalAction',
908
+ action: 'sell-nft',
909
+ transfers,
910
+ } satisfies NormalActionSellNft
911
+ }
912
+ case 'send-to-cex': {
913
+ // transferCryptoCurrencyOutSchema, transferNftOutSchema
914
+ const transfers = action.transfers.filter(
915
+ (transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
916
+ isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
917
+ )
918
+ if (transfers.length !== action.transfers.length) {
919
+ throw new Error('Invalid action.transfers for send-to-cex')
920
+ }
921
+ return {
922
+ ...action,
923
+ type: 'NormalAction',
924
+ action: 'send-to-cex',
925
+ transfers,
926
+ } satisfies NormalActionSendToCex
927
+ }
928
+ case 'spam': {
929
+ // transferCryptoCurrencyInSchema,
930
+ // transferNftInSchema,
931
+ // transferCryptoCurrencyOutSchema,
932
+ // transferNftOutSchema,
933
+ const transfers = action.transfers.filter(
934
+ (
935
+ transfer,
936
+ ): transfer is
937
+ | TransferCryptoCurrencyIn
938
+ | TransferNftIn
939
+ | TransferCryptoCurrencyOut
940
+ | TransferNftOut =>
941
+ isTransferCryptoCurrencyIn(transfer) ||
942
+ isTransferNftIn(transfer) ||
943
+ isTransferCryptoCurrencyOut(transfer) ||
944
+ isTransferNftOut(transfer),
945
+ )
946
+ if (transfers.length !== action.transfers.length) {
947
+ throw new Error('Invalid action.transfers for spam')
948
+ }
949
+ return {
950
+ ...action,
951
+ type: 'NormalAction',
952
+ action: 'spam',
953
+ transfers,
954
+ } satisfies NormalActionSpam
955
+ }
956
+ case 'stake': {
957
+ // transferCryptoCurrencyOutSchema, transferNftOutSchema
958
+ const transfers = action.transfers.filter(
959
+ (transfer): transfer is TransferCryptoCurrencyOut | TransferNftOut =>
960
+ isTransferCryptoCurrencyOut(transfer) || isTransferNftOut(transfer),
961
+ )
962
+ if (transfers.length !== action.transfers.length) {
963
+ throw new Error('Invalid action.transfers for stake')
964
+ }
965
+ if (action.loanId === undefined) {
966
+ throw new Error('action.loandId is required for stake')
967
+ }
968
+ return {
969
+ ...action,
970
+ type: 'LoanNormalAction',
971
+ action: 'stake',
972
+ loanId: action.loanId,
973
+ transfers,
974
+ } satisfies NormalActionStake
975
+ }
976
+ case 'swap-nft': {
977
+ // transferNftInSchema, transferNftOutSchema
978
+ const transfers = action.transfers.filter(
979
+ (transfer): transfer is TransferNftIn | TransferNftOut =>
980
+ isTransferNftIn(transfer) || isTransferNftOut(transfer),
981
+ )
982
+ if (transfers.length !== action.transfers.length) {
983
+ throw new Error('Invalid action.transfers for swap-nft')
984
+ }
985
+ return {
986
+ ...action,
987
+ type: 'NormalAction',
988
+ action: 'swap-nft',
989
+ transfers,
990
+ } satisfies NormalActionSwapNft
991
+ }
992
+ case 'trade': {
993
+ // transferInSchema, transferOutSchema
994
+ const transfers = action.transfers.filter(
995
+ (
996
+ transfer,
997
+ ): transfer is
998
+ | TransferCryptoCurrencyIn
999
+ | TransferNftIn
1000
+ | TransferFiatCurrencyIn
1001
+ | TransferCryptoCurrencyOut
1002
+ | TransferNftOut
1003
+ | TransferFiatCurrencyOut =>
1004
+ isTransferCryptoCurrencyIn(transfer) ||
1005
+ isTransferNftIn(transfer) ||
1006
+ isTransferFiatCurrencyIn(transfer) ||
1007
+ isTransferCryptoCurrencyOut(transfer) ||
1008
+ isTransferNftOut(transfer) ||
1009
+ isTransferFiatCurrencyOut(transfer),
1010
+ )
1011
+ if (transfers.length !== action.transfers.length) {
1012
+ throw new Error('Invalid action.transfers for trade')
1013
+ }
1014
+ return {
1015
+ ...action,
1016
+ type: 'NormalAction',
1017
+ action: 'trade',
1018
+ transfers,
1019
+ } satisfies NormalActionTrade
1020
+ }
1021
+ case 'transaction-fee': {
1022
+ // transferCryptoCurrencyOutSchema
1023
+ const transfers = action.transfers.filter(
1024
+ (transfer): transfer is TransferCryptoCurrencyOut =>
1025
+ isTransferCryptoCurrencyOut(transfer),
1026
+ )
1027
+ if (transfers.length !== action.transfers.length) {
1028
+ throw new Error('Invalid action.transfers for transaction-fee')
1029
+ }
1030
+ return {
1031
+ ...action,
1032
+ type: 'NormalAction',
1033
+ action: 'transaction-fee',
1034
+ transfers,
1035
+ } satisfies NormalActionTransactionFee
1036
+ }
1037
+ case 'transfer': {
1038
+ return {
1039
+ ...action,
1040
+ type: 'NormalAction',
1041
+ action: 'transfer',
1042
+ transfers: [...action.transfers],
1043
+ } satisfies NormalActionTransfer
1044
+ }
1045
+ case 'unstake': {
1046
+ // transferCryptoCurrencyInSchema, transferNftInSchema
1047
+ const transfers = action.transfers.filter(
1048
+ (transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
1049
+ isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
1050
+ )
1051
+ if (transfers.length !== action.transfers.length) {
1052
+ throw new Error('Invalid action.transfers for unstake')
1053
+ }
1054
+ if (action.loanId === undefined) {
1055
+ throw new Error('action.loandId is required for unstake')
1056
+ }
1057
+ return {
1058
+ ...action,
1059
+ type: 'LoanNormalAction',
1060
+ action: 'unstake',
1061
+ loanId: action.loanId,
1062
+ transfers,
1063
+ } satisfies NormalActionUnstake
1064
+ }
1065
+ case 'unwrap': {
1066
+ // transferCryptoCurrencyInSchema,
1067
+ // transferCryptoCurrencyOutSchema,
1068
+ const transfers = action.transfers.filter(
1069
+ (
1070
+ transfer,
1071
+ ): transfer is TransferCryptoCurrencyIn | TransferCryptoCurrencyOut =>
1072
+ isTransferCryptoCurrencyIn(transfer) ||
1073
+ isTransferCryptoCurrencyOut(transfer),
1074
+ )
1075
+ if (transfers.length !== action.transfers.length) {
1076
+ throw new Error('Invalid action.transfers for unwrap')
1077
+ }
1078
+ return {
1079
+ ...action,
1080
+ type: 'NormalAction',
1081
+ action: 'unwrap',
1082
+ transfers,
1083
+ } satisfies NormalActionUnwrap
1084
+ }
1085
+ case 'wrap': {
1086
+ // transferCryptoCurrencyInSchema,
1087
+ // transferCryptoCurrencyOutSchema,
1088
+ const transfers = action.transfers.filter(
1089
+ (
1090
+ transfer,
1091
+ ): transfer is TransferCryptoCurrencyIn | TransferCryptoCurrencyOut =>
1092
+ isTransferCryptoCurrencyIn(transfer) ||
1093
+ isTransferCryptoCurrencyOut(transfer),
1094
+ )
1095
+ if (transfers.length !== action.transfers.length) {
1096
+ throw new Error('Invalid action.transfers for wrap')
1097
+ }
1098
+ return {
1099
+ ...action,
1100
+ type: 'NormalAction',
1101
+ action: 'wrap',
1102
+ transfers,
1103
+ } satisfies NormalActionWrap
1104
+ }
1105
+ case 'valuedown': {
1106
+ // TODO asset の指定を可能にする
1107
+ throw new Error('Not implemented for valuedown')
1108
+ }
1109
+ case 'valueup': {
1110
+ // TODO
1111
+ throw new Error('Not implemented for valueup')
1112
+ }
1113
+ case 'withdraw': {
1114
+ // transferCryptoCurrencyInSchema, transferNftInSchema
1115
+ const transfers = action.transfers.filter(
1116
+ (transfer): transfer is TransferCryptoCurrencyIn | TransferNftIn =>
1117
+ isTransferCryptoCurrencyIn(transfer) || isTransferNftIn(transfer),
1118
+ )
1119
+ if (transfers.length !== action.transfers.length) {
1120
+ throw new Error('Invalid action.transfers for withdraw')
1121
+ }
1122
+ if (action.loanId === undefined) {
1123
+ throw new Error('action.loandId is required for withdraw')
1124
+ }
1125
+ return {
1126
+ ...action,
1127
+ type: 'LoanNormalAction',
1128
+ action: 'withdraw',
1129
+ loanId: action.loanId,
1130
+ transfers,
1131
+ } satisfies NormalActionWithdraw
1132
+ }
1133
+ case 'withdraw-with-bond': {
1134
+ // transferCryptoCurrencyInSchema,
1135
+ // transferNftInSchema,
1136
+ // transferCryptoCurrencyOutSchema,
1137
+ // transferNftOutSchema,
1138
+ const transfers = action.transfers.filter(
1139
+ (
1140
+ transfer,
1141
+ ): transfer is
1142
+ | TransferCryptoCurrencyIn
1143
+ | TransferNftIn
1144
+ | TransferCryptoCurrencyOut
1145
+ | TransferNftOut =>
1146
+ isTransferCryptoCurrencyIn(transfer) ||
1147
+ isTransferNftIn(transfer) ||
1148
+ isTransferCryptoCurrencyOut(transfer) ||
1149
+ isTransferNftOut(transfer),
1150
+ )
1151
+ if (transfers.length !== action.transfers.length) {
1152
+ throw new Error('Invalid action.transfers for withdraw-with-bond')
1153
+ }
1154
+ if (action.loanId === undefined) {
1155
+ throw new Error('action.loandId is required for withdraw-with-bond')
1156
+ }
1157
+ return {
1158
+ ...action,
1159
+ type: 'LoanNormalAction',
1160
+ action: 'withdraw-with-bond',
1161
+ loanId: action.loanId,
1162
+ transfers,
1163
+ } satisfies NormalActionWithdrawWithBond
1164
+ }
1165
+ }
1166
+ }