aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-06-09 02:18:32 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-06-09 05:56:45 +0800
commit760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36 (patch)
tree05911f7eaa9cd8a48448b371f46186d2ffc5541e /packages/web3-wrapper
parent817c332d11835f02726f0609374d1c25c9ab39b5 (diff)
downloaddexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar
dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.gz
dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.bz2
dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.lz
dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.xz
dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.zst
dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.zip
Implement SolidityProfiler & adapt sol-cov to work with Geth
Diffstat (limited to 'packages/web3-wrapper')
-rw-r--r--packages/web3-wrapper/CHANGELOG.json12
-rw-r--r--packages/web3-wrapper/src/web3_wrapper.ts41
2 files changed, 48 insertions, 5 deletions
diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json
index 54a816e23..35a8e2c05 100644
--- a/packages/web3-wrapper/CHANGELOG.json
+++ b/packages/web3-wrapper/CHANGELOG.json
@@ -3,6 +3,18 @@
"version": "0.7.0",
"changes": [
{
+ "note": "Add `web3Wrapper.getContractCodeAsync`",
+ "pr": 675
+ },
+ {
+ "note": "Add `web3Wrapper.getTransactionTraceAsync`",
+ "pr": 675
+ },
+ {
+ "note": "Add `web3Wrapper.getBlockWithTransactionDataAsync`",
+ "pr": 675
+ },
+ {
"note": "Add exported uniqueVersionIds object",
"pr": 622
},
diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts
index 559bf3ea9..ecb400656 100644
--- a/packages/web3-wrapper/src/web3_wrapper.ts
+++ b/packages/web3-wrapper/src/web3_wrapper.ts
@@ -2,6 +2,7 @@ import { AbiDecoder, addressUtils, BigNumber, intervalUtils, promisify } from '@
import {
BlockParam,
BlockWithoutTransactionData,
+ BlockWithTransactionData,
CallData,
ContractAbi,
FilterObject,
@@ -10,8 +11,10 @@ import {
LogEntry,
Provider,
RawLogEntry,
+ TraceParams,
TransactionReceipt,
TransactionReceiptWithDecodedLogs,
+ TransactionTrace,
TxData,
} from 'ethereum-types';
import * as _ from 'lodash';
@@ -187,11 +190,22 @@ export class Web3Wrapper {
* @returns Whether or not contract code was found at the supplied address
*/
public async doesContractExistAtAddressAsync(address: string): Promise<boolean> {
- const code = await promisify<string>(this._web3.eth.getCode)(address);
+ const code = await this.getContractCodeAsync(address);
// Regex matches 0x0, 0x00, 0x in order to accommodate poorly implemented clients
const isCodeEmpty = /^0x0{0,40}$/i.test(code);
return !isCodeEmpty;
}
+ public async getContractCodeAsync(address: string): Promise<string> {
+ const code = await promisify<string>(this._web3.eth.getCode)(address);
+ return code;
+ }
+ public async getTransactionTraceAsync(txHash: string, traceParams: TraceParams): Promise<TransactionTrace> {
+ const trace = await this._sendRawPayloadAsync<TransactionTrace>({
+ method: 'debug_traceTransaction',
+ params: [txHash, traceParams],
+ });
+ return trace;
+ }
/**
* Sign a message with a specific address's private key (`eth_sign`)
* @param address Address of signer
@@ -211,13 +225,30 @@ export class Web3Wrapper {
return blockNumber;
}
/**
- * Fetch a specific Ethereum block
+ * Fetch a specific Ethereum block without transaction data
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The requested block without transaction data
*/
public async getBlockAsync(blockParam: string | BlockParam): Promise<BlockWithoutTransactionData> {
- const block = await promisify<BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam);
- return block;
+ const shouldIncludeTransactionData = false;
+ const blockWithoutTransactionData = await promisify<BlockWithoutTransactionData>(this._web3.eth.getBlock)(
+ blockParam,
+ shouldIncludeTransactionData,
+ );
+ return blockWithoutTransactionData;
+ }
+ /**
+ * Fetch a specific Ethereum block with transaction data
+ * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
+ * @returns The requested block with transaction data
+ */
+ public async getBlockWithTransactionDataAsync(blockParam: string | BlockParam): Promise<BlockWithTransactionData> {
+ const shouldIncludeTransactionData = true;
+ const blockWithTransactionData = await promisify<BlockWithTransactionData>(this._web3.eth.getBlock)(
+ blockParam,
+ shouldIncludeTransactionData,
+ );
+ return blockWithTransactionData;
}
/**
* Fetch a block's timestamp
@@ -469,4 +500,4 @@ export class Web3Wrapper {
const decimal = this._web3.toDecimal(hex);
return decimal;
}
-}
+} // tslint:disable-line:max-file-line-count