Skip to content

Commit d5287aa

Browse files
committed
feat: add proxy deployment also
1 parent 673d8f5 commit d5287aa

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

script/Deploy.s.sol

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,33 @@
22
pragma solidity ^0.8.13;
33

44
import {AlchemyProxyLoader} from "../src/AlchemyProxyLoader.sol";
5+
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
56
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
67
import {Script} from "forge-std/Script.sol";
78

89
contract DeployScript is Script {
910
address public create2Factory = address(0);
1011
address public proxyLoaderOwner = 0xDdF32240B4ca3184De7EC8f0D5Aba27dEc8B7A5C;
11-
address public expectedDeployAddress = 0xea8ea085589afBA8C5DA2808F150AC14fA10BA78;
12+
address public expectedDeployAddress = 0x658ce9D45885BCE9682e5c07c9E7982610c7aB37;
13+
14+
bytes32 public proxySalt = 0; // TODO
15+
address public proxyAddress = address(0); // TODO
1216

1317
function run() public {
14-
address deployed = address(new AlchemyProxyLoader{salt: 0}(proxyLoaderOwner));
18+
address proxyLoader = address(new AlchemyProxyLoader{salt: 0}(proxyLoaderOwner));
19+
20+
if (proxyLoader != expectedDeployAddress) {
21+
revert(
22+
string(
23+
abi.encodePacked("Proxy loader deployed to: ", proxyLoader, " instead of ", expectedDeployAddress)
24+
)
25+
);
26+
}
27+
28+
address proxy = address(new ERC1967Proxy{salt: proxySalt}(proxyLoader, ""));
1529

16-
if (deployed != expectedDeployAddress) {
17-
revert(string(abi.encodePacked("Attempted to deploy to address: ", deployed)));
30+
if (proxy != proxyAddress) {
31+
revert(string(abi.encodePacked("Proxy deployed to: ", proxy, " instead of ", proxyAddress)));
1832
}
1933
}
2034
}

test/AlchemyProxyLoader.t.sol

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,23 @@ contract AlchemyProxyLoaderTest is Test {
5454

5555
function test_getDeployedAddress() public pure {
5656
bytes32 bytecodeHash = keccak256(
57-
abi.encode(
57+
abi.encodePacked(
5858
type(AlchemyProxyLoader).creationCode,
5959
bytes32(uint256(uint160(0xDdF32240B4ca3184De7EC8f0D5Aba27dEc8B7A5C)))
6060
)
6161
);
6262

6363
address predicted = Create2.computeAddress(bytes32(0), bytecodeHash, CREATE2_FACTORY);
64-
assertEq(predicted, 0xea8ea085589afBA8C5DA2808F150AC14fA10BA78);
64+
assertEq(predicted, 0x658ce9D45885BCE9682e5c07c9E7982610c7aB37);
65+
}
66+
67+
function test_getDeployedProxyInitcode() public pure {
68+
bytes32 bytecodeHash = keccak256(
69+
abi.encodePacked(
70+
type(ERC1967Proxy).creationCode,
71+
abi.encodePacked(address(0xea8ea085589afBA8C5DA2808F150AC14fA10BA78), "")
72+
)
73+
);
74+
assertEq(bytecodeHash, 0xb3fd145a437320ebc1cf7ad1887a3a263ce4003431505352568badf1e3be92cc);
6575
}
6676
}

0 commit comments

Comments
 (0)