ethereum-web3-plus
Advanced tools
Comparing version 0.4.2 to 0.4.3
41
index.js
@@ -147,2 +147,9 @@ | ||
// handle the case where the submitted gas was not retrieved when starting waiting. Found the case with Ganache | ||
if(txwait.gas==0) { | ||
var getTx=self.web3.eth.getTransaction(tx); | ||
if(getTx) txwait.gas=getTx.gas; | ||
// else, the txwait.receipt will also be null | ||
} | ||
// to protect against a case where the receipt would not be loaded while available, load it if 2 blocks have passed | ||
@@ -161,12 +168,24 @@ if(!txwait.receipt && block.number >= txwait.startBlock + 2) { | ||
cb_args.push(receipt.contractAddress || receipt.to); | ||
//if(receipt.status==0) // failure returned | ||
if(txwait.gas<=receipt.gasUsed) | ||
cb_args.push("full gas used:"+receipt.gasUsed) | ||
else if(receipt.contractAddress | ||
// test if we are in version where status is implemented | ||
if( receipt.status !== undefined) | ||
if( self.web3.toDecimal(receipt.status) == 1) | ||
cb_args.push(null); // No error | ||
else | ||
if(txwait.gas<=receipt.gasUsed) | ||
cb_args.push("full gas used:"+txwait.gas + "/"+ receipt.gasUsed) | ||
else if(receipt.contractAddress | ||
&& self.web3.eth.getCode(receipt.contractAddress)=="0x") | ||
cb_args.push("created contract has no bytecodes"); | ||
else cb_args.push("Failure has happened. Status="+receipt.status); | ||
else // status is undefined, use old logic | ||
if(txwait.gas<=receipt.gasUsed) | ||
cb_args.push("full gas used:"+txwait.gas + "/"+ receipt.gasUsed) | ||
else if(receipt.contractAddress | ||
&& self.web3.eth.getCode(receipt.contractAddress)=="0x") | ||
cb_args.push("created contract has no bytecodes"); | ||
else if(receipt.status==0) cb_args.push("another failure has happened."); | ||
else cb_args.push(null); // No error | ||
cb_args.push("created contract has no bytecodes"); | ||
else cb_args.push(null); // No error | ||
// remove the txHash from the wait dictionary | ||
delete self.tx_wait[tx]; | ||
delete self.tx_wait[tx]; | ||
// manage the case of a group | ||
@@ -265,6 +284,4 @@ if(txwait.group && txgroup[txwait.group] && txgroup[txwait.group][tx]) { | ||
if(!tx) { // the first argument is not an existing txHash !! | ||
args.unshift(txHash); | ||
args.push(null); | ||
args.push("the provided txHash does not exists in the geth node. Check your code."); | ||
return callback.apply(null,args); | ||
// set the submitted gas to 0 and wait for the block loop to get the transaction gas | ||
tx = {gas:0}; | ||
} | ||
@@ -271,0 +288,0 @@ var gas=tx.gas; // the requested max gas that will be compared to the gasUsed of the transaction receipt |
{ | ||
"name": "ethereum-web3-plus", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Adds some simplifications to the web3 package such as compilation, instance creation, call sequencing, events readers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -100,2 +100,4 @@ # Documentation page for ethereum-web3-plus | ||
### Using the block watcher functionalities | ||
_**NOTE:** The watcher is registered asynchronously but the BlockWatcherStart function returns immediatly. Be aware of this as it may happen that the watcher is initialized after the first transaction is submitted._ | ||
```js | ||
@@ -252,2 +254,7 @@ bw= web3.BlockWatcherStart(func); | ||
### v 0.4.3 | ||
- While testing Ganache, I found different behavior of getTransaction just after submitting a transaction. It does not exists hence the reading of submitted gas should be delayed. | ||
- Correct the implementation of TransactionReceipt.status | ||
- Info: The `web3.BlockWatcherStart()` does not wait for successfull registration of the filter before watching the new blocks. Hence be carefull that you could submit a transaction before the listener is in place and miss it. | ||
### v 0.4.2 | ||
@@ -254,0 +261,0 @@ - Adding a try catch in the block watcher for when the geth api do not return properly |
48198
595
325