ethereum-web3-plus
Advanced tools
Comparing version 0.4.3 to 0.4.4
{ | ||
"name": "ethereum-web3-plus", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"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.20.4" | ||
"web3": "^0.20.7" | ||
}, | ||
@@ -20,0 +20,0 @@ "repository": { |
@@ -253,2 +253,5 @@ # Documentation page for ethereum-web3-plus | ||
### v 0.4.4 | ||
- Adjustment of the compiler bin and abi file loading to handle solcjs file names that includes the solidity file. | ||
### v 0.4.3 | ||
@@ -297,3 +300,2 @@ - 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. | ||
### v 0.2.6 and v 0.2.5 | ||
@@ -300,0 +302,0 @@ - Documentation corrections |
@@ -97,6 +97,19 @@ | ||
} | ||
function resolveFile(basefolder, contract) { | ||
const fs=require("fs"); | ||
// check contract exists as is in the folder | ||
if (fs.existsSync(path.resolve(basefolder,contract+".abi")) ) return contract; | ||
// if not check if there is a file that ends with the contract name. solcjs does prefix the files with the solidity file name and I want to ignore this | ||
files=fs.readdirSync(basefolder); | ||
files=files.filter( file => file.endsWith('_'+contract+'.abi') ); | ||
if (files.length>0) return files[0].replace('.abi',''); else return null; | ||
} | ||
SolidityCompiler.prototype.load = function(contract) { | ||
const fs=require("fs"); | ||
if(! fs.existsSync(solidityFolder)) throw new Error("a folder "+solidityFolder+" is expected to locate the contract abi and binary" ); | ||
const abifile = path.resolve(solidityFolder,contract+".abi"); | ||
const contractFile = resolveFile(solidityFolder, contract); | ||
if(!contractFile) throw new Error("check you have compiled contract "+contract+"!"); | ||
const abifile = path.resolve(solidityFolder,contractFile+".abi"); | ||
if(fs.existsSync(abifile)) { | ||
@@ -111,3 +124,3 @@ const abi = JSON.parse(fs.readFileSync(abifile)); | ||
//this.LibToken[contract]= ("__"+obj.substr(0,36)+"_".repeat(38)).substr(0,40); // 40 is the size of the target address | ||
const binfile= path.resolve(solidityFolder, contract+".bin"); | ||
const binfile= path.resolve(solidityFolder, contractFile+".bin"); | ||
if(fs.existsSync(binfile)) { | ||
@@ -150,2 +163,3 @@ const code="0x"+fs.readFileSync(binfile).toString(); | ||
} catch (error) { | ||
console.error("Failed loading contract "+contract+" due to error "+error) | ||
return null; | ||
@@ -159,2 +173,3 @@ } | ||
} catch (error) { | ||
console.error("Failed loading contract "+contract+" due to error "+error) | ||
return null; | ||
@@ -161,0 +176,0 @@ } |
49172
608
327
3
Updatedweb3@^0.20.7