Skip to content

Commit 582038f

Browse files
authored
Merge branch 'master' into create-versions-dropdown
2 parents 2fcac87 + 3ed4a34 commit 582038f

File tree

14 files changed

+128
-60
lines changed

14 files changed

+128
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist/*
44
.DS_Store
55
coverage/*
66
.vscode/*
7+
contracts/*

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:8-alpine
2+
3+
RUN apk update && apk upgrade && \
4+
apk add --no-cache bash git python g++ gcc libgcc libstdc++ linux-headers make
5+
6+
RUN npm install --quiet node-gyp -g
7+
8+
WORKDIR /opt/app
9+
10+
COPY package.json ./
11+
12+
RUN npm i -g npm@^6.1.0 && npm install
13+
14+
COPY . .
15+
16+
EXPOSE 9090
17+
18+
CMD [ "npm", "run", "start" ]

README.md

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ There are already tools that allow you to debug Ethereum transactions (Solidity)
2020

2121
Use release link:
2222

23-
* [v3.5.0](https://github.com/fergarrui/ethereum-graph-debugger/releases/tag/v3.5.0)
23+
* [v3.6.0](https://github.com/fergarrui/ethereum-graph-debugger/releases/tag/v3.6.0)
2424

2525
If you want to use master (it can be more unstable), clone and start the application
2626

@@ -39,6 +39,14 @@ npm start
3939

4040
Go to localhost:9090
4141

42+
### With docker
43+
44+
`docker-compose up`
45+
46+
Go to localhost:9090
47+
48+
Add contracts to `./contracts` (you will need to create the directory) and empty string at the 'Load contracts from URI' form.
49+
4250
### Use
4351

4452
* Go to localhost:9090
@@ -53,33 +61,6 @@ Go to localhost:9090
5361
* Scan the directory as described above
5462
* You won't get source code mappings when clicking in operations of the CFG
5563

56-
### [Temporal] - switch solc version
57-
58-
Current `solc` version is `0.5.8`, if you want to use an earlier version, for now it can only be done via API (UI coming soon)
59-
60-
* List supported `solc` versions
61-
* `curl http://localhost:9090/solc/list`
62-
* Output will be like:
63-
```
64-
[
65-
{
66-
"version": "0.5.8",
67-
"commit": "v0.5.8+commit.23d335f2"
68-
},
69-
{
70-
"version": "0.5.7",
71-
"commit": "v0.5.7+commit.6da8b019"
72-
},
73-
{
74-
"version": "0.5.6",
75-
"commit": "v0.5.6+commit.b259423e"
76-
},
77-
(... truncated ...)
78-
```
79-
* Select a commit, for example: `v0.5.6+commit.b259423e`
80-
* Set the version to that commit: `curl -X POST --data '{"version": "v0.5.8+commit.23d335f2"}' http://localhost:9090/solc -H 'Content-Type: application/json'`
81-
* Check what version is loaded: `curl http://localhost:9090/solc`
82-
8364
# Features
8465

8566
* **Now interactive** :star2:: it has a sepparate frontend and API instead of building a static HTML file like in earlier versions

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '3.4'
2+
3+
services:
4+
debugger:
5+
image: ethereum-graph-debugger
6+
build:
7+
context: ./
8+
environment:
9+
- BLOCKCHAIN_HOST=ganache:8545
10+
ports:
11+
- 9090:9090
12+
volumes:
13+
- ./src:/opt/app/src:delegated
14+
- ./contracts:/opt/app/contracts:delegated
15+
16+
ganache:
17+
image: trufflesuite/ganache-cli:v6.1.6
18+
container_name: ganache
19+
restart: always
20+
command: -l 804247552 -h 0.0.0.0 -d
21+
ports:
22+
- 8545:8545

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ethereum-graph-debugger",
33
"author": "Fernando Garcia",
44
"license": "GPL",
5-
"version": "3.5.0",
5+
"version": "3.6.0",
66
"description": "Ethereum graph debugger",
77
"main": "dist/run-server.js",
88
"scripts": {

src/api/blockchain/Web3Instance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export class Web3Instance implements IWeb3 {
88
constructor(config: Web3Configuration) {
99
const isEmpty = Object.values(config).every(x => (!x) || x === '')
1010
if (isEmpty) {
11-
this.web3Instance = new Web3('http://127.0.0.1:8545')
11+
this.web3Instance = new Web3(process.env.BLOCKCHAIN_HOST? `http://${process.env.BLOCKCHAIN_HOST }`:'http://127.0.0.1:8545')
1212
} else {
1313
const protocol = config.blockchainProtocol || 'http'
14-
const url = config.blockchainHost || '127.0.0.1:8545'
14+
const url = config.blockchainHost || process.env.BLOCKCHAIN_HOST || '127.0.0.1:8545'
1515
let blockchainUrl = `${protocol}://`
1616
if (config.blockchainBasicAuthUsername && config.blockchainBasicAuthPassword) {
1717
blockchainUrl += `${config.blockchainBasicAuthUsername}:${config.blockchainBasicAuthPassword}@`

src/api/service/controller/ContractController.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { logger } from '../../../Logger';
66
import { RunContractFunctionRequest } from '../request/RunContractFunctionRequest';
77
import { Web3Configuration } from '../../blockchain/Web3Configuration';
88
import { DeployContractRequest } from '../request/DeployContractRequest';
9+
import { StringBodyRequest } from '../request/StringBodyRequest';
910

1011
@Route('contract')
1112
@provideSingleton(ContractController)
@@ -17,14 +18,14 @@ export class ContractController extends Controller {
1718
super()
1819
}
1920

20-
@Get('abi')
21+
@Post('abi')
2122
async getAbi(
22-
@Query('source') source: string,
23+
@Body() source: StringBodyRequest,
2324
@Query('name') name: string,
2425
@Query('path') path: string
2526
){
2627
try {
27-
const abi = this.contractService.getAbi(name, source, path)
28+
const abi = this.contractService.getAbi(name, source.request, path)
2829
if (!abi) {
2930
throw new Error(`No abi found for contract ${name}`)
3031
}
@@ -35,6 +36,24 @@ export class ContractController extends Controller {
3536
}
3637
}
3738

39+
@Post('functions')
40+
async getFunctions(
41+
@Body() source: StringBodyRequest,
42+
@Query('name') name: string,
43+
@Query('path') path: string
44+
){
45+
try {
46+
const functions = this.contractService.getFunctions(name, source.request, path)
47+
if (!functions) {
48+
throw new Error(`No abi found for contract ${name}`)
49+
}
50+
return functions
51+
} catch (err) {
52+
logger.error(err)
53+
throw new Error(err.message)
54+
}
55+
}
56+
3857
@Post('deploy')
3958
async deploy(
4059
@Body() deployRequest: DeployContractRequest,

src/api/service/controller/ControlFlowGraphController.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { GFCResponse } from '../response/CFGResponse'
88
import { OperationResponse } from '../response/OperationResponse'
99
import { logger } from '../../../Logger'
1010
import { StringBodyRequest } from '../request/StringBodyRequest';
11-
const fs = require('fs')
1211

1312
@Route('cfg')
1413
@provideSingleton(ControlFlowGraphController)
@@ -33,7 +32,6 @@ export class ControlFlowGraphController extends Controller {
3332
throw new Error('Constructor is true but no constructor found in bytecode')
3433
}
3534
const cfg = this.createCFG(contractBlocks, constructor)
36-
await fs.writeFileSync('cfg', cfg)
3735
return this.buildResponse(contractBlocks, constructor, cfg)
3836
} catch (err) {
3937
logger.error(err)

src/api/service/controller/FileController.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export class FileController extends Controller {
1616
@Get('{dir}')
1717
async findContractsInDir(@Path() dir: string, @Query('extension') extension: string): Promise<ContractFile[]> {
1818
try {
19-
const contracts = await this.fileService.findContractssWithExtension(dir, extension)
19+
let directory = dir
20+
if (!dir || dir === '' || dir === ' ') {
21+
directory = './contracts'
22+
}
23+
const contracts = await this.fileService.findContractssWithExtension(directory, extension)
2024
if (contracts.length === 0) {
2125
throw new Error(`No contracts found at ${dir} with extension ${extension}`)
2226
}

0 commit comments

Comments
 (0)