@rosen-bridge/abstract-extractor 1.0.0 → 1.0.1-967dc6f4
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 +7 -0
- package/dist/ergo/AbstractErgoExtractor.d.ts +5 -3
- package/dist/ergo/AbstractErgoExtractor.d.ts.map +1 -1
- package/dist/ergo/AbstractErgoExtractor.js +8 -3
- package/dist/ergo/initializable/AbstractInitializable.d.ts +1 -1
- package/dist/ergo/initializable/AbstractInitializable.d.ts.map +1 -1
- package/dist/ergo/initializable/AbstractInitializable.js +3 -3
- package/dist/ergo/interfaces.d.ts +4 -0
- package/dist/ergo/interfaces.d.ts.map +1 -1
- package/dist/ergo/interfaces.js +1 -1
- package/dist/ergo/network/ExplorerNetwork.d.ts.map +1 -1
- package/dist/ergo/network/ExplorerNetwork.js +3 -1
- package/dist/ergo/network/NodeNetwork.d.ts.map +1 -1
- package/dist/ergo/network/NodeNetwork.js +2 -1
- package/lib/ergo/AbstractErgoExtractor.ts +11 -3
- package/lib/ergo/initializable/AbstractInitializable.ts +3 -2
- package/lib/ergo/interfaces.ts +5 -0
- package/lib/ergo/network/ExplorerNetwork.ts +2 -0
- package/lib/ergo/network/NodeNetwork.ts +2 -1
- package/package.json +3 -3
- package/tests/AbstractErgoExtractor.mock.ts +4 -0
- package/tests/AbstractErgoExtractor.spec.ts +39 -2
- package/tests/network/testData.ts +11 -18
- package/tests/testData.ts +3 -11
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -82,6 +82,7 @@ export class ExplorerNetwork extends AbstractNetwork {
|
|
|
82
82
|
tx.dataInputs?.map((dataInput) => ({
|
|
83
83
|
boxId: dataInput.boxId,
|
|
84
84
|
})) ?? [],
|
|
85
|
+
// TODO: Add input extension to explorer local/ergo/rosen-bridge/scanner/-/issues/156
|
|
85
86
|
inputs: tx.inputs?.map((input) => ({ boxId: input.boxId })) ?? [],
|
|
86
87
|
outputs:
|
|
87
88
|
tx.outputs?.map((output) => ({
|
|
@@ -113,6 +114,7 @@ export class ExplorerNetwork extends AbstractNetwork {
|
|
|
113
114
|
tx.dataInputs?.map((dataInput) => ({
|
|
114
115
|
boxId: dataInput.id,
|
|
115
116
|
})) ?? [],
|
|
117
|
+
// TODO: Add input extension local/ergo/rosen-bridge/scanner/-/issues/156
|
|
116
118
|
inputs: tx.inputs?.map((input) => ({ boxId: input.id })) ?? [],
|
|
117
119
|
outputs:
|
|
118
120
|
tx.outputs?.map((output) => ({
|
|
@@ -64,7 +64,8 @@ export class NodeNetwork extends AbstractNetwork {
|
|
|
64
64
|
additionalRegisters: output.additionalRegisters,
|
|
65
65
|
boxId: output.boxId || '',
|
|
66
66
|
})),
|
|
67
|
-
|
|
67
|
+
// TODO: Add input extension local/ergo/rosen-bridge/scanner/-/issues/156
|
|
68
|
+
inputs: tx.inputs.map((input) => ({ boxId: input.boxId! })) ?? [],
|
|
68
69
|
dataInputs: tx.dataInputs,
|
|
69
70
|
};
|
|
70
71
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosen-bridge/abstract-extractor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-967dc6f4",
|
|
4
4
|
"description": "Rosen Bridge extractor interfaces to work with scanner",
|
|
5
5
|
"repository": "",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"node": ">=20.11.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rosen-bridge/abstract-logger": "^
|
|
39
|
+
"@rosen-bridge/abstract-logger": "^2.0.1",
|
|
40
40
|
"@rosen-bridge/json-bigint": "^0.1.0",
|
|
41
41
|
"@rosen-clients/ergo-explorer": "^1.1.2",
|
|
42
|
-
"@rosen-clients/ergo-node": "^1.
|
|
42
|
+
"@rosen-clients/ergo-node": "^1.2.0",
|
|
43
43
|
"lodash-es": "^4.17.21",
|
|
44
44
|
"typeorm": "^0.3.20",
|
|
45
45
|
"uuid": "^9.0.0"
|
|
@@ -17,6 +17,10 @@ export class MockedErgoExtractor extends AbstractErgoExtractor<
|
|
|
17
17
|
AbstractErgoExtractorEntity
|
|
18
18
|
>;
|
|
19
19
|
|
|
20
|
+
constructor(trackInputExtension = false) {
|
|
21
|
+
super(undefined, trackInputExtension);
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
getId = () => 'Test';
|
|
21
25
|
|
|
22
26
|
initializeBoxes: (initialBlock: BlockInfo) => Promise<void>;
|
|
@@ -22,7 +22,7 @@ describe('AbstractErgoExtractor', () => {
|
|
|
22
22
|
* - spy `extractBoxData` and `storeBoxes`
|
|
23
23
|
* - run test (call `processTransactions`)
|
|
24
24
|
* @expected
|
|
25
|
-
* - to call `extractBoxData` for the specific box
|
|
25
|
+
* - to call `extractBoxData` for the specific box and undefined (without input extension)
|
|
26
26
|
* - to insert the extracted box to database
|
|
27
27
|
* - to return true when total procedure is successful
|
|
28
28
|
* - to trigger `INSERT` callbacks with correct data
|
|
@@ -49,7 +49,7 @@ describe('AbstractErgoExtractor', () => {
|
|
|
49
49
|
const result = await extractor.processTransactions([tx], block);
|
|
50
50
|
|
|
51
51
|
expect(extractSpy).toBeCalledTimes(1);
|
|
52
|
-
expect(extractSpy).toBeCalledWith(tx.outputs[0]);
|
|
52
|
+
expect(extractSpy).toBeCalledWith(tx.outputs[0], undefined);
|
|
53
53
|
expect(storeSpy).toBeCalledWith([extractedData], block, 'Test');
|
|
54
54
|
expect(result).toEqual(true);
|
|
55
55
|
expect(triggerCallbacks).toBeCalledWith(CallbackType.Insert, [
|
|
@@ -109,6 +109,43 @@ describe('AbstractErgoExtractor', () => {
|
|
|
109
109
|
]);
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @target processTransactions should extract input extensions and use in `extractBoxData`
|
|
114
|
+
* @dependencies
|
|
115
|
+
* @scenario
|
|
116
|
+
* - mock extractor with track input extensions
|
|
117
|
+
* - mock `hasData` to return true for one box
|
|
118
|
+
* - spy `extractBoxData`, `storeBoxes` and `spendBoxes`
|
|
119
|
+
* - run test (call `processTransactions`)
|
|
120
|
+
* @expected
|
|
121
|
+
* - to call `extractBoxData` for the specific box with all input extensions
|
|
122
|
+
*/
|
|
123
|
+
it('should extract input extensions and use in `extractBoxData`', async () => {
|
|
124
|
+
const extractor = new MockedErgoExtractor(true);
|
|
125
|
+
const triggerCallbacks = vitest.fn();
|
|
126
|
+
extractor['triggerCallbacks'] = triggerCallbacks;
|
|
127
|
+
extractor.hasData = (box: V1.OutputInfo | OutputBox) => {
|
|
128
|
+
if (box.boxId == tx.outputs[0].boxId) return true;
|
|
129
|
+
return false;
|
|
130
|
+
};
|
|
131
|
+
const extractSpy = vitest.fn().mockReturnValue(extractedData);
|
|
132
|
+
extractor.extractBoxData = extractSpy;
|
|
133
|
+
extractor['actions'] = {
|
|
134
|
+
storeBoxes: vitest.fn().mockResolvedValue(true),
|
|
135
|
+
spendBoxes: vitest.fn().mockResolvedValue([]),
|
|
136
|
+
} as unknown as AbstractErgoExtractorAction<
|
|
137
|
+
AbstractBoxData,
|
|
138
|
+
AbstractErgoExtractorEntity
|
|
139
|
+
>;
|
|
140
|
+
await extractor.processTransactions([tx], block);
|
|
141
|
+
|
|
142
|
+
expect(extractSpy).toBeCalledTimes(1);
|
|
143
|
+
expect(extractSpy).toBeCalledWith(tx.outputs[0], [
|
|
144
|
+
tx.inputs[0].extension,
|
|
145
|
+
{},
|
|
146
|
+
]);
|
|
147
|
+
});
|
|
148
|
+
|
|
112
149
|
/**
|
|
113
150
|
* @target processTransactions should return false if data insertion fails
|
|
114
151
|
* @dependencies
|
|
@@ -1240,7 +1240,7 @@ export const nodeTx = {
|
|
|
1240
1240
|
timestamp: 1722500537020n,
|
|
1241
1241
|
index: 3,
|
|
1242
1242
|
globalIndex: 7582283n,
|
|
1243
|
-
numConfirmations:
|
|
1243
|
+
numConfirmations: 146428,
|
|
1244
1244
|
inputs: [
|
|
1245
1245
|
{
|
|
1246
1246
|
globalIndex: 41863807n,
|
|
@@ -1264,17 +1264,11 @@ export const nodeTx = {
|
|
|
1264
1264
|
additionalRegisters: {
|
|
1265
1265
|
R4: '05a686a9ad09',
|
|
1266
1266
|
R5: '04a299a101',
|
|
1267
|
-
},
|
|
1267
|
+
} as Registers,
|
|
1268
1268
|
transactionId:
|
|
1269
1269
|
'c1625b2f26935514d9cc47ce3acedb75e7b51595c1a26cc2fe0b6eadeeb205d8',
|
|
1270
1270
|
index: 0,
|
|
1271
|
-
|
|
1272
|
-
proofBytes:
|
|
1273
|
-
'4ab9da11fc216660e974842cc3b7705e62ebb9e0bf5ff78e53f9cd40abadd1173ab9da11fc216660e974842cc3b7705e62ebb9e0bf5ff78e53f9cd40abadd1173ab9da11fc216660e974842cc3b7705e62ebb9e0bf5ff78e53f9cd40abadd117',
|
|
1274
|
-
extension: {
|
|
1275
|
-
'1': 'a2aed72ff1b139f35d1ad2938cb44c9848a34d4dcfd6d8ab717ebde40a7304f2541cf628ffc8b5c496e6161eba3f169c6dd440704b1719e0',
|
|
1276
|
-
},
|
|
1277
|
-
},
|
|
1271
|
+
spendingHeight: null,
|
|
1278
1272
|
},
|
|
1279
1273
|
{
|
|
1280
1274
|
globalIndex: 41863813n,
|
|
@@ -1292,13 +1286,7 @@ export const nodeTx = {
|
|
|
1292
1286
|
transactionId:
|
|
1293
1287
|
'c1625b2f26935514d9cc47ce3acedb75e7b51595c1a26cc2fe0b6eadeeb205d8',
|
|
1294
1288
|
index: 6,
|
|
1295
|
-
|
|
1296
|
-
proofBytes:
|
|
1297
|
-
'4ab9da11fc216660e974842cc3b7705e62ebb9e0bf5ff78e53f9cd40abadd1173ab9da11fc216660e974842cc3b7705e62ebb9e0bf5ff78e53f9cd40abadd1173ab9da11fc216660e974842cc3b7705e62ebb9e0bf5ff78e53f9cd40abadd117',
|
|
1298
|
-
extension: {
|
|
1299
|
-
'1': 'a2aed72ff1b139f35d1ad2938cb44c9848a34d4dcfd6d8ab717ebde40a7304f2541cf628ffc8b5c496e6161eba3f169c6dd440704b1719e0',
|
|
1300
|
-
},
|
|
1301
|
-
},
|
|
1289
|
+
spendingHeight: null,
|
|
1302
1290
|
},
|
|
1303
1291
|
],
|
|
1304
1292
|
dataInputs: [],
|
|
@@ -1308,7 +1296,8 @@ export const nodeTx = {
|
|
|
1308
1296
|
inclusionHeight: 1320528,
|
|
1309
1297
|
address:
|
|
1310
1298
|
'NTkuk55NdwCXkF1e2nCABxq7bHjtinX3wH13zYPZ6qYT71dCoZBe1gZkh9FAr7GeHo2EpFoibzpNQmoi89atUjKRrhZEYrTapdtXrWU4kq319oY7BEWmtmRU9cMohX69XMuxJjJP5hRM8WQLfFnffbjshhEP3ck9CKVEkFRw1JDYkqVke2JVqoMED5yxLVkScbBUiJJLWq9BSbE1JJmmreNVskmWNxWE6V7ksKPxFMoqh1SVePh3UWAaBgGQRZ7TWf4dTBF5KMVHmRXzmQqEu2Fz2yeSLy23sM3pfqa78VuvoFHnTFXYFFxn3DNttxwq3EU3Zv25SmgrWjLKiZjFcEcqGgH6DJ9FZ1DfucVtTXwyDJutY3ksUBaEStRxoUQyRu4EhDobixL3PUWRcxaRJ8JKA9b64ALErGepRHkAoVmS8DaE6VbroskyMuhkTo7LbrzhTyJbqKurEzoEfhYxus7bMpLTePgKcktgRRyB7MjVxjSpxWzZedvzbjzZaHLZLkWZESk1WtdM25My33wtVLNXiTvficEUbjA23sNd24pv1YQ72nY1aqUHa2',
|
|
1311
|
-
spentTransactionId:
|
|
1299
|
+
spentTransactionId:
|
|
1300
|
+
'0ad32fd0423a4d2e551f0ae9be28a650bef4b9420791bd5208c6f35c1b234322',
|
|
1312
1301
|
boxId: '3729892f2fcd5b05761ab2994bb418947a5e7d6aaeae5c46351b2e6cf29afc34',
|
|
1313
1302
|
value: 5810250000n,
|
|
1314
1303
|
ergoTree:
|
|
@@ -1329,6 +1318,7 @@ export const nodeTx = {
|
|
|
1329
1318
|
transactionId:
|
|
1330
1319
|
'4e7c782db6525e7d59a28df3b72a16d26fcb64ceae535dfec3936e61d8feddf2',
|
|
1331
1320
|
index: 0,
|
|
1321
|
+
spendingHeight: null,
|
|
1332
1322
|
},
|
|
1333
1323
|
{
|
|
1334
1324
|
globalIndex: 41864032n,
|
|
@@ -1347,12 +1337,14 @@ export const nodeTx = {
|
|
|
1347
1337
|
transactionId:
|
|
1348
1338
|
'4e7c782db6525e7d59a28df3b72a16d26fcb64ceae535dfec3936e61d8feddf2',
|
|
1349
1339
|
index: 1,
|
|
1340
|
+
spendingHeight: null,
|
|
1350
1341
|
},
|
|
1351
1342
|
{
|
|
1352
1343
|
globalIndex: 41864033n,
|
|
1353
1344
|
inclusionHeight: 1320528,
|
|
1354
1345
|
address: '9fzRcctiWfzoJyqGtPWqoXPuxSmFw6zpnjtsQ1B6jSN514XqH4q',
|
|
1355
|
-
spentTransactionId:
|
|
1346
|
+
spentTransactionId:
|
|
1347
|
+
'fc362346389ebad8252c19a6489a5c55eb3afbca4b9e21cc1c8aa4583d1aefd3',
|
|
1356
1348
|
boxId: '918c7a92bf9ab9ba45cb96df067129f3fc0c24b62bf91d7f8c7f1d3062e52426',
|
|
1357
1349
|
value: 23324978571n,
|
|
1358
1350
|
ergoTree:
|
|
@@ -1363,6 +1355,7 @@ export const nodeTx = {
|
|
|
1363
1355
|
transactionId:
|
|
1364
1356
|
'4e7c782db6525e7d59a28df3b72a16d26fcb64ceae535dfec3936e61d8feddf2',
|
|
1365
1357
|
index: 2,
|
|
1358
|
+
spendingHeight: null,
|
|
1366
1359
|
},
|
|
1367
1360
|
],
|
|
1368
1361
|
size: 789,
|
package/tests/testData.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block } from '../lib';
|
|
1
|
+
import { Block, InputExtension } from '../lib';
|
|
2
2
|
import { TestEntity } from './testUtils';
|
|
3
3
|
|
|
4
4
|
export const tx = {
|
|
@@ -6,19 +6,11 @@ export const tx = {
|
|
|
6
6
|
inputs: [
|
|
7
7
|
{
|
|
8
8
|
boxId: '3df73b29204ffa2085c38a958d322c86bee0471a5a1296b031f137236e038c6d',
|
|
9
|
-
|
|
10
|
-
proofBytes:
|
|
11
|
-
'06fb1e785d12ac74886c0d3fa0e61db0aa4dfaef6b6a42ab7a908625f3721f35bbce8245876ab14113baf41ff7b479863513462a8b438ec3',
|
|
12
|
-
extension: {},
|
|
13
|
-
},
|
|
9
|
+
extension: { '0': '1101d00f' } as InputExtension,
|
|
14
10
|
},
|
|
15
11
|
{
|
|
16
12
|
boxId: '846f3cedf2fc4242898413558e73a69d057edda1df6f274a1eeea219b6dd62dd',
|
|
17
|
-
|
|
18
|
-
proofBytes:
|
|
19
|
-
'2c930f70ba11b35f32e3eb9023634e7a394a8714ebe794fd7134ab4cea9da753303f2f56e6bf4d1b0b0466b29fc8ce8c949ca602edf38895',
|
|
20
|
-
extension: {},
|
|
21
|
-
},
|
|
13
|
+
extension: {},
|
|
22
14
|
},
|
|
23
15
|
],
|
|
24
16
|
dataInputs: [],
|