provable-things / ethereum-api

Provable API for Ethereum smart contracts
https://docs.provable.xyz/#ethereum
MIT License
801 stars 428 forks source link

EthPM module does not have the correct contracts #18

Closed rhlsthrm closed 7 years ago

rhlsthrm commented 7 years ago

Only the usingOraclize.sol contract gets installed through EthPM. This should be updated to include all the necessary contracts.

marcogiglio commented 7 years ago

Hi @rhlsthrm, I am not sure for which use case you would need them. I presume you are refering to the Oraclize Connector and Address Resolver contracts. Those haven't been included because their deployment to a local chain instance (e.g testrpc) is handled by the ethereum-bridge, while the oraclizeAPI and your contract code are compiled and deployed via Truffle.

rhlsthrm commented 7 years ago

I'm not sure I understand. I am referring to oraclizeAPI. If I do truffle install oraclize, I see there are contracts which get installed under the installed_contracts directory. Following the instructions provided by truffle to (consume installed contracts)[http://truffleframework.com/docs/getting_started/packages-ethpm#consuming-installed-contracts], I declare the following import:

pragma solidity ^0.4.2;
import "oraclize/oraclizeAPI.sol";

contract MyContract is usingOraclize {
    ...
}

However, when I use truffle compile, the compilation fails:

Error: Could not find oraclize/oraclizeAPI.sol from any sources; imported from <...>
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:49111:23
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:60660:16
    at next (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:69109:18)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:49099:7
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:96498:5
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:69014:16
    at replenish (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:60630:25)
    at iterateeCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:60620:17)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:60660:16
    at ReadFileContext.callback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:96494:14)

I looked and the oraclizeAPI is not in the installed contracts. Is there anything else I need to do to make this work?

marcogiglio commented 7 years ago

It's a limitation of Ethpm, the name of the file must be the same as the name of the contract. Therefore the correct line way to import the contract is:

pragma solidity ^0.4.2;
import "oraclize/usingOraclize.sol";

contract MyContract is usingOraclize {
    ...
}