tapimo 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (443) hide show
  1. package/dist/App.d.ts +6396 -4575
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/App.js +39 -4
  4. package/dist/App.js.map +1 -1
  5. package/dist/Assets.d.ts +15 -0
  6. package/dist/Assets.d.ts.map +1 -1
  7. package/dist/Assets.js +7 -0
  8. package/dist/Assets.js.map +1 -1
  9. package/dist/Scope.d.ts +2 -0
  10. package/dist/Scope.d.ts.map +1 -1
  11. package/dist/Scope.js +17 -0
  12. package/dist/Scope.js.map +1 -1
  13. package/dist/admin/App.d.ts +176 -78
  14. package/dist/admin/App.d.ts.map +1 -1
  15. package/dist/admin/apps/api-keys.d.ts +84 -4
  16. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  17. package/dist/admin/apps/api-keys.js +54 -0
  18. package/dist/admin/apps/api-keys.js.map +1 -1
  19. package/dist/admin/apps/earn-vaults.d.ts +123 -9
  20. package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
  21. package/dist/admin/apps/earn-vaults.js +60 -7
  22. package/dist/admin/apps/earn-vaults.js.map +1 -1
  23. package/dist/admin/apps/organizations.d.ts.map +1 -1
  24. package/dist/admin/apps/organizations.js +4 -2
  25. package/dist/admin/apps/organizations.js.map +1 -1
  26. package/dist/admin/apps/verified-tokens.d.ts +90 -90
  27. package/dist/admin/ui.generated.d.ts +1 -1
  28. package/dist/admin/ui.generated.js +71 -71
  29. package/dist/admin/ui.generated.js.map +1 -1
  30. package/dist/apps/Zones.d.ts +16 -16
  31. package/dist/apps/Zones.js +4 -4
  32. package/dist/apps/data/App.d.ts +1699 -749
  33. package/dist/apps/data/App.d.ts.map +1 -1
  34. package/dist/apps/data/App.js +58 -9
  35. package/dist/apps/data/App.js.map +1 -1
  36. package/dist/apps/data/ZoneSelection.d.ts +62 -0
  37. package/dist/apps/data/ZoneSelection.d.ts.map +1 -0
  38. package/dist/apps/data/ZoneSelection.js +44 -0
  39. package/dist/apps/data/ZoneSelection.js.map +1 -0
  40. package/dist/apps/data/routes/activities.d.ts +2417 -50
  41. package/dist/apps/data/routes/activities.d.ts.map +1 -1
  42. package/dist/apps/data/routes/activities.js +1896 -1293
  43. package/dist/apps/data/routes/activities.js.map +1 -1
  44. package/dist/apps/data/routes/addresses.d.ts +471 -340
  45. package/dist/apps/data/routes/addresses.d.ts.map +1 -1
  46. package/dist/apps/data/routes/balances.d.ts +12 -12
  47. package/dist/apps/data/routes/balances.d.ts.map +1 -1
  48. package/dist/apps/data/routes/balances.js +44 -17
  49. package/dist/apps/data/routes/balances.js.map +1 -1
  50. package/dist/apps/data/routes/blocks.d.ts +42 -42
  51. package/dist/apps/data/routes/blocks.d.ts.map +1 -1
  52. package/dist/apps/data/routes/blocks.js +22 -12
  53. package/dist/apps/data/routes/blocks.js.map +1 -1
  54. package/dist/apps/data/routes/coingecko.d.ts +179 -179
  55. package/dist/apps/data/routes/earn.d.ts +144 -19
  56. package/dist/apps/data/routes/earn.d.ts.map +1 -1
  57. package/dist/apps/data/routes/earn.js +160 -28
  58. package/dist/apps/data/routes/earn.js.map +1 -1
  59. package/dist/apps/data/routes/exchanges.d.ts +719 -13
  60. package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
  61. package/dist/apps/data/routes/exchanges.js +16 -13
  62. package/dist/apps/data/routes/exchanges.js.map +1 -1
  63. package/dist/apps/data/routes/fee-amm.d.ts +2 -2
  64. package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
  65. package/dist/apps/data/routes/fee-amm.js +9 -11
  66. package/dist/apps/data/routes/fee-amm.js.map +1 -1
  67. package/dist/apps/data/routes/indexer.d.ts +34 -34
  68. package/dist/apps/data/routes/receipts.d.ts +363 -263
  69. package/dist/apps/data/routes/receipts.d.ts.map +1 -1
  70. package/dist/apps/data/routes/receipts.js +29 -11
  71. package/dist/apps/data/routes/receipts.js.map +1 -1
  72. package/dist/apps/data/routes/rpc.js +24 -10
  73. package/dist/apps/data/routes/rpc.js.map +1 -1
  74. package/dist/apps/data/routes/tokenlist.d.ts +13 -13
  75. package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
  76. package/dist/apps/data/routes/tokenlist.js +16 -15
  77. package/dist/apps/data/routes/tokenlist.js.map +1 -1
  78. package/dist/apps/data/routes/tokens.d.ts +112 -98
  79. package/dist/apps/data/routes/tokens.d.ts.map +1 -1
  80. package/dist/apps/data/routes/tokens.js +85 -35
  81. package/dist/apps/data/routes/tokens.js.map +1 -1
  82. package/dist/apps/data/routes/transactions.d.ts +7 -2
  83. package/dist/apps/data/routes/transactions.d.ts.map +1 -1
  84. package/dist/apps/data/routes/transactions.js +38 -18
  85. package/dist/apps/data/routes/transactions.js.map +1 -1
  86. package/dist/apps/data/routes/transfers.d.ts +1 -1
  87. package/dist/apps/data/routes/transfers.d.ts.map +1 -1
  88. package/dist/apps/data/routes/transfers.js +25 -21
  89. package/dist/apps/data/routes/transfers.js.map +1 -1
  90. package/dist/apps/data/routes/valuation.d.ts +1 -1
  91. package/dist/apps/data/routes/valuation.d.ts.map +1 -1
  92. package/dist/apps/data/routes/valuation.js +12 -7
  93. package/dist/apps/data/routes/valuation.js.map +1 -1
  94. package/dist/apps/data/routes/verified-tokens.d.ts +3 -3
  95. package/dist/apps/data/routes/webhooks.d.ts +15 -15
  96. package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
  97. package/dist/apps/data/routes/webhooks.js +2 -2
  98. package/dist/apps/data/routes/webhooks.js.map +1 -1
  99. package/dist/apps/data/routes/zones.d.ts +32 -32
  100. package/dist/apps/data/routes/zones.js +1 -1
  101. package/dist/apps/funding/App.d.ts +38 -27
  102. package/dist/apps/funding/App.d.ts.map +1 -1
  103. package/dist/apps/funding/routes/chains.d.ts.map +1 -1
  104. package/dist/apps/funding/routes/chains.js +5 -4
  105. package/dist/apps/funding/routes/chains.js.map +1 -1
  106. package/dist/apps/funding/routes/deposit-addresses.d.ts +16 -16
  107. package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -1
  108. package/dist/apps/funding/routes/deposit-addresses.js +24 -19
  109. package/dist/apps/funding/routes/deposit-addresses.js.map +1 -1
  110. package/dist/apps/funding/routes/providers.d.ts +13 -13
  111. package/dist/apps/funding/routes/providers.d.ts.map +1 -1
  112. package/dist/apps/funding/routes/providers.js +3 -2
  113. package/dist/apps/funding/routes/providers.js.map +1 -1
  114. package/dist/apps/funding/routes/quotes.d.ts.map +1 -1
  115. package/dist/apps/funding/routes/quotes.js +2 -2
  116. package/dist/apps/funding/routes/quotes.js.map +1 -1
  117. package/dist/apps/funding/routes/transfers.d.ts +60 -48
  118. package/dist/apps/funding/routes/transfers.d.ts.map +1 -1
  119. package/dist/apps/funding/routes/transfers.js +27 -19
  120. package/dist/apps/funding/routes/transfers.js.map +1 -1
  121. package/dist/apps/management/App.d.ts +4558 -3700
  122. package/dist/apps/management/App.d.ts.map +1 -1
  123. package/dist/apps/management/Billing.d.ts.map +1 -1
  124. package/dist/apps/management/Billing.js +19 -6
  125. package/dist/apps/management/Billing.js.map +1 -1
  126. package/dist/apps/management/routes/api-keys.d.ts +786 -175
  127. package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
  128. package/dist/apps/management/routes/api-keys.js +312 -34
  129. package/dist/apps/management/routes/api-keys.js.map +1 -1
  130. package/dist/apps/management/routes/billing.d.ts +103 -30
  131. package/dist/apps/management/routes/billing.d.ts.map +1 -1
  132. package/dist/apps/management/routes/billing.js +91 -32
  133. package/dist/apps/management/routes/billing.js.map +1 -1
  134. package/dist/apps/management/routes/faucet.d.ts +35 -35
  135. package/dist/apps/management/routes/faucet.d.ts.map +1 -1
  136. package/dist/apps/management/routes/faucet.js +23 -12
  137. package/dist/apps/management/routes/faucet.js.map +1 -1
  138. package/dist/apps/management/routes/invitations.d.ts +46 -13
  139. package/dist/apps/management/routes/invitations.d.ts.map +1 -1
  140. package/dist/apps/management/routes/invitations.js +79 -29
  141. package/dist/apps/management/routes/invitations.js.map +1 -1
  142. package/dist/apps/management/routes/invite-links.d.ts +120 -75
  143. package/dist/apps/management/routes/invite-links.d.ts.map +1 -1
  144. package/dist/apps/management/routes/invite-links.js +100 -41
  145. package/dist/apps/management/routes/invite-links.js.map +1 -1
  146. package/dist/apps/management/routes/me.d.ts +5 -5
  147. package/dist/apps/management/routes/me.d.ts.map +1 -1
  148. package/dist/apps/management/routes/me.js +14 -10
  149. package/dist/apps/management/routes/me.js.map +1 -1
  150. package/dist/apps/management/routes/members.d.ts +99 -78
  151. package/dist/apps/management/routes/members.d.ts.map +1 -1
  152. package/dist/apps/management/routes/members.js +37 -18
  153. package/dist/apps/management/routes/members.js.map +1 -1
  154. package/dist/apps/management/routes/orgs.d.ts +48 -8
  155. package/dist/apps/management/routes/orgs.d.ts.map +1 -1
  156. package/dist/apps/management/routes/orgs.js +48 -19
  157. package/dist/apps/management/routes/orgs.js.map +1 -1
  158. package/dist/apps/management/routes/projects.d.ts +108 -46
  159. package/dist/apps/management/routes/projects.d.ts.map +1 -1
  160. package/dist/apps/management/routes/projects.js +72 -21
  161. package/dist/apps/management/routes/projects.js.map +1 -1
  162. package/dist/apps/management/routes/scopes.d.ts.map +1 -1
  163. package/dist/apps/management/routes/scopes.js +8 -5
  164. package/dist/apps/management/routes/scopes.js.map +1 -1
  165. package/dist/apps/management/routes/usage.d.ts +82 -82
  166. package/dist/apps/management/routes/usage.d.ts.map +1 -1
  167. package/dist/apps/management/routes/usage.js +41 -31
  168. package/dist/apps/management/routes/usage.js.map +1 -1
  169. package/dist/apps/management/routes/verified-token-requests.d.ts +35 -7
  170. package/dist/apps/management/routes/verified-token-requests.d.ts.map +1 -1
  171. package/dist/apps/management/routes/verified-token-requests.js +36 -17
  172. package/dist/apps/management/routes/verified-token-requests.js.map +1 -1
  173. package/dist/apps/management/routes/webhooks.d.ts +200 -183
  174. package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
  175. package/dist/apps/management/routes/webhooks.js +80 -35
  176. package/dist/apps/management/routes/webhooks.js.map +1 -1
  177. package/dist/apps/mpp/internal/Adapter.d.ts +1 -1
  178. package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
  179. package/dist/apps/mpp/internal/Adapter.js +12 -0
  180. package/dist/apps/mpp/internal/Adapter.js.map +1 -1
  181. package/dist/db/Db.d.ts +2 -0
  182. package/dist/db/Db.d.ts.map +1 -1
  183. package/dist/db/Db.js +52 -1
  184. package/dist/db/Db.js.map +1 -1
  185. package/dist/db/Schema.d.ts +26 -3
  186. package/dist/db/Schema.d.ts.map +1 -1
  187. package/dist/db/Schema.js +24 -5
  188. package/dist/db/Schema.js.map +1 -1
  189. package/dist/db/tables/earnVaults.d.ts +5 -1
  190. package/dist/db/tables/earnVaults.d.ts.map +1 -1
  191. package/dist/db/tables/earnVaults.js +5 -0
  192. package/dist/db/tables/earnVaults.js.map +1 -1
  193. package/dist/db/tables/fundingCatalog.d.ts +4 -2
  194. package/dist/db/tables/fundingCatalog.d.ts.map +1 -1
  195. package/dist/db/tables/fundingCatalog.js +5 -1
  196. package/dist/db/tables/fundingCatalog.js.map +1 -1
  197. package/dist/db/tables/webhookDeliveries.d.ts.map +1 -1
  198. package/dist/db/tables/webhookDeliveries.js +10 -0
  199. package/dist/db/tables/webhookDeliveries.js.map +1 -1
  200. package/dist/db/tables/webhookQueueCompletions.d.ts +15 -0
  201. package/dist/db/tables/webhookQueueCompletions.d.ts.map +1 -0
  202. package/dist/db/tables/webhookQueueCompletions.js +32 -0
  203. package/dist/db/tables/webhookQueueCompletions.js.map +1 -0
  204. package/dist/db/tables/webhookQueueEvents.d.ts +14 -20
  205. package/dist/db/tables/webhookQueueEvents.d.ts.map +1 -1
  206. package/dist/db/tables/webhookQueueEvents.js +68 -47
  207. package/dist/db/tables/webhookQueueEvents.js.map +1 -1
  208. package/dist/db/tables/webhookSubscriptions.d.ts +16 -5
  209. package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
  210. package/dist/db/tables/webhookSubscriptions.js +29 -5
  211. package/dist/db/tables/webhookSubscriptions.js.map +1 -1
  212. package/dist/handlers/internal/utils.d.ts.map +1 -1
  213. package/dist/handlers/internal/utils.js +9 -0
  214. package/dist/handlers/internal/utils.js.map +1 -1
  215. package/dist/internal/Auth.d.ts +11 -2
  216. package/dist/internal/Auth.d.ts.map +1 -1
  217. package/dist/internal/Auth.js +19 -6
  218. package/dist/internal/Auth.js.map +1 -1
  219. package/dist/internal/Cache.d.ts.map +1 -1
  220. package/dist/internal/Cache.js +11 -7
  221. package/dist/internal/Cache.js.map +1 -1
  222. package/dist/internal/EarnVaults.d.ts +43 -4
  223. package/dist/internal/EarnVaults.d.ts.map +1 -1
  224. package/dist/internal/EarnVaults.js +167 -0
  225. package/dist/internal/EarnVaults.js.map +1 -1
  226. package/dist/internal/Fetch.d.ts +23 -0
  227. package/dist/internal/Fetch.d.ts.map +1 -0
  228. package/dist/internal/Fetch.js +26 -0
  229. package/dist/internal/Fetch.js.map +1 -0
  230. package/dist/internal/Log.d.ts +3 -1
  231. package/dist/internal/Log.d.ts.map +1 -1
  232. package/dist/internal/Log.js +16 -3
  233. package/dist/internal/Log.js.map +1 -1
  234. package/dist/internal/OpenApi.d.ts +30 -24
  235. package/dist/internal/OpenApi.d.ts.map +1 -1
  236. package/dist/internal/OpenApi.js +140 -41
  237. package/dist/internal/OpenApi.js.map +1 -1
  238. package/dist/internal/Response.d.ts +14 -9
  239. package/dist/internal/Response.d.ts.map +1 -1
  240. package/dist/internal/Response.js +16 -5
  241. package/dist/internal/Response.js.map +1 -1
  242. package/dist/internal/Schema.d.ts +11 -10
  243. package/dist/internal/Schema.d.ts.map +1 -1
  244. package/dist/internal/Schema.js +14 -9
  245. package/dist/internal/Schema.js.map +1 -1
  246. package/dist/internal/Store.d.ts +28 -6
  247. package/dist/internal/Store.d.ts.map +1 -1
  248. package/dist/internal/Store.js +121 -25
  249. package/dist/internal/Store.js.map +1 -1
  250. package/dist/internal/Tidx.d.ts +2 -0
  251. package/dist/internal/Tidx.d.ts.map +1 -1
  252. package/dist/internal/Tidx.js +23 -6
  253. package/dist/internal/Tidx.js.map +1 -1
  254. package/dist/internal/Timeout.d.ts +36 -0
  255. package/dist/internal/Timeout.d.ts.map +1 -0
  256. package/dist/internal/Timeout.js +37 -0
  257. package/dist/internal/Timeout.js.map +1 -0
  258. package/dist/internal/Timing.d.ts +9 -0
  259. package/dist/internal/Timing.d.ts.map +1 -1
  260. package/dist/internal/Timing.js +7 -0
  261. package/dist/internal/Timing.js.map +1 -1
  262. package/dist/internal/WebhookDestination.d.ts.map +1 -1
  263. package/dist/internal/WebhookDestination.js +3 -0
  264. package/dist/internal/WebhookDestination.js.map +1 -1
  265. package/dist/internal/Webhooks.d.ts +29 -12
  266. package/dist/internal/Webhooks.d.ts.map +1 -1
  267. package/dist/internal/Webhooks.js +37 -20
  268. package/dist/internal/Webhooks.js.map +1 -1
  269. package/dist/internal/funding/Action.d.ts +9 -0
  270. package/dist/internal/funding/Action.d.ts.map +1 -1
  271. package/dist/internal/funding/Action.js +16 -8
  272. package/dist/internal/funding/Action.js.map +1 -1
  273. package/dist/internal/funding/Catalog.d.ts +9 -2
  274. package/dist/internal/funding/Catalog.d.ts.map +1 -1
  275. package/dist/internal/funding/Catalog.js +19 -8
  276. package/dist/internal/funding/Catalog.js.map +1 -1
  277. package/dist/internal/funding/Deposit.d.ts +2 -2
  278. package/dist/internal/funding/Deposit.d.ts.map +1 -1
  279. package/dist/internal/funding/Deposit.js +9 -8
  280. package/dist/internal/funding/Deposit.js.map +1 -1
  281. package/dist/internal/funding/DepositAddress.d.ts +4 -4
  282. package/dist/internal/funding/DepositAddress.d.ts.map +1 -1
  283. package/dist/internal/funding/DepositAddress.js +9 -8
  284. package/dist/internal/funding/DepositAddress.js.map +1 -1
  285. package/dist/internal/funding/Provider.d.ts +68 -13
  286. package/dist/internal/funding/Provider.d.ts.map +1 -1
  287. package/dist/internal/funding/Provider.js +42 -20
  288. package/dist/internal/funding/Provider.js.map +1 -1
  289. package/dist/internal/funding/Transfer.d.ts +13 -12
  290. package/dist/internal/funding/Transfer.d.ts.map +1 -1
  291. package/dist/internal/funding/Transfer.js +23 -21
  292. package/dist/internal/funding/Transfer.js.map +1 -1
  293. package/dist/internal/funding/providers/stargate.d.ts +38 -0
  294. package/dist/internal/funding/providers/stargate.d.ts.map +1 -0
  295. package/dist/internal/funding/providers/stargate.js +277 -0
  296. package/dist/internal/funding/providers/stargate.js.map +1 -0
  297. package/dist/internal/index.d.ts +1 -0
  298. package/dist/internal/index.d.ts.map +1 -1
  299. package/dist/internal/index.js +1 -0
  300. package/dist/internal/index.js.map +1 -1
  301. package/dist/providers/index.d.ts +7 -0
  302. package/dist/providers/index.d.ts.map +1 -1
  303. package/dist/providers/index.js +3 -0
  304. package/dist/providers/index.js.map +1 -1
  305. package/package.json +3 -3
  306. package/src/App.test.ts +148 -0
  307. package/src/App.ts +45 -4
  308. package/src/Assets.test.ts +18 -0
  309. package/src/Assets.ts +22 -0
  310. package/src/Client.test-d.ts +311 -16
  311. package/src/Scope.test.ts +20 -0
  312. package/src/Scope.ts +16 -0
  313. package/src/admin/apps/api-keys.test.ts +75 -0
  314. package/src/admin/apps/api-keys.ts +64 -0
  315. package/src/admin/apps/earn-vaults.test.ts +143 -0
  316. package/src/admin/apps/earn-vaults.ts +84 -7
  317. package/src/admin/apps/organizations.ts +6 -2
  318. package/src/admin/ui/src/lib/api-keys.ts +19 -0
  319. package/src/admin/ui/src/routes/api-keys.tsx +125 -2
  320. package/src/admin/ui.generated.ts +71 -71
  321. package/src/apps/Zones.test.ts +4 -4
  322. package/src/apps/Zones.ts +4 -4
  323. package/src/apps/composition.test.ts +1 -1
  324. package/src/apps/data/App.test.ts +72 -0
  325. package/src/apps/data/App.ts +58 -10
  326. package/src/apps/data/ZoneSelection.test.ts +196 -0
  327. package/src/apps/data/ZoneSelection.ts +108 -0
  328. package/src/apps/data/routes/activities.test.ts +1843 -2
  329. package/src/apps/data/routes/activities.ts +2211 -1388
  330. package/src/apps/data/routes/balances.ts +134 -98
  331. package/src/apps/data/routes/blocks.test.ts +533 -0
  332. package/src/apps/data/routes/blocks.ts +36 -17
  333. package/src/apps/data/routes/earn.test.ts +187 -25
  334. package/src/apps/data/routes/earn.ts +228 -32
  335. package/src/apps/data/routes/earn.zone-access.test.ts +46 -0
  336. package/src/apps/data/routes/exchanges.test.ts +31 -1
  337. package/src/apps/data/routes/exchanges.ts +19 -15
  338. package/src/apps/data/routes/fee-amm.ts +18 -11
  339. package/src/apps/data/routes/receipts.ts +48 -17
  340. package/src/apps/data/routes/rpc.test.ts +75 -0
  341. package/src/apps/data/routes/rpc.ts +23 -9
  342. package/src/apps/data/routes/tokenlist.ts +21 -18
  343. package/src/apps/data/routes/tokens.test.ts +607 -0
  344. package/src/apps/data/routes/tokens.ts +312 -231
  345. package/src/apps/data/routes/transactions.ts +69 -30
  346. package/src/apps/data/routes/transfers.test.ts +424 -3
  347. package/src/apps/data/routes/transfers.ts +57 -36
  348. package/src/apps/data/routes/valuation.ts +94 -78
  349. package/src/apps/data/routes/webhooks.ts +6 -2
  350. package/src/apps/data/routes/zones.test.ts +21 -15
  351. package/src/apps/data/routes/zones.ts +1 -1
  352. package/src/apps/funding/routes/chains.test.ts +211 -7
  353. package/src/apps/funding/routes/chains.ts +19 -12
  354. package/src/apps/funding/routes/deposit-addresses.test.ts +416 -0
  355. package/src/apps/funding/routes/deposit-addresses.ts +101 -84
  356. package/src/apps/funding/routes/providers.ts +9 -5
  357. package/src/apps/funding/routes/quotes.test.ts +42 -0
  358. package/src/apps/funding/routes/quotes.ts +8 -5
  359. package/src/apps/funding/routes/transfers.test.ts +430 -40
  360. package/src/apps/funding/routes/transfers.ts +76 -59
  361. package/src/apps/management/Billing.test.ts +26 -0
  362. package/src/apps/management/Billing.ts +24 -7
  363. package/src/apps/management/routes/api-keys.test.ts +398 -0
  364. package/src/apps/management/routes/api-keys.ts +481 -145
  365. package/src/apps/management/routes/billing.test.ts +209 -0
  366. package/src/apps/management/routes/billing.ts +254 -177
  367. package/src/apps/management/routes/faucet.test.ts +39 -0
  368. package/src/apps/management/routes/faucet.ts +75 -41
  369. package/src/apps/management/routes/invitations.test.ts +216 -0
  370. package/src/apps/management/routes/invitations.ts +186 -109
  371. package/src/apps/management/routes/invite-links.test.ts +263 -1
  372. package/src/apps/management/routes/invite-links.ts +295 -214
  373. package/src/apps/management/routes/me.test.ts +49 -0
  374. package/src/apps/management/routes/me.ts +42 -32
  375. package/src/apps/management/routes/members.test.ts +124 -1
  376. package/src/apps/management/routes/members.ts +81 -51
  377. package/src/apps/management/routes/orgs.test.ts +176 -0
  378. package/src/apps/management/routes/orgs.ts +101 -59
  379. package/src/apps/management/routes/projects.test.ts +183 -0
  380. package/src/apps/management/routes/projects.ts +124 -60
  381. package/src/apps/management/routes/scopes.test.ts +44 -0
  382. package/src/apps/management/routes/scopes.ts +37 -28
  383. package/src/apps/management/routes/usage.test.ts +92 -0
  384. package/src/apps/management/routes/usage.ts +186 -151
  385. package/src/apps/management/routes/verified-token-requests.test.ts +114 -0
  386. package/src/apps/management/routes/verified-token-requests.ts +166 -133
  387. package/src/apps/management/routes/webhooks.test.ts +234 -0
  388. package/src/apps/management/routes/webhooks.ts +191 -78
  389. package/src/apps/mpp/internal/Adapter.ts +13 -1
  390. package/src/db/Db.test.ts +41 -0
  391. package/src/db/Db.ts +75 -1
  392. package/src/db/Schema.ts +33 -5
  393. package/src/db/tables/earnVaults.test.ts +22 -0
  394. package/src/db/tables/earnVaults.ts +11 -1
  395. package/src/db/tables/fundingCatalog.test.ts +16 -2
  396. package/src/db/tables/fundingCatalog.ts +9 -3
  397. package/src/db/tables/webhookDeliveries.ts +13 -0
  398. package/src/db/tables/webhookQueueCompletions.ts +55 -0
  399. package/src/db/tables/webhookQueueEvents.ts +95 -61
  400. package/src/db/tables/webhookSubscriptions.ts +45 -6
  401. package/src/handlers/internal/utils.test.ts +53 -0
  402. package/src/handlers/internal/utils.ts +15 -0
  403. package/src/internal/Auth.ts +35 -9
  404. package/src/internal/Cache.ts +14 -7
  405. package/src/internal/EarnVaults.capabilities.test.ts +33 -0
  406. package/src/internal/EarnVaults.test.ts +79 -0
  407. package/src/internal/EarnVaults.ts +277 -0
  408. package/src/internal/Fetch.test.ts +46 -0
  409. package/src/internal/Fetch.ts +56 -0
  410. package/src/internal/Log.test.ts +21 -0
  411. package/src/internal/Log.ts +20 -5
  412. package/src/internal/OpenApi.ts +177 -51
  413. package/src/internal/Response.test.ts +95 -0
  414. package/src/internal/Response.ts +41 -3
  415. package/src/internal/Schema.test.ts +18 -0
  416. package/src/internal/Schema.ts +19 -9
  417. package/src/internal/Store.test.ts +364 -0
  418. package/src/internal/Store.ts +153 -27
  419. package/src/internal/Tidx.test.ts +21 -1
  420. package/src/internal/Tidx.ts +23 -6
  421. package/src/internal/Timeout.test.ts +35 -0
  422. package/src/internal/Timeout.ts +73 -0
  423. package/src/internal/Timing.ts +16 -0
  424. package/src/internal/WebhookDestination.ts +3 -0
  425. package/src/internal/Webhooks.test.ts +122 -8
  426. package/src/internal/Webhooks.ts +59 -29
  427. package/src/internal/funding/Action.test.ts +41 -1
  428. package/src/internal/funding/Action.ts +69 -41
  429. package/src/internal/funding/Catalog.test.ts +34 -0
  430. package/src/internal/funding/Catalog.ts +28 -11
  431. package/src/internal/funding/Deposit.ts +71 -64
  432. package/src/internal/funding/DepositAddress.ts +50 -43
  433. package/src/internal/funding/Provider.test.ts +73 -0
  434. package/src/internal/funding/Provider.ts +246 -170
  435. package/src/internal/funding/Transfer.ts +133 -110
  436. package/src/internal/funding/providers/index.test.ts +22 -0
  437. package/src/internal/funding/providers/relay.test.ts +2 -2
  438. package/src/internal/funding/providers/stargate.test.ts +163 -0
  439. package/src/internal/funding/providers/stargate.ts +409 -0
  440. package/src/internal/index.test.ts +1 -0
  441. package/src/internal/index.ts +1 -0
  442. package/src/providers/index.test.ts +1 -0
  443. package/src/providers/index.ts +9 -0
@@ -18,7 +18,26 @@ const redactedSlackUrl = 'https://hooks.slack.com/…'
18
18
  /** OpenAPI schemas owned by console webhook management. */
19
19
  export namespace schema {
20
20
  /** Public webhook subscription representation. */
21
- export const Subscription = webhookSchema.Subscription
21
+ export const Subscription = OpenApi.component(
22
+ z
23
+ .object({
24
+ ...webhookSchema.Subscription.shape,
25
+ context: webhookSchema.Subscription.shape.context.check(
26
+ z.meta({ examples: [{ title: 'Production transfers' }] }),
27
+ ),
28
+ destination: webhookSchema.Subscription.shape.destination.check(
29
+ z.meta({ examples: [{ type: 'url', url: 'https://example.com/webhooks' }] }),
30
+ ),
31
+ })
32
+ .check(z.describe('An organization webhook subscription.')),
33
+ 'OrganizationWebhook',
34
+ )
35
+
36
+ /** Webhook delivery data returned in collection rows. */
37
+ export const Delivery = OpenApi.component(
38
+ webhookSchema.Delivery,
39
+ 'OrganizationWebhookDeliverySummary',
40
+ )
22
41
 
23
42
  /** Schemas for creating an organization webhook. */
24
43
  export namespace createWebhook {
@@ -30,61 +49,119 @@ export namespace schema {
30
49
  )
31
50
 
32
51
  /** Organization webhook creation requires an explicit network. */
33
- export const Body = z
34
- .intersection(
35
- webhookSchema.createWebhook.Body,
36
- z.object({
37
- chainId: webhookSchema.Subscription.shape.chainId,
38
- environment: z.optional(Environment),
39
- }),
40
- )
41
- .check(
42
- z.refine(
43
- (body) => body.eventType !== 'funding:deposit.updated' || body.environment !== undefined,
44
- { error: '`environment` is required for funding deposit subscriptions.' },
52
+ export const Body = OpenApi.component(
53
+ z
54
+ .intersection(
55
+ webhookSchema.createWebhook.Body,
56
+ z.object({
57
+ chainId: webhookSchema.Subscription.shape.chainId,
58
+ environment: z.optional(Environment),
59
+ }),
60
+ )
61
+ .check(
62
+ z.refine(
63
+ (body) =>
64
+ body.eventType !== 'funding:deposit.updated' || body.environment !== undefined,
65
+ { error: '`environment` is required for funding deposit subscriptions.' },
66
+ ),
67
+ z.describe('Details for creating an organization webhook subscription.'),
45
68
  ),
46
- z.describe('Details for creating an organization webhook subscription.'),
47
- )
69
+ 'CreateOrganizationWebhookRequest',
70
+ )
48
71
 
49
72
  const secret = webhookSchema.createWebhook.Response.shape.secret
50
- const urlDestination = z.object({
51
- type: z.literal('url'),
52
- url: z
53
- .url()
54
- .check(
55
- z.describe('Your HTTPS endpoint where Tempo sends signed event POSTs.'),
56
- z.meta({ examples: ['https://example.com/webhooks'] }),
57
- ),
58
- })
59
- const slackDestination = z.object({
60
- type: z.literal('slack'),
61
- url: z.literal(redactedSlackUrl).check(z.describe('Redacted Slack webhook URL.')),
62
- })
63
- const betterstackDestination = z.object({
64
- token: z
65
- .literal(redactedBetterstackToken)
66
- .check(z.describe('Redacted Better Stack source token.')),
67
- type: z.literal('betterstack'),
68
- url: z
69
- .url()
70
- .check(
71
- z.describe('Your Better Stack source ingest host URL.'),
72
- z.meta({ examples: ['https://s1234567.eu-nbg-2.betterstackdata.com'] }),
73
- ),
74
- })
73
+ const urlDestination = z
74
+ .object({
75
+ type: z
76
+ .literal('url')
77
+ .check(z.describe('HTTPS destination.'), z.meta({ examples: ['url'] })),
78
+ url: z
79
+ .url()
80
+ .check(
81
+ z.describe('Your HTTPS endpoint where Tempo sends signed event POSTs.'),
82
+ z.meta({ examples: ['https://example.com/webhooks'] }),
83
+ ),
84
+ })
85
+ .check(
86
+ z.describe('HTTPS webhook destination.'),
87
+ z.meta({ examples: [{ type: 'url', url: 'https://example.com/webhooks' }] }),
88
+ )
89
+ const slackDestination = z
90
+ .object({
91
+ type: z
92
+ .literal('slack')
93
+ .check(z.describe('Slack destination.'), z.meta({ examples: ['slack'] })),
94
+ url: z
95
+ .literal(redactedSlackUrl)
96
+ .check(
97
+ z.describe('Redacted Slack webhook URL.'),
98
+ z.meta({ examples: [redactedSlackUrl] }),
99
+ ),
100
+ })
101
+ .check(
102
+ z.describe('Slack webhook destination with its URL redacted.'),
103
+ z.meta({ examples: [{ type: 'slack', url: redactedSlackUrl }] }),
104
+ )
105
+ const betterstackDestination = z
106
+ .object({
107
+ token: z
108
+ .literal(redactedBetterstackToken)
109
+ .check(
110
+ z.describe('Redacted Better Stack source token.'),
111
+ z.meta({ examples: [redactedBetterstackToken] }),
112
+ ),
113
+ type: z
114
+ .literal('betterstack')
115
+ .check(z.describe('Better Stack destination.'), z.meta({ examples: ['betterstack'] })),
116
+ url: z
117
+ .url()
118
+ .check(
119
+ z.describe('Your Better Stack source ingest host URL.'),
120
+ z.meta({ examples: ['https://s1234567.eu-nbg-2.betterstackdata.com'] }),
121
+ ),
122
+ })
123
+ .check(
124
+ z.describe('Better Stack destination with its token redacted.'),
125
+ z.meta({
126
+ examples: [
127
+ {
128
+ token: redactedBetterstackToken,
129
+ type: 'betterstack',
130
+ url: 'https://s1234567.eu-nbg-2.betterstackdata.com',
131
+ },
132
+ ],
133
+ }),
134
+ )
135
+ const UrlResponse = OpenApi.component(
136
+ z
137
+ .object({ ...Subscription.shape, destination: urlDestination, secret })
138
+ .check(z.describe('Created HTTPS webhook with its one-time signing secret.')),
139
+ 'CreateOrganizationWebhookUrlResponse',
140
+ )
141
+ const SlackResponse = OpenApi.component(
142
+ z
143
+ .object({ ...Subscription.shape, destination: slackDestination })
144
+ .check(z.describe('Created Slack webhook with its destination redacted.')),
145
+ 'CreateOrganizationWebhookSlackResponse',
146
+ )
147
+ const BetterstackResponse = OpenApi.component(
148
+ z
149
+ .object({ ...Subscription.shape, destination: betterstackDestination })
150
+ .check(z.describe('Created Better Stack webhook with its credentials redacted.')),
151
+ 'CreateOrganizationWebhookBetterstackResponse',
152
+ )
75
153
 
76
154
  /** Created webhook with transport credentials redacted. */
77
- export const Response = z
78
- .union([
79
- z.object({ ...Subscription.shape, destination: urlDestination, secret }),
80
- z.object({ ...Subscription.shape, destination: slackDestination }),
81
- z.object({ ...Subscription.shape, destination: betterstackDestination }),
82
- ])
83
- .check(
84
- z.describe(
85
- 'The new webhook subscription. HTTPS endpoints include their one-time signing secret.',
155
+ export const Response = OpenApi.component(
156
+ z
157
+ .union([UrlResponse, SlackResponse, BetterstackResponse])
158
+ .check(
159
+ z.describe(
160
+ 'The new webhook subscription. HTTPS endpoints include their one-time signing secret.',
161
+ ),
86
162
  ),
87
- )
163
+ 'CreateOrganizationWebhookResponse',
164
+ )
88
165
  }
89
166
 
90
167
  /** Organization webhook collection parameters. */
@@ -116,7 +193,23 @@ export namespace schema {
116
193
  export namespace listWebhookDeliveries {
117
194
  export const Params = WebhookParams
118
195
  export const Query = webhookSchema.listWebhookDeliveries.Query
119
- export const Response = webhookSchema.listWebhookDeliveries.Response
196
+ export const Response = OpenApi.component(
197
+ z
198
+ .object({
199
+ data: z
200
+ .array(Delivery)
201
+ .check(
202
+ z.describe('Webhook delivery attempts on this page.'),
203
+ z.meta({ examples: [[]] }),
204
+ ),
205
+ meta: webhookSchema.listWebhookDeliveries.Response.shape.meta.check(
206
+ z.meta({ examples: [{ totalCount: 1, totalCountCapped: false }] }),
207
+ ),
208
+ nextCursor: webhookSchema.listWebhookDeliveries.Response.shape.nextCursor,
209
+ })
210
+ .check(z.describe("A page of an organization's webhook delivery attempts.")),
211
+ 'OrganizationWebhookDeliveryList',
212
+ )
120
213
  }
121
214
 
122
215
  const DeliveryParams = z
@@ -130,43 +223,63 @@ export namespace schema {
130
223
  /** Schemas for loading one organization webhook delivery. */
131
224
  export namespace getWebhookDelivery {
132
225
  export const Params = DeliveryParams
133
- export const Response = z
134
- .object({
135
- ...webhookSchema.Delivery.shape,
136
- envelope: webhookSchema.Envelope,
137
- })
138
- .check(z.describe('A webhook delivery attempt with the exact JSON payload Tempo sent.'))
226
+ export const Response = OpenApi.component(
227
+ z
228
+ .object({
229
+ ...Delivery.shape,
230
+ envelope: webhookSchema.Envelope,
231
+ })
232
+ .check(z.describe('A webhook delivery attempt with the exact JSON payload Tempo sent.')),
233
+ 'OrganizationWebhookDelivery',
234
+ )
139
235
  }
140
236
 
141
237
  /** Schemas for replaying one organization webhook delivery. */
142
238
  export namespace retryWebhookDelivery {
143
239
  export const Params = DeliveryParams
144
- export const Response = webhookSchema.retryWebhookDelivery.Response
240
+ export const Response = OpenApi.component(
241
+ webhookSchema.retryWebhookDelivery.Response,
242
+ 'RetryOrganizationWebhookDeliveryResponse',
243
+ )
145
244
  }
146
245
 
147
246
  /** Non-paginated organization webhook list. */
148
- export const ListResponse = z
149
- .object({
150
- data: z.array(Subscription).check(z.describe("The organization's webhooks, newest first.")),
151
- })
152
- .check(z.describe("An organization's webhook subscriptions."))
247
+ export const ListResponse = OpenApi.component(
248
+ z
249
+ .object({
250
+ data: z
251
+ .array(Subscription)
252
+ .check(
253
+ z.describe("The organization's webhooks, newest first."),
254
+ z.meta({ examples: [[]] }),
255
+ ),
256
+ })
257
+ .check(z.describe("An organization's webhook subscriptions.")),
258
+ 'OrganizationWebhookList',
259
+ )
153
260
 
154
261
  /** Lifecycle state editable from the console. */
155
- export const UpdateBody = z
156
- .object({ status: webhookSchema.Status })
157
- .check(z.describe('New delivery state for a webhook subscription.'))
262
+ export const UpdateBody = OpenApi.component(
263
+ z
264
+ .object({ status: webhookSchema.Status })
265
+ .check(z.describe('New delivery state for a webhook subscription.')),
266
+ 'UpdateOrganizationWebhookRequest',
267
+ )
158
268
 
159
269
  /** Webhook deletion confirmation. */
160
- export const DeleteResponse = z
161
- .object({
162
- id: z
163
- .string()
164
- .check(
165
- z.describe('Deleted webhook subscription id.'),
166
- z.meta({ examples: ['wh_001718668800000_2ZPE2gvateYEQ0dQslgvkhjx'] }),
167
- ),
168
- })
169
- .check(z.describe('Confirmation that a webhook subscription was deleted.'))
270
+ export const DeleteResponse = OpenApi.component(
271
+ z
272
+ .object({
273
+ id: z
274
+ .string()
275
+ .check(
276
+ z.describe('Deleted webhook subscription id.'),
277
+ z.meta({ examples: ['wh_001718668800000_2ZPE2gvateYEQ0dQslgvkhjx'] }),
278
+ ),
279
+ })
280
+ .check(z.describe('Confirmation that a webhook subscription was deleted.')),
281
+ 'DeleteOrganizationWebhookResponse',
282
+ )
170
283
  }
171
284
 
172
285
  const bodyValidation = {
@@ -542,7 +655,7 @@ export function webhooks(options: webhooks.Options = {}) {
542
655
  },
543
656
  success: {
544
657
  description: 'Updated webhook.',
545
- schema: webhookSchema.Subscription,
658
+ schema: schema.Subscription,
546
659
  },
547
660
  }),
548
661
  summary: 'Update webhook',
@@ -564,7 +677,7 @@ export function webhooks(options: webhooks.Options = {}) {
564
677
  )
565
678
  if (!subscription) return notFound(c)
566
679
  return c.json(
567
- Response.validated(webhookSchema.Subscription, publicSubscription(subscription)),
680
+ Response.validated(schema.Subscription, publicSubscription(subscription)),
568
681
  200,
569
682
  )
570
683
  } catch (cause) {
@@ -1,9 +1,10 @@
1
1
  import * as Mppx from 'mppx'
2
2
  import { tempo } from 'mppx/server'
3
+ import { maxUint256 } from 'viem'
3
4
  import type { LocalAccount } from 'viem/accounts'
4
5
 
5
- import type * as Viem from '../../../internal/Viem.js'
6
6
  import * as Store from '../../../internal/Store.js'
7
+ import * as Viem from '../../../internal/Viem.js'
7
8
  import * as Mpp from '../Mpp.js'
8
9
  import * as MppError from './Error.js'
9
10
  import * as Screening from './Screening.js'
@@ -37,9 +38,20 @@ export function create(options: create.Options): Adapter {
37
38
  store: screeningStore,
38
39
  ttl: screeningTtl,
39
40
  })
41
+ // Moderato fees exceed MPPX defaults; preserve its gas cap and bound each
42
+ // sponsored transaction to $1.
43
+ const feePayerPolicy =
44
+ chainId === Viem.chainId.testnet
45
+ ? {
46
+ maxFeePerGas: maxUint256,
47
+ maxPriorityFeePerGas: maxUint256,
48
+ maxTotalFee: 1_000_000_000_000_000_000n,
49
+ }
50
+ : undefined
40
51
  const methods = [
41
52
  tempo.charge({
42
53
  ...(feePayer ? { feePayer } : {}),
54
+ ...(feePayerPolicy ? { feePayerPolicy } : {}),
43
55
  getClient: ({ chainId: chainId_option }) =>
44
56
  getClient(chainId_option as Viem.ChainId | undefined),
45
57
  store: Utils.mppxStore(state),
package/src/db/Db.test.ts CHANGED
@@ -3,6 +3,7 @@ import { nanoid } from 'nanoid'
3
3
 
4
4
  import * as Runtime from '../../test/runtime.js'
5
5
  import * as Db from './Db.js'
6
+ import * as Webhooks from '../internal/Webhooks.js'
6
7
  import * as Invitations from './tables/invitations.js'
7
8
  import * as Organizations from './tables/organizations.js'
8
9
  import * as WebhookSubscriptions from './tables/webhookSubscriptions.js'
@@ -35,6 +36,46 @@ describe('postgres', () => {
35
36
  await db.close()
36
37
  })
37
38
 
39
+ test('behavior: raw webhook staging respects schema scoping', async () => {
40
+ // Exercises the one raw statement against a schema-scoped db whose only
41
+ // qualification is WithSchemaPlugin, matching preview Workers: migrate on
42
+ // one pool (whose session gains a search_path), then query from a fresh
43
+ // pool that never ran it.
44
+ const schema = `t_${nanoid()}`
45
+ const migrator = Db.postgres({ connectionString: Runtime.postgresUrl, schema })
46
+ await migrator.migrate()
47
+ await migrator.close()
48
+ const db = Db.postgres({ connectionString: Runtime.postgresUrl, schema })
49
+ const subscription = await Webhooks.createSubscription(db, {
50
+ chainId: 4217,
51
+ destination: { type: 'url', url: 'https://hooks.example.com/endpoint' },
52
+ eventType: 'token:transfer',
53
+ owner: { orgId: 'org_1', type: 'api_key' },
54
+ })
55
+ const envelope = Webhooks.buildEnvelope({
56
+ blockNumber: 123,
57
+ createdAt: new Date(),
58
+ data: { amount: '1' },
59
+ logIndex: 4,
60
+ subscription,
61
+ })
62
+
63
+ const staged = await Webhooks.ensureQueueEvents(db, [{ envelope, subscription }])
64
+ expect(staged.created).toBe(1)
65
+ const claim = await Webhooks.claimQueueEvent(db, staged.references[0]!)
66
+ if (claim.type !== 'claimed') throw new Error(`Unexpected claim: ${claim.type}`)
67
+ await Webhooks.completeQueueEvent(db, staged.references[0]!, {
68
+ claimedAt: claim.record.attemptingAt!,
69
+ status: 'succeeded',
70
+ })
71
+
72
+ // The completion read inside the same raw statement must also resolve
73
+ // inside the schema for the replay to be suppressed.
74
+ const replay = await Webhooks.ensureQueueEvents(db, [{ envelope, subscription }])
75
+ expect(replay.created).toBe(0)
76
+ await db.close()
77
+ })
78
+
38
79
  test('behavior: creates a Postgres db without schema scoping', async () => {
39
80
  const db = Db.postgres({ connectionString: Runtime.postgresUrl })
40
81
  await db.close()
package/src/db/Db.ts CHANGED
@@ -36,6 +36,7 @@ import type * as Users from './tables/users.js'
36
36
  import type * as VerifiedTokenRequests from './tables/verifiedTokenRequests.js'
37
37
  import type * as VerifiedTokens from './tables/verifiedTokens.js'
38
38
  import type * as WebhookDeliveries from './tables/webhookDeliveries.js'
39
+ import type * as WebhookQueueCompletions from './tables/webhookQueueCompletions.js'
39
40
  import type * as WebhookQueueEvents from './tables/webhookQueueEvents.js'
40
41
  import type * as WebhookSubscriptions from './tables/webhookSubscriptions.js'
41
42
 
@@ -83,6 +84,7 @@ export type Database = {
83
84
  verified_token_requests: VerifiedTokenRequests.Table
84
85
  verified_tokens: VerifiedTokens.Table
85
86
  webhook_deliveries: WebhookDeliveries.Table
87
+ webhook_queue_completions: WebhookQueueCompletions.Table
86
88
  webhook_queue_events: WebhookQueueEvents.Table
87
89
  webhook_subscriptions: WebhookSubscriptions.Table
88
90
  }
@@ -1421,6 +1423,71 @@ export const migrations: readonly Migration[] = [
1421
1423
  up: (db) =>
1422
1424
  raw(db, sql`ALTER TABLE webhook_queue_events ADD COLUMN IF NOT EXISTS observed_at text`),
1423
1425
  },
1426
+ {
1427
+ name: '0131_webhook_queue_completions',
1428
+ up: (db) =>
1429
+ db.schema
1430
+ .createTable('webhookQueueCompletions')
1431
+ .ifNotExists()
1432
+ .addColumn('subscriptionId', 'text', (c) =>
1433
+ c.notNull().references('webhookSubscriptions.id').onDelete('cascade'),
1434
+ )
1435
+ .addColumn('eventId', 'text', (c) => c.notNull())
1436
+ .addColumn('status', 'text', (c) => c.notNull())
1437
+ .addColumn('expiresAt', 'text', (c) => c.notNull())
1438
+ .addPrimaryKeyConstraint('webhook_queue_completions_pkey', ['subscriptionId', 'eventId'])
1439
+ .addCheckConstraint(
1440
+ 'webhook_queue_completions_status_check',
1441
+ sql`status IN ('failed', 'skipped', 'succeeded')`,
1442
+ ),
1443
+ },
1444
+ {
1445
+ name: '0132_webhook_queue_completions_expires_index',
1446
+ up: (db) =>
1447
+ db.schema
1448
+ .createIndex('webhook_queue_completions_expires_idx')
1449
+ .ifNotExists()
1450
+ .on('webhookQueueCompletions')
1451
+ .column('expiresAt'),
1452
+ },
1453
+ {
1454
+ // Stock thresholds let ~2M dead tuples accumulate before vacuuming, then
1455
+ // grind gigabytes at once; frequent small vacuums keep indexes usable.
1456
+ name: '0133_webhook_queue_events_autovacuum',
1457
+ up: (db) =>
1458
+ raw(
1459
+ db,
1460
+ sql`ALTER TABLE webhook_queue_events SET (autovacuum_vacuum_scale_factor = 0.01, autovacuum_vacuum_cost_limit = 2000)`,
1461
+ ),
1462
+ },
1463
+ {
1464
+ // New code stops writing queue-event expiry: completions own the dedupe
1465
+ // window, so the column is nullable and inert.
1466
+ name: '0134_webhook_queue_events_expires_nullable',
1467
+ up: (db) =>
1468
+ raw(db, sql`ALTER TABLE webhook_queue_events ALTER COLUMN expires_at DROP NOT NULL`),
1469
+ },
1470
+ {
1471
+ name: '0135_webhook_queue_completions_autovacuum',
1472
+ up: (db) =>
1473
+ raw(
1474
+ db,
1475
+ sql`ALTER TABLE webhook_queue_completions SET (autovacuum_vacuum_scale_factor = 0.01, autovacuum_vacuum_cost_limit = 2000)`,
1476
+ ),
1477
+ },
1478
+ {
1479
+ name: '0136_earn_vault_zones',
1480
+ up: (db) =>
1481
+ raw(
1482
+ db,
1483
+ sql`ALTER TABLE earn_vaults ADD COLUMN IF NOT EXISTS zones jsonb NOT NULL DEFAULT '[]'::jsonb`,
1484
+ ),
1485
+ },
1486
+ {
1487
+ name: '0137_funding_routes_configuration',
1488
+ up: (db) =>
1489
+ raw(db, sql`ALTER TABLE funding_routes ADD COLUMN IF NOT EXISTS configuration jsonb`),
1490
+ },
1424
1491
  ]
1425
1492
 
1426
1493
  /**
@@ -1558,7 +1625,14 @@ declare namespace fromDialect {
1558
1625
  */
1559
1626
  export function postgres(options: postgres.Options): Db {
1560
1627
  const { connectionString, schema } = options
1561
- const pool = new pg.Pool(schema ? { connectionString, max: 1 } : { connectionString })
1628
+ // Bounded connect and pool-checkout wait: the pg default (0) waits forever,
1629
+ // so an unresponsive origin parks callers and their invocation memory
1630
+ // invisibly instead of failing into the retry paths.
1631
+ const pool = new pg.Pool({
1632
+ connectionString,
1633
+ connectionTimeoutMillis: 30_000,
1634
+ ...(schema ? { max: 1 } : {}),
1635
+ })
1562
1636
  return fromDialect(new PostgresDialect({ pool }), { schema })
1563
1637
  }
1564
1638
 
package/src/db/Schema.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as z from 'zod/mini'
2
2
  import type { Address } from 'viem'
3
3
 
4
+ import type * as EarnVaults from '../internal/EarnVaults.js'
4
5
  import type * as funding_Catalog from '../internal/funding/Catalog.js'
5
6
  import type * as funding_Deposit from '../internal/funding/Deposit.js'
6
7
  import type * as funding_DepositAddress from '../internal/funding/DepositAddress.js'
@@ -106,6 +107,9 @@ export const EarnVault = z
106
107
  slug: z.string().check(z.describe('Stable URL slug assigned when the vault is registered.')),
107
108
  updatedAt: z.string().check(z.describe('When the vault registration last changed (ISO 8601).')),
108
109
  vaultAddress: z.custom<Address>().check(z.describe('Earn vault address (lowercase).')),
110
+ zones: z
111
+ .custom<readonly EarnVaults.ZoneRoute[]>()
112
+ .check(z.describe('Curated private Zone routes (`jsonb`).')),
109
113
  })
110
114
  .check(z.describe('One curated Earn vault row.'))
111
115
 
@@ -449,11 +453,14 @@ export type FundingChainToken = z.output<typeof FundingChainToken>
449
453
 
450
454
  /** One source-to-destination route supported by a funding provider. */
451
455
  export const FundingRoute = z.object({
452
- destinationChainId: z.string().check(z.describe('Destination funding chain identifier.')),
453
- destinationTokenId: z.string().check(z.describe('Destination funding token identifier.')),
454
456
  capabilities: z
455
457
  .nullable(z.custom<funding_Catalog.Capabilities>())
456
458
  .check(z.describe('Executable capability (`jsonb`), or null for indicative-only routes.')),
459
+ configuration: z
460
+ .nullable(z.custom<funding_Catalog.Configuration>())
461
+ .check(z.describe('Provider-specific route configuration (`jsonb`), or null.')),
462
+ destinationChainId: z.string().check(z.describe('Destination funding chain identifier.')),
463
+ destinationTokenId: z.string().check(z.describe('Destination funding token identifier.')),
457
464
  providerId: z.string().check(z.describe('Funding provider identifier.')),
458
465
  sourceChainId: z.string().check(z.describe('Source funding chain identifier.')),
459
466
  sourceTokenId: z.string().check(z.describe('Source funding token identifier.')),
@@ -881,6 +888,23 @@ export const WebhookDelivery = z.object({
881
888
  /** Columns of the `webhook_deliveries` table. */
882
889
  export type WebhookDelivery = z.output<typeof WebhookDelivery>
883
890
 
891
+ /** An insert-only dedupe record marking a delivery obligation terminal. */
892
+ export const WebhookQueueCompletion = z.object({
893
+ eventId: z.string().check(z.describe('Idempotent event id (`evt_...`).')),
894
+ expiresAt: z
895
+ .string()
896
+ .check(z.describe('ISO dedupe retention deadline; rows past it are invisible and pruned.')),
897
+ status: z
898
+ .enum(['failed', 'skipped', 'succeeded'])
899
+ .check(z.describe('Terminal delivery-obligation outcome.')),
900
+ subscriptionId: z
901
+ .string()
902
+ .check(z.describe('Owning subscription id (`wh_...`); FK with `ON DELETE CASCADE`.')),
903
+ })
904
+
905
+ /** Columns of the `webhook_queue_completions` table. */
906
+ export type WebhookQueueCompletion = z.output<typeof WebhookQueueCompletion>
907
+
884
908
  /** A durable webhook envelope staged before its compact Queue reference is admitted. */
885
909
  export const WebhookQueueEvent = z.object({
886
910
  attemptCount: z.number().check(z.describe('Delivery attempts claimed so far.')),
@@ -893,10 +917,10 @@ export const WebhookQueueEvent = z.object({
893
917
  .check(z.describe('The full webhook envelope retained outside Cloudflare Queues.')),
894
918
  eventId: z.string().check(z.describe('Idempotent event id (`evt_...`).')),
895
919
  expiresAt: z
896
- .string()
920
+ .nullable(z.string())
897
921
  .check(
898
922
  z.describe(
899
- 'ISO dedupe retention deadline, restarted at terminal transitions; inert while pending.',
923
+ 'Unwritten since completions took over dedupe; non-null only on rows staged before the split.',
900
924
  ),
901
925
  ),
902
926
  nextAttemptAt: z
@@ -911,7 +935,11 @@ export const WebhookQueueEvent = z.object({
911
935
  ),
912
936
  status: z
913
937
  .enum(['failed', 'pending', 'skipped', 'succeeded'])
914
- .check(z.describe('Delivery-obligation lifecycle status.')),
938
+ .check(
939
+ z.describe(
940
+ 'Always `pending` since completions took over terminal state; other values occur only on rows completed before the split.',
941
+ ),
942
+ ),
915
943
  subscriptionId: z
916
944
  .string()
917
945
  .check(z.describe('Owning subscription id (`wh_...`); FK with `ON DELETE CASCADE`.')),
@@ -11,6 +11,13 @@ const input = {
11
11
  ],
12
12
  privateOutputTokens: ['0x20c00000000000000000000057F242B21a53ae4D'],
13
13
  vaultAddress: '0x2f05f4d3625B2eFFb383eFbEDAFd2D8F04371636',
14
+ zones: [
15
+ {
16
+ chainId: 1_424_310_003,
17
+ deploymentBlock: 31_730_087,
18
+ earnRouter: '0xeBEdC74FFeEAD186ACC6caC05Eb82fB9e093a7c7',
19
+ },
20
+ ],
14
21
  } as const satisfies EarnVaults.upsert.Options
15
22
 
16
23
  describe('upsert', () => {
@@ -36,6 +43,13 @@ describe('upsert', () => {
36
43
  ],
37
44
  "updatedAt": "2026-01-01T00:00:00.000Z",
38
45
  "vaultAddress": "0x2f05f4d3625b2effb383efbedafd2d8f04371636",
46
+ "zones": [
47
+ {
48
+ "chainId": 1424310003,
49
+ "deploymentBlock": 31730087,
50
+ "earnRouter": "0xebedc74ffeead186acc6cac05eb82fb9e093a7c7",
51
+ },
52
+ ],
39
53
  }
40
54
  `)
41
55
  } finally {
@@ -68,6 +82,7 @@ describe('upsert', () => {
68
82
  privateInputTokens: stored.privateInputTokens,
69
83
  privateOutputTokens: stored.privateOutputTokens,
70
84
  updatedAt: stored.updatedAt,
85
+ zones: stored.zones,
71
86
  }).toMatchInlineSnapshot(`
72
87
  {
73
88
  "createdAt": "2026-01-01T00:00:00.000Z",
@@ -76,6 +91,13 @@ describe('upsert', () => {
76
91
  "privateInputTokens": [],
77
92
  "privateOutputTokens": [],
78
93
  "updatedAt": "2026-01-02T00:00:00.000Z",
94
+ "zones": [
95
+ {
96
+ "chainId": 1424310003,
97
+ "deploymentBlock": 31730087,
98
+ "earnRouter": "0xebedc74ffeead186acc6cac05eb82fb9e093a7c7",
99
+ },
100
+ ],
79
101
  }
80
102
  `)
81
103