-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.ts
48 lines (44 loc) · 1.42 KB
/
main.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
import './env'
import { parseArgs } from "util"
import { Indexer } from "./src/indexer"
import { DEPHY_ID_PROGRAM_ADDRESS } from '@dephy-io/dephy-id-program-client'
try {
const { values: config } = parseArgs({
options: {
rpcUrl: {
type: 'string',
short: 'r',
default: 'http://127.0.0.1:8899',
},
pubSubUrl: {
type: 'string',
short: 's',
default: 'ws://127.0.0.1:8900',
},
databaseUrl: {
type: 'string',
short: 'd'
},
programId: {
type: 'string',
short: 'p',
default: DEPHY_ID_PROGRAM_ADDRESS
},
pluginsDir: {
type: 'string',
default: './src/plugins'
}
}
})
let indexer = new Indexer(config)
await indexer.ensureConnected()
console.log('Connected')
await indexer.run(config.programId!, 'confirmed')
// [ABORTED] Reaching this line means the subscription was aborted — i.e. unsubscribed.
} catch (e) {
// [FAILED] Reaching this line means the subscription went down.
// Retry it, then recover from potential missed messages.
console.error(e)
} finally {
// [ABORTED or FAILED] Whether the subscription failed or was aborted, you can run cleanup code here.
}