project-cpu-mcp 0.12.0 → 0.12.2

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 (418) hide show
  1. package/dist/api/client.d.ts.map +1 -1
  2. package/dist/api/client.js +7 -3
  3. package/dist/api/client.js.map +1 -1
  4. package/dist/api/types.d.ts +12 -1
  5. package/dist/api/types.d.ts.map +1 -1
  6. package/dist/api/types.js +2 -0
  7. package/dist/api/types.js.map +1 -1
  8. package/dist/contracts/approval.constants.d.ts +4 -0
  9. package/dist/contracts/approval.constants.d.ts.map +1 -0
  10. package/dist/contracts/approval.constants.js +4 -0
  11. package/dist/contracts/approval.constants.js.map +1 -0
  12. package/dist/contracts/approval.types.d.ts +9 -0
  13. package/dist/contracts/approval.types.d.ts.map +1 -0
  14. package/dist/contracts/approval.types.js +2 -0
  15. package/dist/contracts/approval.types.js.map +1 -0
  16. package/dist/contracts/approval.utils.d.ts +4 -0
  17. package/dist/contracts/approval.utils.d.ts.map +1 -0
  18. package/dist/contracts/approval.utils.js +41 -0
  19. package/dist/contracts/approval.utils.js.map +1 -0
  20. package/dist/contracts/erc721.abi.d.ts +27 -0
  21. package/dist/contracts/erc721.abi.d.ts.map +1 -0
  22. package/dist/contracts/erc721.abi.js +6 -0
  23. package/dist/contracts/erc721.abi.js.map +1 -0
  24. package/dist/contracts/seaport-events.abi.d.ts +95 -0
  25. package/dist/contracts/seaport-events.abi.d.ts.map +1 -0
  26. package/dist/contracts/seaport-events.abi.js +52 -0
  27. package/dist/contracts/seaport-events.abi.js.map +1 -0
  28. package/dist/contracts/seaport-spender.reader.d.ts +9 -0
  29. package/dist/contracts/seaport-spender.reader.d.ts.map +1 -0
  30. package/dist/contracts/seaport-spender.reader.js +101 -0
  31. package/dist/contracts/seaport-spender.reader.js.map +1 -0
  32. package/dist/contracts/seaport.constants.d.ts +136 -0
  33. package/dist/contracts/seaport.constants.d.ts.map +1 -0
  34. package/dist/contracts/seaport.constants.js +57 -0
  35. package/dist/contracts/seaport.constants.js.map +1 -0
  36. package/dist/contracts/seaport.types.d.ts +34 -0
  37. package/dist/contracts/seaport.types.d.ts.map +1 -0
  38. package/dist/contracts/seaport.types.js +24 -0
  39. package/dist/contracts/seaport.types.js.map +1 -0
  40. package/dist/index.js +11 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/logger/constants.d.ts.map +1 -1
  43. package/dist/logger/constants.js +2 -0
  44. package/dist/logger/constants.js.map +1 -1
  45. package/dist/paybox/auth/types.d.ts +2 -2
  46. package/dist/paybox/auth/types.d.ts.map +1 -1
  47. package/dist/paybox/sdk/adapter.d.ts +2 -1
  48. package/dist/paybox/sdk/adapter.d.ts.map +1 -1
  49. package/dist/paybox/sdk/adapter.js +24 -0
  50. package/dist/paybox/sdk/adapter.js.map +1 -1
  51. package/dist/paybox/types.d.ts +20 -16
  52. package/dist/paybox/types.d.ts.map +1 -1
  53. package/dist/paybox/types.js +1 -0
  54. package/dist/paybox/types.js.map +1 -1
  55. package/dist/paybox/wallet/manager.d.ts +3 -1
  56. package/dist/paybox/wallet/manager.d.ts.map +1 -1
  57. package/dist/paybox/wallet/manager.js +16 -5
  58. package/dist/paybox/wallet/manager.js.map +1 -1
  59. package/dist/paybox/wallet/rpc.client.d.ts +1 -0
  60. package/dist/paybox/wallet/rpc.client.d.ts.map +1 -1
  61. package/dist/paybox/wallet/rpc.client.js +4 -0
  62. package/dist/paybox/wallet/rpc.client.js.map +1 -1
  63. package/dist/paybox/wallet/utils.d.ts +0 -2
  64. package/dist/paybox/wallet/utils.d.ts.map +1 -1
  65. package/dist/paybox/wallet/utils.js +2 -65
  66. package/dist/paybox/wallet/utils.js.map +1 -1
  67. package/dist/server.constants.d.ts.map +1 -1
  68. package/dist/server.constants.js +13 -19
  69. package/dist/server.constants.js.map +1 -1
  70. package/dist/server.d.ts.map +1 -1
  71. package/dist/server.js +11 -5
  72. package/dist/server.js.map +1 -1
  73. package/dist/services/app-config.utils.d.ts.map +1 -1
  74. package/dist/services/app-config.utils.js +1 -0
  75. package/dist/services/app-config.utils.js.map +1 -1
  76. package/dist/services/auth.service.d.ts.map +1 -1
  77. package/dist/services/auth.service.js +16 -4
  78. package/dist/services/auth.service.js.map +1 -1
  79. package/dist/services/market/acceptance.constants.d.ts +5 -0
  80. package/dist/services/market/acceptance.constants.d.ts.map +1 -0
  81. package/dist/services/market/acceptance.constants.js +6 -0
  82. package/dist/services/market/acceptance.constants.js.map +1 -0
  83. package/dist/services/market/acceptance.service.d.ts +51 -0
  84. package/dist/services/market/acceptance.service.d.ts.map +1 -0
  85. package/dist/services/market/acceptance.service.js +595 -0
  86. package/dist/services/market/acceptance.service.js.map +1 -0
  87. package/dist/services/market/acceptance.types.d.ts +214 -0
  88. package/dist/services/market/acceptance.types.d.ts.map +1 -0
  89. package/dist/services/market/acceptance.types.js +13 -0
  90. package/dist/services/market/acceptance.types.js.map +1 -0
  91. package/dist/services/market/acceptance.utils.d.ts +7 -0
  92. package/dist/services/market/acceptance.utils.d.ts.map +1 -0
  93. package/dist/services/market/acceptance.utils.js +15 -0
  94. package/dist/services/market/acceptance.utils.js.map +1 -0
  95. package/dist/services/market/action.types.d.ts +29 -0
  96. package/dist/services/market/action.types.d.ts.map +1 -0
  97. package/dist/services/market/action.types.js +9 -0
  98. package/dist/services/market/action.types.js.map +1 -0
  99. package/dist/services/market/budget.d.ts +17 -0
  100. package/dist/services/market/budget.d.ts.map +1 -0
  101. package/dist/services/market/budget.js +52 -0
  102. package/dist/services/market/budget.js.map +1 -0
  103. package/dist/services/market/budget.scope.d.ts +4 -0
  104. package/dist/services/market/budget.scope.d.ts.map +1 -0
  105. package/dist/services/market/budget.scope.js +10 -0
  106. package/dist/services/market/budget.scope.js.map +1 -0
  107. package/dist/services/market/budget.utils.d.ts +4 -0
  108. package/dist/services/market/budget.utils.d.ts.map +1 -0
  109. package/dist/services/market/budget.utils.js +29 -0
  110. package/dist/services/market/budget.utils.js.map +1 -0
  111. package/dist/services/market/cancel.abi.d.ts +108 -0
  112. package/dist/services/market/cancel.abi.d.ts.map +1 -0
  113. package/dist/services/market/cancel.abi.js +50 -0
  114. package/dist/services/market/cancel.abi.js.map +1 -0
  115. package/dist/services/market/cancel.constants.d.ts +4 -0
  116. package/dist/services/market/cancel.constants.d.ts.map +1 -0
  117. package/dist/services/market/cancel.constants.js +5 -0
  118. package/dist/services/market/cancel.constants.js.map +1 -0
  119. package/dist/services/market/cancel.service.d.ts +34 -0
  120. package/dist/services/market/cancel.service.d.ts.map +1 -0
  121. package/dist/services/market/cancel.service.js +342 -0
  122. package/dist/services/market/cancel.service.js.map +1 -0
  123. package/dist/services/market/cancel.types.d.ts +87 -0
  124. package/dist/services/market/cancel.types.d.ts.map +1 -0
  125. package/dist/services/market/cancel.types.js +8 -0
  126. package/dist/services/market/cancel.types.js.map +1 -0
  127. package/dist/services/market/cancel.utils.d.ts +7 -0
  128. package/dist/services/market/cancel.utils.d.ts.map +1 -0
  129. package/dist/services/market/cancel.utils.js +71 -0
  130. package/dist/services/market/cancel.utils.js.map +1 -0
  131. package/dist/services/market/client.d.ts +19 -0
  132. package/dist/services/market/client.d.ts.map +1 -0
  133. package/dist/services/market/client.js +198 -0
  134. package/dist/services/market/client.js.map +1 -0
  135. package/dist/services/market/client.types.d.ts +6 -0
  136. package/dist/services/market/client.types.d.ts.map +1 -0
  137. package/dist/services/market/client.types.js +2 -0
  138. package/dist/services/market/client.types.js.map +1 -0
  139. package/dist/services/market/constants.d.ts +21 -0
  140. package/dist/services/market/constants.d.ts.map +1 -0
  141. package/dist/services/market/constants.js +36 -0
  142. package/dist/services/market/constants.js.map +1 -0
  143. package/dist/services/market/error.d.ts +10 -0
  144. package/dist/services/market/error.d.ts.map +1 -0
  145. package/dist/services/market/error.js +18 -0
  146. package/dist/services/market/error.js.map +1 -0
  147. package/dist/services/market/error.utils.d.ts +10 -0
  148. package/dist/services/market/error.utils.d.ts.map +1 -0
  149. package/dist/services/market/error.utils.js +56 -0
  150. package/dist/services/market/error.utils.js.map +1 -0
  151. package/dist/services/market/factory.d.ts +4 -0
  152. package/dist/services/market/factory.d.ts.map +1 -0
  153. package/dist/services/market/factory.js +86 -0
  154. package/dist/services/market/factory.js.map +1 -0
  155. package/dist/services/market/factory.types.d.ts +34 -0
  156. package/dist/services/market/factory.types.d.ts.map +1 -0
  157. package/dist/services/market/factory.types.js +2 -0
  158. package/dist/services/market/factory.types.js.map +1 -0
  159. package/dist/services/market/fulfilment-proof.d.ts +13 -0
  160. package/dist/services/market/fulfilment-proof.d.ts.map +1 -0
  161. package/dist/services/market/fulfilment-proof.js +116 -0
  162. package/dist/services/market/fulfilment-proof.js.map +1 -0
  163. package/dist/services/market/fulfilment-proof.reader.d.ts +8 -0
  164. package/dist/services/market/fulfilment-proof.reader.d.ts.map +1 -0
  165. package/dist/services/market/fulfilment-proof.reader.js +22 -0
  166. package/dist/services/market/fulfilment-proof.reader.js.map +1 -0
  167. package/dist/services/market/fulfilment-proof.types.d.ts +46 -0
  168. package/dist/services/market/fulfilment-proof.types.d.ts.map +1 -0
  169. package/dist/services/market/fulfilment-proof.types.js +6 -0
  170. package/dist/services/market/fulfilment-proof.types.js.map +1 -0
  171. package/dist/services/market/fulfilment-proof.utils.d.ts +19 -0
  172. package/dist/services/market/fulfilment-proof.utils.d.ts.map +1 -0
  173. package/dist/services/market/fulfilment-proof.utils.js +69 -0
  174. package/dist/services/market/fulfilment-proof.utils.js.map +1 -0
  175. package/dist/services/market/idempotency.utils.d.ts +4 -0
  176. package/dist/services/market/idempotency.utils.d.ts.map +1 -0
  177. package/dist/services/market/idempotency.utils.js +15 -0
  178. package/dist/services/market/idempotency.utils.js.map +1 -0
  179. package/dist/services/market/listing.constants.d.ts +7 -0
  180. package/dist/services/market/listing.constants.d.ts.map +1 -0
  181. package/dist/services/market/listing.constants.js +8 -0
  182. package/dist/services/market/listing.constants.js.map +1 -0
  183. package/dist/services/market/listing.service.d.ts +53 -0
  184. package/dist/services/market/listing.service.d.ts.map +1 -0
  185. package/dist/services/market/listing.service.js +671 -0
  186. package/dist/services/market/listing.service.js.map +1 -0
  187. package/dist/services/market/listing.types.d.ts +718 -0
  188. package/dist/services/market/listing.types.d.ts.map +1 -0
  189. package/dist/services/market/listing.types.js +84 -0
  190. package/dist/services/market/listing.types.js.map +1 -0
  191. package/dist/services/market/listing.utils.d.ts +12 -0
  192. package/dist/services/market/listing.utils.d.ts.map +1 -0
  193. package/dist/services/market/listing.utils.js +51 -0
  194. package/dist/services/market/listing.utils.js.map +1 -0
  195. package/dist/services/market/offer.constants.d.ts +8 -0
  196. package/dist/services/market/offer.constants.d.ts.map +1 -0
  197. package/dist/services/market/offer.constants.js +9 -0
  198. package/dist/services/market/offer.constants.js.map +1 -0
  199. package/dist/services/market/offer.service.d.ts +54 -0
  200. package/dist/services/market/offer.service.d.ts.map +1 -0
  201. package/dist/services/market/offer.service.js +757 -0
  202. package/dist/services/market/offer.service.js.map +1 -0
  203. package/dist/services/market/offer.types.d.ts +554 -0
  204. package/dist/services/market/offer.types.d.ts.map +1 -0
  205. package/dist/services/market/offer.types.js +73 -0
  206. package/dist/services/market/offer.types.js.map +1 -0
  207. package/dist/services/market/offer.utils.d.ts +7 -0
  208. package/dist/services/market/offer.utils.d.ts.map +1 -0
  209. package/dist/services/market/offer.utils.js +25 -0
  210. package/dist/services/market/offer.utils.js.map +1 -0
  211. package/dist/services/market/profile.client.d.ts +14 -0
  212. package/dist/services/market/profile.client.d.ts.map +1 -0
  213. package/dist/services/market/profile.client.js +65 -0
  214. package/dist/services/market/profile.client.js.map +1 -0
  215. package/dist/services/market/profile.schemas.d.ts +630 -0
  216. package/dist/services/market/profile.schemas.d.ts.map +1 -0
  217. package/dist/services/market/profile.schemas.js +84 -0
  218. package/dist/services/market/profile.schemas.js.map +1 -0
  219. package/dist/services/market/profile.utils.d.ts +2 -0
  220. package/dist/services/market/profile.utils.d.ts.map +1 -0
  221. package/dist/services/market/profile.utils.js +8 -0
  222. package/dist/services/market/profile.utils.js.map +1 -0
  223. package/dist/services/market/purchase.constants.d.ts +5 -0
  224. package/dist/services/market/purchase.constants.d.ts.map +1 -0
  225. package/dist/services/market/purchase.constants.js +6 -0
  226. package/dist/services/market/purchase.constants.js.map +1 -0
  227. package/dist/services/market/purchase.service.d.ts +48 -0
  228. package/dist/services/market/purchase.service.d.ts.map +1 -0
  229. package/dist/services/market/purchase.service.js +564 -0
  230. package/dist/services/market/purchase.service.js.map +1 -0
  231. package/dist/services/market/purchase.types.d.ts +207 -0
  232. package/dist/services/market/purchase.types.d.ts.map +1 -0
  233. package/dist/services/market/purchase.types.js +13 -0
  234. package/dist/services/market/purchase.types.js.map +1 -0
  235. package/dist/services/market/purchase.utils.d.ts +11 -0
  236. package/dist/services/market/purchase.utils.d.ts.map +1 -0
  237. package/dist/services/market/purchase.utils.js +29 -0
  238. package/dist/services/market/purchase.utils.js.map +1 -0
  239. package/dist/services/market/recovery.constants.d.ts +6 -0
  240. package/dist/services/market/recovery.constants.d.ts.map +1 -0
  241. package/dist/services/market/recovery.constants.js +6 -0
  242. package/dist/services/market/recovery.constants.js.map +1 -0
  243. package/dist/services/market/recovery.store.d.ts +10 -0
  244. package/dist/services/market/recovery.store.d.ts.map +1 -0
  245. package/dist/services/market/recovery.store.js +44 -0
  246. package/dist/services/market/recovery.store.js.map +1 -0
  247. package/dist/services/market/service.d.ts +11 -0
  248. package/dist/services/market/service.d.ts.map +1 -0
  249. package/dist/services/market/service.js +71 -0
  250. package/dist/services/market/service.js.map +1 -0
  251. package/dist/services/market/single-flight.d.ts +6 -0
  252. package/dist/services/market/single-flight.d.ts.map +1 -0
  253. package/dist/services/market/single-flight.js +19 -0
  254. package/dist/services/market/single-flight.js.map +1 -0
  255. package/dist/services/market/snapshot.schemas.d.ts +385 -0
  256. package/dist/services/market/snapshot.schemas.d.ts.map +1 -0
  257. package/dist/services/market/snapshot.schemas.js +67 -0
  258. package/dist/services/market/snapshot.schemas.js.map +1 -0
  259. package/dist/services/market/types.d.ts +787 -0
  260. package/dist/services/market/types.d.ts.map +1 -0
  261. package/dist/services/market/types.js +216 -0
  262. package/dist/services/market/types.js.map +1 -0
  263. package/dist/services/types.d.ts +2 -0
  264. package/dist/services/types.d.ts.map +1 -1
  265. package/dist/services/types.js.map +1 -1
  266. package/dist/session/jwt.utils.d.ts +1 -0
  267. package/dist/session/jwt.utils.d.ts.map +1 -1
  268. package/dist/session/jwt.utils.js +4 -0
  269. package/dist/session/jwt.utils.js.map +1 -1
  270. package/dist/session/manager.d.ts +1 -1
  271. package/dist/session/manager.d.ts.map +1 -1
  272. package/dist/session/manager.js.map +1 -1
  273. package/dist/tools/authenticate.d.ts +1 -1
  274. package/dist/tools/authenticate.d.ts.map +1 -1
  275. package/dist/tools/authenticate.js.map +1 -1
  276. package/dist/tools/config/get-game-config/get-game-config.utils.js +1 -1
  277. package/dist/tools/config/get-game-config/get-game-config.utils.js.map +1 -1
  278. package/dist/tools/market/accept-offer/accept-offer.d.ts +4 -0
  279. package/dist/tools/market/accept-offer/accept-offer.d.ts.map +1 -0
  280. package/dist/tools/market/accept-offer/accept-offer.js +29 -0
  281. package/dist/tools/market/accept-offer/accept-offer.js.map +1 -0
  282. package/dist/tools/market/accept-offer/constants.d.ts +2 -0
  283. package/dist/tools/market/accept-offer/constants.d.ts.map +1 -0
  284. package/dist/tools/market/accept-offer/constants.js +27 -0
  285. package/dist/tools/market/accept-offer/constants.js.map +1 -0
  286. package/dist/tools/market/accept-offer/format.utils.d.ts +3 -0
  287. package/dist/tools/market/accept-offer/format.utils.d.ts.map +1 -0
  288. package/dist/tools/market/accept-offer/format.utils.js +22 -0
  289. package/dist/tools/market/accept-offer/format.utils.js.map +1 -0
  290. package/dist/tools/market/accept-offer/types.d.ts +9 -0
  291. package/dist/tools/market/accept-offer/types.d.ts.map +1 -0
  292. package/dist/tools/market/accept-offer/types.js +14 -0
  293. package/dist/tools/market/accept-offer/types.js.map +1 -0
  294. package/dist/tools/market/buy-cell/buy-cell.d.ts +4 -0
  295. package/dist/tools/market/buy-cell/buy-cell.d.ts.map +1 -0
  296. package/dist/tools/market/buy-cell/buy-cell.js +30 -0
  297. package/dist/tools/market/buy-cell/buy-cell.js.map +1 -0
  298. package/dist/tools/market/buy-cell/constants.d.ts +2 -0
  299. package/dist/tools/market/buy-cell/constants.d.ts.map +1 -0
  300. package/dist/tools/market/buy-cell/constants.js +23 -0
  301. package/dist/tools/market/buy-cell/constants.js.map +1 -0
  302. package/dist/tools/market/buy-cell/format.utils.d.ts +3 -0
  303. package/dist/tools/market/buy-cell/format.utils.d.ts.map +1 -0
  304. package/dist/tools/market/buy-cell/format.utils.js +17 -0
  305. package/dist/tools/market/buy-cell/format.utils.js.map +1 -0
  306. package/dist/tools/market/buy-cell/types.d.ts +6 -0
  307. package/dist/tools/market/buy-cell/types.d.ts.map +1 -0
  308. package/dist/tools/market/buy-cell/types.js +10 -0
  309. package/dist/tools/market/buy-cell/types.js.map +1 -0
  310. package/dist/tools/market/cancel-order/cancel-order.d.ts +4 -0
  311. package/dist/tools/market/cancel-order/cancel-order.d.ts.map +1 -0
  312. package/dist/tools/market/cancel-order/cancel-order.js +29 -0
  313. package/dist/tools/market/cancel-order/cancel-order.js.map +1 -0
  314. package/dist/tools/market/cancel-order/constants.d.ts +2 -0
  315. package/dist/tools/market/cancel-order/constants.d.ts.map +1 -0
  316. package/dist/tools/market/cancel-order/constants.js +22 -0
  317. package/dist/tools/market/cancel-order/constants.js.map +1 -0
  318. package/dist/tools/market/cancel-order/format.utils.d.ts +3 -0
  319. package/dist/tools/market/cancel-order/format.utils.d.ts.map +1 -0
  320. package/dist/tools/market/cancel-order/format.utils.js +13 -0
  321. package/dist/tools/market/cancel-order/format.utils.js.map +1 -0
  322. package/dist/tools/market/cancel-order/types.d.ts +8 -0
  323. package/dist/tools/market/cancel-order/types.d.ts.map +1 -0
  324. package/dist/tools/market/cancel-order/types.js +7 -0
  325. package/dist/tools/market/cancel-order/types.js.map +1 -0
  326. package/dist/tools/market/cell-market/cell-market.d.ts +4 -0
  327. package/dist/tools/market/cell-market/cell-market.d.ts.map +1 -0
  328. package/dist/tools/market/cell-market/cell-market.js +24 -0
  329. package/dist/tools/market/cell-market/cell-market.js.map +1 -0
  330. package/dist/tools/market/cell-market/constants.d.ts +2 -0
  331. package/dist/tools/market/cell-market/constants.d.ts.map +1 -0
  332. package/dist/tools/market/cell-market/constants.js +16 -0
  333. package/dist/tools/market/cell-market/constants.js.map +1 -0
  334. package/dist/tools/market/format.utils.d.ts +8 -0
  335. package/dist/tools/market/format.utils.d.ts.map +1 -0
  336. package/dist/tools/market/format.utils.js +75 -0
  337. package/dist/tools/market/format.utils.js.map +1 -0
  338. package/dist/tools/market/list-cell/constants.d.ts +2 -0
  339. package/dist/tools/market/list-cell/constants.d.ts.map +1 -0
  340. package/dist/tools/market/list-cell/constants.js +23 -0
  341. package/dist/tools/market/list-cell/constants.js.map +1 -0
  342. package/dist/tools/market/list-cell/list-cell.d.ts +4 -0
  343. package/dist/tools/market/list-cell/list-cell.d.ts.map +1 -0
  344. package/dist/tools/market/list-cell/list-cell.js +31 -0
  345. package/dist/tools/market/list-cell/list-cell.js.map +1 -0
  346. package/dist/tools/market/list-cell/types.d.ts +7 -0
  347. package/dist/tools/market/list-cell/types.d.ts.map +1 -0
  348. package/dist/tools/market/list-cell/types.js +15 -0
  349. package/dist/tools/market/list-cell/types.js.map +1 -0
  350. package/dist/tools/market/make-offer/constants.d.ts +2 -0
  351. package/dist/tools/market/make-offer/constants.d.ts.map +1 -0
  352. package/dist/tools/market/make-offer/constants.js +22 -0
  353. package/dist/tools/market/make-offer/constants.js.map +1 -0
  354. package/dist/tools/market/make-offer/format.utils.d.ts +3 -0
  355. package/dist/tools/market/make-offer/format.utils.d.ts.map +1 -0
  356. package/dist/tools/market/make-offer/format.utils.js +16 -0
  357. package/dist/tools/market/make-offer/format.utils.js.map +1 -0
  358. package/dist/tools/market/make-offer/make-offer.d.ts +4 -0
  359. package/dist/tools/market/make-offer/make-offer.d.ts.map +1 -0
  360. package/dist/tools/market/make-offer/make-offer.js +30 -0
  361. package/dist/tools/market/make-offer/make-offer.js.map +1 -0
  362. package/dist/tools/market/make-offer/types.d.ts +10 -0
  363. package/dist/tools/market/make-offer/types.d.ts.map +1 -0
  364. package/dist/tools/market/make-offer/types.js +10 -0
  365. package/dist/tools/market/make-offer/types.js.map +1 -0
  366. package/dist/tools/market/my-listings/constants.d.ts +2 -0
  367. package/dist/tools/market/my-listings/constants.d.ts.map +1 -0
  368. package/dist/tools/market/my-listings/constants.js +14 -0
  369. package/dist/tools/market/my-listings/constants.js.map +1 -0
  370. package/dist/tools/market/my-listings/my-listings.d.ts +4 -0
  371. package/dist/tools/market/my-listings/my-listings.d.ts.map +1 -0
  372. package/dist/tools/market/my-listings/my-listings.js +24 -0
  373. package/dist/tools/market/my-listings/my-listings.js.map +1 -0
  374. package/dist/tools/market/my-offers/constants.d.ts +2 -0
  375. package/dist/tools/market/my-offers/constants.d.ts.map +1 -0
  376. package/dist/tools/market/my-offers/constants.js +15 -0
  377. package/dist/tools/market/my-offers/constants.js.map +1 -0
  378. package/dist/tools/market/my-offers/my-offers.d.ts +4 -0
  379. package/dist/tools/market/my-offers/my-offers.d.ts.map +1 -0
  380. package/dist/tools/market/my-offers/my-offers.js +24 -0
  381. package/dist/tools/market/my-offers/my-offers.js.map +1 -0
  382. package/dist/tools/market/my-offers-received/constants.d.ts +2 -0
  383. package/dist/tools/market/my-offers-received/constants.d.ts.map +1 -0
  384. package/dist/tools/market/my-offers-received/constants.js +16 -0
  385. package/dist/tools/market/my-offers-received/constants.js.map +1 -0
  386. package/dist/tools/market/my-offers-received/my-offers-received.d.ts +4 -0
  387. package/dist/tools/market/my-offers-received/my-offers-received.d.ts.map +1 -0
  388. package/dist/tools/market/my-offers-received/my-offers-received.js +24 -0
  389. package/dist/tools/market/my-offers-received/my-offers-received.js.map +1 -0
  390. package/dist/tools/market/output.types.d.ts +822 -0
  391. package/dist/tools/market/output.types.d.ts.map +1 -0
  392. package/dist/tools/market/output.types.js +75 -0
  393. package/dist/tools/market/output.types.js.map +1 -0
  394. package/dist/tools/market/register.d.ts +12 -0
  395. package/dist/tools/market/register.d.ts.map +1 -0
  396. package/dist/tools/market/register.js +50 -0
  397. package/dist/tools/market/register.js.map +1 -0
  398. package/dist/tools/market/types.d.ts +16 -0
  399. package/dist/tools/market/types.d.ts.map +1 -0
  400. package/dist/tools/market/types.js +14 -0
  401. package/dist/tools/market/types.js.map +1 -0
  402. package/dist/tools/types.d.ts +6 -1
  403. package/dist/tools/types.d.ts.map +1 -1
  404. package/dist/tools/types.js +5 -0
  405. package/dist/tools/types.js.map +1 -1
  406. package/dist/types.d.ts +14 -0
  407. package/dist/types.d.ts.map +1 -1
  408. package/dist/types.js.map +1 -1
  409. package/dist/wallet/evm.manager.d.ts +3 -1
  410. package/dist/wallet/evm.manager.d.ts.map +1 -1
  411. package/dist/wallet/evm.manager.js +12 -0
  412. package/dist/wallet/evm.manager.js.map +1 -1
  413. package/dist/wallet/evm.provider.d.ts.map +1 -1
  414. package/dist/wallet/evm.provider.js +0 -3
  415. package/dist/wallet/evm.provider.js.map +1 -1
  416. package/dist/wallet/types.d.ts +19 -0
  417. package/dist/wallet/types.d.ts.map +1 -1
  418. package/package.json +1 -1
@@ -0,0 +1,671 @@
1
+ import { zeroAddress, zeroHash } from 'viem';
2
+ import { MarketActionTool, } from './action.types.js';
3
+ import { narrowInvocationDeadline, waitOnInvocationBudget } from './budget.utils.js';
4
+ import { MS_PER_SECOND, PROVEN_UNPUBLISHED_MARKET_ERROR_CODES, USDG_CENT_BASE_UNITS } from './constants.js';
5
+ import { MarketError } from './error.js';
6
+ import { marketActionKey } from './idempotency.utils.js';
7
+ import { LISTING_NO_IDENTIFIER, LISTING_SINGLE_UNIT, LISTING_START_TIME_SKEW_SECONDS, LISTING_SUBMIT_MAX_ATTEMPTS, MARKET_LISTING_PREPARE_PATH, MARKET_LISTING_SUBMIT_PATH, } from './listing.constants.js';
8
+ import { MarketScanOutcome, prepareListingResponseSchemaFor, submitListingResponseSchemaFor, } from './listing.types.js';
9
+ import { effectiveListingDeadline, isEquivalentActiveListing, listingActionInputs, sameAddress, sameOptionalAddress, seaportSignableOrder, sumBaseUnits, } from './listing.utils.js';
10
+ import { MARKET_PROFILE_CACHE_MS, MARKET_RECONCILE_MAX_PAGES } from './recovery.constants.js';
11
+ import { cellTokenIdSchema, evmAddressSchema, MarketActionStage, MarketActionStatus, MarketErrorCode, MarketTransactionKind, positiveBaseUnitAmountSchema, unixSecondsSchema, } from './types.js';
12
+ import { collectionApprovalCall } from '../../contracts/approval.utils.js';
13
+ import { SeaportSpenderReader } from '../../contracts/seaport-spender.reader.js';
14
+ import { OPENSEA_SIGNED_ZONE_V2, SEAPORT_ADDRESS, SEAPORT_DOMAIN_NAME, SEAPORT_DOMAIN_VERSION, SEAPORT_ORDER_COMPONENTS_TYPES, SEAPORT_ORDER_PRIMARY_TYPE, } from '../../contracts/seaport.constants.js';
15
+ import { SeaportItemType, SeaportOrderType, SeaportSpenderOutcome, } from '../../contracts/seaport.types.js';
16
+ import { TxStatus } from '../../wallet/types.js';
17
+ export class MarketListingService {
18
+ client;
19
+ profile;
20
+ appConfig;
21
+ wallet;
22
+ network;
23
+ singleFlight;
24
+ recovery;
25
+ logger;
26
+ spenders;
27
+ lastProfileReadAt = null;
28
+ constructor(options) {
29
+ this.spenders = new SeaportSpenderReader({ wallet: options.wallet });
30
+ this.client = options.client;
31
+ this.profile = options.profile;
32
+ this.appConfig = options.appConfig;
33
+ this.wallet = options.wallet;
34
+ this.network = options.network;
35
+ this.singleFlight = options.singleFlight;
36
+ this.recovery = options.recovery;
37
+ this.logger = options.logger;
38
+ }
39
+ async listCell(request) {
40
+ const validated = this.requireUsableRequest(request);
41
+ const key = marketActionKey({
42
+ wallet: this.walletAddress(),
43
+ network: this.network,
44
+ tool: MarketActionTool.ListCell,
45
+ inputs: listingActionInputs(validated),
46
+ });
47
+ return this.singleFlight.run(key, async () => this.publish(key, validated));
48
+ }
49
+ async publish(key, request) {
50
+ const unresolved = this.recovery.read(key);
51
+ if (unresolved !== null && unresolved.payload.prepared !== null) {
52
+ return this.resume(key, request, unresolved);
53
+ }
54
+ this.reserve(key, MarketActionStage.Reconcile, this.emptyPayload());
55
+ let payload = this.emptyPayload();
56
+ try {
57
+ await this.requireNoEquivalentActiveListing(request);
58
+ const prepared = await this.prepare(request);
59
+ payload = { prepared, signature: null, approvalTxHashes: [] };
60
+ this.reserve(key, MarketActionStage.Prepare, payload);
61
+ payload = { ...payload, approvalTxHashes: await this.broadcastApprovals(prepared) };
62
+ this.reserve(key, MarketActionStage.Approve, payload);
63
+ payload = { ...payload, signature: await this.sign(prepared) };
64
+ this.reserve(key, MarketActionStage.Sign, payload);
65
+ }
66
+ catch (error) {
67
+ this.recovery.forget(key);
68
+ throw error;
69
+ }
70
+ return this.submit(key, request, payload, false);
71
+ }
72
+ async resume(key, request, record) {
73
+ const payload = record.payload;
74
+ const prepared = payload.prepared;
75
+ if (prepared === null) {
76
+ this.recovery.forget(key);
77
+ return this.publish(key, request);
78
+ }
79
+ if (this.nowSeconds() >= effectiveListingDeadline(prepared)) {
80
+ return this.reconcileExpired(key, request, prepared);
81
+ }
82
+ if (payload.signature === null) {
83
+ const resumed = {
84
+ ...payload,
85
+ approvalTxHashes: await this.broadcastApprovals(prepared),
86
+ };
87
+ const signed = { ...resumed, signature: await this.sign(prepared) };
88
+ this.reserve(key, MarketActionStage.Sign, signed);
89
+ return this.submit(key, request, signed, false);
90
+ }
91
+ return this.submit(key, request, payload, record.stage === MarketActionStage.Submit);
92
+ }
93
+ async submit(key, request, payload, submittedBefore) {
94
+ const prepared = this.requirePrepared(payload);
95
+ let reachedServer = submittedBefore;
96
+ for (let attempt = 1; attempt <= LISTING_SUBMIT_MAX_ATTEMPTS; attempt += 1) {
97
+ this.requireWithinDeadline(prepared, MarketActionStage.Submit);
98
+ const priorSubmission = reachedServer;
99
+ reachedServer = true;
100
+ try {
101
+ const response = await this.client.sendOnce({
102
+ path: MARKET_LISTING_SUBMIT_PATH,
103
+ method: 'POST',
104
+ body: { prepareId: prepared.prepareId, signature: payload.signature },
105
+ schema: submitListingResponseSchemaFor(this.wallet.get().getChainId()),
106
+ stage: MarketActionStage.Submit,
107
+ label: `Publishing the listing for Cell ${request.tokenId}`,
108
+ });
109
+ this.recovery.forget(key);
110
+ return this.result(MarketActionStatus.Completed, request, payload, response.listing);
111
+ }
112
+ catch (error) {
113
+ if (this.provenUnpublished(error, priorSubmission)) {
114
+ this.recovery.forget(key);
115
+ throw error;
116
+ }
117
+ this.reserve(key, MarketActionStage.Submit, payload);
118
+ this.logger.warn('the listing submit left an uncertain outcome — reconciling before any retry', {
119
+ tokenId: request.tokenId,
120
+ attempt,
121
+ });
122
+ const published = await this.reconcile(request, MarketActionStage.Submit);
123
+ if (published !== null) {
124
+ this.recovery.forget(key);
125
+ return this.result(MarketActionStatus.AlreadyCompleted, request, payload, published);
126
+ }
127
+ if (error instanceof MarketError && !error.retryable) {
128
+ throw this.outcomeUnknown(request, MarketActionStage.Submit);
129
+ }
130
+ }
131
+ }
132
+ throw this.outcomeUnknown(request, MarketActionStage.Submit);
133
+ }
134
+ provenUnpublished(error, priorSubmission) {
135
+ return (!priorSubmission &&
136
+ error instanceof MarketError &&
137
+ !error.retryable &&
138
+ PROVEN_UNPUBLISHED_MARKET_ERROR_CODES.has(error.code));
139
+ }
140
+ async reconcileExpired(key, request, prepared) {
141
+ const published = await this.reconcile(request, MarketActionStage.Reconcile);
142
+ if (published !== null) {
143
+ this.recovery.forget(key);
144
+ return this.result(MarketActionStatus.AlreadyCompleted, request, { prepared, signature: null, approvalTxHashes: [] }, published);
145
+ }
146
+ this.recovery.forget(key);
147
+ throw new MarketError({
148
+ code: MarketErrorCode.PreparedIntentExpired,
149
+ message: `The prepared listing for Cell ${request.tokenId} ran out of time before it could be published, ` +
150
+ 'and no matching listing is active. Call the tool again to prepare a fresh listing.',
151
+ retryable: false,
152
+ retryAfterSeconds: null,
153
+ stage: MarketActionStage.Reconcile,
154
+ txHash: null,
155
+ });
156
+ }
157
+ async reconcile(request, stage) {
158
+ await this.waitForProfileCacheHorizon();
159
+ let scan;
160
+ try {
161
+ scan = await this.scanActiveListings(request);
162
+ }
163
+ catch (error) {
164
+ this.logger.error('cannot reconcile an uncertain listing against the marketplace', {
165
+ tokenId: request.tokenId,
166
+ error,
167
+ });
168
+ throw this.outcomeUnknown(request, stage);
169
+ }
170
+ if (scan.outcome === MarketScanOutcome.Exhausted) {
171
+ this.logger.error('the active listings run past the pages this tool may read, so nothing is settled', {
172
+ tokenId: request.tokenId,
173
+ pages: MARKET_RECONCILE_MAX_PAGES,
174
+ });
175
+ throw this.outcomeUnknown(request, stage);
176
+ }
177
+ return scan.listing;
178
+ }
179
+ async requireNoEquivalentActiveListing(request) {
180
+ const scan = await this.scanActiveListings(request);
181
+ if (scan.outcome === MarketScanOutcome.Exhausted) {
182
+ throw new MarketError({
183
+ code: MarketErrorCode.OutcomeUnknown,
184
+ message: `Your active listings run past the ${MARKET_RECONCILE_MAX_PAGES} pages this tool reads, so it ` +
185
+ `cannot rule out that Cell ${request.tokenId} already carries an equivalent listing, and it ` +
186
+ 'will not prepare another one blindly. Cancel listings you no longer need, then call the tool ' +
187
+ 'again.',
188
+ retryable: true,
189
+ retryAfterSeconds: null,
190
+ stage: MarketActionStage.Reconcile,
191
+ txHash: null,
192
+ });
193
+ }
194
+ const active = scan.listing;
195
+ if (active === null) {
196
+ return;
197
+ }
198
+ throw new MarketError({
199
+ code: MarketErrorCode.ActiveOrderExists,
200
+ message: `Cell ${request.tokenId} already carries an active listing of yours at this price and expiry ` +
201
+ `(order ${active.orderHash}). A public listing and a listing reserved for one buyer look the same ` +
202
+ 'from outside, so publishing another one could duplicate your order. Cancel that order first if ' +
203
+ 'you meant to replace it.',
204
+ retryable: false,
205
+ retryAfterSeconds: null,
206
+ stage: MarketActionStage.Reconcile,
207
+ txHash: null,
208
+ });
209
+ }
210
+ async scanActiveListings(request) {
211
+ const wallet = this.walletAddress();
212
+ let cursor = null;
213
+ for (let page = 0; page < MARKET_RECONCILE_MAX_PAGES; page += 1) {
214
+ const listings = await this.profile.getMyListings(cursor);
215
+ this.lastProfileReadAt = Date.now();
216
+ const candidates = listings.items.filter((listing) => listing.tokenId === request.tokenId && listing.price === request.price);
217
+ for (const candidate of candidates) {
218
+ try {
219
+ const details = await this.profile.getOrderDetails(candidate.orderHash);
220
+ if (details.orderKind === 'listing' && isEquivalentActiveListing(details.order, request, wallet)) {
221
+ return { outcome: MarketScanOutcome.Found, listing: details.order };
222
+ }
223
+ }
224
+ catch (error) {
225
+ if (error instanceof MarketError &&
226
+ (error.code === MarketErrorCode.StaleListing || error.code === MarketErrorCode.StaleOffer)) {
227
+ continue;
228
+ }
229
+ throw error;
230
+ }
231
+ }
232
+ cursor = listings.nextCursor;
233
+ if (cursor === null) {
234
+ return { outcome: MarketScanOutcome.Absent, listing: null };
235
+ }
236
+ }
237
+ return { outcome: MarketScanOutcome.Exhausted, listing: null };
238
+ }
239
+ async waitForProfileCacheHorizon() {
240
+ if (this.lastProfileReadAt === null) {
241
+ return;
242
+ }
243
+ const remaining = MARKET_PROFILE_CACHE_MS - (Date.now() - this.lastProfileReadAt);
244
+ if (remaining > 0) {
245
+ this.logger.info('waiting for the marketplace read snapshot to advance before reconciling', { remaining });
246
+ await waitOnInvocationBudget(remaining);
247
+ }
248
+ }
249
+ async prepare(request) {
250
+ const body = {
251
+ tokenId: request.tokenId,
252
+ price: request.price,
253
+ expirationTime: request.expirationTime,
254
+ };
255
+ if (request.buyerAddress !== null) {
256
+ body.buyerAddress = request.buyerAddress;
257
+ }
258
+ const contracts = await this.requireMarketContracts();
259
+ const prepared = await this.client.send({
260
+ path: MARKET_LISTING_PREPARE_PATH,
261
+ method: 'POST',
262
+ body,
263
+ schema: prepareListingResponseSchemaFor(request),
264
+ stage: MarketActionStage.Prepare,
265
+ label: `Preparing the listing for Cell ${request.tokenId}`,
266
+ });
267
+ this.requireSupportedPricePrecision(request, prepared, contracts.usdg);
268
+ await this.requireTrustworthyPreparation(request, prepared, contracts.collection);
269
+ return prepared;
270
+ }
271
+ async requireMarketContracts() {
272
+ const config = await this.appConfig.load();
273
+ const collection = config.contracts.land;
274
+ if (!evmAddressSchema.safeParse(collection).success) {
275
+ throw new MarketError({
276
+ code: MarketErrorCode.InvalidMarketResponse,
277
+ message: 'The Cell collection contract is not configured for this network, so the order a listing asks ' +
278
+ 'the wallet to sign cannot be checked against the collection it must offer.',
279
+ retryable: false,
280
+ retryAfterSeconds: null,
281
+ stage: MarketActionStage.Prepare,
282
+ txHash: null,
283
+ });
284
+ }
285
+ return { collection, usdg: config.contracts.usdg };
286
+ }
287
+ requireSupportedPricePrecision(request, prepared, usdg) {
288
+ if (evmAddressSchema.safeParse(usdg).success &&
289
+ sameAddress(prepared.listing.currency.address, usdg) &&
290
+ BigInt(request.price) % USDG_CENT_BASE_UNITS !== 0n) {
291
+ throw this.rejectedInput(`"${request.price}" is not a valid USDG listing price. Pass a positive decimal integer in whole ` +
292
+ 'cent increments: 10000 base units is $0.01.');
293
+ }
294
+ }
295
+ async requireTrustworthyPreparation(request, prepared, collection) {
296
+ const wallet = this.walletAddress();
297
+ const chainId = this.wallet.get().getChainId();
298
+ if (prepared.chainId !== chainId) {
299
+ throw this.untrustworthy(MarketErrorCode.ChainMismatch, `it targets chain ${prepared.chainId} while this wallet signs for chain ${chainId}`, request);
300
+ }
301
+ if (!sameAddress(prepared.protocolAddress, SEAPORT_ADDRESS)) {
302
+ throw this.untrustworthy(MarketErrorCode.ProtocolAddressMismatch, `it names protocol contract ${prepared.protocolAddress} instead of the pinned ${SEAPORT_ADDRESS}`, request);
303
+ }
304
+ if (!sameAddress(prepared.listing.maker, wallet) || !sameAddress(prepared.order.offerer, wallet)) {
305
+ throw this.untrustworthy(MarketErrorCode.WrongOwner, `it sells on behalf of ${prepared.listing.maker} rather than this wallet ${wallet}`, request);
306
+ }
307
+ this.requireRequestedTerms(request, prepared);
308
+ this.requireFeeArithmetic(request, prepared);
309
+ await this.requireApprovalsOnly(request, prepared, collection);
310
+ this.requireOfferedCell(request, prepared, collection);
311
+ this.requireOrderShape(request, prepared);
312
+ this.requireConsideration(request, prepared);
313
+ }
314
+ requireRequestedTerms(request, prepared) {
315
+ const listing = prepared.listing;
316
+ if (listing.tokenId !== request.tokenId) {
317
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it sells Cell ${listing.tokenId} instead of Cell ${request.tokenId}`, request);
318
+ }
319
+ if (listing.price !== request.price) {
320
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `its gross price is ${listing.price} instead of the requested ${request.price}`, request);
321
+ }
322
+ if (listing.expirationTime !== request.expirationTime) {
323
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it expires at ${listing.expirationTime} instead of the requested ${request.expirationTime}`, request);
324
+ }
325
+ if (!sameOptionalAddress(listing.buyerAddress, request.buyerAddress)) {
326
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `its reserved buyer is ${listing.buyerAddress ?? 'nobody'} instead of ` +
327
+ `${request.buyerAddress ?? 'nobody'}`, request);
328
+ }
329
+ if (listing.startTime > this.nowSeconds() + LISTING_START_TIME_SKEW_SECONDS) {
330
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it does not become fillable until ${listing.startTime}, so it would not be the listing you asked ` +
331
+ 'for now', request);
332
+ }
333
+ }
334
+ requireFeeArithmetic(request, prepared) {
335
+ const fees = prepared.fees;
336
+ const total = sumBaseUnits([fees.platformFee, fees.creatorFee, fees.estimatedProceeds]);
337
+ if (total !== prepared.listing.price) {
338
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `its platform fee, creator fee and proceeds add up to ${total} rather than the gross price ` +
339
+ `${prepared.listing.price}`, request);
340
+ }
341
+ }
342
+ async requireApprovalsOnly(request, prepared, collection) {
343
+ const chainId = this.wallet.get().getChainId();
344
+ const foreign = prepared.transactions.find((transaction) => transaction.kind !== MarketTransactionKind.CollectionApproval || transaction.chainId !== chainId);
345
+ if (foreign !== undefined) {
346
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `publishing a listing may only need collection approvals, but it asks to send a "${foreign.kind}" ` +
347
+ `transaction on chain ${foreign.chainId}`, request);
348
+ }
349
+ const operators = prepared.transactions.map((transaction) => this.requireCollectionOperator(request, transaction, collection));
350
+ await this.requireOrderOperator(request, prepared, operators);
351
+ }
352
+ requireCollectionOperator(request, transaction, collection) {
353
+ if (!sameAddress(transaction.to, collection)) {
354
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it asks the wallet to approve contract ${transaction.to} instead of the Cell collection ` +
355
+ `${collection}`, request);
356
+ }
357
+ const approval = collectionApprovalCall(transaction.data);
358
+ if (approval === null) {
359
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, 'it asks the wallet to send calldata the Cell collection would not read as approving one operator', request);
360
+ }
361
+ if (!approval.approved) {
362
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it asks the wallet to withdraw ${approval.operator}'s approval rather than grant the one a ` +
363
+ 'listing needs', request);
364
+ }
365
+ return approval;
366
+ }
367
+ async requireOrderOperator(request, prepared, approvals) {
368
+ if (approvals.length === 0) {
369
+ return;
370
+ }
371
+ const conduitKey = prepared.order.conduitKey;
372
+ const answer = await this.spenders.spenderForConduitKey(conduitKey);
373
+ const detail = answer.detail ?? `conduit key ${conduitKey} resolves to nothing`;
374
+ if (answer.outcome === SeaportSpenderOutcome.Unreachable) {
375
+ throw new MarketError({
376
+ code: MarketErrorCode.NetworkFailure,
377
+ message: `The listing for Cell ${request.tokenId} was not signed because ${detail}. Nothing was ` +
378
+ 'approved and nothing was published.',
379
+ retryable: true,
380
+ retryAfterSeconds: null,
381
+ stage: MarketActionStage.Prepare,
382
+ txHash: null,
383
+ });
384
+ }
385
+ if (answer.address === null) {
386
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign settles through an operator this client cannot justify: ` +
387
+ `${detail}`, request);
388
+ }
389
+ const operator = answer.address;
390
+ const stranger = approvals.find((approval) => !sameAddress(approval.operator, operator));
391
+ if (stranger !== undefined) {
392
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it asks the wallet to let ${stranger.operator} move every Cell it owns, while the order it signs ` +
393
+ `is settled by ${operator}`, request);
394
+ }
395
+ }
396
+ requireOfferedCell(request, prepared, collection) {
397
+ const order = prepared.order;
398
+ const sold = order.offer.length === 1 ? (order.offer[0] ?? null) : null;
399
+ if (sold === null || sold.identifierOrCriteria !== request.tokenId) {
400
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign does not offer exactly Cell ${request.tokenId}`, request);
401
+ }
402
+ if (sold.itemType !== SeaportItemType.Erc721) {
403
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign offers item type ${sold.itemType} rather than the ERC-721 Cell`, request);
404
+ }
405
+ if (!sameAddress(sold.token, collection)) {
406
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign offers a token of collection ${sold.token} instead of the ` +
407
+ `Cell collection ${collection}`, request);
408
+ }
409
+ if (sold.startAmount !== LISTING_SINGLE_UNIT || sold.endAmount !== LISTING_SINGLE_UNIT) {
410
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign offers ${sold.startAmount} units of the Cell rather than one`, request);
411
+ }
412
+ }
413
+ requireOrderShape(request, prepared) {
414
+ const order = prepared.order;
415
+ const reserved = request.buyerAddress !== null;
416
+ const openPublic = order.orderType === SeaportOrderType.FullOpen &&
417
+ sameAddress(order.zone, zeroAddress) &&
418
+ order.zoneHash === zeroHash;
419
+ const signedZonePublic = order.orderType === SeaportOrderType.FullRestricted &&
420
+ sameAddress(order.zone, OPENSEA_SIGNED_ZONE_V2) &&
421
+ order.zoneHash === zeroHash;
422
+ if (!reserved && !openPublic && !signedZonePublic) {
423
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign is neither a full-open zero-zone listing nor a ` +
424
+ `full-restricted listing through the pinned signed zone ${OPENSEA_SIGNED_ZONE_V2}`, request);
425
+ }
426
+ if (reserved && (order.orderType !== SeaportOrderType.FullRestricted || sameAddress(order.zone, zeroAddress))) {
427
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, 'the order it asks the wallet to sign names no zone, so nothing would hold the sale to the buyer ' +
428
+ 'you reserved it for', request);
429
+ }
430
+ if (order.startTime !== prepared.listing.startTime.toString()) {
431
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign becomes fillable at ${order.startTime} instead of the ` +
432
+ `prepared ${prepared.listing.startTime}`, request);
433
+ }
434
+ if (order.endTime !== request.expirationTime.toString()) {
435
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign ends at ${order.endTime} instead of ${request.expirationTime}`, request);
436
+ }
437
+ }
438
+ requireConsideration(request, prepared) {
439
+ const order = prepared.order;
440
+ const currency = prepared.listing.currency.address;
441
+ const expected = sameAddress(currency, zeroAddress) ? SeaportItemType.Native : SeaportItemType.Erc20;
442
+ const payments = [...order.consideration];
443
+ if (request.buyerAddress !== null) {
444
+ const marker = payments.pop();
445
+ const sold = order.offer[0];
446
+ this.requirePrivateSaleMarker(request, marker, sold);
447
+ }
448
+ if (payments.length === 0) {
449
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, 'the order it asks the wallet to sign pays the seller side nothing at all', request);
450
+ }
451
+ if (order.totalOriginalConsiderationItems !== order.consideration.length) {
452
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign declares ${order.totalOriginalConsiderationItems} original ` +
453
+ `consideration items while carrying ${order.consideration.length}`, request);
454
+ }
455
+ for (const item of payments) {
456
+ this.requireConsiderationItem(request, item, currency, expected);
457
+ }
458
+ const paid = sumBaseUnits(payments.map((item) => item.startAmount));
459
+ if (paid !== prepared.listing.price) {
460
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign collects ${paid} for the seller side rather than the gross ` +
461
+ `price ${prepared.listing.price}`, request);
462
+ }
463
+ const kept = sumBaseUnits(payments
464
+ .filter((item) => sameAddress(item.recipient, this.walletAddress()))
465
+ .map((item) => item.startAmount));
466
+ if (BigInt(kept) < BigInt(prepared.fees.estimatedProceeds)) {
467
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign pays this wallet ${kept} while its fee preview promises ` +
468
+ `${prepared.fees.estimatedProceeds}`, request);
469
+ }
470
+ }
471
+ requirePrivateSaleMarker(request, marker, sold) {
472
+ const buyer = request.buyerAddress;
473
+ const exactMarker = buyer !== null &&
474
+ marker !== undefined &&
475
+ sold !== undefined &&
476
+ marker.itemType === sold.itemType &&
477
+ sameAddress(marker.token, sold.token) &&
478
+ marker.identifierOrCriteria === sold.identifierOrCriteria &&
479
+ marker.startAmount === sold.startAmount &&
480
+ marker.endAmount === sold.endAmount &&
481
+ sameAddress(marker.recipient, buyer);
482
+ if (!exactMarker) {
483
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, 'its last consideration item is not the exact offered Cell delivered to the reserved buyer', request);
484
+ }
485
+ }
486
+ requireConsiderationItem(request, item, currency, expected) {
487
+ if (!sameAddress(item.token, currency)) {
488
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign pays part of the price in ${item.token} instead of the ` +
489
+ `listing currency ${currency}`, request);
490
+ }
491
+ if (item.itemType !== expected) {
492
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign pays part of the price as item type ${item.itemType} instead ` +
493
+ `of ${expected}`, request);
494
+ }
495
+ if (item.identifierOrCriteria !== LISTING_NO_IDENTIFIER) {
496
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign pays part of the price with token ` +
497
+ `${item.identifierOrCriteria} rather than a plain amount`, request);
498
+ }
499
+ if (item.startAmount !== item.endAmount) {
500
+ throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign starts a payment at ${item.startAmount} and ends it at ` +
501
+ `${item.endAmount}, so it could be filled for less than the price you set`, request);
502
+ }
503
+ }
504
+ async broadcastApprovals(prepared) {
505
+ const hashes = [];
506
+ for (const transaction of prepared.transactions) {
507
+ hashes.push(await this.broadcast(transaction));
508
+ }
509
+ return hashes;
510
+ }
511
+ async broadcast(transaction) {
512
+ const wallet = this.wallet.get();
513
+ const hash = await wallet.sendTransaction({
514
+ to: transaction.to,
515
+ data: transaction.data,
516
+ value: BigInt(transaction.value),
517
+ gas: null,
518
+ });
519
+ const receipt = await wallet.waitForReceipt(hash);
520
+ if (receipt.status !== TxStatus.Success) {
521
+ throw new MarketError({
522
+ code: MarketErrorCode.TransactionReverted,
523
+ message: `The collection approval this listing needs reverted on-chain, so the listing was never ` +
524
+ 'signed or published.',
525
+ retryable: false,
526
+ retryAfterSeconds: null,
527
+ stage: MarketActionStage.Approve,
528
+ txHash: hash,
529
+ });
530
+ }
531
+ return hash;
532
+ }
533
+ async sign(prepared) {
534
+ this.requireWithinDeadline(prepared, MarketActionStage.Sign);
535
+ return this.wallet.get().signTypedData({
536
+ domain: {
537
+ name: SEAPORT_DOMAIN_NAME,
538
+ version: SEAPORT_DOMAIN_VERSION,
539
+ chainId: prepared.chainId,
540
+ verifyingContract: prepared.protocolAddress,
541
+ },
542
+ types: SEAPORT_ORDER_COMPONENTS_TYPES,
543
+ primaryType: SEAPORT_ORDER_PRIMARY_TYPE,
544
+ message: seaportSignableOrder(prepared.order),
545
+ });
546
+ }
547
+ requireWithinDeadline(prepared, stage) {
548
+ const deadline = effectiveListingDeadline(prepared);
549
+ narrowInvocationDeadline(deadline);
550
+ if (this.nowSeconds() < deadline) {
551
+ return;
552
+ }
553
+ throw new MarketError({
554
+ code: MarketErrorCode.PreparedIntentExpired,
555
+ message: 'This prepared listing is past the earlier of its own deadline and the order expiry, so it can no ' +
556
+ 'longer be signed or published. Call the tool again to prepare a fresh listing.',
557
+ retryable: false,
558
+ retryAfterSeconds: null,
559
+ stage,
560
+ txHash: null,
561
+ });
562
+ }
563
+ requirePrepared(payload) {
564
+ if (payload.prepared === null) {
565
+ throw new MarketError({
566
+ code: MarketErrorCode.InvalidMarketResponse,
567
+ message: 'The listing has no prepared order to publish.',
568
+ retryable: false,
569
+ retryAfterSeconds: null,
570
+ stage: MarketActionStage.Submit,
571
+ txHash: null,
572
+ });
573
+ }
574
+ return payload.prepared;
575
+ }
576
+ requireUsableRequest(request) {
577
+ const tokenId = cellTokenIdSchema.safeParse(request.tokenId);
578
+ if (!tokenId.success) {
579
+ throw this.rejectedInput(`"${request.tokenId}" is not a canonical Cell token id. Pass a decimal integer with no leading ` +
580
+ 'zeroes so that one Cell keeps one identity.');
581
+ }
582
+ const price = positiveBaseUnitAmountSchema.safeParse(request.price);
583
+ if (!price.success) {
584
+ throw this.rejectedInput(`"${request.price}" is not a listing price. Pass the gross amount a buyer pays as a positive ` +
585
+ 'decimal integer of the currency base units, never a decimal fraction.');
586
+ }
587
+ const expirationTime = unixSecondsSchema.safeParse(request.expirationTime);
588
+ if (!expirationTime.success || expirationTime.data <= this.nowSeconds()) {
589
+ throw this.rejectedInput(`${request.expirationTime} is not a future expiry. Pass the Unix second at which the listing ` +
590
+ 'should stop being fillable.');
591
+ }
592
+ const buyerAddress = request.buyerAddress;
593
+ if (buyerAddress !== null && !evmAddressSchema.safeParse(buyerAddress).success) {
594
+ throw this.rejectedInput(`"${buyerAddress}" is not an address. Pass the one wallet allowed to buy this listing, or null to ` +
595
+ 'let anyone buy it.');
596
+ }
597
+ return {
598
+ tokenId: tokenId.data,
599
+ price: price.data,
600
+ expirationTime: expirationTime.data,
601
+ buyerAddress,
602
+ };
603
+ }
604
+ reserve(key, stage, payload) {
605
+ this.recovery.write(key, { tool: MarketActionTool.ListCell, stage, payload });
606
+ }
607
+ emptyPayload() {
608
+ return { prepared: null, signature: null, approvalTxHashes: [] };
609
+ }
610
+ result(status, request, payload, listing) {
611
+ const prepared = this.requirePrepared(payload);
612
+ this.logger.info('the Cell listing is published', {
613
+ tokenId: request.tokenId,
614
+ status,
615
+ orderHash: listing.orderHash,
616
+ });
617
+ return {
618
+ status,
619
+ stage: MarketActionStage.Submit,
620
+ wallet: this.walletAddress(),
621
+ tokenId: request.tokenId,
622
+ listing,
623
+ grossPrice: prepared.listing.price,
624
+ currency: prepared.listing.currency,
625
+ platformFee: prepared.fees.platformFee,
626
+ creatorFee: prepared.fees.creatorFee,
627
+ estimatedProceeds: prepared.fees.estimatedProceeds,
628
+ approvalTxHashes: [...payload.approvalTxHashes],
629
+ };
630
+ }
631
+ outcomeUnknown(request, stage) {
632
+ return new MarketError({
633
+ code: MarketErrorCode.OutcomeUnknown,
634
+ message: `The listing for Cell ${request.tokenId} was submitted but its outcome could not be confirmed, and ` +
635
+ 'the marketplace cannot be read to settle the question. The exact prepared order is kept, so ' +
636
+ 'repeating this call republishes the same order rather than creating a second one.',
637
+ retryable: true,
638
+ retryAfterSeconds: null,
639
+ stage,
640
+ txHash: null,
641
+ });
642
+ }
643
+ untrustworthy(code, detail, request) {
644
+ this.logger.error('the prepared listing does not match the request', { tokenId: request.tokenId, detail });
645
+ return new MarketError({
646
+ code,
647
+ message: `The prepared listing for Cell ${request.tokenId} cannot be signed: ${detail}.`,
648
+ retryable: false,
649
+ retryAfterSeconds: null,
650
+ stage: MarketActionStage.Prepare,
651
+ txHash: null,
652
+ });
653
+ }
654
+ rejectedInput(message) {
655
+ return new MarketError({
656
+ code: MarketErrorCode.InvalidInput,
657
+ message,
658
+ retryable: false,
659
+ retryAfterSeconds: null,
660
+ stage: MarketActionStage.Prepare,
661
+ txHash: null,
662
+ });
663
+ }
664
+ walletAddress() {
665
+ return this.wallet.get().getAddress();
666
+ }
667
+ nowSeconds() {
668
+ return Math.floor(Date.now() / MS_PER_SECOND);
669
+ }
670
+ }
671
+ //# sourceMappingURL=listing.service.js.map