/
types.ts
51 lines (47 loc) · 1.49 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
import { Diff } from 'deep-diff'
import { AmmanAccountProvider, AmmanAccountRendererMap } from '../types'
/** The version of amman, used by amman-explorer to detect amman compatibility */
const { version } = require('../../package.json')
export const AMMAN_VERSION: [number, number, number] = version
.split('.')
.map((v: string) => parseInt(v)) as [number, number, number]
/**
* The Default Amman Relay Configuration
*
* @category config
*/
export const DEFAULT_RELAY_CONFIG: RelayConfig = {
enabled: process.env.CI == null,
killRunningRelay: true,
accountProviders: {},
accountRenderers: new Map(),
}
/**
* Configures the Amman Relay
*
* @property enabled if true an amman-explorer relay is launched alongside the
* validator
* @property killRunningRelay if true an existing running relays are killed at
* start
* @property accountProviders a map of account providers which the relay uses
* to deserialize account data
* @property accountRenderers a map of account providers which the relay uses
* to custom render account data
*
* @category config
*/
export type RelayConfig = {
enabled: boolean
killRunningRelay: boolean
accountProviders: Record<string, AmmanAccountProvider>
accountRenderers: AmmanAccountRendererMap
}
export type AccountDiff = Array<Diff<Record<string, any>, Record<string, any>>>
export type RelayAccountState = {
account: Record<string, any>
accountDiff?: AccountDiff
slot: number
rendered?: string
renderedDiff?: Diff.Change[]
timestamp: number
}