mppx 0.8.15 → 0.8.18

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 (966) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +15 -0
  3. package/dist/Challenge.js +61 -39
  4. package/dist/Constants.d.ts +17 -17
  5. package/dist/Errors.d.ts +3 -3
  6. package/dist/Method.d.ts +35 -5
  7. package/dist/Method.js +7 -22
  8. package/dist/Store.d.ts +19 -0
  9. package/dist/Store.js +43 -0
  10. package/dist/attestation/Client.d.ts +17 -0
  11. package/dist/attestation/Client.js +28 -0
  12. package/dist/attestation/Constants.d.ts +15 -0
  13. package/dist/attestation/Constants.js +15 -0
  14. package/dist/attestation/Server.d.ts +4 -0
  15. package/dist/attestation/Server.js +8 -0
  16. package/dist/attestation/Types.d.ts +76 -0
  17. package/dist/attestation/Types.js +2 -0
  18. package/dist/attestation/index.d.ts +6 -0
  19. package/dist/attestation/index.js +6 -0
  20. package/dist/attestation/internal/HttpMessageSignature.d.ts +73 -0
  21. package/dist/attestation/internal/HttpMessageSignature.js +320 -0
  22. package/dist/attestation/internal/SigningContext.d.ts +4 -0
  23. package/dist/attestation/internal/SigningContext.js +11 -0
  24. package/dist/bin.js +3 -3
  25. package/dist/cli/THIRD-PARTY-LICENSES.txt +328 -0
  26. package/dist/cli/account.d.ts +14 -14
  27. package/dist/cli/cli.d.ts +6 -6
  28. package/dist/cli/cli.js +253 -1504
  29. package/dist/cli/plugins/index.js +19 -5
  30. package/dist/cli/plugins/tempo.js +7 -3
  31. package/dist/cli/sessions/Manager.js +7 -4
  32. package/dist/cli/sessions/commands.d.ts +4 -4
  33. package/dist/cli/sessions/request.d.ts +2 -0
  34. package/dist/cli/sessions/request.js +18 -0
  35. package/dist/cli/sessions/store.js +28 -14
  36. package/dist/cli/utils.d.ts +1 -1
  37. package/dist/cli/validate/index.d.ts +3 -3
  38. package/dist/client/Mppx.d.ts +3 -0
  39. package/dist/client/Mppx.js +13 -5
  40. package/dist/client/Transport.d.ts +3 -5
  41. package/dist/client/Transport.js +1 -17
  42. package/dist/client/internal/Fetch.js +2 -6
  43. package/dist/discovery/Discovery.js +2 -1
  44. package/dist/discovery/OpenApi.d.ts +3 -5
  45. package/dist/discovery/OpenApi.js +13 -34
  46. package/dist/discovery/internal/Metadata.d.ts +20 -0
  47. package/dist/discovery/internal/Metadata.js +36 -0
  48. package/dist/evm/Methods.d.ts +11 -11
  49. package/dist/evm/Types.d.ts +17 -17
  50. package/dist/evm/client/Charge.d.ts +11 -11
  51. package/dist/evm/client/Charge.js +8 -0
  52. package/dist/evm/client/Methods.d.ts +11 -11
  53. package/dist/evm/server/Charge.d.ts +1 -1
  54. package/dist/evm/server/Charge.js +2 -0
  55. package/dist/evm/server/Methods.d.ts +11 -11
  56. package/dist/internal/HeaderCodec.d.ts +2 -2
  57. package/dist/internal/types.d.ts +6 -0
  58. package/dist/proxy/Proxy.d.ts +2 -0
  59. package/dist/proxy/Proxy.js +117 -9
  60. package/dist/proxy/Service.d.ts +36 -1
  61. package/dist/proxy/Service.js +9 -8
  62. package/dist/proxy/services/anthropic.js +1 -0
  63. package/dist/proxy/services/openai.js +1 -0
  64. package/dist/proxy/services/stripe.js +1 -0
  65. package/dist/server/Mppx.d.ts +75 -13
  66. package/dist/server/Mppx.js +201 -23
  67. package/dist/server/core.d.ts +9 -0
  68. package/dist/server/core.js +9 -0
  69. package/dist/server/internal/html/config.d.ts +9 -9
  70. package/dist/server/internal/html/constants.d.ts +17 -17
  71. package/dist/stripe/Methods.d.ts +10 -10
  72. package/dist/stripe/client/Charge.d.ts +10 -10
  73. package/dist/stripe/client/Methods.d.ts +10 -10
  74. package/dist/stripe/internal/constants.d.ts +1 -1
  75. package/dist/stripe/internal/constants.js +1 -1
  76. package/dist/stripe/internal/types.d.ts +1 -0
  77. package/dist/stripe/server/Charge.d.ts +11 -11
  78. package/dist/stripe/server/Charge.js +51 -5
  79. package/dist/stripe/server/Methods.d.ts +137 -48
  80. package/dist/stripe/server/Methods.js +265 -4
  81. package/dist/stripe/server/internal/deposit-address.d.ts +13 -0
  82. package/dist/stripe/server/internal/deposit-address.js +28 -0
  83. package/dist/stripe/server/internal/html.gen.d.ts +1 -1
  84. package/dist/stripe/server/internal/html.gen.js +1 -1
  85. package/dist/stripe/server/internal/record-payment.d.ts +15 -0
  86. package/dist/stripe/server/internal/record-payment.js +42 -0
  87. package/dist/stripe/server/internal/request.d.ts +25 -0
  88. package/dist/stripe/server/internal/request.js +29 -0
  89. package/dist/stripe/server/spt.d.ts +8 -0
  90. package/dist/stripe/server/spt.js +8 -0
  91. package/dist/tap/Constants.d.ts +28 -0
  92. package/dist/tap/Constants.js +32 -0
  93. package/dist/tap/Types.d.ts +11 -0
  94. package/dist/tap/Types.js +2 -0
  95. package/dist/tap/client/index.d.ts +26 -0
  96. package/dist/tap/client/index.js +33 -0
  97. package/dist/tap/index.d.ts +5 -0
  98. package/dist/tap/index.js +5 -0
  99. package/dist/tap/server/index.d.ts +20 -0
  100. package/dist/tap/server/index.js +36 -0
  101. package/dist/tempo/Attribution.d.ts +1 -1
  102. package/dist/tempo/Methods.d.ts +73 -60
  103. package/dist/tempo/Methods.js +14 -3
  104. package/dist/tempo/Proof.d.ts +16 -16
  105. package/dist/tempo/client/Charge.d.ts +22 -19
  106. package/dist/tempo/client/Charge.js +32 -16
  107. package/dist/tempo/client/Methods.d.ts +51 -38
  108. package/dist/tempo/client/Subscription.d.ts +23 -23
  109. package/dist/tempo/internal/address.d.ts +2 -1
  110. package/dist/tempo/internal/address.js +3 -1
  111. package/dist/tempo/internal/auto-swap.js +4 -19
  112. package/dist/tempo/internal/defaults.d.ts +17 -6
  113. package/dist/tempo/internal/defaults.js +11 -0
  114. package/dist/tempo/internal/fee-payer.d.ts +12 -12
  115. package/dist/tempo/internal/machine-token-charge.d.ts +51 -0
  116. package/dist/tempo/internal/machine-token-charge.js +113 -0
  117. package/dist/tempo/internal/machine-token-session.d.ts +88 -0
  118. package/dist/tempo/internal/machine-token-session.js +173 -0
  119. package/dist/tempo/internal/proof.d.ts +17 -17
  120. package/dist/tempo/internal/signature-envelope.d.ts +14 -0
  121. package/dist/tempo/internal/signature-envelope.js +28 -0
  122. package/dist/tempo/legacy/client/ChannelOps.d.ts +2 -2
  123. package/dist/tempo/legacy/client/ChannelOps.js +11 -5
  124. package/dist/tempo/legacy/client/Session.d.ts +33 -21
  125. package/dist/tempo/legacy/client/Session.js +3 -3
  126. package/dist/tempo/legacy/client/SessionManager.d.ts +3 -1
  127. package/dist/tempo/legacy/client/SessionManager.js +2 -0
  128. package/dist/tempo/legacy/index.d.ts +1 -3
  129. package/dist/tempo/legacy/index.js +1 -3
  130. package/dist/tempo/legacy/session/escrow.abi.d.ts +374 -374
  131. package/dist/tempo/server/Charge.d.ts +28 -11
  132. package/dist/tempo/server/Charge.js +101 -55
  133. package/dist/tempo/server/Methods.d.ts +58 -56
  134. package/dist/tempo/server/Methods.js +8 -18
  135. package/dist/tempo/server/Relay.d.ts +1 -1
  136. package/dist/tempo/server/Relay.js +2 -2
  137. package/dist/tempo/server/Subscription.d.ts +25 -25
  138. package/dist/tempo/server/Subscription.js +2 -0
  139. package/dist/tempo/server/index.d.ts +1 -1
  140. package/dist/tempo/server/index.js +1 -1
  141. package/dist/tempo/server/internal/html.gen.d.ts +1 -1
  142. package/dist/tempo/server/internal/html.gen.js +1 -1
  143. package/dist/tempo/server/internal/transport.d.ts +2 -0
  144. package/dist/tempo/server/internal/transport.js +9 -2
  145. package/dist/tempo/session/client/ChannelOps.d.ts +18 -3
  146. package/dist/tempo/session/client/ChannelOps.js +35 -6
  147. package/dist/tempo/session/client/ChannelStore.d.ts +0 -5
  148. package/dist/tempo/session/client/ChannelStore.js +2 -2
  149. package/dist/tempo/session/client/CredentialState.d.ts +18 -3
  150. package/dist/tempo/session/client/CredentialState.js +77 -76
  151. package/dist/tempo/session/client/Runtime.d.ts +4 -2
  152. package/dist/tempo/session/client/Runtime.js +21 -5
  153. package/dist/tempo/session/client/Session.d.ts +34 -22
  154. package/dist/tempo/session/client/Session.js +186 -63
  155. package/dist/tempo/session/client/SessionManager.d.ts +3 -1
  156. package/dist/tempo/session/client/SessionManager.js +35 -11
  157. package/dist/tempo/session/client/Transports.d.ts +2 -0
  158. package/dist/tempo/session/client/Transports.js +12 -2
  159. package/dist/tempo/session/precompile/Chain.d.ts +37 -2
  160. package/dist/tempo/session/precompile/Chain.js +116 -15
  161. package/dist/tempo/session/precompile/Protocol.d.ts +15 -0
  162. package/dist/tempo/session/precompile/Protocol.js +7 -0
  163. package/dist/tempo/session/precompile/Voucher.d.ts +7 -5
  164. package/dist/tempo/session/precompile/Voucher.js +6 -12
  165. package/dist/tempo/session/precompile/escrow.abi.d.ts +306 -306
  166. package/dist/tempo/session/server/ChannelStore.d.ts +15 -0
  167. package/dist/tempo/session/server/ChannelStore.js +27 -12
  168. package/dist/tempo/session/server/CredentialVerification.d.ts +39 -20
  169. package/dist/tempo/session/server/CredentialVerification.js +359 -89
  170. package/dist/tempo/session/server/MeteredStream.d.ts +4 -1
  171. package/dist/tempo/session/server/MeteredStream.js +8 -5
  172. package/dist/tempo/session/server/RequestState.d.ts +19 -0
  173. package/dist/tempo/session/server/RequestState.js +61 -15
  174. package/dist/tempo/session/server/Session.d.ts +46 -23
  175. package/dist/tempo/session/server/Session.js +150 -56
  176. package/dist/tempo/session/server/Settlement.d.ts +11 -4
  177. package/dist/tempo/session/server/Settlement.js +53 -21
  178. package/dist/tempo/session/server/Sse.d.ts +3 -1
  179. package/dist/tempo/session/server/Sse.js +2 -1
  180. package/dist/tempo/session/server/Transports.d.ts +1 -1
  181. package/dist/tempo/session/server/Transports.js +1 -0
  182. package/dist/tempo/session/server/Ws.d.ts +6 -1
  183. package/dist/tempo/session/server/Ws.js +1 -0
  184. package/dist/tempo/subscription/KeyAuthorization.d.ts +39 -39
  185. package/dist/web-bot-auth/Constants.d.ts +20 -0
  186. package/dist/web-bot-auth/Constants.js +24 -0
  187. package/dist/web-bot-auth/Types.d.ts +10 -0
  188. package/dist/web-bot-auth/Types.js +2 -0
  189. package/dist/web-bot-auth/client/index.d.ts +29 -0
  190. package/dist/web-bot-auth/client/index.js +64 -0
  191. package/dist/web-bot-auth/index.d.ts +7 -0
  192. package/dist/web-bot-auth/index.js +7 -0
  193. package/dist/web-bot-auth/internal/JwkThumbprint.d.ts +5 -0
  194. package/dist/web-bot-auth/internal/JwkThumbprint.js +20 -0
  195. package/dist/web-bot-auth/internal/SignatureAgent.d.ts +3 -0
  196. package/dist/web-bot-auth/internal/SignatureAgent.js +18 -0
  197. package/dist/web-bot-auth/server/index.d.ts +35 -0
  198. package/dist/web-bot-auth/server/index.js +88 -0
  199. package/dist/x402/Types.d.ts +6 -6
  200. package/dist/x402/client/Exact.d.ts +8 -0
  201. package/dist/x402/client/Exact.js +40 -10
  202. package/dist/x402/server/EvmCharge.d.ts +22 -0
  203. package/dist/x402/server/EvmCharge.js +54 -20
  204. package/package.json +28 -34
  205. package/dist/BodyDigest.d.ts.map +0 -1
  206. package/dist/BodyDigest.js.map +0 -1
  207. package/dist/Challenge.d.ts.map +0 -1
  208. package/dist/Challenge.js.map +0 -1
  209. package/dist/Constants.d.ts.map +0 -1
  210. package/dist/Constants.js.map +0 -1
  211. package/dist/Credential.d.ts.map +0 -1
  212. package/dist/Credential.js.map +0 -1
  213. package/dist/Errors.d.ts.map +0 -1
  214. package/dist/Errors.js.map +0 -1
  215. package/dist/Expires.d.ts.map +0 -1
  216. package/dist/Expires.js.map +0 -1
  217. package/dist/Html.d.ts.map +0 -1
  218. package/dist/Html.js.map +0 -1
  219. package/dist/Mcp.d.ts.map +0 -1
  220. package/dist/Mcp.js.map +0 -1
  221. package/dist/Method.d.ts.map +0 -1
  222. package/dist/Method.js.map +0 -1
  223. package/dist/PaymentRequest.d.ts.map +0 -1
  224. package/dist/PaymentRequest.js.map +0 -1
  225. package/dist/Receipt.d.ts.map +0 -1
  226. package/dist/Receipt.js.map +0 -1
  227. package/dist/Store.d.ts.map +0 -1
  228. package/dist/Store.js.map +0 -1
  229. package/dist/bin.d.ts.map +0 -1
  230. package/dist/bin.js.map +0 -1
  231. package/dist/cli/account.d.ts.map +0 -1
  232. package/dist/cli/account.js.map +0 -1
  233. package/dist/cli/cli.d.ts.map +0 -1
  234. package/dist/cli/cli.js.map +0 -1
  235. package/dist/cli/config.d.ts.map +0 -1
  236. package/dist/cli/config.js.map +0 -1
  237. package/dist/cli/internal.d.ts.map +0 -1
  238. package/dist/cli/internal.js.map +0 -1
  239. package/dist/cli/plugins/evm.d.ts.map +0 -1
  240. package/dist/cli/plugins/evm.js.map +0 -1
  241. package/dist/cli/plugins/index.d.ts.map +0 -1
  242. package/dist/cli/plugins/index.js.map +0 -1
  243. package/dist/cli/plugins/plugin.d.ts.map +0 -1
  244. package/dist/cli/plugins/plugin.js.map +0 -1
  245. package/dist/cli/plugins/stripe.d.ts.map +0 -1
  246. package/dist/cli/plugins/stripe.js.map +0 -1
  247. package/dist/cli/plugins/tempo.d.ts.map +0 -1
  248. package/dist/cli/plugins/tempo.js.map +0 -1
  249. package/dist/cli/sessions/Manager.d.ts.map +0 -1
  250. package/dist/cli/sessions/Manager.js.map +0 -1
  251. package/dist/cli/sessions/commands.d.ts.map +0 -1
  252. package/dist/cli/sessions/commands.js.map +0 -1
  253. package/dist/cli/sessions/request.d.ts.map +0 -1
  254. package/dist/cli/sessions/request.js.map +0 -1
  255. package/dist/cli/sessions/store.d.ts.map +0 -1
  256. package/dist/cli/sessions/store.js.map +0 -1
  257. package/dist/cli/utils.d.ts.map +0 -1
  258. package/dist/cli/utils.js.map +0 -1
  259. package/dist/cli/validate/challenge.d.ts.map +0 -1
  260. package/dist/cli/validate/challenge.js.map +0 -1
  261. package/dist/cli/validate/discovery.d.ts.map +0 -1
  262. package/dist/cli/validate/discovery.js.map +0 -1
  263. package/dist/cli/validate/helpers.d.ts.map +0 -1
  264. package/dist/cli/validate/helpers.js.map +0 -1
  265. package/dist/cli/validate/index.d.ts.map +0 -1
  266. package/dist/cli/validate/index.js.map +0 -1
  267. package/dist/cli/validate/messages.d.ts.map +0 -1
  268. package/dist/cli/validate/messages.js.map +0 -1
  269. package/dist/cli/validate/payment.d.ts.map +0 -1
  270. package/dist/cli/validate/payment.js.map +0 -1
  271. package/dist/client/Methods.d.ts.map +0 -1
  272. package/dist/client/Methods.js.map +0 -1
  273. package/dist/client/Mppx.d.ts.map +0 -1
  274. package/dist/client/Mppx.js.map +0 -1
  275. package/dist/client/Transport.d.ts.map +0 -1
  276. package/dist/client/Transport.js.map +0 -1
  277. package/dist/client/index.d.ts.map +0 -1
  278. package/dist/client/index.js.map +0 -1
  279. package/dist/client/internal/Fetch.d.ts.map +0 -1
  280. package/dist/client/internal/Fetch.js.map +0 -1
  281. package/dist/client/internal/MethodChallenge.d.ts.map +0 -1
  282. package/dist/client/internal/MethodChallenge.js.map +0 -1
  283. package/dist/client/internal/MethodResponse.d.ts.map +0 -1
  284. package/dist/client/internal/MethodResponse.js.map +0 -1
  285. package/dist/client/internal/protocols/Mcp.d.ts.map +0 -1
  286. package/dist/client/internal/protocols/Mcp.js.map +0 -1
  287. package/dist/client/internal/protocols/Mpp.d.ts.map +0 -1
  288. package/dist/client/internal/protocols/Mpp.js.map +0 -1
  289. package/dist/client/internal/protocols/Protocol.d.ts.map +0 -1
  290. package/dist/client/internal/protocols/Protocol.js.map +0 -1
  291. package/dist/client/internal/protocols/Shared.d.ts.map +0 -1
  292. package/dist/client/internal/protocols/Shared.js.map +0 -1
  293. package/dist/client/internal/protocols/X402.d.ts.map +0 -1
  294. package/dist/client/internal/protocols/X402.js.map +0 -1
  295. package/dist/client/node.d.ts.map +0 -1
  296. package/dist/client/node.js.map +0 -1
  297. package/dist/discovery/Discovery.d.ts.map +0 -1
  298. package/dist/discovery/Discovery.js.map +0 -1
  299. package/dist/discovery/OpenApi.d.ts.map +0 -1
  300. package/dist/discovery/OpenApi.js.map +0 -1
  301. package/dist/discovery/Validate.d.ts.map +0 -1
  302. package/dist/discovery/Validate.js.map +0 -1
  303. package/dist/discovery/index.d.ts.map +0 -1
  304. package/dist/discovery/index.js.map +0 -1
  305. package/dist/evm/Assets.d.ts.map +0 -1
  306. package/dist/evm/Assets.js.map +0 -1
  307. package/dist/evm/Chains.d.ts.map +0 -1
  308. package/dist/evm/Chains.js.map +0 -1
  309. package/dist/evm/Methods.d.ts.map +0 -1
  310. package/dist/evm/Methods.js.map +0 -1
  311. package/dist/evm/Types.d.ts.map +0 -1
  312. package/dist/evm/Types.js.map +0 -1
  313. package/dist/evm/client/Charge.d.ts.map +0 -1
  314. package/dist/evm/client/Charge.js.map +0 -1
  315. package/dist/evm/client/Methods.d.ts.map +0 -1
  316. package/dist/evm/client/Methods.js.map +0 -1
  317. package/dist/evm/client/index.d.ts.map +0 -1
  318. package/dist/evm/client/index.js.map +0 -1
  319. package/dist/evm/index.d.ts.map +0 -1
  320. package/dist/evm/index.js.map +0 -1
  321. package/dist/evm/server/Charge.d.ts.map +0 -1
  322. package/dist/evm/server/Charge.js.map +0 -1
  323. package/dist/evm/server/Methods.d.ts.map +0 -1
  324. package/dist/evm/server/Methods.js.map +0 -1
  325. package/dist/evm/server/index.d.ts.map +0 -1
  326. package/dist/evm/server/index.js.map +0 -1
  327. package/dist/index.d.ts.map +0 -1
  328. package/dist/index.js.map +0 -1
  329. package/dist/internal/AcceptPayment.d.ts.map +0 -1
  330. package/dist/internal/AcceptPayment.js.map +0 -1
  331. package/dist/internal/HeaderCodec.d.ts.map +0 -1
  332. package/dist/internal/HeaderCodec.js.map +0 -1
  333. package/dist/internal/constantTimeEqual.d.ts.map +0 -1
  334. package/dist/internal/constantTimeEqual.js.map +0 -1
  335. package/dist/internal/env.d.ts.map +0 -1
  336. package/dist/internal/env.js.map +0 -1
  337. package/dist/internal/types.d.ts.map +0 -1
  338. package/dist/internal/types.js.map +0 -1
  339. package/dist/mcp/client/McpClient.d.ts.map +0 -1
  340. package/dist/mcp/client/McpClient.js.map +0 -1
  341. package/dist/mcp/client/index.d.ts.map +0 -1
  342. package/dist/mcp/client/index.js.map +0 -1
  343. package/dist/mcp/server/Transport.d.ts.map +0 -1
  344. package/dist/mcp/server/Transport.js.map +0 -1
  345. package/dist/mcp/server/index.d.ts.map +0 -1
  346. package/dist/mcp/server/index.js.map +0 -1
  347. package/dist/middlewares/elysia.d.ts.map +0 -1
  348. package/dist/middlewares/elysia.js.map +0 -1
  349. package/dist/middlewares/express.d.ts.map +0 -1
  350. package/dist/middlewares/express.js.map +0 -1
  351. package/dist/middlewares/hono.d.ts.map +0 -1
  352. package/dist/middlewares/hono.js.map +0 -1
  353. package/dist/middlewares/internal/mppx.d.ts.map +0 -1
  354. package/dist/middlewares/internal/mppx.js.map +0 -1
  355. package/dist/middlewares/nextjs.d.ts.map +0 -1
  356. package/dist/middlewares/nextjs.js.map +0 -1
  357. package/dist/proxy/Proxy.d.ts.map +0 -1
  358. package/dist/proxy/Proxy.js.map +0 -1
  359. package/dist/proxy/Service.d.ts.map +0 -1
  360. package/dist/proxy/Service.js.map +0 -1
  361. package/dist/proxy/index.d.ts.map +0 -1
  362. package/dist/proxy/index.js.map +0 -1
  363. package/dist/proxy/internal/Headers.d.ts.map +0 -1
  364. package/dist/proxy/internal/Headers.js.map +0 -1
  365. package/dist/proxy/internal/Route.d.ts.map +0 -1
  366. package/dist/proxy/internal/Route.js.map +0 -1
  367. package/dist/proxy/services/anthropic.d.ts.map +0 -1
  368. package/dist/proxy/services/anthropic.js.map +0 -1
  369. package/dist/proxy/services/openai.d.ts.map +0 -1
  370. package/dist/proxy/services/openai.js.map +0 -1
  371. package/dist/proxy/services/stripe.d.ts.map +0 -1
  372. package/dist/proxy/services/stripe.js.map +0 -1
  373. package/dist/server/Methods.d.ts.map +0 -1
  374. package/dist/server/Methods.js.map +0 -1
  375. package/dist/server/Mppx.d.ts.map +0 -1
  376. package/dist/server/Mppx.js.map +0 -1
  377. package/dist/server/NodeListener.d.ts.map +0 -1
  378. package/dist/server/NodeListener.js.map +0 -1
  379. package/dist/server/Request.d.ts.map +0 -1
  380. package/dist/server/Request.js.map +0 -1
  381. package/dist/server/Response.d.ts.map +0 -1
  382. package/dist/server/Response.js.map +0 -1
  383. package/dist/server/Transport.d.ts.map +0 -1
  384. package/dist/server/Transport.js.map +0 -1
  385. package/dist/server/index.d.ts.map +0 -1
  386. package/dist/server/index.js.map +0 -1
  387. package/dist/server/internal/html/compose.main.gen.d.ts.map +0 -1
  388. package/dist/server/internal/html/compose.main.gen.js.map +0 -1
  389. package/dist/server/internal/html/config.d.ts.map +0 -1
  390. package/dist/server/internal/html/config.js.map +0 -1
  391. package/dist/server/internal/html/constants.d.ts.map +0 -1
  392. package/dist/server/internal/html/constants.js.map +0 -1
  393. package/dist/server/internal/html/serviceWorker.client.d.ts.map +0 -1
  394. package/dist/server/internal/html/serviceWorker.client.js.map +0 -1
  395. package/dist/server/internal/html/serviceWorker.gen.d.ts.map +0 -1
  396. package/dist/server/internal/html/serviceWorker.gen.js.map +0 -1
  397. package/dist/server/internal/scope.d.ts.map +0 -1
  398. package/dist/server/internal/scope.js.map +0 -1
  399. package/dist/stripe/Methods.d.ts.map +0 -1
  400. package/dist/stripe/Methods.js.map +0 -1
  401. package/dist/stripe/client/Charge.d.ts.map +0 -1
  402. package/dist/stripe/client/Charge.js.map +0 -1
  403. package/dist/stripe/client/Methods.d.ts.map +0 -1
  404. package/dist/stripe/client/Methods.js.map +0 -1
  405. package/dist/stripe/client/index.d.ts.map +0 -1
  406. package/dist/stripe/client/index.js.map +0 -1
  407. package/dist/stripe/index.d.ts.map +0 -1
  408. package/dist/stripe/index.js.map +0 -1
  409. package/dist/stripe/internal/constants.d.ts.map +0 -1
  410. package/dist/stripe/internal/constants.js.map +0 -1
  411. package/dist/stripe/internal/types.d.ts.map +0 -1
  412. package/dist/stripe/internal/types.js.map +0 -1
  413. package/dist/stripe/server/Charge.d.ts.map +0 -1
  414. package/dist/stripe/server/Charge.js.map +0 -1
  415. package/dist/stripe/server/Methods.d.ts.map +0 -1
  416. package/dist/stripe/server/Methods.js.map +0 -1
  417. package/dist/stripe/server/index.d.ts.map +0 -1
  418. package/dist/stripe/server/index.js.map +0 -1
  419. package/dist/stripe/server/internal/html/types.d.ts.map +0 -1
  420. package/dist/stripe/server/internal/html/types.js.map +0 -1
  421. package/dist/stripe/server/internal/html.gen.d.ts.map +0 -1
  422. package/dist/stripe/server/internal/html.gen.js.map +0 -1
  423. package/dist/tempo/Attribution.d.ts.map +0 -1
  424. package/dist/tempo/Attribution.js.map +0 -1
  425. package/dist/tempo/Methods.d.ts.map +0 -1
  426. package/dist/tempo/Methods.js.map +0 -1
  427. package/dist/tempo/Proof.d.ts.map +0 -1
  428. package/dist/tempo/Proof.js.map +0 -1
  429. package/dist/tempo/client/Charge.d.ts.map +0 -1
  430. package/dist/tempo/client/Charge.js.map +0 -1
  431. package/dist/tempo/client/Methods.d.ts.map +0 -1
  432. package/dist/tempo/client/Methods.js.map +0 -1
  433. package/dist/tempo/client/ResolveAccount.d.ts.map +0 -1
  434. package/dist/tempo/client/ResolveAccount.js.map +0 -1
  435. package/dist/tempo/client/Subscription.d.ts.map +0 -1
  436. package/dist/tempo/client/Subscription.js.map +0 -1
  437. package/dist/tempo/client/index.d.ts.map +0 -1
  438. package/dist/tempo/client/index.js.map +0 -1
  439. package/dist/tempo/index.d.ts.map +0 -1
  440. package/dist/tempo/index.js.map +0 -1
  441. package/dist/tempo/internal/account.d.ts.map +0 -1
  442. package/dist/tempo/internal/account.js.map +0 -1
  443. package/dist/tempo/internal/address.d.ts.map +0 -1
  444. package/dist/tempo/internal/address.js.map +0 -1
  445. package/dist/tempo/internal/auto-swap.d.ts.map +0 -1
  446. package/dist/tempo/internal/auto-swap.js.map +0 -1
  447. package/dist/tempo/internal/charge.d.ts.map +0 -1
  448. package/dist/tempo/internal/charge.js.map +0 -1
  449. package/dist/tempo/internal/defaults.d.ts.map +0 -1
  450. package/dist/tempo/internal/defaults.js.map +0 -1
  451. package/dist/tempo/internal/fee-payer.d.ts.map +0 -1
  452. package/dist/tempo/internal/fee-payer.js.map +0 -1
  453. package/dist/tempo/internal/fee-token.d.ts.map +0 -1
  454. package/dist/tempo/internal/fee-token.js.map +0 -1
  455. package/dist/tempo/internal/proof.d.ts.map +0 -1
  456. package/dist/tempo/internal/proof.js.map +0 -1
  457. package/dist/tempo/internal/selectors.d.ts.map +0 -1
  458. package/dist/tempo/internal/selectors.js.map +0 -1
  459. package/dist/tempo/internal/types.d.ts.map +0 -1
  460. package/dist/tempo/internal/types.js.map +0 -1
  461. package/dist/tempo/legacy/client/ChannelOps.d.ts.map +0 -1
  462. package/dist/tempo/legacy/client/ChannelOps.js.map +0 -1
  463. package/dist/tempo/legacy/client/Session.d.ts.map +0 -1
  464. package/dist/tempo/legacy/client/Session.js.map +0 -1
  465. package/dist/tempo/legacy/client/SessionManager.d.ts.map +0 -1
  466. package/dist/tempo/legacy/client/SessionManager.js.map +0 -1
  467. package/dist/tempo/legacy/client/index.d.ts.map +0 -1
  468. package/dist/tempo/legacy/client/index.js.map +0 -1
  469. package/dist/tempo/legacy/index.d.ts.map +0 -1
  470. package/dist/tempo/legacy/index.js.map +0 -1
  471. package/dist/tempo/legacy/server/Session.d.ts +0 -208
  472. package/dist/tempo/legacy/server/Session.d.ts.map +0 -1
  473. package/dist/tempo/legacy/server/Session.js +0 -698
  474. package/dist/tempo/legacy/server/Session.js.map +0 -1
  475. package/dist/tempo/legacy/server/index.d.ts +0 -5
  476. package/dist/tempo/legacy/server/index.d.ts.map +0 -1
  477. package/dist/tempo/legacy/server/index.js +0 -5
  478. package/dist/tempo/legacy/server/index.js.map +0 -1
  479. package/dist/tempo/legacy/session/Chain.d.ts.map +0 -1
  480. package/dist/tempo/legacy/session/Chain.js.map +0 -1
  481. package/dist/tempo/legacy/session/Channel.d.ts.map +0 -1
  482. package/dist/tempo/legacy/session/Channel.js.map +0 -1
  483. package/dist/tempo/legacy/session/ChannelStore.d.ts +0 -22
  484. package/dist/tempo/legacy/session/ChannelStore.d.ts.map +0 -1
  485. package/dist/tempo/legacy/session/ChannelStore.js +0 -6
  486. package/dist/tempo/legacy/session/ChannelStore.js.map +0 -1
  487. package/dist/tempo/legacy/session/Types.d.ts.map +0 -1
  488. package/dist/tempo/legacy/session/Types.js.map +0 -1
  489. package/dist/tempo/legacy/session/Voucher.d.ts.map +0 -1
  490. package/dist/tempo/legacy/session/Voucher.js.map +0 -1
  491. package/dist/tempo/legacy/session/escrow.abi.d.ts.map +0 -1
  492. package/dist/tempo/legacy/session/escrow.abi.js.map +0 -1
  493. package/dist/tempo/legacy/session/index.d.ts.map +0 -1
  494. package/dist/tempo/legacy/session/index.js.map +0 -1
  495. package/dist/tempo/server/Charge.d.ts.map +0 -1
  496. package/dist/tempo/server/Charge.js.map +0 -1
  497. package/dist/tempo/server/Methods.d.ts.map +0 -1
  498. package/dist/tempo/server/Methods.js.map +0 -1
  499. package/dist/tempo/server/Relay.d.ts.map +0 -1
  500. package/dist/tempo/server/Relay.js.map +0 -1
  501. package/dist/tempo/server/SponsorBudget.d.ts.map +0 -1
  502. package/dist/tempo/server/SponsorBudget.js.map +0 -1
  503. package/dist/tempo/server/Subscription.d.ts.map +0 -1
  504. package/dist/tempo/server/Subscription.js.map +0 -1
  505. package/dist/tempo/server/index.d.ts.map +0 -1
  506. package/dist/tempo/server/index.js.map +0 -1
  507. package/dist/tempo/server/internal/html.gen.d.ts.map +0 -1
  508. package/dist/tempo/server/internal/html.gen.js.map +0 -1
  509. package/dist/tempo/server/internal/request-body.d.ts.map +0 -1
  510. package/dist/tempo/server/internal/request-body.js.map +0 -1
  511. package/dist/tempo/server/internal/transport.d.ts.map +0 -1
  512. package/dist/tempo/server/internal/transport.js.map +0 -1
  513. package/dist/tempo/session/Snapshot.d.ts.map +0 -1
  514. package/dist/tempo/session/Snapshot.js.map +0 -1
  515. package/dist/tempo/session/client/ChannelOps.d.ts.map +0 -1
  516. package/dist/tempo/session/client/ChannelOps.js.map +0 -1
  517. package/dist/tempo/session/client/ChannelStore.d.ts.map +0 -1
  518. package/dist/tempo/session/client/ChannelStore.js.map +0 -1
  519. package/dist/tempo/session/client/CredentialState.d.ts.map +0 -1
  520. package/dist/tempo/session/client/CredentialState.js.map +0 -1
  521. package/dist/tempo/session/client/ReceiptCoordinator.d.ts.map +0 -1
  522. package/dist/tempo/session/client/ReceiptCoordinator.js.map +0 -1
  523. package/dist/tempo/session/client/Runtime.d.ts.map +0 -1
  524. package/dist/tempo/session/client/Runtime.js.map +0 -1
  525. package/dist/tempo/session/client/Session.d.ts.map +0 -1
  526. package/dist/tempo/session/client/Session.js.map +0 -1
  527. package/dist/tempo/session/client/SessionManager.d.ts.map +0 -1
  528. package/dist/tempo/session/client/SessionManager.js.map +0 -1
  529. package/dist/tempo/session/client/Transports.d.ts.map +0 -1
  530. package/dist/tempo/session/client/Transports.js.map +0 -1
  531. package/dist/tempo/session/client/index.d.ts.map +0 -1
  532. package/dist/tempo/session/client/index.js.map +0 -1
  533. package/dist/tempo/session/client/internal/SessionManager.d.ts.map +0 -1
  534. package/dist/tempo/session/client/internal/SessionManager.js.map +0 -1
  535. package/dist/tempo/session/index.d.ts.map +0 -1
  536. package/dist/tempo/session/index.js.map +0 -1
  537. package/dist/tempo/session/precompile/Chain.d.ts.map +0 -1
  538. package/dist/tempo/session/precompile/Chain.js.map +0 -1
  539. package/dist/tempo/session/precompile/Channel.d.ts.map +0 -1
  540. package/dist/tempo/session/precompile/Channel.js.map +0 -1
  541. package/dist/tempo/session/precompile/Protocol.d.ts.map +0 -1
  542. package/dist/tempo/session/precompile/Protocol.js.map +0 -1
  543. package/dist/tempo/session/precompile/Voucher.d.ts.map +0 -1
  544. package/dist/tempo/session/precompile/Voucher.js.map +0 -1
  545. package/dist/tempo/session/precompile/escrow.abi.d.ts.map +0 -1
  546. package/dist/tempo/session/precompile/escrow.abi.js.map +0 -1
  547. package/dist/tempo/session/precompile/index.d.ts.map +0 -1
  548. package/dist/tempo/session/precompile/index.js.map +0 -1
  549. package/dist/tempo/session/server/ChannelOps.d.ts.map +0 -1
  550. package/dist/tempo/session/server/ChannelOps.js.map +0 -1
  551. package/dist/tempo/session/server/ChannelStore.d.ts.map +0 -1
  552. package/dist/tempo/session/server/ChannelStore.js.map +0 -1
  553. package/dist/tempo/session/server/CredentialVerification.d.ts.map +0 -1
  554. package/dist/tempo/session/server/CredentialVerification.js.map +0 -1
  555. package/dist/tempo/session/server/MeteredStream.d.ts.map +0 -1
  556. package/dist/tempo/session/server/MeteredStream.js.map +0 -1
  557. package/dist/tempo/session/server/RequestState.d.ts.map +0 -1
  558. package/dist/tempo/session/server/RequestState.js.map +0 -1
  559. package/dist/tempo/session/server/Session.d.ts.map +0 -1
  560. package/dist/tempo/session/server/Session.js.map +0 -1
  561. package/dist/tempo/session/server/Settlement.d.ts.map +0 -1
  562. package/dist/tempo/session/server/Settlement.js.map +0 -1
  563. package/dist/tempo/session/server/Sse.d.ts.map +0 -1
  564. package/dist/tempo/session/server/Sse.js.map +0 -1
  565. package/dist/tempo/session/server/Transports.d.ts.map +0 -1
  566. package/dist/tempo/session/server/Transports.js.map +0 -1
  567. package/dist/tempo/session/server/Ws.d.ts.map +0 -1
  568. package/dist/tempo/session/server/Ws.js.map +0 -1
  569. package/dist/tempo/session/server/index.d.ts.map +0 -1
  570. package/dist/tempo/session/server/index.js.map +0 -1
  571. package/dist/tempo/subscription/KeyAuthorization.d.ts.map +0 -1
  572. package/dist/tempo/subscription/KeyAuthorization.js.map +0 -1
  573. package/dist/tempo/subscription/Receipt.d.ts.map +0 -1
  574. package/dist/tempo/subscription/Receipt.js.map +0 -1
  575. package/dist/tempo/subscription/Store.d.ts.map +0 -1
  576. package/dist/tempo/subscription/Store.js.map +0 -1
  577. package/dist/tempo/subscription/Types.d.ts.map +0 -1
  578. package/dist/tempo/subscription/Types.js.map +0 -1
  579. package/dist/tempo/subscription/index.d.ts.map +0 -1
  580. package/dist/tempo/subscription/index.js.map +0 -1
  581. package/dist/validation/core.d.ts.map +0 -1
  582. package/dist/validation/core.js.map +0 -1
  583. package/dist/validation/index.d.ts.map +0 -1
  584. package/dist/validation/index.js.map +0 -1
  585. package/dist/viem/Account.d.ts.map +0 -1
  586. package/dist/viem/Account.js.map +0 -1
  587. package/dist/viem/Client.d.ts.map +0 -1
  588. package/dist/viem/Client.js.map +0 -1
  589. package/dist/x402/Assets.d.ts.map +0 -1
  590. package/dist/x402/Assets.js.map +0 -1
  591. package/dist/x402/Header.d.ts.map +0 -1
  592. package/dist/x402/Header.js.map +0 -1
  593. package/dist/x402/Types.d.ts.map +0 -1
  594. package/dist/x402/Types.js.map +0 -1
  595. package/dist/x402/client/Exact.d.ts.map +0 -1
  596. package/dist/x402/client/Exact.js.map +0 -1
  597. package/dist/x402/index.d.ts.map +0 -1
  598. package/dist/x402/index.js.map +0 -1
  599. package/dist/x402/internal/ChallengeBrand.d.ts.map +0 -1
  600. package/dist/x402/internal/ChallengeBrand.js.map +0 -1
  601. package/dist/x402/internal/RouteBinding.d.ts.map +0 -1
  602. package/dist/x402/internal/RouteBinding.js.map +0 -1
  603. package/dist/x402/server/EvmCharge.d.ts.map +0 -1
  604. package/dist/x402/server/EvmCharge.js.map +0 -1
  605. package/dist/x402/server/Facilitator.d.ts.map +0 -1
  606. package/dist/x402/server/Facilitator.js.map +0 -1
  607. package/dist/zod.d.ts.map +0 -1
  608. package/dist/zod.js.map +0 -1
  609. package/src/BodyDigest.test.ts +0 -43
  610. package/src/BodyDigest.ts +0 -55
  611. package/src/Challenge.fuzz.test.ts +0 -121
  612. package/src/Challenge.test-d.ts +0 -82
  613. package/src/Challenge.test.ts +0 -995
  614. package/src/Challenge.ts +0 -683
  615. package/src/Constants.ts +0 -58
  616. package/src/Credential.fuzz.test.ts +0 -62
  617. package/src/Credential.test.ts +0 -378
  618. package/src/Credential.ts +0 -217
  619. package/src/Errors.test.ts +0 -520
  620. package/src/Errors.ts +0 -448
  621. package/src/Expires.test.ts +0 -112
  622. package/src/Expires.ts +0 -59
  623. package/src/Html.ts +0 -67
  624. package/src/Mcp.ts +0 -85
  625. package/src/Method.test.ts +0 -177
  626. package/src/Method.ts +0 -617
  627. package/src/PaymentRequest.test.ts +0 -147
  628. package/src/PaymentRequest.ts +0 -108
  629. package/src/Receipt.test.ts +0 -151
  630. package/src/Receipt.ts +0 -146
  631. package/src/Store.test-d.ts +0 -195
  632. package/src/Store.test.ts +0 -357
  633. package/src/Store.ts +0 -329
  634. package/src/bin.ts +0 -4
  635. package/src/cli/account.ts +0 -269
  636. package/src/cli/cli.test.ts +0 -2221
  637. package/src/cli/cli.ts +0 -1649
  638. package/src/cli/config.test.ts +0 -89
  639. package/src/cli/config.ts +0 -50
  640. package/src/cli/internal.ts +0 -114
  641. package/src/cli/mcp.test.ts +0 -262
  642. package/src/cli/plugins/evm.ts +0 -55
  643. package/src/cli/plugins/index.ts +0 -4
  644. package/src/cli/plugins/plugin.ts +0 -84
  645. package/src/cli/plugins/stripe.ts +0 -174
  646. package/src/cli/plugins/tempo.ts +0 -1102
  647. package/src/cli/sessions/Manager.test.ts +0 -249
  648. package/src/cli/sessions/Manager.ts +0 -93
  649. package/src/cli/sessions/commands.ts +0 -444
  650. package/src/cli/sessions/request.test.ts +0 -51
  651. package/src/cli/sessions/request.ts +0 -353
  652. package/src/cli/sessions/store.test.ts +0 -581
  653. package/src/cli/sessions/store.ts +0 -940
  654. package/src/cli/utils.test.ts +0 -156
  655. package/src/cli/utils.ts +0 -394
  656. package/src/cli/validate/challenge.ts +0 -565
  657. package/src/cli/validate/discovery.test.ts +0 -435
  658. package/src/cli/validate/discovery.ts +0 -221
  659. package/src/cli/validate/helpers.ts +0 -166
  660. package/src/cli/validate/index.ts +0 -229
  661. package/src/cli/validate/messages.ts +0 -7
  662. package/src/cli/validate/payment.ts +0 -774
  663. package/src/cli/validate.test.ts +0 -843
  664. package/src/client/Methods.ts +0 -8
  665. package/src/client/Mppx.test-d.ts +0 -270
  666. package/src/client/Mppx.test.ts +0 -1065
  667. package/src/client/Mppx.ts +0 -466
  668. package/src/client/Transport.test.ts +0 -619
  669. package/src/client/Transport.ts +0 -191
  670. package/src/client/index.ts +0 -29
  671. package/src/client/internal/Fetch.browser.test.ts +0 -197
  672. package/src/client/internal/Fetch.test-d.ts +0 -109
  673. package/src/client/internal/Fetch.test.ts +0 -2336
  674. package/src/client/internal/Fetch.ts +0 -1079
  675. package/src/client/internal/MethodChallenge.ts +0 -35
  676. package/src/client/internal/MethodResponse.ts +0 -67
  677. package/src/client/internal/protocols/Mcp.test.ts +0 -220
  678. package/src/client/internal/protocols/Mcp.ts +0 -186
  679. package/src/client/internal/protocols/Mpp.ts +0 -21
  680. package/src/client/internal/protocols/Protocol.ts +0 -10
  681. package/src/client/internal/protocols/Shared.ts +0 -25
  682. package/src/client/internal/protocols/X402.ts +0 -46
  683. package/src/client/node.test.ts +0 -115
  684. package/src/client/node.ts +0 -247
  685. package/src/discovery/Discovery.test.ts +0 -214
  686. package/src/discovery/Discovery.ts +0 -105
  687. package/src/discovery/OpenApi.test.ts +0 -453
  688. package/src/discovery/OpenApi.ts +0 -224
  689. package/src/discovery/Validate.test.ts +0 -305
  690. package/src/discovery/Validate.ts +0 -77
  691. package/src/discovery/index.ts +0 -3
  692. package/src/env.d.ts +0 -12
  693. package/src/evm/Assets.ts +0 -1
  694. package/src/evm/Chains.ts +0 -11
  695. package/src/evm/Methods.ts +0 -44
  696. package/src/evm/PublicInterface.test-d.ts +0 -134
  697. package/src/evm/Types.ts +0 -140
  698. package/src/evm/client/Charge.test.ts +0 -347
  699. package/src/evm/client/Charge.ts +0 -187
  700. package/src/evm/client/Methods.ts +0 -19
  701. package/src/evm/client/index.ts +0 -6
  702. package/src/evm/index.ts +0 -16
  703. package/src/evm/server/Charge.test.ts +0 -339
  704. package/src/evm/server/Charge.ts +0 -290
  705. package/src/evm/server/Methods.ts +0 -22
  706. package/src/evm/server/index.ts +0 -6
  707. package/src/index.ts +0 -14
  708. package/src/internal/AcceptPayment.test.ts +0 -343
  709. package/src/internal/AcceptPayment.ts +0 -366
  710. package/src/internal/HeaderCodec.ts +0 -36
  711. package/src/internal/changeset.test.ts +0 -106
  712. package/src/internal/constantTimeEqual.test.ts +0 -47
  713. package/src/internal/constantTimeEqual.ts +0 -10
  714. package/src/internal/env.test.ts +0 -42
  715. package/src/internal/env.ts +0 -49
  716. package/src/internal/types.test-d.ts +0 -21
  717. package/src/internal/types.ts +0 -470
  718. package/src/mcp/client/McpClient.integration.test.ts +0 -652
  719. package/src/mcp/client/McpClient.test-d.ts +0 -144
  720. package/src/mcp/client/McpClient.test.ts +0 -463
  721. package/src/mcp/client/McpClient.ts +0 -307
  722. package/src/mcp/client/McpClient.unit.test.ts +0 -135
  723. package/src/mcp/client/index.ts +0 -2
  724. package/src/mcp/server/Transport.test.ts +0 -191
  725. package/src/mcp/server/Transport.ts +0 -111
  726. package/src/mcp/server/index.ts +0 -1
  727. package/src/middlewares/elysia.test.ts +0 -295
  728. package/src/middlewares/elysia.ts +0 -116
  729. package/src/middlewares/express.test.ts +0 -371
  730. package/src/middlewares/express.ts +0 -140
  731. package/src/middlewares/hono.test.ts +0 -476
  732. package/src/middlewares/hono.ts +0 -153
  733. package/src/middlewares/internal/mppx.test.ts +0 -177
  734. package/src/middlewares/internal/mppx.ts +0 -67
  735. package/src/middlewares/nextjs.test.ts +0 -369
  736. package/src/middlewares/nextjs.ts +0 -107
  737. package/src/proxy/Proxy.test.ts +0 -1031
  738. package/src/proxy/Proxy.ts +0 -345
  739. package/src/proxy/Service.test.ts +0 -182
  740. package/src/proxy/Service.ts +0 -253
  741. package/src/proxy/index.ts +0 -6
  742. package/src/proxy/internal/Headers.test.ts +0 -139
  743. package/src/proxy/internal/Headers.ts +0 -66
  744. package/src/proxy/internal/Route.test.ts +0 -217
  745. package/src/proxy/internal/Route.ts +0 -64
  746. package/src/proxy/services/anthropic.test.ts +0 -132
  747. package/src/proxy/services/anthropic.ts +0 -52
  748. package/src/proxy/services/openai.test.ts +0 -157
  749. package/src/proxy/services/openai.ts +0 -59
  750. package/src/proxy/services/stripe.test.ts +0 -175
  751. package/src/proxy/services/stripe.ts +0 -58
  752. package/src/server/Methods.ts +0 -3
  753. package/src/server/Mppx.authorize.test.ts +0 -210
  754. package/src/server/Mppx.test-d.ts +0 -360
  755. package/src/server/Mppx.test.ts +0 -5813
  756. package/src/server/Mppx.ts +0 -2623
  757. package/src/server/NodeListener.test.ts +0 -293
  758. package/src/server/NodeListener.ts +0 -45
  759. package/src/server/Request.test.ts +0 -255
  760. package/src/server/Request.ts +0 -155
  761. package/src/server/Response.test.ts +0 -32
  762. package/src/server/Response.ts +0 -45
  763. package/src/server/Transport.test.ts +0 -598
  764. package/src/server/Transport.ts +0 -320
  765. package/src/server/index.ts +0 -9
  766. package/src/server/internal/html/compose.main.gen.ts +0 -2
  767. package/src/server/internal/html/compose.main.ts +0 -88
  768. package/src/server/internal/html/config.ts +0 -672
  769. package/src/server/internal/html/constants.ts +0 -28
  770. package/src/server/internal/html/serviceWorker.client.ts +0 -28
  771. package/src/server/internal/html/serviceWorker.gen.ts +0 -2
  772. package/src/server/internal/html/serviceWorker.ts +0 -27
  773. package/src/server/internal/html/tsconfig.compose.json +0 -8
  774. package/src/server/internal/html/tsconfig.worker.client.json +0 -8
  775. package/src/server/internal/html/tsconfig.worker.json +0 -8
  776. package/src/server/internal/scope.ts +0 -43
  777. package/src/stripe/Charge.integration.test.ts +0 -329
  778. package/src/stripe/Methods.test.ts +0 -62
  779. package/src/stripe/Methods.ts +0 -44
  780. package/src/stripe/client/Charge.test.ts +0 -205
  781. package/src/stripe/client/Charge.ts +0 -132
  782. package/src/stripe/client/Methods.ts +0 -37
  783. package/src/stripe/client/index.ts +0 -2
  784. package/src/stripe/index.ts +0 -1
  785. package/src/stripe/internal/constants.ts +0 -7
  786. package/src/stripe/internal/types.ts +0 -46
  787. package/src/stripe/server/Charge.test-d.ts +0 -66
  788. package/src/stripe/server/Charge.test.ts +0 -621
  789. package/src/stripe/server/Charge.ts +0 -434
  790. package/src/stripe/server/Methods.ts +0 -24
  791. package/src/stripe/server/index.ts +0 -2
  792. package/src/stripe/server/internal/html/main.ts +0 -165
  793. package/src/stripe/server/internal/html/node_modules/.bin/mppx +0 -22
  794. package/src/stripe/server/internal/html/node_modules/.bin/mppx.src +0 -22
  795. package/src/stripe/server/internal/html/package.json +0 -9
  796. package/src/stripe/server/internal/html/stripe-js-pure.d.ts +0 -7
  797. package/src/stripe/server/internal/html/tsconfig.json +0 -8
  798. package/src/stripe/server/internal/html/types.ts +0 -5
  799. package/src/stripe/server/internal/html.gen.ts +0 -2
  800. package/src/tempo/AccessKeyAuthorization.test.ts +0 -141
  801. package/src/tempo/Attribution.test.ts +0 -294
  802. package/src/tempo/Attribution.ts +0 -185
  803. package/src/tempo/Methods.test.ts +0 -425
  804. package/src/tempo/Methods.ts +0 -367
  805. package/src/tempo/Proof.conformance.test.ts +0 -146
  806. package/src/tempo/Proof.test-d.ts +0 -32
  807. package/src/tempo/Proof.test.ts +0 -40
  808. package/src/tempo/Proof.ts +0 -69
  809. package/src/tempo/PublicExports.test-d.ts +0 -130
  810. package/src/tempo/Subscription.integration.test.ts +0 -591
  811. package/src/tempo/client/Charge.test.ts +0 -501
  812. package/src/tempo/client/Charge.ts +0 -289
  813. package/src/tempo/client/Methods.ts +0 -45
  814. package/src/tempo/client/ResolveAccount.ts +0 -46
  815. package/src/tempo/client/Subscription.test.ts +0 -180
  816. package/src/tempo/client/Subscription.ts +0 -156
  817. package/src/tempo/client/index.ts +0 -17
  818. package/src/tempo/index.ts +0 -5
  819. package/src/tempo/internal/account.ts +0 -56
  820. package/src/tempo/internal/address.ts +0 -6
  821. package/src/tempo/internal/auto-swap.test.ts +0 -198
  822. package/src/tempo/internal/auto-swap.ts +0 -188
  823. package/src/tempo/internal/charge.test.ts +0 -66
  824. package/src/tempo/internal/charge.ts +0 -43
  825. package/src/tempo/internal/defaults.test.ts +0 -95
  826. package/src/tempo/internal/defaults.ts +0 -53
  827. package/src/tempo/internal/fee-payer.test.ts +0 -1177
  828. package/src/tempo/internal/fee-payer.ts +0 -808
  829. package/src/tempo/internal/fee-token.test.ts +0 -165
  830. package/src/tempo/internal/fee-token.ts +0 -72
  831. package/src/tempo/internal/proof.test.ts +0 -97
  832. package/src/tempo/internal/proof.ts +0 -87
  833. package/src/tempo/internal/selectors.ts +0 -10
  834. package/src/tempo/internal/types.ts +0 -19
  835. package/src/tempo/legacy/AccessKeyAuthorization.test.ts +0 -162
  836. package/src/tempo/legacy/README.md +0 -9
  837. package/src/tempo/legacy/client/ChannelOps.test.ts +0 -379
  838. package/src/tempo/legacy/client/ChannelOps.ts +0 -271
  839. package/src/tempo/legacy/client/Session.test.ts +0 -800
  840. package/src/tempo/legacy/client/Session.ts +0 -397
  841. package/src/tempo/legacy/client/SessionManager.test.ts +0 -468
  842. package/src/tempo/legacy/client/SessionManager.ts +0 -909
  843. package/src/tempo/legacy/client/index.ts +0 -6
  844. package/src/tempo/legacy/index.ts +0 -6
  845. package/src/tempo/legacy/server/Defaults.test-d.ts +0 -9
  846. package/src/tempo/legacy/server/Session.test.ts +0 -6370
  847. package/src/tempo/legacy/server/Session.ts +0 -1024
  848. package/src/tempo/legacy/server/index.ts +0 -4
  849. package/src/tempo/legacy/session/Chain.test.ts +0 -1349
  850. package/src/tempo/legacy/session/Chain.ts +0 -830
  851. package/src/tempo/legacy/session/Channel.test.ts +0 -109
  852. package/src/tempo/legacy/session/Channel.ts +0 -51
  853. package/src/tempo/legacy/session/ChannelStore.test.ts +0 -58
  854. package/src/tempo/legacy/session/ChannelStore.ts +0 -39
  855. package/src/tempo/legacy/session/Types.ts +0 -91
  856. package/src/tempo/legacy/session/Voucher.test.ts +0 -410
  857. package/src/tempo/legacy/session/Voucher.ts +0 -183
  858. package/src/tempo/legacy/session/escrow.abi.ts +0 -760
  859. package/src/tempo/legacy/session/index.ts +0 -8
  860. package/src/tempo/server/AtomicStore.test-d.ts +0 -50
  861. package/src/tempo/server/Charge.test.ts +0 -6121
  862. package/src/tempo/server/Charge.ts +0 -1351
  863. package/src/tempo/server/Methods.ts +0 -106
  864. package/src/tempo/server/Relay.test.ts +0 -677
  865. package/src/tempo/server/Relay.ts +0 -297
  866. package/src/tempo/server/SponsorBudget.test.ts +0 -154
  867. package/src/tempo/server/SponsorBudget.ts +0 -219
  868. package/src/tempo/server/Sse.test.ts +0 -321
  869. package/src/tempo/server/Subscription.test.ts +0 -1944
  870. package/src/tempo/server/Subscription.ts +0 -1333
  871. package/src/tempo/server/index.ts +0 -12
  872. package/src/tempo/server/internal/html/main.ts +0 -115
  873. package/src/tempo/server/internal/html/node_modules/.bin/mppx +0 -22
  874. package/src/tempo/server/internal/html/node_modules/.bin/mppx.src +0 -22
  875. package/src/tempo/server/internal/html/package.json +0 -10
  876. package/src/tempo/server/internal/html/tsconfig.json +0 -8
  877. package/src/tempo/server/internal/html.gen.ts +0 -2
  878. package/src/tempo/server/internal/request-body.test.ts +0 -210
  879. package/src/tempo/server/internal/request-body.ts +0 -61
  880. package/src/tempo/server/internal/transport.test.ts +0 -903
  881. package/src/tempo/server/internal/transport.ts +0 -310
  882. package/src/tempo/session/README.md +0 -208
  883. package/src/tempo/session/Snapshot.test.ts +0 -41
  884. package/src/tempo/session/Snapshot.ts +0 -95
  885. package/src/tempo/session/client/ChannelOps.test.ts +0 -218
  886. package/src/tempo/session/client/ChannelOps.ts +0 -348
  887. package/src/tempo/session/client/ChannelStore.ts +0 -111
  888. package/src/tempo/session/client/CredentialState.test.ts +0 -789
  889. package/src/tempo/session/client/CredentialState.ts +0 -942
  890. package/src/tempo/session/client/ReceiptCoordinator.ts +0 -95
  891. package/src/tempo/session/client/Runtime.test.ts +0 -1104
  892. package/src/tempo/session/client/Runtime.ts +0 -1008
  893. package/src/tempo/session/client/Session.test.ts +0 -1355
  894. package/src/tempo/session/client/Session.ts +0 -420
  895. package/src/tempo/session/client/SessionManager.test.ts +0 -1899
  896. package/src/tempo/session/client/SessionManager.ts +0 -996
  897. package/src/tempo/session/client/Transports.test.ts +0 -1141
  898. package/src/tempo/session/client/Transports.ts +0 -1534
  899. package/src/tempo/session/client/index.ts +0 -40
  900. package/src/tempo/session/client/internal/SessionManager.ts +0 -36
  901. package/src/tempo/session/index.ts +0 -7
  902. package/src/tempo/session/precompile/Chain.integration.test.ts +0 -339
  903. package/src/tempo/session/precompile/Chain.test.ts +0 -1641
  904. package/src/tempo/session/precompile/Chain.ts +0 -1149
  905. package/src/tempo/session/precompile/Channel.test.ts +0 -147
  906. package/src/tempo/session/precompile/Channel.ts +0 -108
  907. package/src/tempo/session/precompile/Protocol.test.ts +0 -358
  908. package/src/tempo/session/precompile/Protocol.ts +0 -520
  909. package/src/tempo/session/precompile/Voucher.test.ts +0 -354
  910. package/src/tempo/session/precompile/Voucher.ts +0 -162
  911. package/src/tempo/session/precompile/escrow.abi.ts +0 -226
  912. package/src/tempo/session/precompile/index.ts +0 -33
  913. package/src/tempo/session/server/ChannelOps.test.ts +0 -129
  914. package/src/tempo/session/server/ChannelOps.ts +0 -157
  915. package/src/tempo/session/server/ChannelStore.test.ts +0 -1093
  916. package/src/tempo/session/server/ChannelStore.ts +0 -835
  917. package/src/tempo/session/server/CredentialVerification.test.ts +0 -299
  918. package/src/tempo/session/server/CredentialVerification.ts +0 -775
  919. package/src/tempo/session/server/MeteredStream.ts +0 -95
  920. package/src/tempo/session/server/RequestState.test.ts +0 -574
  921. package/src/tempo/session/server/RequestState.ts +0 -507
  922. package/src/tempo/session/server/Session.integration.test.ts +0 -449
  923. package/src/tempo/session/server/Session.test.ts +0 -3862
  924. package/src/tempo/session/server/Session.ts +0 -570
  925. package/src/tempo/session/server/Settlement.test.ts +0 -345
  926. package/src/tempo/session/server/Settlement.ts +0 -527
  927. package/src/tempo/session/server/Sse.fuzz.test.ts +0 -138
  928. package/src/tempo/session/server/Sse.test.ts +0 -557
  929. package/src/tempo/session/server/Sse.ts +0 -254
  930. package/src/tempo/session/server/Transports.test.ts +0 -346
  931. package/src/tempo/session/server/Transports.ts +0 -255
  932. package/src/tempo/session/server/Ws.test.ts +0 -594
  933. package/src/tempo/session/server/Ws.ts +0 -385
  934. package/src/tempo/session/server/index.ts +0 -12
  935. package/src/tempo/subscription/KeyAuthorization.test.ts +0 -282
  936. package/src/tempo/subscription/KeyAuthorization.ts +0 -396
  937. package/src/tempo/subscription/Receipt.ts +0 -28
  938. package/src/tempo/subscription/Store.test.ts +0 -609
  939. package/src/tempo/subscription/Store.ts +0 -449
  940. package/src/tempo/subscription/Types.ts +0 -68
  941. package/src/tempo/subscription/index.ts +0 -23
  942. package/src/tsconfig.json +0 -10
  943. package/src/validation/core.ts +0 -386
  944. package/src/validation/index.ts +0 -11
  945. package/src/viem/Account.test.ts +0 -72
  946. package/src/viem/Account.ts +0 -30
  947. package/src/viem/Client.test.ts +0 -366
  948. package/src/viem/Client.ts +0 -93
  949. package/src/x402/Assets.test.ts +0 -253
  950. package/src/x402/Assets.ts +0 -221
  951. package/src/x402/Exact.e2e.test.ts +0 -448
  952. package/src/x402/Exact.localnet.test.ts +0 -475
  953. package/src/x402/Header.test.ts +0 -73
  954. package/src/x402/Header.ts +0 -79
  955. package/src/x402/PublicInterface.test-d.ts +0 -39
  956. package/src/x402/Types.ts +0 -248
  957. package/src/x402/client/Exact.test.ts +0 -309
  958. package/src/x402/client/Exact.ts +0 -186
  959. package/src/x402/index.ts +0 -6
  960. package/src/x402/internal/ChallengeBrand.ts +0 -14
  961. package/src/x402/internal/RouteBinding.ts +0 -18
  962. package/src/x402/server/EvmCharge.ts +0 -394
  963. package/src/x402/server/Facilitator.test.ts +0 -111
  964. package/src/x402/server/Facilitator.ts +0 -56
  965. package/src/zod.test.ts +0 -169
  966. package/src/zod.ts +0 -71
@@ -1,1149 +0,0 @@
1
- import type { Account, Address, Client, Hex } from 'viem'
2
- import { decodeFunctionData, encodeFunctionData, isAddressEqual, parseEventLogs } from 'viem'
3
- import {
4
- call,
5
- prepareTransactionRequest,
6
- readContract,
7
- sendRawTransaction,
8
- sendRawTransactionSync,
9
- sendTransaction as sendViemTransaction,
10
- signTransaction,
11
- waitForTransactionReceipt,
12
- } from 'viem/actions'
13
- import { Abis, Addresses, Transaction } from 'viem/tempo'
14
-
15
- import { BadRequestError, VerificationFailedError } from '../../../Errors.js'
16
- import * as FeePayer from '../../internal/fee-payer.js'
17
- import { resolveFeeToken } from '../../internal/fee-token.js'
18
- import * as ChannelOps from '../server/ChannelOps.js'
19
- import * as ChannelUtils from './Channel.js'
20
- import type { ChannelDescriptor } from './Channel.js'
21
- import { escrowAbi } from './escrow.abi.js'
22
- import { tip20ChannelEscrow } from './Protocol.js'
23
-
24
- /** Minimal on-chain state read back after precompile transaction receipts. */
25
- export type ReceiptValidationChannelState = {
26
- /** Cumulative amount settled on-chain. */
27
- settled: bigint
28
- /** Current on-chain channel deposit. */
29
- deposit: bigint
30
- /** Close-request timestamp, or zero when open. */
31
- closeRequestedAt: number
32
- }
33
-
34
- /** Inputs used to validate a ChannelOpened event against the verified open calldata. */
35
- export type ValidateChannelOpenedReceiptParameters = {
36
- /** Chain ID used in descriptor-derived channel ID. */
37
- chainId: number
38
- /** Descriptor reconstructed from the open calldata. */
39
- descriptor: ChannelDescriptor
40
- /** Channel ID emitted by the ChannelOpened event. */
41
- emittedChannelId: Hex
42
- /** Deposit emitted by the ChannelOpened event. */
43
- emittedDeposit: bigint
44
- /** Expiring nonce hash emitted by the ChannelOpened event. */
45
- emittedExpiringNonceHash: Hex
46
- /** Escrow precompile address used in descriptor-derived channel ID. */
47
- escrow: Address
48
- /** Channel ID expected from the credential. */
49
- expectedChannelId: Hex
50
- /** Deposit parsed from open calldata. */
51
- openDeposit: bigint
52
- }
53
-
54
- /** Inputs used to validate open read-back state after ChannelOpened. */
55
- export type ValidateOpenReadbackStateParameters = {
56
- /** Deposit emitted by the ChannelOpened event. */
57
- emittedDeposit: bigint
58
- /** State read back from the precompile. */
59
- state: ReceiptValidationChannelState
60
- }
61
-
62
- /** Inputs used to validate a TopUp event against the credential channel ID. */
63
- export type ValidateTopUpReceiptParameters = {
64
- /** Channel ID emitted by the TopUp event. */
65
- emittedChannelId: Hex
66
- /** Channel ID expected from the credential. */
67
- expectedChannelId: Hex
68
- }
69
-
70
- /** Inputs used to validate top-up read-back state after TopUp. */
71
- export type ValidateTopUpReadbackStateParameters = {
72
- /** New deposit emitted by the TopUp event. */
73
- newDeposit: bigint
74
- /** State read back from the precompile. */
75
- state: ReceiptValidationChannelState
76
- }
77
-
78
- /** Typed fields decoded from a ChannelOpened receipt event. */
79
- export type ChannelOpenedReceiptFields = {
80
- /** Channel ID emitted by the precompile. */
81
- channelId: Hex
82
- /** Deposit emitted by the precompile. */
83
- deposit: bigint
84
- /** Expiring nonce hash emitted by the precompile. */
85
- expiringNonceHash: Hex
86
- }
87
-
88
- /** Typed fields decoded from a TopUp receipt event. */
89
- export type TopUpReceiptFields = {
90
- /** Channel ID emitted by the precompile. */
91
- channelId: Hex
92
- /** New total deposit emitted by the precompile. */
93
- newDeposit: bigint
94
- }
95
-
96
- /** Typed fields decoded from a Settled receipt event. */
97
- export type SettledReceiptFields = {
98
- /** New cumulative amount settled on-chain. */
99
- newSettled: bigint
100
- }
101
-
102
- /** Typed fields decoded from a ChannelClosed receipt event. */
103
- export type ChannelClosedReceiptFields = {
104
- /** Amount captured by the payee. */
105
- settledToPayee: bigint
106
- /** Amount refunded to the payer. */
107
- refundedToPayer: bigint
108
- }
109
-
110
- type ReceiptEventWithArgs = {
111
- args: Record<string, unknown>
112
- }
113
-
114
- const uint96Max = 2n ** 96n - 1n
115
-
116
- function readBytes32(value: unknown, label: string): Hex {
117
- if (typeof value === 'string' && /^0x[0-9a-fA-F]{64}$/.test(value)) return value as Hex
118
- throw new VerificationFailedError({ reason: `${label} missing from receipt event` })
119
- }
120
-
121
- function readUint96(value: unknown, label: string): bigint {
122
- if (typeof value !== 'bigint')
123
- throw new VerificationFailedError({ reason: `${label} missing from receipt event` })
124
- if (value < 0n || value > uint96Max)
125
- throw new VerificationFailedError({ reason: `${label} exceeds uint96 range` })
126
- return value
127
- }
128
-
129
- /** Reads and validates typed fields from a ChannelOpened receipt event. */
130
- export function readChannelOpenedReceiptFields(
131
- event: ReceiptEventWithArgs,
132
- ): ChannelOpenedReceiptFields {
133
- return {
134
- channelId: readBytes32(event.args.channelId, 'ChannelOpened channelId'),
135
- deposit: readUint96(event.args.deposit, 'ChannelOpened deposit'),
136
- expiringNonceHash: readBytes32(event.args.expiringNonceHash, 'ChannelOpened expiringNonceHash'),
137
- }
138
- }
139
-
140
- /** Reads and validates typed fields from a TopUp receipt event. */
141
- export function readTopUpReceiptFields(event: ReceiptEventWithArgs): TopUpReceiptFields {
142
- return {
143
- channelId: readBytes32(event.args.channelId, 'TopUp channelId'),
144
- newDeposit: readUint96(event.args.newDeposit, 'TopUp newDeposit'),
145
- }
146
- }
147
-
148
- /** Reads and validates typed fields from a Settled receipt event. */
149
- export function readSettledReceiptFields(event: ReceiptEventWithArgs): SettledReceiptFields {
150
- return {
151
- newSettled: readUint96(event.args.newSettled, 'Settled newSettled'),
152
- }
153
- }
154
-
155
- /** Reads and validates typed fields from a ChannelClosed receipt event. */
156
- export function readChannelClosedReceiptFields(
157
- event: ReceiptEventWithArgs,
158
- ): ChannelClosedReceiptFields {
159
- return {
160
- settledToPayee: readUint96(event.args.settledToPayee, 'ChannelClosed settledToPayee'),
161
- refundedToPayer: readUint96(event.args.refundedToPayer, 'ChannelClosed refundedToPayer'),
162
- }
163
- }
164
-
165
- /** Validates that ChannelOpened receipt fields match calldata, descriptor, and credential. */
166
- export function validateChannelOpenedReceipt(
167
- parameters: ValidateChannelOpenedReceiptParameters,
168
- ): void {
169
- const {
170
- chainId,
171
- descriptor,
172
- emittedChannelId,
173
- emittedDeposit,
174
- emittedExpiringNonceHash,
175
- escrow,
176
- expectedChannelId,
177
- openDeposit,
178
- } = parameters
179
-
180
- if (emittedChannelId.toLowerCase() !== expectedChannelId.toLowerCase())
181
- throw new VerificationFailedError({
182
- reason: 'ChannelOpened channelId does not match credential',
183
- })
184
- if (emittedExpiringNonceHash.toLowerCase() !== descriptor.expiringNonceHash.toLowerCase())
185
- throw new VerificationFailedError({
186
- reason: 'ChannelOpened expiringNonceHash does not match descriptor',
187
- })
188
- if (emittedDeposit !== openDeposit)
189
- throw new VerificationFailedError({ reason: 'ChannelOpened deposit does not match calldata' })
190
-
191
- const confirmedChannelId = ChannelUtils.computeId({ ...descriptor, chainId, escrow })
192
- if (confirmedChannelId.toLowerCase() !== emittedChannelId.toLowerCase())
193
- throw new VerificationFailedError({
194
- reason: 'descriptor does not match ChannelOpened channelId',
195
- })
196
- }
197
-
198
- /** Validates the state read back after a successful open transaction. */
199
- export function validateOpenReadbackState(parameters: ValidateOpenReadbackStateParameters): void {
200
- const { emittedDeposit, state } = parameters
201
- if (state.deposit !== emittedDeposit || state.settled !== 0n || state.closeRequestedAt !== 0)
202
- throw new VerificationFailedError({
203
- reason: 'on-chain channel state does not match open receipt',
204
- })
205
- }
206
-
207
- /** Validates that a TopUp receipt belongs to the credential channel. */
208
- export function validateTopUpReceipt(parameters: ValidateTopUpReceiptParameters): void {
209
- if (parameters.emittedChannelId.toLowerCase() !== parameters.expectedChannelId.toLowerCase())
210
- throw new VerificationFailedError({ reason: 'TopUp channelId does not match credential' })
211
- }
212
-
213
- /** Validates the state read back after a successful top-up transaction. */
214
- export function validateTopUpReadbackState(parameters: ValidateTopUpReadbackStateParameters): void {
215
- if (parameters.state.deposit !== parameters.newDeposit)
216
- throw new VerificationFailedError({
217
- reason: 'on-chain channel state does not match topUp receipt',
218
- })
219
- }
220
-
221
- /** Fee fields produced by viem transaction preparation for direct precompile calls. */
222
- export type PreparedPrecompileFeePayerTransaction = {
223
- /** Estimated gas units for the transaction. */
224
- gas?: bigint | undefined
225
- /** Maximum fee per gas unit. */
226
- maxFeePerGas?: bigint | undefined
227
- /** Maximum priority fee per gas unit. */
228
- maxPriorityFeePerGas?: bigint | undefined
229
- }
230
-
231
- /** Parameters for checking a direct precompile transaction against sponsor limits. */
232
- export type AssertPrecompileFeePayerPolicyParameters = {
233
- /** Prepared transaction fee fields to validate. */
234
- prepared: PreparedPrecompileFeePayerTransaction
235
- /** Optional sponsor policy overrides. Missing fields are not enforced here. */
236
- policy?: Partial<FeePayer.Policy> | undefined
237
- }
238
-
239
- /** Enforces sponsor gas and fee limits before co-signing a direct precompile call. */
240
- export function assertPrecompileFeePayerPolicy(
241
- parameters: AssertPrecompileFeePayerPolicyParameters,
242
- ) {
243
- const { policy, prepared } = parameters
244
- if (!policy) return
245
- if (policy.maxGas !== undefined && (prepared.gas ?? 0n) > policy.maxGas)
246
- throw new BadRequestError({ reason: 'fee-payer policy maxGas exceeded' })
247
- if (policy.maxFeePerGas !== undefined && (prepared.maxFeePerGas ?? 0n) > policy.maxFeePerGas)
248
- throw new BadRequestError({ reason: 'fee-payer policy maxFeePerGas exceeded' })
249
- if (
250
- policy.maxPriorityFeePerGas !== undefined &&
251
- (prepared.maxPriorityFeePerGas ?? 0n) > policy.maxPriorityFeePerGas
252
- )
253
- throw new BadRequestError({ reason: 'fee-payer policy maxPriorityFeePerGas exceeded' })
254
- if (
255
- policy.maxTotalFee !== undefined &&
256
- (prepared.gas ?? 0n) * (prepared.maxFeePerGas ?? 0n) > policy.maxTotalFee
257
- )
258
- throw new BadRequestError({ reason: 'fee-payer policy maxTotalFee exceeded' })
259
- }
260
-
261
- const UINT96_MAX = 2n ** 96n - 1n
262
-
263
- /** viem client shape accepted by raw Tempo transaction actions. */
264
- export type TransactionClient = Parameters<typeof sendRawTransaction>[0]
265
-
266
- function assertUint96(amount: bigint): void {
267
- if (amount < 0n || amount > UINT96_MAX) {
268
- throw new VerificationFailedError({ reason: 'amount exceeds uint96 range' })
269
- }
270
- }
271
-
272
- /**
273
- * On-chain channel state from the TIP20EscrowChannel precompile.
274
- */
275
- export type ChannelState = {
276
- settled: bigint
277
- deposit: bigint
278
- closeRequestedAt: number
279
- }
280
-
281
- /**
282
- * On-chain channel descriptor and state from the TIP20EscrowChannel precompile.
283
- */
284
- export type Channel = {
285
- descriptor: ChannelDescriptor
286
- state: ChannelState
287
- }
288
-
289
- /**
290
- * Read channel descriptor and state from the TIP20EscrowChannel precompile.
291
- */
292
- export async function getChannel(
293
- client: Client,
294
- descriptor: ChannelDescriptor,
295
- escrow: Address = tip20ChannelEscrow,
296
- blockNumber?: bigint,
297
- ): Promise<Channel> {
298
- const channel = await readContract(client, {
299
- address: escrow,
300
- abi: escrowAbi,
301
- functionName: 'getChannel',
302
- args: [descriptorTuple(descriptor)],
303
- ...(blockNumber !== undefined ? { blockNumber } : {}),
304
- })
305
- return {
306
- descriptor: channel.descriptor,
307
- state: stateFromTuple(channel.state),
308
- }
309
- }
310
-
311
- /**
312
- * Read channel state from the TIP20EscrowChannel precompile.
313
- */
314
- export async function getChannelState(
315
- client: Client,
316
- channelId: Hex,
317
- escrow: Address = tip20ChannelEscrow,
318
- blockNumber?: bigint,
319
- ): Promise<ChannelState> {
320
- const state = await readContract(client, {
321
- address: escrow,
322
- abi: escrowAbi,
323
- functionName: 'getChannelState',
324
- args: [channelId],
325
- ...(blockNumber !== undefined ? { blockNumber } : {}),
326
- })
327
- return stateFromTuple(state)
328
- }
329
-
330
- /**
331
- * Read channel states from the TIP20EscrowChannel precompile.
332
- */
333
- export async function getChannelStatesBatch(
334
- client: Client,
335
- channelIds: readonly Hex[],
336
- escrow: Address = tip20ChannelEscrow,
337
- ): Promise<ChannelState[]> {
338
- const states = await readContract(client, {
339
- address: escrow,
340
- abi: escrowAbi,
341
- functionName: 'getChannelStatesBatch',
342
- args: [channelIds],
343
- })
344
- return states.map(stateFromTuple)
345
- }
346
-
347
- /** Tuning for {@link readbackWithRetry}. */
348
- export type ReadbackRetryOptions = {
349
- /** Additional attempts after the first, before giving up. @default 5 */
350
- retries?: number | undefined
351
- /** Delay between attempts, in milliseconds. @default 250 */
352
- delayMs?: number | undefined
353
- }
354
-
355
- /**
356
- * Retry an on-chain readback that is pinned to the block containing a just-sent
357
- * transaction.
358
- *
359
- * The escrow state read is served by a load-balanced RPC whose replicas can lag
360
- * behind the block that produced the transaction receipt. Callers pin the read
361
- * to that block number (via the `blockNumber` arg on {@link getChannel} /
362
- * {@link getChannelState}) so a node that has imported the block returns
363
- * authoritative state; replicas that have not yet imported it throw (e.g.
364
- * "header not found"), so we retry with a short backoff until one catches up.
365
- *
366
- * This closes the read-after-write race behind
367
- * `on-chain channel state does not match open receipt` — without it, a stale
368
- * `latest` read on a lagging replica returns an empty channel and fails
369
- * verification even though the open transaction succeeded.
370
- */
371
- export async function readbackWithRetry<T>(
372
- read: () => Promise<T>,
373
- options: ReadbackRetryOptions = {},
374
- ): Promise<T> {
375
- const { retries = 5, delayMs = 250 } = options
376
- let lastError: unknown
377
- for (let attempt = 0; attempt <= retries; attempt++) {
378
- try {
379
- return await read()
380
- } catch (error) {
381
- lastError = error
382
- if (attempt < retries) await new Promise((resolve) => setTimeout(resolve, delayMs))
383
- }
384
- }
385
- throw lastError
386
- }
387
-
388
- /** Options accepted by low-level TIP-1034 on-chain management helpers. */
389
- export type ChannelTransactionOptions = {
390
- /** Account used to send the transaction when the viem client has no default account. */
391
- account?: Account | undefined
392
- /** Candidate fee tokens used when resolving a fee token for fee-sponsored transactions. */
393
- candidateFeeTokens?: readonly Address[] | undefined
394
- /** Fee-payer account used to co-sign Tempo fee-sponsored transactions. */
395
- feePayer?: Account | undefined
396
- /** Optional fee-payer gas and total-fee limits enforced before co-signing. */
397
- feePayerPolicy?: Partial<FeePayer.Policy> | undefined
398
- /** Explicit fee token for the transaction. */
399
- feeToken?: Address | undefined
400
- }
401
-
402
- type ParsedPrecompileCredentialTransaction = {
403
- call: Transaction.TransactionTempo['calls'][number] & { data: Hex; to: Address }
404
- prefixCalls: readonly Transaction.TransactionTempo['calls'][number][]
405
- transaction: ReturnType<(typeof Transaction)['deserialize']>
406
- }
407
-
408
- function parsePrecompileCredentialTransaction(parameters: {
409
- escrowContract: Address
410
- feePayer?: Account | true | undefined
411
- label: 'open' | 'topUp'
412
- serializedTransaction: Hex
413
- }): ParsedPrecompileCredentialTransaction {
414
- const { escrowContract, feePayer, label, serializedTransaction } = parameters
415
- if (feePayer && !FeePayer.isTempoTransaction(serializedTransaction))
416
- throw new BadRequestError({ reason: 'Only Tempo (0x76/0x78) transactions are supported' })
417
-
418
- const transaction = Transaction.deserialize(
419
- serializedTransaction as Transaction.TransactionSerializedTempo,
420
- )
421
- const calls = transaction.calls
422
- if (calls.length !== 1 && calls.length !== 3)
423
- throw new VerificationFailedError({
424
- reason: `TIP-1034 ${label} transaction must contain one management call, optionally preceded by an auto-swap`,
425
- })
426
- const call = calls[calls.length - 1]!
427
- if (!call.to || !isAddressEqual(call.to, escrowContract))
428
- throw new VerificationFailedError({
429
- reason: `TIP-1034 ${label} transaction targets the wrong address`,
430
- })
431
- if (!call.data)
432
- throw new VerificationFailedError({
433
- reason: `TIP-1034 ${label} transaction is missing calldata`,
434
- })
435
- return {
436
- transaction,
437
- call: { ...call, data: call.data, to: call.to },
438
- prefixCalls: calls.slice(0, -1),
439
- }
440
- }
441
-
442
- function validateAutoSwapPrefix(parameters: {
443
- amountOut: bigint
444
- currency: Address
445
- label: 'open' | 'topUp'
446
- prefixCalls: readonly Transaction.TransactionTempo['calls'][number][]
447
- }) {
448
- const { amountOut, currency, label, prefixCalls } = parameters
449
- if (prefixCalls.length === 0) return
450
-
451
- const fail = (reason: string): never => {
452
- throw new VerificationFailedError({ reason: `TIP-1034 ${label} auto-swap ${reason}` })
453
- }
454
- if (prefixCalls.length !== 2) fail('must contain exactly approve and swap calls')
455
-
456
- const approveCall = prefixCalls[0]!
457
- const swapCall = prefixCalls[1]!
458
- const approveTo = approveCall.to
459
- const approveData = approveCall.data
460
- const swapTo = swapCall.to
461
- const swapData = swapCall.data
462
- if (!approveTo || !approveData || !swapTo || !swapData)
463
- fail('call is missing a target or calldata')
464
- const checkedApproveTo = approveTo as Address
465
- const checkedApproveData = approveData as Hex
466
- const checkedSwapTo = swapTo as Address
467
- const checkedSwapData = swapData as Hex
468
- if ((approveCall.value ?? 0n) !== 0n || (swapCall.value ?? 0n) !== 0n)
469
- fail('calls must not transfer native value')
470
- if (!isAddressEqual(checkedSwapTo, Addresses.stablecoinDex)) fail('targets the wrong DEX')
471
-
472
- const approve = (() => {
473
- try {
474
- return decodeFunctionData({ abi: Abis.tip20, data: checkedApproveData })
475
- } catch {
476
- return fail('approval calldata is invalid')
477
- }
478
- })()
479
- const swap = (() => {
480
- try {
481
- return decodeFunctionData({ abi: Abis.stablecoinDex, data: checkedSwapData })
482
- } catch {
483
- return fail('swap calldata is invalid')
484
- }
485
- })()
486
- if (approve.functionName !== 'approve' || swap.functionName !== 'swapExactAmountOut')
487
- fail('must contain approve followed by swapExactAmountOut')
488
-
489
- const [spender, approvedAmount] = approve.args as readonly [Address, bigint]
490
- const [tokenIn, tokenOut, swapAmountOut, maxAmountIn] = swap.args as readonly [
491
- Address,
492
- Address,
493
- bigint,
494
- bigint,
495
- ]
496
- if (!isAddressEqual(checkedApproveTo, tokenIn)) fail('approval token does not match swap input')
497
- if (!isAddressEqual(spender, Addresses.stablecoinDex)) fail('approval spender is not the DEX')
498
- if (approvedAmount !== maxAmountIn) fail('approval amount does not match swap maximum input')
499
- if (!isAddressEqual(tokenOut, currency)) fail('output token does not match channel currency')
500
- if (swapAmountOut !== amountOut) fail('output amount does not match channel deposit')
501
- if (isAddressEqual(tokenIn, tokenOut)) fail('input and output tokens must differ')
502
-
503
- const canonicalApprove = encodeFunctionData({
504
- abi: Abis.tip20,
505
- functionName: 'approve',
506
- args: [spender, approvedAmount],
507
- })
508
- const canonicalSwap = encodeFunctionData({
509
- abi: Abis.stablecoinDex,
510
- functionName: 'swapExactAmountOut',
511
- args: [tokenIn, tokenOut, swapAmountOut, maxAmountIn],
512
- })
513
- if (checkedApproveData.toLowerCase() !== canonicalApprove.toLowerCase())
514
- fail('approval calldata is not canonical')
515
- if (checkedSwapData.toLowerCase() !== canonicalSwap.toLowerCase())
516
- fail('swap calldata is not canonical')
517
- }
518
-
519
- async function simulateTempoTransaction(client: Client, request: unknown) {
520
- // viem's public `call` type does not yet model Tempo's multi-call and
521
- // fee-payer fields together. Keep that compatibility cast in one place.
522
- await call(client, request as never)
523
- }
524
-
525
- async function signTempoTransaction(client: Client, transaction: unknown): Promise<Hex> {
526
- return (await signTransaction(client, transaction as never)) as Hex
527
- }
528
-
529
- async function prepareFeePayerCallTransaction(
530
- client: Client,
531
- parameters: {
532
- account: Account
533
- data: Hex
534
- feeToken?: Address | undefined
535
- to: Address
536
- },
537
- ) {
538
- const { account, data, feeToken, to } = parameters
539
- // viem's stable request type does not expose Tempo fee-payer transaction
540
- // fields for this call shape. Keep the cast at the boundary.
541
- return prepareTransactionRequest(client, {
542
- account,
543
- calls: [{ to, data }],
544
- feePayer: true,
545
- ...(feeToken ? { feeToken } : {}),
546
- } as never)
547
- }
548
-
549
- function sendPrecompileContractCall(
550
- client: Client,
551
- parameters: {
552
- account?: Account | undefined
553
- data: Hex
554
- feeToken?: Address | undefined
555
- to: Address
556
- },
557
- ): Promise<Hex> {
558
- const { account, data, feeToken, to } = parameters
559
- // `feeToken` is Tempo-specific and not represented on viem's base
560
- // transaction request type.
561
- return sendViemTransaction(client, {
562
- ...(account ? { account } : {}),
563
- to,
564
- data,
565
- ...(feeToken ? { feeToken } : {}),
566
- } as never)
567
- }
568
-
569
- /**
570
- * Submit a settle transaction on-chain.
571
- */
572
- export async function settleOnChain(
573
- client: Client,
574
- descriptor: ChannelDescriptor,
575
- cumulativeAmount: bigint,
576
- signature: Hex,
577
- escrow: Address = tip20ChannelEscrow,
578
- options?: ChannelTransactionOptions,
579
- ): Promise<Hex> {
580
- assertUint96(cumulativeAmount)
581
- const args = [descriptorTuple(descriptor), cumulativeAmount, signature] as const
582
- return sendPrecompileTransaction(
583
- client,
584
- escrow,
585
- encodeFunctionData({ abi: escrowAbi, functionName: 'settle', args }),
586
- 'settle',
587
- options,
588
- )
589
- }
590
-
591
- /**
592
- * Submit a top-up transaction on-chain.
593
- */
594
- export async function topUpOnChain(
595
- client: Client,
596
- descriptor: ChannelDescriptor,
597
- additionalDeposit: bigint,
598
- escrow: Address = tip20ChannelEscrow,
599
- options?: ChannelTransactionOptions,
600
- ): Promise<Hex> {
601
- assertUint96(additionalDeposit)
602
- const args = [descriptorTuple(descriptor), additionalDeposit] as const
603
- return sendPrecompileTransaction(
604
- client,
605
- escrow,
606
- encodeFunctionData({ abi: escrowAbi, functionName: 'topUp', args }),
607
- 'topUp',
608
- options,
609
- )
610
- }
611
-
612
- /**
613
- * Submit a request-close transaction on-chain.
614
- */
615
- export async function requestCloseOnChain(
616
- client: Client,
617
- descriptor: ChannelDescriptor,
618
- escrow: Address = tip20ChannelEscrow,
619
- options?: ChannelTransactionOptions,
620
- ): Promise<Hex> {
621
- const args = [descriptorTuple(descriptor)] as const
622
- return sendPrecompileTransaction(
623
- client,
624
- escrow,
625
- encodeFunctionData({ abi: escrowAbi, functionName: 'requestClose', args }),
626
- 'requestClose',
627
- options,
628
- )
629
- }
630
-
631
- /**
632
- * Submit a withdraw transaction on-chain.
633
- */
634
- export async function withdrawOnChain(
635
- client: Client,
636
- descriptor: ChannelDescriptor,
637
- escrow: Address = tip20ChannelEscrow,
638
- options?: ChannelTransactionOptions,
639
- ): Promise<Hex> {
640
- const args = [descriptorTuple(descriptor)] as const
641
- return sendPrecompileTransaction(
642
- client,
643
- escrow,
644
- encodeFunctionData({ abi: escrowAbi, functionName: 'withdraw', args }),
645
- 'withdraw',
646
- options,
647
- )
648
- }
649
-
650
- /**
651
- * Submit a close transaction on-chain.
652
- */
653
- export async function closeOnChain(
654
- client: Client,
655
- descriptor: ChannelDescriptor,
656
- cumulativeAmount: bigint,
657
- captureAmount: bigint,
658
- signature: Hex,
659
- escrow: Address = tip20ChannelEscrow,
660
- options?: ChannelTransactionOptions,
661
- ): Promise<Hex> {
662
- assertUint96(cumulativeAmount)
663
- assertUint96(captureAmount)
664
- const args = [descriptorTuple(descriptor), cumulativeAmount, captureAmount, signature] as const
665
- return sendPrecompileTransaction(
666
- client,
667
- escrow,
668
- encodeFunctionData({ abi: escrowAbi, functionName: 'close', args }),
669
- 'close',
670
- options,
671
- )
672
- }
673
-
674
- /** Receipt event shape emitted by TIP20EscrowChannel precompile management calls. */
675
- export type ChannelReceiptEvent = {
676
- args: {
677
- channelId: Hex
678
- expiringNonceHash?: Hex | undefined
679
- deposit?: bigint | undefined
680
- newDeposit?: bigint | undefined
681
- newSettled?: bigint | undefined
682
- settledToPayee?: bigint | undefined
683
- refundedToPayer?: bigint | undefined
684
- }
685
- }
686
-
687
- /** Receipt-like input used when extracting channel events from transaction logs. */
688
- export type ChannelEventReceipt = {
689
- logs: Parameters<typeof parseEventLogs>[0]['logs']
690
- }
691
-
692
- /**
693
- * Asserts that a deserialized transaction has an existing sender signature.
694
- */
695
- export function assertSenderSigned(
696
- transaction: ReturnType<(typeof Transaction)['deserialize']>,
697
- ): void {
698
- if (!transaction.signature || !transaction.from)
699
- throw new BadRequestError({
700
- reason: 'Transaction must be signed by the sender before fee payer co-signing',
701
- })
702
- }
703
-
704
- /** Broadcast a raw serialized transaction. */
705
- export async function sendTransaction(client: TransactionClient, transaction: Hex) {
706
- return sendRawTransaction(client, { serializedTransaction: transaction })
707
- }
708
-
709
- /** Wait for a receipt and reject reverted precompile transactions. */
710
- export async function waitForSuccessfulReceipt(client: TransactionClient, hash: Hex) {
711
- const receipt = await waitForTransactionReceipt(client, { hash, checkReplacement: false })
712
- if (receipt.status !== 'success')
713
- throw new VerificationFailedError({ reason: 'precompile transaction reverted' })
714
- return receipt
715
- }
716
-
717
- /** Extract exactly one channel event for a channel ID from a receipt. */
718
- export function getChannelEvent(
719
- receipt: ChannelEventReceipt,
720
- name: 'ChannelOpened' | 'TopUp' | 'Settled' | 'ChannelClosed',
721
- channelId: Hex,
722
- ): ChannelReceiptEvent {
723
- const logs = parseEventLogs({
724
- abi: escrowAbi,
725
- eventName: name,
726
- logs: receipt.logs,
727
- }) as ChannelReceiptEvent[]
728
- const matches = logs.filter((log) => log.args.channelId.toLowerCase() === channelId.toLowerCase())
729
- if (matches.length !== 1)
730
- throw new VerificationFailedError({
731
- reason: `expected one ${name} event for credential channelId in receipt`,
732
- })
733
- return matches[0]!
734
- }
735
-
736
- /** Inputs for broadcasting a client-signed precompile management transaction. */
737
- export type SendCredentialTransactionParameters = {
738
- /** Challenge expiration propagated into fee-payer policy checks. */
739
- challengeExpires?: string | undefined
740
- /** Chain ID used for fee-payer transaction signing. */
741
- chainId: number
742
- /** viem client used to submit the transaction. */
743
- client: TransactionClient
744
- /** Fee tokens allowed by the server for sponsored transactions. */
745
- allowedFeeTokens?: readonly Address[] | undefined
746
- /** Human-readable transaction details used by fee-payer policy hooks. */
747
- details: Record<string, string>
748
- /** Fee-payer account, or `true` when the client transport delegates co-signing to a hosted relay. */
749
- feePayer?: Account | true | undefined
750
- /** Optional fee-payer policy enforced before co-signing. */
751
- feePayerPolicy?: Partial<FeePayer.Policy> | undefined
752
- /** Management transaction kind, used for validation errors. */
753
- label: 'open' | 'topUp'
754
- /** Client-signed serialized transaction. */
755
- serializedTransaction: Hex
756
- /** Deserialized transaction corresponding to `serializedTransaction`. */
757
- transaction: ReturnType<(typeof Transaction)['deserialize']>
758
- }
759
-
760
- /** Broadcasts a client-signed management transaction, adding a fee-payer co-signature when requested. */
761
- export async function sendCredentialTransaction(parameters: SendCredentialTransactionParameters) {
762
- const {
763
- challengeExpires,
764
- chainId,
765
- client,
766
- allowedFeeTokens,
767
- details,
768
- feePayer,
769
- feePayerPolicy,
770
- label,
771
- serializedTransaction,
772
- transaction,
773
- } = parameters
774
-
775
- if (!feePayer) {
776
- const txHash = await sendTransaction(client, serializedTransaction)
777
- return waitForSuccessfulReceipt(client, txHash)
778
- }
779
-
780
- if (!FeePayer.isTempoTransaction(serializedTransaction))
781
- throw new BadRequestError({ reason: 'Only Tempo (0x76/0x78) transactions are supported' })
782
- assertSenderSigned(transaction)
783
-
784
- if (feePayer === true) {
785
- // The transport owns hosted completion, so mppx can only preflight call
786
- // execution as the sender. It intentionally omits fee fields here; the
787
- // transport is responsible for validating its final sponsored envelope.
788
- await simulateTempoTransaction(
789
- client,
790
- FeePayer.simulationTransaction(transaction, { feePayer: true }),
791
- )
792
- const txHash = await sendTransaction(client, serializedTransaction)
793
- return waitForSuccessfulReceipt(client, txHash)
794
- }
795
-
796
- const sponsorshipTransaction = {
797
- ...transaction,
798
- ...(allowedFeeTokens?.[0] ? { feeToken: transaction.feeToken ?? allowedFeeTokens[0] } : {}),
799
- }
800
- const completed = await FeePayer.preflightSponsorship({
801
- transaction: sponsorshipTransaction,
802
- simulate: (request) => simulateTempoTransaction(client, request),
803
- async complete() {
804
- const sponsored = FeePayer.prepareSponsoredTransaction({
805
- account: feePayer,
806
- allowedFeeTokens,
807
- challengeExpires,
808
- chainId,
809
- details,
810
- policy: feePayerPolicy,
811
- transaction: sponsorshipTransaction,
812
- })
813
- return { feePayer: feePayer.address, transaction: sponsored }
814
- },
815
- })
816
- const serialized = await signTempoTransaction(client, completed.transaction)
817
- const receipt = await sendRawTransactionSync(client, {
818
- serializedTransaction: serialized as Transaction.TransactionSerializedTempo,
819
- })
820
- if (receipt.status !== 'success')
821
- throw new VerificationFailedError({
822
- reason: `${label} precompile transaction reverted: ${receipt.transactionHash}`,
823
- })
824
- return receipt
825
- }
826
-
827
- /** Result returned after a TIP-1034 open transaction is broadcast and verified. */
828
- export type BroadcastOpenTransactionResult = {
829
- /** Broadcast transaction hash. */
830
- txHash: Hex
831
- /** Descriptor recovered from the verified open transaction. */
832
- descriptor: ChannelDescriptor
833
- /** Latest on-chain channel state after open. */
834
- state: ChannelState
835
- /** Expiring nonce hash emitted by the open receipt. */
836
- expiringNonceHash: Hex
837
- /** Deposit amount encoded in the open calldata. */
838
- openDeposit: bigint
839
- }
840
-
841
- /** Inputs for broadcasting and verifying a client-signed TIP-1034 open transaction. */
842
- export type BroadcastOpenTransactionParameters = {
843
- /** Hook invoked after calldata validation but before broadcasting. */
844
- beforeBroadcast?:
845
- | ((result: Omit<BroadcastOpenTransactionResult, 'txHash' | 'state'>) => Promise<void> | void)
846
- | undefined
847
- /** Challenge expiration propagated into fee-payer policy checks. */
848
- challengeExpires?: string | undefined
849
- /** Chain ID used for channel ID and voucher domain separation. */
850
- chainId: number
851
- /** viem client used for transaction submission and readback. */
852
- client: TransactionClient
853
- /** TIP20EscrowChannel precompile address. */
854
- escrowContract: Address
855
- /** Authorized voucher signer expected in the open calldata. */
856
- expectedAuthorizedSigner: Address
857
- /** Channel ID expected from descriptor, escrow, and chain ID. */
858
- expectedChannelId: Hex
859
- /** Payment token expected in the open calldata. */
860
- expectedCurrency: Address
861
- /** Transaction-bound nonce hash expected in the descriptor. */
862
- expectedExpiringNonceHash: Hex
863
- /** Payee-side operator expected in the open calldata. */
864
- expectedOperator: Address
865
- /** Payment recipient expected in the open calldata. */
866
- expectedPayee: Address
867
- /** Payer expected to have signed the open transaction. */
868
- expectedPayer: Address
869
- /** Fee-payer account, or `true` when the client transport delegates co-signing to a hosted relay. */
870
- feePayer?: Account | true | undefined
871
- /** Optional fee-payer policy enforced before co-signing. */
872
- feePayerPolicy?: Partial<FeePayer.Policy> | undefined
873
- /** Client-signed serialized open transaction. */
874
- serializedTransaction: Hex
875
- }
876
-
877
- /** Broadcast and validate a client-signed TIP-1034 open transaction. */
878
- export async function broadcastOpenTransaction(
879
- parameters: BroadcastOpenTransactionParameters,
880
- ): Promise<BroadcastOpenTransactionResult> {
881
- const { transaction, call, prefixCalls } = parsePrecompileCredentialTransaction({
882
- escrowContract: parameters.escrowContract,
883
- feePayer: parameters.feePayer,
884
- label: 'open',
885
- serializedTransaction: parameters.serializedTransaction,
886
- })
887
- const payer = transaction.from ?? parameters.expectedPayer
888
- const open = ChannelOps.parseOpenCall({
889
- data: call.data,
890
- expected: {
891
- payee: parameters.expectedPayee,
892
- token: parameters.expectedCurrency,
893
- operator: parameters.expectedOperator,
894
- authorizedSigner: parameters.expectedAuthorizedSigner,
895
- },
896
- })
897
- validateAutoSwapPrefix({
898
- amountOut: open.deposit,
899
- currency: parameters.expectedCurrency,
900
- label: 'open',
901
- prefixCalls,
902
- })
903
- const descriptor = ChannelOps.descriptorFromOpen({
904
- chainId: parameters.chainId,
905
- escrow: parameters.escrowContract,
906
- payer,
907
- open,
908
- expiringNonceHash: parameters.expectedExpiringNonceHash,
909
- channelId: parameters.expectedChannelId,
910
- })
911
- if (parameters.feePayer) assertSenderSigned(transaction)
912
- const expiringNonceHash = ChannelUtils.computeExpiringNonceHash(
913
- ChannelUtils.transactionForExpiringNonceHash({
914
- feePayer: parameters.feePayer,
915
- transaction,
916
- }),
917
- { sender: payer },
918
- )
919
- if (expiringNonceHash.toLowerCase() !== descriptor.expiringNonceHash.toLowerCase())
920
- throw new VerificationFailedError({
921
- reason: 'credential expiringNonceHash does not match transaction',
922
- })
923
- await parameters.beforeBroadcast?.({
924
- descriptor,
925
- expiringNonceHash,
926
- openDeposit: open.deposit,
927
- })
928
- const receipt = await sendCredentialTransaction({
929
- challengeExpires: parameters.challengeExpires,
930
- chainId: parameters.chainId,
931
- client: parameters.client,
932
- allowedFeeTokens: [parameters.expectedCurrency],
933
- details: {
934
- channelId: parameters.expectedChannelId,
935
- currency: parameters.expectedCurrency,
936
- recipient: parameters.expectedPayee,
937
- },
938
- feePayer: parameters.feePayer,
939
- feePayerPolicy: parameters.feePayerPolicy,
940
- label: 'open',
941
- serializedTransaction: parameters.serializedTransaction,
942
- transaction,
943
- })
944
- const opened = readChannelOpenedReceiptFields(
945
- getChannelEvent(receipt, 'ChannelOpened', parameters.expectedChannelId),
946
- )
947
- validateChannelOpenedReceipt({
948
- chainId: parameters.chainId,
949
- descriptor,
950
- emittedChannelId: opened.channelId,
951
- emittedDeposit: opened.deposit,
952
- emittedExpiringNonceHash: opened.expiringNonceHash,
953
- escrow: parameters.escrowContract,
954
- expectedChannelId: parameters.expectedChannelId,
955
- openDeposit: open.deposit,
956
- })
957
- const chainChannel = await readbackWithRetry(() =>
958
- getChannel(parameters.client, descriptor, parameters.escrowContract, receipt.blockNumber),
959
- )
960
- const state = chainChannel.state
961
- validateOpenReadbackState({ emittedDeposit: opened.deposit, state })
962
- return {
963
- txHash: receipt.transactionHash,
964
- descriptor,
965
- state,
966
- expiringNonceHash: opened.expiringNonceHash,
967
- openDeposit: open.deposit,
968
- }
969
- }
970
-
971
- /** Result returned after a TIP-1034 top-up transaction is broadcast and verified. */
972
- export type BroadcastTopUpTransactionResult = {
973
- /** Broadcast transaction hash. */
974
- txHash: Hex
975
- /** New on-chain deposit emitted by the top-up receipt. */
976
- newDeposit: bigint
977
- /** Latest on-chain channel state after top-up. */
978
- state: ChannelState
979
- }
980
-
981
- /** Inputs for broadcasting and verifying a client-signed TIP-1034 top-up transaction. */
982
- export type BroadcastTopUpTransactionParameters = {
983
- /** Additional deposit amount expected in the top-up calldata. */
984
- additionalDeposit: bigint
985
- /** Challenge expiration propagated into fee-payer policy checks. */
986
- challengeExpires?: string | undefined
987
- /** Chain ID used for fee-payer transaction signing. */
988
- chainId: number
989
- /** viem client used for transaction submission and readback. */
990
- client: TransactionClient
991
- /** Descriptor expected in the top-up calldata. */
992
- descriptor: ChannelDescriptor
993
- /** TIP20EscrowChannel precompile address. */
994
- escrowContract: Address
995
- /** Channel ID expected in the top-up receipt. */
996
- expectedChannelId: Hex
997
- /** Payment token expected for sponsored transaction fee token checks. */
998
- expectedCurrency: Address
999
- /** Fee-payer account, or `true` when the client transport delegates co-signing to a hosted relay. */
1000
- feePayer?: Account | true | undefined
1001
- /** Optional fee-payer policy enforced before co-signing. */
1002
- feePayerPolicy?: Partial<FeePayer.Policy> | undefined
1003
- /** Client-signed serialized top-up transaction. */
1004
- serializedTransaction: Hex
1005
- }
1006
-
1007
- /** Broadcast and validate a client-signed TIP-1034 top-up transaction. */
1008
- export async function broadcastTopUpTransaction(
1009
- parameters: BroadcastTopUpTransactionParameters,
1010
- ): Promise<BroadcastTopUpTransactionResult> {
1011
- const { transaction, call, prefixCalls } = parsePrecompileCredentialTransaction({
1012
- escrowContract: parameters.escrowContract,
1013
- feePayer: parameters.feePayer,
1014
- label: 'topUp',
1015
- serializedTransaction: parameters.serializedTransaction,
1016
- })
1017
- ChannelOps.parseTopUpCall({
1018
- data: call.data,
1019
- expected: {
1020
- descriptor: parameters.descriptor,
1021
- additionalDeposit: parameters.additionalDeposit,
1022
- },
1023
- })
1024
- validateAutoSwapPrefix({
1025
- amountOut: parameters.additionalDeposit,
1026
- currency: parameters.expectedCurrency,
1027
- label: 'topUp',
1028
- prefixCalls,
1029
- })
1030
- const receipt = await sendCredentialTransaction({
1031
- challengeExpires: parameters.challengeExpires,
1032
- chainId: parameters.chainId,
1033
- client: parameters.client,
1034
- allowedFeeTokens: [parameters.expectedCurrency],
1035
- details: {
1036
- additionalDeposit: parameters.additionalDeposit.toString(),
1037
- channelId: parameters.expectedChannelId,
1038
- currency: parameters.expectedCurrency,
1039
- },
1040
- feePayer: parameters.feePayer,
1041
- feePayerPolicy: parameters.feePayerPolicy,
1042
- label: 'topUp',
1043
- serializedTransaction: parameters.serializedTransaction,
1044
- transaction,
1045
- })
1046
- const toppedUp = readTopUpReceiptFields(
1047
- getChannelEvent(receipt, 'TopUp', parameters.expectedChannelId),
1048
- )
1049
- validateTopUpReceipt({
1050
- emittedChannelId: toppedUp.channelId,
1051
- expectedChannelId: parameters.expectedChannelId,
1052
- })
1053
- const state = await readbackWithRetry(() =>
1054
- getChannelState(
1055
- parameters.client,
1056
- toppedUp.channelId,
1057
- parameters.escrowContract,
1058
- receipt.blockNumber,
1059
- ),
1060
- )
1061
- validateTopUpReadbackState({ newDeposit: toppedUp.newDeposit, state })
1062
- return { txHash: receipt.transactionHash, newDeposit: toppedUp.newDeposit, state }
1063
- }
1064
-
1065
- function stateFromTuple(state: {
1066
- settled: bigint
1067
- deposit: bigint
1068
- closeRequestedAt: number
1069
- }): ChannelState {
1070
- assertUint96(state.settled)
1071
- assertUint96(state.deposit)
1072
- return {
1073
- settled: state.settled,
1074
- deposit: state.deposit,
1075
- closeRequestedAt: state.closeRequestedAt,
1076
- }
1077
- }
1078
-
1079
- function descriptorTuple(descriptor: ChannelDescriptor) {
1080
- return {
1081
- payer: descriptor.payer,
1082
- payee: descriptor.payee,
1083
- operator: descriptor.operator,
1084
- token: descriptor.token,
1085
- salt: descriptor.salt,
1086
- authorizedSigner: descriptor.authorizedSigner,
1087
- expiringNonceHash: descriptor.expiringNonceHash,
1088
- } as const
1089
- }
1090
-
1091
- async function sendPrecompileTransaction(
1092
- client: Client,
1093
- to: Address,
1094
- data: Hex,
1095
- label: string,
1096
- options?: ChannelTransactionOptions,
1097
- ): Promise<Hex> {
1098
- const account = options?.account ?? client.account
1099
- const selfSponsored =
1100
- account && options?.feePayer && isAddressEqual(account.address, options.feePayer.address)
1101
-
1102
- if (options?.feePayer && !selfSponsored) {
1103
- if (!account) throw new Error(`Cannot ${label} precompile channel: no account available.`)
1104
- const feeToken =
1105
- options.feeToken ??
1106
- (await resolveFeeToken({
1107
- account: options.feePayer.address,
1108
- candidateTokens: options.candidateFeeTokens,
1109
- client,
1110
- }))
1111
- const prepared = await prepareFeePayerCallTransaction(client, {
1112
- account,
1113
- data,
1114
- feeToken,
1115
- to,
1116
- })
1117
- assertPrecompileFeePayerPolicy({ prepared, policy: options.feePayerPolicy })
1118
- const serialized = await signTempoTransaction(client, {
1119
- ...prepared,
1120
- account,
1121
- feePayer: options.feePayer,
1122
- })
1123
- const receipt = await sendRawTransactionSync(client, {
1124
- serializedTransaction: serialized as Transaction.TransactionSerializedTempo,
1125
- })
1126
- if (receipt.status !== 'success')
1127
- throw new VerificationFailedError({
1128
- reason: `${label} precompile transaction reverted: ${receipt.transactionHash}`,
1129
- })
1130
- return receipt.transactionHash
1131
- }
1132
-
1133
- const feeToken =
1134
- options?.feeToken ??
1135
- (selfSponsored
1136
- ? await resolveFeeToken({
1137
- account: account.address,
1138
- candidateTokens: options?.candidateFeeTokens,
1139
- client,
1140
- })
1141
- : undefined)
1142
-
1143
- return sendPrecompileContractCall(client, {
1144
- account,
1145
- to,
1146
- data,
1147
- feeToken,
1148
- })
1149
- }