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,128 @@
1
+ import { maxUint256, parseEventLogs } from 'viem';
2
+ import { LOT_RETURN_REVERT_NAMES, LOT_RETURN_REVERT_REASONS } from './lot-return.constants.js';
3
+ import { decodeKnownRevert } from './revert-decode.utils.js';
4
+ import { lotStateFromChain } from './trade.helpers.js';
5
+ import { LotReturnBranch } from './types.js';
6
+ import { LotState } from '../api/types.js';
7
+ import { TRADE_ABI } from '../contracts/trade.abi.js';
8
+ import { TRANSPORT_ABI } from '../contracts/transport.abi.js';
9
+ import { cpuFromWei } from '../utils/format.utils.js';
10
+ import { WEI_STRING_PATTERN } from '../utils/wei.constants.js';
11
+ const RETURN_ERROR_ABI = [...TRADE_ABI, ...TRANSPORT_ABI];
12
+ export function assertReturnRoute(chain) {
13
+ if (chain.length < 2) {
14
+ throw new Error('A lot return needs the full route home: [hub, ...waypoints, your destination cell]. ' +
15
+ 'Give at least the hub and one cell of your own.');
16
+ }
17
+ const seen = new Set();
18
+ for (const tokenId of chain) {
19
+ if (seen.has(tokenId)) {
20
+ throw new Error(`The route visits cell ${tokenId} twice; a lot return travels each cell once.`);
21
+ }
22
+ seen.add(tokenId);
23
+ }
24
+ }
25
+ /**
26
+ * The chain is the arbiter of what a lot is: the projection can lag an eviction or a sell-out by a block,
27
+ * and a return sent against a stale state is a spend that reverts.
28
+ */
29
+ export function assertReturnableLot(lot, seller, lotId) {
30
+ const state = lotStateFromChain(lot.state);
31
+ if (state === null) {
32
+ throw new Error(`Lot ${lotId} is closed: it was sold out, already returned, or never existed. Nothing is left to send home.`);
33
+ }
34
+ if (lot.seller.toLowerCase() !== seller.toLowerCase()) {
35
+ throw new Error(`Lot ${lotId} is not yours — it belongs to ${lot.seller}. Only its seller can return it.`);
36
+ }
37
+ if (state !== LotState.Open && state !== LotState.Evicted) {
38
+ throw new Error(`Lot ${lotId} is ${state}: its escrow is still delivering to the hub. Finalize that delivery first — ` +
39
+ `only an open or an evicted lot can be sent home.`);
40
+ }
41
+ return state;
42
+ }
43
+ export function assertRouteStartsAtHub(chain, hub, lotId) {
44
+ const start = chain[0];
45
+ if (BigInt(start) !== hub) {
46
+ throw new Error(`The route must start at the lot's hub: lot ${lotId} sits on cell ${hub.toString()}, but the route ` +
47
+ `starts at ${String(start)}.`);
48
+ }
49
+ }
50
+ /** A lot return is all-or-nothing; a quote for anything but the current remainder is a partial return. */
51
+ export function assertWholeRemainder(quoted, remaining, lotId) {
52
+ if (quoted !== remaining) {
53
+ throw new Error(`The return quote for lot ${lotId} covers ${quoted.toString()} units but the lot holds ` +
54
+ `${remaining.toString()}. A lot return always moves the whole remainder, so nothing was sent — ` +
55
+ `re-read the lot and quote it again.`);
56
+ }
57
+ }
58
+ /** The ceiling travels as wei precisely so nothing rounds it; a figure that is not whole wei is not a ceiling. */
59
+ export function parseFeeCeilingWei(maxTransitFeeWei, lotId) {
60
+ if (!WEI_STRING_PATTERN.test(maxTransitFeeWei)) {
61
+ throw new Error(`The fee ceiling for lot ${lotId} must be a whole number of wei, but it reads ` +
62
+ `"${maxTransitFeeWei}". Quote the return with cpu_quote_lot_return and pass the ` +
63
+ `maxTransitFeeWei it answers with, unchanged — that field is already wei, not $CPU.`);
64
+ }
65
+ const ceiling = BigInt(maxTransitFeeWei);
66
+ // A padded ceiling is the way an agent tries to switch the guard off, and it cannot be encoded as the
67
+ // uint256 the contract takes: refusing it here keeps that failure off the allowance and off the chain.
68
+ if (ceiling > maxUint256) {
69
+ throw new Error(`The fee ceiling for lot ${lotId} reads ${maxTransitFeeWei} wei, past the uint256 maximum the ` +
70
+ `contract can hold, so nothing was approved and nothing was sent. The ceiling is a guard, not ` +
71
+ `a switch to turn off — quote the return with cpu_quote_lot_return and pass the ` +
72
+ `maxTransitFeeWei it answers with, unchanged.`);
73
+ }
74
+ return ceiling;
75
+ }
76
+ /**
77
+ * The client half of the fee promise. Only the source hub's rate is pinned on-chain, at the figure recorded
78
+ * when the lot was listed, so any later waypoint can raise its own between the quote and this call. The
79
+ * ceiling itself does travel with the transaction and caps the whole route total there, but that backstop
80
+ * only fires once gas is committed: refusing here — before the allowance, before the transaction — is what
81
+ * makes a stale ceiling cost a re-quote instead of a reverted spend.
82
+ */
83
+ export function assertFeeWithinCeiling(quotedWei, ceilingWei, lotId) {
84
+ if (quotedWei <= ceilingWei) {
85
+ return;
86
+ }
87
+ throw new Error(`Returning lot ${lotId} now costs ${cpuFromWei(quotedWei.toString())} $CPU in transit ` +
88
+ `(${quotedWei.toString()} wei), above the ${cpuFromWei(ceilingWei.toString())} $CPU ceiling you ` +
89
+ `passed (${ceilingWei.toString()} wei): a fee on the route moved since that quote. Nothing was ` +
90
+ `approved and nothing was sent. Quote the return again with cpu_quote_lot_return and send it ` +
91
+ `straight away with the maxTransitFeeWei it answers with, or route around the cell that raised its rate.`);
92
+ }
93
+ export function returnBranchOf(state) {
94
+ return state === LotState.Evicted ? LotReturnBranch.Reclaimed : LotReturnBranch.Cancelled;
95
+ }
96
+ export function describeCapacityRefusal(capacity, destinationTokenId, lotId) {
97
+ const free = capacity.free ?? '0';
98
+ return (`Cell ${destinationTokenId} cannot take the whole remainder of lot ${lotId}: it needs room for ` +
99
+ `${capacity.required} units and only ${free} are free (what it already holds and everything reserved on ` +
100
+ `it are counted). Nothing was approved and nothing was sent. Free the space, or pick another destination ` +
101
+ `you own, then quote the return again.`);
102
+ }
103
+ export function describeLotReturnRevert(error, branch) {
104
+ const decoded = decodeKnownRevert(error, RETURN_ERROR_ABI, LOT_RETURN_REVERT_NAMES);
105
+ if (decoded === null) {
106
+ return error;
107
+ }
108
+ return new Error(`This lot return did not go through: ${LOT_RETURN_REVERT_REASONS[decoded.name]}. ` +
109
+ `The ${branch === LotReturnBranch.Reclaimed ? 'reclaim' : 'cancel'} was refused on-chain, so the lot ` +
110
+ `and its units are untouched.`, { cause: error });
111
+ }
112
+ /**
113
+ * Both branches close the lot with the same lifecycle event. When a receipt carries none — a contract that
114
+ * settles a reclaim silently — the quote the contract itself just priced is the only honest figure left, and
115
+ * refusing to answer would report a settled return as a failure.
116
+ */
117
+ export function decodeReturnedUnits(logs, trade, quoted, logger) {
118
+ const events = parseEventLogs({ abi: TRADE_ABI, eventName: 'LotCancelled', logs });
119
+ const event = events.find((e) => e.address.toLowerCase() === trade.toLowerCase());
120
+ if (event === undefined) {
121
+ logger.warn('lot return confirmed without a lifecycle event; reporting the quoted remainder', {
122
+ quoted: quoted.toString(),
123
+ });
124
+ return quoted;
125
+ }
126
+ return event.args.returned;
127
+ }
128
+ //# sourceMappingURL=lot-return.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-return.utils.js","sourceRoot":"","sources":["../../src/services/lot-return.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAoC,MAAM,MAAM,CAAC;AAEpF,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAiD,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,gBAAgB,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,aAAa,CAAmB,CAAC;AAE5E,MAAM,UAAU,iBAAiB,CAAC,KAAo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AACH,MAAM,UAAU,mBAAmB,CAAC,IAAgB,EAAE,KAAc,EAAE,MAAc,EAAE,MAAe;IACjG,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IACnF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAClF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,gFAAgF,EAAE;YAC1F,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;SAC5B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const WHOLE_UNITS_PATTERN: RegExp;
2
+ export declare const LIVE_LOT_COUNT_NOTE = "delivering, open and evicted lots all count";
3
+ export declare const EVICTED_BLOCK_NOTE: string;
4
+ //# sourceMappingURL=lot-terms.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.constants.d.ts","sourceRoot":"","sources":["../../src/services/lot-terms.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAAU,CAAC;AAE3C,eAAO,MAAM,mBAAmB,gDAAgD,CAAC;AAEjF,eAAO,MAAM,kBAAkB,QAEqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const WHOLE_UNITS_PATTERN = /^\d+$/;
2
+ export const LIVE_LOT_COUNT_NOTE = 'delivering, open and evicted lots all count';
3
+ export const EVICTED_BLOCK_NOTE = 'an evicted lot keeps its per-seller slot until its remainder is on the way home, and it blocks every ' +
4
+ 'resource on that hub while it waits; other hubs are unaffected';
5
+ //# sourceMappingURL=lot-terms.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.constants.js","sourceRoot":"","sources":["../../src/services/lot-terms.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,6CAA6C,CAAC;AAEjF,MAAM,CAAC,MAAM,kBAAkB,GAC3B,uGAAuG;IACvG,gEAAgE,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare function parseListedValue(value: string): bigint | null;
2
+ export declare function evictedPendingMessage(count: number, hubTokenId: string): string;
3
+ export declare function invalidValueMessage(value: string): string;
4
+ export declare function invalidPriceMessage(pricePerUnit: string): string;
5
+ export declare function priceBelowFloorMessage(pricePerUnit: string, floor: string): string;
6
+ export declare function emptyWindowMessage(hubTokenId: string, resourceId: number, min: string, max: string): string;
7
+ export declare function belowMinimumMessage(value: string, min: string, hubTokenId: string, resourceId: number): string;
8
+ export declare function aboveMaximumMessage(value: string, max: string, hubTokenId: string, resourceId: number): string;
9
+ export declare function sellerLotLimitMessage(count: number, limit: number, hubTokenId: string, resourceId: number): string;
10
+ export declare function saleFeeToleranceMessage(livePercent: number, tolerancePercent: number, hubTokenId: string): string;
11
+ //# sourceMappingURL=lot-terms.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.helpers.d.ts","sourceRoot":"","sources":["../../src/services/lot-terms.helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAM/E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKlF;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAM3G;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK9G;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK9G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAKlH;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAKjH"}
@@ -0,0 +1,45 @@
1
+ import { EVICTED_BLOCK_NOTE, LIVE_LOT_COUNT_NOTE, WHOLE_UNITS_PATTERN } from './lot-terms.constants.js';
2
+ export function parseListedValue(value) {
3
+ if (!WHOLE_UNITS_PATTERN.test(value)) {
4
+ return null;
5
+ }
6
+ const units = BigInt(value);
7
+ return units > 0n ? units : null;
8
+ }
9
+ export function evictedPendingMessage(count, hubTokenId) {
10
+ return (`You still owe ${count} evicted lot return${count === 1 ? '' : 's'} on hub ${hubTokenId}, so this hub ` +
11
+ `refuses every new lot of yours. Schedule the return of each evicted remainder there — ` +
12
+ `${EVICTED_BLOCK_NOTE}.`);
13
+ }
14
+ export function invalidValueMessage(value) {
15
+ return `A lot needs a positive whole number of units; "${value}" is not one.`;
16
+ }
17
+ export function invalidPriceMessage(pricePerUnit) {
18
+ return `An asking price must be a positive $CPU amount per unit; "${pricePerUnit}" is not one.`;
19
+ }
20
+ export function priceBelowFloorMessage(pricePerUnit, floor) {
21
+ return (`Asking ${pricePerUnit} $CPU per unit is below the live floor of ${floor} $CPU per unit. ` +
22
+ `Ask ${floor} or more.`);
23
+ }
24
+ export function emptyWindowMessage(hubTokenId, resourceId, min, max) {
25
+ return (`Hub ${hubTokenId} has no listing window for resource #${resourceId} right now: its live minimum is ` +
26
+ `${min} units and its live maximum is ${max} units, so no amount fits. List on another hub, or wait ` +
27
+ `for this hub's storage for that resource to change.`);
28
+ }
29
+ export function belowMinimumMessage(value, min, hubTokenId, resourceId) {
30
+ return (`A lot of ${value} units is below the live minimum of ${min} units for resource #${resourceId} on hub ` +
31
+ `${hubTokenId}. List at least ${min} units, or pick a hub with a lower minimum.`);
32
+ }
33
+ export function aboveMaximumMessage(value, max, hubTokenId, resourceId) {
34
+ return (`A lot of ${value} units is above the live maximum of ${max} units for resource #${resourceId} on hub ` +
35
+ `${hubTokenId}. List at most ${max} units, and sell the rest in a later lot or on another hub.`);
36
+ }
37
+ export function sellerLotLimitMessage(count, limit, hubTokenId, resourceId) {
38
+ return (`You already hold ${count} of ${limit} live lots for resource #${resourceId} on hub ${hubTokenId} — ` +
39
+ `${LIVE_LOT_COUNT_NOTE}. Wait for one to sell out, or return one remainder home, before listing another.`);
40
+ }
41
+ export function saleFeeToleranceMessage(livePercent, tolerancePercent, hubTokenId) {
42
+ return (`Hub ${hubTokenId} charges ${livePercent}% sale fee, above your tolerance of ${tolerancePercent}%. ` +
43
+ `Raise maxSaleFeePercent to ${livePercent} or more, or list on a cheaper hub.`);
44
+ }
45
+ //# sourceMappingURL=lot-terms.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.helpers.js","sourceRoot":"","sources":["../../src/services/lot-terms.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAA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AAwB,UAAU,UAAU;QACvG,GAAG,UAAU,mBAAmB,GAAG,6CAA6C,CACnF,CAAC;AACN,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,GAAW,EAAE,UAAkB,EAAE,UAAkB;IAClG,OAAO,CACH,YAAY,KAAK,uCAAuC,GAAG,wBAAwB,UAAU,UAAU;QACvG,GAAG,UAAU,kBAAkB,GAAG,6DAA6D,CAClG,CAAC;AACN,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAa,EAAE,KAAa,EAAE,UAAkB,EAAE,UAAkB;IACtG,OAAO,CACH,oBAAoB,KAAK,OAAO,KAAK,4BAA4B,UAAU,WAAW,UAAU,KAAK;QACrG,GAAG,mBAAmB,mFAAmF,CAC5G,CAAC;AACN,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,WAAmB,EAAE,gBAAwB,EAAE,UAAkB;IACrG,OAAO,CACH,OAAO,UAAU,YAAY,WAAW,uCAAuC,gBAAgB,KAAK;QACpG,8BAA8B,WAAW,qCAAqC,CACjF,CAAC;AACN,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ILotTerms, ListingPreflightInput, LotTermsServiceOptions } from './lot-terms.types.js';
2
+ import { type LotTermsInput, type LotTermsResult } from './types.js';
3
+ /**
4
+ * The listing terms of one hub and resource, and the gate `cpu_create_lot` passes through. The window is
5
+ * read from the contract's own bound views and never worked out from the configured shares, and every
6
+ * deterministic refusal happens here — before the allowance and before the transaction — so a listing the
7
+ * contract already refuses never costs the seller an approval or gas.
8
+ */
9
+ export declare class LotTermsService implements ILotTerms {
10
+ private readonly appConfig;
11
+ private readonly wallet;
12
+ private readonly tradeClient;
13
+ private readonly logger;
14
+ constructor(options: LotTermsServiceOptions);
15
+ getLotTerms(input: LotTermsInput): Promise<LotTermsResult>;
16
+ assertListingAllowed(input: ListingPreflightInput): Promise<LotTermsResult>;
17
+ private readLiveTerms;
18
+ private parsePrice;
19
+ }
20
+ //# sourceMappingURL=lot-terms.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.service.d.ts","sourceRoot":"","sources":["../../src/services/lot-terms.service.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAGrG,OAAO,EAIH,KAAK,aAAa,EAClB,KAAK,cAAc,EAEtB,MAAM,YAAY,CAAC;AAYpB;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAC7C,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,sBAAsB;IAOrC,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAI1D,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;YA2CnE,aAAa;IAkD3B,OAAO,CAAC,UAAU;CAQrB"}
@@ -0,0 +1,119 @@
1
+ import { formatEther, parseEther } from 'viem';
2
+ import { aboveMaximumMessage, belowMinimumMessage, emptyWindowMessage, evictedPendingMessage, invalidPriceMessage, invalidValueMessage, parseListedValue, priceBelowFloorMessage, saleFeeToleranceMessage, sellerLotLimitMessage, } from './lot-terms.helpers.js';
3
+ import { preparePaidAction } from './paid-action.js';
4
+ import { AppContract } from './paid-action.types.js';
5
+ import { LotListingBlocker, } from './types.js';
6
+ import { bpToPercent } from '../utils/format.utils.js';
7
+ /**
8
+ * The listing terms of one hub and resource, and the gate `cpu_create_lot` passes through. The window is
9
+ * read from the contract's own bound views and never worked out from the configured shares, and every
10
+ * deterministic refusal happens here — before the allowance and before the transaction — so a listing the
11
+ * contract already refuses never costs the seller an approval or gas.
12
+ */
13
+ export class LotTermsService {
14
+ appConfig;
15
+ wallet;
16
+ tradeClient;
17
+ logger;
18
+ constructor(options) {
19
+ this.appConfig = options.appConfig;
20
+ this.wallet = options.wallet;
21
+ this.tradeClient = options.tradeClient;
22
+ this.logger = options.logger;
23
+ }
24
+ async getLotTerms(input) {
25
+ return (await this.readLiveTerms(input.hubTokenId, input.resourceId)).terms;
26
+ }
27
+ async assertListingAllowed(input) {
28
+ const { terms, config, trade, hub } = await this.readLiveTerms(input.hubTokenId, input.resourceId);
29
+ const { hubTokenId, resourceId } = input;
30
+ if (terms.outstandingEvictedCount > 0) {
31
+ throw new Error(evictedPendingMessage(terms.outstandingEvictedCount, hubTokenId));
32
+ }
33
+ const value = parseListedValue(input.value);
34
+ if (value === null) {
35
+ throw new Error(invalidValueMessage(input.value));
36
+ }
37
+ const price = this.parsePrice(input.pricePerUnit);
38
+ if (price === null) {
39
+ throw new Error(invalidPriceMessage(input.pricePerUnit));
40
+ }
41
+ if (price < config.minPricePerUnit) {
42
+ throw new Error(priceBelowFloorMessage(input.pricePerUnit, formatEther(config.minPricePerUnit)));
43
+ }
44
+ if (terms.blockers.includes(LotListingBlocker.EmptyWindow)) {
45
+ throw new Error(emptyWindowMessage(hubTokenId, resourceId, terms.effectiveMin, terms.effectiveMax));
46
+ }
47
+ if (value < BigInt(terms.effectiveMin)) {
48
+ throw new Error(belowMinimumMessage(input.value, terms.effectiveMin, hubTokenId, resourceId));
49
+ }
50
+ if (value > BigInt(terms.effectiveMax)) {
51
+ throw new Error(aboveMaximumMessage(input.value, terms.effectiveMax, hubTokenId, resourceId));
52
+ }
53
+ if (terms.blockers.includes(LotListingBlocker.SellerLotLimit)) {
54
+ throw new Error(sellerLotLimitMessage(terms.sellerLotCount, terms.sellerLotLimit, hubTokenId, resourceId));
55
+ }
56
+ if (input.maxSaleFeePercent !== null) {
57
+ const livePercent = bpToPercent(await this.tradeClient.getSaleFee({ trade, hub, res: resourceId }));
58
+ if (livePercent > input.maxSaleFeePercent) {
59
+ throw new Error(saleFeeToleranceMessage(livePercent, input.maxSaleFeePercent, hubTokenId));
60
+ }
61
+ }
62
+ return terms;
63
+ }
64
+ async readLiveTerms(hubTokenId, resourceId) {
65
+ const action = await preparePaidAction({ appConfig: this.appConfig, wallet: this.wallet });
66
+ const trade = action.requireContract(AppContract.Trade, 'cannot read the lot listing terms');
67
+ const seller = action.wallet.getAddress();
68
+ const hub = BigInt(hubTokenId);
69
+ const evicted = await this.tradeClient.getSellerEvictedCount({ trade, seller, hub });
70
+ const config = await this.tradeClient.getConfig({ trade });
71
+ const min = await this.tradeClient.getMinLotValue({ trade, hub, res: resourceId });
72
+ const max = await this.tradeClient.getMaxLotValue({ trade, hub, res: resourceId });
73
+ const lotCount = await this.tradeClient.getSellerLotCount({ trade, seller, hub, res: resourceId });
74
+ const blockers = [];
75
+ if (evicted > 0n) {
76
+ blockers.push(LotListingBlocker.EvictedPending);
77
+ }
78
+ if (max === 0n || min > max) {
79
+ blockers.push(LotListingBlocker.EmptyWindow);
80
+ }
81
+ if (lotCount >= BigInt(config.maxLotsPerSellerResource)) {
82
+ blockers.push(LotListingBlocker.SellerLotLimit);
83
+ }
84
+ this.logger.info('read lot terms', {
85
+ hubTokenId,
86
+ resourceId,
87
+ effectiveMin: min.toString(),
88
+ effectiveMax: max.toString(),
89
+ blockers,
90
+ });
91
+ return {
92
+ trade,
93
+ hub,
94
+ config,
95
+ terms: {
96
+ hubTokenId,
97
+ resourceId,
98
+ sellerAddress: seller,
99
+ effectiveMin: min.toString(),
100
+ effectiveMax: max.toString(),
101
+ sellerLotCount: Number(lotCount),
102
+ sellerLotLimit: config.maxLotsPerSellerResource,
103
+ outstandingEvictedCount: Number(evicted),
104
+ canList: blockers.length === 0,
105
+ blockers,
106
+ },
107
+ };
108
+ }
109
+ parsePrice(pricePerUnit) {
110
+ try {
111
+ const wei = parseEther(pricePerUnit);
112
+ return wei > 0n ? wei : null;
113
+ }
114
+ catch {
115
+ return null;
116
+ }
117
+ }
118
+ }
119
+ //# sourceMappingURL=lot-terms.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.service.js","sourceRoot":"","sources":["../../src/services/lot-terms.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAE7D,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACH,iBAAiB,GAMpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAUvD;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACP,SAAS,CAAa;IACtB,MAAM,CAAiB;IACvB,WAAW,CAAe;IAC1B,MAAM,CAAU;IAEjC,YAAY,OAA+B;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAoB;QAClC,OAAO,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,KAA4B;QACnD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,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AC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC/B,UAAU;YACV,UAAU;YACV,YAAY,EAAE,GAAG,CAAC,QAAQ,EAAE;YAC5B,YAAY,EAAE,GAAG,CAAC,QAAQ,EAAE;YAC5B,QAAQ;SACX,CAAC,CAAC;QAEH,OAAO;YACH,KAAK;YACL,GAAG;YACH,MAAM;YACN,KAAK,EAAE;gBACH,UAAU;gBACV,UAAU;gBACV,aAAa,EAAE,MAAM;gBACrB,YAAY,EAAE,GAAG,CAAC,QAAQ,EAAE;gBAC5B,YAAY,EAAE,GAAG,CAAC,QAAQ,EAAE;gBAC5B,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC;gBAChC,cAAc,EAAE,MAAM,CAAC,wBAAwB;gBAC/C,uBAAuB,EAAE,MAAM,CAAC,OAAO,CAAC;gBACxC,OAAO,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;gBAC9B,QAAQ;aACX;SACJ,CAAC;IACN,CAAC;IAEO,UAAU,CAAC,YAAoB;QACnC,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;YACrC,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,25 @@
1
+ import type { IAppConfig, ITradeClient, LotTermsInput, LotTermsResult } from './types.js';
2
+ import type { ILogger } from '../logger/types.js';
3
+ import type { WalletProvider } from '../wallet/types.js';
4
+ export interface LotTermsServiceOptions {
5
+ appConfig: IAppConfig;
6
+ wallet: WalletProvider;
7
+ tradeClient: ITradeClient;
8
+ logger: ILogger;
9
+ }
10
+ /** One proposed listing, in the units the seller asked in. */
11
+ export interface ListingPreflightInput {
12
+ hubTokenId: string;
13
+ resourceId: number;
14
+ value: string;
15
+ pricePerUnit: string;
16
+ /** Null means "lock in whatever the hub charges right now", so there is no tolerance to check. */
17
+ maxSaleFeePercent: number | null;
18
+ }
19
+ /** Reads the live listing terms and refuses a listing the contract already refuses. */
20
+ export interface ILotTerms {
21
+ getLotTerms(input: LotTermsInput): Promise<LotTermsResult>;
22
+ /** Throws a domain error on the first violated rule, in the contract's own order. */
23
+ assertListingAllowed(input: ListingPreflightInput): Promise<LotTermsResult>;
24
+ }
25
+ //# sourceMappingURL=lot-terms.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.types.d.ts","sourceRoot":"","sources":["../../src/services/lot-terms.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACnC,SAAS,EAAE,UAAU,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,EAAE,YAAY,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,uFAAuF;AACvF,MAAM,WAAW,SAAS;IACtB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3D,qFAAqF;IACrF,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=lot-terms.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lot-terms.types.js","sourceRoot":"","sources":["../../src/services/lot-terms.types.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  export declare function isRevealAlreadyPending(error: unknown): boolean;
2
2
  export declare function withRevealInFlightPhrase(error: unknown, tokenId: string): unknown;
3
3
  export declare function withRevealRequestPhrase(error: unknown, tokenId: string): unknown;
4
+ export declare function withRevealQuotePhrase(error: unknown): unknown;
4
5
  //# sourceMappingURL=reveal-revert.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reveal-revert.utils.d.ts","sourceRoot":"","sources":["../../src/services/reveal-revert.utils.ts"],"names":[],"mappings":"AAmFA,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG9D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMjF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMhF"}
1
+ {"version":3,"file":"reveal-revert.utils.d.ts","sourceRoot":"","sources":["../../src/services/reveal-revert.utils.ts"],"names":[],"mappings":"AAsGA,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG9D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMjF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMhF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM7D"}
@@ -9,6 +9,11 @@ function messageFor(name, args, tokenId) {
9
9
  return (`The reveal price moved between the quote and the send: cell ${tokenId} required ` +
10
10
  `${String(args[0] ?? 'more')} wei and this transaction carried ${String(args[1] ?? 'less')}. ` +
11
11
  `Nothing was spent — reveal cell ${tokenId} again and it prices the reveal afresh.`);
12
+ case CellRevertName.REVEAL_SERVICE_FEES_EXCEED_BUDGET:
13
+ return (`The configured reveal budget is ${String(args[0] ?? 'unknown')} wei, but the live randomness ` +
14
+ `fee and metadata publication charge need ${String(args[1] ?? 'more')} wei together. The service ` +
15
+ `fees cannot be paid on top of the budget, so no reveal can be quoted or requested until the ` +
16
+ `budget or fees change. Nothing was spent.`);
12
17
  case CellRevertName.REVEAL_PAYMENT_NOT_CONFIGURED:
13
18
  return (`This deployment has put no price on a reveal yet — neither the ETH leg nor the $CPU leg — so ` +
14
19
  `no cell can be revealed on it. Nothing was spent and cell ${tokenId} is untouched.`);
@@ -19,6 +24,14 @@ function messageFor(name, args, tokenId) {
19
24
  return (`The reveal's ETH contribution could not be delivered, so the whole request was undone: ` +
20
25
  `nothing was spent and cell ${tokenId} is untouched. This is a fault of the deployment, not ` +
21
26
  `of your wallet — retry later.`);
27
+ case CellRevertName.METADATA_PUBLISHER_NOT_CONFIGURED:
28
+ return (`This deployment charges for Land metadata publication but has no metadata publisher configured, ` +
29
+ `so it refuses every reveal. Nothing was spent and cell ${tokenId} is untouched. Retrying cannot ` +
30
+ `fix this deployment configuration.`);
31
+ case CellRevertName.PUBLISHER_DELIVERY_FAILED:
32
+ return (`The Land metadata publication charge could not be delivered to the metadata publisher, so the ` +
33
+ `whole request was undone: nothing was spent and cell ${tokenId} is untouched. This is a fault ` +
34
+ `of the deployment, not of your wallet.`);
22
35
  case CellRevertName.REFUND_FAILED:
23
36
  return (`The reveal carried more ETH than it cost and the change could not be returned, so the whole ` +
24
37
  `request was undone: nothing was spent and cell ${tokenId} is untouched. A wallet that ` +
@@ -72,4 +85,11 @@ export function withRevealRequestPhrase(error, tokenId) {
72
85
  }
73
86
  return new Error(messageFor(decoded.name, decoded.args, tokenId), { cause: error });
74
87
  }
88
+ export function withRevealQuotePhrase(error) {
89
+ const decoded = decodeKnownRevert(error, CELL_ABI, CELL_REVERT_NAMES);
90
+ if (decoded === null) {
91
+ return withAdapterPhrase(error);
92
+ }
93
+ return new Error(messageFor(decoded.name, decoded.args, 'before the request'), { cause: error });
94
+ }
75
95
  //# sourceMappingURL=reveal-revert.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reveal-revert.utils.js","sourceRoot":"","sources":["../../src/services/reveal-revert.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,MAAM,iBAAiB,GAAkC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAEvF,SAAS,UAAU,CAAC,IAAoB,EAAE,IAA4B,EAAE,OAAe;IACnF,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,cAAc,CAAC,2BAA2B;YAC3C,OAAO,CACH,+DAA+D,OAAO,YAAY;gBAClF,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,qCAAqC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI;gBAC9F,mCAAmC,OAAO,yCAAyC,CACtF,CAAC;QACN,KAAK,cAAc,CAAC,6BAA6B;YAC7C,OAAO,CACH,+FAA+F;gBAC/F,6DAA6D,OAAO,gBAAgB,CACvF,CAAC;QACN,KAAK,cAAc,CAAC,0BAA0B;YAC1C,OAAO,CACH,+FAA+F;gBAC/F,8BAA8B,OAAO,gBAAgB,CACxD,CAAC;QACN,KAAK,cAAc,CAAC,oBAAoB;YACpC,OAAO,CACH,yFAAyF;gBACzF,8BAA8B,OAAO,wDAAwD;gBAC7F,+BAA+B,CAClC,CAAC;QACN,KAAK,cAAc,CAAC,aAAa;YAC7B,OA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_PAYMENT_BUFFER_BPS = 1000n;
2
2
  export declare const REVEAL_POLL_TIMEOUT_MS = 45000;
3
3
  export declare const REVEAL_POLL_INTERVAL_MS = 3000;
4
4
  export declare const REVEAL_PRIME_ATTEMPTS = 3;
@@ -1 +1 @@
1
- {"version":3,"file":"reveal.constants.d.ts","sourceRoot":"","sources":["../../src/services/reveal.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAE7C,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,wBAAwB,OAA0B,CAAC"}
1
+ {"version":3,"file":"reveal.constants.d.ts","sourceRoot":"","sources":["../../src/services/reveal.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAE7C,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,wBAAwB,OAA0B,CAAC"}
@@ -1,4 +1,4 @@
1
- export const REVEAL_FEE_BUFFER_BPS = 2500n;
1
+ export const REVEAL_PAYMENT_BUFFER_BPS = 1000n;
2
2
  export const REVEAL_POLL_TIMEOUT_MS = 45_000;
3
3
  export const REVEAL_POLL_INTERVAL_MS = 3_000;
4
4
  export const REVEAL_PRIME_ATTEMPTS = 3;
@@ -1 +1 @@
1
- {"version":3,"file":"reveal.constants.js","sourceRoot":"","sources":["../../src/services/reveal.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAM,CAAC;AAE5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC"}
1
+ {"version":3,"file":"reveal.constants.js","sourceRoot":"","sources":["../../src/services/reveal.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAM,CAAC;AAEhD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC"}
@@ -28,11 +28,12 @@ export declare class RevealService {
28
28
  private pendingAtRetiredSource;
29
29
  private pendingButUnlisted;
30
30
  /**
31
- * Every reveal is paid for, first one included, and only the Cell knows the price: the chain config
32
- * carries the two gameplay legs but not the live randomness fee, so a value rebuilt from it underpays.
33
- * Either leg may be zero — a zero burn needs no approval, and a zero contribution is not a free reveal.
31
+ * Every reveal is paid for, first one included, and only the Cell knows the price: the served config omits
32
+ * live service-fee split and validates that it fits inside the configured ETH budget. A zero burn needs no
33
+ * approval; service fees can consume the whole ETH budget without making the reveal free.
34
34
  */
35
35
  private fundReveal;
36
+ private readCpuBalance;
36
37
  private prepareRevealRequest;
37
38
  private sendRevealRequest;
38
39
  private pollFulfillment;
@@ -1 +1 @@
1
- {"version":3,"file":"reveal.service.d.ts","sourceRoot":"","sources":["../../src/services/reveal.service.ts"],"names":[],"mappings":"AAYA,OAAO,EAUH,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAI5B,MAAM,YAAY,CAAC;AAqBpB,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IACzC,OAAO,CA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