Socket
Socket
Sign inDemoInstall

ethereum-web3-plus

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-web3-plus - npm Package Compare versions

Comparing version 0.3.2 to 0.4.1

43

index.js

@@ -45,3 +45,3 @@

var name=args.shift(); // extract the name and leave the rest
if(typeof this.solidityCompiler !== 'object') return null; // the compiler has not been created
if(typeof this.solidityCompiler !== 'object') this.solidityCompiler(); // the compiler has not been created
var c = this.solidityCompiler.getContract(name);

@@ -59,3 +59,3 @@ if(!c) return null;

// call the new function. there is no callback so the return value is the TxHash
var tx= this.eth.sendTransaction({data:data, gas:gas});
var tx= this.eth.sendTransaction({data:data, gas:gas+1});
return tx;

@@ -66,3 +66,3 @@ }

Web3.prototype.instanceAt = function(name, address) {
if(typeof this.solidityCompiler !== 'object') return null; // the compiler has not been created
if(typeof this.solidityCompiler !== 'object') this.solidityCompiler(); // the compiler has not been created
var c = this.solidityCompiler.getContract(name);

@@ -111,2 +111,10 @@ if(!c) return null;

/** This is to enable the new field status in the transactionreceipt even if not present in the underlying Geth node */
function upgradeReceipt(receipt) {
if(!receipt) return receipt;
if(typeof receipt.status === 'undefined')
receipt.status=1;
return receipt;
}
var BlockWatcher = function(web3, bindEnvironment) {

@@ -134,3 +142,3 @@ var self=this;

txwait.startBlock=block.number;
txwait.receipt=self.web3.eth.getTransactionReceipt(txHash);
txwait.receipt=upgradeReceipt(self.web3.eth.getTransactionReceipt(txHash));
} // end if tx exists in the wait dictionary

@@ -146,3 +154,3 @@ } // end for each transaction

if(!txwait.receipt && block.number >= txwait.startBlock + 2) {
txwait.receipt=self.web3.eth.getTransactionReceipt(tx);
txwait.receipt=upgradeReceipt(self.web3.eth.getTransactionReceipt(tx));
if(txwait.receipt) txwait.startBlock=txwait.receipt.blockNumber; // update the startBlock

@@ -158,8 +166,10 @@ }

cb_args.push(receipt.contractAddress || receipt.to);
if(txwait.gas<=receipt.gasUsed)
cb_args.push("full gas used:"+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(null); // No error
//if(receipt.status==0) // failure returned
if(txwait.gas<=receipt.gasUsed)
cb_args.push("full gas used:"+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
// remove the txHash from the wait dictionary

@@ -202,3 +212,3 @@ delete self.tx_wait[tx];

this.start = function() {
if(this.filter) { this.filter.stopWatching(); this.filter=null; } // clear any previous watching and filter
this.stop(); // clear any previous watching and filter
if(!this.filter) this.filter = this.web3.eth.filter('latest');

@@ -210,4 +220,3 @@ console.log("Starting the block watcher");

this.stop = function() {
this.filter.stopWatching();
this.filter=null;
if(this.filter) { this.filter.stopWatching(); this.filter=null; }
}

@@ -251,2 +260,8 @@

if(isArray(txHash)) return this.waitForAll.apply(this, arguments);
if(!txHash) { // the first argument is not an existing txHash !!
args.unshift(txHash);
args.push(null);
args.push("not a valid txHash."+txHash);
return callback.apply(null,args);
}
var tx=this.eth.getTransaction(this.toHex(txHash));

@@ -253,0 +268,0 @@ if(!tx) { // the first argument is not an existing txHash !!

{
"name": "ethereum-web3-plus",
"version": "0.3.2",
"version": "0.4.1",
"description": "Adds some simplifications to the web3 package such as compilation, instance creation, call sequencing, events readers",

@@ -17,3 +17,3 @@ "main": "index.js",

"dependencies": {
"web3": "^0.18.2"
"web3": "^0.20.4"
},

@@ -20,0 +20,0 @@ "repository": {

@@ -53,3 +53,3 @@ # Documentation page for ethereum-web3-plus

- A workaround is to create symbolic link to the sources path either from the geth node path or from the root (/)
NOTE: with version 0.3.0, you do not need to compile at runtime but you can use pre-compiled files either generated by this package (see `persist()`) or from solc or another compatible compiler. However, linkeage is still done at runtime to be able to deploy contract code to a production ethereum network with a different library pre-deployed address.
NOTE: from version 0.3.0, you do not need to compile at runtime but you can use pre-compiled files either generated by this package (see `persist()`) or from solc or another compatible compiler. However, linkeage is still done at runtime to be able to deploy contract code to a production ethereum network with a different library pre-deployed address.

@@ -251,2 +251,10 @@ ```js

## Change log
### v 0.4.1
Adaptation for TransactionReceipt.status from geth v1.7.3 used in the waitFor function to signal error
Other minor bug corrections
- Test of for null transaction before trying to get the transaction info
- Auto creation of the solidityCompiler in newInstanceTx and instanceAt
- Adding 1 gas to the newInstanceTx gas estimation to manage older version of geth
- Correcting a bug in the BlockWatcher.stop() caused by possible null filter.
### v 0.3.2

@@ -253,0 +261,0 @@ Correction of the use of environemnt variable process.env.PWD by process.cwd() as the earlier is not available on windows.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc