Move deployer to src so we can install with forge install
PatrickAlphaC opened this issue · 4 comments
Potentially have the vyperlang org fork this? Would be cool to contribute to this there.
Thoughts?
And maybe change the name to foundry-vyper
In any case, let me know if you want some help supporting this, happy to help
Sort of just leaving notes here, sorry.
Let me know if you like some of the changes: https://github.com/PatrickAlphaC/foundry-vyper
Hey, yeah I would be more than happy to integrate this into the Vyperlang org. Thats actually what we did for the Huff language org as well.
Enabling installation with forge install
is a great idea, I'm open to anything that makes the repo more accessible/easy to use.
I checked out your fork and the readme looks solid. I would be happy to merge your fork and work together on it. If the Vyperlang org would like it under their account, I am more than happy to port to a version over there or migrate this repo over.
Sort of just leaving notes here, sorry.
Let me know if you like some of the changes: https://github.com/PatrickAlphaC/foundry-vyper
Hey after taking a look I've got a few suggestions, first I think we should change the name of VyperDeployer.sol
-> VyperTest.sol
and rewrite the file to look something like this:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
abstract contract VyperTest is Test {
function compileVyper(
string memory fileLocation
) public returns (bytes memory byteCode) {
string[] memory cmds = new string[](2);
cmds[0] = "vyper";
cmds[1] = fileLocation;
return vm.ffi(cmds);
}
function compileVyper(
string memory fileLocation,
bytes memory args
) public returns (bytes memory byteCodeWithArgs) {
string[] memory cmds = new string[](2);
cmds[0] = "vyper";
cmds[1] = fileLocation;
return abi.encodePacked(vm.ffi(cmds), args);
}
function deployByteCode(
bytes memory vyperByteCode
) public returns (address contractAddr) {
assembly {
contractAddr := create(0, add(vyperByteCode, 0x20), mload(vyperByteCode))
}
require(
contractAddr != address(0) && contractAddr.code.length > 0,
"Vyper contract deployment failed"
);
}
function deployContract(
string memory fileLocation
) public returns (address contractAddr) {
return deployByteCode(compileVyper(fileLocation));
}
function deployContract(
string memory fileLocation,
bytes memory args
) public returns (address contractAddr) {
return deployByteCode(compileVyper(fileLocation, args));
}
}
This would let users import and inherit VyperTest.sol
that inherits forge-std/Test.sol
which would give easy access to both Vyper deployment functionality and the regular test methods/cheats.