trufflesuite / truffle-migrate

On-chain migrations management
17 stars 17 forks source link

Fix support for contracts from npm packages due to import_path normalization bug #25

Closed pkieltyka closed 6 years ago

pkieltyka commented 6 years ago

Ref: trufflesuite/truffle#901

PR #18 normalized the caching key for artifacts but was too aggressive with the normalization. Instead of trimming the ".sol" it would also trim the entire path including an external package name when used in a migration to link to an outside package with a contract such as

var OtherContract = artifacts.require('other/contracts/OtherContract')

the current code post v4.1.3 and a bug that remains in the latest release, will normalize the above import_path to "OtherContract".

this is problematic because in the truffle-resolver of the NPM code, https://github.com/trufflesuite/truffle-resolver/blob/develop/npm.js#L17 the package_name is parsed from the import_path, which in this case is being clobbered, and as a result OtherContract is unable to be found, breaking support for contracts from npm packages

this PR fixes it by only trimming the .sol extension and leaving the import_path otherwise untouched