-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
113 lines (96 loc) · 2.94 KB
/
types.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { ConfirmedSignatureInfo } from '@solana/web3.js'
import {
AccountStateStorage,
AccountEntityHistoryState,
BaseFetcherJobRunnerOptions,
BaseFetcherPaginationResponse,
BlockchainRequestArgs,
FetcherAccountPartitionRequestArgs,
} from '@aleph-indexer/framework'
import { SolanaErrorFetching } from '../../../sdk/index.js'
export type SolanaAccountTransactionHistoryPaginationCursor = {
signature?: string
slot?: number
timestamp?: number
}
export type SolanaSignatureInfo = ConfirmedSignatureInfo
export type SolanaSignature = Omit<
ConfirmedSignatureInfo,
'memo' | 'confirmationStatus'
> & {
id: string
timestamp: number
accountSlotIndex: Record<string, number>
accounts: string[]
}
// --------------------------
export type SolanaTransactionHistoryFetcherJobRunnerOptions = Omit<
BaseFetcherJobRunnerOptions<SolanaAccountTransactionHistoryPaginationCursor>,
'handleFetch' | 'updateCursor' | 'interval'
> & {
interval?: number
iterationFetchLimit?: number
}
export type SolanaTransactionHistoryFetcherForwardJobRunnerOptions =
SolanaTransactionHistoryFetcherJobRunnerOptions & {
ratio?: number
ratioThreshold?: number
}
export type SolanaTransactionHistoryFetcherBackwardJobRunnerOptions =
SolanaTransactionHistoryFetcherJobRunnerOptions & {
fetchUntil?: string
}
export type SolanaTransactionHistoryFetcherOptions = {
address: string
forward?: boolean | SolanaTransactionHistoryFetcherForwardJobRunnerOptions
backward?: boolean | SolanaTransactionHistoryFetcherBackwardJobRunnerOptions
errorFetching?: SolanaErrorFetching
indexSignatures(
signatures: SolanaSignature[],
goingForward: boolean,
): Promise<void>
}
export type SolanaTransactionHistoryPaginationResponse =
BaseFetcherPaginationResponse<
SolanaSignatureInfo,
SolanaAccountTransactionHistoryPaginationCursor
>
// Account State
export type SolanaAccountStateFetcherOptions = {
account: string
subscribeChanges?: boolean
}
export type SolanaAccountState = {
account: string
executable: boolean
owner: string
lamports: number
data: any
rentEpoch?: number
}
export type SolanaAccountStateStorage = AccountStateStorage<SolanaAccountState>
// -------------------------------------------------------------------
export type SolanaAccountEntityHistoryState =
AccountEntityHistoryState<SolanaAccountTransactionHistoryPaginationCursor> & {
firstSlot?: number
lastSlot?: number
}
export type AddAccountStateRequestArgs = BlockchainRequestArgs &
FetcherAccountPartitionRequestArgs & {
/**
* Whether to subscribe to future account updates.
*/
subscribeChanges: boolean
}
/**
* Account and slot range to get the signatures for.
*/
export type FetchAccountTransactionsBySlotRequestArgs = BlockchainRequestArgs &
FetcherAccountPartitionRequestArgs & {
startSlot: number
endSlot: number
/**
* Indexer instance id, the result will be delivered here
*/
indexerId?: string
}