@rosen-bridge/address-extractor 0.1.1 → 0.1.2-alpha
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/dist/actions/db.js +6 -10
- package/dist/entities/boxEntity.js +11 -14
- package/dist/extractor/ergoUtxoExtractor.js +6 -33
- package/dist/index.js +3 -9
- package/dist/interfaces/ExtractedBox.js +1 -4
- package/dist/migrations/boxEntity1659770552000.js +1 -5
- package/dist/migrations/index.js +2 -5
- package/package.json +2 -2
package/dist/actions/db.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BoxEntityAction = void 0;
|
|
4
|
-
const boxEntity_1 = require("../entities/boxEntity");
|
|
5
|
-
class BoxEntityAction {
|
|
1
|
+
import { BoxEntity } from "../entities/boxEntity";
|
|
2
|
+
export class BoxEntityAction {
|
|
6
3
|
datasource;
|
|
7
4
|
constructor(dataSource) {
|
|
8
5
|
this.datasource = dataSource;
|
|
@@ -16,7 +13,7 @@ class BoxEntityAction {
|
|
|
16
13
|
*/
|
|
17
14
|
storeBox = async (boxes, spendBoxes, block, extractor) => {
|
|
18
15
|
const boxEntities = boxes.map((box) => {
|
|
19
|
-
const row = new
|
|
16
|
+
const row = new BoxEntity();
|
|
20
17
|
row.address = box.address;
|
|
21
18
|
row.boxId = box.boxId;
|
|
22
19
|
row.createBlock = block.hash;
|
|
@@ -31,7 +28,7 @@ class BoxEntityAction {
|
|
|
31
28
|
await queryRunner.startTransaction();
|
|
32
29
|
try {
|
|
33
30
|
await queryRunner.manager.save(boxEntities);
|
|
34
|
-
await this.datasource.getRepository(
|
|
31
|
+
await this.datasource.getRepository(BoxEntity).createQueryBuilder()
|
|
35
32
|
.update()
|
|
36
33
|
.set({ spendBlock: block.hash })
|
|
37
34
|
.where("boxId IN (:boxes) AND extractor = :extractor", {
|
|
@@ -59,12 +56,12 @@ class BoxEntityAction {
|
|
|
59
56
|
deleteBlockBoxes = async (block, extractor) => {
|
|
60
57
|
await this.datasource.createQueryBuilder()
|
|
61
58
|
.delete()
|
|
62
|
-
.from(
|
|
59
|
+
.from(BoxEntity)
|
|
63
60
|
.where("extractor = :extractor AND createBlock = :block", {
|
|
64
61
|
"block": block,
|
|
65
62
|
"extractor": extractor
|
|
66
63
|
}).execute();
|
|
67
|
-
await this.datasource.getRepository(
|
|
64
|
+
await this.datasource.getRepository(BoxEntity).createQueryBuilder()
|
|
68
65
|
.update()
|
|
69
66
|
.set({ spendBlock: null })
|
|
70
67
|
.where("spendBlock = :block AND extractor = :extractor", {
|
|
@@ -73,4 +70,3 @@ class BoxEntityAction {
|
|
|
73
70
|
}).execute();
|
|
74
71
|
};
|
|
75
72
|
}
|
|
76
|
-
exports.BoxEntityAction = BoxEntityAction;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,9 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.BoxEntity = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
10
|
+
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
|
14
11
|
let BoxEntity = class BoxEntity {
|
|
15
12
|
id;
|
|
16
13
|
address;
|
|
@@ -22,38 +19,38 @@ let BoxEntity = class BoxEntity {
|
|
|
22
19
|
extractor;
|
|
23
20
|
};
|
|
24
21
|
__decorate([
|
|
25
|
-
|
|
22
|
+
PrimaryGeneratedColumn(),
|
|
26
23
|
__metadata("design:type", Number)
|
|
27
24
|
], BoxEntity.prototype, "id", void 0);
|
|
28
25
|
__decorate([
|
|
29
|
-
|
|
26
|
+
Column(),
|
|
30
27
|
__metadata("design:type", String)
|
|
31
28
|
], BoxEntity.prototype, "address", void 0);
|
|
32
29
|
__decorate([
|
|
33
|
-
|
|
30
|
+
Column(),
|
|
34
31
|
__metadata("design:type", String)
|
|
35
32
|
], BoxEntity.prototype, "boxId", void 0);
|
|
36
33
|
__decorate([
|
|
37
|
-
|
|
34
|
+
Column(),
|
|
38
35
|
__metadata("design:type", String)
|
|
39
36
|
], BoxEntity.prototype, "createBlock", void 0);
|
|
40
37
|
__decorate([
|
|
41
|
-
|
|
38
|
+
Column(),
|
|
42
39
|
__metadata("design:type", Number)
|
|
43
40
|
], BoxEntity.prototype, "creationHeight", void 0);
|
|
44
41
|
__decorate([
|
|
45
|
-
|
|
42
|
+
Column(),
|
|
46
43
|
__metadata("design:type", String)
|
|
47
44
|
], BoxEntity.prototype, "serialized", void 0);
|
|
48
45
|
__decorate([
|
|
49
|
-
|
|
46
|
+
Column({ nullable: true, type: "text" }),
|
|
50
47
|
__metadata("design:type", Object)
|
|
51
48
|
], BoxEntity.prototype, "spendBlock", void 0);
|
|
52
49
|
__decorate([
|
|
53
|
-
|
|
50
|
+
Column(),
|
|
54
51
|
__metadata("design:type", String)
|
|
55
52
|
], BoxEntity.prototype, "extractor", void 0);
|
|
56
53
|
BoxEntity = __decorate([
|
|
57
|
-
|
|
54
|
+
Entity()
|
|
58
55
|
], BoxEntity);
|
|
59
|
-
|
|
56
|
+
export { BoxEntity };
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ErgoUTXOExtractor = void 0;
|
|
27
|
-
const ergoLib = __importStar(require("ergo-lib-wasm-nodejs"));
|
|
28
|
-
const buffer_1 = require("buffer");
|
|
29
|
-
const db_1 = require("../actions/db");
|
|
30
|
-
class ErgoUTXOExtractor {
|
|
1
|
+
import * as ergoLib from 'ergo-lib-wasm-nodejs';
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { BoxEntityAction } from "../actions/db";
|
|
4
|
+
export class ErgoUTXOExtractor {
|
|
31
5
|
dataSource;
|
|
32
6
|
actions;
|
|
33
7
|
id;
|
|
@@ -36,7 +10,7 @@ class ErgoUTXOExtractor {
|
|
|
36
10
|
tokens;
|
|
37
11
|
constructor(dataSource, id, networkType, address, tokens) {
|
|
38
12
|
this.dataSource = dataSource;
|
|
39
|
-
this.actions = new
|
|
13
|
+
this.actions = new BoxEntityAction(dataSource);
|
|
40
14
|
this.id = id;
|
|
41
15
|
this.networkType = networkType;
|
|
42
16
|
this.ergoTree = address ? ergoLib.Address.from_base58(address).to_ergo_tree().to_base16_bytes() : undefined;
|
|
@@ -76,7 +50,7 @@ class ErgoUTXOExtractor {
|
|
|
76
50
|
boxes.push({
|
|
77
51
|
boxId: output.box_id().to_str(),
|
|
78
52
|
address: ergoLib.Address.recreate_from_ergo_tree(output.ergo_tree()).to_base58(this.networkType),
|
|
79
|
-
serialized:
|
|
53
|
+
serialized: Buffer.from(output.sigma_serialize_bytes()).toString("hex")
|
|
80
54
|
});
|
|
81
55
|
}
|
|
82
56
|
for (let index2 = 0; index2 < transaction.inputs().len(); index2++) {
|
|
@@ -104,4 +78,3 @@ class ErgoUTXOExtractor {
|
|
|
104
78
|
await this.actions.deleteBlockBoxes(hash, this.getId());
|
|
105
79
|
};
|
|
106
80
|
}
|
|
107
|
-
exports.ErgoUTXOExtractor = ErgoUTXOExtractor;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var ergoUtxoExtractor_1 = require("./extractor/ergoUtxoExtractor");
|
|
5
|
-
Object.defineProperty(exports, "ErgoUTXOExtractor", { enumerable: true, get: function () { return ergoUtxoExtractor_1.ErgoUTXOExtractor; } });
|
|
6
|
-
var boxEntity_1 = require("./entities/boxEntity");
|
|
7
|
-
Object.defineProperty(exports, "BoxEntity", { enumerable: true, get: function () { return boxEntity_1.BoxEntity; } });
|
|
8
|
-
var index_1 = require("./migrations/index");
|
|
9
|
-
Object.defineProperty(exports, "migrations", { enumerable: true, get: function () { return index_1.migrations; } });
|
|
1
|
+
export { ErgoUTXOExtractor } from './extractor/ergoUtxoExtractor';
|
|
2
|
+
export { BoxEntity } from './entities/boxEntity';
|
|
3
|
+
export { migrations } from './migrations/index';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.boxEntity1659770552000 = void 0;
|
|
4
|
-
class boxEntity1659770552000 {
|
|
1
|
+
export class boxEntity1659770552000 {
|
|
5
2
|
name = 'boxEntity1659770552000';
|
|
6
3
|
async up(queryRunner) {
|
|
7
4
|
await queryRunner.query(`CREATE TABLE "box_entity" (
|
|
@@ -18,4 +15,3 @@ class boxEntity1659770552000 {
|
|
|
18
15
|
await queryRunner.query(`DROP TABLE "box_entity"`);
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.boxEntity1659770552000 = boxEntity1659770552000;
|
package/dist/migrations/index.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.migrations = void 0;
|
|
4
|
-
const boxEntity1659770552000_1 = require("./boxEntity1659770552000");
|
|
5
|
-
exports.migrations = [boxEntity1659770552000_1.boxEntity1659770552000];
|
|
1
|
+
import { boxEntity1659770552000 } from "./boxEntity1659770552000";
|
|
2
|
+
export const migrations = [boxEntity1659770552000];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosen-bridge/address-extractor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-alpha",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "Vorujack",
|
|
18
18
|
"license": "GPL-3.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@rosen-bridge/scanner": "^0.1.
|
|
20
|
+
"@rosen-bridge/scanner": "^0.1.6-alpha",
|
|
21
21
|
"blakejs": "^1.2.1",
|
|
22
22
|
"ergo-lib-wasm-nodejs": "^0.18.0",
|
|
23
23
|
"reflect-metadata": "^0.1.13",
|