-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.ts
68 lines (61 loc) · 2.17 KB
/
factory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* eslint-disable prettier/prettier */
import { Utils } from '@aleph-indexer/core'
import {
Blockchain,
BlockchainIndexerI,
createEntityIndexerStateDAL,
createEntityRequestDAL,
createEntityRequestIncomingEntityDAL,
createEntityRequestPendingEntityDAL,
createEntityRequestResponseDAL,
FetcherMsClient,
IndexableEntityType,
IndexerMsClient,
IndexerWorkerDomainI,
ParserMsClient,
BaseEntityIndexer
} from '@aleph-indexer/framework'
import { SolanaParsedTransaction } from '../../types.js'
import { SolanaIndexer } from './main.js'
import { SolanaIndexerTransactionFetcher } from './src/transactionFetcher.js'
export async function solanaIndexerFactory(
basePath: string,
domain: IndexerWorkerDomainI,
indexerMsClient: IndexerMsClient,
fetcherMsClient: FetcherMsClient,
parserMsClient: ParserMsClient,
): Promise<BlockchainIndexerI> {
await Utils.ensurePath(basePath)
// DALs
const transactionRequestDAL = createEntityRequestDAL(basePath, IndexableEntityType.Transaction)
const transactionRequestIncomingTransactionDAL = createEntityRequestIncomingEntityDAL<SolanaParsedTransaction>(basePath, IndexableEntityType.Transaction)
const transactionRequestPendingSignatureDAL = createEntityRequestPendingEntityDAL(basePath, IndexableEntityType.Transaction)
const transactionRequestResponseDAL = createEntityRequestResponseDAL(basePath, IndexableEntityType.Transaction)
const transactionIndexerStateDAL = createEntityIndexerStateDAL(basePath, IndexableEntityType.Transaction)
const transactionFetcher = new SolanaIndexerTransactionFetcher(
Blockchain.Solana,
fetcherMsClient,
transactionRequestDAL,
transactionRequestIncomingTransactionDAL,
transactionRequestPendingSignatureDAL,
transactionRequestResponseDAL,
)
const transactionFetcherMain = new BaseEntityIndexer(
IndexableEntityType.Transaction,
Blockchain.Solana,
domain,
indexerMsClient,
fetcherMsClient,
parserMsClient,
transactionIndexerStateDAL,
transactionFetcher,
)
const entityIndexers = {
[IndexableEntityType.Transaction]: transactionFetcherMain
}
return new SolanaIndexer(
indexerMsClient,
domain,
entityIndexers,
)
}