aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper/src/index.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-03-30 01:02:46 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-03-30 01:02:46 +0800
commit665011174bab7cfc6ec53e0044d60e1463222aee (patch)
tree44bc55bd390044d6cbfe8e0f7dddb621a8be7249 /packages/web3-wrapper/src/index.ts
parentd106079d9b69191d9cdc6d9323dbae3e4b45daf2 (diff)
parentc4dd9658e791a9f821ea3b6eb4326bcba53b081a (diff)
downloaddexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.gz
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.bz2
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.lz
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.xz
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.zst
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.zip
Merge branch 'development' into feature/website/wallet-wrap
* development: (35 commits) Fix CHANGELOG Update Yarn.lock Standardize changelog dates and format Fix stubbing of a non-existent property Remove redundant cast Move common types out of web3 types Add monorepo_scripts to npmignore Add typeRoots Add clean-state tests Remove nested .gitignore files since `yarn publish` gets confused by them and ignores their contents on the top-level scope Remove WETH hack now that updated WETH address is in TokenRegistry Revert TokenRegistry address on Kovan Improve rounding error message Portal fill with mixed decimals Add error popover if TokenRegistry on network user is browsing on don't include the requisite default tokens for 0x Portal to function Set timeout for compiler tests Remove redundant types Add missing param comments Fix a comment Add a comment ...
Diffstat (limited to 'packages/web3-wrapper/src/index.ts')
-rw-r--r--packages/web3-wrapper/src/index.ts36
1 files changed, 24 insertions, 12 deletions
diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts
index 2ce2580ee..87c69b269 100644
--- a/packages/web3-wrapper/src/index.ts
+++ b/packages/web3-wrapper/src/index.ts
@@ -1,4 +1,16 @@
-import { RawLogEntry, TransactionReceipt, TxData } from '@0xproject/types';
+import {
+ BlockParam,
+ BlockWithoutTransactionData,
+ CallData,
+ ContractAbi,
+ FilterObject,
+ JSONRPCRequestPayload,
+ JSONRPCResponsePayload,
+ LogEntry,
+ RawLogEntry,
+ TransactionReceipt,
+ TxData,
+} from '@0xproject/types';
import { BigNumber, promisify } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -157,8 +169,8 @@ export class Web3Wrapper {
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The requested block without transaction data
*/
- public async getBlockAsync(blockParam: string | Web3.BlockParam): Promise<Web3.BlockWithoutTransactionData> {
- const block = await promisify<Web3.BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam);
+ public async getBlockAsync(blockParam: string | BlockParam): Promise<BlockWithoutTransactionData> {
+ const block = await promisify<BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam);
return block;
}
/**
@@ -166,7 +178,7 @@ export class Web3Wrapper {
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The block's timestamp
*/
- public async getBlockTimestampAsync(blockParam: string | Web3.BlockParam): Promise<number> {
+ public async getBlockTimestampAsync(blockParam: string | BlockParam): Promise<number> {
const { timestamp } = await this.getBlockAsync(blockParam);
return timestamp;
}
@@ -214,7 +226,7 @@ export class Web3Wrapper {
* @param filter Parameters by which to filter which logs to retrieve
* @returns The corresponding log entries
*/
- public async getLogsAsync(filter: Web3.FilterObject): Promise<Web3.LogEntry[]> {
+ public async getLogsAsync(filter: FilterObject): Promise<LogEntry[]> {
let fromBlock = filter.fromBlock;
if (_.isNumber(fromBlock)) {
fromBlock = this._web3.toHex(fromBlock);
@@ -243,7 +255,7 @@ export class Web3Wrapper {
* @param abi Smart contract ABI
* @returns Web3 contract factory which can create Web3 Contract instances from the supplied ABI
*/
- public getContractFromAbi(abi: Web3.ContractAbi): Web3.Contract<any> {
+ public getContractFromAbi(abi: ContractAbi): Web3.Contract<any> {
const web3Contract = this._web3.eth.contract(abi);
return web3Contract;
}
@@ -252,7 +264,7 @@ export class Web3Wrapper {
* @param txData Transaction data
* @returns Estimated gas cost
*/
- public async estimateGasAsync(txData: Partial<Web3.TxData>): Promise<number> {
+ public async estimateGasAsync(txData: Partial<TxData>): Promise<number> {
const gas = await promisify<number>(this._web3.eth.estimateGas)(txData);
return gas;
}
@@ -262,7 +274,7 @@ export class Web3Wrapper {
* @param defaultBlock Block height at which to make the call. Defaults to `latest`
* @returns The raw call result
*/
- public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise<string> {
+ public async callAsync(callData: CallData, defaultBlock?: BlockParam): Promise<string> {
const rawCallResult = await promisify<string>(this._web3.eth.call)(callData, defaultBlock);
return rawCallResult;
}
@@ -271,13 +283,13 @@ export class Web3Wrapper {
* @param txData Transaction data
* @returns Transaction hash
*/
- public async sendTransactionAsync(txData: Web3.TxData): Promise<string> {
+ public async sendTransactionAsync(txData: TxData): Promise<string> {
const txHash = await promisify<string>(this._web3.eth.sendTransaction)(txData);
return txHash;
}
- private async _sendRawPayloadAsync<A>(payload: Partial<Web3.JSONRPCRequestPayload>): Promise<A> {
+ private async _sendRawPayloadAsync<A>(payload: Partial<JSONRPCRequestPayload>): Promise<A> {
const sendAsync = this._web3.currentProvider.sendAsync.bind(this._web3.currentProvider);
- const response = await promisify<Web3.JSONRPCResponsePayload>(sendAsync)(payload);
+ const response = await promisify<JSONRPCResponsePayload>(sendAsync)(payload);
const result = response.result;
return result;
}
@@ -295,7 +307,7 @@ export class Web3Wrapper {
return status;
}
}
- private _formatLog(rawLog: RawLogEntry): Web3.LogEntry {
+ private _formatLog(rawLog: RawLogEntry): LogEntry {
const formattedLog = {
...rawLog,
logIndex: this._hexToDecimal(rawLog.logIndex),