diff options
author | Fabio Berger <me@fabioberger.com> | 2018-11-22 05:19:31 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-11-22 05:19:31 +0800 |
commit | 83a043e6397421db0d1d5b8059341b84eeb1e1a7 (patch) | |
tree | b7685c0285283ebce73786a2e8b0ff0996eeb243 /packages/web3-wrapper/src/web3_wrapper.ts | |
parent | 8175192f60e2c2827f6e7d664fbe8bf2d9ddee9c (diff) | |
parent | f46a49fd13c88dd86c9661d76bace18844642c04 (diff) | |
download | dexon-sol-tools-master.tar dexon-sol-tools-master.tar.gz dexon-sol-tools-master.tar.bz2 dexon-sol-tools-master.tar.lz dexon-sol-tools-master.tar.xz dexon-sol-tools-master.tar.zst dexon-sol-tools-master.zip |
Merge branch 'development'master
* development: (81 commits)
Publish
Updated CHANGELOGS
print out error message and stack
immediately return the patch incremented version if no changelog entries exist
Put python package above TS/JS packages
Reduce title size
reduce text side in README
Improve top-level README
Fix prettier
remove unused flag
Add CHANGELOG entry
Fix additional comments
Improve comments
Add migrations, contract-addresses and contract-artifacts to Developers home
Create migrations doc reference page
Add additional CHANGELOG to types package
Add CHANGELOG entry
Fix prettier
Fix `SimpleContractArtifact` type
Update abi-gen-wrappers
...
Diffstat (limited to 'packages/web3-wrapper/src/web3_wrapper.ts')
-rw-r--r-- | packages/web3-wrapper/src/web3_wrapper.ts | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index be1713f20..f1247e48a 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -27,6 +27,7 @@ import { BlockWithoutTransactionDataRPC, BlockWithTransactionDataRPC, NodeType, + TransactionReceiptRPC, TransactionRPC, Web3WrapperErrors, } from './types'; @@ -212,20 +213,23 @@ export class Web3Wrapper { return networkId; } /** - * Retrieves the transaction receipt for a given transaction hash + * Retrieves the transaction receipt for a given transaction hash if found * @param txHash Transaction hash - * @returns The transaction receipt, including it's status (0: failed, 1: succeeded or undefined: not found) + * @returns The transaction receipt, including it's status (0: failed, 1: succeeded). Returns undefined if transaction not found. */ - public async getTransactionReceiptAsync(txHash: string): Promise<TransactionReceipt> { + public async getTransactionReceiptIfExistsAsync(txHash: string): Promise<TransactionReceipt | undefined> { assert.isHexString('txHash', txHash); - const transactionReceipt = await this.sendRawPayloadAsync<TransactionReceipt>({ + const transactionReceiptRpc = await this.sendRawPayloadAsync<TransactionReceiptRPC>({ method: 'eth_getTransactionReceipt', params: [txHash], }); - if (!_.isNull(transactionReceipt)) { - transactionReceipt.status = Web3Wrapper._normalizeTxReceiptStatus(transactionReceipt.status); + if (!_.isNull(transactionReceiptRpc)) { + transactionReceiptRpc.status = Web3Wrapper._normalizeTxReceiptStatus(transactionReceiptRpc.status); + const transactionReceipt = marshaller.unmarshalTransactionReceipt(transactionReceiptRpc); + return transactionReceipt; + } else { + return undefined; } - return transactionReceipt; } /** * Retrieves the transaction data for a given transaction @@ -572,8 +576,8 @@ export class Web3Wrapper { assert.isNumber('timeoutMs', timeoutMs); } // Immediately check if the transaction has already been mined. - let transactionReceipt = await this.getTransactionReceiptAsync(txHash); - if (!_.isNull(transactionReceipt) && !_.isNull(transactionReceipt.blockNumber)) { + let transactionReceipt = await this.getTransactionReceiptIfExistsAsync(txHash); + if (!_.isUndefined(transactionReceipt) && !_.isNull(transactionReceipt.blockNumber)) { const logsWithDecodedArgs = _.map( transactionReceipt.logs, this.abiDecoder.tryToDecodeLogOrNoop.bind(this.abiDecoder), @@ -600,8 +604,8 @@ export class Web3Wrapper { return reject(Web3WrapperErrors.TransactionMiningTimeout); } - transactionReceipt = await this.getTransactionReceiptAsync(txHash); - if (!_.isNull(transactionReceipt)) { + transactionReceipt = await this.getTransactionReceiptIfExistsAsync(txHash); + if (!_.isUndefined(transactionReceipt)) { intervalUtils.clearAsyncExcludingInterval(intervalId); const logsWithDecodedArgs = _.map( transactionReceipt.logs, |