dapphub / dapple

EVM contract system developer multitool
GNU General Public License v3.0
299 stars 59 forks source link

EIP 82 Local packages paths imports to be in the format of './auth.sol' #238

Open juanfranblanco opened 8 years ago

juanfranblanco commented 8 years ago

Following discussions with @chriseth on the imports format for the EIP 82. https://github.com/ethereum/EIPs/issues/82 he has pointed out that import references to local packages should follow the format './'.

This will allow for any package to comply the compilation standard as per https://solidity.readthedocs.io/en/latest/layout-of-source-files.html#use-in-actual-compilers.

The compiler will resolve any imports, so there is no need to replace them.

Package dependencies imports will follow the same format.

nmushegian commented 8 years ago

:+1: @ryepdx @mhhf who is up to the challenge??

mhhf commented 8 years ago

I don't understand it fully... Does it mean we have to change to import packages with the ./ prefix aka: ./dappsys/auth.sol? Since dapples contract files are lying in the ./contracts directory and the packages in ./dapple_packages/... we would need to include them with a relative path in order for the solidity compiler to be able to resolve the imports on its own: import "./../dapple_packages/dappsys/auth.sol". If this is the desired behavior, i can include this in the next dapple version.

The import standard also allows to specify path prefix remappings so we could keep using import "dappsys/auth.sol"; as long as we tell the compiler where to find each package: solc dappsys=$DIR/dapple_packages/dappsys authenticated.sol

We can also default to a pkg directory which maps to the local dapple_package directory, with this no manipulation on the solc command needs: solc pkg=$DIR/dapple_packages/ ./* and import them via: import "pkg/dappsys/auth.sol";

nmushegian commented 8 years ago

The ./ prefix is for the files that are simply in the contracts dir tree and not in subpackages. When you exclude the ./ prefix, the first dirname is the package.

Isn't that just like how require works in node?

nmushegian commented 8 years ago

So import pkg/dir/contract.sol would look in dapple_packages/pkg/contracts/dir/contract.sol while import ./pkg/dir/contract.sol would simply look in contracts/pkg/dir/contract.sol (not actually a package)

juanfranblanco commented 8 years ago

I have modified 'feedbase' here as a sample https://github.com/juanfranblanco/feedbase. I have included a 'dapple' package with test.sol and debug.sol, obviously those do nothing.

juanfranblanco commented 8 years ago

This might help you, or confused you.. https://github.com/juanfranblanco/vscode-solidity/blob/master/src/projectService.ts, https://github.com/juanfranblanco/vscode-solidity/blob/master/src/model/contractsCollection.ts Please note until the compiler supports it I am replacing the modules paths with absolute paths on imports.

mhhf commented 8 years ago

will include this asap in the next version