aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-25 19:27:10 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-13 04:05:06 +0800
commit50ee23ebfa5270f98c64c8be5ba4a7061c47bc27 (patch)
tree8be0036bef63e9c15fd31744f0db303227af1e13 /src/web3_wrapper.ts
parent719c51f61a65e3e179ba2a78fa48105247ba2b41 (diff)
downloaddexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.tar
dexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.tar.gz
dexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.tar.bz2
dexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.tar.lz
dexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.tar.xz
dexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.tar.zst
dexon-sol-tools-50ee23ebfa5270f98c64c8be5ba4a7061c47bc27.zip
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 3b1e4477b..56b08ebec 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 {
@@ -31,8 +31,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(status);
return transactionReceipt;
}
public getCurrentProvider(): Web3.Provider {
@@ -144,4 +145,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;
+ }
+ }
}