project-cpu-mcp 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (574) hide show
  1. package/README.md +111 -35
  2. package/dist/api/authentication-required.error.d.ts +6 -0
  3. package/dist/api/authentication-required.error.d.ts.map +1 -0
  4. package/dist/api/authentication-required.error.js +9 -0
  5. package/dist/api/authentication-required.error.js.map +1 -0
  6. package/dist/api/client.d.ts +7 -5
  7. package/dist/api/client.d.ts.map +1 -1
  8. package/dist/api/client.js +29 -14
  9. package/dist/api/client.js.map +1 -1
  10. package/dist/api/constants.d.ts +2 -0
  11. package/dist/api/constants.d.ts.map +1 -1
  12. package/dist/api/constants.js +6 -0
  13. package/dist/api/constants.js.map +1 -1
  14. package/dist/api/types.d.ts +189 -220
  15. package/dist/api/types.d.ts.map +1 -1
  16. package/dist/api/types.js +43 -29
  17. package/dist/api/types.js.map +1 -1
  18. package/dist/config/constants.d.ts +6 -2
  19. package/dist/config/constants.d.ts.map +1 -1
  20. package/dist/config/constants.js +6 -2
  21. package/dist/config/constants.js.map +1 -1
  22. package/dist/config/types.js +2 -2
  23. package/dist/config/types.js.map +1 -1
  24. package/dist/contracts/cell.abi.d.ts +26 -2
  25. package/dist/contracts/cell.abi.d.ts.map +1 -1
  26. package/dist/contracts/cell.abi.js +21 -2
  27. package/dist/contracts/cell.abi.js.map +1 -1
  28. package/dist/contracts/erc20.abi.d.ts.map +1 -1
  29. package/dist/contracts/erc20.abi.js +1 -2
  30. package/dist/contracts/erc20.abi.js.map +1 -1
  31. package/dist/contracts/trade.abi.d.ts +341 -0
  32. package/dist/contracts/trade.abi.d.ts.map +1 -1
  33. package/dist/contracts/trade.abi.js +163 -0
  34. package/dist/contracts/trade.abi.js.map +1 -1
  35. package/dist/contracts/trade.types.d.ts +14 -0
  36. package/dist/contracts/trade.types.d.ts.map +1 -0
  37. package/dist/contracts/trade.types.js +15 -0
  38. package/dist/contracts/trade.types.js.map +1 -0
  39. package/dist/contracts/transport.abi.d.ts +4 -0
  40. package/dist/contracts/transport.abi.d.ts.map +1 -1
  41. package/dist/contracts/transport.abi.js +1 -0
  42. package/dist/contracts/transport.abi.js.map +1 -1
  43. package/dist/index.js +40 -3
  44. package/dist/index.js.map +1 -1
  45. package/dist/logger/constants.d.ts +7 -0
  46. package/dist/logger/constants.d.ts.map +1 -1
  47. package/dist/logger/constants.js +11 -0
  48. package/dist/logger/constants.js.map +1 -1
  49. package/dist/logger/file-log.utils.d.ts +4 -0
  50. package/dist/logger/file-log.utils.d.ts.map +1 -0
  51. package/dist/logger/file-log.utils.js +23 -0
  52. package/dist/logger/file-log.utils.js.map +1 -0
  53. package/dist/logger/index.d.ts +1 -1
  54. package/dist/logger/index.d.ts.map +1 -1
  55. package/dist/logger/index.js +5 -3
  56. package/dist/logger/index.js.map +1 -1
  57. package/dist/logger/logger.d.ts +4 -0
  58. package/dist/logger/logger.d.ts.map +1 -1
  59. package/dist/logger/logger.js +48 -3
  60. package/dist/logger/logger.js.map +1 -1
  61. package/dist/logger/redact.utils.d.ts.map +1 -1
  62. package/dist/logger/redact.utils.js +7 -2
  63. package/dist/logger/redact.utils.js.map +1 -1
  64. package/dist/logger/types.d.ts +8 -0
  65. package/dist/logger/types.d.ts.map +1 -1
  66. package/dist/map/attention.utils.d.ts.map +1 -1
  67. package/dist/map/attention.utils.js +1 -0
  68. package/dist/map/attention.utils.js.map +1 -1
  69. package/dist/map/cell-view.utils.d.ts.map +1 -1
  70. package/dist/map/cell-view.utils.js +5 -3
  71. package/dist/map/cell-view.utils.js.map +1 -1
  72. package/dist/map/process-projection.utils.js +2 -2
  73. package/dist/map/process-projection.utils.js.map +1 -1
  74. package/dist/map/reader.utils.d.ts.map +1 -1
  75. package/dist/map/reader.utils.js +3 -2
  76. package/dist/map/reader.utils.js.map +1 -1
  77. package/dist/map/storage.utils.d.ts.map +1 -1
  78. package/dist/map/storage.utils.js +5 -1
  79. package/dist/map/storage.utils.js.map +1 -1
  80. package/dist/map/types.d.ts +21 -0
  81. package/dist/map/types.d.ts.map +1 -1
  82. package/dist/map/types.js +6 -0
  83. package/dist/map/types.js.map +1 -1
  84. package/dist/paybox/auth/authority.d.ts +46 -0
  85. package/dist/paybox/auth/authority.d.ts.map +1 -0
  86. package/dist/paybox/auth/authority.js +410 -0
  87. package/dist/paybox/auth/authority.js.map +1 -0
  88. package/dist/paybox/auth/browser-opener.d.ts +8 -0
  89. package/dist/paybox/auth/browser-opener.d.ts.map +1 -0
  90. package/dist/paybox/auth/browser-opener.js +22 -0
  91. package/dist/paybox/auth/browser-opener.js.map +1 -0
  92. package/dist/paybox/auth/browser-opener.utils.d.ts +2 -0
  93. package/dist/paybox/auth/browser-opener.utils.d.ts.map +1 -0
  94. package/dist/paybox/auth/browser-opener.utils.js +10 -0
  95. package/dist/paybox/auth/browser-opener.utils.js.map +1 -0
  96. package/dist/paybox/auth/constants.d.ts +16 -0
  97. package/dist/paybox/auth/constants.d.ts.map +1 -0
  98. package/dist/paybox/auth/constants.js +16 -0
  99. package/dist/paybox/auth/constants.js.map +1 -0
  100. package/dist/paybox/auth/coordinator.d.ts +21 -0
  101. package/dist/paybox/auth/coordinator.d.ts.map +1 -0
  102. package/dist/paybox/auth/coordinator.factory.d.ts +5 -0
  103. package/dist/paybox/auth/coordinator.factory.d.ts.map +1 -0
  104. package/dist/paybox/auth/coordinator.factory.js +5 -0
  105. package/dist/paybox/auth/coordinator.factory.js.map +1 -0
  106. package/dist/paybox/auth/coordinator.js +87 -0
  107. package/dist/paybox/auth/coordinator.js.map +1 -0
  108. package/dist/paybox/auth/coordinator.utils.d.ts +4 -0
  109. package/dist/paybox/auth/coordinator.utils.d.ts.map +1 -0
  110. package/dist/paybox/auth/coordinator.utils.js +8 -0
  111. package/dist/paybox/auth/coordinator.utils.js.map +1 -0
  112. package/dist/paybox/auth/flow-session.d.ts +24 -0
  113. package/dist/paybox/auth/flow-session.d.ts.map +1 -0
  114. package/dist/paybox/auth/flow-session.js +155 -0
  115. package/dist/paybox/auth/flow-session.js.map +1 -0
  116. package/dist/paybox/auth/loopback-flow.d.ts +49 -0
  117. package/dist/paybox/auth/loopback-flow.d.ts.map +1 -0
  118. package/dist/paybox/auth/loopback-flow.js +381 -0
  119. package/dist/paybox/auth/loopback-flow.js.map +1 -0
  120. package/dist/paybox/auth/loopback-flow.utils.d.ts +7 -0
  121. package/dist/paybox/auth/loopback-flow.utils.d.ts.map +1 -0
  122. package/dist/paybox/auth/loopback-flow.utils.js +47 -0
  123. package/dist/paybox/auth/loopback-flow.utils.js.map +1 -0
  124. package/dist/paybox/auth/loopback-page-fonts.constants.d.ts +3 -0
  125. package/dist/paybox/auth/loopback-page-fonts.constants.d.ts.map +1 -0
  126. package/dist/paybox/auth/loopback-page-fonts.constants.js +228 -0
  127. package/dist/paybox/auth/loopback-page-fonts.constants.js.map +1 -0
  128. package/dist/paybox/auth/loopback-page.utils.d.ts +4 -0
  129. package/dist/paybox/auth/loopback-page.utils.d.ts.map +1 -0
  130. package/dist/paybox/auth/loopback-page.utils.js +261 -0
  131. package/dist/paybox/auth/loopback-page.utils.js.map +1 -0
  132. package/dist/paybox/auth/provisioning.utils.d.ts +3 -0
  133. package/dist/paybox/auth/provisioning.utils.d.ts.map +1 -0
  134. package/dist/paybox/auth/provisioning.utils.js +27 -0
  135. package/dist/paybox/auth/provisioning.utils.js.map +1 -0
  136. package/dist/paybox/auth/signing-key.utils.d.ts +2 -0
  137. package/dist/paybox/auth/signing-key.utils.d.ts.map +1 -0
  138. package/dist/paybox/auth/signing-key.utils.js +14 -0
  139. package/dist/paybox/auth/signing-key.utils.js.map +1 -0
  140. package/dist/paybox/auth/types.d.ts +18 -0
  141. package/dist/paybox/auth/types.d.ts.map +1 -0
  142. package/dist/paybox/auth/types.js +6 -0
  143. package/dist/paybox/auth/types.js.map +1 -0
  144. package/dist/paybox/auth/utils.d.ts +5 -0
  145. package/dist/paybox/auth/utils.d.ts.map +1 -0
  146. package/dist/paybox/auth/utils.js +17 -0
  147. package/dist/paybox/auth/utils.js.map +1 -0
  148. package/dist/paybox/constants.d.ts +11 -0
  149. package/dist/paybox/constants.d.ts.map +1 -0
  150. package/dist/paybox/constants.js +11 -0
  151. package/dist/paybox/constants.js.map +1 -0
  152. package/dist/paybox/errors.d.ts +43 -0
  153. package/dist/paybox/errors.d.ts.map +1 -0
  154. package/dist/paybox/errors.js +141 -0
  155. package/dist/paybox/errors.js.map +1 -0
  156. package/dist/paybox/sdk/adapter.d.ts +16 -0
  157. package/dist/paybox/sdk/adapter.d.ts.map +1 -0
  158. package/dist/paybox/sdk/adapter.js +127 -0
  159. package/dist/paybox/sdk/adapter.js.map +1 -0
  160. package/dist/paybox/sdk/constants.d.ts +14 -0
  161. package/dist/paybox/sdk/constants.d.ts.map +1 -0
  162. package/dist/paybox/sdk/constants.js +23 -0
  163. package/dist/paybox/sdk/constants.js.map +1 -0
  164. package/dist/paybox/sdk/factory.d.ts +4 -0
  165. package/dist/paybox/sdk/factory.d.ts.map +1 -0
  166. package/dist/paybox/sdk/factory.js +24 -0
  167. package/dist/paybox/sdk/factory.js.map +1 -0
  168. package/dist/paybox/sdk/logging.utils.d.ts +4 -0
  169. package/dist/paybox/sdk/logging.utils.d.ts.map +1 -0
  170. package/dist/paybox/sdk/logging.utils.js +19 -0
  171. package/dist/paybox/sdk/logging.utils.js.map +1 -0
  172. package/dist/paybox/sdk/utils.d.ts +7 -0
  173. package/dist/paybox/sdk/utils.d.ts.map +1 -0
  174. package/dist/paybox/sdk/utils.js +182 -0
  175. package/dist/paybox/sdk/utils.js.map +1 -0
  176. package/dist/paybox/storage.d.ts +17 -0
  177. package/dist/paybox/storage.d.ts.map +1 -0
  178. package/dist/paybox/storage.js +87 -0
  179. package/dist/paybox/storage.js.map +1 -0
  180. package/dist/paybox/types.d.ts +481 -0
  181. package/dist/paybox/types.d.ts.map +1 -0
  182. package/dist/paybox/types.js +144 -0
  183. package/dist/paybox/types.js.map +1 -0
  184. package/dist/paybox/wallet/manager.d.ts +22 -0
  185. package/dist/paybox/wallet/manager.d.ts.map +1 -0
  186. package/dist/paybox/wallet/manager.js +111 -0
  187. package/dist/paybox/wallet/manager.js.map +1 -0
  188. package/dist/paybox/wallet/rpc.client.d.ts +16 -0
  189. package/dist/paybox/wallet/rpc.client.d.ts.map +1 -0
  190. package/dist/paybox/wallet/rpc.client.js +53 -0
  191. package/dist/paybox/wallet/rpc.client.js.map +1 -0
  192. package/dist/paybox/wallet/utils.d.ts +5 -0
  193. package/dist/paybox/wallet/utils.d.ts.map +1 -0
  194. package/dist/paybox/wallet/utils.js +82 -0
  195. package/dist/paybox/wallet/utils.js.map +1 -0
  196. package/dist/server.constants.d.ts.map +1 -1
  197. package/dist/server.constants.js +5 -2
  198. package/dist/server.constants.js.map +1 -1
  199. package/dist/server.d.ts.map +1 -1
  200. package/dist/server.js +8 -2
  201. package/dist/server.js.map +1 -1
  202. package/dist/services/app-config.utils.d.ts.map +1 -1
  203. package/dist/services/app-config.utils.js +22 -11
  204. package/dist/services/app-config.utils.js.map +1 -1
  205. package/dist/services/auth.service.d.ts +3 -5
  206. package/dist/services/auth.service.d.ts.map +1 -1
  207. package/dist/services/auth.service.js +20 -77
  208. package/dist/services/auth.service.js.map +1 -1
  209. package/dist/services/cell.client.d.ts.map +1 -1
  210. package/dist/services/cell.client.js +22 -9
  211. package/dist/services/cell.client.js.map +1 -1
  212. package/dist/services/lot-return.constants.d.ts +3 -0
  213. package/dist/services/lot-return.constants.d.ts.map +1 -0
  214. package/dist/services/lot-return.constants.js +35 -0
  215. package/dist/services/lot-return.constants.js.map +1 -0
  216. package/dist/services/lot-return.service.d.ts +25 -0
  217. package/dist/services/lot-return.service.d.ts.map +1 -0
  218. package/dist/services/lot-return.service.js +151 -0
  219. package/dist/services/lot-return.service.js.map +1 -0
  220. package/dist/services/lot-return.types.d.ts +19 -0
  221. package/dist/services/lot-return.types.d.ts.map +1 -0
  222. package/dist/services/lot-return.types.js +2 -0
  223. package/dist/services/lot-return.types.js.map +1 -0
  224. package/dist/services/lot-return.utils.d.ts +33 -0
  225. package/dist/services/lot-return.utils.d.ts.map +1 -0
  226. package/dist/services/lot-return.utils.js +128 -0
  227. package/dist/services/lot-return.utils.js.map +1 -0
  228. package/dist/services/lot-terms.constants.d.ts +4 -0
  229. package/dist/services/lot-terms.constants.d.ts.map +1 -0
  230. package/dist/services/lot-terms.constants.js +5 -0
  231. package/dist/services/lot-terms.constants.js.map +1 -0
  232. package/dist/services/lot-terms.helpers.d.ts +11 -0
  233. package/dist/services/lot-terms.helpers.d.ts.map +1 -0
  234. package/dist/services/lot-terms.helpers.js +45 -0
  235. package/dist/services/lot-terms.helpers.js.map +1 -0
  236. package/dist/services/lot-terms.service.d.ts +20 -0
  237. package/dist/services/lot-terms.service.d.ts.map +1 -0
  238. package/dist/services/lot-terms.service.js +119 -0
  239. package/dist/services/lot-terms.service.js.map +1 -0
  240. package/dist/services/lot-terms.types.d.ts +25 -0
  241. package/dist/services/lot-terms.types.d.ts.map +1 -0
  242. package/dist/services/lot-terms.types.js +2 -0
  243. package/dist/services/lot-terms.types.js.map +1 -0
  244. package/dist/services/reveal-revert.utils.d.ts +1 -0
  245. package/dist/services/reveal-revert.utils.d.ts.map +1 -1
  246. package/dist/services/reveal-revert.utils.js +20 -0
  247. package/dist/services/reveal-revert.utils.js.map +1 -1
  248. package/dist/services/reveal.constants.d.ts +1 -1
  249. package/dist/services/reveal.constants.d.ts.map +1 -1
  250. package/dist/services/reveal.constants.js +1 -1
  251. package/dist/services/reveal.constants.js.map +1 -1
  252. package/dist/services/reveal.service.d.ts +4 -3
  253. package/dist/services/reveal.service.d.ts.map +1 -1
  254. package/dist/services/reveal.service.js +35 -10
  255. package/dist/services/reveal.service.js.map +1 -1
  256. package/dist/services/reveal.utils.d.ts +7 -8
  257. package/dist/services/reveal.utils.d.ts.map +1 -1
  258. package/dist/services/reveal.utils.js +15 -8
  259. package/dist/services/reveal.utils.js.map +1 -1
  260. package/dist/services/route.constants.d.ts +12 -1
  261. package/dist/services/route.constants.d.ts.map +1 -1
  262. package/dist/services/route.constants.js +66 -15
  263. package/dist/services/route.constants.js.map +1 -1
  264. package/dist/services/route.lots.d.ts +18 -0
  265. package/dist/services/route.lots.d.ts.map +1 -0
  266. package/dist/services/route.lots.js +33 -0
  267. package/dist/services/route.lots.js.map +1 -0
  268. package/dist/services/route.service.d.ts +13 -4
  269. package/dist/services/route.service.d.ts.map +1 -1
  270. package/dist/services/route.service.js +95 -13
  271. package/dist/services/route.service.js.map +1 -1
  272. package/dist/services/route.types.d.ts +76 -0
  273. package/dist/services/route.types.d.ts.map +1 -0
  274. package/dist/services/route.types.js +8 -0
  275. package/dist/services/route.types.js.map +1 -0
  276. package/dist/services/route.utils.d.ts +19 -0
  277. package/dist/services/route.utils.d.ts.map +1 -1
  278. package/dist/services/route.utils.js +35 -0
  279. package/dist/services/route.utils.js.map +1 -1
  280. package/dist/services/trade-eviction.constants.d.ts +12 -0
  281. package/dist/services/trade-eviction.constants.d.ts.map +1 -0
  282. package/dist/services/trade-eviction.constants.js +25 -0
  283. package/dist/services/trade-eviction.constants.js.map +1 -0
  284. package/dist/services/trade-eviction.service.d.ts +22 -0
  285. package/dist/services/trade-eviction.service.d.ts.map +1 -0
  286. package/dist/services/trade-eviction.service.js +101 -0
  287. package/dist/services/trade-eviction.service.js.map +1 -0
  288. package/dist/services/trade-eviction.types.d.ts +30 -0
  289. package/dist/services/trade-eviction.types.d.ts.map +1 -0
  290. package/dist/services/trade-eviction.types.js +2 -0
  291. package/dist/services/trade-eviction.types.js.map +1 -0
  292. package/dist/services/trade-eviction.utils.d.ts +9 -0
  293. package/dist/services/trade-eviction.utils.d.ts.map +1 -0
  294. package/dist/services/trade-eviction.utils.js +38 -0
  295. package/dist/services/trade-eviction.utils.js.map +1 -0
  296. package/dist/services/trade-rules.service.d.ts +15 -0
  297. package/dist/services/trade-rules.service.d.ts.map +1 -0
  298. package/dist/services/trade-rules.service.js +45 -0
  299. package/dist/services/trade-rules.service.js.map +1 -0
  300. package/dist/services/trade.client.d.ts +11 -1
  301. package/dist/services/trade.client.d.ts.map +1 -1
  302. package/dist/services/trade.client.js +87 -0
  303. package/dist/services/trade.client.js.map +1 -1
  304. package/dist/services/trade.constants.d.ts +9 -0
  305. package/dist/services/trade.constants.d.ts.map +1 -0
  306. package/dist/services/trade.constants.js +28 -0
  307. package/dist/services/trade.constants.js.map +1 -0
  308. package/dist/services/trade.helpers.d.ts +9 -1
  309. package/dist/services/trade.helpers.d.ts.map +1 -1
  310. package/dist/services/trade.helpers.js +40 -27
  311. package/dist/services/trade.helpers.js.map +1 -1
  312. package/dist/services/transport-revert.utils.d.ts +3 -0
  313. package/dist/services/transport-revert.utils.d.ts.map +1 -0
  314. package/dist/services/transport-revert.utils.js +15 -0
  315. package/dist/services/transport-revert.utils.js.map +1 -0
  316. package/dist/services/transport.client.d.ts.map +1 -1
  317. package/dist/services/transport.client.js +14 -6
  318. package/dist/services/transport.client.js.map +1 -1
  319. package/dist/services/types.d.ts +249 -21
  320. package/dist/services/types.d.ts.map +1 -1
  321. package/dist/services/types.js +25 -0
  322. package/dist/services/types.js.map +1 -1
  323. package/dist/services/warehouse.utils.d.ts +8 -0
  324. package/dist/services/warehouse.utils.d.ts.map +1 -1
  325. package/dist/services/warehouse.utils.js +25 -0
  326. package/dist/services/warehouse.utils.js.map +1 -1
  327. package/dist/session/manager.d.ts +1 -0
  328. package/dist/session/manager.d.ts.map +1 -1
  329. package/dist/session/manager.js +13 -0
  330. package/dist/session/manager.js.map +1 -1
  331. package/dist/session/storage.d.ts +0 -3
  332. package/dist/session/storage.d.ts.map +1 -1
  333. package/dist/session/storage.js +6 -43
  334. package/dist/session/storage.js.map +1 -1
  335. package/dist/session/types.d.ts +4 -98
  336. package/dist/session/types.d.ts.map +1 -1
  337. package/dist/session/types.js +0 -15
  338. package/dist/session/types.js.map +1 -1
  339. package/dist/tools/authenticate.d.ts +1 -1
  340. package/dist/tools/authenticate.d.ts.map +1 -1
  341. package/dist/tools/authenticate.js +19 -45
  342. package/dist/tools/authenticate.js.map +1 -1
  343. package/dist/tools/config/get-game-config/constants.d.ts +3 -0
  344. package/dist/tools/config/get-game-config/constants.d.ts.map +1 -1
  345. package/dist/tools/config/get-game-config/constants.js +13 -2
  346. package/dist/tools/config/get-game-config/constants.js.map +1 -1
  347. package/dist/tools/config/get-game-config/get-game-config.d.ts.map +1 -1
  348. package/dist/tools/config/get-game-config/get-game-config.js +6 -3
  349. package/dist/tools/config/get-game-config/get-game-config.js.map +1 -1
  350. package/dist/tools/config/get-game-config/get-game-config.utils.d.ts +4 -4
  351. package/dist/tools/config/get-game-config/get-game-config.utils.d.ts.map +1 -1
  352. package/dist/tools/config/get-game-config/get-game-config.utils.js +26 -9
  353. package/dist/tools/config/get-game-config/get-game-config.utils.js.map +1 -1
  354. package/dist/tools/config/get-game-config/types.d.ts +6 -2
  355. package/dist/tools/config/get-game-config/types.d.ts.map +1 -1
  356. package/dist/tools/config/resource-lens/resource-lens.utils.d.ts.map +1 -1
  357. package/dist/tools/config/resource-lens/resource-lens.utils.js +5 -4
  358. package/dist/tools/config/resource-lens/resource-lens.utils.js.map +1 -1
  359. package/dist/tools/map/attention/attention.d.ts.map +1 -1
  360. package/dist/tools/map/attention/attention.js +16 -5
  361. package/dist/tools/map/attention/attention.js.map +1 -1
  362. package/dist/tools/map/attention/constants.d.ts +6 -0
  363. package/dist/tools/map/attention/constants.d.ts.map +1 -1
  364. package/dist/tools/map/attention/constants.js +16 -2
  365. package/dist/tools/map/attention/constants.js.map +1 -1
  366. package/dist/tools/map/attention/evicted.service.d.ts +19 -0
  367. package/dist/tools/map/attention/evicted.service.d.ts.map +1 -0
  368. package/dist/tools/map/attention/evicted.service.js +73 -0
  369. package/dist/tools/map/attention/evicted.service.js.map +1 -0
  370. package/dist/tools/map/attention/evicted.utils.d.ts +16 -0
  371. package/dist/tools/map/attention/evicted.utils.d.ts.map +1 -0
  372. package/dist/tools/map/attention/evicted.utils.js +72 -0
  373. package/dist/tools/map/attention/evicted.utils.js.map +1 -0
  374. package/dist/tools/map/attention/panel.utils.d.ts.map +1 -1
  375. package/dist/tools/map/attention/panel.utils.js +1 -0
  376. package/dist/tools/map/attention/panel.utils.js.map +1 -1
  377. package/dist/tools/map/attention/types.d.ts +17 -0
  378. package/dist/tools/map/attention/types.d.ts.map +1 -1
  379. package/dist/tools/map/attention/types.js.map +1 -1
  380. package/dist/tools/map/get-map/constants.d.ts.map +1 -1
  381. package/dist/tools/map/get-map/constants.js +4 -2
  382. package/dist/tools/map/get-map/constants.js.map +1 -1
  383. package/dist/tools/reveal/constants.d.ts.map +1 -1
  384. package/dist/tools/reveal/constants.js +3 -1
  385. package/dist/tools/reveal/constants.js.map +1 -1
  386. package/dist/tools/trade/buy-lot/buy-lot.d.ts.map +1 -1
  387. package/dist/tools/trade/buy-lot/buy-lot.js +2 -0
  388. package/dist/tools/trade/buy-lot/buy-lot.js.map +1 -1
  389. package/dist/tools/trade/buy-lot/constants.d.ts.map +1 -1
  390. package/dist/tools/trade/buy-lot/constants.js +2 -0
  391. package/dist/tools/trade/buy-lot/constants.js.map +1 -1
  392. package/dist/tools/trade/buyer-guard/constants.d.ts +4 -0
  393. package/dist/tools/trade/buyer-guard/constants.d.ts.map +1 -0
  394. package/dist/tools/trade/buyer-guard/constants.js +11 -0
  395. package/dist/tools/trade/buyer-guard/constants.js.map +1 -0
  396. package/dist/tools/trade/buyer-guard/lot-open.guard.d.ts +9 -0
  397. package/dist/tools/trade/buyer-guard/lot-open.guard.d.ts.map +1 -0
  398. package/dist/tools/trade/buyer-guard/lot-open.guard.js +15 -0
  399. package/dist/tools/trade/buyer-guard/lot-open.guard.js.map +1 -0
  400. package/dist/tools/trade/buyer-guard/types.d.ts +6 -0
  401. package/dist/tools/trade/buyer-guard/types.d.ts.map +1 -0
  402. package/dist/tools/trade/buyer-guard/types.js +2 -0
  403. package/dist/tools/trade/buyer-guard/types.js.map +1 -0
  404. package/dist/tools/trade/constants.d.ts +5 -0
  405. package/dist/tools/trade/constants.d.ts.map +1 -0
  406. package/dist/tools/trade/constants.js +14 -0
  407. package/dist/tools/trade/constants.js.map +1 -0
  408. package/dist/tools/trade/create-lot/constants.d.ts.map +1 -1
  409. package/dist/tools/trade/create-lot/constants.js +4 -1
  410. package/dist/tools/trade/create-lot/constants.js.map +1 -1
  411. package/dist/tools/trade/create-lot/create-lot.d.ts +2 -1
  412. package/dist/tools/trade/create-lot/create-lot.d.ts.map +1 -1
  413. package/dist/tools/trade/create-lot/create-lot.js +15 -1
  414. package/dist/tools/trade/create-lot/create-lot.js.map +1 -1
  415. package/dist/tools/trade/evict-lot/constants.d.ts +4 -0
  416. package/dist/tools/trade/evict-lot/constants.d.ts.map +1 -0
  417. package/dist/tools/trade/evict-lot/constants.js +13 -0
  418. package/dist/tools/trade/evict-lot/constants.js.map +1 -0
  419. package/dist/tools/trade/evict-lot/evict-lot.d.ts +6 -0
  420. package/dist/tools/trade/evict-lot/evict-lot.d.ts.map +1 -0
  421. package/dist/tools/trade/evict-lot/evict-lot.js +35 -0
  422. package/dist/tools/trade/evict-lot/evict-lot.js.map +1 -0
  423. package/dist/tools/trade/evict-lot/format.utils.d.ts +5 -0
  424. package/dist/tools/trade/evict-lot/format.utils.d.ts.map +1 -0
  425. package/dist/tools/trade/evict-lot/format.utils.js +10 -0
  426. package/dist/tools/trade/evict-lot/format.utils.js.map +1 -0
  427. package/dist/tools/trade/evict-lot/types.d.ts +5 -0
  428. package/dist/tools/trade/evict-lot/types.d.ts.map +1 -0
  429. package/dist/tools/trade/evict-lot/types.js +8 -0
  430. package/dist/tools/trade/evict-lot/types.js.map +1 -0
  431. package/dist/tools/trade/format.utils.d.ts +2 -4
  432. package/dist/tools/trade/format.utils.d.ts.map +1 -1
  433. package/dist/tools/trade/format.utils.js +11 -13
  434. package/dist/tools/trade/format.utils.js.map +1 -1
  435. package/dist/tools/trade/get-lot/constants.d.ts.map +1 -1
  436. package/dist/tools/trade/get-lot/constants.js +2 -1
  437. package/dist/tools/trade/get-lot/constants.js.map +1 -1
  438. package/dist/tools/trade/list-lots/constants.d.ts +2 -0
  439. package/dist/tools/trade/list-lots/constants.d.ts.map +1 -1
  440. package/dist/tools/trade/list-lots/constants.js +5 -1
  441. package/dist/tools/trade/list-lots/constants.js.map +1 -1
  442. package/dist/tools/trade/list-lots/list-lots.d.ts.map +1 -1
  443. package/dist/tools/trade/list-lots/list-lots.js +2 -1
  444. package/dist/tools/trade/list-lots/list-lots.js.map +1 -1
  445. package/dist/tools/trade/list-lots/list-lots.utils.d.ts +8 -0
  446. package/dist/tools/trade/list-lots/list-lots.utils.d.ts.map +1 -0
  447. package/dist/tools/trade/list-lots/list-lots.utils.js +10 -0
  448. package/dist/tools/trade/list-lots/list-lots.utils.js.map +1 -0
  449. package/dist/tools/trade/list-mine/constants.d.ts.map +1 -1
  450. package/dist/tools/trade/list-mine/constants.js +3 -1
  451. package/dist/tools/trade/list-mine/constants.js.map +1 -1
  452. package/dist/tools/trade/lot-terms/constants.d.ts +5 -0
  453. package/dist/tools/trade/lot-terms/constants.d.ts.map +1 -0
  454. package/dist/tools/trade/lot-terms/constants.js +13 -0
  455. package/dist/tools/trade/lot-terms/constants.js.map +1 -0
  456. package/dist/tools/trade/lot-terms/factory.d.ts +4 -0
  457. package/dist/tools/trade/lot-terms/factory.d.ts.map +1 -0
  458. package/dist/tools/trade/lot-terms/factory.js +14 -0
  459. package/dist/tools/trade/lot-terms/factory.js.map +1 -0
  460. package/dist/tools/trade/lot-terms/format.utils.d.ts +4 -0
  461. package/dist/tools/trade/lot-terms/format.utils.d.ts.map +1 -0
  462. package/dist/tools/trade/lot-terms/format.utils.js +30 -0
  463. package/dist/tools/trade/lot-terms/format.utils.js.map +1 -0
  464. package/dist/tools/trade/lot-terms/lot-terms.d.ts +5 -0
  465. package/dist/tools/trade/lot-terms/lot-terms.d.ts.map +1 -0
  466. package/dist/tools/trade/lot-terms/lot-terms.js +23 -0
  467. package/dist/tools/trade/lot-terms/lot-terms.js.map +1 -0
  468. package/dist/tools/trade/lot-terms/types.d.ts +6 -0
  469. package/dist/tools/trade/lot-terms/types.d.ts.map +1 -0
  470. package/dist/tools/trade/lot-terms/types.js +7 -0
  471. package/dist/tools/trade/lot-terms/types.js.map +1 -0
  472. package/dist/tools/trade/market-index/constants.d.ts.map +1 -1
  473. package/dist/tools/trade/market-index/constants.js +2 -0
  474. package/dist/tools/trade/market-index/constants.js.map +1 -1
  475. package/dist/tools/trade/markets/constants.d.ts.map +1 -1
  476. package/dist/tools/trade/markets/constants.js +2 -1
  477. package/dist/tools/trade/markets/constants.js.map +1 -1
  478. package/dist/tools/trade/quote-buy/constants.d.ts.map +1 -1
  479. package/dist/tools/trade/quote-buy/constants.js +4 -2
  480. package/dist/tools/trade/quote-buy/constants.js.map +1 -1
  481. package/dist/tools/trade/quote-buy/quote-buy.d.ts.map +1 -1
  482. package/dist/tools/trade/quote-buy/quote-buy.js +2 -0
  483. package/dist/tools/trade/quote-buy/quote-buy.js.map +1 -1
  484. package/dist/tools/trade/quote-lot-return/constants.d.ts +2 -0
  485. package/dist/tools/trade/quote-lot-return/constants.d.ts.map +1 -0
  486. package/dist/tools/trade/quote-lot-return/constants.js +11 -0
  487. package/dist/tools/trade/quote-lot-return/constants.js.map +1 -0
  488. package/dist/tools/trade/quote-lot-return/quote-lot-return.d.ts +5 -0
  489. package/dist/tools/trade/quote-lot-return/quote-lot-return.d.ts.map +1 -0
  490. package/dist/tools/trade/quote-lot-return/quote-lot-return.js +20 -0
  491. package/dist/tools/trade/quote-lot-return/quote-lot-return.js.map +1 -0
  492. package/dist/tools/trade/return-lot/constants.d.ts +5 -0
  493. package/dist/tools/trade/return-lot/constants.d.ts.map +1 -0
  494. package/dist/tools/trade/return-lot/constants.js +26 -0
  495. package/dist/tools/trade/return-lot/constants.js.map +1 -0
  496. package/dist/tools/trade/return-lot/factory.d.ts +4 -0
  497. package/dist/tools/trade/return-lot/factory.d.ts.map +1 -0
  498. package/dist/tools/trade/return-lot/factory.js +18 -0
  499. package/dist/tools/trade/return-lot/factory.js.map +1 -0
  500. package/dist/tools/trade/return-lot/format.utils.d.ts +5 -0
  501. package/dist/tools/trade/return-lot/format.utils.d.ts.map +1 -0
  502. package/dist/tools/trade/return-lot/format.utils.js +39 -0
  503. package/dist/tools/trade/return-lot/format.utils.js.map +1 -0
  504. package/dist/tools/trade/return-lot/return-lot.d.ts +5 -0
  505. package/dist/tools/trade/return-lot/return-lot.d.ts.map +1 -0
  506. package/dist/tools/trade/return-lot/return-lot.js +25 -0
  507. package/dist/tools/trade/return-lot/return-lot.js.map +1 -0
  508. package/dist/tools/trade/return-lot/types.d.ts +11 -0
  509. package/dist/tools/trade/return-lot/types.d.ts.map +1 -0
  510. package/dist/tools/trade/return-lot/types.js +21 -0
  511. package/dist/tools/trade/return-lot/types.js.map +1 -0
  512. package/dist/tools/trade/types.d.ts +0 -4
  513. package/dist/tools/trade/types.d.ts.map +1 -1
  514. package/dist/tools/trade/types.js +4 -12
  515. package/dist/tools/trade/types.js.map +1 -1
  516. package/dist/tools/transport/constants.d.ts.map +1 -1
  517. package/dist/tools/transport/constants.js +9 -0
  518. package/dist/tools/transport/constants.js.map +1 -1
  519. package/dist/tools/transport/network/constants.d.ts +2 -0
  520. package/dist/tools/transport/network/constants.d.ts.map +1 -1
  521. package/dist/tools/transport/network/constants.js +2 -0
  522. package/dist/tools/transport/network/constants.js.map +1 -1
  523. package/dist/tools/transport/network/panel.utils.d.ts +2 -2
  524. package/dist/tools/transport/network/panel.utils.d.ts.map +1 -1
  525. package/dist/tools/transport/network/panel.utils.js +20 -0
  526. package/dist/tools/transport/network/panel.utils.js.map +1 -1
  527. package/dist/tools/transport/network/route-network.d.ts.map +1 -1
  528. package/dist/tools/transport/network/route-network.js +1 -1
  529. package/dist/tools/transport/network/route-network.js.map +1 -1
  530. package/dist/tools/transport/next-hops/next-hops.d.ts.map +1 -1
  531. package/dist/tools/transport/next-hops/next-hops.js +13 -3
  532. package/dist/tools/transport/next-hops/next-hops.js.map +1 -1
  533. package/dist/tools/transport/quote/constants.d.ts.map +1 -1
  534. package/dist/tools/transport/quote/constants.js +5 -3
  535. package/dist/tools/transport/quote/constants.js.map +1 -1
  536. package/dist/tools/transport/types.d.ts +2 -0
  537. package/dist/tools/transport/types.d.ts.map +1 -1
  538. package/dist/tools/transport/types.js +16 -0
  539. package/dist/tools/transport/types.js.map +1 -1
  540. package/dist/tools/types.d.ts +7 -1
  541. package/dist/tools/types.d.ts.map +1 -1
  542. package/dist/tools/types.js +16 -1
  543. package/dist/tools/types.js.map +1 -1
  544. package/dist/types.d.ts +3 -1
  545. package/dist/types.d.ts.map +1 -1
  546. package/dist/types.js +1 -1
  547. package/dist/types.js.map +1 -1
  548. package/dist/utils/wei.constants.d.ts +6 -0
  549. package/dist/utils/wei.constants.d.ts.map +1 -0
  550. package/dist/utils/wei.constants.js +6 -0
  551. package/dist/utils/wei.constants.js.map +1 -0
  552. package/dist/wallet/index.d.ts.map +1 -1
  553. package/dist/wallet/index.js +2 -3
  554. package/dist/wallet/index.js.map +1 -1
  555. package/dist/wallet/types.d.ts +0 -9
  556. package/dist/wallet/types.d.ts.map +1 -1
  557. package/dist/wallet/types.js.map +1 -1
  558. package/package.json +2 -2
  559. package/dist/tools/trade/cancel-lot/cancel-lot.d.ts +0 -4
  560. package/dist/tools/trade/cancel-lot/cancel-lot.d.ts.map +0 -1
  561. package/dist/tools/trade/cancel-lot/cancel-lot.js +0 -20
  562. package/dist/tools/trade/cancel-lot/cancel-lot.js.map +0 -1
  563. package/dist/tools/trade/cancel-lot/constants.d.ts +0 -2
  564. package/dist/tools/trade/cancel-lot/constants.d.ts.map +0 -1
  565. package/dist/tools/trade/cancel-lot/constants.js +0 -8
  566. package/dist/tools/trade/cancel-lot/constants.js.map +0 -1
  567. package/dist/wallet/agw.manager.d.ts +0 -20
  568. package/dist/wallet/agw.manager.d.ts.map +0 -1
  569. package/dist/wallet/agw.manager.js +0 -90
  570. package/dist/wallet/agw.manager.js.map +0 -1
  571. package/dist/wallet/agw.provider.d.ts +0 -14
  572. package/dist/wallet/agw.provider.d.ts.map +0 -1
  573. package/dist/wallet/agw.provider.js +0 -48
  574. package/dist/wallet/agw.provider.js.map +0 -1
@@ -0,0 +1,101 @@
1
+ import { parseEventLogs } from 'viem';
2
+ import { preparePaidAction } from './paid-action.js';
3
+ import { AppContract } from './paid-action.types.js';
4
+ import { EVICTION_TX_LABEL } from './trade-eviction.constants.js';
5
+ import { enrichEvictionRevert, hubNotInMapMessage, lotAlreadyEvictedMessage, lotDeliveringMessage, lotNotLiveMessage, notHubOwnerMessage, selfEvictionMessage, } from './trade-eviction.utils.js';
6
+ import { lotStateFromChain } from './trade.helpers.js';
7
+ import { LotState } from '../api/types.js';
8
+ import { TRADE_ABI } from '../contracts/trade.abi.js';
9
+ import { sameAddress } from '../randomness/request.utils.js';
10
+ /**
11
+ * A hub owner ending one foreign Open lot on their own hub. Eviction is the narrowest write in Trade: it
12
+ * takes the shelf back and nothing else — no route, no escrow, no transfer — so this service holds no
13
+ * transport, allowance or delivery dependency at all, and the lot's units stay the seller's and stay
14
+ * escrowed until the seller ships them home themselves.
15
+ */
16
+ export class LotEvictionService {
17
+ wallet;
18
+ appConfig;
19
+ tradeClient;
20
+ contracts;
21
+ mapReader;
22
+ logger;
23
+ constructor(options) {
24
+ this.wallet = options.wallet;
25
+ this.appConfig = options.appConfig;
26
+ this.tradeClient = options.tradeClient;
27
+ this.contracts = options.contracts;
28
+ this.mapReader = options.mapReader;
29
+ this.logger = options.logger;
30
+ }
31
+ async evictLot(input) {
32
+ const action = await preparePaidAction({ appConfig: this.appConfig, wallet: this.wallet });
33
+ const trade = action.requireContract(AppContract.Trade, 'cannot evict a lot');
34
+ const caller = action.wallet.getAddress();
35
+ const lotId = BigInt(input.lotId);
36
+ const lot = await this.tradeClient.getLot({ trade, lotId });
37
+ this.assertForeignOpenLot(input.lotId, lot, caller);
38
+ await this.assertHubOwner(input.lotId, lot, caller);
39
+ this.logger.info('evicting lot', {
40
+ lotId: input.lotId,
41
+ hub: lot.hub.toString(),
42
+ network: action.config.network,
43
+ });
44
+ const confirmed = await this.submit(trade, lotId, input.lotId);
45
+ const evicted = parseEventLogs({ abi: TRADE_ABI, eventName: 'LotEvicted', logs: confirmed.logs }).find((event) => sameAddress(event.address, trade));
46
+ if (evicted === undefined) {
47
+ throw new Error(`The eviction of lot ${input.lotId} confirmed but Trade emitted no LotEvicted event; the lot's ` +
48
+ `state is unproven. Re-read it with cpu_get_lot before acting on it.`);
49
+ }
50
+ return {
51
+ lotId: evicted.args.lotId.toString(),
52
+ hubTokenId: lot.hub.toString(),
53
+ sellerAddress: evicted.args.seller,
54
+ resourceId: lot.resource,
55
+ remaining: evicted.args.remaining.toString(),
56
+ state: LotState.Evicted,
57
+ txHash: confirmed.txHash,
58
+ status: confirmed.status,
59
+ blockNumber: confirmed.blockNumber,
60
+ };
61
+ }
62
+ assertForeignOpenLot(lotId, lot, caller) {
63
+ const state = lotStateFromChain(lot.state);
64
+ const hubTokenId = lot.hub.toString();
65
+ if (state === null) {
66
+ throw new Error(lotNotLiveMessage(lotId));
67
+ }
68
+ if (state === LotState.Delivering) {
69
+ throw new Error(lotDeliveringMessage(lotId, hubTokenId));
70
+ }
71
+ if (state === LotState.Evicted) {
72
+ throw new Error(lotAlreadyEvictedMessage(lotId, hubTokenId));
73
+ }
74
+ if (sameAddress(lot.seller, caller)) {
75
+ throw new Error(selfEvictionMessage(lotId));
76
+ }
77
+ }
78
+ // The local snapshot is refreshed first: eviction is admitted on ownership, and a cached hub that has
79
+ // since changed hands would let the call through to a guaranteed on-chain refusal.
80
+ async assertHubOwner(lotId, lot, caller) {
81
+ await this.mapReader.refresh();
82
+ const hubTokenId = lot.hub.toString();
83
+ const hub = await this.mapReader.readRevealCell(hubTokenId);
84
+ if (hub === null) {
85
+ throw new Error(hubNotInMapMessage(lotId, hubTokenId));
86
+ }
87
+ if (!sameAddress(hub.owner, caller)) {
88
+ throw new Error(notHubOwnerMessage(lotId, hubTokenId, hub.owner));
89
+ }
90
+ }
91
+ async submit(trade, lotId, label) {
92
+ try {
93
+ const txHash = await this.tradeClient.evict({ trade, lotId });
94
+ return await this.contracts.confirm(txHash, `${EVICTION_TX_LABEL} ${label}`);
95
+ }
96
+ catch (error) {
97
+ throw enrichEvictionRevert(error, label);
98
+ }
99
+ }
100
+ }
101
+ //# sourceMappingURL=trade-eviction.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-eviction.service.js","sourceRoot":"","sources":["../../src/services/trade-eviction.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,MAAM,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAOlE,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IACV,MAAM,CAAiB;IACvB,SAAS,CAAa;IACtB,WAAW,CAAqB;IAChC,SAAS,CAAwB;IACjC,SAAS,CAAmB;IAC5B,MAAM,CAAU;IAEjC,YAAY,OAAkC;QAC1C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CA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AS,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,IAAI,KAAK,EAAE,CAAC,CAAC;QACjF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,oBAAoB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,30 @@
1
+ import type { Hash } from 'viem';
2
+ import type { EvictLotInput, EvictLotResult, EvictLotParams, GetLotParams, IAppConfig, OnChainLot } from './types.js';
3
+ import type { ILogger } from '../logger/types.js';
4
+ import type { RevealCellReader } from '../map/types.js';
5
+ import type { ConfirmedTx, WalletProvider } from '../wallet/types.js';
6
+ /**
7
+ * Deliberately narrower than `ITradeClient`: eviction must never be able to reach `buy`, `cancel`,
8
+ * `reclaim` or `createLot`, and a service that cannot name them cannot move a unit of anyone's goods.
9
+ */
10
+ export interface ILotEvictionClient {
11
+ getLot(params: GetLotParams): Promise<OnChainLot>;
12
+ evict(params: EvictLotParams): Promise<Hash>;
13
+ }
14
+ /** The receipt half of the contract client; eviction sends only through `ILotEvictionClient`. */
15
+ export interface ILotEvictionConfirmer {
16
+ confirm(txHash: Hash, revertLabel: string): Promise<ConfirmedTx>;
17
+ }
18
+ export interface LotEvictionServiceOptions {
19
+ wallet: WalletProvider;
20
+ appConfig: IAppConfig;
21
+ tradeClient: ILotEvictionClient;
22
+ contracts: ILotEvictionConfirmer;
23
+ mapReader: RevealCellReader;
24
+ logger: ILogger;
25
+ }
26
+ /** One hub owner ending one foreign Open lot — implemented by LotEvictionService. */
27
+ export interface ILotEviction {
28
+ evictLot(input: EvictLotInput): Promise<EvictLotResult>;
29
+ }
30
+ //# sourceMappingURL=trade-eviction.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-eviction.types.d.ts","sourceRoot":"","sources":["../../src/services/trade-eviction.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAClD,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,iGAAiG;AACjG,MAAM,WAAW,qBAAqB;IAClC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;IAChC,SAAS,EAAE,qBAAqB,CAAC;IACjC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,qFAAqF;AACrF,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC3D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=trade-eviction.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-eviction.types.js","sourceRoot":"","sources":["../../src/services/trade-eviction.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export declare function lotNotLiveMessage(lotId: string): string;
2
+ export declare function lotDeliveringMessage(lotId: string, hubTokenId: string): string;
3
+ export declare function lotAlreadyEvictedMessage(lotId: string, hubTokenId: string): string;
4
+ export declare function selfEvictionMessage(lotId: string): string;
5
+ export declare function hubNotInMapMessage(lotId: string, hubTokenId: string): string;
6
+ export declare function notHubOwnerMessage(lotId: string, hubTokenId: string, owner: string): string;
7
+ /** Names the on-chain refusal in the agent's own vocabulary; an undecoded revert travels unchanged. */
8
+ export declare function enrichEvictionRevert(error: unknown, lotId: string): unknown;
9
+ //# sourceMappingURL=trade-eviction.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-eviction.utils.d.ts","sourceRoot":"","sources":["../../src/services/trade-eviction.utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAM9E;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAKlF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK5E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK3F;AAED,uGAAuG;AACvG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAS3E"}
@@ -0,0 +1,38 @@
1
+ import { EVICTION_REVERT_REASONS, EVICTION_SLOT_NOTE, LOT_RETURN_TOOL } from './trade-eviction.constants.js';
2
+ export function lotNotLiveMessage(lotId) {
3
+ return (`The Trade contract holds no live lot ${lotId}: it sold out, was cancelled, or its remainder has already ` +
4
+ `gone home. There is nothing to evict.`);
5
+ }
6
+ export function lotDeliveringMessage(lotId, hubTokenId) {
7
+ return (`Lot ${lotId} is still delivering into Hub ${hubTokenId} — its escrow has not arrived yet. Only an open lot ` +
8
+ `can be evicted, and eviction never finalizes a delivery on the seller's behalf. Wait for the escrow to ` +
9
+ `land (the seller finalizes it), re-read the lot with cpu_get_lot, and evict once it is open.`);
10
+ }
11
+ export function lotAlreadyEvictedMessage(lotId, hubTokenId) {
12
+ return (`Lot ${lotId} on Hub ${hubTokenId} is already evicted, so evicting it again would change nothing. ` +
13
+ `${EVICTION_SLOT_NOTE} Only the seller can move those units, with a lot return (${LOT_RETURN_TOOL}).`);
14
+ }
15
+ export function selfEvictionMessage(lotId) {
16
+ return (`Lot ${lotId} is your own lot, and eviction only ever ends someone else's. To take your own remainder off ` +
17
+ `the shelf and ship it home, use a lot return (${LOT_RETURN_TOOL}) with the route you want it to travel.`);
18
+ }
19
+ export function hubNotInMapMessage(lotId, hubTokenId) {
20
+ return (`Hub ${hubTokenId}, which carries lot ${lotId}, is not in the current map, so your ownership of it cannot ` +
21
+ `be verified. Only the hub owner may evict a lot from it.`);
22
+ }
23
+ export function notHubOwnerMessage(lotId, hubTokenId, owner) {
24
+ return (`Only the hub owner can evict a lot from Hub ${hubTokenId} (owner ${owner}), and lot ${lotId} sits there. ` +
25
+ `Eviction is a hub owner's control over their own storage, never a way to reach another player's goods.`);
26
+ }
27
+ /** Names the on-chain refusal in the agent's own vocabulary; an undecoded revert travels unchanged. */
28
+ export function enrichEvictionRevert(error, lotId) {
29
+ if (!(error instanceof Error)) {
30
+ return error;
31
+ }
32
+ const match = EVICTION_REVERT_REASONS.find((entry) => error.message.includes(entry.name));
33
+ if (match === undefined) {
34
+ return error;
35
+ }
36
+ return new Error(`${error.message} — lot ${lotId} was not evicted: ${match.reason}.`, { cause: error });
37
+ }
38
+ //# sourceMappingURL=trade-eviction.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-eviction.utils.js","sourceRoot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AAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1F,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,UAAU,KAAK,qBAAqB,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5G,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ITradeRules, LotListingRulesView, TradeRulesServiceOptions } from './types.js';
2
+ /**
3
+ * The listing rules live only on the deployed Trade contract — the game API's config projects the fee
4
+ * parameters, not the lot window. Reading them is therefore a chain call, and the rulebook read that
5
+ * carries them must survive a chain it cannot reach: an unavailable answer is null, never a guess.
6
+ */
7
+ export declare class TradeRulesService implements ITradeRules {
8
+ private readonly appConfig;
9
+ private readonly wallet;
10
+ private readonly tradeClient;
11
+ private readonly logger;
12
+ constructor(options: TradeRulesServiceOptions);
13
+ loadLotListingRules(): Promise<LotListingRulesView | null>;
14
+ }
15
+ //# sourceMappingURL=trade-rules.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-rules.service.d.ts","sourceRoot":"","sources":["../../src/services/trade-rules.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4B,WAAW,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAMvH;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,OAAO,EAAE,wBAAwB;IAOvC,mBAAmB,IAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CAqBnE"}
@@ -0,0 +1,45 @@
1
+ import { formatEther } from 'viem';
2
+ import { preparePaidAction } from './paid-action.js';
3
+ import { AppContract } from './paid-action.types.js';
4
+ import { errorMessage } from '../utils/error.utils.js';
5
+ import { bpToPercent } from '../utils/format.utils.js';
6
+ /**
7
+ * The listing rules live only on the deployed Trade contract — the game API's config projects the fee
8
+ * parameters, not the lot window. Reading them is therefore a chain call, and the rulebook read that
9
+ * carries them must survive a chain it cannot reach: an unavailable answer is null, never a guess.
10
+ */
11
+ export class TradeRulesService {
12
+ appConfig;
13
+ wallet;
14
+ tradeClient;
15
+ logger;
16
+ constructor(options) {
17
+ this.appConfig = options.appConfig;
18
+ this.wallet = options.wallet;
19
+ this.tradeClient = options.tradeClient;
20
+ this.logger = options.logger;
21
+ }
22
+ async loadLotListingRules() {
23
+ if (!this.wallet.isReady()) {
24
+ return null;
25
+ }
26
+ try {
27
+ const action = await preparePaidAction({ appConfig: this.appConfig, wallet: this.wallet });
28
+ const trade = action.requireContract(AppContract.Trade, 'cannot read the lot listing rules');
29
+ const config = await this.tradeClient.getConfig({ trade });
30
+ return {
31
+ minLotSharePercent: bpToPercent(config.minLotShareBp),
32
+ maxLotSharePercent: bpToPercent(config.maxLotShareBp),
33
+ minUncappedLotValue: config.minUncappedLotValue.toString(),
34
+ maxUncappedLotValue: config.maxUncappedLotValue.toString(),
35
+ maxLotsPerSellerHubResource: config.maxLotsPerSellerResource,
36
+ minPricePerUnit: formatEther(config.minPricePerUnit),
37
+ };
38
+ }
39
+ catch (error) {
40
+ this.logger.warn('could not read the lot listing rules', { error: errorMessage(error) });
41
+ return null;
42
+ }
43
+ }
44
+ }
45
+ //# sourceMappingURL=trade-rules.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade-rules.service.js","sourceRoot":"","sources":["../../src/services/trade-rules.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,EAA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AAE,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE;gBAC1D,2BAA2B,EAAE,MAAM,CAAC,wBAAwB;gBAC5D,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC;aACvD,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACzF,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
@@ -1,5 +1,5 @@
1
1
  import { type Hash } from 'viem';
2
- import type { BuyLotParams, BuyQuoteResult, CancelLotParams, CreateLotParams, GetSaleFeeParams, ITradeClient, QuoteBuyParams, QuoteSaleParams, SaleQuoteResult, SetSaleFeeParams, TradeClientOptions } from './types.js';
2
+ import type { BuyLotParams, BuyQuoteResult, CancelLotParams, CreateLotParams, EvictLotParams, GetLotParams, GetLotsParams, GetSaleFeeParams, GetTradeConfigParams, ITradeClient, LotBoundParams, OnChainLot, OnChainTradeConfig, QuoteBuyParams, QuoteReturnParams, QuoteSaleParams, ReclaimLotParams, ReturnQuoteResult, SaleQuoteResult, SellerEvictedCountParams, SellerLotCountParams, SetSaleFeeParams, TradeClientOptions } from './types.js';
3
3
  export declare class TradeClient implements ITradeClient {
4
4
  private readonly contracts;
5
5
  private readonly logger;
@@ -7,8 +7,18 @@ export declare class TradeClient implements ITradeClient {
7
7
  createLot(params: CreateLotParams): Promise<Hash>;
8
8
  buy(params: BuyLotParams): Promise<Hash>;
9
9
  cancel(params: CancelLotParams): Promise<Hash>;
10
+ reclaim(params: ReclaimLotParams): Promise<Hash>;
11
+ evict(params: EvictLotParams): Promise<Hash>;
10
12
  setSaleFee(params: SetSaleFeeParams): Promise<Hash>;
11
13
  getSaleFee(params: GetSaleFeeParams): Promise<number>;
14
+ getLot(params: GetLotParams): Promise<OnChainLot>;
15
+ getLots(params: GetLotsParams): Promise<Array<OnChainLot>>;
16
+ getConfig(params: GetTradeConfigParams): Promise<OnChainTradeConfig>;
17
+ getMinLotValue(params: LotBoundParams): Promise<bigint>;
18
+ getMaxLotValue(params: LotBoundParams): Promise<bigint>;
19
+ getSellerLotCount(params: SellerLotCountParams): Promise<bigint>;
20
+ getSellerEvictedCount(params: SellerEvictedCountParams): Promise<bigint>;
21
+ quoteReturn(params: QuoteReturnParams): Promise<ReturnQuoteResult>;
12
22
  quoteSale(params: QuoteSaleParams): Promise<SaleQuoteResult>;
13
23
  quoteBuy(params: QuoteBuyParams): Promise<BuyQuoteResult>;
14
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"trade.client.d.ts","sourceRoot":"","sources":["../../src/services/trade.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,IAAI,EAAE,MAAM,MAAM,CAAC;AAGrD,OAAO,KAAK,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,YAAY,CAAC;AAKpB,qBAAa,WAAY,YAAW,YAAY;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,OAAO,EAAE,kBAAkB;IAKjC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBjD,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAexC,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAc9C,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAenD,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUrD,SAAS,CAAC,MAAM,EA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EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IASjD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAS1D,SAAS,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IASpE,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IASvD,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IASvD,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAShE,qBAAqB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC;IASxE,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAalE,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAa5D,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;CAYlE"}
@@ -51,6 +51,24 @@ export class TradeClient {
51
51
  });
52
52
  return this.contracts.send({ to: params.trade, data, value: null, gas: null }, TRADE_ABI);
53
53
  }
54
+ async reclaim(params) {
55
+ const data = encodeFunctionData({
56
+ abi: TRADE_ABI,
57
+ functionName: 'reclaim',
58
+ args: [params.lotId, params.returnTokenIds, params.maxFee],
59
+ });
60
+ this.logger.info('submitting reclaim lot', {
61
+ trade: params.trade,
62
+ lotId: params.lotId.toString(),
63
+ maxFeeWei: params.maxFee.toString(),
64
+ });
65
+ return this.contracts.send({ to: params.trade, data, value: null, gas: null }, TRADE_ABI);
66
+ }
67
+ async evict(params) {
68
+ const data = encodeFunctionData({ abi: TRADE_ABI, functionName: 'evict', args: [params.lotId] });
69
+ this.logger.info('submitting evict lot', { trade: params.trade, lotId: params.lotId.toString() });
70
+ return this.contracts.send({ to: params.trade, data, value: null, gas: null }, TRADE_ABI);
71
+ }
54
72
  async setSaleFee(params) {
55
73
  const data = encodeFunctionData({
56
74
  abi: TRADE_ABI,
@@ -74,6 +92,75 @@ export class TradeClient {
74
92
  });
75
93
  return Number(feeBp);
76
94
  }
95
+ async getLot(params) {
96
+ return this.contracts.read({
97
+ address: params.trade,
98
+ abi: TRADE_ABI,
99
+ functionName: 'getLot',
100
+ args: [params.lotId],
101
+ });
102
+ }
103
+ async getLots(params) {
104
+ return this.contracts.read({
105
+ address: params.trade,
106
+ abi: TRADE_ABI,
107
+ functionName: 'getLots',
108
+ args: [params.lotIds],
109
+ });
110
+ }
111
+ async getConfig(params) {
112
+ return this.contracts.read({
113
+ address: params.trade,
114
+ abi: TRADE_ABI,
115
+ functionName: 'getConfig',
116
+ args: [],
117
+ });
118
+ }
119
+ async getMinLotValue(params) {
120
+ return this.contracts.read({
121
+ address: params.trade,
122
+ abi: TRADE_ABI,
123
+ functionName: 'getMinLotValue',
124
+ args: [params.hub, params.res],
125
+ });
126
+ }
127
+ async getMaxLotValue(params) {
128
+ return this.contracts.read({
129
+ address: params.trade,
130
+ abi: TRADE_ABI,
131
+ functionName: 'getMaxLotValue',
132
+ args: [params.hub, params.res],
133
+ });
134
+ }
135
+ async getSellerLotCount(params) {
136
+ return this.contracts.read({
137
+ address: params.trade,
138
+ abi: TRADE_ABI,
139
+ functionName: 'getSellerLotCount',
140
+ args: [params.seller, params.hub, params.res],
141
+ });
142
+ }
143
+ async getSellerEvictedCount(params) {
144
+ return this.contracts.read({
145
+ address: params.trade,
146
+ abi: TRADE_ABI,
147
+ functionName: 'getSellerEvictedCount',
148
+ args: [params.seller, params.hub],
149
+ });
150
+ }
151
+ async quoteReturn(params) {
152
+ try {
153
+ return await this.contracts.read({
154
+ address: params.trade,
155
+ abi: TRADE_ABI,
156
+ functionName: 'quoteReturn',
157
+ args: [params.lotId, params.returnTokenIds, params.seller],
158
+ });
159
+ }
160
+ catch (error) {
161
+ throw namedQuoteRevert(error);
162
+ }
163
+ }
77
164
  async quoteSale(params) {
78
165
  try {
79
166
  return await this.contracts.read({
@@ -1 +1 @@
1
- {"version":3,"file":"trade.client.js","sourceRoot":"","sources":["../../src/services/trade.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAa,MAAM,MAAM,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AActD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAItD,MAAM,OAAO,WAAW;IACH,SAAS,CAAkB;IAC3B,MAAM,CAAU;IAEjC,YAAY,OAA2B;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAuB;QACnC,MAAM,IAAI,GAAG,kBAAkB,CAAC;YAC5B,GAAG,EAAE,SAAS;YACd,YAAY,EAAE,WAAW;YACzB,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC;SACtG,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE;YACtC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC9B,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;YACjC,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;SACtC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC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AC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;aACxE,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The buy-quote revert map ships as agent-facing prose, so it is pinned here rather than inlined in the
3
+ * helper: `src/__tests__/tool-registry.test.ts` scans it for the vocabulary the surface must never use.
4
+ */
5
+ export declare const QUOTE_REVERT_REASONS: ReadonlyArray<{
6
+ name: string;
7
+ reason: string;
8
+ }>;
9
+ //# sourceMappingURL=trade.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade.constants.d.ts","sourceRoot":"","sources":["../../src/services/trade.constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAwBhF,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The buy-quote revert map ships as agent-facing prose, so it is pinned here rather than inlined in the
3
+ * helper: `src/__tests__/tool-registry.test.ts` scans it for the vocabulary the surface must never use.
4
+ */
5
+ export const QUOTE_REVERT_REASONS = [
6
+ { name: 'LotNotOpen', reason: 'the lot is closed — sold out, still delivering, or cancelled' },
7
+ { name: 'ExceedsRemaining', reason: "the amount exceeds the lot's remaining units" },
8
+ { name: 'InvalidValue', reason: 'the buy amount must be greater than zero' },
9
+ {
10
+ name: 'SaleFeeExceedsMax',
11
+ reason: "the lot is frozen: the hub's live sale fee now exceeds the seller's tolerance, so the buy reverts " +
12
+ 'until the hub lowers the rate (or the seller sends the remainder home)',
13
+ },
14
+ { name: 'WrongHub', reason: "the route must start at the lot's hub" },
15
+ { name: 'NotDestOwner', reason: 'the destination cell (route end) must be one you own' },
16
+ { name: 'PathTooShort', reason: 'the route needs at least the hub and your destination cell' },
17
+ {
18
+ name: 'NotEligibleWaypoint',
19
+ reason: 'a waypoint on the route is not eligible — a hub on the path cannot serve as a live node right now ' +
20
+ '(temporarily unroutable, not frozen)',
21
+ },
22
+ { name: 'HopOutOfRange', reason: "a hop on the route is longer than transport's reach" },
23
+ { name: 'NotWaypointOwner', reason: 'a non-hub waypoint on the route is not owned by you' },
24
+ { name: 'DegenerateWaypoint', reason: 'the route repeats a waypoint' },
25
+ { name: 'NotRevealed', reason: 'a cell on the route (or the hub) is not revealed yet' },
26
+ { name: 'BelowMinAmount', reason: "the amount is below transport's minimum" },
27
+ ];
28
+ //# sourceMappingURL=trade.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade.constants.js","sourceRoot":"","sources":["../../src/services/trade.constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoD;IACjF,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,8DAA8D,EAAE;IAC9F,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,8CAA8C,EAAE;IACpF,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,0CAA0C,EAAE;IAC5E;QACI,IAAI,EAAE,mBAAmB;QACzB,MAAM,EACF,oGAAoG;YACpG,wEAAwE;KAC/E;IACD,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,uCAAuC,EAAE;IACrE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,sDAAsD,EAAE;IACxF,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,4DAA4D,EAAE;IAC9F;QACI,IAAI,EAAE,qBAAqB;QAC3B,MAAM,EACF,oGAAoG;YACpG,sCAAsC;KAC7C;IACD,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,qDAAqD,EAAE;IACxF,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,qDAAqD,EAAE;IAC3F,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,8BAA8B,EAAE;IACtE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,sDAAsD,EAAE;IACvF,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,yCAAyC,EAAE;CAChF,CAAC"}
@@ -1,5 +1,13 @@
1
- import type { ApiLotView, ApiMarketIndex, ApiMarketResourceSummary, LotView, MarketIndex, MarketResourceSummary } from '../api/types.js';
1
+ import { type ApiLotView, type ApiMarketIndex, type ApiMarketResourceSummary, type LotView, type MarketIndex, type MarketResourceSummary, LotState } from '../api/types.js';
2
+ import { OnChainLotState } from '../contracts/trade.types.js';
2
3
  export declare function namedQuoteRevert(error: unknown): unknown;
4
+ /**
5
+ * The two boundaries name the lifecycle differently and neither is a superset of the other: the contract
6
+ * deletes a lot once it is sold out, cancelled or reclaimed, so its terminal ordinal is the empty slot,
7
+ * while the projection keeps naming which terminal state it reached.
8
+ */
9
+ export declare function lotStateFromChain(state: OnChainLotState): LotState | null;
10
+ export declare function lotStateToChain(state: LotState): OnChainLotState;
3
11
  export declare function toLotView(lot: ApiLotView): LotView;
4
12
  export declare function toMarketIndex(index: ApiMarketIndex): MarketIndex;
5
13
  export declare function toMarketResourceSummary(row: ApiMarketResourceSummary): MarketResourceSummary;
@@ -1 +1 @@
1
- {"version":3,"file":"trade.helpers.d.ts","sourceRoot":"","sources":["../../src/services/trade.helpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,OAAO,EACP,WAAW,EACX,qBAAqB,EACxB,MAAM,iBAAiB,CAAC;AAQzB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMxD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAiBlD;AAED,wBAAgB,aAAa,CAAC,KAAK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@
1
+ import { QUOTE_REVERT_REASONS } from './trade.constants.js';
2
+ import { LotState, } from '../api/types.js';
1
3
  import { TRADE_ABI } from '../contracts/trade.abi.js';
4
+ import { OnChainLotState } from '../contracts/trade.types.js';
2
5
  import { TRANSPORT_ABI } from '../contracts/transport.abi.js';
3
6
  import { bpToPercent } from '../utils/format.utils.js';
4
7
  import { describeRevert } from '../wallet/revert.utils.js';
@@ -10,6 +13,36 @@ export function namedQuoteRevert(error) {
10
13
  }
11
14
  return new Error(`Quote reverted: ${revert}`, { cause: error });
12
15
  }
16
+ /**
17
+ * The two boundaries name the lifecycle differently and neither is a superset of the other: the contract
18
+ * deletes a lot once it is sold out, cancelled or reclaimed, so its terminal ordinal is the empty slot,
19
+ * while the projection keeps naming which terminal state it reached.
20
+ */
21
+ export function lotStateFromChain(state) {
22
+ switch (state) {
23
+ case OnChainLotState.Delivering:
24
+ return LotState.Delivering;
25
+ case OnChainLotState.Open:
26
+ return LotState.Open;
27
+ case OnChainLotState.Evicted:
28
+ return LotState.Evicted;
29
+ case OnChainLotState.None:
30
+ return null;
31
+ }
32
+ }
33
+ export function lotStateToChain(state) {
34
+ switch (state) {
35
+ case LotState.Delivering:
36
+ return OnChainLotState.Delivering;
37
+ case LotState.Open:
38
+ return OnChainLotState.Open;
39
+ case LotState.Evicted:
40
+ return OnChainLotState.Evicted;
41
+ case LotState.Sold:
42
+ case LotState.Cancelled:
43
+ return OnChainLotState.None;
44
+ }
45
+ }
13
46
  export function toLotView(lot) {
14
47
  return {
15
48
  id: lot.id,
@@ -21,7 +54,8 @@ export function toLotView(lot) {
21
54
  pricePerUnit: lot.pricePerUnit,
22
55
  saleFeePercent: bpToPercent(lot.saleFeeBp),
23
56
  maxSaleFeePercent: bpToPercent(lot.maxSaleFeeBp),
24
- frozen: lot.saleFeeBp > lot.maxSaleFeeBp,
57
+ // Only an Open lot can freeze: freezing means a buy would revert, and nothing else is buyable.
58
+ frozen: lot.state === LotState.Open && lot.saleFeeBp > lot.maxSaleFeeBp,
25
59
  state: lot.state,
26
60
  distanceFromAnchor: lot.distanceFromAnchor,
27
61
  createdAt: lot.createdAt,
@@ -43,8 +77,8 @@ export function toMarketResourceSummary(row) {
43
77
  minPricePerUnit: row.minPricePerUnit,
44
78
  incomingLots: row.incomingLots,
45
79
  incomingRemaining: row.incomingRemaining,
46
- frozenLots: row.frozenLots ?? null,
47
- frozenRemaining: row.frozenRemaining ?? null,
80
+ frozenLots: row.frozenLots,
81
+ frozenRemaining: row.frozenRemaining,
48
82
  distanceFromAnchor: row.distanceFromAnchor,
49
83
  };
50
84
  }
@@ -52,33 +86,12 @@ export function enrichSaleFeeToleranceError(error) {
52
86
  if (error instanceof Error && error.message.includes('SaleFeeExceedsMax')) {
53
87
  return new Error(`${error.message} — the hub's live sale fee now exceeds your tolerance (maxSaleFeePercent), which ` +
54
88
  `would list an already-frozen lot (buys revert until the hub lowers the rate to the tolerance or ` +
55
- `below, though cancel stays fee-free). Re-read the hub's current rate (cpu_get_cell or ` +
89
+ `below; a lot return owes no sale fee, but still pays transit for the route home). Re-read the ` +
90
+ `hub's current rate (cpu_get_cell or ` +
56
91
  `cpu_get_markets), then retry with a higher maxSaleFeePercent, or omit it to accept the current rate.`, { cause: error });
57
92
  }
58
93
  return error;
59
94
  }
60
- const QUOTE_REVERT_REASONS = [
61
- { name: 'LotNotOpen', reason: 'the lot is closed — sold out, still delivering, or cancelled' },
62
- { name: 'ExceedsRemaining', reason: "the amount exceeds the lot's remaining units" },
63
- { name: 'InvalidValue', reason: 'the buy amount must be greater than zero' },
64
- {
65
- name: 'SaleFeeExceedsMax',
66
- reason: "the lot is frozen: the hub's live sale fee now exceeds the seller's tolerance, so the buy reverts " +
67
- 'until the hub lowers the rate (or the seller cancels, fee-free)',
68
- },
69
- { name: 'WrongHub', reason: "the route must start at the lot's hub" },
70
- { name: 'NotDestOwner', reason: 'the destination cell (route end) must be one you own' },
71
- { name: 'PathTooShort', reason: 'the route needs at least the hub and your destination cell' },
72
- {
73
- name: 'NotEligibleWaypoint',
74
- reason: 'a waypoint on the route is not eligible — a foreign frozen hub blocks the path',
75
- },
76
- { name: 'HopOutOfRange', reason: "a hop on the route is longer than transport's reach" },
77
- { name: 'NotWaypointOwner', reason: 'a non-hub waypoint on the route is not owned by you' },
78
- { name: 'DegenerateWaypoint', reason: 'the route repeats a waypoint' },
79
- { name: 'NotRevealed', reason: 'a cell on the route (or the hub) is not revealed yet' },
80
- { name: 'BelowMinAmount', reason: "the amount is below transport's minimum" },
81
- ];
82
95
  export function enrichBuyQuoteRevert(error) {
83
96
  if (!(error instanceof Error) || !error.message.includes('Quote reverted:')) {
84
97
  return error;
@@ -93,7 +106,7 @@ export function enrichFrozenBuyError(error) {
93
106
  return new Error(`${error.message} — this lot is frozen: the hub's live sale fee now exceeds the seller's tolerance ` +
94
107
  `(maxSaleFeePercent), so the buy reverts. Wait for the hub owner to lower the rate to the tolerance ` +
95
108
  `or below (re-check with cpu_get_lot or cpu_get_markets), or pick another lot; the seller can ` +
96
- `cancel the lot fee-free at any time.`, { cause: error });
109
+ `send the remainder home at any time, paying no sale fee but still paying transit for the route.`, { cause: error });
97
110
  }
98
111
  return error;
99
112
  }