File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ pragma solidity ^0.8.13;
4
4
import {Test, console} from "forge-std/Test.sol " ;
5
5
import {AlchemyProxyLoader} from "../src/AlchemyProxyLoader.sol " ;
6
6
import {ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol " ;
7
+ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol " ;
7
8
8
9
contract AlchemyProxyLoaderTest is Test {
9
10
AlchemyProxyLoader public proxyRegistry;
@@ -50,4 +51,16 @@ contract AlchemyProxyLoaderTest is Test {
50
51
function _getImplementation (address proxy ) internal view returns (address ) {
51
52
return address (uint160 (uint256 (vm.load (address (proxy), _PROXY_IMPL_SLOT))));
52
53
}
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
+ }
53
66
}
You can’t perform that action at this time.
0 commit comments