Skip to content

Commit e27d77f

Browse files
committed
Add storage reader API call
1 parent 73bfd9d commit e27d77f

18 files changed

+380
-46
lines changed

package-lock.json

Lines changed: 114 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
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.0.2",
5+
"version": "2.1.0",
66
"description": "Ethereum graph debugger",
77
"main": "dist/run-server.js",
88
"scripts": {
@@ -83,7 +83,7 @@
8383
"recursive-readdir": "^2.2.2",
8484
"redux-thunk": "^2.3.0",
8585
"reflect-metadata": "^0.1.12",
86-
"solc": "^0.5.8",
86+
"solc": "^0.4.24",
8787
"terser": "3.14.1",
8888
"tsoa": "2.1.8",
8989
"web3": "1.0.0-beta.37",

src/api/bytecode/EVMDisassembler.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ export class EVMDisassembler implements Disassembler {
118118
const constructor = disassembledCode.constructor
119119
const runtime = disassembledCode.runtime
120120
if (constructor.length !== asmConstructor.length + 1 || runtime.length !== asmRuntime.length + 1) {
121-
console.log(constructor)
122-
console.log('================')
123-
console.log(asmConstructor)
124121
logger.error(`Source mappings do not match with bytecode, constructorLength=${constructor.length}, asmConstructorLength=${asmConstructor.length}, runtimeLength=${runtime.length}, asmRuntimeLength=${asmRuntime.length}`)
125122
throw new Error(`Source mappings do not match with bytecode`)
126123
}

src/api/service/bean/Block.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export interface Block {
2+
difficulty: number;
3+
extraData?: string;
4+
gasLimit: number;
5+
gasUsed: number;
6+
hash: string;
7+
logsBloom?: string;
8+
miner?: string;
9+
mixHash?: string;
10+
nonce: string;
11+
number: number;
12+
parentHash: string;
13+
receiptsRoot?: string;
14+
sha3Uncles?: string;
15+
size?: number;
16+
stateRoot?: string;
17+
timestamp: number;
18+
totalDifficulty?: number;
19+
transactions: string[];
20+
transactionsRoot?: string;
21+
uncles: any[];
22+
}

src/api/service/bean/Storage.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export class Storage {
2+
storage: any = {}
3+
4+
setStorage(key: string, value: string, block: number, transactionHash: string, transactionIndex: number) {
5+
this.storage[key] = {
6+
value,
7+
transactionHash,
8+
block,
9+
transactionIndex
10+
} as StorageEntry
11+
}
12+
}
13+
14+
export interface StorageEntry {
15+
value: string
16+
transactionHash: string
17+
block: number
18+
transactionIndex: number
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export interface Transaction {
2+
blockHash: string;
3+
blockNumber: number;
4+
from: string;
5+
gas: number;
6+
gasPrice: number;
7+
hash: string;
8+
input: string;
9+
nonce: number;
10+
to: string;
11+
transactionIndex: number;
12+
value: number;
13+
}

src/api/service/bean/TransactionReceipt.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ export interface TransactionReceipt {
33
data: string
44
to: string
55
from: string
6+
blockNumber: number
7+
transactionIndex: number
8+
contractAddress: string
69
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Route, Path, Controller, Get, Query } from 'tsoa'
2+
import { provideSingleton } from '../../../inversify/ioc';
3+
import { inject } from 'inversify';
4+
import { TYPES } from '../../../inversify/types';
5+
import { StorageRecover } from '../service/StorageRecover';
6+
import { Web3Configuration } from '../../blockchain/Web3Configuration';
7+
import { logger } from '../../../Logger'
8+
9+
@Route('storage')
10+
@provideSingleton(StorageRecoverController)
11+
export class StorageRecoverController extends Controller {
12+
13+
constructor(@inject(TYPES.StorageRecover) private storageRecover: StorageRecover) {
14+
super()
15+
}
16+
17+
@Get('{contractAddress}')
18+
async getStorage(
19+
@Path() contractAddress: string,
20+
@Query('startBlock') startBlock: number,
21+
@Query('endBlock') endBlock: number,
22+
@Query('blockchainHost') blockchainHost?: string,
23+
@Query('blockchainProtocol') blockchainProtocol?: string,
24+
@Query('blockchainBasicAuthUsername') blockchainBasicAuthUsername?: string,
25+
@Query('blockchainBasicAuthPassword') blockchainBasicAuthPassword?: string,
26+
@Query('existingStorage') existingStorage?: string
27+
) {
28+
try {
29+
const config = {
30+
blockchainHost,
31+
blockchainProtocol,
32+
blockchainBasicAuthUsername,
33+
blockchainBasicAuthPassword
34+
} as Web3Configuration
35+
return this.storageRecover.recoverStorage(contractAddress, startBlock, endBlock, config, existingStorage)
36+
} catch (err) {
37+
logger.error(err)
38+
throw new Error(err.message)
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)