aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-13 10:24:00 +0800
committerGitHub <noreply@github.com>2017-11-13 10:24:00 +0800
commita74ec0effa818a86233fe64cb0dad2c61bbb4bb6 (patch)
tree24438eda01318a80b5cbc7f1939d1640764a9859 /src/web3_wrapper.ts
parentb0be323e899ea7be42b6c695b4fd6d526070b213 (diff)
parente33027c6244b99a1fb181404668bd2a259d923e2 (diff)
downloaddexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.tar
dexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.tar.gz
dexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.tar.bz2
dexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.tar.lz
dexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.tar.xz
dexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.tar.zst
dexon-sol-tools-a74ec0effa818a86233fe64cb0dad2c61bbb4bb6.zip
Merge pull request #200 from 0xProject/feature/receipt-status
Normalize the way we return the transaction status
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index d03c102b2..c937f9288 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import BigNumber from 'bignumber.js';
import promisify = require('es6-promisify');
-import {ZeroExError, Artifact} from './types';
+import {ZeroExError, Artifact, TransactionReceipt} from './types';
import {Contract} from './contract';
export class Web3Wrapper {
@@ -37,8 +37,9 @@ export class Web3Wrapper {
const nodeVersion = await promisify(this.web3.version.getNode)();
return nodeVersion;
}
- public async getTransactionReceiptAsync(txHash: string): Promise<Web3.TransactionReceipt> {
+ public async getTransactionReceiptAsync(txHash: string): Promise<TransactionReceipt> {
const transactionReceipt = await promisify(this.web3.eth.getTransactionReceipt)(txHash);
+ transactionReceipt.status = this.normalizeTxReceiptStatus(transactionReceipt.status);
return transactionReceipt;
}
public getCurrentProvider(): Web3.Provider {
@@ -154,4 +155,18 @@ export class Web3Wrapper {
const result = response.result;
return result;
}
+ private normalizeTxReceiptStatus(status: undefined|null|string|0|1): null|0|1 {
+ // Transaction status might have four values
+ // undefined - Testrpc and other old clients
+ // null - New clients on old transactions
+ // number - Parity
+ // hex - Geth
+ if (_.isString(status)) {
+ return this.web3.toDecimal(status) as 0|1;
+ } else if (_.isUndefined(status)) {
+ return null;
+ } else {
+ return status;
+ }
+ }
}