foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat: getCode for linked contracts

Open jparklev opened this issue 2 years ago • 3 comments

Component

Forge

Describe the feature you would like

This is quite a niche feature request, I think. But currently it's not possible to use the getCode cheatcode with contracts that have linked libraries, so you can't import a local contract using a different solidity version in your tests if it's using one.

Additional context

The specific use case I ran into was importing a Balancer pool (0.7.6) that implemented an oracle using Balancer's query processor library into a testing suite of a newer project (0.8.11).

jparklev avatar Apr 01 '22 05:04 jparklev

This adds a lot of complexity to getCode. Right now it's a pretty simple "find the artifact, extract the bytecode" which requires close to 0 knowledge of how the project is structured and what was compiled.

This change would require a lot of information about the project, such as what contracts were compiled, which ones are unlinked, what the bytecode is of those libraries and then linking them.

Since this is hard I'm marking it https://github.com/gakonst/foundry/labels/D-hard and since the problem is pretty niche, I'm marking this as https://github.com/gakonst/foundry/labels/P-low

Is there any way you can achieve what you want to achieve without using getCode? The primary use case for getCode (I think, at least) is importing non-Solidity contracts

onbjerg avatar Apr 01 '22 21:04 onbjerg

Since this is hard I'm marking it D-hard and since the problem is pretty niche, I'm marking this as P-low

Yea, sounds v reasonable to me

Is there any way you can achieve what you want to achieve without using getCode?

Since the contract i'm testing against is now live on mainnet, i'm interacting with the deployed code using a mainnet fork, which mostly meets my needs here ~

The primary use case for getCode (I think, at least) is importing non-Solidity contracts

Ahh I think it was added for different compiler versions as well! https://github.com/gakonst/foundry/issues/326

jparklev avatar Apr 01 '22 21:04 jparklev

@onbjerg assign this to me, btw wthat's the final decision create a new cheatcode or modify getcode

malik672 avatar Feb 13 '24 09:02 malik672