@filoz/ponder 0.0.0-bootstrap.0 → 0.17.4-filecoin.4

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 (616) hide show
  1. package/CHANGELOG.md +3537 -0
  2. package/LICENSE +21 -0
  3. package/README.md +88 -0
  4. package/dist/esm/bin/commands/codegen.js +37 -0
  5. package/dist/esm/bin/commands/codegen.js.map +1 -0
  6. package/dist/esm/bin/commands/createViews.js +171 -0
  7. package/dist/esm/bin/commands/createViews.js.map +1 -0
  8. package/dist/esm/bin/commands/dev.js +412 -0
  9. package/dist/esm/bin/commands/dev.js.map +1 -0
  10. package/dist/esm/bin/commands/list.js +144 -0
  11. package/dist/esm/bin/commands/list.js.map +1 -0
  12. package/dist/esm/bin/commands/prune.js +219 -0
  13. package/dist/esm/bin/commands/prune.js.map +1 -0
  14. package/dist/esm/bin/commands/serve.js +183 -0
  15. package/dist/esm/bin/commands/serve.js.map +1 -0
  16. package/dist/esm/bin/commands/start.js +237 -0
  17. package/dist/esm/bin/commands/start.js.map +1 -0
  18. package/dist/esm/bin/isolatedController.js +200 -0
  19. package/dist/esm/bin/isolatedController.js.map +1 -0
  20. package/dist/esm/bin/isolatedWorker.js +141 -0
  21. package/dist/esm/bin/isolatedWorker.js.map +1 -0
  22. package/dist/esm/bin/ponder.js +137 -0
  23. package/dist/esm/bin/ponder.js.map +1 -0
  24. package/dist/esm/bin/utils/codegen.js +25 -0
  25. package/dist/esm/bin/utils/codegen.js.map +1 -0
  26. package/dist/esm/bin/utils/exit.js +96 -0
  27. package/dist/esm/bin/utils/exit.js.map +1 -0
  28. package/dist/esm/build/config.js +745 -0
  29. package/dist/esm/build/config.js.map +1 -0
  30. package/dist/esm/build/factory.js +82 -0
  31. package/dist/esm/build/factory.js.map +1 -0
  32. package/dist/esm/build/index.js +570 -0
  33. package/dist/esm/build/index.js.map +1 -0
  34. package/dist/esm/build/plugin.js +53 -0
  35. package/dist/esm/build/plugin.js.map +1 -0
  36. package/dist/esm/build/pre.js +83 -0
  37. package/dist/esm/build/pre.js.map +1 -0
  38. package/dist/esm/build/schema.js +195 -0
  39. package/dist/esm/build/schema.js.map +1 -0
  40. package/dist/esm/build/stacktrace.js +137 -0
  41. package/dist/esm/build/stacktrace.js.map +1 -0
  42. package/dist/esm/client/index.js +440 -0
  43. package/dist/esm/client/index.js.map +1 -0
  44. package/dist/esm/config/address.js +2 -0
  45. package/dist/esm/config/address.js.map +1 -0
  46. package/dist/esm/config/eventFilter.js +2 -0
  47. package/dist/esm/config/eventFilter.js.map +1 -0
  48. package/dist/esm/config/index.js +2 -0
  49. package/dist/esm/config/index.js.map +1 -0
  50. package/dist/esm/config/utilityTypes.js +2 -0
  51. package/dist/esm/config/utilityTypes.js.map +1 -0
  52. package/dist/esm/database/actions.js +395 -0
  53. package/dist/esm/database/actions.js.map +1 -0
  54. package/dist/esm/database/index.js +604 -0
  55. package/dist/esm/database/index.js.map +1 -0
  56. package/dist/esm/database/queryBuilder.js +311 -0
  57. package/dist/esm/database/queryBuilder.js.map +1 -0
  58. package/dist/esm/drizzle/bigint.js +36 -0
  59. package/dist/esm/drizzle/bigint.js.map +1 -0
  60. package/dist/esm/drizzle/bytes.js +45 -0
  61. package/dist/esm/drizzle/bytes.js.map +1 -0
  62. package/dist/esm/drizzle/hex.js +38 -0
  63. package/dist/esm/drizzle/hex.js.map +1 -0
  64. package/dist/esm/drizzle/index.js +28 -0
  65. package/dist/esm/drizzle/index.js.map +1 -0
  66. package/dist/esm/drizzle/json.js +119 -0
  67. package/dist/esm/drizzle/json.js.map +1 -0
  68. package/dist/esm/drizzle/kit/index.js +913 -0
  69. package/dist/esm/drizzle/kit/index.js.map +1 -0
  70. package/dist/esm/drizzle/onchain.js +226 -0
  71. package/dist/esm/drizzle/onchain.js.map +1 -0
  72. package/dist/esm/drizzle/text.js +59 -0
  73. package/dist/esm/drizzle/text.js.map +1 -0
  74. package/dist/esm/graphql/graphiql.html.js +59 -0
  75. package/dist/esm/graphql/graphiql.html.js.map +1 -0
  76. package/dist/esm/graphql/index.js +964 -0
  77. package/dist/esm/graphql/index.js.map +1 -0
  78. package/dist/esm/graphql/json.js +42 -0
  79. package/dist/esm/graphql/json.js.map +1 -0
  80. package/dist/esm/graphql/middleware.js +83 -0
  81. package/dist/esm/graphql/middleware.js.map +1 -0
  82. package/dist/esm/index.js +9 -0
  83. package/dist/esm/index.js.map +1 -0
  84. package/dist/esm/indexing/addStackTrace.js +54 -0
  85. package/dist/esm/indexing/addStackTrace.js.map +1 -0
  86. package/dist/esm/indexing/client.js +674 -0
  87. package/dist/esm/indexing/client.js.map +1 -0
  88. package/dist/esm/indexing/index.js +665 -0
  89. package/dist/esm/indexing/index.js.map +1 -0
  90. package/dist/esm/indexing/profile.js +584 -0
  91. package/dist/esm/indexing/profile.js.map +1 -0
  92. package/dist/esm/indexing-store/cache.js +657 -0
  93. package/dist/esm/indexing-store/cache.js.map +1 -0
  94. package/dist/esm/indexing-store/index.js +457 -0
  95. package/dist/esm/indexing-store/index.js.map +1 -0
  96. package/dist/esm/indexing-store/profile.js +428 -0
  97. package/dist/esm/indexing-store/profile.js.map +1 -0
  98. package/dist/esm/indexing-store/utils.js +131 -0
  99. package/dist/esm/indexing-store/utils.js.map +1 -0
  100. package/dist/esm/internal/common.js +2 -0
  101. package/dist/esm/internal/common.js.map +1 -0
  102. package/dist/esm/internal/errors.js +300 -0
  103. package/dist/esm/internal/errors.js.map +1 -0
  104. package/dist/esm/internal/logger.js +178 -0
  105. package/dist/esm/internal/logger.js.map +1 -0
  106. package/dist/esm/internal/metrics.js +1117 -0
  107. package/dist/esm/internal/metrics.js.map +1 -0
  108. package/dist/esm/internal/options.js +70 -0
  109. package/dist/esm/internal/options.js.map +1 -0
  110. package/dist/esm/internal/shutdown.js +24 -0
  111. package/dist/esm/internal/shutdown.js.map +1 -0
  112. package/dist/esm/internal/types.js +2 -0
  113. package/dist/esm/internal/types.js.map +1 -0
  114. package/dist/esm/rpc/actions.js +1051 -0
  115. package/dist/esm/rpc/actions.js.map +1 -0
  116. package/dist/esm/rpc/http.js +134 -0
  117. package/dist/esm/rpc/http.js.map +1 -0
  118. package/dist/esm/rpc/index.js +767 -0
  119. package/dist/esm/rpc/index.js.map +1 -0
  120. package/dist/esm/runtime/events.js +662 -0
  121. package/dist/esm/runtime/events.js.map +1 -0
  122. package/dist/esm/runtime/filter.js +443 -0
  123. package/dist/esm/runtime/filter.js.map +1 -0
  124. package/dist/esm/runtime/fragments.js +478 -0
  125. package/dist/esm/runtime/fragments.js.map +1 -0
  126. package/dist/esm/runtime/historical.js +941 -0
  127. package/dist/esm/runtime/historical.js.map +1 -0
  128. package/dist/esm/runtime/index.js +335 -0
  129. package/dist/esm/runtime/index.js.map +1 -0
  130. package/dist/esm/runtime/isolated.js +471 -0
  131. package/dist/esm/runtime/isolated.js.map +1 -0
  132. package/dist/esm/runtime/multichain.js +518 -0
  133. package/dist/esm/runtime/multichain.js.map +1 -0
  134. package/dist/esm/runtime/omnichain.js +553 -0
  135. package/dist/esm/runtime/omnichain.js.map +1 -0
  136. package/dist/esm/runtime/realtime.js +724 -0
  137. package/dist/esm/runtime/realtime.js.map +1 -0
  138. package/dist/esm/server/error.js +56 -0
  139. package/dist/esm/server/error.js.map +1 -0
  140. package/dist/esm/server/index.js +121 -0
  141. package/dist/esm/server/index.js.map +1 -0
  142. package/dist/esm/sync-historical/index.js +731 -0
  143. package/dist/esm/sync-historical/index.js.map +1 -0
  144. package/dist/esm/sync-realtime/bloom.js +76 -0
  145. package/dist/esm/sync-realtime/bloom.js.map +1 -0
  146. package/dist/esm/sync-realtime/index.js +972 -0
  147. package/dist/esm/sync-realtime/index.js.map +1 -0
  148. package/dist/esm/sync-store/encode.js +105 -0
  149. package/dist/esm/sync-store/encode.js.map +1 -0
  150. package/dist/esm/sync-store/index.js +864 -0
  151. package/dist/esm/sync-store/index.js.map +1 -0
  152. package/dist/esm/sync-store/migrations.js +1595 -0
  153. package/dist/esm/sync-store/migrations.js.map +1 -0
  154. package/dist/esm/sync-store/schema.js +181 -0
  155. package/dist/esm/sync-store/schema.js.map +1 -0
  156. package/dist/esm/types/db.js +2 -0
  157. package/dist/esm/types/db.js.map +1 -0
  158. package/dist/esm/types/eth.js +2 -0
  159. package/dist/esm/types/eth.js.map +1 -0
  160. package/dist/esm/types/utils.js +2 -0
  161. package/dist/esm/types/utils.js.map +1 -0
  162. package/dist/esm/types/virtual.js +2 -0
  163. package/dist/esm/types/virtual.js.map +1 -0
  164. package/dist/esm/ui/app.js +157 -0
  165. package/dist/esm/ui/app.js.map +1 -0
  166. package/dist/esm/ui/index.js +29 -0
  167. package/dist/esm/ui/index.js.map +1 -0
  168. package/dist/esm/ui/patch.js +139 -0
  169. package/dist/esm/ui/patch.js.map +1 -0
  170. package/dist/esm/utils/abi.js +55 -0
  171. package/dist/esm/utils/abi.js.map +1 -0
  172. package/dist/esm/utils/bigint.js +37 -0
  173. package/dist/esm/utils/bigint.js.map +1 -0
  174. package/dist/esm/utils/chains.js +21 -0
  175. package/dist/esm/utils/chains.js.map +1 -0
  176. package/dist/esm/utils/checkpoint.js +139 -0
  177. package/dist/esm/utils/checkpoint.js.map +1 -0
  178. package/dist/esm/utils/chunk.js +8 -0
  179. package/dist/esm/utils/chunk.js.map +1 -0
  180. package/dist/esm/utils/copy.js +140 -0
  181. package/dist/esm/utils/copy.js.map +1 -0
  182. package/dist/esm/utils/date.js +27 -0
  183. package/dist/esm/utils/date.js.map +1 -0
  184. package/dist/esm/utils/debug.js +2 -0
  185. package/dist/esm/utils/debug.js.map +1 -0
  186. package/dist/esm/utils/decodeAbiParameters.js +289 -0
  187. package/dist/esm/utils/decodeAbiParameters.js.map +1 -0
  188. package/dist/esm/utils/decodeEventLog.js +75 -0
  189. package/dist/esm/utils/decodeEventLog.js.map +1 -0
  190. package/dist/esm/utils/dedupe.js +29 -0
  191. package/dist/esm/utils/dedupe.js.map +1 -0
  192. package/dist/esm/utils/duplicates.js +19 -0
  193. package/dist/esm/utils/duplicates.js.map +1 -0
  194. package/dist/esm/utils/estimate.js +6 -0
  195. package/dist/esm/utils/estimate.js.map +1 -0
  196. package/dist/esm/utils/finality.js +49 -0
  197. package/dist/esm/utils/finality.js.map +1 -0
  198. package/dist/esm/utils/format.js +20 -0
  199. package/dist/esm/utils/format.js.map +1 -0
  200. package/dist/esm/utils/generators.js +121 -0
  201. package/dist/esm/utils/generators.js.map +1 -0
  202. package/dist/esm/utils/getLogsRetryHelper.js +40 -0
  203. package/dist/esm/utils/getLogsRetryHelper.js.map +1 -0
  204. package/dist/esm/utils/hash.js +11 -0
  205. package/dist/esm/utils/hash.js.map +1 -0
  206. package/dist/esm/utils/interval.js +171 -0
  207. package/dist/esm/utils/interval.js.map +1 -0
  208. package/dist/esm/utils/lowercase.js +7 -0
  209. package/dist/esm/utils/lowercase.js.map +1 -0
  210. package/dist/esm/utils/mutex.js +26 -0
  211. package/dist/esm/utils/mutex.js.map +1 -0
  212. package/dist/esm/utils/never.js +4 -0
  213. package/dist/esm/utils/never.js.map +1 -0
  214. package/dist/esm/utils/offset.js +101 -0
  215. package/dist/esm/utils/offset.js.map +1 -0
  216. package/dist/esm/utils/order.js +18 -0
  217. package/dist/esm/utils/order.js.map +1 -0
  218. package/dist/esm/utils/partition.js +46 -0
  219. package/dist/esm/utils/partition.js.map +1 -0
  220. package/dist/esm/utils/pg.js +175 -0
  221. package/dist/esm/utils/pg.js.map +1 -0
  222. package/dist/esm/utils/pglite.js +78 -0
  223. package/dist/esm/utils/pglite.js.map +1 -0
  224. package/dist/esm/utils/port.js +30 -0
  225. package/dist/esm/utils/port.js.map +1 -0
  226. package/dist/esm/utils/print.js +24 -0
  227. package/dist/esm/utils/print.js.map +1 -0
  228. package/dist/esm/utils/promiseAllSettledWithThrow.js +19 -0
  229. package/dist/esm/utils/promiseAllSettledWithThrow.js.map +1 -0
  230. package/dist/esm/utils/promiseWithResolvers.js +13 -0
  231. package/dist/esm/utils/promiseWithResolvers.js.map +1 -0
  232. package/dist/esm/utils/queue.js +150 -0
  233. package/dist/esm/utils/queue.js.map +1 -0
  234. package/dist/esm/utils/range.js +8 -0
  235. package/dist/esm/utils/range.js.map +1 -0
  236. package/dist/esm/utils/result.js +10 -0
  237. package/dist/esm/utils/result.js.map +1 -0
  238. package/dist/esm/utils/sql-parse.js +1326 -0
  239. package/dist/esm/utils/sql-parse.js.map +1 -0
  240. package/dist/esm/utils/timer.js +9 -0
  241. package/dist/esm/utils/timer.js.map +1 -0
  242. package/dist/esm/utils/truncate.js +15 -0
  243. package/dist/esm/utils/truncate.js.map +1 -0
  244. package/dist/esm/utils/wait.js +10 -0
  245. package/dist/esm/utils/wait.js.map +1 -0
  246. package/dist/esm/utils/zipper.js +67 -0
  247. package/dist/esm/utils/zipper.js.map +1 -0
  248. package/dist/types/bin/commands/codegen.d.ts +5 -0
  249. package/dist/types/bin/commands/codegen.d.ts.map +1 -0
  250. package/dist/types/bin/commands/createViews.d.ts +8 -0
  251. package/dist/types/bin/commands/createViews.d.ts.map +1 -0
  252. package/dist/types/bin/commands/dev.d.ts +5 -0
  253. package/dist/types/bin/commands/dev.d.ts.map +1 -0
  254. package/dist/types/bin/commands/list.d.ts +5 -0
  255. package/dist/types/bin/commands/list.d.ts.map +1 -0
  256. package/dist/types/bin/commands/prune.d.ts +5 -0
  257. package/dist/types/bin/commands/prune.d.ts.map +1 -0
  258. package/dist/types/bin/commands/serve.d.ts +5 -0
  259. package/dist/types/bin/commands/serve.d.ts.map +1 -0
  260. package/dist/types/bin/commands/start.d.ts +19 -0
  261. package/dist/types/bin/commands/start.d.ts.map +1 -0
  262. package/dist/types/bin/isolatedController.d.ts +13 -0
  263. package/dist/types/bin/isolatedController.d.ts.map +1 -0
  264. package/dist/types/bin/isolatedWorker.d.ts +9 -0
  265. package/dist/types/bin/isolatedWorker.d.ts.map +1 -0
  266. package/dist/types/bin/ponder.d.ts +37 -0
  267. package/dist/types/bin/ponder.d.ts.map +1 -0
  268. package/dist/types/bin/utils/codegen.d.ts +6 -0
  269. package/dist/types/bin/utils/codegen.d.ts.map +1 -0
  270. package/dist/types/bin/utils/exit.d.ts +10 -0
  271. package/dist/types/bin/utils/exit.d.ts.map +1 -0
  272. package/dist/types/build/config.d.ts +97 -0
  273. package/dist/types/build/config.d.ts.map +1 -0
  274. package/dist/types/build/factory.d.ts +9 -0
  275. package/dist/types/build/factory.d.ts.map +1 -0
  276. package/dist/types/build/index.d.ts +84 -0
  277. package/dist/types/build/index.d.ts.map +1 -0
  278. package/dist/types/build/plugin.d.ts +4 -0
  279. package/dist/types/build/plugin.d.ts.map +1 -0
  280. package/dist/types/build/pre.d.ts +29 -0
  281. package/dist/types/build/pre.d.ts.map +1 -0
  282. package/dist/types/build/schema.d.ts +20 -0
  283. package/dist/types/build/schema.d.ts.map +1 -0
  284. package/dist/types/build/stacktrace.d.ts +13 -0
  285. package/dist/types/build/stacktrace.d.ts.map +1 -0
  286. package/dist/types/client/index.d.ts +27 -0
  287. package/dist/types/client/index.d.ts.map +1 -0
  288. package/dist/types/config/address.d.ts +35 -0
  289. package/dist/types/config/address.d.ts.map +1 -0
  290. package/dist/types/config/eventFilter.d.ts +18 -0
  291. package/dist/types/config/eventFilter.d.ts.map +1 -0
  292. package/dist/types/config/index.d.ts +144 -0
  293. package/dist/types/config/index.d.ts.map +1 -0
  294. package/dist/types/config/utilityTypes.d.ts +43 -0
  295. package/dist/types/config/utilityTypes.d.ts.map +1 -0
  296. package/dist/types/database/actions.d.ts +99 -0
  297. package/dist/types/database/actions.d.ts.map +1 -0
  298. package/dist/types/database/index.d.ts +493 -0
  299. package/dist/types/database/index.d.ts.map +1 -0
  300. package/dist/types/database/queryBuilder.d.ts +65 -0
  301. package/dist/types/database/queryBuilder.d.ts.map +1 -0
  302. package/dist/types/drizzle/bigint.d.ts +25 -0
  303. package/dist/types/drizzle/bigint.d.ts.map +1 -0
  304. package/dist/types/drizzle/bytes.d.ts +32 -0
  305. package/dist/types/drizzle/bytes.d.ts.map +1 -0
  306. package/dist/types/drizzle/hex.d.ts +25 -0
  307. package/dist/types/drizzle/hex.d.ts.map +1 -0
  308. package/dist/types/drizzle/index.d.ts +6 -0
  309. package/dist/types/drizzle/index.d.ts.map +1 -0
  310. package/dist/types/drizzle/json.d.ts +51 -0
  311. package/dist/types/drizzle/json.d.ts.map +1 -0
  312. package/dist/types/drizzle/kit/index.d.ts +187 -0
  313. package/dist/types/drizzle/kit/index.d.ts.map +1 -0
  314. package/dist/types/drizzle/onchain.d.ts +302 -0
  315. package/dist/types/drizzle/onchain.d.ts.map +1 -0
  316. package/dist/types/drizzle/text.d.ts +29 -0
  317. package/dist/types/drizzle/text.d.ts.map +1 -0
  318. package/dist/types/graphql/graphiql.html.d.ts +2 -0
  319. package/dist/types/graphql/graphiql.html.d.ts.map +1 -0
  320. package/dist/types/graphql/index.d.ts +12 -0
  321. package/dist/types/graphql/index.d.ts.map +1 -0
  322. package/dist/types/graphql/json.d.ts +3 -0
  323. package/dist/types/graphql/json.d.ts.map +1 -0
  324. package/dist/types/graphql/middleware.d.ts +29 -0
  325. package/dist/types/graphql/middleware.d.ts.map +1 -0
  326. package/dist/types/index.d.ts +23 -0
  327. package/dist/types/index.d.ts.map +1 -0
  328. package/dist/types/indexing/addStackTrace.d.ts +3 -0
  329. package/dist/types/indexing/addStackTrace.d.ts.map +1 -0
  330. package/dist/types/indexing/client.d.ts +153 -0
  331. package/dist/types/indexing/client.d.ts.map +1 -0
  332. package/dist/types/indexing/index.d.ts +72 -0
  333. package/dist/types/indexing/index.d.ts.map +1 -0
  334. package/dist/types/indexing/profile.d.ts +16 -0
  335. package/dist/types/indexing/profile.d.ts.map +1 -0
  336. package/dist/types/indexing-store/cache.d.ts +115 -0
  337. package/dist/types/indexing-store/cache.d.ts.map +1 -0
  338. package/dist/types/indexing-store/index.d.ts +23 -0
  339. package/dist/types/indexing-store/index.d.ts.map +1 -0
  340. package/dist/types/indexing-store/profile.d.ts +7 -0
  341. package/dist/types/indexing-store/profile.d.ts.map +1 -0
  342. package/dist/types/indexing-store/utils.d.ts +24 -0
  343. package/dist/types/indexing-store/utils.d.ts.map +1 -0
  344. package/dist/types/internal/common.d.ts +13 -0
  345. package/dist/types/internal/common.d.ts.map +1 -0
  346. package/dist/types/internal/errors.d.ts +101 -0
  347. package/dist/types/internal/errors.d.ts.map +1 -0
  348. package/dist/types/internal/logger.d.ts +37 -0
  349. package/dist/types/internal/logger.d.ts.map +1 -0
  350. package/dist/types/internal/metrics.d.ts +133 -0
  351. package/dist/types/internal/metrics.d.ts.map +1 -0
  352. package/dist/types/internal/options.d.ts +56 -0
  353. package/dist/types/internal/options.d.ts.map +1 -0
  354. package/dist/types/internal/shutdown.d.ts +8 -0
  355. package/dist/types/internal/shutdown.d.ts.map +1 -0
  356. package/dist/types/internal/types.d.ts +433 -0
  357. package/dist/types/internal/types.d.ts.map +1 -0
  358. package/dist/types/rpc/actions.d.ts +378 -0
  359. package/dist/types/rpc/actions.d.ts.map +1 -0
  360. package/dist/types/rpc/http.d.ts +17 -0
  361. package/dist/types/rpc/http.d.ts.map +1 -0
  362. package/dist/types/rpc/index.d.ts +43 -0
  363. package/dist/types/rpc/index.d.ts.map +1 -0
  364. package/dist/types/runtime/events.d.ts +40 -0
  365. package/dist/types/runtime/events.d.ts.map +1 -0
  366. package/dist/types/runtime/filter.d.ts +87 -0
  367. package/dist/types/runtime/filter.d.ts.map +1 -0
  368. package/dist/types/runtime/fragments.d.ts +30 -0
  369. package/dist/types/runtime/fragments.d.ts.map +1 -0
  370. package/dist/types/runtime/historical.d.ts +123 -0
  371. package/dist/types/runtime/historical.d.ts.map +1 -0
  372. package/dist/types/runtime/index.d.ts +88 -0
  373. package/dist/types/runtime/index.d.ts.map +1 -0
  374. package/dist/types/runtime/isolated.d.ts +14 -0
  375. package/dist/types/runtime/isolated.d.ts.map +1 -0
  376. package/dist/types/runtime/multichain.d.ts +13 -0
  377. package/dist/types/runtime/multichain.d.ts.map +1 -0
  378. package/dist/types/runtime/omnichain.d.ts +23 -0
  379. package/dist/types/runtime/omnichain.d.ts.map +1 -0
  380. package/dist/types/runtime/realtime.d.ts +93 -0
  381. package/dist/types/runtime/realtime.d.ts.map +1 -0
  382. package/dist/types/server/error.d.ts +5 -0
  383. package/dist/types/server/error.d.ts.map +1 -0
  384. package/dist/types/server/index.d.ts +13 -0
  385. package/dist/types/server/index.d.ts.map +1 -0
  386. package/dist/types/sync-historical/index.d.ts +36 -0
  387. package/dist/types/sync-historical/index.d.ts.map +1 -0
  388. package/dist/types/sync-realtime/bloom.d.ts +18 -0
  389. package/dist/types/sync-realtime/bloom.d.ts.map +1 -0
  390. package/dist/types/sync-realtime/index.d.ts +47 -0
  391. package/dist/types/sync-realtime/index.d.ts.map +1 -0
  392. package/dist/types/sync-store/encode.d.ts +25 -0
  393. package/dist/types/sync-store/encode.d.ts.map +1 -0
  394. package/dist/types/sync-store/index.d.ts +146 -0
  395. package/dist/types/sync-store/index.d.ts.map +1 -0
  396. package/dist/types/sync-store/migrations.d.ts +8 -0
  397. package/dist/types/sync-store/migrations.d.ts.map +1 -0
  398. package/dist/types/sync-store/schema.d.ts +1828 -0
  399. package/dist/types/sync-store/schema.d.ts.map +1 -0
  400. package/dist/types/types/db.d.ts +213 -0
  401. package/dist/types/types/db.d.ts.map +1 -0
  402. package/dist/types/types/eth.d.ts +196 -0
  403. package/dist/types/types/eth.d.ts.map +1 -0
  404. package/dist/types/types/utils.d.ts +38 -0
  405. package/dist/types/types/utils.d.ts.map +1 -0
  406. package/dist/types/types/virtual.d.ts +99 -0
  407. package/dist/types/types/virtual.d.ts.map +1 -0
  408. package/dist/types/ui/app.d.ts +22 -0
  409. package/dist/types/ui/app.d.ts.map +1 -0
  410. package/dist/types/ui/index.d.ts +5 -0
  411. package/dist/types/ui/index.d.ts.map +1 -0
  412. package/dist/types/ui/patch.d.ts +7 -0
  413. package/dist/types/ui/patch.d.ts.map +1 -0
  414. package/dist/types/utils/abi.d.ts +23 -0
  415. package/dist/types/utils/abi.d.ts.map +1 -0
  416. package/dist/types/utils/bigint.d.ts +15 -0
  417. package/dist/types/utils/bigint.d.ts.map +1 -0
  418. package/dist/types/utils/chains.d.ts +44 -0
  419. package/dist/types/utils/chains.d.ts.map +1 -0
  420. package/dist/types/utils/checkpoint.d.ts +52 -0
  421. package/dist/types/utils/checkpoint.d.ts.map +1 -0
  422. package/dist/types/utils/chunk.d.ts +2 -0
  423. package/dist/types/utils/chunk.d.ts.map +1 -0
  424. package/dist/types/utils/copy.d.ts +16 -0
  425. package/dist/types/utils/copy.d.ts.map +1 -0
  426. package/dist/types/utils/date.d.ts +7 -0
  427. package/dist/types/utils/date.d.ts.map +1 -0
  428. package/dist/types/utils/debug.d.ts +105 -0
  429. package/dist/types/utils/debug.d.ts.map +1 -0
  430. package/dist/types/utils/decodeAbiParameters.d.ts +28 -0
  431. package/dist/types/utils/decodeAbiParameters.d.ts.map +1 -0
  432. package/dist/types/utils/decodeEventLog.d.ts +12 -0
  433. package/dist/types/utils/decodeEventLog.d.ts.map +1 -0
  434. package/dist/types/utils/dedupe.d.ts +20 -0
  435. package/dist/types/utils/dedupe.d.ts.map +1 -0
  436. package/dist/types/utils/duplicates.d.ts +7 -0
  437. package/dist/types/utils/duplicates.d.ts.map +1 -0
  438. package/dist/types/utils/estimate.d.ts +11 -0
  439. package/dist/types/utils/estimate.d.ts.map +1 -0
  440. package/dist/types/utils/finality.d.ts +15 -0
  441. package/dist/types/utils/finality.d.ts.map +1 -0
  442. package/dist/types/utils/format.d.ts +3 -0
  443. package/dist/types/utils/format.d.ts.map +1 -0
  444. package/dist/types/utils/generators.d.ts +42 -0
  445. package/dist/types/utils/generators.d.ts.map +1 -0
  446. package/dist/types/utils/getLogsRetryHelper.d.ts +3 -0
  447. package/dist/types/utils/getLogsRetryHelper.d.ts.map +1 -0
  448. package/dist/types/utils/hash.d.ts +11 -0
  449. package/dist/types/utils/hash.d.ts.map +1 -0
  450. package/dist/types/utils/interval.d.ts +53 -0
  451. package/dist/types/utils/interval.d.ts.map +1 -0
  452. package/dist/types/utils/lowercase.d.ts +5 -0
  453. package/dist/types/utils/lowercase.d.ts.map +1 -0
  454. package/dist/types/utils/mutex.d.ts +5 -0
  455. package/dist/types/utils/mutex.d.ts.map +1 -0
  456. package/dist/types/utils/never.d.ts +2 -0
  457. package/dist/types/utils/never.d.ts.map +1 -0
  458. package/dist/types/utils/offset.d.ts +8 -0
  459. package/dist/types/utils/offset.d.ts.map +1 -0
  460. package/dist/types/utils/order.d.ts +2 -0
  461. package/dist/types/utils/order.d.ts.map +1 -0
  462. package/dist/types/utils/partition.d.ts +22 -0
  463. package/dist/types/utils/partition.d.ts.map +1 -0
  464. package/dist/types/utils/pg.d.ts +8 -0
  465. package/dist/types/utils/pg.d.ts.map +1 -0
  466. package/dist/types/utils/pglite.d.ts +25 -0
  467. package/dist/types/utils/pglite.d.ts.map +1 -0
  468. package/dist/types/utils/port.d.ts +5 -0
  469. package/dist/types/utils/port.d.ts.map +1 -0
  470. package/dist/types/utils/print.d.ts +4 -0
  471. package/dist/types/utils/print.d.ts.map +1 -0
  472. package/dist/types/utils/promiseAllSettledWithThrow.d.ts +8 -0
  473. package/dist/types/utils/promiseAllSettledWithThrow.d.ts.map +1 -0
  474. package/dist/types/utils/promiseWithResolvers.d.ts +10 -0
  475. package/dist/types/utils/promiseWithResolvers.d.ts.map +1 -0
  476. package/dist/types/utils/queue.d.ts +33 -0
  477. package/dist/types/utils/queue.d.ts.map +1 -0
  478. package/dist/types/utils/range.d.ts +8 -0
  479. package/dist/types/utils/range.d.ts.map +1 -0
  480. package/dist/types/utils/result.d.ts +17 -0
  481. package/dist/types/utils/result.d.ts.map +1 -0
  482. package/dist/types/utils/sql-parse.d.ts +21 -0
  483. package/dist/types/utils/sql-parse.d.ts.map +1 -0
  484. package/dist/types/utils/timer.d.ts +6 -0
  485. package/dist/types/utils/timer.d.ts.map +1 -0
  486. package/dist/types/utils/truncate.d.ts +9 -0
  487. package/dist/types/utils/truncate.d.ts.map +1 -0
  488. package/dist/types/utils/wait.d.ts +6 -0
  489. package/dist/types/utils/wait.d.ts.map +1 -0
  490. package/dist/types/utils/zipper.d.ts +36 -0
  491. package/dist/types/utils/zipper.d.ts.map +1 -0
  492. package/package.json +121 -1
  493. package/src/bin/commands/codegen.ts +46 -0
  494. package/src/bin/commands/createViews.ts +295 -0
  495. package/src/bin/commands/dev.ts +470 -0
  496. package/src/bin/commands/list.ts +205 -0
  497. package/src/bin/commands/prune.ts +319 -0
  498. package/src/bin/commands/serve.ts +220 -0
  499. package/src/bin/commands/start.ts +302 -0
  500. package/src/bin/isolatedController.ts +300 -0
  501. package/src/bin/isolatedWorker.ts +186 -0
  502. package/src/bin/ponder.ts +208 -0
  503. package/src/bin/utils/codegen.ts +32 -0
  504. package/src/bin/utils/exit.ts +104 -0
  505. package/src/build/config.ts +1146 -0
  506. package/src/build/factory.ts +125 -0
  507. package/src/build/index.ts +800 -0
  508. package/src/build/plugin.ts +58 -0
  509. package/src/build/pre.ts +114 -0
  510. package/src/build/schema.ts +353 -0
  511. package/src/build/stacktrace.ts +137 -0
  512. package/src/client/index.ts +553 -0
  513. package/src/config/address.ts +46 -0
  514. package/src/config/eventFilter.ts +33 -0
  515. package/src/config/index.ts +240 -0
  516. package/src/config/utilityTypes.ts +152 -0
  517. package/src/database/actions.ts +825 -0
  518. package/src/database/index.ts +1029 -0
  519. package/src/database/queryBuilder.ts +535 -0
  520. package/src/drizzle/bigint.ts +57 -0
  521. package/src/drizzle/bytes.ts +68 -0
  522. package/src/drizzle/hex.ts +58 -0
  523. package/src/drizzle/index.ts +40 -0
  524. package/src/drizzle/json.ts +159 -0
  525. package/src/drizzle/kit/index.ts +1334 -0
  526. package/src/drizzle/onchain.ts +528 -0
  527. package/src/drizzle/text.ts +77 -0
  528. package/src/graphql/graphiql.html.ts +59 -0
  529. package/src/graphql/index.ts +1392 -0
  530. package/src/graphql/json.ts +62 -0
  531. package/src/graphql/middleware.ts +117 -0
  532. package/src/index.ts +131 -0
  533. package/src/indexing/addStackTrace.ts +69 -0
  534. package/src/indexing/client.ts +1187 -0
  535. package/src/indexing/index.ts +976 -0
  536. package/src/indexing/profile.ts +771 -0
  537. package/src/indexing-store/cache.ts +1059 -0
  538. package/src/indexing-store/index.ts +673 -0
  539. package/src/indexing-store/profile.ts +557 -0
  540. package/src/indexing-store/utils.ts +192 -0
  541. package/src/internal/common.ts +13 -0
  542. package/src/internal/errors.ts +228 -0
  543. package/src/internal/logger.ts +255 -0
  544. package/src/internal/metrics.ts +1111 -0
  545. package/src/internal/options.ts +122 -0
  546. package/src/internal/shutdown.ts +32 -0
  547. package/src/internal/types.ts +596 -0
  548. package/src/rpc/actions.ts +1423 -0
  549. package/src/rpc/http.ts +168 -0
  550. package/src/rpc/index.ts +980 -0
  551. package/src/runtime/events.ts +876 -0
  552. package/src/runtime/filter.ts +670 -0
  553. package/src/runtime/fragments.ts +674 -0
  554. package/src/runtime/historical.ts +1497 -0
  555. package/src/runtime/index.ts +594 -0
  556. package/src/runtime/isolated.ts +785 -0
  557. package/src/runtime/multichain.ts +867 -0
  558. package/src/runtime/omnichain.ts +927 -0
  559. package/src/runtime/realtime.ts +1164 -0
  560. package/src/server/error.ts +68 -0
  561. package/src/server/index.ts +173 -0
  562. package/src/sync-historical/index.ts +1094 -0
  563. package/src/sync-realtime/bloom.ts +102 -0
  564. package/src/sync-realtime/index.ts +1366 -0
  565. package/src/sync-store/encode.ts +153 -0
  566. package/src/sync-store/index.ts +1616 -0
  567. package/src/sync-store/migrations.ts +1801 -0
  568. package/src/sync-store/schema.ts +248 -0
  569. package/src/types/db.ts +292 -0
  570. package/src/types/eth.ts +216 -0
  571. package/src/types/utils.ts +47 -0
  572. package/src/types/virtual.ts +244 -0
  573. package/src/types.d.ts +40 -0
  574. package/src/ui/app.ts +207 -0
  575. package/src/ui/index.ts +37 -0
  576. package/src/ui/patch.ts +203 -0
  577. package/src/utils/abi.ts +106 -0
  578. package/src/utils/bigint.ts +41 -0
  579. package/src/utils/chains.ts +22 -0
  580. package/src/utils/checkpoint.ts +203 -0
  581. package/src/utils/chunk.ts +7 -0
  582. package/src/utils/copy.ts +165 -0
  583. package/src/utils/date.ts +26 -0
  584. package/src/utils/debug.ts +110 -0
  585. package/src/utils/decodeAbiParameters.ts +426 -0
  586. package/src/utils/decodeEventLog.ts +100 -0
  587. package/src/utils/dedupe.ts +32 -0
  588. package/src/utils/duplicates.ts +19 -0
  589. package/src/utils/estimate.ts +27 -0
  590. package/src/utils/finality.ts +54 -0
  591. package/src/utils/format.ts +22 -0
  592. package/src/utils/generators.ts +157 -0
  593. package/src/utils/getLogsRetryHelper.ts +46 -0
  594. package/src/utils/hash.ts +22 -0
  595. package/src/utils/interval.ts +212 -0
  596. package/src/utils/lowercase.ts +6 -0
  597. package/src/utils/mutex.ts +33 -0
  598. package/src/utils/never.ts +3 -0
  599. package/src/utils/offset.ts +133 -0
  600. package/src/utils/order.ts +16 -0
  601. package/src/utils/partition.ts +53 -0
  602. package/src/utils/pg.ts +230 -0
  603. package/src/utils/pglite.ts +96 -0
  604. package/src/utils/port.ts +34 -0
  605. package/src/utils/print.ts +34 -0
  606. package/src/utils/promiseAllSettledWithThrow.ts +27 -0
  607. package/src/utils/promiseWithResolvers.ts +20 -0
  608. package/src/utils/queue.ts +258 -0
  609. package/src/utils/range.ts +8 -0
  610. package/src/utils/result.ts +26 -0
  611. package/src/utils/sql-parse.ts +1477 -0
  612. package/src/utils/timer.ts +8 -0
  613. package/src/utils/truncate.ts +15 -0
  614. package/src/utils/wait.ts +8 -0
  615. package/src/utils/zipper.ts +80 -0
  616. package/tsconfig.json +12 -0
@@ -0,0 +1,1051 @@
1
+ import { BlockNotFoundError, hexToBigInt, hexToNumber, isHex, numberToHex, TransactionReceiptNotFoundError, zeroAddress, zeroHash, } from "viem";
2
+ import { RpcProviderError } from '../internal/errors.js';
3
+ import { zeroLogsBloom } from '../sync-realtime/bloom.js';
4
+ import { isFilecoinChain } from '../utils/finality.js';
5
+ import { PG_BIGINT_MAX, PG_INTEGER_MAX } from '../utils/pg.js';
6
+ /**
7
+ * Returns true if the error indicates a null round (an epoch with no block).
8
+ * Matches RPC error code 12 or a "null round" error message.
9
+ */
10
+ export function isNullRoundError(error) {
11
+ if (error && typeof error === "object") {
12
+ // Filecoin null rounds return RPC error code 12
13
+ if ("cause" in error &&
14
+ error.cause &&
15
+ typeof error.cause === "object" &&
16
+ "code" in error.cause &&
17
+ error.cause.code === 12) {
18
+ return true;
19
+ }
20
+ // Check the error message as a fallback
21
+ if ("message" in error &&
22
+ typeof error.message === "string" &&
23
+ error.message.includes("null round")) {
24
+ return true;
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+ /**
30
+ * Returns true if the error indicates that a block does not exist.
31
+ * Handles both viem's BlockNotFoundError (null response) and Filecoin's
32
+ * RPC error code 12 ("requested epoch was a null round").
33
+ */
34
+ export function isBlockNotFoundError(error) {
35
+ if (error instanceof BlockNotFoundError)
36
+ return true;
37
+ if (error && typeof error === "object") {
38
+ if ("cause" in error && error.cause instanceof BlockNotFoundError) {
39
+ return true;
40
+ }
41
+ }
42
+ return isNullRoundError(error);
43
+ }
44
+ /**
45
+ * Helper function for "eth_getBlockByNumber" request.
46
+ */
47
+ export const eth_getBlockByNumber = (rpc, params, context) => rpc
48
+ .request({ method: "eth_getBlockByNumber", params }, context)
49
+ .then((_block) => {
50
+ if (!_block) {
51
+ let blockNumber;
52
+ if (isHex(params[0])) {
53
+ blockNumber = hexToBigInt(params[0]);
54
+ }
55
+ else {
56
+ // @ts-expect-error `BlockNotFoundError` expects a bigint, but it also just passes
57
+ // the `blockNumber` directly to the error message, so breaking the type constraint is fine.
58
+ blockNumber = params[0];
59
+ }
60
+ throw new BlockNotFoundError({ blockNumber });
61
+ }
62
+ return standardizeBlock(_block, {
63
+ method: "eth_getBlockByNumber",
64
+ params,
65
+ });
66
+ });
67
+ // Null rounds come in short runs; a longer run means the RPC is unhealthy.
68
+ const MAX_NULL_ROUNDS = 1_000;
69
+ /**
70
+ * The block at `blockNumber`, or the nearest block below it when that height is
71
+ * a null round (a Filecoin epoch without a block).
72
+ */
73
+ export const eth_getBlockAtOrBelow = async (rpc, blockNumber, context) => {
74
+ for (let n = blockNumber;; n--) {
75
+ try {
76
+ return await eth_getBlockByNumber(rpc, [numberToHex(n), false], context);
77
+ }
78
+ catch (error) {
79
+ if (!isNullRoundError(error) ||
80
+ n === 0 ||
81
+ blockNumber - n >= MAX_NULL_ROUNDS) {
82
+ throw error;
83
+ }
84
+ }
85
+ }
86
+ };
87
+ /**
88
+ * Helper function for "eth_getBlockByHash" request.
89
+ */
90
+ export const eth_getBlockByHash = (rpc, params, context) => rpc
91
+ .request({ method: "eth_getBlockByHash", params }, context)
92
+ .then((_block) => {
93
+ if (!_block)
94
+ throw new BlockNotFoundError({ blockHash: params[0] });
95
+ return standardizeBlock(_block, {
96
+ method: "eth_getBlockByHash",
97
+ params,
98
+ });
99
+ });
100
+ /**
101
+ * Helper function for "eth_getLogs" rpc request.
102
+ * Handles different error types and retries the request if applicable.
103
+ */
104
+ export const eth_getLogs = async (rpc, params, context) => {
105
+ const request = {
106
+ method: "eth_getLogs",
107
+ params,
108
+ };
109
+ return rpc.request(request, context).then((logs) => {
110
+ if (logs === null || logs === undefined) {
111
+ throw new Error("Received invalid empty eth_getLogs response.");
112
+ }
113
+ return standardizeLogs(logs, request);
114
+ });
115
+ };
116
+ /**
117
+ * Helper function for "eth_getTransactionReceipt" request.
118
+ */
119
+ export const eth_getTransactionReceipt = (rpc, params, context) => rpc
120
+ .request({ method: "eth_getTransactionReceipt", params }, context)
121
+ .then((receipt) => {
122
+ if (!receipt) {
123
+ throw new TransactionReceiptNotFoundError({
124
+ hash: params[0],
125
+ });
126
+ }
127
+ return standardizeTransactionReceipts([receipt], {
128
+ method: "eth_getTransactionReceipt",
129
+ params,
130
+ })[0];
131
+ });
132
+ /**
133
+ * Helper function for "eth_getBlockReceipts" request.
134
+ */
135
+ export const eth_getBlockReceipts = (rpc, params, context) => rpc
136
+ .request({ method: "eth_getBlockReceipts", params }, context)
137
+ .then((receipts) => {
138
+ if (receipts === null || receipts === undefined) {
139
+ throw new Error("Received invalid empty eth_getBlockReceipts response.");
140
+ }
141
+ return standardizeTransactionReceipts(receipts, {
142
+ method: "eth_getBlockReceipts",
143
+ params,
144
+ });
145
+ });
146
+ /**
147
+ * Helper function for "debug_traceBlockByNumber" request.
148
+ */
149
+ export const debug_traceBlockByNumber = (rpc, params, context) => rpc
150
+ .request({ method: "debug_traceBlockByNumber", params }, context)
151
+ .then((traces) => {
152
+ if (traces === null || traces === undefined) {
153
+ throw new Error("Received invalid empty debug_traceBlockByNumber response.");
154
+ }
155
+ const result = [];
156
+ let index = 0;
157
+ // all traces that weren't included because the trace has an error
158
+ // or the trace's parent has an error, mapped to the error string
159
+ const failedTraces = new Map();
160
+ const dfs = (frames, transactionHash, parentFrame) => {
161
+ for (const frame of frames) {
162
+ if (frame.error !== undefined) {
163
+ failedTraces.set(frame, {
164
+ error: frame.error,
165
+ revertReason: frame.revertReason,
166
+ });
167
+ }
168
+ else if (parentFrame && failedTraces.has(parentFrame)) {
169
+ const error = failedTraces.get(parentFrame);
170
+ frame.error = error.error;
171
+ frame.revertReason = error.revertReason;
172
+ failedTraces.set(frame, error);
173
+ }
174
+ // @ts-expect-error
175
+ frame.index = index;
176
+ // @ts-expect-error
177
+ frame.subcalls = frame.calls?.length ?? 0;
178
+ result.push({ trace: frame, transactionHash });
179
+ index++;
180
+ if (frame.calls) {
181
+ dfs(frame.calls, transactionHash, frame);
182
+ }
183
+ }
184
+ };
185
+ for (const trace of traces) {
186
+ index = 0;
187
+ dfs([trace.result], trace.txHash, undefined);
188
+ }
189
+ return result.map((trace) => standardizeTrace(trace, {
190
+ method: "debug_traceBlockByNumber",
191
+ params,
192
+ }));
193
+ });
194
+ /**
195
+ * Helper function for "debug_traceBlockByHash" request.
196
+ */
197
+ export const debug_traceBlockByHash = (rpc, params, context) => rpc
198
+ .request({ method: "debug_traceBlockByHash", params }, context)
199
+ .then((traces) => {
200
+ if (traces === null || traces === undefined) {
201
+ throw new Error("Received invalid empty debug_traceBlockByHash response.");
202
+ }
203
+ const result = [];
204
+ let index = 0;
205
+ // all traces that weren't included because the trace has an error
206
+ // or the trace's parent has an error, mapped to the error string
207
+ const failedTraces = new Map();
208
+ const dfs = (frames, transactionHash, parentFrame) => {
209
+ for (const frame of frames) {
210
+ if (frame.error !== undefined) {
211
+ failedTraces.set(frame, {
212
+ error: frame.error,
213
+ revertReason: frame.revertReason,
214
+ });
215
+ }
216
+ else if (parentFrame && failedTraces.has(parentFrame)) {
217
+ const error = failedTraces.get(parentFrame);
218
+ frame.error = error.error;
219
+ frame.revertReason = error.revertReason;
220
+ failedTraces.set(frame, error);
221
+ }
222
+ // @ts-expect-error
223
+ frame.index = index;
224
+ // @ts-expect-error
225
+ frame.subcalls = frame.calls?.length ?? 0;
226
+ result.push({ trace: frame, transactionHash });
227
+ index++;
228
+ if (frame.calls) {
229
+ dfs(frame.calls, transactionHash, frame);
230
+ }
231
+ }
232
+ };
233
+ for (const trace of traces) {
234
+ index = 0;
235
+ dfs([trace.result], trace.txHash, undefined);
236
+ }
237
+ return result.map((trace) => standardizeTrace(trace, {
238
+ method: "debug_traceBlockByHash",
239
+ params,
240
+ }));
241
+ });
242
+ /**
243
+ * Validate that the transactions are consistent with the block.
244
+ */
245
+ export const validateTransactionsAndBlock = (block, request) => {
246
+ for (const [index, transaction] of block.transactions.entries()) {
247
+ if (block.hash !== transaction.blockHash) {
248
+ const error = new RpcProviderError(`Inconsistent RPC response data. The transaction at index ${index} of the 'block.transactions' array has a 'transaction.blockHash' of ${transaction.blockHash}, but the block itself has a 'block.hash' of ${block.hash}.`);
249
+ error.meta = [
250
+ "Please report this error to the RPC operator.",
251
+ requestText(request),
252
+ ];
253
+ error.stack = undefined;
254
+ throw error;
255
+ }
256
+ if (block.number !== transaction.blockNumber) {
257
+ const error = new RpcProviderError(`Inconsistent RPC response data. The transaction at index ${index} of the 'block.transactions' array has a 'transaction.blockNumber' of ${transaction.blockNumber} (${hexToNumber(transaction.blockNumber)}), but the block itself has a 'block.number' of ${block.number} (${hexToNumber(block.number)}).`);
258
+ error.meta = [
259
+ "Please report this error to the RPC operator.",
260
+ requestText(request),
261
+ ];
262
+ error.stack = undefined;
263
+ throw error;
264
+ }
265
+ }
266
+ };
267
+ /**
268
+ * Validate that the logs are consistent with the block.
269
+ *
270
+ * @dev Allows `log.transactionHash` to be `zeroHash`.
271
+ * @dev Allows `block.logsBloom` to be `zeroLogsBloom`.
272
+ * @dev Filecoin FVM fills all logsBloom bits regardless of actual logs.
273
+ * The logsBloom vs empty-logs check is skipped for Filecoin chains.
274
+ */
275
+ export const validateLogsAndBlock = (logs, block, logsRequest, blockRequest, chainId) => {
276
+ // Filecoin FVM sets all logsBloom bits to 1, defeating bloom filter
277
+ // optimizations. A non-zero logsBloom with zero logs is normal on Filecoin.
278
+ if (block.logsBloom !== zeroLogsBloom &&
279
+ logs.length === 0 &&
280
+ !(chainId !== undefined && isFilecoinChain(chainId))) {
281
+ const error = new RpcProviderError(`Inconsistent RPC response data. The logs array has length 0, but the associated block has a non-empty 'block.logsBloom'.`);
282
+ error.meta = [
283
+ "Please report this error to the RPC operator.",
284
+ requestText(blockRequest),
285
+ requestText(logsRequest),
286
+ ];
287
+ error.stack = undefined;
288
+ throw error;
289
+ }
290
+ const transactionByIndex = new Map(block.transactions.map((transaction) => [
291
+ transaction.transactionIndex,
292
+ transaction,
293
+ ]));
294
+ for (const log of logs) {
295
+ if (block.hash !== log.blockHash) {
296
+ const error = new RpcProviderError(`Inconsistent RPC response data. The log with 'logIndex' ${log.logIndex} (${hexToNumber(log.logIndex)}) has a 'log.blockHash' of ${log.blockHash}, but the associated block has a 'block.hash' of ${block.hash}.`);
297
+ error.meta = [
298
+ "Please report this error to the RPC operator.",
299
+ requestText(blockRequest),
300
+ requestText(logsRequest),
301
+ ];
302
+ error.stack = undefined;
303
+ throw error;
304
+ }
305
+ if (block.number !== log.blockNumber) {
306
+ const error = new RpcProviderError(`Inconsistent RPC response data. The log with 'logIndex' ${log.logIndex} (${hexToNumber(log.logIndex)}) has a 'log.blockNumber' of ${log.blockNumber} (${hexToNumber(log.blockNumber)}), but the associated block has a 'block.number' of ${block.number} (${hexToNumber(block.number)}).`);
307
+ error.meta = [
308
+ "Please report this error to the RPC operator.",
309
+ requestText(blockRequest),
310
+ requestText(logsRequest),
311
+ ];
312
+ error.stack = undefined;
313
+ throw error;
314
+ }
315
+ if (log.transactionHash !== zeroHash) {
316
+ const transaction = transactionByIndex.get(log.transactionIndex);
317
+ if (transaction === undefined) {
318
+ const error = new RpcProviderError(`Inconsistent RPC response data. The log with 'logIndex' ${log.logIndex} (${hexToNumber(log.logIndex)}) has a 'log.transactionIndex' of ${log.transactionIndex} (${hexToNumber(log.transactionIndex)}), but the associated 'block.transactions' array does not contain a transaction matching that 'transactionIndex'.`);
319
+ error.meta = [
320
+ "Please report this error to the RPC operator.",
321
+ requestText(blockRequest),
322
+ requestText(logsRequest),
323
+ ];
324
+ error.stack = undefined;
325
+ throw error;
326
+ }
327
+ else if (transaction.hash !== log.transactionHash) {
328
+ const error = new RpcProviderError(`Inconsistent RPC response data. The log with 'logIndex' ${log.logIndex} (${hexToNumber(log.logIndex)}) matches a transaction in the associated 'block.transactions' array by 'transactionIndex' ${log.transactionIndex} (${hexToNumber(log.transactionIndex)}), but the log has a 'log.transactionHash' of ${log.transactionHash} while the transaction has a 'transaction.hash' of ${transaction.hash}.`);
329
+ error.meta = [
330
+ "Please report this error to the RPC operator.",
331
+ requestText(blockRequest),
332
+ requestText(logsRequest),
333
+ ];
334
+ error.stack = undefined;
335
+ throw error;
336
+ }
337
+ }
338
+ }
339
+ };
340
+ /**
341
+ * Validate that the traces are consistent with the block.
342
+ */
343
+ export const validateTracesAndBlock = (traces, block, tracesRequest, blockRequest) => {
344
+ const transactionHashes = new Set(block.transactions.map((t) => t.hash));
345
+ for (const [index, trace] of traces.entries()) {
346
+ if (transactionHashes.has(trace.transactionHash) === false) {
347
+ const error = new RpcProviderError(`Inconsistent RPC response data. The top-level trace at array index ${index} has a 'transactionHash' of ${trace.transactionHash}, but the associated 'block.transactions' array does not contain a transaction matching that hash.`);
348
+ error.meta = [
349
+ "Please report this error to the RPC operator.",
350
+ requestText(blockRequest),
351
+ requestText(tracesRequest),
352
+ ];
353
+ error.stack = undefined;
354
+ throw error;
355
+ }
356
+ }
357
+ // Use the fact that any transaction produces a trace to validate.
358
+ if (block.transactions.length !== 0 && traces.length === 0) {
359
+ const error = new RpcProviderError(`Inconsistent RPC response data. The traces array has length 0, but the associated 'block.transactions' array has length ${block.transactions.length}.`);
360
+ error.meta = [
361
+ "Please report this error to the RPC operator.",
362
+ requestText(blockRequest),
363
+ requestText(tracesRequest),
364
+ ];
365
+ error.stack = undefined;
366
+ throw error;
367
+ }
368
+ };
369
+ /**
370
+ * Validate that the receipts are consistent with the block.
371
+ */
372
+ export const validateReceiptsAndBlock = (receipts, block, receiptsRequest, blockRequest) => {
373
+ const transactionByIndex = new Map(block.transactions.map((transaction) => [
374
+ transaction.transactionIndex,
375
+ transaction,
376
+ ]));
377
+ for (const [index, receipt] of receipts.entries()) {
378
+ if (block.hash !== receipt.blockHash) {
379
+ const error = new RpcProviderError(`Inconsistent RPC response data. The receipt at array index ${index} has a 'receipt.blockHash' of ${receipt.blockHash}, but the associated block has a 'block.hash' of ${block.hash}.`);
380
+ error.meta = [
381
+ "Please report this error to the RPC operator.",
382
+ requestText(blockRequest),
383
+ requestText(receiptsRequest),
384
+ ];
385
+ error.stack = undefined;
386
+ throw error;
387
+ }
388
+ if (block.number !== receipt.blockNumber) {
389
+ const error = new RpcProviderError(`Inconsistent RPC response data. The receipt at array index ${index} has a 'receipt.blockNumber' of ${receipt.blockNumber} (${hexToNumber(receipt.blockNumber)}), but the associated block has a 'block.number' of ${block.number} (${hexToNumber(block.number)}).`);
390
+ error.meta = [
391
+ "Please report this error to the RPC operator.",
392
+ requestText(blockRequest),
393
+ requestText(receiptsRequest),
394
+ ];
395
+ error.stack = undefined;
396
+ throw error;
397
+ }
398
+ const transaction = transactionByIndex.get(receipt.transactionIndex);
399
+ if (transaction === undefined) {
400
+ const error = new RpcProviderError(`Inconsistent RPC response data. The receipt at array index ${index} has a 'receipt.transactionIndex' of ${receipt.transactionIndex} (${hexToNumber(receipt.transactionIndex)}), but the associated 'block.transactions' array does not contain a transaction matching that 'transactionIndex'.`);
401
+ error.meta = [
402
+ "Please report this error to the RPC operator.",
403
+ requestText(blockRequest),
404
+ requestText(receiptsRequest),
405
+ ];
406
+ error.stack = undefined;
407
+ throw error;
408
+ }
409
+ else if (transaction.hash !== receipt.transactionHash) {
410
+ const error = new RpcProviderError(`Inconsistent RPC response data. The receipt at array index ${index} matches a transaction in the associated 'block.transactions' array by 'transactionIndex' ${receipt.transactionIndex} (${hexToNumber(receipt.transactionIndex)}), but the receipt has a 'receipt.transactionHash' of ${receipt.transactionHash} while the transaction has a 'transaction.hash' of ${transaction.hash}.`);
411
+ error.meta = [
412
+ "Please report this error to the RPC operator.",
413
+ requestText(blockRequest),
414
+ requestText(receiptsRequest),
415
+ ];
416
+ error.stack = undefined;
417
+ throw error;
418
+ }
419
+ }
420
+ if (receiptsRequest.method === "eth_getBlockReceipts" &&
421
+ block.transactions.length !== receipts.length) {
422
+ const error = new RpcProviderError(`Inconsistent RPC response data. The receipts array has length ${receipts.length}, but the associated 'block.transactions' array has length ${block.transactions.length}.`);
423
+ error.meta = [
424
+ "Please report this error to the RPC operator.",
425
+ requestText(blockRequest),
426
+ requestText(receiptsRequest),
427
+ ];
428
+ error.stack = undefined;
429
+ throw error;
430
+ }
431
+ };
432
+ /**
433
+ * Validate required block properties and set non-required properties.
434
+ *
435
+ * Required properties:
436
+ * - hash
437
+ * - number
438
+ * - timestamp
439
+ * - logsBloom
440
+ * - parentHash
441
+ * - transactions
442
+ *
443
+ * Non-required properties:
444
+ * - miner
445
+ * - gasUsed
446
+ * - gasLimit
447
+ * - baseFeePerGas
448
+ * - nonce
449
+ * - mixHash
450
+ * - stateRoot
451
+ * - transactionsRoot
452
+ * - sha3Uncles
453
+ * - size
454
+ * - difficulty
455
+ * - totalDifficulty
456
+ * - extraData
457
+ */
458
+ export const standardizeBlock = (block, request) => {
459
+ // required properties
460
+ if (block.hash === undefined) {
461
+ const error = new RpcProviderError("Invalid RPC response: 'block.hash' is a required property");
462
+ error.meta = [
463
+ "Please report this error to the RPC operator.",
464
+ requestText(request),
465
+ ];
466
+ error.stack = undefined;
467
+ throw error;
468
+ }
469
+ if (block.number === undefined) {
470
+ const error = new RpcProviderError("Invalid RPC response: 'block.number' is a required property");
471
+ error.meta = [
472
+ "Please report this error to the RPC operator.",
473
+ requestText(request),
474
+ ];
475
+ error.stack = undefined;
476
+ throw error;
477
+ }
478
+ if (block.timestamp === undefined) {
479
+ const error = new RpcProviderError("Invalid RPC response: 'block.timestamp' is a required property");
480
+ error.meta = [
481
+ "Please report this error to the RPC operator.",
482
+ requestText(request),
483
+ ];
484
+ error.stack = undefined;
485
+ throw error;
486
+ }
487
+ if (block.logsBloom === undefined) {
488
+ const error = new RpcProviderError("Invalid RPC response: 'block.logsBloom' is a required property");
489
+ error.meta = [
490
+ "Please report this error to the RPC operator.",
491
+ requestText(request),
492
+ ];
493
+ error.stack = undefined;
494
+ throw error;
495
+ }
496
+ if (block.parentHash === undefined) {
497
+ const error = new RpcProviderError("Invalid RPC response: 'block.parentHash' is a required property");
498
+ error.meta = [
499
+ "Please report this error to the RPC operator.",
500
+ requestText(request),
501
+ ];
502
+ error.stack = undefined;
503
+ throw error;
504
+ }
505
+ // non-required properties
506
+ if (block.miner === undefined) {
507
+ block.miner = zeroAddress;
508
+ }
509
+ if (block.gasUsed === undefined) {
510
+ block.gasUsed = "0x0";
511
+ }
512
+ if (block.gasLimit === undefined) {
513
+ block.gasLimit = "0x0";
514
+ }
515
+ if (block.baseFeePerGas === undefined) {
516
+ block.baseFeePerGas = "0x0";
517
+ }
518
+ if (block.nonce === undefined) {
519
+ block.nonce = "0x0";
520
+ }
521
+ if (block.mixHash === undefined) {
522
+ block.mixHash = zeroHash;
523
+ }
524
+ if (block.stateRoot === undefined) {
525
+ block.stateRoot = zeroHash;
526
+ }
527
+ if (block.transactionsRoot === undefined) {
528
+ block.transactionsRoot = zeroHash;
529
+ }
530
+ if (block.sha3Uncles === undefined) {
531
+ block.sha3Uncles = zeroHash;
532
+ }
533
+ if (block.size === undefined) {
534
+ block.size = "0x0";
535
+ }
536
+ if (block.difficulty === undefined) {
537
+ block.difficulty = "0x0";
538
+ }
539
+ if (block.totalDifficulty === undefined) {
540
+ block.totalDifficulty = "0x0";
541
+ }
542
+ if (block.extraData === undefined) {
543
+ block.extraData = "0x";
544
+ }
545
+ if (hexToBigInt(block.number) > PG_BIGINT_MAX) {
546
+ const error = new RpcProviderError(`Invalid RPC response: 'block.number' (${hexToBigInt(block.number)}) is larger than the maximum allowed value (${PG_BIGINT_MAX}).`);
547
+ error.meta = [
548
+ "Please report this error to the RPC operator.",
549
+ requestText(request),
550
+ ];
551
+ error.stack = undefined;
552
+ throw error;
553
+ }
554
+ if (hexToBigInt(block.timestamp) > PG_BIGINT_MAX) {
555
+ const error = new RpcProviderError(`Invalid RPC response: 'block.timestamp' (${hexToBigInt(block.timestamp)}) is larger than the maximum allowed value (${PG_BIGINT_MAX}).`);
556
+ error.meta = [
557
+ "Please report this error to the RPC operator.",
558
+ requestText(request),
559
+ ];
560
+ error.stack = undefined;
561
+ throw error;
562
+ }
563
+ // Note: block headers for some providers may contain transactions hashes,
564
+ // but Ponder coerces the transactions property to undefined.
565
+ if (request.method === "eth_subscribe" || request.params[1] === false) {
566
+ block.transactions = undefined;
567
+ return block;
568
+ }
569
+ else {
570
+ if (block.transactions === undefined) {
571
+ throw new Error("Invalid RPC response: 'block.transactions' is a required property");
572
+ }
573
+ block.transactions = standardizeTransactions(block.transactions, request);
574
+ return block;
575
+ }
576
+ };
577
+ /**
578
+ * Validate required transaction properties and set non-required properties.
579
+ *
580
+ * Required properties:
581
+ * - hash
582
+ * - transactionIndex
583
+ * - blockNumber
584
+ * - blockHash
585
+ * - from
586
+ * - to
587
+ *
588
+ * Non-required properties:
589
+ * - input
590
+ * - value
591
+ * - nonce
592
+ * - r
593
+ * - s
594
+ * - v
595
+ * - type
596
+ * - gas
597
+ */
598
+ export const standardizeTransactions = (transactions, request) => {
599
+ const transactionIds = new Set();
600
+ for (const transaction of transactions) {
601
+ if (transactionIds.has(transaction.transactionIndex)) {
602
+ const error = new RpcProviderError(`Inconsistent RPC response data. The 'block.transactions' array contains two objects with a 'transactionIndex' of ${transaction.transactionIndex} (${hexToNumber(transaction.transactionIndex)}).`);
603
+ error.meta = [
604
+ "Please report this error to the RPC operator.",
605
+ requestText(request),
606
+ ];
607
+ error.stack = undefined;
608
+ throw error;
609
+ }
610
+ else {
611
+ transactionIds.add(transaction.transactionIndex);
612
+ }
613
+ // required properties
614
+ if (transaction.hash === undefined) {
615
+ const error = new RpcProviderError("Invalid RPC response: 'transaction.hash' is a required property");
616
+ error.meta = [
617
+ "Please report this error to the RPC operator.",
618
+ requestText(request),
619
+ ];
620
+ error.stack = undefined;
621
+ throw error;
622
+ }
623
+ if (transaction.transactionIndex === undefined) {
624
+ const error = new RpcProviderError("Invalid RPC response: 'transaction.transactionIndex' is a required property");
625
+ error.meta = [
626
+ "Please report this error to the RPC operator.",
627
+ requestText(request),
628
+ ];
629
+ error.stack = undefined;
630
+ throw error;
631
+ }
632
+ if (transaction.blockNumber === undefined) {
633
+ const error = new RpcProviderError("Invalid RPC response: 'transaction.blockNumber' is a required property");
634
+ error.meta = [
635
+ "Please report this error to the RPC operator.",
636
+ requestText(request),
637
+ ];
638
+ error.stack = undefined;
639
+ throw error;
640
+ }
641
+ if (transaction.blockHash === undefined) {
642
+ const error = new RpcProviderError("Invalid RPC response: 'transaction.blockHash' is a required property");
643
+ error.meta = [
644
+ "Please report this error to the RPC operator.",
645
+ requestText(request),
646
+ ];
647
+ error.stack = undefined;
648
+ throw error;
649
+ }
650
+ if (transaction.from === undefined) {
651
+ const error = new RpcProviderError("Invalid RPC response: 'transaction.from' is a required property");
652
+ error.meta = [
653
+ "Please report this error to the RPC operator.",
654
+ requestText(request),
655
+ ];
656
+ error.stack = undefined;
657
+ throw error;
658
+ }
659
+ // Note: `to` is a required property but can be coerced to `null`.
660
+ if (transaction.to === undefined) {
661
+ transaction.to = null;
662
+ }
663
+ // non-required properties
664
+ if (transaction.input === undefined) {
665
+ transaction.input = "0x";
666
+ }
667
+ if (transaction.value === undefined) {
668
+ transaction.value = "0x0";
669
+ }
670
+ if (transaction.nonce === undefined) {
671
+ transaction.nonce = "0x0";
672
+ }
673
+ if (transaction.r === undefined) {
674
+ transaction.r = "0x0";
675
+ }
676
+ if (transaction.s === undefined) {
677
+ transaction.s = "0x0";
678
+ }
679
+ if (transaction.v === undefined) {
680
+ transaction.v = "0x0";
681
+ }
682
+ if (transaction.type === undefined) {
683
+ // @ts-expect-error
684
+ transaction.type = "0x0";
685
+ }
686
+ if (transaction.gas === undefined) {
687
+ transaction.gas = "0x0";
688
+ }
689
+ if (hexToBigInt(transaction.blockNumber) > PG_BIGINT_MAX) {
690
+ const error = new RpcProviderError(`Invalid RPC response: 'transaction.blockNumber' (${hexToBigInt(transaction.blockNumber)}) is larger than the maximum allowed value (${PG_BIGINT_MAX}).`);
691
+ error.meta = [
692
+ "Please report this error to the RPC operator.",
693
+ requestText(request),
694
+ ];
695
+ error.stack = undefined;
696
+ throw error;
697
+ }
698
+ if (hexToBigInt(transaction.transactionIndex) > BigInt(PG_INTEGER_MAX)) {
699
+ const error = new RpcProviderError(`Invalid RPC response: 'transaction.transactionIndex' (${hexToBigInt(transaction.transactionIndex)}) is larger than the maximum allowed value (${PG_INTEGER_MAX}).`);
700
+ error.meta = [
701
+ "Please report this error to the RPC operator.",
702
+ requestText(request),
703
+ ];
704
+ error.stack = undefined;
705
+ throw error;
706
+ }
707
+ if (hexToBigInt(transaction.nonce) > BigInt(PG_INTEGER_MAX)) {
708
+ const error = new RpcProviderError(`Invalid RPC response: 'transaction.nonce' (${hexToBigInt(transaction.nonce)}) is larger than the maximum allowed value (${PG_INTEGER_MAX}).`);
709
+ error.meta = [
710
+ "Please report this error to the RPC operator.",
711
+ requestText(request),
712
+ ];
713
+ error.stack = undefined;
714
+ throw error;
715
+ }
716
+ }
717
+ return transactions;
718
+ };
719
+ /**
720
+ * Validate required log properties and set properties.
721
+ *
722
+ * Required properties:
723
+ * - blockNumber
724
+ * - logIndex
725
+ * - blockHash
726
+ * - address
727
+ * - topics
728
+ * - data
729
+ * - transactionHash
730
+ * - transactionIndex
731
+ *
732
+ * Non-required properties:
733
+ * - removed
734
+ */
735
+ export const standardizeLogs = (logs, request) => {
736
+ const logIds = new Set();
737
+ for (const log of logs) {
738
+ if (logIds.has(`${log.blockNumber}_${log.logIndex}`)) {
739
+ const error = new RpcProviderError(`Inconsistent RPC response data. The logs array contains two objects with 'blockNumber' ${log.blockNumber} (${hexToNumber(log.blockNumber)}) and 'logIndex' ${log.logIndex} (${hexToNumber(log.logIndex)}).`);
740
+ error.meta = [
741
+ "Please report this error to the RPC operator.",
742
+ requestText(request),
743
+ ];
744
+ error.stack = undefined;
745
+ throw error;
746
+ }
747
+ else {
748
+ logIds.add(`${log.blockNumber}_${log.logIndex}`);
749
+ }
750
+ // required properties
751
+ if (log.blockNumber === undefined) {
752
+ const error = new RpcProviderError("Invalid RPC response: 'log.blockNumber' is a required property");
753
+ error.meta = [
754
+ "Please report this error to the RPC operator.",
755
+ requestText(request),
756
+ ];
757
+ error.stack = undefined;
758
+ throw error;
759
+ }
760
+ if (log.logIndex === undefined) {
761
+ const error = new RpcProviderError("Invalid RPC response: 'log.logIndex' is a required property");
762
+ error.meta = [
763
+ "Please report this error to the RPC operator.",
764
+ requestText(request),
765
+ ];
766
+ error.stack = undefined;
767
+ throw error;
768
+ }
769
+ if (log.blockHash === undefined) {
770
+ const error = new RpcProviderError("Invalid RPC response: 'log.blockHash' is a required property");
771
+ error.meta = [
772
+ "Please report this error to the RPC operator.",
773
+ requestText(request),
774
+ ];
775
+ error.stack = undefined;
776
+ throw error;
777
+ }
778
+ if (log.address === undefined) {
779
+ const error = new RpcProviderError("Invalid RPC response: 'log.address' is a required property");
780
+ error.meta = [
781
+ "Please report this error to the RPC operator.",
782
+ requestText(request),
783
+ ];
784
+ error.stack = undefined;
785
+ throw error;
786
+ }
787
+ if (log.topics === undefined) {
788
+ const error = new RpcProviderError("Invalid RPC response: 'log.topics' is a required property");
789
+ error.meta = [
790
+ "Please report this error to the RPC operator.",
791
+ requestText(request),
792
+ ];
793
+ error.stack = undefined;
794
+ throw error;
795
+ }
796
+ if (log.data === undefined) {
797
+ const error = new RpcProviderError("Invalid RPC response: 'log.data' is a required property");
798
+ error.meta = [
799
+ "Please report this error to the RPC operator.",
800
+ requestText(request),
801
+ ];
802
+ error.stack = undefined;
803
+ throw error;
804
+ }
805
+ if (log.transactionHash === undefined) {
806
+ log.transactionHash = zeroHash;
807
+ }
808
+ if (log.transactionIndex === undefined) {
809
+ log.transactionIndex = "0x0";
810
+ }
811
+ // non-required properties
812
+ if (log.removed === undefined) {
813
+ log.removed = false;
814
+ }
815
+ if (hexToBigInt(log.blockNumber) > PG_BIGINT_MAX) {
816
+ const error = new RpcProviderError(`Invalid RPC response: 'log.blockNumber' (${hexToBigInt(log.blockNumber)}) is larger than the maximum allowed value (${PG_BIGINT_MAX}).`);
817
+ error.meta = [
818
+ "Please report this error to the RPC operator.",
819
+ requestText(request),
820
+ ];
821
+ error.stack = undefined;
822
+ throw error;
823
+ }
824
+ if (hexToBigInt(log.transactionIndex) > BigInt(PG_INTEGER_MAX)) {
825
+ const error = new RpcProviderError(`Invalid RPC response: 'log.transactionIndex' (${hexToBigInt(log.transactionIndex)}) is larger than the maximum allowed value (${PG_INTEGER_MAX}).`);
826
+ error.meta = [
827
+ "Please report this error to the RPC operator.",
828
+ requestText(request),
829
+ ];
830
+ error.stack = undefined;
831
+ throw error;
832
+ }
833
+ if (hexToBigInt(log.logIndex) > BigInt(PG_INTEGER_MAX)) {
834
+ const error = new RpcProviderError(`Invalid RPC response: 'log.logIndex' (${hexToBigInt(log.logIndex)}) is larger than the maximum allowed value (${PG_INTEGER_MAX}).`);
835
+ error.meta = [
836
+ "Please report this error to the RPC operator.",
837
+ requestText(request),
838
+ ];
839
+ error.stack = undefined;
840
+ throw error;
841
+ }
842
+ }
843
+ return logs;
844
+ };
845
+ /**
846
+ * Validate required trace properties and set non-required properties.
847
+ *
848
+ * Required properties:
849
+ * - transactionHash
850
+ * - type
851
+ * - from
852
+ * - input
853
+ *
854
+ * Non-required properties:
855
+ * - gas
856
+ * - gasUsed
857
+ */
858
+ export const standardizeTrace = (trace, request) => {
859
+ // required properties
860
+ if (trace.transactionHash === undefined) {
861
+ const error = new RpcProviderError("Invalid RPC response: 'trace.transactionHash' is a required property");
862
+ error.meta = [
863
+ "Please report this error to the RPC operator.",
864
+ requestText(request),
865
+ ];
866
+ error.stack = undefined;
867
+ throw error;
868
+ }
869
+ if (trace.trace.type === undefined) {
870
+ const error = new RpcProviderError("Invalid RPC response: 'trace.type' is a required property");
871
+ error.meta = [
872
+ "Please report this error to the RPC operator.",
873
+ requestText(request),
874
+ ];
875
+ error.stack = undefined;
876
+ throw error;
877
+ }
878
+ if (trace.trace.from === undefined) {
879
+ const error = new RpcProviderError("Invalid RPC response: 'trace.from' is a required property");
880
+ error.meta = [
881
+ "Please report this error to the RPC operator.",
882
+ requestText(request),
883
+ ];
884
+ error.stack = undefined;
885
+ throw error;
886
+ }
887
+ if (trace.trace.input === undefined) {
888
+ const error = new RpcProviderError("Invalid RPC response: 'trace.input' is a required property");
889
+ error.meta = [
890
+ "Please report this error to the RPC operator.",
891
+ requestText(request),
892
+ ];
893
+ error.stack = undefined;
894
+ throw error;
895
+ }
896
+ // non-required properties
897
+ if (trace.trace.gas === undefined) {
898
+ trace.trace.gas = "0x0";
899
+ }
900
+ if (trace.trace.gasUsed === undefined) {
901
+ trace.trace.gasUsed = "0x0";
902
+ }
903
+ // Note: All INTEGER and BIGINT `trace` columns are generated, not derived from
904
+ // RPC responses.
905
+ return trace;
906
+ };
907
+ /**
908
+ * Validate required transaction receipt properties and set non-required properties.
909
+ *
910
+ * Required properties:
911
+ * - blockHash
912
+ * - blockNumber
913
+ * - transactionHash
914
+ * - transactionIndex
915
+ * - from
916
+ * - to
917
+ * - status
918
+ *
919
+ * Non-required properties:
920
+ * - logs
921
+ * - logsBloom
922
+ * - gasUsed
923
+ * - cumulativeGasUsed
924
+ * - effectiveGasPrice
925
+ * - root
926
+ * - type
927
+ */
928
+ export const standardizeTransactionReceipts = (receipts, request) => {
929
+ const receiptIds = new Set();
930
+ for (const receipt of receipts) {
931
+ if (receiptIds.has(receipt.transactionHash)) {
932
+ const error = new RpcProviderError(`Inconsistent RPC response data. The receipts array contains two objects with a 'transactionHash' of ${receipt.transactionHash}.`);
933
+ error.meta = [
934
+ "Please report this error to the RPC operator.",
935
+ requestText(request),
936
+ ];
937
+ error.stack = undefined;
938
+ throw error;
939
+ }
940
+ else {
941
+ receiptIds.add(receipt.transactionHash);
942
+ }
943
+ // required properties
944
+ if (receipt.blockHash === undefined) {
945
+ const error = new RpcProviderError("Invalid RPC response: 'receipt.blockHash' is a required property");
946
+ error.meta = [
947
+ "Please report this error to the RPC operator.",
948
+ requestText(request),
949
+ ];
950
+ error.stack = undefined;
951
+ throw error;
952
+ }
953
+ if (receipt.blockNumber === undefined) {
954
+ const error = new RpcProviderError("Invalid RPC response: 'receipt.blockNumber' is a required property");
955
+ error.meta = [
956
+ "Please report this error to the RPC operator.",
957
+ requestText(request),
958
+ ];
959
+ error.stack = undefined;
960
+ throw error;
961
+ }
962
+ if (receipt.transactionHash === undefined) {
963
+ const error = new RpcProviderError("Invalid RPC response: 'receipt.transactionHash' is a required property");
964
+ error.meta = [
965
+ "Please report this error to the RPC operator.",
966
+ requestText(request),
967
+ ];
968
+ error.stack = undefined;
969
+ throw error;
970
+ }
971
+ if (receipt.transactionIndex === undefined) {
972
+ const error = new RpcProviderError("Invalid RPC response: 'receipt.transactionIndex' is a required property");
973
+ error.meta = [
974
+ "Please report this error to the RPC operator.",
975
+ requestText(request),
976
+ ];
977
+ error.stack = undefined;
978
+ throw error;
979
+ }
980
+ if (receipt.from === undefined) {
981
+ const error = new RpcProviderError("Invalid RPC response: 'receipt.from' is a required property");
982
+ error.meta = [
983
+ "Please report this error to the RPC operator.",
984
+ requestText(request),
985
+ ];
986
+ error.stack = undefined;
987
+ throw error;
988
+ }
989
+ if (receipt.status === undefined) {
990
+ const error = new RpcProviderError("Invalid RPC response: 'receipt.status' is a required property");
991
+ error.meta = [
992
+ "Please report this error to the RPC operator.",
993
+ requestText(request),
994
+ ];
995
+ error.stack = undefined;
996
+ throw error;
997
+ }
998
+ // Note: `to` is a required property but can be coerced to `null`.
999
+ if (receipt.to === undefined) {
1000
+ receipt.to = null;
1001
+ }
1002
+ // non-required properties
1003
+ if (receipt.logs === undefined) {
1004
+ receipt.logs = [];
1005
+ }
1006
+ if (receipt.logsBloom === undefined) {
1007
+ receipt.logsBloom = zeroLogsBloom;
1008
+ }
1009
+ if (receipt.gasUsed === undefined) {
1010
+ receipt.gasUsed = "0x0";
1011
+ }
1012
+ if (receipt.cumulativeGasUsed === undefined) {
1013
+ receipt.cumulativeGasUsed = "0x0";
1014
+ }
1015
+ if (receipt.effectiveGasPrice === undefined) {
1016
+ receipt.effectiveGasPrice = "0x0";
1017
+ }
1018
+ if (receipt.root === undefined) {
1019
+ receipt.root = zeroHash;
1020
+ }
1021
+ if (receipt.type === undefined) {
1022
+ receipt.type = "0x0";
1023
+ }
1024
+ if (hexToBigInt(receipt.blockNumber) > PG_BIGINT_MAX) {
1025
+ const error = new RpcProviderError(`Invalid RPC response: 'receipt.blockNumber' (${hexToBigInt(receipt.blockNumber)}) is larger than the maximum allowed value (${PG_BIGINT_MAX}).`);
1026
+ error.meta = [
1027
+ "Please report this error to the RPC operator.",
1028
+ requestText(request),
1029
+ ];
1030
+ error.stack = undefined;
1031
+ throw error;
1032
+ }
1033
+ if (hexToBigInt(receipt.transactionIndex) > BigInt(PG_INTEGER_MAX)) {
1034
+ const error = new RpcProviderError(`Invalid RPC response: 'receipt.transactionIndex' (${hexToBigInt(receipt.transactionIndex)}) is larger than the maximum allowed value (${PG_INTEGER_MAX}).`);
1035
+ error.meta = [
1036
+ "Please report this error to the RPC operator.",
1037
+ requestText(request),
1038
+ ];
1039
+ error.stack = undefined;
1040
+ throw error;
1041
+ }
1042
+ }
1043
+ return receipts;
1044
+ };
1045
+ function requestText(request) {
1046
+ return `Request: ${JSON.stringify({
1047
+ method: request.method,
1048
+ params: request.params,
1049
+ }, null, 2)}`;
1050
+ }
1051
+ //# sourceMappingURL=actions.js.map