Skip to content

Commit 673d8f5

Browse files
committed
feat: add deploy script + test for deployed address
1 parent 77d317f commit 673d8f5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

script/Deploy.s.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {AlchemyProxyLoader} from "../src/AlchemyProxyLoader.sol";
5+
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
6+
import {Script} from "forge-std/Script.sol";
7+
8+
contract DeployScript is Script {
9+
address public create2Factory = address(0);
10+
address public proxyLoaderOwner = 0xDdF32240B4ca3184De7EC8f0D5Aba27dEc8B7A5C;
11+
address public expectedDeployAddress = 0xea8ea085589afBA8C5DA2808F150AC14fA10BA78;
12+
13+
function run() public {
14+
address deployed = address(new AlchemyProxyLoader{salt: 0}(proxyLoaderOwner));
15+
16+
if (deployed != expectedDeployAddress) {
17+
revert(string(abi.encodePacked("Attempted to deploy to address: ", deployed)));
18+
}
19+
}
20+
}

test/AlchemyProxyLoader.t.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.8.13;
44
import {Test, console} from "forge-std/Test.sol";
55
import {AlchemyProxyLoader} from "../src/AlchemyProxyLoader.sol";
66
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
7+
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
78

89
contract AlchemyProxyLoaderTest is Test {
910
AlchemyProxyLoader public proxyRegistry;
@@ -50,4 +51,16 @@ contract AlchemyProxyLoaderTest is Test {
5051
function _getImplementation(address proxy) internal view returns (address) {
5152
return address(uint160(uint256(vm.load(address(proxy), _PROXY_IMPL_SLOT))));
5253
}
54+
55+
function test_getDeployedAddress() public pure {
56+
bytes32 bytecodeHash = keccak256(
57+
abi.encode(
58+
type(AlchemyProxyLoader).creationCode,
59+
bytes32(uint256(uint160(0xDdF32240B4ca3184De7EC8f0D5Aba27dEc8B7A5C)))
60+
)
61+
);
62+
63+
address predicted = Create2.computeAddress(bytes32(0), bytecodeHash, CREATE2_FACTORY);
64+
assertEq(predicted, 0xea8ea085589afBA8C5DA2808F150AC14fA10BA78);
65+
}
5366
}

0 commit comments

Comments
 (0)