-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement interfaces in mock tokens #510
Conversation
Thanks for your PR :) What is the benefit of having them inherit from the interfaces? This feels like a nontrivial diff that adds code for unclear benefit, since these ERC interfaces are finalized and static, and the mocks are already compliant. I'd like to keep everything in forge-std as simple as possible so it's easy to read/maintain and to reduce compilation times. I'm also not a fan of making the variables private since that limits devs from inheriting the mock and adding e.g. new methods to set approvals |
It is unintuitive for there to be an interface as well as an implementation of that interface in the same repo but them not be tied together at all. I came across this when using the interface and the mock token in a situation shown below:
It is highly preferred for the below to work:
|
That would be really nice but I don't think that is supported since solidity doesn't have structural typing: https://forum.soliditylang.org/t/making-interfaces-structural/1790 import {MockERC20} from "../src/mocks/MockERC20.sol";
import {IERC20} from "../src/interfaces/IERC20.sol";
import {Test} from "../src/Test.sol";
contract ATest is Test {
IERC20 public token;
function setUp() public {
IERC20 fromToken;
fromToken = new MockERC20();
}
}
|
@mds1 Consider running that test in the context of this PR. It works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops you're right, I was on the wrong branch. Ok, agreed that is a much better UX!
Two small changes then we can merge
@mds1 let me know if any other changes are needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Currently
MockERC20
andMockERC721
don't implement their respective interfaces. This PR fixes that.