@my-packages-changeit/abstract-extractor 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +225 -0
- package/README.md +24 -0
- package/dist/abstractExtractor.d.ts +59 -0
- package/dist/abstractExtractor.d.ts.map +1 -0
- package/dist/abstractExtractor.js +22 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +4 -0
- package/dist/ergo/database/actions/abstractErgoAction.d.ts +91 -0
- package/dist/ergo/database/actions/abstractErgoAction.d.ts.map +1 -0
- package/dist/ergo/database/actions/abstractErgoAction.js +180 -0
- package/dist/ergo/database/actions/abstractErgoBoxAction.d.ts +31 -0
- package/dist/ergo/database/actions/abstractErgoBoxAction.d.ts.map +1 -0
- package/dist/ergo/database/actions/abstractErgoBoxAction.js +70 -0
- package/dist/ergo/database/entities/abstractErgoBoxEntity.d.ts +18 -0
- package/dist/ergo/database/entities/abstractErgoBoxEntity.d.ts.map +1 -0
- package/dist/ergo/database/entities/abstractErgoBoxEntity.js +36 -0
- package/dist/ergo/database/entities/abstractErgoEntity.d.ts +26 -0
- package/dist/ergo/database/entities/abstractErgoEntity.d.ts.map +1 -0
- package/dist/ergo/database/entities/abstractErgoEntity.js +64 -0
- package/dist/ergo/database/index.d.ts +5 -0
- package/dist/ergo/database/index.d.ts.map +1 -0
- package/dist/ergo/database/index.js +5 -0
- package/dist/ergo/extractors/abstractErgoBoxExtractor.d.ts +67 -0
- package/dist/ergo/extractors/abstractErgoBoxExtractor.d.ts.map +1 -0
- package/dist/ergo/extractors/abstractErgoBoxExtractor.js +106 -0
- package/dist/ergo/extractors/abstractErgoExtractor.d.ts +61 -0
- package/dist/ergo/extractors/abstractErgoExtractor.d.ts.map +1 -0
- package/dist/ergo/extractors/abstractErgoExtractor.js +99 -0
- package/dist/ergo/extractors/abstractErgoTxExtractor.d.ts +54 -0
- package/dist/ergo/extractors/abstractErgoTxExtractor.d.ts.map +1 -0
- package/dist/ergo/extractors/abstractErgoTxExtractor.js +76 -0
- package/dist/ergo/extractors/index.d.ts +4 -0
- package/dist/ergo/extractors/index.d.ts.map +1 -0
- package/dist/ergo/extractors/index.js +4 -0
- package/dist/ergo/index.d.ts +8 -0
- package/dist/ergo/index.d.ts.map +1 -0
- package/dist/ergo/index.js +8 -0
- package/dist/ergo/initializers/constants.d.ts +4 -0
- package/dist/ergo/initializers/constants.d.ts.map +1 -0
- package/dist/ergo/initializers/constants.js +4 -0
- package/dist/ergo/initializers/ergoBoxInitializer.d.ts +36 -0
- package/dist/ergo/initializers/ergoBoxInitializer.d.ts.map +1 -0
- package/dist/ergo/initializers/ergoBoxInitializer.js +84 -0
- package/dist/ergo/initializers/ergoInitializer.d.ts +39 -0
- package/dist/ergo/initializers/ergoInitializer.d.ts.map +1 -0
- package/dist/ergo/initializers/ergoInitializer.js +80 -0
- package/dist/ergo/initializers/index.d.ts +4 -0
- package/dist/ergo/initializers/index.d.ts.map +1 -0
- package/dist/ergo/initializers/index.js +4 -0
- package/dist/ergo/initializers/strategies/explorerInitializationStrategy.d.ts +59 -0
- package/dist/ergo/initializers/strategies/explorerInitializationStrategy.d.ts.map +1 -0
- package/dist/ergo/initializers/strategies/explorerInitializationStrategy.js +161 -0
- package/dist/ergo/initializers/strategies/index.d.ts +4 -0
- package/dist/ergo/initializers/strategies/index.d.ts.map +1 -0
- package/dist/ergo/initializers/strategies/index.js +4 -0
- package/dist/ergo/initializers/strategies/nodeInitializationStrategy.d.ts +30 -0
- package/dist/ergo/initializers/strategies/nodeInitializationStrategy.d.ts.map +1 -0
- package/dist/ergo/initializers/strategies/nodeInitializationStrategy.js +78 -0
- package/dist/ergo/initializers/strategies/workerManager.d.ts +79 -0
- package/dist/ergo/initializers/strategies/workerManager.d.ts.map +1 -0
- package/dist/ergo/initializers/strategies/workerManager.js +182 -0
- package/dist/ergo/interfaces.d.ts +63 -0
- package/dist/ergo/interfaces.d.ts.map +1 -0
- package/dist/ergo/interfaces.js +8 -0
- package/dist/ergo/networks/explorerNetwork.d.ts +52 -0
- package/dist/ergo/networks/explorerNetwork.d.ts.map +1 -0
- package/dist/ergo/networks/explorerNetwork.js +132 -0
- package/dist/ergo/networks/index.d.ts +3 -0
- package/dist/ergo/networks/index.d.ts.map +1 -0
- package/dist/ergo/networks/index.js +3 -0
- package/dist/ergo/networks/nodeNetwork.d.ts +34 -0
- package/dist/ergo/networks/nodeNetwork.d.ts.map +1 -0
- package/dist/ergo/networks/nodeNetwork.js +77 -0
- package/dist/ergo/utils.d.ts +23 -0
- package/dist/ergo/utils.d.ts.map +1 -0
- package/dist/ergo/utils.js +49 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# @rosen-bridge/abstract-extractor
|
|
2
|
+
|
|
3
|
+
## 3.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Replace `await-semaphore` with `@rosen-bridge/semaphore` package
|
|
8
|
+
|
|
9
|
+
## 3.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Update dependencies
|
|
14
|
+
- @rosen-clients/ergo-explorer@2.1.3
|
|
15
|
+
- @rosen-clients/ergo-node@3.1.3
|
|
16
|
+
|
|
17
|
+
## 3.2.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Make `fromHeight` and `toHeight` required in `hasEventInHeightRange`.
|
|
22
|
+
|
|
23
|
+
## 3.2.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- Add `hasEventInHeightRange` function to `AbstractExtractor` which is utilized by the fast-forward feature in scanners
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Update dependencies
|
|
32
|
+
- @rosen-bridge/scanner-interfaces@1.0.0
|
|
33
|
+
- uuid@11.1.1
|
|
34
|
+
|
|
35
|
+
## 3.1.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Update dependencies
|
|
40
|
+
- @rosen-bridge/extended-typeorm@1.1.0
|
|
41
|
+
|
|
42
|
+
## 3.1.1
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Update dependencies
|
|
47
|
+
- @rosen-clients/ergo-explorer@2.1.2
|
|
48
|
+
- @rosen-clients/ergo-node@3.1.2
|
|
49
|
+
|
|
50
|
+
## 3.1.0
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- Add block parameter to the AbstractErgoTxExtractor.extractTxData method
|
|
55
|
+
|
|
56
|
+
## 3.0.1
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Add `spendingProof` to input box interface
|
|
61
|
+
- Update dependencies
|
|
62
|
+
- @rosen-bridge/scanner-interfaces@0.2.2
|
|
63
|
+
|
|
64
|
+
## 3.0.0
|
|
65
|
+
|
|
66
|
+
### Major Changes
|
|
67
|
+
|
|
68
|
+
- Update AbstractExtractor interface; use `BlockInfo` in `processTransactions` and rename `initializeBoxes` to `initializeData`
|
|
69
|
+
- Update abstract entities and actions to have a new abstraction level, seperating box-based logic from general extraction
|
|
70
|
+
- Update `AbstractErgoExtractor` to use a tx-based data extraction method and add `AbstractErgoBoxExtractor` for box-based data extraction
|
|
71
|
+
- Update AbstractExtractor interface; add `createUsedBlocksQuery` method that returns the query for used blocks
|
|
72
|
+
- Update abstract database entity to be general; rename `boxId` columnt to `identifier`
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Update dependencies
|
|
77
|
+
- @rosen-bridge/abstract-logger@4.0.0
|
|
78
|
+
|
|
79
|
+
## 2.1.2
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Fix package-lock and move typescript and types/node into root
|
|
84
|
+
- Update eslint and plugins:
|
|
85
|
+
- Apply new rules such as sort imports and file name
|
|
86
|
+
- Update dependencies
|
|
87
|
+
- @rosen-bridge/scanner-interfaces@0.2.1
|
|
88
|
+
- @rosen-bridge/abstract-scanner@0.2.1
|
|
89
|
+
- @rosen-bridge/extended-typeorm@1.0.1
|
|
90
|
+
- @rosen-clients/rate-limited-axios@1.1.0
|
|
91
|
+
- @rosen-bridge/rosen-extractor@10.1.1
|
|
92
|
+
- @rosen-bridge/tokens@4.0.1
|
|
93
|
+
- @rosen-bridge/abstract-logger@3.0.1
|
|
94
|
+
- @rosen-bridge/json-bigint@1.1.0
|
|
95
|
+
- @rosen-clients/ergo-explorer@2.1.0
|
|
96
|
+
- @rosen-clients/ergo-node@3.1.0
|
|
97
|
+
|
|
98
|
+
## 2.1.1
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Update dependencies
|
|
103
|
+
- @rosen-bridge/extended-typeorm@1.0.0
|
|
104
|
+
- @rosen-bridge/abstract-logger@3.0.0
|
|
105
|
+
- @rosen-bridge/json-bigint@1.0.0
|
|
106
|
+
- @rosen-clients/ergo-explorer@2.0.0
|
|
107
|
+
- @rosen-clients/ergo-node@3.0.0
|
|
108
|
+
|
|
109
|
+
## 2.1.0
|
|
110
|
+
|
|
111
|
+
### Minor Changes
|
|
112
|
+
|
|
113
|
+
- Upgrade to Node.js version 22.18.0
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Update dependencies
|
|
118
|
+
- @rosen-bridge/scanner-interfaces@0.2.0
|
|
119
|
+
|
|
120
|
+
## 2.0.3
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- Update package license to MIT
|
|
125
|
+
- Update dependencies
|
|
126
|
+
- @rosen-bridge/scanner-interfaces@0.1.1
|
|
127
|
+
|
|
128
|
+
## 2.0.2
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Update network clients and ethers and rateLimitedAxios packages
|
|
133
|
+
|
|
134
|
+
## 2.0.1
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- Use rate limiting methods using @rosen-bridge/rate-limited-axios to prevent overwhelming the endpoints
|
|
139
|
+
|
|
140
|
+
## 2.0.0
|
|
141
|
+
|
|
142
|
+
### Major Changes
|
|
143
|
+
|
|
144
|
+
- Unify and move shared interfaces and update all package dependencies
|
|
145
|
+
- Update extra information interfaces and extraction functions
|
|
146
|
+
|
|
147
|
+
## 1.0.2
|
|
148
|
+
|
|
149
|
+
### Patch Changes
|
|
150
|
+
|
|
151
|
+
- Add input box extension to network api interfaces
|
|
152
|
+
- Refactor query logic in abstract ergo extractor actions
|
|
153
|
+
|
|
154
|
+
## 1.0.1
|
|
155
|
+
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
158
|
+
- Update node version to 20
|
|
159
|
+
- Update logger package
|
|
160
|
+
|
|
161
|
+
## 1.0.0
|
|
162
|
+
|
|
163
|
+
### Major Changes
|
|
164
|
+
|
|
165
|
+
- Move database action shared logic to abstract class
|
|
166
|
+
- Add callback support to abstract ergo extractor and update abstract db action interface
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- Ensure initialization with the node is stateful and resilient to network issues
|
|
171
|
+
- Fix `processTransaction` to return false if data insertion encounters error
|
|
172
|
+
- Modify the initialization procedure to retry upon failure
|
|
173
|
+
|
|
174
|
+
## 0.3.1
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Remove unnecessary properties from abstract extracted data type
|
|
179
|
+
- Add extras field to store extra information for spending
|
|
180
|
+
|
|
181
|
+
## 0.3.0
|
|
182
|
+
|
|
183
|
+
### Minor Changes
|
|
184
|
+
|
|
185
|
+
- Add abstract extractor class that can be initialized using address transactions.
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Change processTransaction Block interface to use minimal information
|
|
190
|
+
|
|
191
|
+
## 0.2.0
|
|
192
|
+
|
|
193
|
+
### Minor Changes
|
|
194
|
+
|
|
195
|
+
- Add spendIndex to extracted data in initialization
|
|
196
|
+
|
|
197
|
+
## 0.1.5
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- fix storing duplicate boxes
|
|
202
|
+
|
|
203
|
+
## 0.1.4
|
|
204
|
+
|
|
205
|
+
### Patch Changes
|
|
206
|
+
|
|
207
|
+
- prevent to store multiple boxes on initialize
|
|
208
|
+
|
|
209
|
+
## 0.1.3
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- switch to using unspent boxes for initialization
|
|
214
|
+
|
|
215
|
+
## 0.1.2
|
|
216
|
+
|
|
217
|
+
### Patch Changes
|
|
218
|
+
|
|
219
|
+
- fix spend info extraction in initialize process
|
|
220
|
+
|
|
221
|
+
## 0.1.1
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- Export constants and AbstractNetwork interface
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# extractor
|
|
2
|
+
|
|
3
|
+
## Table of contents
|
|
4
|
+
|
|
5
|
+
- [Introduction](#introduction)
|
|
6
|
+
- [Installation](#installation)
|
|
7
|
+
|
|
8
|
+
## Introduction
|
|
9
|
+
|
|
10
|
+
Rosen Bridge extractor interfaces to work with scanner
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
npm:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm i @rosen-bridge/abstract-extractor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
yarn:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
yarn add @rosen-bridge/abstract-extractor
|
|
24
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ObjectLiteral, SelectQueryBuilder } from '@rosen-bridge/extended-typeorm';
|
|
2
|
+
import { BlockInfo } from '@rosen-bridge/scanner-interfaces';
|
|
3
|
+
export declare abstract class AbstractExtractor<TransactionType, ExtractorEntity extends ObjectLiteral> {
|
|
4
|
+
/**
|
|
5
|
+
* Process a list of transactions (or other blockchain data) in a block and store required information.
|
|
6
|
+
* This method is the core of the extraction process and should be implemented to handle
|
|
7
|
+
* the specific data extraction logic for your blockchain.
|
|
8
|
+
*
|
|
9
|
+
* @param txs - List of transactions or blockchain data structures in the block
|
|
10
|
+
* @param block - Block information containing metadata about the block
|
|
11
|
+
* @returns Promise<boolean> - true if the process completed successfully, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
abstract processTransactions: (txs: Array<TransactionType>, block: BlockInfo) => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Return a unique identifier for this extractor.
|
|
16
|
+
* This ID must be unique across all extractors in the system to prevent conflicts.
|
|
17
|
+
*
|
|
18
|
+
* @returns string - Unique extractor identifier
|
|
19
|
+
*/
|
|
20
|
+
abstract getId: () => string;
|
|
21
|
+
/**
|
|
22
|
+
* Fork (rollback) one block and remove all stored information for this block.
|
|
23
|
+
* This is essential for handling blockchain reorganizations where blocks
|
|
24
|
+
* need to be removed from the database.
|
|
25
|
+
*
|
|
26
|
+
* @param hash - Block hash to fork/remove
|
|
27
|
+
*/
|
|
28
|
+
abstract forkBlock: (hash: string) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Initialize extractor database with historical data created below the initial height.
|
|
31
|
+
* This method is called during extractor setup to populate the database with
|
|
32
|
+
* data that existed before the scanner started monitoring.
|
|
33
|
+
*
|
|
34
|
+
* @param initialBlock - The block from which to start scanning (initial height)
|
|
35
|
+
*/
|
|
36
|
+
abstract initializeData: (initialBlock: BlockInfo) => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* hasEventInHeightRange used by the scanner's fast-forward mechanism.
|
|
39
|
+
* During a large sync, instead of fetching and processing thousands of blocks one by one,
|
|
40
|
+
* the scanner checks this method. If an external API or node can confirm that *no relevant events*
|
|
41
|
+
* exist in the `[fromHeight, toHeight]` range, return `false`. The scanner will then skip fetching
|
|
42
|
+
* these blocks entirely, vastly improving sync speed.
|
|
43
|
+
* Returns `true`, forcing the scanner to safely process every single block sequentially.
|
|
44
|
+
*
|
|
45
|
+
* @param fromHeight - The starting block height of the chunk being evaluated.
|
|
46
|
+
* @param toHeight - The ending block height of the chunk.
|
|
47
|
+
* @returns {Promise<boolean>} `true` if events exist (or if unknown). `false` ONLY if it's guaranteed the range is empty.
|
|
48
|
+
*/
|
|
49
|
+
hasEventInHeightRange: (fromHeight: number, toHeight: number) => Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Create a query for used blocks associated with the given `extractorId`
|
|
52
|
+
* This method only builds the query and does not execute it
|
|
53
|
+
*
|
|
54
|
+
* @returns A TypeORM SelectQueryBuilder that selects used block values or
|
|
55
|
+
* `undefined` if the extractor has no associated entity
|
|
56
|
+
*/
|
|
57
|
+
abstract createUsedBlocksQuery: () => SelectQueryBuilder<ExtractorEntity> | undefined;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=abstractExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractExtractor.d.ts","sourceRoot":"","sources":["../lib/abstractExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,8BAAsB,iBAAiB,CACrC,eAAe,EACf,eAAe,SAAS,aAAa;IAErC;;;;;;;;OAQG;IACH,QAAQ,CAAC,mBAAmB,EAAE,CAC5B,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,EAC3B,KAAK,EAAE,SAAS,KACb,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC;IAE7B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,EAAE,CAAC,YAAY,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;;;;;;;;OAWG;IACI,qBAAqB,GAE1B,YAAY,MAAM,EAElB,UAAU,MAAM,KACf,OAAO,CAAC,OAAO,CAAC,CAEjB;IAEF;;;;;;OAMG;IACH,QAAQ,CAAC,qBAAqB,EAAE,MAC5B,kBAAkB,CAAC,eAAe,CAAC,GACnC,SAAS,CAAC;CACf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class AbstractExtractor {
|
|
2
|
+
/**
|
|
3
|
+
* hasEventInHeightRange used by the scanner's fast-forward mechanism.
|
|
4
|
+
* During a large sync, instead of fetching and processing thousands of blocks one by one,
|
|
5
|
+
* the scanner checks this method. If an external API or node can confirm that *no relevant events*
|
|
6
|
+
* exist in the `[fromHeight, toHeight]` range, return `false`. The scanner will then skip fetching
|
|
7
|
+
* these blocks entirely, vastly improving sync speed.
|
|
8
|
+
* Returns `true`, forcing the scanner to safely process every single block sequentially.
|
|
9
|
+
*
|
|
10
|
+
* @param fromHeight - The starting block height of the chunk being evaluated.
|
|
11
|
+
* @param toHeight - The ending block height of the chunk.
|
|
12
|
+
* @returns {Promise<boolean>} `true` if events exist (or if unknown). `false` ONLY if it's guaranteed the range is empty.
|
|
13
|
+
*/
|
|
14
|
+
hasEventInHeightRange = async (
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
+
fromHeight,
|
|
17
|
+
// eslint-disable-next-line @typesc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gZnJvbUhlaWdodDogbnVtYmVyLFxuICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBAdHlwZXNjcmlwdC1lc2xpbnQvbm8tdW51c2VkLXZhcnNcbiAgICB0b0hlaWdodDogbnVtYmVyLFxuICApOiBQcm9taXNlPGJvb2xlYW4+ID0+IHtcbiAgICByZXR1cm4gdHJ1ZTtcbiAgfTtcblxuICAvKipcbiAgICogQ3JlYXRlIGEgcXVlcnkgZm9yIHVzZWQgYmxvY2tzIGFzc29jaWF0ZWQgd2l0aCB0aGUgZ2l2ZW4gYGV4dHJhY3RvcklkYFxuICAgKiBUaGlzIG1ldGhvZCBvbmx5IGJ1aWxkcyB0aGUgcXVlcnkgYW5kIGRvZXMgbm90IGV4ZWN1dGUgaXRcbiAgICpcbiAgICogQHJldHVybnMgQSBUeXBlT1JNIFNlbGVjdFF1ZXJ5QnVpbGRlciB0aGF0IHNlbGVjdHMgdXNlZCBibG9jayB2YWx1ZXMgb3JcbiAgICogYHVuZGVmaW5lZGAgaWYgdGhlIGV4dHJhY3RvciBoYXMgbm8gYXNzb2NpYXRlZCBlbnRpdHlcbiAgICovXG4gIGFic3RyYWN0IGNyZWF0ZVVzZWRCbG9ja3NRdWVyeTogKCkgPT5cbiAgICB8IFNlbGVjdFF1ZXJ5QnVpbGRlcjxFeHRyYWN0b3JFbnRpdHk+XG4gICAgfCB1bmRlZmluZWQ7XG59XG4iXX0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,aAAa,MAAM,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const API_LIMIT = 100;
|
|
2
|
+
export const RETRIAL_COUNT = 10;
|
|
3
|
+
export const DB_CHUNK_SIZE = 100;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vbGliL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsTUFBTSxTQUFTLEdBQUcsR0FBRyxDQUFDO0FBQzdCLE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxFQUFFLENBQUM7QUFDaEMsTUFBTSxDQUFDLE1BQU0sYUFBYSxHQUFHLEdBQUcsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjb25zdCBBUElfTElNSVQgPSAxMDA7XG5leHBvcnQgY29uc3QgUkVUUklBTF9DT1VOVCA9IDEwO1xuZXhwb3J0IGNvbnN0IERCX0NIVU5LX1NJWkUgPSAxMDA7XG4iXX0=
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { AbstractLogger } from '@rosen-bridge/abstract-logger';
|
|
2
|
+
import { DataSource, EntityTarget, QueryRunner, Repository, SelectQueryBuilder } from '@rosen-bridge/extended-typeorm';
|
|
3
|
+
import { BlockInfo } from '@rosen-bridge/scanner-interfaces';
|
|
4
|
+
import { AbstractEntityData, EntityInfo } from '../../interfaces';
|
|
5
|
+
import { AbstractErgoEntity } from '../entities/abstractErgoEntity';
|
|
6
|
+
export declare abstract class AbstractErgoAction<ExtractedData extends AbstractEntityData, ExtractorEntity extends AbstractErgoEntity> {
|
|
7
|
+
protected readonly dataSource: DataSource;
|
|
8
|
+
protected readonly repo: EntityTarget<ExtractorEntity>;
|
|
9
|
+
protected readonly logger: AbstractLogger;
|
|
10
|
+
protected readonly repository: Repository<ExtractorEntity>;
|
|
11
|
+
constructor(dataSource: DataSource, repo: EntityTarget<ExtractorEntity>, logger?: AbstractLogger);
|
|
12
|
+
/**
|
|
13
|
+
* create the database entity from extracted data and block information
|
|
14
|
+
*/
|
|
15
|
+
protected abstract createEntity: (data: ExtractedData[], block: BlockInfo, extractor: string) => Array<Omit<ExtractorEntity, 'id'>>;
|
|
16
|
+
/**
|
|
17
|
+
* convert the database entity back to raw data
|
|
18
|
+
*/
|
|
19
|
+
protected abstract convertEntityToData: (entities: ExtractorEntity[]) => ExtractedData[];
|
|
20
|
+
/**
|
|
21
|
+
* insert entities extracted from a block to database
|
|
22
|
+
* @param queryRunner
|
|
23
|
+
* @param entitiesToInsert
|
|
24
|
+
* @param block
|
|
25
|
+
* @param extractor
|
|
26
|
+
*/
|
|
27
|
+
protected insertEntities: (queryRunner: QueryRunner, entitiesToInsert: Array<ExtractedData>, block: BlockInfo, extractor: string) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* update an entity in the database
|
|
30
|
+
* @param queryRunner
|
|
31
|
+
* @param updateEntity
|
|
32
|
+
* @param block
|
|
33
|
+
* @param extractor
|
|
34
|
+
*/
|
|
35
|
+
protected updateEntity: (queryRunner: QueryRunner, updatedEntity: ExtractedData, block: BlockInfo, extractor: string) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* delete all database records that were created from a specific block
|
|
38
|
+
* @param queryRunner
|
|
39
|
+
* @param extractor
|
|
40
|
+
* @param block
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
protected deleteBlockRecords: (queryRunner: QueryRunner, extractor: string, block: string) => Promise<ExtractedData[]>;
|
|
44
|
+
/**
|
|
45
|
+
* override this method to revert the updates made to entities when a block is deleted
|
|
46
|
+
* e.g., mark boxes as unspent, update related entities, etc.
|
|
47
|
+
* @param queryRunner
|
|
48
|
+
* @param extractor
|
|
49
|
+
* @param block
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
protected revertBlockUpdates: (queryRunner: QueryRunner, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
53
|
+
extractor: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
54
|
+
block: string) => Promise<ExtractorEntity[]>;
|
|
55
|
+
/**
|
|
56
|
+
* delete extracted data from a specific block
|
|
57
|
+
* if an entity is updated using the data in this block revert the update
|
|
58
|
+
* if an entity is created in this block remove it from database
|
|
59
|
+
* @param block
|
|
60
|
+
* @param extractor
|
|
61
|
+
* @return deleted items and updated entity identifiers
|
|
62
|
+
*/
|
|
63
|
+
deleteBlockData: (block: string, extractor: string) => Promise<{
|
|
64
|
+
deletedData: ExtractedData[];
|
|
65
|
+
updatedData: EntityInfo[];
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* insert all extracted entity data in an atomic transaction
|
|
69
|
+
* update the data if a entity with the same id is already stored in db
|
|
70
|
+
* @param entities
|
|
71
|
+
* @param block
|
|
72
|
+
* @param extractor
|
|
73
|
+
* @return inserted items and updated entity identifiers
|
|
74
|
+
* returns undefined in case of any problem
|
|
75
|
+
*/
|
|
76
|
+
storeEntities: (entities: Array<ExtractedData>, block: BlockInfo, extractor: string) => Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* remove all existing data for the extractor
|
|
79
|
+
* @param extractorId
|
|
80
|
+
*/
|
|
81
|
+
removeAllData: (extractorId: string) => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Builds a query that returns used blocks by selecting the `block` column from the `ExtractorEntity` repository,
|
|
84
|
+
* filtered by the provided `extractorId`
|
|
85
|
+
*
|
|
86
|
+
* @param extractorId - Identifier of the extractor
|
|
87
|
+
* @returns A query builder selecting used blocks
|
|
88
|
+
*/
|
|
89
|
+
createUsedBlocksQuery: (extractorId: string) => SelectQueryBuilder<ExtractorEntity>;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=abstractErgoAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractErgoAction.d.ts","sourceRoot":"","sources":["../../../../lib/ergo/database/actions/abstractErgoAction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAe,MAAM,+BAA+B,CAAC;AAC5E,OAAO,E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