@rosen-bridge/abstract-extractor 0.1.2 → 0.1.4
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 +12 -0
- package/dist/ergo/initializable/AbstractInitializable.d.ts.map +1 -1
- package/dist/ergo/initializable/AbstractInitializable.js +10 -3
- package/dist/ergo/network/ExplorerNetwork.d.ts.map +1 -1
- package/dist/ergo/network/ExplorerNetwork.js +3 -2
- package/dist/ergo/network/NodeNetwork.d.ts.map +1 -1
- package/dist/ergo/network/NodeNetwork.js +6 -5
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/lib/ergo/initializable/AbstractInitializable.ts +8 -2
- package/lib/ergo/network/ExplorerNetwork.ts +2 -1
- package/lib/ergo/network/NodeNetwork.ts +5 -4
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -93,6 +93,7 @@ export abstract class AbstractInitializableErgoExtractor<
|
|
|
93
93
|
* @param initialBlock
|
|
94
94
|
*/
|
|
95
95
|
initializeBoxes = async (initialBlock: BlockInfo) => {
|
|
96
|
+
const fetched = new Set<string>();
|
|
96
97
|
let trial = 1;
|
|
97
98
|
if (this.initialize) {
|
|
98
99
|
this.logger.debug(
|
|
@@ -109,13 +110,18 @@ export abstract class AbstractInitializableErgoExtractor<
|
|
|
109
110
|
offset,
|
|
110
111
|
API_LIMIT
|
|
111
112
|
);
|
|
113
|
+
const boxes = data.extractedBoxes.filter((item) => {
|
|
114
|
+
if (fetched.has(item.boxId)) return false;
|
|
115
|
+
fetched.add(item.boxId);
|
|
116
|
+
return true;
|
|
117
|
+
});
|
|
112
118
|
this.logger.info(
|
|
113
119
|
`Inserting ${
|
|
114
|
-
|
|
120
|
+
boxes.length
|
|
115
121
|
} new extracted data in ${this.getId()} initialization`
|
|
116
122
|
);
|
|
117
123
|
const insertSuccess = await this.actions.insertBoxes(
|
|
118
|
-
|
|
124
|
+
boxes,
|
|
119
125
|
this.getId()
|
|
120
126
|
);
|
|
121
127
|
if (!insertSuccess) throw new Error('Could not store extracted data');
|
|
@@ -62,9 +62,10 @@ export class ExplorerNetwork extends AbstractNetwork {
|
|
|
62
62
|
offset: number,
|
|
63
63
|
limit: number
|
|
64
64
|
): Promise<{ boxes: ErgoBox[]; hasNextBatch: boolean }> => {
|
|
65
|
-
const boxes = await this.api.v1.
|
|
65
|
+
const boxes = await this.api.v1.getApiV1BoxesUnspentByaddressP1(address, {
|
|
66
66
|
offset: offset,
|
|
67
67
|
limit: limit,
|
|
68
|
+
sortDirection: 'desc',
|
|
68
69
|
});
|
|
69
70
|
if (!boxes.items)
|
|
70
71
|
throw new Error('Explorer BoxesByAddress api expected to have items');
|
|
@@ -64,16 +64,17 @@ export class NodeNetwork extends AbstractNetwork {
|
|
|
64
64
|
offset: number,
|
|
65
65
|
limit: number
|
|
66
66
|
): Promise<{ boxes: ErgoBox[]; hasNextBatch: boolean }> => {
|
|
67
|
-
const boxes = await this.api.
|
|
67
|
+
const boxes = await this.api.getBoxesByAddressUnspent(address, {
|
|
68
68
|
offset: offset,
|
|
69
69
|
limit: limit,
|
|
70
|
+
sortDirection: 'desc',
|
|
70
71
|
});
|
|
71
|
-
if (!boxes
|
|
72
|
+
if (!boxes)
|
|
72
73
|
throw new Error('Ergo node BoxesByAddress api expected to have items');
|
|
73
74
|
const ergoBoxes = await Promise.all(
|
|
74
|
-
boxes.
|
|
75
|
+
boxes.map(async (box) => await this.convertToErgoBox(box))
|
|
75
76
|
);
|
|
76
|
-
return { boxes: ergoBoxes, hasNextBatch: boxes.
|
|
77
|
+
return { boxes: ergoBoxes, hasNextBatch: boxes.length > 0 };
|
|
77
78
|
};
|
|
78
79
|
|
|
79
80
|
/**
|