@0xtorch/evm 0.0.11 → 0.0.13

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