@hugomrdias/foxer 0.1.9 → 0.1.11
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 +16 -0
- package/README.md +71 -1
- package/dist/config/env.d.ts +1 -1
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +2 -2
- package/dist/config/env.js.map +1 -1
- package/dist/db/actions/blocks.d.ts +9 -6
- package/dist/db/actions/blocks.d.ts.map +1 -1
- package/dist/db/actions/blocks.js +39 -43
- package/dist/db/actions/blocks.js.map +1 -1
- package/dist/db/client.d.ts +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +5 -1
- package/dist/db/client.js.map +1 -1
- package/dist/db/column-types.d.ts +2 -2
- package/dist/db/column-types.d.ts.map +1 -1
- package/dist/db/column-types.js +11 -3
- package/dist/db/column-types.js.map +1 -1
- package/dist/db/schema/blocks.d.ts +16 -16
- package/dist/db/schema/index.d.ts +44 -44
- package/dist/db/schema/transactions.d.ts +6 -6
- package/dist/db/schema/transactions.d.ts.map +1 -1
- package/dist/db/schema/transactions.js +3 -1
- package/dist/db/schema/transactions.js.map +1 -1
- package/dist/hooks/registry.d.ts +3 -3
- package/dist/hooks/registry.d.ts.map +1 -1
- package/dist/indexer/backfill.d.ts.map +1 -1
- package/dist/indexer/backfill.js +19 -12
- package/dist/indexer/backfill.js.map +1 -1
- package/dist/indexer/process-block.d.ts +4 -4
- package/dist/indexer/process-block.d.ts.map +1 -1
- package/dist/indexer/process-block.js +4 -29
- package/dist/indexer/process-block.js.map +1 -1
- package/dist/indexer/queue-block.d.ts.map +1 -1
- package/dist/indexer/queue-block.js +19 -1
- package/dist/indexer/queue-block.js.map +1 -1
- package/dist/indexer/reorg.d.ts +2 -2
- package/dist/indexer/reorg.d.ts.map +1 -1
- package/dist/rpc/get-logs.js +1 -1
- package/dist/rpc/get-logs.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -9
- package/src/config/env.ts +2 -2
- package/src/db/actions/blocks.ts +51 -51
- package/src/db/client.ts +5 -1
- package/src/db/column-types.ts +17 -6
- package/src/db/schema/transactions.ts +3 -1
- package/src/hooks/registry.ts +3 -3
- package/src/indexer/backfill.ts +28 -10
- package/src/indexer/process-block.ts +10 -39
- package/src/indexer/queue-block.ts +24 -1
- package/src/indexer/reorg.ts +2 -2
- package/src/rpc/get-logs.ts +1 -1
- package/src/types.ts +2 -0
|
@@ -5,6 +5,8 @@ import { filterContracts, type InternalConfig } from '../config/config.ts'
|
|
|
5
5
|
import type { Database } from '../db/client.ts'
|
|
6
6
|
import type { relations, schema } from '../db/schema/index.ts'
|
|
7
7
|
import type { HookRegistry } from '../hooks/registry.ts'
|
|
8
|
+
import { safeGetBlock } from '../rpc/get-block.ts'
|
|
9
|
+
import type { EncodedBlock, EncodedTransaction } from '../types.ts'
|
|
8
10
|
import { startClock } from '../utils/timer.ts'
|
|
9
11
|
import { processBlock } from './process-block.ts'
|
|
10
12
|
|
|
@@ -34,15 +36,36 @@ export async function queueBlock(args: QueueBlockArgs): Promise<void> {
|
|
|
34
36
|
const endClock = startClock()
|
|
35
37
|
try {
|
|
36
38
|
const contracts = filterContracts(config, blockNumber, blockNumber)
|
|
39
|
+
|
|
40
|
+
const [blockResult, logsResult] = await Promise.all([
|
|
41
|
+
safeGetBlock({ client, blockNumber, db }),
|
|
42
|
+
client.getLogs({
|
|
43
|
+
address: contracts.addresses,
|
|
44
|
+
events: contracts.eventAbis,
|
|
45
|
+
fromBlock: blockNumber,
|
|
46
|
+
toBlock: blockNumber,
|
|
47
|
+
}),
|
|
48
|
+
])
|
|
49
|
+
|
|
50
|
+
const { transactions, ..._block } = blockResult
|
|
51
|
+
const block: EncodedBlock = _block
|
|
52
|
+
const transactionsMap = new Map<`0x${string}`, EncodedTransaction>()
|
|
53
|
+
|
|
54
|
+
for (const tx of transactions) {
|
|
55
|
+
transactionsMap.set(tx.hash, tx)
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
const result = await processBlock({
|
|
38
59
|
logger,
|
|
39
60
|
config,
|
|
40
61
|
db,
|
|
41
62
|
client,
|
|
42
63
|
registry,
|
|
43
|
-
blockNumber,
|
|
44
64
|
type: 'live',
|
|
45
65
|
contracts,
|
|
66
|
+
block,
|
|
67
|
+
transactionsMap,
|
|
68
|
+
logs: logsResult,
|
|
46
69
|
})
|
|
47
70
|
|
|
48
71
|
if (result.status === 'reorg') {
|
package/src/indexer/reorg.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PublicClient } from 'viem'
|
|
|
3
3
|
import { deleteBlocksFrom } from '../db/actions/blocks.ts'
|
|
4
4
|
import type { Database } from '../db/client.ts'
|
|
5
5
|
import { safeGetBlock } from '../rpc/get-block.ts'
|
|
6
|
-
import type {
|
|
6
|
+
import type { EncodedBlock } from '../types'
|
|
7
7
|
import { hashEquals } from '../utils/hash.ts'
|
|
8
8
|
import type { Logger } from '../utils/logger.ts'
|
|
9
9
|
import { startClock } from '../utils/timer.ts'
|
|
@@ -16,7 +16,7 @@ export async function ensureParentContinuity(args: {
|
|
|
16
16
|
logger: Logger
|
|
17
17
|
db: Database
|
|
18
18
|
client: PublicClient
|
|
19
|
-
block:
|
|
19
|
+
block: EncodedBlock
|
|
20
20
|
}): Promise<bigint | null> {
|
|
21
21
|
const { logger, db, client, block } = args
|
|
22
22
|
if (block.number === 0n) return null
|
package/src/rpc/get-logs.ts
CHANGED