ponder 0.9.5-debug.1 → 0.9.5
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/dist/{types/bin → bin}/ponder.d.ts +6 -5
- package/dist/bin/ponder.js +12933 -0
- package/dist/bin/ponder.js.map +1 -0
- package/dist/chunk-K2TLRLX3.js +163 -0
- package/dist/chunk-K2TLRLX3.js.map +1 -0
- package/dist/chunk-LHCA5XFV.js +257 -0
- package/dist/chunk-LHCA5XFV.js.map +1 -0
- package/dist/{types/drizzle → drizzle}/onchain.d.ts +96 -49
- package/dist/drizzle/onchain.js +19 -0
- package/dist/drizzle/onchain.js.map +1 -0
- package/dist/index.d.ts +819 -0
- package/dist/index.js +2217 -0
- package/dist/index.js.map +1 -0
- package/dist/utils-ceNucOJb.d.ts +14 -0
- package/package.json +17 -17
- package/src/bin/commands/dev.ts +1 -1
- package/src/bin/ponder.ts +1 -1
- package/src/build/configAndIndexingFunctions.ts +1 -1
- package/src/build/factory.ts +1 -1
- package/src/client/index.ts +1 -1
- package/src/indexing-store/historical.ts +1 -1
- package/src/indexing-store/realtime.ts +1 -1
- package/src/internal/telemetry.ts +1 -1
- package/src/sync/fragments.ts +1 -1
- package/src/sync-realtime/index.ts +1 -1
- package/src/utils/generators.ts +1 -1
- package/src/utils/mutex.ts +1 -1
- package/src/utils/requestQueue.ts +1 -1
- package/CHANGELOG.md +0 -2201
- package/dist/esm/bin/commands/codegen.js +0 -37
- package/dist/esm/bin/commands/codegen.js.map +0 -1
- package/dist/esm/bin/commands/dev.js +0 -242
- package/dist/esm/bin/commands/dev.js.map +0 -1
- package/dist/esm/bin/commands/list.js +0 -103
- package/dist/esm/bin/commands/list.js.map +0 -1
- package/dist/esm/bin/commands/serve.js +0 -123
- package/dist/esm/bin/commands/serve.js.map +0 -1
- package/dist/esm/bin/commands/start.js +0 -136
- package/dist/esm/bin/commands/start.js.map +0 -1
- package/dist/esm/bin/ponder.js +0 -118
- package/dist/esm/bin/ponder.js.map +0 -1
- package/dist/esm/bin/utils/codegen.js +0 -26
- package/dist/esm/bin/utils/codegen.js.map +0 -1
- package/dist/esm/bin/utils/exit.js +0 -69
- package/dist/esm/bin/utils/exit.js.map +0 -1
- package/dist/esm/bin/utils/run.js +0 -247
- package/dist/esm/bin/utils/run.js.map +0 -1
- package/dist/esm/bin/utils/runServer.js +0 -8
- package/dist/esm/bin/utils/runServer.js.map +0 -1
- package/dist/esm/build/configAndIndexingFunctions.js +0 -654
- package/dist/esm/build/configAndIndexingFunctions.js.map +0 -1
- package/dist/esm/build/factory.js +0 -43
- package/dist/esm/build/factory.js.map +0 -1
- package/dist/esm/build/index.js +0 -431
- package/dist/esm/build/index.js.map +0 -1
- package/dist/esm/build/plugin.js +0 -43
- package/dist/esm/build/plugin.js.map +0 -1
- package/dist/esm/build/pre.js +0 -112
- package/dist/esm/build/pre.js.map +0 -1
- package/dist/esm/build/schema.js +0 -89
- package/dist/esm/build/schema.js.map +0 -1
- package/dist/esm/build/stacktrace.js +0 -137
- package/dist/esm/build/stacktrace.js.map +0 -1
- package/dist/esm/client/index.js +0 -124
- package/dist/esm/client/index.js.map +0 -1
- package/dist/esm/client/validate.js +0 -1151
- package/dist/esm/client/validate.js.map +0 -1
- package/dist/esm/config/address.js +0 -2
- package/dist/esm/config/address.js.map +0 -1
- package/dist/esm/config/eventFilter.js +0 -2
- package/dist/esm/config/eventFilter.js.map +0 -1
- package/dist/esm/config/index.js +0 -2
- package/dist/esm/config/index.js.map +0 -1
- package/dist/esm/config/networks.js +0 -120
- package/dist/esm/config/networks.js.map +0 -1
- package/dist/esm/config/utilityTypes.js +0 -2
- package/dist/esm/config/utilityTypes.js.map +0 -1
- package/dist/esm/database/index.js +0 -914
- package/dist/esm/database/index.js.map +0 -1
- package/dist/esm/drizzle/bigint.js +0 -36
- package/dist/esm/drizzle/bigint.js.map +0 -1
- package/dist/esm/drizzle/hex.js +0 -38
- package/dist/esm/drizzle/hex.js.map +0 -1
- package/dist/esm/drizzle/index.js +0 -43
- package/dist/esm/drizzle/index.js.map +0 -1
- package/dist/esm/drizzle/kit/index.js +0 -658
- package/dist/esm/drizzle/kit/index.js.map +0 -1
- package/dist/esm/drizzle/onchain.js +0 -102
- package/dist/esm/drizzle/onchain.js.map +0 -1
- package/dist/esm/graphql/index.js +0 -704
- package/dist/esm/graphql/index.js.map +0 -1
- package/dist/esm/graphql/json.js +0 -42
- package/dist/esm/graphql/json.js.map +0 -1
- package/dist/esm/graphql/middleware.js +0 -80
- package/dist/esm/graphql/middleware.js.map +0 -1
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/indexing/addStackTrace.js +0 -54
- package/dist/esm/indexing/addStackTrace.js.map +0 -1
- package/dist/esm/indexing/index.js +0 -10
- package/dist/esm/indexing/index.js.map +0 -1
- package/dist/esm/indexing/ponderActions.js +0 -60
- package/dist/esm/indexing/ponderActions.js.map +0 -1
- package/dist/esm/indexing/service.js +0 -312
- package/dist/esm/indexing/service.js.map +0 -1
- package/dist/esm/indexing-store/historical.js +0 -591
- package/dist/esm/indexing-store/historical.js.map +0 -1
- package/dist/esm/indexing-store/index.js +0 -19
- package/dist/esm/indexing-store/index.js.map +0 -1
- package/dist/esm/indexing-store/metadata.js +0 -46
- package/dist/esm/indexing-store/metadata.js.map +0 -1
- package/dist/esm/indexing-store/realtime.js +0 -295
- package/dist/esm/indexing-store/realtime.js.map +0 -1
- package/dist/esm/internal/common.js +0 -2
- package/dist/esm/internal/common.js.map +0 -1
- package/dist/esm/internal/errors.js +0 -175
- package/dist/esm/internal/errors.js.map +0 -1
- package/dist/esm/internal/logger.js +0 -96
- package/dist/esm/internal/logger.js.map +0 -1
- package/dist/esm/internal/metrics.js +0 -569
- package/dist/esm/internal/metrics.js.map +0 -1
- package/dist/esm/internal/options.js +0 -69
- package/dist/esm/internal/options.js.map +0 -1
- package/dist/esm/internal/shutdown.js +0 -18
- package/dist/esm/internal/shutdown.js.map +0 -1
- package/dist/esm/internal/telemetry.js +0 -199
- package/dist/esm/internal/telemetry.js.map +0 -1
- package/dist/esm/internal/types.js +0 -2
- package/dist/esm/internal/types.js.map +0 -1
- package/dist/esm/server/error.js +0 -55
- package/dist/esm/server/error.js.map +0 -1
- package/dist/esm/server/index.js +0 -107
- package/dist/esm/server/index.js.map +0 -1
- package/dist/esm/sync/abi.js +0 -67
- package/dist/esm/sync/abi.js.map +0 -1
- package/dist/esm/sync/events.js +0 -607
- package/dist/esm/sync/events.js.map +0 -1
- package/dist/esm/sync/filter.js +0 -356
- package/dist/esm/sync/filter.js.map +0 -1
- package/dist/esm/sync/fragments.js +0 -300
- package/dist/esm/sync/fragments.js.map +0 -1
- package/dist/esm/sync/index.js +0 -1001
- package/dist/esm/sync/index.js.map +0 -1
- package/dist/esm/sync/transport.js +0 -94
- package/dist/esm/sync/transport.js.map +0 -1
- package/dist/esm/sync-historical/index.js +0 -590
- package/dist/esm/sync-historical/index.js.map +0 -1
- package/dist/esm/sync-realtime/bloom.js +0 -75
- package/dist/esm/sync-realtime/bloom.js.map +0 -1
- package/dist/esm/sync-realtime/index.js +0 -794
- package/dist/esm/sync-realtime/index.js.map +0 -1
- package/dist/esm/sync-store/encoding.js +0 -157
- package/dist/esm/sync-store/encoding.js.map +0 -1
- package/dist/esm/sync-store/index.js +0 -727
- package/dist/esm/sync-store/index.js.map +0 -1
- package/dist/esm/sync-store/migrations.js +0 -1186
- package/dist/esm/sync-store/migrations.js.map +0 -1
- package/dist/esm/types/db.js +0 -2
- package/dist/esm/types/db.js.map +0 -1
- package/dist/esm/types/eth.js +0 -2
- package/dist/esm/types/eth.js.map +0 -1
- package/dist/esm/types/sync.js +0 -2
- package/dist/esm/types/sync.js.map +0 -1
- package/dist/esm/types/utils.js +0 -2
- package/dist/esm/types/utils.js.map +0 -1
- package/dist/esm/types/virtual.js +0 -2
- package/dist/esm/types/virtual.js.map +0 -1
- package/dist/esm/ui/ProgressBar.js +0 -11
- package/dist/esm/ui/ProgressBar.js.map +0 -1
- package/dist/esm/ui/Table.js +0 -50
- package/dist/esm/ui/Table.js.map +0 -1
- package/dist/esm/ui/app.js +0 -113
- package/dist/esm/ui/app.js.map +0 -1
- package/dist/esm/ui/graphiql.html.js +0 -59
- package/dist/esm/ui/graphiql.html.js.map +0 -1
- package/dist/esm/ui/index.js +0 -21
- package/dist/esm/ui/index.js.map +0 -1
- package/dist/esm/utils/bigint.js +0 -37
- package/dist/esm/utils/bigint.js.map +0 -1
- package/dist/esm/utils/chains.js +0 -3
- package/dist/esm/utils/chains.js.map +0 -1
- package/dist/esm/utils/checkpoint.js +0 -114
- package/dist/esm/utils/checkpoint.js.map +0 -1
- package/dist/esm/utils/chunk.js +0 -8
- package/dist/esm/utils/chunk.js.map +0 -1
- package/dist/esm/utils/date.js +0 -27
- package/dist/esm/utils/date.js.map +0 -1
- package/dist/esm/utils/debug.js +0 -2
- package/dist/esm/utils/debug.js.map +0 -1
- package/dist/esm/utils/dedupe.js +0 -33
- package/dist/esm/utils/dedupe.js.map +0 -1
- package/dist/esm/utils/duplicates.js +0 -19
- package/dist/esm/utils/duplicates.js.map +0 -1
- package/dist/esm/utils/estimate.js +0 -6
- package/dist/esm/utils/estimate.js.map +0 -1
- package/dist/esm/utils/extend.js +0 -28
- package/dist/esm/utils/extend.js.map +0 -1
- package/dist/esm/utils/format.js +0 -20
- package/dist/esm/utils/format.js.map +0 -1
- package/dist/esm/utils/generators.js +0 -77
- package/dist/esm/utils/generators.js.map +0 -1
- package/dist/esm/utils/hash.js +0 -11
- package/dist/esm/utils/hash.js.map +0 -1
- package/dist/esm/utils/interval.js +0 -171
- package/dist/esm/utils/interval.js.map +0 -1
- package/dist/esm/utils/lowercase.js +0 -7
- package/dist/esm/utils/lowercase.js.map +0 -1
- package/dist/esm/utils/mutex.js +0 -25
- package/dist/esm/utils/mutex.js.map +0 -1
- package/dist/esm/utils/never.js +0 -4
- package/dist/esm/utils/never.js.map +0 -1
- package/dist/esm/utils/offset.js +0 -73
- package/dist/esm/utils/offset.js.map +0 -1
- package/dist/esm/utils/order.js +0 -18
- package/dist/esm/utils/order.js.map +0 -1
- package/dist/esm/utils/partition.js +0 -37
- package/dist/esm/utils/partition.js.map +0 -1
- package/dist/esm/utils/pg.js +0 -126
- package/dist/esm/utils/pg.js.map +0 -1
- package/dist/esm/utils/pglite.js +0 -80
- package/dist/esm/utils/pglite.js.map +0 -1
- package/dist/esm/utils/port.js +0 -30
- package/dist/esm/utils/port.js.map +0 -1
- package/dist/esm/utils/print.js +0 -23
- package/dist/esm/utils/print.js.map +0 -1
- package/dist/esm/utils/promiseWithResolvers.js +0 -13
- package/dist/esm/utils/promiseWithResolvers.js.map +0 -1
- package/dist/esm/utils/queue.js +0 -145
- package/dist/esm/utils/queue.js.map +0 -1
- package/dist/esm/utils/range.js +0 -8
- package/dist/esm/utils/range.js.map +0 -1
- package/dist/esm/utils/requestQueue.js +0 -127
- package/dist/esm/utils/requestQueue.js.map +0 -1
- package/dist/esm/utils/result.js +0 -10
- package/dist/esm/utils/result.js.map +0 -1
- package/dist/esm/utils/rpc.js +0 -202
- package/dist/esm/utils/rpc.js.map +0 -1
- package/dist/esm/utils/serialize.js +0 -23
- package/dist/esm/utils/serialize.js.map +0 -1
- package/dist/esm/utils/timer.js +0 -17
- package/dist/esm/utils/timer.js.map +0 -1
- package/dist/esm/utils/wait.js +0 -8
- package/dist/esm/utils/wait.js.map +0 -1
- package/dist/esm/utils/zipper.js +0 -67
- package/dist/esm/utils/zipper.js.map +0 -1
- package/dist/types/bin/commands/codegen.d.ts +0 -5
- package/dist/types/bin/commands/codegen.d.ts.map +0 -1
- package/dist/types/bin/commands/dev.d.ts +0 -5
- package/dist/types/bin/commands/dev.d.ts.map +0 -1
- package/dist/types/bin/commands/list.d.ts +0 -5
- package/dist/types/bin/commands/list.d.ts.map +0 -1
- package/dist/types/bin/commands/serve.d.ts +0 -5
- package/dist/types/bin/commands/serve.d.ts.map +0 -1
- package/dist/types/bin/commands/start.d.ts +0 -5
- package/dist/types/bin/commands/start.d.ts.map +0 -1
- package/dist/types/bin/ponder.d.ts.map +0 -1
- package/dist/types/bin/utils/codegen.d.ts +0 -6
- package/dist/types/bin/utils/codegen.d.ts.map +0 -1
- package/dist/types/bin/utils/exit.d.ts +0 -9
- package/dist/types/bin/utils/exit.d.ts.map +0 -1
- package/dist/types/bin/utils/run.d.ts +0 -14
- package/dist/types/bin/utils/run.d.ts.map +0 -1
- package/dist/types/bin/utils/runServer.d.ts +0 -12
- package/dist/types/bin/utils/runServer.d.ts.map +0 -1
- package/dist/types/build/configAndIndexingFunctions.d.ts +0 -37
- package/dist/types/build/configAndIndexingFunctions.d.ts.map +0 -1
- package/dist/types/build/factory.d.ts +0 -10
- package/dist/types/build/factory.d.ts.map +0 -1
- package/dist/types/build/index.d.ts +0 -70
- package/dist/types/build/index.d.ts.map +0 -1
- package/dist/types/build/plugin.d.ts +0 -4
- package/dist/types/build/plugin.d.ts.map +0 -1
- package/dist/types/build/pre.d.ts +0 -35
- package/dist/types/build/pre.d.ts.map +0 -1
- package/dist/types/build/schema.d.ts +0 -18
- package/dist/types/build/schema.d.ts.map +0 -1
- package/dist/types/build/stacktrace.d.ts +0 -13
- package/dist/types/build/stacktrace.d.ts.map +0 -1
- package/dist/types/client/index.d.ts +0 -27
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/validate.d.ts +0 -2
- package/dist/types/client/validate.d.ts.map +0 -1
- package/dist/types/config/address.d.ts +0 -14
- package/dist/types/config/address.d.ts.map +0 -1
- package/dist/types/config/eventFilter.d.ts +0 -18
- package/dist/types/config/eventFilter.d.ts.map +0 -1
- package/dist/types/config/index.d.ts +0 -143
- package/dist/types/config/index.d.ts.map +0 -1
- package/dist/types/config/networks.d.ts +0 -30
- package/dist/types/config/networks.d.ts.map +0 -1
- package/dist/types/config/utilityTypes.d.ts +0 -43
- package/dist/types/config/utilityTypes.d.ts.map +0 -1
- package/dist/types/database/index.d.ts +0 -91
- package/dist/types/database/index.d.ts.map +0 -1
- package/dist/types/drizzle/bigint.d.ts +0 -25
- package/dist/types/drizzle/bigint.d.ts.map +0 -1
- package/dist/types/drizzle/hex.d.ts +0 -25
- package/dist/types/drizzle/hex.d.ts.map +0 -1
- package/dist/types/drizzle/index.d.ts +0 -14
- package/dist/types/drizzle/index.d.ts.map +0 -1
- package/dist/types/drizzle/kit/index.d.ts +0 -49
- package/dist/types/drizzle/kit/index.d.ts.map +0 -1
- package/dist/types/drizzle/onchain.d.ts.map +0 -1
- package/dist/types/graphql/index.d.ts +0 -14
- package/dist/types/graphql/index.d.ts.map +0 -1
- package/dist/types/graphql/json.d.ts +0 -3
- package/dist/types/graphql/json.d.ts.map +0 -1
- package/dist/types/graphql/middleware.d.ts +0 -29
- package/dist/types/graphql/middleware.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -18
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/indexing/addStackTrace.d.ts +0 -3
- package/dist/types/indexing/addStackTrace.d.ts.map +0 -1
- package/dist/types/indexing/index.d.ts +0 -575
- package/dist/types/indexing/index.d.ts.map +0 -1
- package/dist/types/indexing/ponderActions.d.ts +0 -47
- package/dist/types/indexing/ponderActions.d.ts.map +0 -1
- package/dist/types/indexing/service.d.ts +0 -73
- package/dist/types/indexing/service.d.ts.map +0 -1
- package/dist/types/indexing-store/historical.d.ts +0 -19
- package/dist/types/indexing-store/historical.d.ts.map +0 -1
- package/dist/types/indexing-store/index.d.ts +0 -10
- package/dist/types/indexing-store/index.d.ts.map +0 -1
- package/dist/types/indexing-store/metadata.d.ts +0 -10
- package/dist/types/indexing-store/metadata.d.ts.map +0 -1
- package/dist/types/indexing-store/realtime.d.ts +0 -10
- package/dist/types/indexing-store/realtime.d.ts.map +0 -1
- package/dist/types/internal/common.d.ts +0 -13
- package/dist/types/internal/common.d.ts.map +0 -1
- package/dist/types/internal/errors.d.ts +0 -55
- package/dist/types/internal/errors.d.ts.map +0 -1
- package/dist/types/internal/logger.d.ts +0 -26
- package/dist/types/internal/logger.d.ts.map +0 -1
- package/dist/types/internal/metrics.d.ts +0 -77
- package/dist/types/internal/metrics.d.ts.map +0 -1
- package/dist/types/internal/options.d.ts +0 -59
- package/dist/types/internal/options.d.ts.map +0 -1
- package/dist/types/internal/shutdown.d.ts +0 -8
- package/dist/types/internal/shutdown.d.ts.map +0 -1
- package/dist/types/internal/telemetry.d.ts +0 -43
- package/dist/types/internal/telemetry.d.ts.map +0 -1
- package/dist/types/internal/types.d.ts +0 -328
- package/dist/types/internal/types.d.ts.map +0 -1
- package/dist/types/server/error.d.ts +0 -5
- package/dist/types/server/error.d.ts.map +0 -1
- package/dist/types/server/index.d.ts +0 -13
- package/dist/types/server/index.d.ts.map +0 -1
- package/dist/types/sync/abi.d.ts +0 -54
- package/dist/types/sync/abi.d.ts.map +0 -1
- package/dist/types/sync/events.d.ts +0 -24
- package/dist/types/sync/events.d.ts.map +0 -1
- package/dist/types/sync/filter.d.ts +0 -71
- package/dist/types/sync/filter.d.ts.map +0 -1
- package/dist/types/sync/fragments.d.ts +0 -21
- package/dist/types/sync/fragments.d.ts.map +0 -1
- package/dist/types/sync/index.d.ts +0 -112
- package/dist/types/sync/index.d.ts.map +0 -1
- package/dist/types/sync/transport.d.ts +0 -8
- package/dist/types/sync/transport.d.ts.map +0 -1
- package/dist/types/sync-historical/index.d.ts +0 -28
- package/dist/types/sync-historical/index.d.ts.map +0 -1
- package/dist/types/sync-realtime/bloom.d.ts +0 -19
- package/dist/types/sync-realtime/bloom.d.ts.map +0 -1
- package/dist/types/sync-realtime/index.d.ts +0 -48
- package/dist/types/sync-realtime/index.d.ts.map +0 -1
- package/dist/types/sync-store/encoding.d.ts +0 -151
- package/dist/types/sync-store/encoding.d.ts.map +0 -1
- package/dist/types/sync-store/index.d.ts +0 -104
- package/dist/types/sync-store/index.d.ts.map +0 -1
- package/dist/types/sync-store/migrations.d.ts +0 -13
- package/dist/types/sync-store/migrations.d.ts.map +0 -1
- package/dist/types/types/db.d.ts +0 -213
- package/dist/types/types/db.d.ts.map +0 -1
- package/dist/types/types/eth.d.ts +0 -196
- package/dist/types/types/eth.d.ts.map +0 -1
- package/dist/types/types/sync.d.ts +0 -15
- package/dist/types/types/sync.d.ts.map +0 -1
- package/dist/types/types/utils.d.ts +0 -22
- package/dist/types/types/utils.d.ts.map +0 -1
- package/dist/types/types/virtual.d.ts +0 -95
- package/dist/types/types/virtual.d.ts.map +0 -1
- package/dist/types/ui/ProgressBar.d.ts +0 -7
- package/dist/types/ui/ProgressBar.d.ts.map +0 -1
- package/dist/types/ui/Table.d.ts +0 -24
- package/dist/types/ui/Table.d.ts.map +0 -1
- package/dist/types/ui/app.d.ts +0 -14
- package/dist/types/ui/app.d.ts.map +0 -1
- package/dist/types/ui/graphiql.html.d.ts +0 -2
- package/dist/types/ui/graphiql.html.d.ts.map +0 -1
- package/dist/types/ui/index.d.ts +0 -5
- package/dist/types/ui/index.d.ts.map +0 -1
- package/dist/types/utils/bigint.d.ts +0 -15
- package/dist/types/utils/bigint.d.ts.map +0 -1
- package/dist/types/utils/chains.d.ts +0 -3
- package/dist/types/utils/chains.d.ts.map +0 -1
- package/dist/types/utils/checkpoint.d.ts +0 -40
- package/dist/types/utils/checkpoint.d.ts.map +0 -1
- package/dist/types/utils/chunk.d.ts +0 -2
- package/dist/types/utils/chunk.d.ts.map +0 -1
- package/dist/types/utils/date.d.ts +0 -7
- package/dist/types/utils/date.d.ts.map +0 -1
- package/dist/types/utils/debug.d.ts +0 -105
- package/dist/types/utils/debug.d.ts.map +0 -1
- package/dist/types/utils/dedupe.d.ts +0 -20
- package/dist/types/utils/dedupe.d.ts.map +0 -1
- package/dist/types/utils/duplicates.d.ts +0 -7
- package/dist/types/utils/duplicates.d.ts.map +0 -1
- package/dist/types/utils/estimate.d.ts +0 -11
- package/dist/types/utils/estimate.d.ts.map +0 -1
- package/dist/types/utils/extend.d.ts +0 -13
- package/dist/types/utils/extend.d.ts.map +0 -1
- package/dist/types/utils/format.d.ts +0 -3
- package/dist/types/utils/format.d.ts.map +0 -1
- package/dist/types/utils/generators.d.ts +0 -23
- package/dist/types/utils/generators.d.ts.map +0 -1
- package/dist/types/utils/hash.d.ts +0 -11
- package/dist/types/utils/hash.d.ts.map +0 -1
- package/dist/types/utils/interval.d.ts +0 -53
- package/dist/types/utils/interval.d.ts.map +0 -1
- package/dist/types/utils/lowercase.d.ts +0 -5
- package/dist/types/utils/lowercase.d.ts.map +0 -1
- package/dist/types/utils/mutex.d.ts +0 -8
- package/dist/types/utils/mutex.d.ts.map +0 -1
- package/dist/types/utils/never.d.ts +0 -2
- package/dist/types/utils/never.d.ts.map +0 -1
- package/dist/types/utils/offset.d.ts +0 -3
- package/dist/types/utils/offset.d.ts.map +0 -1
- package/dist/types/utils/order.d.ts +0 -2
- package/dist/types/utils/order.d.ts.map +0 -1
- package/dist/types/utils/partition.d.ts +0 -22
- package/dist/types/utils/partition.d.ts.map +0 -1
- package/dist/types/utils/pg.d.ts +0 -5
- package/dist/types/utils/pg.d.ts.map +0 -1
- package/dist/types/utils/pglite.d.ts +0 -25
- package/dist/types/utils/pglite.d.ts.map +0 -1
- package/dist/types/utils/port.d.ts +0 -5
- package/dist/types/utils/port.d.ts.map +0 -1
- package/dist/types/utils/print.d.ts +0 -2
- package/dist/types/utils/print.d.ts.map +0 -1
- package/dist/types/utils/promiseWithResolvers.d.ts +0 -10
- package/dist/types/utils/promiseWithResolvers.d.ts.map +0 -1
- package/dist/types/utils/queue.d.ts +0 -33
- package/dist/types/utils/queue.d.ts.map +0 -1
- package/dist/types/utils/range.d.ts +0 -8
- package/dist/types/utils/range.d.ts.map +0 -1
- package/dist/types/utils/requestQueue.d.ts +0 -21
- package/dist/types/utils/requestQueue.d.ts.map +0 -1
- package/dist/types/utils/result.d.ts +0 -17
- package/dist/types/utils/result.d.ts.map +0 -1
- package/dist/types/utils/rpc.d.ts +0 -57
- package/dist/types/utils/rpc.d.ts.map +0 -1
- package/dist/types/utils/serialize.d.ts +0 -19
- package/dist/types/utils/serialize.d.ts.map +0 -1
- package/dist/types/utils/timer.d.ts +0 -11
- package/dist/types/utils/timer.d.ts.map +0 -1
- package/dist/types/utils/wait.d.ts +0 -6
- package/dist/types/utils/wait.d.ts.map +0 -1
- package/dist/types/utils/zipper.d.ts +0 -36
- package/dist/types/utils/zipper.d.ts.map +0 -1
- package/src/utils/dedupe.ts +0 -40
- package/src/utils/promiseWithResolvers.ts +0 -20
- package/src/utils/queue.ts +0 -250
|
@@ -1,727 +0,0 @@
|
|
|
1
|
-
import { NonRetryableError } from '../internal/errors.js';
|
|
2
|
-
import { isAddressFactory, shouldGetTransactionReceipt, } from '../sync/filter.js';
|
|
3
|
-
import { fragmentToId, getFragments } from '../sync/fragments.js';
|
|
4
|
-
import { sql as ksql } from "kysely";
|
|
5
|
-
import { checksumAddress, hexToBigInt, } from "viem";
|
|
6
|
-
import { encodeBlock, encodeLog, encodeTrace, encodeTransaction, encodeTransactionReceipt, } from "./encoding.js";
|
|
7
|
-
const logFactorySQL = (qb, factory) => qb
|
|
8
|
-
.select((() => {
|
|
9
|
-
if (factory.childAddressLocation.startsWith("offset")) {
|
|
10
|
-
const childAddressOffset = Number(factory.childAddressLocation.substring(6));
|
|
11
|
-
const start = 2 + 12 * 2 + childAddressOffset * 2 + 1;
|
|
12
|
-
const length = 20 * 2;
|
|
13
|
-
return ksql `'0x' || substring(data from ${start}::int for ${length}::int)`;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
const start = 2 + 12 * 2 + 1;
|
|
17
|
-
const length = 20 * 2;
|
|
18
|
-
return ksql `'0x' || substring(${ksql.ref(factory.childAddressLocation)} from ${start}::integer for ${length}::integer)`;
|
|
19
|
-
}
|
|
20
|
-
})().as("childAddress"))
|
|
21
|
-
.distinct()
|
|
22
|
-
.$call((qb) => {
|
|
23
|
-
if (Array.isArray(factory.address)) {
|
|
24
|
-
return qb.where("address", "in", factory.address);
|
|
25
|
-
}
|
|
26
|
-
return qb.where("address", "=", factory.address);
|
|
27
|
-
})
|
|
28
|
-
.where("topic0", "=", factory.eventSelector)
|
|
29
|
-
.where("chainId", "=", factory.chainId);
|
|
30
|
-
export const createSyncStore = ({ common, database, }) => ({
|
|
31
|
-
insertIntervals: async ({ intervals, chainId }) => {
|
|
32
|
-
if (intervals.length === 0)
|
|
33
|
-
return;
|
|
34
|
-
await database.wrap({ method: "insertIntervals", includeTraceLogs: true }, async () => {
|
|
35
|
-
const perFragmentIntervals = new Map();
|
|
36
|
-
const values = [];
|
|
37
|
-
// dedupe and merge matching fragments
|
|
38
|
-
for (const { filter, interval } of intervals) {
|
|
39
|
-
for (const fragment of getFragments(filter)) {
|
|
40
|
-
const fragmentId = fragmentToId(fragment.fragment);
|
|
41
|
-
if (perFragmentIntervals.has(fragmentId) === false) {
|
|
42
|
-
perFragmentIntervals.set(fragmentId, []);
|
|
43
|
-
}
|
|
44
|
-
perFragmentIntervals.get(fragmentId).push(interval);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// NOTE: In order to force proper range union behavior, `interval[1]` must
|
|
48
|
-
// be rounded up.
|
|
49
|
-
for (const [fragmentId, intervals] of perFragmentIntervals) {
|
|
50
|
-
const numranges = intervals
|
|
51
|
-
.map((interval) => {
|
|
52
|
-
const start = interval[0];
|
|
53
|
-
const end = interval[1] + 1;
|
|
54
|
-
return `numrange(${start}, ${end}, '[]')`;
|
|
55
|
-
})
|
|
56
|
-
.join(", ");
|
|
57
|
-
values.push({
|
|
58
|
-
fragment_id: fragmentId,
|
|
59
|
-
chain_id: chainId,
|
|
60
|
-
blocks: ksql.raw(`nummultirange(${numranges})`),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
await database.qb.sync
|
|
64
|
-
.insertInto("intervals")
|
|
65
|
-
.values(values)
|
|
66
|
-
.onConflict((oc) => oc.column("fragment_id").doUpdateSet({
|
|
67
|
-
blocks: ksql `intervals.blocks + excluded.blocks`,
|
|
68
|
-
}))
|
|
69
|
-
.execute();
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
getIntervals: async ({ filters }) => database.wrap({ method: "getIntervals", includeTraceLogs: true }, async () => {
|
|
73
|
-
let query;
|
|
74
|
-
for (let i = 0; i < filters.length; i++) {
|
|
75
|
-
const filter = filters[i];
|
|
76
|
-
const fragments = getFragments(filter);
|
|
77
|
-
for (let j = 0; j < fragments.length; j++) {
|
|
78
|
-
const fragment = fragments[j];
|
|
79
|
-
const _query = database.qb.sync
|
|
80
|
-
.selectFrom(database.qb.sync
|
|
81
|
-
.selectFrom("intervals")
|
|
82
|
-
.select(ksql `unnest(blocks)`.as("blocks"))
|
|
83
|
-
.where("fragment_id", "in", fragment.adjacentIds)
|
|
84
|
-
.as("unnested"))
|
|
85
|
-
.select([
|
|
86
|
-
ksql `range_agg(unnested.blocks)`.as("merged_blocks"),
|
|
87
|
-
ksql.raw(`'${i}'`).as("filter"),
|
|
88
|
-
ksql.raw(`'${j}'`).as("fragment"),
|
|
89
|
-
]);
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
query = query === undefined ? _query : query.unionAll(_query);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const rows = await query.execute();
|
|
95
|
-
const result = new Map();
|
|
96
|
-
// NOTE: `interval[1]` must be rounded down in order to offset the previous
|
|
97
|
-
// rounding.
|
|
98
|
-
for (let i = 0; i < filters.length; i++) {
|
|
99
|
-
const filter = filters[i];
|
|
100
|
-
const fragments = getFragments(filter);
|
|
101
|
-
result.set(filter, []);
|
|
102
|
-
for (let j = 0; j < fragments.length; j++) {
|
|
103
|
-
const fragment = fragments[j];
|
|
104
|
-
const intervals = rows
|
|
105
|
-
.filter((row) => row.filter === `${i}`)
|
|
106
|
-
.filter((row) => row.fragment === `${j}`)
|
|
107
|
-
.map((row) => (row.merged_blocks
|
|
108
|
-
? JSON.parse(`[${row.merged_blocks.slice(1, -1)}]`)
|
|
109
|
-
: []).map((interval) => [interval[0], interval[1] - 1]))[0];
|
|
110
|
-
result
|
|
111
|
-
.get(filter)
|
|
112
|
-
.push({ fragment: fragment.fragment, intervals });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}),
|
|
117
|
-
getChildAddresses: ({ filter, limit }) => database.wrap({ method: "getChildAddresses", includeTraceLogs: true }, async () => {
|
|
118
|
-
return await database.qb.sync
|
|
119
|
-
.selectFrom("logs")
|
|
120
|
-
.$call((qb) => logFactorySQL(qb, filter))
|
|
121
|
-
.$if(limit !== undefined, (qb) => qb.limit(limit))
|
|
122
|
-
.execute()
|
|
123
|
-
.then((addresses) => addresses.map(({ childAddress }) => childAddress));
|
|
124
|
-
}),
|
|
125
|
-
filterChildAddresses: ({ filter, addresses }) => database.wrap({ method: "filterChildAddresses", includeTraceLogs: true }, async () => {
|
|
126
|
-
const result = await database.qb.sync
|
|
127
|
-
.with("addresses(address)", () => ksql `( values ${ksql.join(addresses.map((a) => ksql `( ${ksql.val(a)} )`))} )`)
|
|
128
|
-
.with("childAddresses", (db) => db.selectFrom("logs").$call((qb) => logFactorySQL(qb, filter)))
|
|
129
|
-
.selectFrom("addresses")
|
|
130
|
-
.where("addresses.address", "in", ksql `(SELECT "childAddress" FROM "childAddresses")`)
|
|
131
|
-
.selectAll()
|
|
132
|
-
.execute();
|
|
133
|
-
return new Set([...result.map(({ address }) => address)]);
|
|
134
|
-
}),
|
|
135
|
-
insertLogs: async ({ logs, shouldUpdateCheckpoint, chainId }) => {
|
|
136
|
-
if (logs.length === 0)
|
|
137
|
-
return;
|
|
138
|
-
await database.wrap({ method: "insertLogs", includeTraceLogs: true }, async () => {
|
|
139
|
-
// Calculate `batchSize` based on how many parameters the
|
|
140
|
-
// input will have
|
|
141
|
-
const batchSize = Math.floor(common.options.databaseMaxQueryParameters /
|
|
142
|
-
Object.keys(encodeLog({ log: logs[0].log, chainId })).length);
|
|
143
|
-
// As an optimization, logs that are matched by a factory do
|
|
144
|
-
// not contain a checkpoint, because not corresponding block is
|
|
145
|
-
// fetched (no block.timestamp). However, when a log is matched by
|
|
146
|
-
// both a log filter and a factory, the checkpoint must be included
|
|
147
|
-
// in the db.
|
|
148
|
-
for (let i = 0; i < logs.length; i += batchSize) {
|
|
149
|
-
await database.qb.sync
|
|
150
|
-
.insertInto("logs")
|
|
151
|
-
.values(logs
|
|
152
|
-
.slice(i, i + batchSize)
|
|
153
|
-
.map(({ log, block }) => encodeLog({ log, block, chainId })))
|
|
154
|
-
.onConflict((oc) => oc.column("id").$call((qb) => shouldUpdateCheckpoint
|
|
155
|
-
? qb.doUpdateSet((eb) => ({
|
|
156
|
-
checkpoint: eb.ref("excluded.checkpoint"),
|
|
157
|
-
}))
|
|
158
|
-
: qb.doNothing()))
|
|
159
|
-
.execute();
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
insertBlocks: async ({ blocks, chainId }) => {
|
|
164
|
-
if (blocks.length === 0)
|
|
165
|
-
return;
|
|
166
|
-
await database.wrap({ method: "insertBlocks", includeTraceLogs: true }, async () => {
|
|
167
|
-
// Calculate `batchSize` based on how many parameters the
|
|
168
|
-
// input will have
|
|
169
|
-
const batchSize = Math.floor(common.options.databaseMaxQueryParameters /
|
|
170
|
-
Object.keys(encodeBlock({ block: blocks[0], chainId })).length);
|
|
171
|
-
for (let i = 0; i < blocks.length; i += batchSize) {
|
|
172
|
-
await database.qb.sync
|
|
173
|
-
.insertInto("blocks")
|
|
174
|
-
.values(blocks
|
|
175
|
-
.slice(i, i + batchSize)
|
|
176
|
-
.map((block) => encodeBlock({ block, chainId })))
|
|
177
|
-
.onConflict((oc) => oc.column("hash").doNothing())
|
|
178
|
-
.execute();
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
hasBlock: async ({ hash }) => database.wrap({ method: "hasBlock", includeTraceLogs: true }, async () => {
|
|
183
|
-
return await database.qb.sync
|
|
184
|
-
.selectFrom("blocks")
|
|
185
|
-
.select("hash")
|
|
186
|
-
.where("hash", "=", hash)
|
|
187
|
-
.executeTakeFirst()
|
|
188
|
-
.then((result) => result !== undefined);
|
|
189
|
-
}),
|
|
190
|
-
insertTransactions: async ({ transactions, chainId }) => {
|
|
191
|
-
if (transactions.length === 0)
|
|
192
|
-
return;
|
|
193
|
-
await database.wrap({ method: "insertTransactions", includeTraceLogs: true }, async () => {
|
|
194
|
-
// Calculate `batchSize` based on how many parameters the
|
|
195
|
-
// input will have
|
|
196
|
-
const batchSize = Math.floor(common.options.databaseMaxQueryParameters /
|
|
197
|
-
Object.keys(encodeTransaction({
|
|
198
|
-
transaction: transactions[0].transaction,
|
|
199
|
-
block: transactions[0].block,
|
|
200
|
-
chainId,
|
|
201
|
-
})).length);
|
|
202
|
-
// As an optimization for the migration, transactions inserted before 0.8 do not
|
|
203
|
-
// contain a checkpoint. However, for correctness the checkpoint must be inserted
|
|
204
|
-
// for new transactions (using onConflictDoUpdate).
|
|
205
|
-
for (let i = 0; i < transactions.length; i += batchSize) {
|
|
206
|
-
await database.qb.sync
|
|
207
|
-
.insertInto("transactions")
|
|
208
|
-
.values(transactions
|
|
209
|
-
.slice(i, i + batchSize)
|
|
210
|
-
.map(({ transaction, block }) => encodeTransaction({ transaction, block, chainId })))
|
|
211
|
-
.onConflict((oc) => oc.column("hash").doUpdateSet((eb) => ({
|
|
212
|
-
checkpoint: eb.ref("excluded.checkpoint"),
|
|
213
|
-
})))
|
|
214
|
-
.execute();
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
},
|
|
218
|
-
hasTransaction: async ({ hash }) => database.wrap({ method: "hasTransaction", includeTraceLogs: true }, async () => {
|
|
219
|
-
return await database.qb.sync
|
|
220
|
-
.selectFrom("transactions")
|
|
221
|
-
.select("hash")
|
|
222
|
-
.where("hash", "=", hash)
|
|
223
|
-
.executeTakeFirst()
|
|
224
|
-
.then((result) => result !== undefined);
|
|
225
|
-
}),
|
|
226
|
-
insertTransactionReceipts: async ({ transactionReceipts, chainId }) => {
|
|
227
|
-
if (transactionReceipts.length === 0)
|
|
228
|
-
return;
|
|
229
|
-
await database.wrap({ method: "insertTransactionReceipts", includeTraceLogs: true }, async () => {
|
|
230
|
-
// Calculate `batchSize` based on how many parameters the
|
|
231
|
-
// input will have
|
|
232
|
-
const batchSize = Math.floor(common.options.databaseMaxQueryParameters /
|
|
233
|
-
Object.keys(encodeTransactionReceipt({
|
|
234
|
-
transactionReceipt: transactionReceipts[0],
|
|
235
|
-
chainId,
|
|
236
|
-
})).length);
|
|
237
|
-
for (let i = 0; i < transactionReceipts.length; i += batchSize) {
|
|
238
|
-
await database.qb.sync
|
|
239
|
-
.insertInto("transactionReceipts")
|
|
240
|
-
.values(transactionReceipts
|
|
241
|
-
.slice(i, i + batchSize)
|
|
242
|
-
.map((transactionReceipt) => encodeTransactionReceipt({
|
|
243
|
-
transactionReceipt,
|
|
244
|
-
chainId,
|
|
245
|
-
})))
|
|
246
|
-
.onConflict((oc) => oc.column("transactionHash").doNothing())
|
|
247
|
-
.execute();
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
hasTransactionReceipt: async ({ hash }) => database.wrap({ method: "hasTransactionReceipt", includeTraceLogs: true }, async () => {
|
|
252
|
-
return await database.qb.sync
|
|
253
|
-
.selectFrom("transactionReceipts")
|
|
254
|
-
.select("transactionHash")
|
|
255
|
-
.where("transactionHash", "=", hash)
|
|
256
|
-
.executeTakeFirst()
|
|
257
|
-
.then((result) => result !== undefined);
|
|
258
|
-
}),
|
|
259
|
-
insertTraces: async ({ traces, chainId }) => {
|
|
260
|
-
if (traces.length === 0)
|
|
261
|
-
return;
|
|
262
|
-
await database.wrap({ method: "insertTraces", includeTraceLogs: true }, async () => {
|
|
263
|
-
// Calculate `batchSize` based on how many parameters the
|
|
264
|
-
// input will have
|
|
265
|
-
const batchSize = Math.floor(common.options.databaseMaxQueryParameters /
|
|
266
|
-
Object.keys(encodeTrace({
|
|
267
|
-
trace: traces[0].trace.trace,
|
|
268
|
-
block: traces[0].block,
|
|
269
|
-
transaction: traces[0].transaction,
|
|
270
|
-
chainId,
|
|
271
|
-
})).length);
|
|
272
|
-
for (let i = 0; i < traces.length; i += batchSize) {
|
|
273
|
-
await database.qb.sync
|
|
274
|
-
.insertInto("traces")
|
|
275
|
-
.values(traces
|
|
276
|
-
.slice(i, i + batchSize)
|
|
277
|
-
.map(({ trace, block, transaction }) => encodeTrace({
|
|
278
|
-
trace: trace.trace,
|
|
279
|
-
block,
|
|
280
|
-
transaction,
|
|
281
|
-
chainId,
|
|
282
|
-
})))
|
|
283
|
-
.onConflict((oc) => oc.column("id").doNothing())
|
|
284
|
-
.execute();
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
},
|
|
288
|
-
getEvents: async ({ filters, from, to, limit }) => database.wrap({ method: "getEvents", includeTraceLogs: true }, async () => {
|
|
289
|
-
let query;
|
|
290
|
-
for (let i = 0; i < filters.length; i++) {
|
|
291
|
-
const filter = filters[i];
|
|
292
|
-
const _query = filter.type === "log"
|
|
293
|
-
? logSQL(filter, database.qb.sync, i)
|
|
294
|
-
: filter.type === "block"
|
|
295
|
-
? blockSQL(filter, database.qb.sync, i)
|
|
296
|
-
: filter.type === "transaction"
|
|
297
|
-
? transactionSQL(filter, database.qb.sync, i)
|
|
298
|
-
: filter.type === "transfer"
|
|
299
|
-
? transferSQL(filter, database.qb.sync, i)
|
|
300
|
-
: traceSQL(filter, database.qb.sync, i);
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
query = query === undefined ? _query : query.unionAll(_query);
|
|
303
|
-
}
|
|
304
|
-
const rows = await database.qb.sync
|
|
305
|
-
.with("event", () => query)
|
|
306
|
-
.selectFrom("event")
|
|
307
|
-
.select([
|
|
308
|
-
"event.filterIndex as event_filterIndex",
|
|
309
|
-
"event.checkpoint as event_checkpoint",
|
|
310
|
-
])
|
|
311
|
-
.innerJoin("blocks", "blocks.hash", "event.blockHash")
|
|
312
|
-
.select([
|
|
313
|
-
"blocks.baseFeePerGas as block_baseFeePerGas",
|
|
314
|
-
"blocks.difficulty as block_difficulty",
|
|
315
|
-
"blocks.extraData as block_extraData",
|
|
316
|
-
"blocks.gasLimit as block_gasLimit",
|
|
317
|
-
"blocks.gasUsed as block_gasUsed",
|
|
318
|
-
"blocks.hash as block_hash",
|
|
319
|
-
"blocks.logsBloom as block_logsBloom",
|
|
320
|
-
"blocks.miner as block_miner",
|
|
321
|
-
"blocks.mixHash as block_mixHash",
|
|
322
|
-
"blocks.nonce as block_nonce",
|
|
323
|
-
"blocks.number as block_number",
|
|
324
|
-
"blocks.parentHash as block_parentHash",
|
|
325
|
-
"blocks.receiptsRoot as block_receiptsRoot",
|
|
326
|
-
"blocks.sha3Uncles as block_sha3Uncles",
|
|
327
|
-
"blocks.size as block_size",
|
|
328
|
-
"blocks.stateRoot as block_stateRoot",
|
|
329
|
-
"blocks.timestamp as block_timestamp",
|
|
330
|
-
"blocks.totalDifficulty as block_totalDifficulty",
|
|
331
|
-
"blocks.transactionsRoot as block_transactionsRoot",
|
|
332
|
-
])
|
|
333
|
-
.leftJoin("logs", "logs.id", "event.logId")
|
|
334
|
-
.select([
|
|
335
|
-
"logs.address as log_address",
|
|
336
|
-
"logs.chainId as log_chainId",
|
|
337
|
-
"logs.data as log_data",
|
|
338
|
-
"logs.id as log_id",
|
|
339
|
-
"logs.logIndex as log_logIndex",
|
|
340
|
-
"logs.topic0 as log_topic0",
|
|
341
|
-
"logs.topic1 as log_topic1",
|
|
342
|
-
"logs.topic2 as log_topic2",
|
|
343
|
-
"logs.topic3 as log_topic3",
|
|
344
|
-
])
|
|
345
|
-
.leftJoin("transactions", "transactions.hash", "event.transactionHash")
|
|
346
|
-
.select([
|
|
347
|
-
"transactions.accessList as tx_accessList",
|
|
348
|
-
"transactions.from as tx_from",
|
|
349
|
-
"transactions.gas as tx_gas",
|
|
350
|
-
"transactions.gasPrice as tx_gasPrice",
|
|
351
|
-
"transactions.hash as tx_hash",
|
|
352
|
-
"transactions.input as tx_input",
|
|
353
|
-
"transactions.maxFeePerGas as tx_maxFeePerGas",
|
|
354
|
-
"transactions.maxPriorityFeePerGas as tx_maxPriorityFeePerGas",
|
|
355
|
-
"transactions.nonce as tx_nonce",
|
|
356
|
-
"transactions.r as tx_r",
|
|
357
|
-
"transactions.s as tx_s",
|
|
358
|
-
"transactions.to as tx_to",
|
|
359
|
-
"transactions.transactionIndex as tx_transactionIndex",
|
|
360
|
-
"transactions.type as tx_type",
|
|
361
|
-
"transactions.value as tx_value",
|
|
362
|
-
"transactions.v as tx_v",
|
|
363
|
-
])
|
|
364
|
-
.leftJoin("traces", "traces.id", "event.traceId")
|
|
365
|
-
.select([
|
|
366
|
-
"traces.id as trace_id",
|
|
367
|
-
"traces.type as trace_callType",
|
|
368
|
-
"traces.from as trace_from",
|
|
369
|
-
"traces.to as trace_to",
|
|
370
|
-
"traces.gas as trace_gas",
|
|
371
|
-
"traces.gasUsed as trace_gasUsed",
|
|
372
|
-
"traces.input as trace_input",
|
|
373
|
-
"traces.output as trace_output",
|
|
374
|
-
"traces.error as trace_error",
|
|
375
|
-
"traces.revertReason as trace_revertReason",
|
|
376
|
-
"traces.value as trace_value",
|
|
377
|
-
"traces.index as trace_index",
|
|
378
|
-
"traces.subcalls as trace_subcalls",
|
|
379
|
-
])
|
|
380
|
-
.leftJoin("transactionReceipts", "transactionReceipts.transactionHash", "event.transactionHash")
|
|
381
|
-
.select([
|
|
382
|
-
"transactionReceipts.contractAddress as txr_contractAddress",
|
|
383
|
-
"transactionReceipts.cumulativeGasUsed as txr_cumulativeGasUsed",
|
|
384
|
-
"transactionReceipts.effectiveGasPrice as txr_effectiveGasPrice",
|
|
385
|
-
"transactionReceipts.from as txr_from",
|
|
386
|
-
"transactionReceipts.gasUsed as txr_gasUsed",
|
|
387
|
-
"transactionReceipts.logsBloom as txr_logsBloom",
|
|
388
|
-
"transactionReceipts.status as txr_status",
|
|
389
|
-
"transactionReceipts.to as txr_to",
|
|
390
|
-
"transactionReceipts.type as txr_type",
|
|
391
|
-
])
|
|
392
|
-
.where("event.checkpoint", ">", from)
|
|
393
|
-
.where("event.checkpoint", "<=", to)
|
|
394
|
-
.orderBy("event.checkpoint", "asc")
|
|
395
|
-
.orderBy("event.filterIndex", "asc")
|
|
396
|
-
.$if(limit !== undefined, (qb) => qb.limit(limit))
|
|
397
|
-
.execute()
|
|
398
|
-
.catch((error) => {
|
|
399
|
-
if (error.message.includes("statement timeout")) {
|
|
400
|
-
throw new NonRetryableError(error.message);
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
throw error;
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
const events = rows.map((_row) => {
|
|
407
|
-
// Without this cast, the block_ and tx_ fields are all nullable
|
|
408
|
-
// which makes this very annoying. Should probably add a runtime check
|
|
409
|
-
// that those fields are indeed present before continuing here.
|
|
410
|
-
const row = _row;
|
|
411
|
-
const filter = filters[row.event_filterIndex];
|
|
412
|
-
const hasLog = row.log_id !== null;
|
|
413
|
-
const hasTransaction = row.tx_hash !== null;
|
|
414
|
-
const hasTrace = row.trace_id !== null;
|
|
415
|
-
const hasTransactionReceipt = shouldGetTransactionReceipt(filter) && row.txr_from !== null;
|
|
416
|
-
return {
|
|
417
|
-
chainId: filter.chainId,
|
|
418
|
-
sourceIndex: Number(row.event_filterIndex),
|
|
419
|
-
checkpoint: row.event_checkpoint,
|
|
420
|
-
block: {
|
|
421
|
-
baseFeePerGas: row.block_baseFeePerGas !== null
|
|
422
|
-
? BigInt(row.block_baseFeePerGas)
|
|
423
|
-
: null,
|
|
424
|
-
difficulty: BigInt(row.block_difficulty),
|
|
425
|
-
extraData: row.block_extraData,
|
|
426
|
-
gasLimit: BigInt(row.block_gasLimit),
|
|
427
|
-
gasUsed: BigInt(row.block_gasUsed),
|
|
428
|
-
hash: row.block_hash,
|
|
429
|
-
logsBloom: row.block_logsBloom,
|
|
430
|
-
miner: checksumAddress(row.block_miner),
|
|
431
|
-
mixHash: row.block_mixHash,
|
|
432
|
-
nonce: row.block_nonce,
|
|
433
|
-
number: BigInt(row.block_number),
|
|
434
|
-
parentHash: row.block_parentHash,
|
|
435
|
-
receiptsRoot: row.block_receiptsRoot,
|
|
436
|
-
sha3Uncles: row.block_sha3Uncles,
|
|
437
|
-
size: BigInt(row.block_size),
|
|
438
|
-
stateRoot: row.block_stateRoot,
|
|
439
|
-
timestamp: BigInt(row.block_timestamp),
|
|
440
|
-
totalDifficulty: row.block_totalDifficulty !== null
|
|
441
|
-
? BigInt(row.block_totalDifficulty)
|
|
442
|
-
: null,
|
|
443
|
-
transactionsRoot: row.block_transactionsRoot,
|
|
444
|
-
},
|
|
445
|
-
log: hasLog
|
|
446
|
-
? {
|
|
447
|
-
address: checksumAddress(row.log_address),
|
|
448
|
-
data: row.log_data,
|
|
449
|
-
id: row.log_id,
|
|
450
|
-
logIndex: Number(row.log_logIndex),
|
|
451
|
-
removed: false,
|
|
452
|
-
topics: [
|
|
453
|
-
row.log_topic0,
|
|
454
|
-
row.log_topic1,
|
|
455
|
-
row.log_topic2,
|
|
456
|
-
row.log_topic3,
|
|
457
|
-
].filter((t) => t !== null),
|
|
458
|
-
}
|
|
459
|
-
: undefined,
|
|
460
|
-
transaction: hasTransaction
|
|
461
|
-
? {
|
|
462
|
-
from: checksumAddress(row.tx_from),
|
|
463
|
-
gas: BigInt(row.tx_gas),
|
|
464
|
-
hash: row.tx_hash,
|
|
465
|
-
input: row.tx_input,
|
|
466
|
-
nonce: Number(row.tx_nonce),
|
|
467
|
-
r: row.tx_r,
|
|
468
|
-
s: row.tx_s,
|
|
469
|
-
to: row.tx_to ? checksumAddress(row.tx_to) : row.tx_to,
|
|
470
|
-
transactionIndex: Number(row.tx_transactionIndex),
|
|
471
|
-
value: BigInt(row.tx_value),
|
|
472
|
-
v: row.tx_v !== null ? BigInt(row.tx_v) : null,
|
|
473
|
-
...(row.tx_type === "0x0"
|
|
474
|
-
? {
|
|
475
|
-
type: "legacy",
|
|
476
|
-
gasPrice: BigInt(row.tx_gasPrice),
|
|
477
|
-
}
|
|
478
|
-
: row.tx_type === "0x1"
|
|
479
|
-
? {
|
|
480
|
-
type: "eip2930",
|
|
481
|
-
gasPrice: BigInt(row.tx_gasPrice),
|
|
482
|
-
accessList: JSON.parse(row.tx_accessList),
|
|
483
|
-
}
|
|
484
|
-
: row.tx_type === "0x2"
|
|
485
|
-
? {
|
|
486
|
-
type: "eip1559",
|
|
487
|
-
maxFeePerGas: BigInt(row.tx_maxFeePerGas),
|
|
488
|
-
maxPriorityFeePerGas: BigInt(row.tx_maxPriorityFeePerGas),
|
|
489
|
-
}
|
|
490
|
-
: row.tx_type === "0x7e"
|
|
491
|
-
? {
|
|
492
|
-
type: "deposit",
|
|
493
|
-
maxFeePerGas: row.tx_maxFeePerGas !== null
|
|
494
|
-
? BigInt(row.tx_maxFeePerGas)
|
|
495
|
-
: undefined,
|
|
496
|
-
maxPriorityFeePerGas: row.tx_maxPriorityFeePerGas !== null
|
|
497
|
-
? BigInt(row.tx_maxPriorityFeePerGas)
|
|
498
|
-
: undefined,
|
|
499
|
-
}
|
|
500
|
-
: {
|
|
501
|
-
type: row.tx_type,
|
|
502
|
-
}),
|
|
503
|
-
}
|
|
504
|
-
: undefined,
|
|
505
|
-
trace: hasTrace
|
|
506
|
-
? {
|
|
507
|
-
id: row.trace_id,
|
|
508
|
-
type: row.trace_callType,
|
|
509
|
-
from: checksumAddress(row.trace_from),
|
|
510
|
-
to: checksumAddress(row.trace_to),
|
|
511
|
-
gas: BigInt(row.trace_gas),
|
|
512
|
-
gasUsed: BigInt(row.trace_gasUsed),
|
|
513
|
-
input: row.trace_input,
|
|
514
|
-
output: row.trace_output,
|
|
515
|
-
value: BigInt(row.trace_value),
|
|
516
|
-
traceIndex: Number(row.trace_index),
|
|
517
|
-
subcalls: Number(row.trace_subcalls),
|
|
518
|
-
}
|
|
519
|
-
: undefined,
|
|
520
|
-
transactionReceipt: hasTransactionReceipt
|
|
521
|
-
? {
|
|
522
|
-
contractAddress: row.txr_contractAddress
|
|
523
|
-
? checksumAddress(row.txr_contractAddress)
|
|
524
|
-
: null,
|
|
525
|
-
cumulativeGasUsed: BigInt(row.txr_cumulativeGasUsed),
|
|
526
|
-
effectiveGasPrice: BigInt(row.txr_effectiveGasPrice),
|
|
527
|
-
from: checksumAddress(row.txr_from),
|
|
528
|
-
gasUsed: BigInt(row.txr_gasUsed),
|
|
529
|
-
logsBloom: row.txr_logsBloom,
|
|
530
|
-
status: row.txr_status === "0x1"
|
|
531
|
-
? "success"
|
|
532
|
-
: row.txr_status === "0x0"
|
|
533
|
-
? "reverted"
|
|
534
|
-
: row.txr_status,
|
|
535
|
-
to: row.txr_to ? checksumAddress(row.txr_to) : null,
|
|
536
|
-
type: row.txr_type === "0x0"
|
|
537
|
-
? "legacy"
|
|
538
|
-
: row.txr_type === "0x1"
|
|
539
|
-
? "eip2930"
|
|
540
|
-
: row.tx_type === "0x2"
|
|
541
|
-
? "eip1559"
|
|
542
|
-
: row.tx_type === "0x7e"
|
|
543
|
-
? "deposit"
|
|
544
|
-
: row.tx_type,
|
|
545
|
-
}
|
|
546
|
-
: undefined,
|
|
547
|
-
};
|
|
548
|
-
});
|
|
549
|
-
let cursor;
|
|
550
|
-
if (events.length !== limit) {
|
|
551
|
-
cursor = to;
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
cursor = events[events.length - 1].checkpoint;
|
|
555
|
-
}
|
|
556
|
-
return { events, cursor };
|
|
557
|
-
}),
|
|
558
|
-
insertRpcRequestResult: async ({ request, blockNumber, chainId, result }) => database.wrap({ method: "insertRpcRequestResult", includeTraceLogs: true }, async () => {
|
|
559
|
-
await database.qb.sync
|
|
560
|
-
.insertInto("rpc_request_results")
|
|
561
|
-
.values({
|
|
562
|
-
request,
|
|
563
|
-
block_number: blockNumber,
|
|
564
|
-
chain_id: chainId,
|
|
565
|
-
result,
|
|
566
|
-
})
|
|
567
|
-
.onConflict((oc) => oc.columns(["request_hash", "chain_id"]).doUpdateSet({ result }))
|
|
568
|
-
.execute();
|
|
569
|
-
}),
|
|
570
|
-
getRpcRequestResult: async ({ request, chainId }) => database.wrap({ method: "getRpcRequestResult", includeTraceLogs: true }, async () => {
|
|
571
|
-
const result = await database.qb.sync
|
|
572
|
-
.selectFrom("rpc_request_results")
|
|
573
|
-
.select("result")
|
|
574
|
-
.where("request_hash", "=", ksql `MD5(${request})`)
|
|
575
|
-
.where("chain_id", "=", chainId)
|
|
576
|
-
.executeTakeFirst();
|
|
577
|
-
return result?.result;
|
|
578
|
-
}),
|
|
579
|
-
pruneRpcRequestResult: async ({ blocks, chainId }) => database.wrap({ method: "pruneRpcRequestResult", includeTraceLogs: true }, async () => {
|
|
580
|
-
if (blocks.length === 0)
|
|
581
|
-
return;
|
|
582
|
-
const numbers = blocks.map(({ number }) => hexToBigInt(number).toString());
|
|
583
|
-
await database.qb.sync
|
|
584
|
-
.deleteFrom("rpc_request_results")
|
|
585
|
-
.where("chain_id", "=", chainId)
|
|
586
|
-
.where("block_number", "in", numbers)
|
|
587
|
-
.execute();
|
|
588
|
-
}),
|
|
589
|
-
pruneByChain: async ({ chainId }) => database.wrap({ method: "pruneByChain", includeTraceLogs: true }, () => database.qb.sync.transaction().execute(async (tx) => {
|
|
590
|
-
await tx.deleteFrom("logs").where("chainId", "=", chainId).execute();
|
|
591
|
-
await tx.deleteFrom("blocks").where("chainId", "=", chainId).execute();
|
|
592
|
-
await tx
|
|
593
|
-
.deleteFrom("rpc_request_results")
|
|
594
|
-
.where("chain_id", "=", chainId)
|
|
595
|
-
.execute();
|
|
596
|
-
await tx.deleteFrom("traces").where("chainId", "=", chainId).execute();
|
|
597
|
-
await tx
|
|
598
|
-
.deleteFrom("transactions")
|
|
599
|
-
.where("chainId", "=", chainId)
|
|
600
|
-
.execute();
|
|
601
|
-
await tx
|
|
602
|
-
.deleteFrom("transactionReceipts")
|
|
603
|
-
.where("chainId", "=", chainId)
|
|
604
|
-
.execute();
|
|
605
|
-
})),
|
|
606
|
-
});
|
|
607
|
-
const addressSQL = (qb, db, address, column) => {
|
|
608
|
-
if (typeof address === "string")
|
|
609
|
-
return qb.where(column, "=", address);
|
|
610
|
-
if (isAddressFactory(address)) {
|
|
611
|
-
return qb.where(column, "in", db.selectFrom("logs").$call((qb) => logFactorySQL(qb, address)));
|
|
612
|
-
}
|
|
613
|
-
if (Array.isArray(address))
|
|
614
|
-
return qb.where(column, "in", address);
|
|
615
|
-
return qb;
|
|
616
|
-
};
|
|
617
|
-
const logSQL = (filter, db, index) => db
|
|
618
|
-
.selectFrom("logs")
|
|
619
|
-
.select([
|
|
620
|
-
ksql.raw(`'${index}'`).as("filterIndex"),
|
|
621
|
-
"checkpoint",
|
|
622
|
-
"chainId",
|
|
623
|
-
"blockHash",
|
|
624
|
-
"transactionHash",
|
|
625
|
-
"id as logId",
|
|
626
|
-
ksql `null`.as("traceId"),
|
|
627
|
-
])
|
|
628
|
-
.where("chainId", "=", filter.chainId)
|
|
629
|
-
.$call((qb) => {
|
|
630
|
-
for (const idx of [0, 1, 2, 3]) {
|
|
631
|
-
// If it's an array of length 1, collapse it.
|
|
632
|
-
const raw = filter[`topic${idx}`] ?? null;
|
|
633
|
-
if (raw === null)
|
|
634
|
-
continue;
|
|
635
|
-
const topic = Array.isArray(raw) && raw.length === 1 ? raw[0] : raw;
|
|
636
|
-
if (Array.isArray(topic)) {
|
|
637
|
-
qb = qb.where((eb) => eb.or(topic.map((t) => eb(`logs.topic${idx}`, "=", t))));
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
qb = qb.where(`logs.topic${idx}`, "=", topic);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
return qb;
|
|
644
|
-
})
|
|
645
|
-
.$call((qb) => addressSQL(qb, db, filter.address, "address"))
|
|
646
|
-
.$if(filter.fromBlock !== undefined, (qb) => qb.where("blockNumber", ">=", filter.fromBlock.toString()))
|
|
647
|
-
.$if(filter.toBlock !== undefined, (qb) => qb.where("blockNumber", "<=", filter.toBlock.toString()));
|
|
648
|
-
const blockSQL = (filter, db, index) => db
|
|
649
|
-
.selectFrom("blocks")
|
|
650
|
-
.select([
|
|
651
|
-
ksql.raw(`'${index}'`).as("filterIndex"),
|
|
652
|
-
"checkpoint",
|
|
653
|
-
"chainId",
|
|
654
|
-
"hash as blockHash",
|
|
655
|
-
ksql `null`.as("transactionHash"),
|
|
656
|
-
ksql `null`.as("logId"),
|
|
657
|
-
ksql `null`.as("traceId"),
|
|
658
|
-
])
|
|
659
|
-
.where("chainId", "=", filter.chainId)
|
|
660
|
-
.$if(filter !== undefined && filter.interval !== undefined, (qb) => qb.where(ksql `(number - ${filter.offset}) % ${filter.interval} = 0`))
|
|
661
|
-
.$if(filter.fromBlock !== undefined, (qb) => qb.where("number", ">=", filter.fromBlock.toString()))
|
|
662
|
-
.$if(filter.toBlock !== undefined, (qb) => qb.where("number", "<=", filter.toBlock.toString()));
|
|
663
|
-
const transactionSQL = (filter, db, index) => db
|
|
664
|
-
.selectFrom("transactions")
|
|
665
|
-
.select([
|
|
666
|
-
ksql.raw(`'${index}'`).as("filterIndex"),
|
|
667
|
-
"checkpoint",
|
|
668
|
-
"chainId",
|
|
669
|
-
"blockHash",
|
|
670
|
-
"hash as transactionHash",
|
|
671
|
-
ksql `null`.as("logId"),
|
|
672
|
-
ksql `null`.as("traceId"),
|
|
673
|
-
])
|
|
674
|
-
.where("chainId", "=", filter.chainId)
|
|
675
|
-
.$call((qb) => addressSQL(qb, db, filter.fromAddress, "from"))
|
|
676
|
-
.$call((qb) => addressSQL(qb, db, filter.toAddress, "to"))
|
|
677
|
-
.$if(filter.includeReverted === false, (qb) => qb.where(db
|
|
678
|
-
.selectFrom("transactionReceipts")
|
|
679
|
-
.select("status")
|
|
680
|
-
.where("transactionReceipts.transactionHash", "=", ksql.ref("transactions.hash")), "=", "0x1"))
|
|
681
|
-
.$if(filter.fromBlock !== undefined, (qb) => qb.where("blockNumber", ">=", filter.fromBlock.toString()))
|
|
682
|
-
.$if(filter.toBlock !== undefined, (qb) => qb.where("blockNumber", "<=", filter.toBlock.toString()));
|
|
683
|
-
const transferSQL = (filter, db, index) => db
|
|
684
|
-
.selectFrom("traces")
|
|
685
|
-
.select([
|
|
686
|
-
ksql.raw(`'${index}'`).as("filterIndex"),
|
|
687
|
-
"checkpoint",
|
|
688
|
-
"chainId",
|
|
689
|
-
"blockHash",
|
|
690
|
-
"transactionHash",
|
|
691
|
-
ksql `null`.as("logId"),
|
|
692
|
-
"id as traceId",
|
|
693
|
-
])
|
|
694
|
-
.where("chainId", "=", filter.chainId)
|
|
695
|
-
.$call((qb) => addressSQL(qb, db, filter.fromAddress, "from"))
|
|
696
|
-
.$call((qb) => addressSQL(qb, db, filter.toAddress, "to"))
|
|
697
|
-
.where("value", ">", "0")
|
|
698
|
-
.$if(filter.includeReverted === false, (qb) => qb.where("isReverted", "=", 0))
|
|
699
|
-
.$if(filter.fromBlock !== undefined, (qb) => qb.where("blockNumber", ">=", filter.fromBlock.toString()))
|
|
700
|
-
.$if(filter.toBlock !== undefined, (qb) => qb.where("blockNumber", "<=", filter.toBlock.toString()));
|
|
701
|
-
const traceSQL = (filter, db, index) => db
|
|
702
|
-
.selectFrom("traces")
|
|
703
|
-
.select([
|
|
704
|
-
ksql.raw(`'${index}'`).as("filterIndex"),
|
|
705
|
-
"checkpoint",
|
|
706
|
-
"chainId",
|
|
707
|
-
"blockHash",
|
|
708
|
-
"transactionHash",
|
|
709
|
-
ksql `null`.as("logId"),
|
|
710
|
-
"id as traceId",
|
|
711
|
-
])
|
|
712
|
-
.where("chainId", "=", filter.chainId)
|
|
713
|
-
.$call((qb) => addressSQL(qb, db, filter.fromAddress, "from"))
|
|
714
|
-
.$call((qb) => addressSQL(qb, db, filter.toAddress, "to"))
|
|
715
|
-
.$if(filter.includeReverted === false, (qb) => qb.where("isReverted", "=", 0))
|
|
716
|
-
.$if(filter.callType !== undefined, (qb) => qb.where("type", "=", filter.callType))
|
|
717
|
-
.$if(filter.functionSelector !== undefined, (qb) => {
|
|
718
|
-
if (Array.isArray(filter.functionSelector)) {
|
|
719
|
-
return qb.where("functionSelector", "in", filter.functionSelector);
|
|
720
|
-
}
|
|
721
|
-
else {
|
|
722
|
-
return qb.where("functionSelector", "=", filter.functionSelector);
|
|
723
|
-
}
|
|
724
|
-
})
|
|
725
|
-
.$if(filter.fromBlock !== undefined, (qb) => qb.where("blockNumber", ">=", filter.fromBlock.toString()))
|
|
726
|
-
.$if(filter.toBlock !== undefined, (qb) => qb.where("blockNumber", "<=", filter.toBlock.toString()));
|
|
727
|
-
//# sourceMappingURL=index.js.map
|