frangio / hardhat-exposed

Automatically expose internal Solidity functions for smart contract testing.
82 stars 13 forks source link

Payable internal functions #13

Open HardlyDifficult opened 1 year ago

HardlyDifficult commented 1 year ago

Could we make the exposed library functions payable?

I have an internal library function that considers msg.value, the library function itself cannot by payable (and it wouldn't be require). But to test this library call, I need to be able to pass value. It seems like it would be okay to make all exposed library calls payable so that tests have the option of specifying a value.

e.g. current output:

function $transferFunds(address paymentToken,address from,address to,uint256 amount) external { ... }

Desired:

function $transferFunds(address paymentToken,address from,address to,uint256 amount) external payable { ... }

Just started toying around with this plugin, seems super useful - thanks!

frangio commented 1 year ago

I think this makes a lot of sense because all library functions can use msg.value.

HardlyDifficult commented 1 year ago

Thanks for the fast turn around - that change worked great.

I realize now though that this applies to internal functions as well. Same problem where they cannot be payable in code, but can work with msg.value.