-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.ts
45 lines (40 loc) · 1.23 KB
/
client.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
import { ServiceBroker } from 'moleculer'
import {
BaseFetcherClient,
Blockchain,
FetcherClientI,
IndexableEntityType,
} from '@aleph-indexer/framework'
import { FetchAccountTransactionsBySlotRequestArgs } from './src/types.js'
import { normalizeAccount, normalizeEntityId } from '../../utils/normalize.js'
export default class SolanaFetcherClient
extends BaseFetcherClient
implements FetcherClientI
{
normalizeAccount(account: string): string {
return normalizeAccount(account)
}
normalizeEntityId(entity: IndexableEntityType, id: string): string {
return normalizeEntityId(entity, id)
}
async fetchAccountTransactionsBySlot(
args: Omit<FetchAccountTransactionsBySlotRequestArgs, 'blockchainId'>,
): Promise<void | AsyncIterable<string[]>> {
const account = this.normalizeAccount(args.account)
return this.invokeBlockchainMethod({
partitionKey: account,
method: 'fetchAccountTransactionsBySlot',
args: {
indexerId: this.broker.nodeID,
...args,
account,
},
})
}
}
export async function solanaFetcherClientFactory(
blockchainId: Blockchain,
broker: ServiceBroker,
): Promise<FetcherClientI> {
return new SolanaFetcherClient(blockchainId, broker)
}