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