Skip to content

Commit

Permalink
Support more recent web3 versions
Browse files Browse the repository at this point in the history
They put the Contract's address on `.address`, instead of `._address`.
  • Loading branch information
Fang- committed Apr 18, 2019
1 parent 67d5a3d commit 27ac422
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,25 @@ const initContractsPartial = async (web3, azimuthAddress) => {
};
}

const newContract = (web3, address, abi) => {
let contract = new web3.eth.Contract(abi, address);
//NOTE this allows us to support a broader range of web3 versions.
// see also #23.
contract._address = (contract._address || contract.address);
return contract;
}

const newEcliptic = (web3, address) =>
new web3.eth.Contract(eclipticAbi, address);
newContract(web3, address, eclipticAbi);

const newAzimuth = (web3, address) =>
new web3.eth.Contract(azimuthAbi, address);
newContract(web3, address, azimuthAbi);

const newPolls = (web3, address) =>
new web3.eth.Contract(pollsAbi, address);
newContract(web3, address, pollsAbi);

const newLinearStarRelease = (web3, address) =>
new web3.eth.Contract(linearStarReleaseAbi, address);
newContract(web3, address, linearStarReleaseAbi);

module.exports = {
initContracts,
Expand Down

0 comments on commit 27ac422

Please sign in to comment.