-
Notifications
You must be signed in to change notification settings - Fork 0
/
accountTransactionHistory.ts
47 lines (42 loc) · 1.4 KB
/
accountTransactionHistory.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
import { EntityStorage } from '@aleph-indexer/core'
import {
AccountEntityHistoryDALKeys,
createAccountEntityHistoryDAL,
IndexableEntityType,
} from '@aleph-indexer/framework'
import { EthereumAccountTransactionHistoryStorageEntity } from '../../../../../types.js'
export type EthereumAccountTransactionHistoryEntity =
EthereumAccountTransactionHistoryStorageEntity
export type EthereumAccountTransactionHistoryStorage =
EntityStorage<EthereumAccountTransactionHistoryStorageEntity>
export enum EthereumAccountTransactionHistoryDALIndex {
AccountTimestampIndex = 'account_timestamp_index',
AccountHeightIndex = 'account_height_index',
}
const { accountKey, indexKey } = AccountEntityHistoryDALKeys
const heightKey = {
get: (e: EthereumAccountTransactionHistoryEntity) => e.height,
// @note: up to 10**9 [9 digits] enough for 300 years
length: 8,
}
/**
* Creates a new signature storage for the ethereum client.
* @param path Path to the database.
*/
export function createEthereumAccountTransactionHistoryDAL(
path: string,
): EthereumAccountTransactionHistoryStorage {
return createAccountEntityHistoryDAL<EthereumAccountTransactionHistoryEntity>(
path,
IndexableEntityType.Transaction,
false,
{
indexes: [
{
name: EthereumAccountTransactionHistoryDALIndex.AccountHeightIndex,
key: [accountKey, heightKey, indexKey],
},
],
},
)
}