tapimo 0.1.0 → 0.3.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 (520) hide show
  1. package/README.md +57 -16
  2. package/dist/ApiKey.d.ts +4 -1
  3. package/dist/ApiKey.d.ts.map +1 -1
  4. package/dist/ApiKey.js +6 -2
  5. package/dist/ApiKey.js.map +1 -1
  6. package/dist/ApiKeys.d.ts +98 -3
  7. package/dist/ApiKeys.d.ts.map +1 -1
  8. package/dist/ApiKeys.js +150 -1
  9. package/dist/ApiKeys.js.map +1 -1
  10. package/dist/App.d.ts +7917 -2315
  11. package/dist/App.d.ts.map +1 -1
  12. package/dist/App.js +141 -329
  13. package/dist/App.js.map +1 -1
  14. package/dist/Scope.d.ts +20 -4
  15. package/dist/Scope.d.ts.map +1 -1
  16. package/dist/Scope.js +23 -4
  17. package/dist/Scope.js.map +1 -1
  18. package/dist/Webhooks.d.ts +2 -2
  19. package/dist/Webhooks.d.ts.map +1 -1
  20. package/dist/Webhooks.js +2 -2
  21. package/dist/Webhooks.js.map +1 -1
  22. package/dist/admin/App.d.ts +203 -120
  23. package/dist/admin/App.d.ts.map +1 -1
  24. package/dist/admin/apps/api-keys.d.ts +111 -6
  25. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  26. package/dist/admin/apps/api-keys.js +67 -0
  27. package/dist/admin/apps/api-keys.js.map +1 -1
  28. package/dist/admin/apps/scopes.d.ts +12 -1
  29. package/dist/admin/apps/scopes.d.ts.map +1 -1
  30. package/dist/admin/apps/scopes.js +3 -0
  31. package/dist/admin/apps/scopes.js.map +1 -1
  32. package/dist/admin/apps/verified-tokens.d.ts +116 -116
  33. package/dist/admin/apps/verified-tokens.js +1 -1
  34. package/dist/admin/apps/verified-tokens.js.map +1 -1
  35. package/dist/admin/ui.generated.d.ts +1 -1
  36. package/dist/admin/ui.generated.js +13 -13
  37. package/dist/admin/ui.generated.js.map +1 -1
  38. package/dist/analytics/Analytics.d.ts +151 -0
  39. package/dist/analytics/Analytics.d.ts.map +1 -0
  40. package/dist/analytics/Analytics.js +212 -0
  41. package/dist/analytics/Analytics.js.map +1 -0
  42. package/dist/analytics/tables/requestEvents.d.ts +215 -0
  43. package/dist/analytics/tables/requestEvents.d.ts.map +1 -0
  44. package/dist/analytics/tables/requestEvents.js +264 -0
  45. package/dist/analytics/tables/requestEvents.js.map +1 -0
  46. package/dist/apps/data/App.d.ts +19576 -0
  47. package/dist/apps/data/App.d.ts.map +1 -0
  48. package/dist/apps/data/App.js +272 -0
  49. package/dist/apps/data/App.js.map +1 -0
  50. package/dist/apps/data/index.d.ts +3 -0
  51. package/dist/apps/data/index.d.ts.map +1 -0
  52. package/dist/apps/data/index.js +3 -0
  53. package/dist/apps/data/index.js.map +1 -0
  54. package/dist/apps/{activities.d.ts → data/routes/activities.d.ts} +32 -32
  55. package/dist/apps/{activities.d.ts.map → data/routes/activities.d.ts.map} +1 -1
  56. package/dist/apps/{activities.js → data/routes/activities.js} +13 -13
  57. package/dist/apps/data/routes/activities.js.map +1 -0
  58. package/dist/apps/{addresses.d.ts → data/routes/addresses.d.ts} +22 -22
  59. package/dist/apps/{addresses.d.ts.map → data/routes/addresses.d.ts.map} +1 -1
  60. package/dist/apps/{addresses.js → data/routes/addresses.js} +5 -5
  61. package/dist/apps/data/routes/addresses.js.map +1 -0
  62. package/dist/apps/{balances.d.ts → data/routes/balances.d.ts} +4 -4
  63. package/dist/apps/data/routes/balances.d.ts.map +1 -0
  64. package/dist/apps/{balances.js → data/routes/balances.js} +42 -11
  65. package/dist/apps/data/routes/balances.js.map +1 -0
  66. package/dist/apps/{blocks.d.ts → data/routes/blocks.d.ts} +47 -47
  67. package/dist/apps/data/routes/blocks.d.ts.map +1 -0
  68. package/dist/apps/{blocks.js → data/routes/blocks.js} +13 -13
  69. package/dist/apps/data/routes/blocks.js.map +1 -0
  70. package/dist/apps/{coingecko.d.ts → data/routes/coingecko.d.ts} +8 -8
  71. package/dist/apps/data/routes/coingecko.d.ts.map +1 -0
  72. package/dist/apps/{coingecko.js → data/routes/coingecko.js} +13 -13
  73. package/dist/apps/data/routes/coingecko.js.map +1 -0
  74. package/dist/apps/{exchanges.d.ts → data/routes/exchanges.d.ts} +108 -108
  75. package/dist/apps/data/routes/exchanges.d.ts.map +1 -0
  76. package/dist/apps/{exchanges.js → data/routes/exchanges.js} +19 -19
  77. package/dist/apps/data/routes/exchanges.js.map +1 -0
  78. package/dist/apps/{fee-amm.d.ts → data/routes/fee-amm.d.ts} +39 -39
  79. package/dist/apps/data/routes/fee-amm.d.ts.map +1 -0
  80. package/dist/apps/{fee-amm.js → data/routes/fee-amm.js} +17 -17
  81. package/dist/apps/data/routes/fee-amm.js.map +1 -0
  82. package/dist/apps/data/routes/funding.d.ts +765 -0
  83. package/dist/apps/data/routes/funding.d.ts.map +1 -0
  84. package/dist/apps/data/routes/funding.js +383 -0
  85. package/dist/apps/data/routes/funding.js.map +1 -0
  86. package/dist/apps/{indexer.d.ts → data/routes/indexer.d.ts} +4 -4
  87. package/dist/apps/data/routes/indexer.d.ts.map +1 -0
  88. package/dist/apps/{indexer.js → data/routes/indexer.js} +13 -9
  89. package/dist/apps/data/routes/indexer.js.map +1 -0
  90. package/dist/apps/{receipts.d.ts → data/routes/receipts.d.ts} +49 -49
  91. package/dist/apps/data/routes/receipts.d.ts.map +1 -0
  92. package/dist/apps/{receipts.js → data/routes/receipts.js} +14 -20
  93. package/dist/apps/data/routes/receipts.js.map +1 -0
  94. package/dist/apps/{rpc.d.ts → data/routes/rpc.d.ts} +33 -40
  95. package/dist/apps/data/routes/rpc.d.ts.map +1 -0
  96. package/dist/apps/{rpc.js → data/routes/rpc.js} +35 -7
  97. package/dist/apps/data/routes/rpc.js.map +1 -0
  98. package/dist/apps/{tokenlist.d.ts → data/routes/tokenlist.d.ts} +40 -40
  99. package/dist/apps/data/routes/tokenlist.d.ts.map +1 -0
  100. package/dist/apps/{tokenlist.js → data/routes/tokenlist.js} +8 -8
  101. package/dist/apps/data/routes/tokenlist.js.map +1 -0
  102. package/dist/apps/{tokens.d.ts → data/routes/tokens.d.ts} +468 -468
  103. package/dist/apps/data/routes/tokens.d.ts.map +1 -0
  104. package/dist/apps/{tokens.js → data/routes/tokens.js} +19 -19
  105. package/dist/apps/data/routes/tokens.js.map +1 -0
  106. package/dist/apps/{transactions.d.ts → data/routes/transactions.d.ts} +304 -304
  107. package/dist/apps/data/routes/transactions.d.ts.map +1 -0
  108. package/dist/apps/{transactions.js → data/routes/transactions.js} +13 -13
  109. package/dist/apps/data/routes/transactions.js.map +1 -0
  110. package/dist/apps/{transfers.d.ts → data/routes/transfers.d.ts} +62 -62
  111. package/dist/apps/data/routes/transfers.d.ts.map +1 -0
  112. package/dist/apps/{transfers.js → data/routes/transfers.js} +13 -13
  113. package/dist/apps/data/routes/transfers.js.map +1 -0
  114. package/dist/apps/{verified-tokens.d.ts → data/routes/verified-tokens.d.ts} +6 -6
  115. package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -0
  116. package/dist/apps/{verified-tokens.js → data/routes/verified-tokens.js} +9 -9
  117. package/dist/apps/data/routes/verified-tokens.js.map +1 -0
  118. package/dist/apps/{webhooks.d.ts → data/routes/webhooks.d.ts} +17 -17
  119. package/dist/apps/{webhooks.d.ts.map → data/routes/webhooks.d.ts.map} +1 -1
  120. package/dist/apps/{webhooks.js → data/routes/webhooks.js} +38 -34
  121. package/dist/apps/data/routes/webhooks.js.map +1 -0
  122. package/dist/apps/docs/App.d.ts +29 -0
  123. package/dist/apps/docs/App.d.ts.map +1 -0
  124. package/dist/apps/docs/App.js +54 -0
  125. package/dist/apps/docs/App.js.map +1 -0
  126. package/dist/{internal/OpenApi.fonts.d.ts → apps/docs/fonts.d.ts} +1 -1
  127. package/dist/apps/docs/fonts.d.ts.map +1 -0
  128. package/dist/{internal/OpenApi.fonts.js → apps/docs/fonts.js} +1 -1
  129. package/dist/apps/docs/fonts.js.map +1 -0
  130. package/dist/apps/docs/index.d.ts +2 -0
  131. package/dist/apps/docs/index.d.ts.map +1 -0
  132. package/dist/apps/docs/index.js +2 -0
  133. package/dist/apps/docs/index.js.map +1 -0
  134. package/dist/{internal/OpenApi.logo.d.ts → apps/docs/logo.d.ts} +1 -1
  135. package/dist/apps/docs/logo.d.ts.map +1 -0
  136. package/dist/{internal/OpenApi.logo.js → apps/docs/logo.js} +1 -1
  137. package/dist/apps/docs/logo.js.map +1 -0
  138. package/dist/apps/docs/reference.d.ts +21 -0
  139. package/dist/apps/docs/reference.d.ts.map +1 -0
  140. package/dist/apps/docs/reference.js +112 -0
  141. package/dist/apps/docs/reference.js.map +1 -0
  142. package/dist/apps/index.d.ts +5 -0
  143. package/dist/apps/index.d.ts.map +1 -0
  144. package/dist/apps/index.js +5 -0
  145. package/dist/apps/index.js.map +1 -0
  146. package/dist/apps/mcp.d.ts +76 -0
  147. package/dist/apps/mcp.d.ts.map +1 -0
  148. package/dist/apps/mcp.js +188 -0
  149. package/dist/apps/mcp.js.map +1 -0
  150. package/dist/apps/metadata.d.ts +7 -0
  151. package/dist/apps/metadata.d.ts.map +1 -0
  152. package/dist/apps/metadata.js +15 -0
  153. package/dist/apps/metadata.js.map +1 -0
  154. package/dist/apps/platform/App.d.ts +5262 -0
  155. package/dist/apps/platform/App.d.ts.map +1 -0
  156. package/dist/apps/platform/App.js +84 -0
  157. package/dist/apps/platform/App.js.map +1 -0
  158. package/dist/apps/platform/Billing.d.ts +279 -0
  159. package/dist/apps/platform/Billing.d.ts.map +1 -0
  160. package/dist/apps/platform/Billing.js +477 -0
  161. package/dist/apps/platform/Billing.js.map +1 -0
  162. package/dist/apps/platform/index.d.ts +3 -0
  163. package/dist/apps/platform/index.d.ts.map +1 -0
  164. package/dist/apps/platform/index.js +3 -0
  165. package/dist/apps/platform/index.js.map +1 -0
  166. package/dist/apps/platform/routes/api-keys.d.ts +973 -0
  167. package/dist/apps/platform/routes/api-keys.d.ts.map +1 -0
  168. package/dist/apps/platform/routes/api-keys.js +430 -0
  169. package/dist/apps/platform/routes/api-keys.js.map +1 -0
  170. package/dist/apps/platform/routes/billing.d.ts +1520 -0
  171. package/dist/apps/platform/routes/billing.d.ts.map +1 -0
  172. package/dist/apps/platform/routes/billing.js +795 -0
  173. package/dist/apps/platform/routes/billing.js.map +1 -0
  174. package/dist/apps/platform/routes/invitations.d.ts +851 -0
  175. package/dist/apps/platform/routes/invitations.d.ts.map +1 -0
  176. package/dist/apps/platform/routes/invitations.js +471 -0
  177. package/dist/apps/platform/routes/invitations.js.map +1 -0
  178. package/dist/apps/platform/routes/me.d.ts +95 -0
  179. package/dist/apps/platform/routes/me.d.ts.map +1 -0
  180. package/dist/apps/platform/routes/me.js +81 -0
  181. package/dist/apps/platform/routes/me.js.map +1 -0
  182. package/dist/apps/platform/routes/members.d.ts +554 -0
  183. package/dist/apps/platform/routes/members.d.ts.map +1 -0
  184. package/dist/apps/platform/routes/members.js +251 -0
  185. package/dist/apps/platform/routes/members.js.map +1 -0
  186. package/dist/apps/platform/routes/orgs.d.ts +596 -0
  187. package/dist/apps/platform/routes/orgs.d.ts.map +1 -0
  188. package/dist/apps/platform/routes/orgs.js +276 -0
  189. package/dist/apps/platform/routes/orgs.js.map +1 -0
  190. package/dist/apps/platform/routes/projects.d.ts +740 -0
  191. package/dist/apps/platform/routes/projects.d.ts.map +1 -0
  192. package/dist/apps/platform/routes/projects.js +286 -0
  193. package/dist/apps/platform/routes/projects.js.map +1 -0
  194. package/dist/apps/platform/routes/scopes.d.ts +107 -0
  195. package/dist/apps/platform/routes/scopes.d.ts.map +1 -0
  196. package/dist/apps/platform/routes/scopes.js +66 -0
  197. package/dist/apps/platform/routes/scopes.js.map +1 -0
  198. package/dist/apps/platform/routes/usage.d.ts +588 -0
  199. package/dist/apps/platform/routes/usage.d.ts.map +1 -0
  200. package/dist/apps/platform/routes/usage.js +391 -0
  201. package/dist/apps/platform/routes/usage.js.map +1 -0
  202. package/dist/apps/relay/App.d.ts +44 -0
  203. package/dist/apps/relay/App.d.ts.map +1 -0
  204. package/dist/apps/relay/App.js +211 -0
  205. package/dist/apps/relay/App.js.map +1 -0
  206. package/dist/apps/relay/Sponsorships.d.ts +107 -0
  207. package/dist/apps/relay/Sponsorships.d.ts.map +1 -0
  208. package/dist/apps/relay/Sponsorships.js +194 -0
  209. package/dist/apps/relay/Sponsorships.js.map +1 -0
  210. package/dist/apps/relay/index.d.ts +3 -0
  211. package/dist/apps/relay/index.d.ts.map +1 -0
  212. package/dist/apps/relay/index.js +3 -0
  213. package/dist/apps/relay/index.js.map +1 -0
  214. package/dist/cli/Cli.d.ts +9 -2
  215. package/dist/cli/Cli.d.ts.map +1 -1
  216. package/dist/cli/Cli.js +12 -4
  217. package/dist/cli/Cli.js.map +1 -1
  218. package/dist/cli/commands/admin.d.ts +5 -1
  219. package/dist/cli/commands/admin.d.ts.map +1 -1
  220. package/dist/cli/commands/admin.js +82 -3
  221. package/dist/cli/commands/admin.js.map +1 -1
  222. package/dist/db/Db.d.ts +17 -0
  223. package/dist/db/Db.d.ts.map +1 -1
  224. package/dist/db/Db.js +254 -0
  225. package/dist/db/Db.js.map +1 -1
  226. package/dist/db/Schema.d.ts +159 -0
  227. package/dist/db/Schema.d.ts.map +1 -1
  228. package/dist/db/Schema.js +187 -2
  229. package/dist/db/Schema.js.map +1 -1
  230. package/dist/db/tables/billingSettings.d.ts +55 -0
  231. package/dist/db/tables/billingSettings.d.ts.map +1 -0
  232. package/dist/db/tables/billingSettings.js +70 -0
  233. package/dist/db/tables/billingSettings.js.map +1 -0
  234. package/dist/db/tables/invitations.d.ts +84 -0
  235. package/dist/db/tables/invitations.d.ts.map +1 -0
  236. package/dist/db/tables/invitations.js +165 -0
  237. package/dist/db/tables/invitations.js.map +1 -0
  238. package/dist/db/tables/memberships.d.ts +108 -0
  239. package/dist/db/tables/memberships.d.ts.map +1 -0
  240. package/dist/db/tables/memberships.js +153 -0
  241. package/dist/db/tables/memberships.js.map +1 -0
  242. package/dist/db/tables/organizations.d.ts +48 -0
  243. package/dist/db/tables/organizations.d.ts.map +1 -1
  244. package/dist/db/tables/organizations.js +97 -2
  245. package/dist/db/tables/organizations.js.map +1 -1
  246. package/dist/db/tables/projects.d.ts +65 -0
  247. package/dist/db/tables/projects.d.ts.map +1 -0
  248. package/dist/db/tables/projects.js +75 -0
  249. package/dist/db/tables/projects.js.map +1 -0
  250. package/dist/db/tables/requestUsage.d.ts +121 -0
  251. package/dist/db/tables/requestUsage.d.ts.map +1 -0
  252. package/dist/db/tables/requestUsage.js +150 -0
  253. package/dist/db/tables/requestUsage.js.map +1 -0
  254. package/dist/db/tables/sponsoredTransactions.d.ts +239 -0
  255. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -0
  256. package/dist/db/tables/sponsoredTransactions.js +314 -0
  257. package/dist/db/tables/sponsoredTransactions.js.map +1 -0
  258. package/dist/db/tables/stripeCustomers.d.ts +81 -0
  259. package/dist/db/tables/stripeCustomers.d.ts.map +1 -0
  260. package/dist/db/tables/stripeCustomers.js +120 -0
  261. package/dist/db/tables/stripeCustomers.js.map +1 -0
  262. package/dist/db/tables/users.d.ts +48 -0
  263. package/dist/db/tables/users.d.ts.map +1 -0
  264. package/dist/db/tables/users.js +65 -0
  265. package/dist/db/tables/users.js.map +1 -0
  266. package/dist/handlers/internal/executionError.d.ts.map +1 -1
  267. package/dist/handlers/internal/executionError.js +2 -0
  268. package/dist/handlers/internal/executionError.js.map +1 -1
  269. package/dist/handlers/internal/multisig.d.ts +2 -6
  270. package/dist/handlers/internal/multisig.d.ts.map +1 -1
  271. package/dist/handlers/internal/multisig.js +11 -36
  272. package/dist/handlers/internal/multisig.js.map +1 -1
  273. package/dist/handlers/internal/sponsorship.d.ts +35 -2
  274. package/dist/handlers/internal/sponsorship.d.ts.map +1 -1
  275. package/dist/handlers/internal/sponsorship.js +53 -14
  276. package/dist/handlers/internal/sponsorship.js.map +1 -1
  277. package/dist/handlers/internal/utils.d.ts +10 -3
  278. package/dist/handlers/internal/utils.d.ts.map +1 -1
  279. package/dist/handlers/internal/utils.js +14 -6
  280. package/dist/handlers/internal/utils.js.map +1 -1
  281. package/dist/handlers/relay.d.ts +6 -2
  282. package/dist/handlers/relay.d.ts.map +1 -1
  283. package/dist/handlers/relay.js +16 -2
  284. package/dist/handlers/relay.js.map +1 -1
  285. package/dist/index.d.ts +1 -0
  286. package/dist/index.d.ts.map +1 -1
  287. package/dist/index.js +1 -0
  288. package/dist/index.js.map +1 -1
  289. package/dist/internal/Auth.d.ts +222 -6
  290. package/dist/internal/Auth.d.ts.map +1 -1
  291. package/dist/internal/Auth.js +625 -74
  292. package/dist/internal/Auth.js.map +1 -1
  293. package/dist/internal/Cache.d.ts.map +1 -1
  294. package/dist/internal/Cache.js +4 -1
  295. package/dist/internal/Cache.js.map +1 -1
  296. package/dist/internal/EdgeCache.d.ts +10 -0
  297. package/dist/internal/EdgeCache.d.ts.map +1 -1
  298. package/dist/internal/EdgeCache.js +39 -8
  299. package/dist/internal/EdgeCache.js.map +1 -1
  300. package/dist/internal/Fees.d.ts +27 -0
  301. package/dist/internal/Fees.d.ts.map +1 -0
  302. package/dist/internal/Fees.js +48 -0
  303. package/dist/internal/Fees.js.map +1 -0
  304. package/dist/internal/FundingRoutes.d.ts +183 -0
  305. package/dist/internal/FundingRoutes.d.ts.map +1 -0
  306. package/dist/internal/FundingRoutes.js +490 -0
  307. package/dist/internal/FundingRoutes.js.map +1 -0
  308. package/dist/internal/Id.d.ts +15 -0
  309. package/dist/internal/Id.d.ts.map +1 -0
  310. package/dist/internal/Id.js +22 -0
  311. package/dist/internal/Id.js.map +1 -0
  312. package/dist/internal/Log.d.ts +9 -3
  313. package/dist/internal/Log.d.ts.map +1 -1
  314. package/dist/internal/Log.js +7 -0
  315. package/dist/internal/Log.js.map +1 -1
  316. package/dist/internal/OpenApi.d.ts +10 -20
  317. package/dist/internal/OpenApi.d.ts.map +1 -1
  318. package/dist/internal/OpenApi.js +8 -58
  319. package/dist/internal/OpenApi.js.map +1 -1
  320. package/dist/internal/RateLimit.d.ts +25 -0
  321. package/dist/internal/RateLimit.d.ts.map +1 -1
  322. package/dist/internal/RateLimit.js +51 -0
  323. package/dist/internal/RateLimit.js.map +1 -1
  324. package/dist/internal/Response.d.ts +1 -1
  325. package/dist/internal/Response.d.ts.map +1 -1
  326. package/dist/internal/Schema.d.ts +8 -0
  327. package/dist/internal/Schema.d.ts.map +1 -1
  328. package/dist/internal/Schema.js +7 -0
  329. package/dist/internal/Schema.js.map +1 -1
  330. package/dist/internal/Store.d.ts +7 -1
  331. package/dist/internal/Store.d.ts.map +1 -1
  332. package/dist/internal/Store.js +16 -2
  333. package/dist/internal/Store.js.map +1 -1
  334. package/dist/internal/Viem.d.ts +84 -0
  335. package/dist/internal/Viem.d.ts.map +1 -1
  336. package/dist/internal/Webhooks.d.ts +1 -1
  337. package/dist/internal/Webhooks.d.ts.map +1 -1
  338. package/dist/internal/Webhooks.js +3 -3
  339. package/dist/internal/Webhooks.js.map +1 -1
  340. package/package.json +33 -6
  341. package/src/ApiKey.ts +10 -2
  342. package/src/ApiKeys.test.ts +155 -1
  343. package/src/ApiKeys.ts +203 -1
  344. package/src/App.test.ts +64 -75741
  345. package/src/App.ts +218 -420
  346. package/src/Client.test-d.ts +657 -15
  347. package/src/Scope.ts +26 -4
  348. package/src/Webhooks.ts +2 -2
  349. package/src/admin/apps/api-keys.test.ts +51 -0
  350. package/src/admin/apps/api-keys.ts +84 -0
  351. package/src/admin/apps/scopes.test.ts +11 -1
  352. package/src/admin/apps/scopes.ts +3 -0
  353. package/src/admin/apps/verified-tokens.ts +1 -1
  354. package/src/admin/ui/src/components/Page.tsx +2 -3
  355. package/src/admin/ui/src/routes/__root.tsx +2 -2
  356. package/src/admin/ui/src/routes/api-keys.tsx +2 -2
  357. package/src/admin/ui.generated.ts +13 -13
  358. package/src/analytics/Analytics.test.ts +527 -0
  359. package/src/analytics/Analytics.ts +318 -0
  360. package/src/analytics/tables/requestEvents.ts +523 -0
  361. package/src/apps/composition.test.ts +66 -0
  362. package/src/apps/data/App.test.ts +72 -0
  363. package/src/apps/data/App.ts +330 -0
  364. package/src/apps/data/index.ts +2 -0
  365. package/src/apps/{activities.test.ts → data/routes/activities.test.ts} +3 -3
  366. package/src/apps/{activities.ts → data/routes/activities.ts} +15 -15
  367. package/src/apps/{addresses.ts → data/routes/addresses.ts} +6 -6
  368. package/src/apps/{balances.test.ts → data/routes/balances.test.ts} +2 -2
  369. package/src/apps/{balances.ts → data/routes/balances.ts} +46 -12
  370. package/src/apps/{blocks.test.ts → data/routes/blocks.test.ts} +3 -3
  371. package/src/apps/{blocks.ts → data/routes/blocks.ts} +14 -14
  372. package/src/apps/{coingecko.test.ts → data/routes/coingecko.test.ts} +2 -2
  373. package/src/apps/{coingecko.ts → data/routes/coingecko.ts} +14 -14
  374. package/src/apps/{exchanges.test.ts → data/routes/exchanges.test.ts} +1 -1
  375. package/src/apps/{exchanges.ts → data/routes/exchanges.ts} +20 -20
  376. package/src/apps/{fee-amm.test.ts → data/routes/fee-amm.test.ts} +3 -3
  377. package/src/apps/{fee-amm.ts → data/routes/fee-amm.ts} +18 -18
  378. package/src/apps/data/routes/funding.test.ts +214 -0
  379. package/src/apps/data/routes/funding.ts +584 -0
  380. package/src/apps/{indexer.test.ts → data/routes/indexer.test.ts} +26 -5
  381. package/src/apps/{indexer.ts → data/routes/indexer.ts} +13 -10
  382. package/src/apps/{receipts.test.ts → data/routes/receipts.test.ts} +3 -3
  383. package/src/apps/{receipts.ts → data/routes/receipts.ts} +15 -22
  384. package/src/apps/{rpc.test.ts → data/routes/rpc.test.ts} +122 -7
  385. package/src/apps/{rpc.ts → data/routes/rpc.ts} +38 -8
  386. package/src/apps/{tokenlist.test.ts → data/routes/tokenlist.test.ts} +3 -3
  387. package/src/apps/{tokenlist.ts → data/routes/tokenlist.ts} +9 -9
  388. package/src/apps/{tokens.test.ts → data/routes/tokens.test.ts} +2 -2
  389. package/src/apps/{tokens.ts → data/routes/tokens.ts} +20 -20
  390. package/src/apps/{transactions.test.ts → data/routes/transactions.test.ts} +3 -3
  391. package/src/apps/{transactions.ts → data/routes/transactions.ts} +15 -15
  392. package/src/apps/{transfers.test.ts → data/routes/transfers.test.ts} +2 -2
  393. package/src/apps/{transfers.ts → data/routes/transfers.ts} +15 -15
  394. package/src/apps/{verified-tokens.test.ts → data/routes/verified-tokens.test.ts} +3 -3
  395. package/src/apps/{verified-tokens.ts → data/routes/verified-tokens.ts} +10 -10
  396. package/src/apps/{webhooks.test.ts → data/routes/webhooks.test.ts} +7 -7
  397. package/src/apps/{webhooks.ts → data/routes/webhooks.ts} +50 -43
  398. package/src/apps/docs/App.ts +65 -0
  399. package/src/apps/docs/index.ts +1 -0
  400. package/src/apps/docs/reference.ts +132 -0
  401. package/src/apps/index.ts +4 -0
  402. package/src/apps/mcp.test.ts +206 -0
  403. package/src/apps/mcp.ts +250 -0
  404. package/src/apps/metadata.ts +23 -0
  405. package/src/apps/platform/App.ts +169 -0
  406. package/src/apps/platform/Billing.test.ts +530 -0
  407. package/src/apps/platform/Billing.ts +682 -0
  408. package/src/apps/platform/index.ts +2 -0
  409. package/src/apps/platform/routes/api-keys.test.ts +493 -0
  410. package/src/apps/platform/routes/api-keys.ts +543 -0
  411. package/src/apps/platform/routes/billing.test.ts +1100 -0
  412. package/src/apps/platform/routes/billing.ts +966 -0
  413. package/src/apps/platform/routes/invitations.test.ts +409 -0
  414. package/src/apps/platform/routes/invitations.ts +587 -0
  415. package/src/apps/platform/routes/me.test.ts +351 -0
  416. package/src/apps/platform/routes/me.ts +106 -0
  417. package/src/apps/platform/routes/members.test.ts +195 -0
  418. package/src/apps/platform/routes/members.ts +313 -0
  419. package/src/apps/platform/routes/orgs.test.ts +313 -0
  420. package/src/apps/platform/routes/orgs.ts +365 -0
  421. package/src/apps/platform/routes/projects.test.ts +181 -0
  422. package/src/apps/platform/routes/projects.ts +367 -0
  423. package/src/apps/platform/routes/scopes.test.ts +29 -0
  424. package/src/apps/platform/routes/scopes.ts +85 -0
  425. package/src/apps/platform/routes/usage.test.ts +422 -0
  426. package/src/apps/platform/routes/usage.ts +527 -0
  427. package/src/apps/relay/App.test.ts +933 -0
  428. package/src/apps/relay/App.ts +236 -0
  429. package/src/apps/relay/Sponsorships.test.ts +375 -0
  430. package/src/apps/relay/Sponsorships.ts +306 -0
  431. package/src/apps/relay/index.ts +2 -0
  432. package/src/cli/Cli.test.ts +25 -2
  433. package/src/cli/Cli.ts +18 -3
  434. package/src/cli/commands/admin.test.ts +83 -0
  435. package/src/cli/commands/admin.ts +91 -3
  436. package/src/db/Db.ts +296 -0
  437. package/src/db/Schema.ts +241 -2
  438. package/src/db/tables/billingSettings.test.ts +87 -0
  439. package/src/db/tables/billingSettings.ts +108 -0
  440. package/src/db/tables/invitations.ts +198 -0
  441. package/src/db/tables/memberships.ts +208 -0
  442. package/src/db/tables/organizations.test.ts +38 -2
  443. package/src/db/tables/organizations.ts +117 -2
  444. package/src/db/tables/projects.ts +107 -0
  445. package/src/db/tables/requestUsage.ts +231 -0
  446. package/src/db/tables/sponsoredTransactions.test.ts +325 -0
  447. package/src/db/tables/sponsoredTransactions.ts +464 -0
  448. package/src/db/tables/stripeCustomers.test.ts +109 -0
  449. package/src/db/tables/stripeCustomers.ts +162 -0
  450. package/src/db/tables/users.ts +85 -0
  451. package/src/handlers/internal/executionError.ts +2 -0
  452. package/src/handlers/internal/multisig.test.ts +84 -10
  453. package/src/handlers/internal/multisig.ts +15 -50
  454. package/src/handlers/internal/sponsorship.ts +106 -20
  455. package/src/handlers/internal/utils.ts +19 -7
  456. package/src/handlers/{internal/relay.localnet.test.ts → relay.test.ts} +2 -2
  457. package/src/handlers/relay.ts +23 -5
  458. package/src/index.ts +1 -0
  459. package/src/internal/Auth.test.ts +491 -25
  460. package/src/internal/Auth.ts +839 -84
  461. package/src/internal/Cache.ts +5 -1
  462. package/src/internal/Cursor.test.ts +3 -2
  463. package/src/internal/EdgeCache.test.ts +27 -4
  464. package/src/internal/EdgeCache.ts +47 -9
  465. package/src/internal/Fees.test.ts +32 -0
  466. package/src/internal/Fees.ts +51 -0
  467. package/src/internal/FundingRoutes.ts +583 -0
  468. package/src/internal/Id.test.ts +17 -0
  469. package/src/internal/Id.ts +24 -0
  470. package/src/internal/Log.test.ts +2 -1
  471. package/src/internal/Log.ts +16 -3
  472. package/src/internal/MetricSink.ts +1 -1
  473. package/src/internal/OpenApi.ts +12 -60
  474. package/src/internal/RateLimit.test.ts +84 -0
  475. package/src/internal/RateLimit.ts +70 -0
  476. package/src/internal/Response.ts +1 -1
  477. package/src/internal/Schema.ts +8 -0
  478. package/src/internal/Store.test.ts +52 -0
  479. package/src/internal/Store.ts +24 -5
  480. package/src/internal/Tidx.local.test.ts +1 -1
  481. package/src/internal/VerifiedTokens.test.ts +1 -1
  482. package/src/internal/WebhookDestination.test.ts +1 -1
  483. package/src/internal/Webhooks.test.ts +7 -7
  484. package/src/internal/Webhooks.ts +4 -4
  485. package/dist/apps/activities.js.map +0 -1
  486. package/dist/apps/addresses.js.map +0 -1
  487. package/dist/apps/balances.d.ts.map +0 -1
  488. package/dist/apps/balances.js.map +0 -1
  489. package/dist/apps/blocks.d.ts.map +0 -1
  490. package/dist/apps/blocks.js.map +0 -1
  491. package/dist/apps/coingecko.d.ts.map +0 -1
  492. package/dist/apps/coingecko.js.map +0 -1
  493. package/dist/apps/exchanges.d.ts.map +0 -1
  494. package/dist/apps/exchanges.js.map +0 -1
  495. package/dist/apps/fee-amm.d.ts.map +0 -1
  496. package/dist/apps/fee-amm.js.map +0 -1
  497. package/dist/apps/indexer.d.ts.map +0 -1
  498. package/dist/apps/indexer.js.map +0 -1
  499. package/dist/apps/receipts.d.ts.map +0 -1
  500. package/dist/apps/receipts.js.map +0 -1
  501. package/dist/apps/rpc.d.ts.map +0 -1
  502. package/dist/apps/rpc.js.map +0 -1
  503. package/dist/apps/tokenlist.d.ts.map +0 -1
  504. package/dist/apps/tokenlist.js.map +0 -1
  505. package/dist/apps/tokens.d.ts.map +0 -1
  506. package/dist/apps/tokens.js.map +0 -1
  507. package/dist/apps/transactions.d.ts.map +0 -1
  508. package/dist/apps/transactions.js.map +0 -1
  509. package/dist/apps/transfers.d.ts.map +0 -1
  510. package/dist/apps/transfers.js.map +0 -1
  511. package/dist/apps/verified-tokens.d.ts.map +0 -1
  512. package/dist/apps/verified-tokens.js.map +0 -1
  513. package/dist/apps/webhooks.js.map +0 -1
  514. package/dist/internal/OpenApi.fonts.d.ts.map +0 -1
  515. package/dist/internal/OpenApi.fonts.js.map +0 -1
  516. package/dist/internal/OpenApi.logo.d.ts.map +0 -1
  517. package/dist/internal/OpenApi.logo.js.map +0 -1
  518. package/src/handlers/internal/multisig.localnet.test.ts +0 -146
  519. /package/src/{internal/OpenApi.fonts.ts → apps/docs/fonts.ts} +0 -0
  520. /package/src/{internal/OpenApi.logo.ts → apps/docs/logo.ts} +0 -0
@@ -66,7 +66,6 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
66
66
  const config = await resolveValidatedConfig({
67
67
  account: input.account,
68
68
  chainId: input.chainId,
69
- genesisConfigId: input.genesisConfigId,
70
69
  init: input.init,
71
70
  pending,
72
71
  resolveConfig,
@@ -78,7 +77,6 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
78
77
  })
79
78
  const initConfig = resolveInitConfig({
80
79
  config,
81
- genesisConfigId: input.genesisConfigId,
82
80
  init: input.init,
83
81
  nonce: input.nonce,
84
82
  pending,
@@ -91,7 +89,6 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
91
89
  claimExpiresAt: pending?.claimExpiresAt,
92
90
  config,
93
91
  createdAt: pending?.createdAt ?? now,
94
- genesisConfigId: input.genesisConfigId,
95
92
  id: input.id,
96
93
  init: pending?.init || !!initConfig,
97
94
  initConfig,
@@ -106,7 +103,6 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
106
103
  let approvals = getApprovals({
107
104
  account: input.account,
108
105
  config,
109
- genesisConfigId: input.genesisConfigId,
110
106
  payload: input.payload,
111
107
  signatures: operation.signatures,
112
108
  })
@@ -121,7 +117,6 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
121
117
  approvals = getApprovals({
122
118
  account: operation.account,
123
119
  config,
124
- genesisConfigId: operation.genesisConfigId,
125
120
  payload: operation.payload,
126
121
  signatures: operation.signatures,
127
122
  })
@@ -136,14 +131,12 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
136
131
  approvals = getApprovals({
137
132
  account: operation.account,
138
133
  config,
139
- genesisConfigId: operation.genesisConfigId,
140
134
  payload: operation.payload,
141
135
  signatures: operation.signatures,
142
136
  })
143
137
  const client = getClient(operation.chainId)
144
138
  const final = await serializeFinal({
145
139
  account: operation.account,
146
- genesisConfigId: operation.genesisConfigId,
147
140
  init: operation.initConfig ?? initConfig,
148
141
  signatures: approvals.signatures,
149
142
  transaction: input.transaction,
@@ -199,6 +192,7 @@ async function collect(options: collect.Options): Promise<collect.ReturnType> {
199
192
  : undefined,
200
193
  getClient,
201
194
  method: broadcastMethod,
195
+ onSponsored: sponsor.onSponsored,
202
196
  request: { params: [final] },
203
197
  sender: operation.account,
204
198
  validate: sponsor.validate,
@@ -295,7 +289,6 @@ export async function getStatus(options: getStatus.Options): Promise<Status | nu
295
289
  const config = await resolveValidatedConfig({
296
290
  account: operation.account,
297
291
  chainId: operation.chainId,
298
- genesisConfigId: operation.genesisConfigId,
299
292
  pending: operation,
300
293
  resolveConfig: options.resolveConfig,
301
294
  })
@@ -303,7 +296,6 @@ export async function getStatus(options: getStatus.Options): Promise<Status | nu
303
296
  return {
304
297
  account: operation.account,
305
298
  chainId: operation.chainId,
306
- genesisConfigId: operation.genesisConfigId,
307
299
  id: operation.id,
308
300
  signatures: operation.signatures.length,
309
301
  status: operation.status,
@@ -312,7 +304,6 @@ export async function getStatus(options: getStatus.Options): Promise<Status | nu
312
304
  const approvals = getApprovals({
313
305
  account: operation.account,
314
306
  config,
315
- genesisConfigId: operation.genesisConfigId,
316
307
  payload: operation.payload,
317
308
  signatures: operation.signatures,
318
309
  })
@@ -339,7 +330,6 @@ export async function listStatuses(options: listStatuses.Options): Promise<reado
339
330
  const config = await resolveValidatedConfig({
340
331
  account: operation.account,
341
332
  chainId: operation.chainId,
342
- genesisConfigId: operation.genesisConfigId,
343
333
  pending: operation,
344
334
  resolveConfig: options.resolveConfig,
345
335
  })
@@ -347,7 +337,6 @@ export async function listStatuses(options: listStatuses.Options): Promise<reado
347
337
  return {
348
338
  account: operation.account,
349
339
  chainId: operation.chainId,
350
- genesisConfigId: operation.genesisConfigId,
351
340
  id: operation.id,
352
341
  signatures: operation.signatures.length,
353
342
  status: operation.status,
@@ -356,7 +345,6 @@ export async function listStatuses(options: listStatuses.Options): Promise<reado
356
345
  const approvals = getApprovals({
357
346
  account: operation.account,
358
347
  config,
359
- genesisConfigId: operation.genesisConfigId,
360
348
  payload: operation.payload,
361
349
  signatures: operation.signatures,
362
350
  })
@@ -497,8 +485,6 @@ export type ResolveConfig = (request: {
497
485
  account: Address
498
486
  /** Transaction chain id. */
499
487
  chainId: number
500
- /** Permanent genesis config id. */
501
- genesisConfigId: Hex.Hex
502
488
  /** Bootstrap config carried by the transaction, when present. */
503
489
  init?: MultisigConfig.Config | undefined
504
490
  }) => MultisigConfig.Config | Promise<MultisigConfig.Config | undefined> | undefined
@@ -509,6 +495,8 @@ export type Sponsor = {
509
495
  account: LocalAccount
510
496
  /** Fee token to set before fee payer signing. */
511
497
  feeToken?: Address | undefined
498
+ /** Called once the fee payer has signed, before any broadcast. */
499
+ onSponsored?: Sponsorship.handleRawTransaction.Options['onSponsored']
512
500
  /** Resolves the default fee token for raw sponsorship. */
513
501
  resolveFeeToken?:
514
502
  | ((chainId: number) => Address | Promise<Address | undefined> | undefined)
@@ -570,8 +558,6 @@ export type Operation = {
570
558
  config?: MultisigConfig.Config | undefined
571
559
  /** Creation timestamp in milliseconds. */
572
560
  createdAt: number
573
- /** Permanent genesis config id. */
574
- genesisConfigId: Hex.Hex
575
561
  /** Deterministic operation id. */
576
562
  id: Hex.Hex
577
563
  /** Whether the finalized transaction must carry the genesis init config. */
@@ -598,8 +584,6 @@ export type Status = {
598
584
  account: Address
599
585
  /** Transaction chain id. */
600
586
  chainId: number
601
- /** Permanent genesis config id. */
602
- genesisConfigId: Hex.Hex
603
587
  /** Deterministic operation id. */
604
588
  id: Hex.Hex
605
589
  /** Number of collected owner approvals. */
@@ -627,7 +611,6 @@ function parse(serialized: Hex.Hex) {
627
611
  const chainId = Number(transaction['chainId'])
628
612
  const id = MultisigConfig.getSignPayload({
629
613
  account: signature.account,
630
- genesisConfigId: signature.genesisConfigId,
631
614
  payload,
632
615
  })
633
616
  const init = signature.init ? MultisigConfig.from(signature.init) : undefined
@@ -636,7 +619,6 @@ function parse(serialized: Hex.Hex) {
636
619
  return {
637
620
  account: signature.account,
638
621
  chainId,
639
- genesisConfigId: signature.genesisConfigId,
640
622
  id,
641
623
  init,
642
624
  nonce,
@@ -652,7 +634,6 @@ function isMultisigSignature(value: unknown): value is SignatureEnvelope.Multisi
652
634
  value !== null &&
653
635
  (value as { type?: unknown }).type === 'multisig' &&
654
636
  typeof (value as { account?: unknown }).account === 'string' &&
655
- typeof (value as { genesisConfigId?: unknown }).genesisConfigId === 'string' &&
656
637
  Array.isArray((value as { signatures?: unknown }).signatures)
657
638
  )
658
639
  }
@@ -660,50 +641,39 @@ function isMultisigSignature(value: unknown): value is SignatureEnvelope.Multisi
660
641
  async function resolveValidatedConfig(options: {
661
642
  account: Address
662
643
  chainId: number
663
- genesisConfigId: Hex.Hex
664
644
  init?: MultisigConfig.Config | undefined
665
645
  pending?: Operation | undefined
666
646
  resolveConfig?: ResolveConfig | undefined
667
647
  }) {
668
- const { account, chainId, genesisConfigId, init, pending, resolveConfig } = options
669
- const config =
670
- (await resolveConfig?.({ account, chainId, genesisConfigId, init })) ?? pending?.config ?? init
648
+ const { account, chainId, init, pending, resolveConfig } = options
649
+ const config = (await resolveConfig?.({ account, chainId, init })) ?? pending?.config ?? init
671
650
  if (!config) return undefined
672
651
 
673
- if (init && !isGenesisConfig(init, genesisConfigId))
674
- throw new RpcResponse.InvalidParamsError({
675
- message: 'Bootstrap multisig init config does not match genesis config id.',
676
- })
677
-
678
652
  const normalized = MultisigConfig.from(config)
679
- const account_expected = MultisigConfig.getAddress({ genesisConfigId })
680
- if (account_expected.toLowerCase() !== account.toLowerCase())
653
+ if (
654
+ init &&
655
+ MultisigConfig.getAddress(MultisigConfig.from(init)).toLowerCase() !== account.toLowerCase()
656
+ )
681
657
  throw new RpcResponse.InvalidParamsError({
682
- message: 'Resolved multisig config does not match account or genesis config id.',
658
+ message: 'Bootstrap multisig init config does not match the multisig account.',
683
659
  })
684
660
  return normalized
685
661
  }
686
662
 
687
663
  function resolveInitConfig(options: {
688
664
  config: MultisigConfig.Config
689
- genesisConfigId: Hex.Hex
690
665
  init?: MultisigConfig.Config | undefined
691
666
  nonce?: number | undefined
692
667
  pending?: Operation | undefined
693
668
  }) {
694
- const { config, genesisConfigId, init, nonce, pending } = options
669
+ const { config, init, nonce, pending } = options
695
670
  if (pending?.initConfig) return pending.initConfig
696
- if (pending?.init && pending.config && isGenesisConfig(pending.config, genesisConfigId))
697
- return pending.config
671
+ if (pending?.init && pending.config) return pending.config
698
672
  if (init) return init
699
- if (nonce === 0 && isGenesisConfig(config, genesisConfigId)) return config
673
+ if (nonce === 0) return config
700
674
  return undefined
701
675
  }
702
676
 
703
- function isGenesisConfig(config: MultisigConfig.Config, genesisConfigId: Hex.Hex) {
704
- return MultisigConfig.toId(config).toLowerCase() === genesisConfigId.toLowerCase()
705
- }
706
-
707
677
  function mergeSignatures(signatures: readonly Hex.Hex[]) {
708
678
  const seen = new Set<string>()
709
679
  const out: Hex.Hex[] = []
@@ -719,12 +689,11 @@ function mergeSignatures(signatures: readonly Hex.Hex[]) {
719
689
  function getApprovals(options: {
720
690
  account: Address
721
691
  config: MultisigConfig.Config
722
- genesisConfigId: Hex.Hex
723
692
  payload: Hex.Hex
724
693
  signatures: readonly Hex.Hex[]
725
694
  }) {
726
- const { account, config, genesisConfigId, payload } = options
727
- const digest = MultisigConfig.getSignPayload({ account, genesisConfigId, payload })
695
+ const { account, config, payload } = options
696
+ const digest = MultisigConfig.getSignPayload({ account, payload })
728
697
  const owners = new Map(
729
698
  config.owners.map((owner) => [
730
699
  owner.owner.toLowerCase(),
@@ -764,7 +733,6 @@ function getApprovals(options: {
764
733
 
765
734
  async function serializeFinal(options: {
766
735
  account: Address
767
- genesisConfigId: Hex.Hex
768
736
  init?: MultisigConfig.Config | undefined
769
737
  signatures: readonly Hex.Hex[]
770
738
  transaction: Record<string, unknown>
@@ -804,13 +772,11 @@ async function serializeFinal(options: {
804
772
  const signatures = options.signatures.map((approval) => SignatureEnvelope.from(approval))
805
773
  const sorted = SignatureEnvelope.sortMultisigApprovals({
806
774
  account: options.account,
807
- genesisConfigId: options.genesisConfigId,
808
775
  payload,
809
776
  signatures,
810
777
  })
811
778
  const signature = SignatureEnvelope.from({
812
779
  account: options.account,
813
- genesisConfigId: options.genesisConfigId,
814
780
  signatures: sorted,
815
781
  ...(options.init ? { init: options.init } : {}),
816
782
  })
@@ -847,7 +813,6 @@ function toStatus(options: {
847
813
  return {
848
814
  account: operation.account,
849
815
  chainId: operation.chainId,
850
- genesisConfigId: operation.genesisConfigId,
851
816
  id: operation.id,
852
817
  signatures: approvals.signatures.length,
853
818
  status: operation.status,
@@ -1,4 +1,4 @@
1
- import { RpcResponse, Signature } from 'ox'
1
+ import { Hash, type Hex, RpcResponse, Signature } from 'ox'
2
2
  import { TxEnvelopeTempo } from 'ox/tempo'
3
3
  import type { Address, Client } from 'viem'
4
4
  import type { LocalAccount } from 'viem/accounts'
@@ -6,6 +6,34 @@ import { Transaction } from 'viem/tempo'
6
6
 
7
7
  import * as Utils from './utils.js'
8
8
 
9
+ /**
10
+ * Sponsorship approval callback. The candidate always carries its `chainId`:
11
+ * raw submissions deserialize it, and fills validate only prepared/filled
12
+ * transactions. Anything but `true` refuses; raw submissions surface a named
13
+ * reason to the caller while fills fall back to an unsponsored fill.
14
+ */
15
+ export type Validate = (
16
+ request: Transaction.TransactionRequest & { chainId?: number | Hex.Hex | undefined },
17
+ ) => Validation | Promise<Validation>
18
+
19
+ /** A sponsorship verdict: `true` sponsors; `false` or a named reason refuses. */
20
+ export type Validation =
21
+ | boolean
22
+ | 'billing_past_due'
23
+ | 'billing_required'
24
+ | 'fee_token_unsupported'
25
+ | 'spend_limit_exceeded'
26
+ | 'tx_fee_limit_exceeded'
27
+
28
+ /** Refusal messages keyed by named validation reason. */
29
+ const refusalMessages = {
30
+ billing_past_due: 'Billing past due.',
31
+ billing_required: 'Billing required.',
32
+ fee_token_unsupported: 'Fee token unsupported.',
33
+ spend_limit_exceeded: 'Spend limit exceeded.',
34
+ tx_fee_limit_exceeded: 'Transaction fee limit exceeded.',
35
+ } as const satisfies Record<Exclude<Validation, boolean>, string>
36
+
9
37
  /** Returns sponsor metadata for `eth_fillTransaction` responses. */
10
38
  export function getSponsor(options: getSponsor.Options): getSponsor.ReturnType {
11
39
  const { account, name, url } = options
@@ -40,10 +68,13 @@ export declare namespace getSponsor {
40
68
  export async function shouldSponsor(options: shouldSponsor.Options) {
41
69
  const { sender, transaction, validate } = options
42
70
  if (!validate) return true
43
- return await validate({
71
+ // Named refusal reasons collapse to false: fills fall back to an
72
+ // unsponsored fill instead of surfacing the reason.
73
+ const verdict = await validate({
44
74
  ...transaction,
45
75
  from: sender,
46
76
  } as Transaction.TransactionRequest)
77
+ return verdict === true
47
78
  }
48
79
 
49
80
  export declare namespace shouldSponsor {
@@ -53,7 +84,7 @@ export declare namespace shouldSponsor {
53
84
  /** Filled transaction to validate. */
54
85
  transaction: Record<string, unknown>
55
86
  /** Optional sponsorship approval callback. */
56
- validate?: ((request: Transaction.TransactionRequest) => boolean | Promise<boolean>) | undefined
87
+ validate?: Validate | undefined
57
88
  }
58
89
  }
59
90
 
@@ -88,13 +119,28 @@ export async function sign(options: sign.Options) {
88
119
  })
89
120
  if (!account.sign) throw new Error('Fee payer account cannot sign transactions.')
90
121
 
91
- const feePayerSignature = Signature.from(
92
- await account.sign({
93
- hash: TxEnvelopeTempo.getFeePayerSignPayload(TxEnvelopeTempo.from(prepared as never), {
94
- sender: prepared.from,
95
- }),
96
- }),
97
- )
122
+ const chainId = Utils.resolveChainId(transaction['chainId'])
123
+ if (chainId === undefined)
124
+ throw new RpcResponse.InvalidParamsError({
125
+ message: 'Transaction chainId must be provided before fee payer signing.',
126
+ })
127
+
128
+ const envelope = TxEnvelopeTempo.from(prepared as never)
129
+ const signPayload = TxEnvelopeTempo.getFeePayerSignPayload(envelope, { sender: prepared.from })
130
+ const feePayerSignature = Signature.from(await account.sign({ hash: signPayload }))
131
+
132
+ // Awaited before the signature leaves the relay: a fill-signed envelope can
133
+ // broadcast anywhere (even directly to a node), so the commitment records as
134
+ // an intent — no transaction hash until the sender signs.
135
+ const feeToken = transaction['feeToken'] as Address | null | undefined
136
+ await options.onSponsored?.({
137
+ chainId,
138
+ ...(feeToken ? { feeToken } : {}),
139
+ method: 'eth_fillTransaction',
140
+ sender: prepared.from,
141
+ signPayload,
142
+ transaction: TxEnvelopeTempo.serialize(envelope, { feePayerSignature }),
143
+ })
98
144
 
99
145
  return { ...prepared, feePayerSignature }
100
146
  }
@@ -103,6 +149,8 @@ export declare namespace sign {
103
149
  type Options = {
104
150
  /** Account used as the fee payer. */
105
151
  account: LocalAccount
152
+ /** Called once the fee payer has signed the fill. Awaited: a throw aborts the fill. */
153
+ onSponsored?: ((event: SponsoredEvent) => Promise<void> | void) | undefined
106
154
  /** Filled transaction to sign. */
107
155
  transaction: Record<string, unknown>
108
156
  /** Sender address from the original request. */
@@ -140,22 +188,36 @@ export async function handleRawTransaction(options: handleRawTransaction.Options
140
188
  feeToken_chain
141
189
  const transaction_sponsored = feeToken ? { ...transaction, feeToken } : transaction
142
190
 
143
- if (validate && !(await validate(transaction_sponsored as Transaction.TransactionRequest)))
144
- throw new RpcResponse.InvalidParamsError({
145
- message: 'Sponsorship rejected.',
146
- })
191
+ if (validate) {
192
+ const verdict = await validate(transaction_sponsored as Transaction.TransactionRequest)
193
+ if (verdict !== true)
194
+ throw new RpcResponse.InvalidParamsError(
195
+ verdict === false
196
+ ? { message: 'Sponsorship rejected.' }
197
+ : { data: { code: verdict }, message: refusalMessages[verdict] },
198
+ )
199
+ }
147
200
 
148
201
  const envelope = TxEnvelopeTempo.from(transaction_sponsored as never)
149
- const feePayerSignature = Signature.from(
150
- await account.sign({
151
- hash: TxEnvelopeTempo.getFeePayerSignPayload(envelope, { sender }),
152
- }),
153
- )
202
+ const signPayload = TxEnvelopeTempo.getFeePayerSignPayload(envelope, { sender })
203
+ const feePayerSignature = Signature.from(await account.sign({ hash: signPayload }))
154
204
  const serializedTransaction = TxEnvelopeTempo.serialize(envelope, {
155
205
  feePayerSignature,
156
206
  signature: transaction.signature,
157
207
  })
158
208
 
209
+ // Awaited before any broadcast so a recording failure refuses sponsorship —
210
+ // no sponsored transaction ever reaches the chain unrecorded.
211
+ await options.onSponsored?.({
212
+ chainId: transaction.chainId,
213
+ ...(feeToken ? { feeToken } : {}),
214
+ method,
215
+ sender,
216
+ signPayload,
217
+ transaction: serializedTransaction,
218
+ transactionHash: Hash.keccak256(serializedTransaction),
219
+ })
220
+
159
221
  // Raw-sign requests stop after fee-payer signature is added; send methods broadcast it.
160
222
  if (method === 'eth_signRawTransaction') return serializedTransaction
161
223
  return await client.request({
@@ -176,11 +238,35 @@ export declare namespace handleRawTransaction {
176
238
  getClient: (chainId?: number) => Client
177
239
  /** Raw transaction method to handle. */
178
240
  method: 'eth_signRawTransaction' | 'eth_sendRawTransaction' | 'eth_sendRawTransactionSync'
241
+ /** Called once the fee payer has signed, before any broadcast. Awaited: a throw aborts the request. */
242
+ onSponsored?: ((event: SponsoredEvent) => Promise<void> | void) | undefined
179
243
  /** Incoming JSON-RPC request. */
180
244
  request: { params?: readonly unknown[] | undefined }
181
245
  /** Sender address to use if it cannot be recovered from the raw envelope. */
182
246
  sender?: Address | undefined
183
247
  /** Optional sponsorship approval callback. */
184
- validate?: ((request: Transaction.TransactionRequest) => boolean | Promise<boolean>) | undefined
248
+ validate?: Validate | undefined
185
249
  }
186
250
  }
251
+
252
+ /** Facts of one sponsorship commitment, emitted at fee-payer signing time. */
253
+ export type SponsoredEvent = {
254
+ /** Chain the sponsored transaction targets. */
255
+ chainId: number
256
+ /** Fee token the sponsorship resolved, when known. */
257
+ feeToken?: Address | undefined
258
+ /** Method that triggered sponsorship: a fill (intent) or a raw submission. */
259
+ method:
260
+ | 'eth_fillTransaction'
261
+ | 'eth_signRawTransaction'
262
+ | 'eth_sendRawTransaction'
263
+ | 'eth_sendRawTransactionSync'
264
+ /** Transaction sender. */
265
+ sender: Address
266
+ /** Fee-payer sign payload — a stable identity for the sponsored envelope. */
267
+ signPayload: Hex.Hex
268
+ /** Serialized sponsored transaction (sender-unsigned for fill intents). */
269
+ transaction: Hex.Hex
270
+ /** Transaction hash (keccak256 of the signed envelope); absent for fill intents, whose senders have not signed yet. */
271
+ transactionHash?: Hex.Hex | undefined
272
+ }
@@ -80,18 +80,30 @@ export function normalizeTempoTransaction(value: Record<string, unknown> | undef
80
80
 
81
81
  /** Returns a raw JSON-RPC error response object (not wrapped in a `Response`). */
82
82
  export function rpcErrorJson(request: RpcRequest.RpcRequest, error: unknown) {
83
- if (error instanceof RpcResponse.InvalidParamsError)
84
- return RpcResponse.from({ error }, { request })
85
-
86
- if (error instanceof RpcResponse.MethodNotSupportedError)
87
- return RpcResponse.from({ error }, { request })
83
+ // Serialize error instances to plain objects: `Error.message` is
84
+ // non-enumerable, so instances stringify onto the wire without it.
85
+ if (
86
+ error instanceof RpcResponse.InvalidParamsError ||
87
+ error instanceof RpcResponse.MethodNotSupportedError
88
+ )
89
+ return RpcResponse.from(
90
+ {
91
+ error: {
92
+ code: error.code,
93
+ message: error.message,
94
+ ...(error.data !== undefined ? { data: error.data } : {}),
95
+ },
96
+ },
97
+ { request },
98
+ )
88
99
 
89
100
  if ((error as { name?: string | undefined }).name === 'ZodError')
90
101
  return RpcResponse.from(
91
102
  {
92
- error: new RpcResponse.InvalidParamsError({
103
+ error: {
104
+ code: RpcResponse.InvalidParamsError.code,
93
105
  message: (error as Error).message,
94
- }),
106
+ },
95
107
  },
96
108
  { request },
97
109
  )
@@ -5,8 +5,8 @@ import { fillTransaction, sendTransactionSync } from 'viem/actions'
5
5
  import { Actions, Addresses, Capabilities, Tick, Transaction, VirtualAddress } from 'viem/tempo'
6
6
  import { tempo, tempoModerato } from 'viem/tempo/chains'
7
7
 
8
- import * as Relay from '../../../test/Relay.js'
9
- import * as Runtime from '../../../test/runtime.js'
8
+ import * as Relay from '../../test/Relay.js'
9
+ import * as Runtime from '../../test/runtime.js'
10
10
 
11
11
  type Server = Relay.Server
12
12
 
@@ -15,7 +15,7 @@ import {
15
15
  } from 'viem'
16
16
  import type { LocalAccount } from 'viem/accounts'
17
17
  import { simulateCalls } from 'viem/actions'
18
- import { Abis, Actions, Addresses, Capabilities, Transaction, VirtualAddress } from 'viem/tempo'
18
+ import { Abis, Actions, Addresses, Capabilities, VirtualAddress } from 'viem/tempo'
19
19
 
20
20
  import * as ExecutionError from './internal/executionError.js'
21
21
  import type * as RpcSchema from '../internal/RpcSchema.js'
@@ -150,6 +150,13 @@ export function relay(options: relay.Options): Handler {
150
150
 
151
151
  const { feePayer: _feePayer, ...normalized } =
152
152
  Utils.normalizeFillTransactionRequest(parameters)
153
+ const hasMultisigHints =
154
+ (typeof normalized['multisig'] === 'object' && normalized['multisig'] !== null) ||
155
+ (typeof normalized['multisigInit'] === 'object' &&
156
+ normalized['multisigInit'] !== null) ||
157
+ typeof normalized['multisigSignatureCount'] !== 'undefined'
158
+ const shouldDeferFeePayerSignature =
159
+ feePayerOptions && multisigOptions && hasMultisigHints
153
160
 
154
161
  // When sponsoring, the sponsor's preferred fee token (if set)
155
162
  // overrides whatever the consumer asked for — the sponsor is
@@ -362,9 +369,16 @@ export function relay(options: relay.Options): Handler {
362
369
  })(),
363
370
  // Sign as fee payer (if sponsored and not already signed).
364
371
  (async () => {
365
- if (!(sponsored && feePayerOptions && !alreadySigned)) return transaction_filled
372
+ // Multisig finalization changes the sender signature. Sign after quorum.
373
+ if (shouldDeferFeePayerSignature) return transaction_filled
374
+ // Never sign with the managed fee payer for an app-provided
375
+ // external fee payer URL: that relay is the sponsorship authority,
376
+ // and signing here would bypass this fee payer's `validate` gate.
377
+ if (!(sponsored && feePayerOptions && !externalFeePayerUrl && !alreadySigned))
378
+ return transaction_filled
366
379
  return Sponsorship.sign({
367
380
  account: feePayerOptions.account,
381
+ onSponsored: feePayerOptions.onSponsored,
368
382
  sender: from,
369
383
  transaction: transaction_filled,
370
384
  })
@@ -519,6 +533,7 @@ export function relay(options: relay.Options): Handler {
519
533
  ? {
520
534
  account: feePayerOptions.account,
521
535
  feeToken: feePayerOptions.feeToken,
536
+ onSponsored: feePayerOptions.onSponsored,
522
537
  resolveFeeToken: async (chainId) => (await getTokens(chainId))[0],
523
538
  validate: feePayerOptions.validate,
524
539
  }
@@ -563,6 +578,7 @@ export function relay(options: relay.Options): Handler {
563
578
  getFeeToken: async (chainId) => (await getTokens(chainId))[0],
564
579
  getClient,
565
580
  method: request.method as Sponsorship.handleRawTransaction.Options['method'],
581
+ onSponsored: feePayerOptions.onSponsored,
566
582
  request: { params: 'params' in request ? request.params : undefined },
567
583
  validate: feePayerOptions.validate,
568
584
  })
@@ -660,13 +676,15 @@ export namespace relay {
660
676
  account: LocalAccount
661
677
  /** Preferred fee token the sponsor wants to pay fees in. */
662
678
  feeToken?: Address | undefined
679
+ /**
680
+ * Called once the fee payer has signed a raw transaction.
681
+ */
682
+ onSponsored?: Sponsorship.handleRawTransaction.Options['onSponsored']
663
683
  /**
664
684
  * Validates whether to sponsor the transaction. When omitted, all
665
685
  * transactions are sponsored. Return `false` to reject sponsorship.
666
686
  */
667
- validate?:
668
- | ((request: Transaction.TransactionRequest) => boolean | Promise<boolean>)
669
- | undefined
687
+ validate?: Sponsorship.Validate | undefined
670
688
  /** Sponsor display name returned from `eth_fillTransaction`. */
671
689
  name?: string | undefined
672
690
  /** Sponsor URL returned from `eth_fillTransaction`. */
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * as Analytics from './analytics/Analytics.js'
1
2
  export * as ApiKey from './ApiKey.js'
2
3
  export * as ApiKeys from './ApiKeys.js'
3
4
  export * as App from './App.js'