Skip to content

Commit 5100418

Browse files
committed
organize monorepo
1 parent 7a3a569 commit 5100418

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3053
-2825
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "packages/darcher-go-ethereum"]
2+
path = packages/darcher-go-ethereum
3+
url = https://github.com/Troublor/darcher-go-ethereum.git

lerna.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"lerna": "3.22.1",
3+
"packages": ["packages/*"],
4+
"version": "1.0.0",
5+
"npmClient": "yarn",
6+
"useWorkspaces": true
7+
}

package-lock.json

-13
This file was deleted.

package.json

+16-18
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,31 @@
77
},
88
"author": "Troublor",
99
"license": "ISC",
10-
"main": "darcher-analyzer/src/index.js",
1110
"private": true,
1211
"workspaces": [
13-
"darcher-analyzer",
14-
"darcher-dbmonitor-browser",
15-
"darcher-rpc",
16-
"darcher-go-ethereum",
17-
"darcher-config"
12+
"packages/*"
1813
],
1914
"scripts": {
20-
"test": "mocha -r ts-node/register darcher-analyzer/test/**/*.test.ts",
21-
"coverage": "nyc -r lcov -e .ts -x \"*.test.ts\" npm run test",
22-
"build:proto": "./scripts/compile_pb.sh",
15+
"build:config": "yarn workspace @darcher/config build",
16+
"build:proto": "yarn workspace @darcher/rpc build",
2317
"build:ethmonitor": "cd packages/darcher-go-ethereum && make ethmonitor",
2418
"build:geth": "cd packages/darcher-go-ethereum && make geth",
25-
"build:dbmonitor-browser": "yarn workspace packages/darcher-dbmonitor-browser build",
19+
"build:dbmonitor-browser": "yarn workspace @darcher/dbmonitor-browser build",
2620
"build": "npm-run-all build:*",
27-
"watch:dbmonitor-browser": "yarn workspace packages/darcher-dbmonitor-browser watch",
28-
"start:darcher": "yarn workspace darcher-analyzer start:darcher",
21+
"watch:dbmonitor-browser": "yarn workspace @darcher/dbmonitor-browser watch",
22+
"start:darcher": "yarn workspace @darcher/analyzer start:darcher",
2923
"start:ethmonitor": "cd packages/darcher-go-ethereum && go run cmd/ethmonitor/main.go --controller darcher --port 8989"
3024
},
3125
"dependencies": {
32-
"@types/chrome": "^0.0.117",
33-
"google-protobuf": "^3.12.2",
34-
"grpc": "^1.24.3",
35-
"grpc-tools": "^1.9.0",
36-
"grpc_tools_node_protoc_ts": "^4.1.0",
37-
"npm-run-all": "^4.1.5"
26+
"lerna": "^3.22.1",
27+
"npm-run-all": "^4.1.5",
28+
"ts-node": "^8.10.2",
29+
"typescript": "^3.9.6"
30+
},
31+
"devDependencies": {
32+
"@types/chai": "^4.2.11",
33+
"@types/mocha": "^7.0.2",
34+
"chai": "^4.2.0",
35+
"mocha": "^8.0.1"
3836
}
3937
}

packages/darcher-analyzer/package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2-
"name": "darcher-analyzer",
2+
"name": "@darcher/analyzer",
33
"version": "1.0.0",
44
"repository": {
55
"url": "https://github.com/Troublor/darcher"
66
},
77
"author": "Troublor",
88
"license": "ISC",
99
"scripts": {
10-
"start:darcher": "ts-node src/index.ts"
10+
"build": "tsc",
11+
"start:darcher": "ts-node src/index.ts",
12+
"test": "mocha --require ts-node/register test/*.test.ts"
1113
},
1214
"dependencies": {
1315
"@babel/polyfill": "^7.8.3",
@@ -20,22 +22,21 @@
2022
"jayson": "^3.2.0",
2123
"lodash": "^4.17.15",
2224
"log4js": "^6.2.1",
23-
"mocha": "^7.0.0",
2425
"request": "^2.88.2",
2526
"ts-enum-util": "^4.0.2",
26-
"ts-node": "^8.6.2",
27-
"typescript": "^3.7.4",
2827
"ws": "^7.3.0"
2928
},
3029
"devDependencies": {
31-
"@types/chai": "^4.2.7",
30+
"@types/chai": "^4.2.11",
3231
"@types/es6-promise": "^3.3.0",
3332
"@types/lodash": "^4.14.155",
34-
"@types/mocha": "^5.2.7",
33+
"@types/mocha": "^7.0.2",
3534
"@types/node": "^13.13.11",
3635
"@types/shelljs": "^0.8.6",
3736
"@types/ws": "^7.2.6",
37+
"chai": "^4.2.0",
3838
"express": "^4.17.1",
39+
"mocha": "^8.0.1",
3940
"shelljs": "^0.8.3",
4041
"ts-protoc-gen": "^0.12.0"
4142
}

packages/darcher-analyzer/src/analysis/analysis.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {CRUDOperation, DAppStateChangeMsg, isDeepEqual, isNullOrUndefined} from "../common";
22
import * as fs from "fs";
3-
import {TxState} from "../rpc/common_pb";
3+
import {TxState} from "@darcher/rpc";
44

55
type StateChange = DAppStateChangeMsg;
66

packages/darcher-analyzer/src/analysis/dArcher.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {EthMonitorController, EventNames, Server} from "../downstream";
33
import {DAppStateChangeMsg, isNullOrUndefined, logger, sleep} from "../common";
44
import * as readline from "readline";
55
import {EventEmitter} from "events";
6-
import {TxState} from "../rpc/common_pb";
6+
import {TxState} from "@darcher/rpc";
77

88
export class DArcher {
99

packages/darcher-analyzer/src/analyzer.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import {TxState} from "./rpc/common_pb";
1+
import {TxState} from "@darcher/rpc";
22
import {
33
TxFinishedMsg,
44
TxStateChangeMsg,
55
TxStateControlMsg,
66
TxTraverseStartMsg
7-
} from "./rpc/darcher_controller_service_pb";
7+
} from "@darcher/rpc";
88
import {logger, prettifyHash} from "./common";
99
import {EventEmitter} from "events";
1010
import {$enum} from "ts-enum-util";
1111
import {DBMonitorService} from "./service/dbmonitorService";
12+
import config from "@darcher/config";
1213

1314
/**
1415
* Extend TxState to introduce logical tx state (reverted, re-executed)
@@ -92,7 +93,7 @@ export class Analyzer {
9293
logger.info("Wait for 500 ms")
9394
setTimeout(async () => {
9495
try {
95-
let data = await this.dbMonitorService.GetAllData();
96+
let data = await this.dbMonitorService.getAllData(config.dapp.address, config.dapp.dbName);
9697
console.log(data);
9798
} catch (e) {
9899
logger.error("Get all data error", e);

packages/darcher-analyzer/src/common/defines.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
export const grpcPort = 1236;
2-
export const websocketPort = 1237;
3-
41
export interface Reply {
52
Err: string
63
}

packages/darcher-analyzer/src/common/helpers.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import {Reply} from "./index";
2-
import {start} from "repl";
3-
import removeTree = chrome.bookmarks.removeTree;
42

53
export const genEmptyReply = (): Reply => {
64
return <Reply>{Err: null};

packages/darcher-analyzer/src/darcher.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
* Darcher listen for new txs and start a analyzer for each tx
33
*/
44
import {DarcherController, DarcherServer} from "./service";
5-
import {SelectTxControlMsg, TxReceivedMsg} from "./rpc/darcher_controller_service_pb";
5+
import {SelectTxControlMsg, TxReceivedMsg} from "@darcher/rpc";
66
import {Analyzer} from "./analyzer";
7-
import {grpcPort, logger, websocketPort} from "./common";
7+
import {logger} from "./common";
8+
import config from "@darcher/config";
89

910
export class Darcher {
1011
private readonly server: DarcherServer;
@@ -14,7 +15,7 @@ export class Darcher {
1415
private readonly darcherController: DarcherController;
1516

1617
constructor() {
17-
this.server = new DarcherServer(grpcPort, websocketPort);
18+
this.server = new DarcherServer(config.rpcPort["darcher-ethmonitor"], config.rpcPort["darcher-dbmonitor"].ws);
1819
this.analyzers = {};
1920
this.darcherController = <DarcherController>{
2021
onTxReceived: this.onTxReceived.bind(this),

packages/darcher-analyzer/src/downstream/dbMonitor.ts

-48
This file was deleted.

packages/darcher-analyzer/src/downstream/index.ts

-1
This file was deleted.

packages/darcher-analyzer/src/downstream/server.ts

-71
This file was deleted.

packages/darcher-analyzer/src/rpc/common_grpc_pb.js

-1
This file was deleted.

packages/darcher-analyzer/src/rpc/common_pb.d.ts

-26
This file was deleted.

0 commit comments

Comments
 (0)