Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

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

Open
juanfranblanco opened this issue May 2, 2016 · 7 comments

Comments

@juanfranblanco
Copy link
Contributor

Following discussions with @chriseth on the imports format for the EIP 82. ethereum/EIPs#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.

@juanfranblanco juanfranblanco changed the title EIP 82 Local packages paths imports to be in the format of './auth.sol', package dependencies imports will follow the current format EIP 82 Local packages paths imports to be in the format of './auth.sol' May 2, 2016
@nmushegian
Copy link
Member

👍 @ryepdx @mhhf who is up to the challenge??

@mhhf
Copy link
Member

mhhf commented May 3, 2016

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
Copy link
Member

nmushegian commented May 3, 2016

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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Contributor Author

juanfranblanco commented May 4, 2016

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
Copy link
Member

mhhf commented May 4, 2016

will include this asap in the next version

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants