@@ -10,81 +10,66 @@ contract DeployFeeVault is Script {
1010 address owner = vm.envAddress ("OWNER " );
1111 bytes32 salt = vm.envOr ("SALT " , bytes32 (0 ));
1212
13- // Optional: Post-deployment configuration
1413 uint32 destinationDomain = uint32 (vm.envOr ("DESTINATION_DOMAIN " , uint256 (0 )));
1514 bytes32 recipientAddress = vm.envOr ("RECIPIENT_ADDRESS " , bytes32 (0 ));
1615 uint256 minimumAmount = vm.envOr ("MINIMUM_AMOUNT " , uint256 (0 ));
1716 uint256 callFee = vm.envOr ("CALL_FEE " , uint256 (0 ));
18- uint256 bridgeShareBps = vm.envOr ("BRIDGE_SHARE_BPS " , uint256 (10000 ));
17+ uint256 bridgeShareBps = vm.envOr ("BRIDGE_SHARE_BPS " , uint256 (0 )); // 0 defaults to 10000 in constructor
1918 address otherRecipient = vm.envOr ("OTHER_RECIPIENT " , address (0 ));
2019 // ===================================
2120
22- // Compute address before deployment
23- address predicted = computeAddress (salt, owner);
24- console.log ("Predicted FeeVault address: " , predicted);
25-
2621 vm.startBroadcast ();
2722
2823 // Deploy FeeVault with CREATE2
29- FeeVault feeVault = new FeeVault {salt: salt}(owner);
30- console.log ("FeeVault deployed at: " , address (feeVault));
31- require (address (feeVault) == predicted, "Address mismatch " );
32-
33- // Configure if values provided
34- if (destinationDomain != 0 && recipientAddress != bytes32 (0 )) {
35- feeVault.setRecipient (destinationDomain, recipientAddress);
36- console.log ("Recipient set - domain: " , destinationDomain);
37- }
38-
39- if (minimumAmount > 0 ) {
40- feeVault.setMinimumAmount (minimumAmount);
41- console.log ("Minimum amount set: " , minimumAmount);
42- }
43-
44- if (callFee > 0 ) {
45- feeVault.setCallFee (callFee);
46- console.log ("Call fee set: " , callFee);
47- }
48-
49- if (bridgeShareBps != 10000 ) {
50- feeVault.setBridgeShare (bridgeShareBps);
51- console.log ("Bridge share set: " , bridgeShareBps, "bps " );
52- }
53-
54- if (otherRecipient != address (0 )) {
55- feeVault.setOtherRecipient (otherRecipient);
56- console.log ("Other recipient set: " , otherRecipient);
57- }
24+ FeeVault feeVault = new FeeVault {salt: salt}(
25+ owner, destinationDomain, recipientAddress, minimumAmount, callFee, bridgeShareBps, otherRecipient
26+ );
5827
5928 vm.stopBroadcast ();
6029
30+ console.log ("FeeVault deployed at: " , address (feeVault));
31+ console.log ("Owner: " , owner);
32+ console.log ("Destination domain: " , destinationDomain);
33+ console.log ("Minimum amount: " , minimumAmount);
34+ console.log ("Call fee: " , callFee);
35+ console.log ("Bridge share bps: " , feeVault.bridgeShareBps ());
6136 console.log ("" );
6237 console.log ("NOTE: Call setHypNativeMinter() after deploying HypNativeMinter " );
6338 }
64-
65- /// @notice Compute the CREATE2 address for FeeVault deployment
66- function computeAddress (bytes32 salt , address owner ) public view returns (address ) {
67- bytes32 bytecodeHash = keccak256 (abi.encodePacked (type (FeeVault).creationCode, abi.encode (owner)));
68- return address (uint160 (uint256 (keccak256 (abi.encodePacked (bytes1 (0xff ), address (this ), salt, bytecodeHash)))));
69- }
7039}
7140
72- /// @notice Standalone script to compute FeeVault address without deploying
41+ /// @notice Compute FeeVault CREATE2 address off-chain
42+ /// @dev Use this to predict the address before deploying
43+ /// Requires env vars: DEPLOYER (EOA), OWNER, SALT (optional), and all constructor args
7344contract ComputeFeeVaultAddress is Script {
7445 function run () external view {
75- address owner = vm.envAddress ("OWNER " );
76- bytes32 salt = vm.envOr ("SALT " , bytes32 (0 ));
7746 address deployer = vm.envAddress ("DEPLOYER " );
47+ bytes32 salt = vm.envOr ("SALT " , bytes32 (0 ));
48+
49+ address owner = vm.envAddress ("OWNER " );
50+ uint32 destinationDomain = uint32 (vm.envOr ("DESTINATION_DOMAIN " , uint256 (0 )));
51+ bytes32 recipientAddress = vm.envOr ("RECIPIENT_ADDRESS " , bytes32 (0 ));
52+ uint256 minimumAmount = vm.envOr ("MINIMUM_AMOUNT " , uint256 (0 ));
53+ uint256 callFee = vm.envOr ("CALL_FEE " , uint256 (0 ));
54+ uint256 bridgeShareBps = vm.envOr ("BRIDGE_SHARE_BPS " , uint256 (0 ));
55+ address otherRecipient = vm.envOr ("OTHER_RECIPIENT " , address (0 ));
7856
79- bytes32 bytecodeHash = keccak256 (abi.encodePacked (type (FeeVault).creationCode, abi.encode (owner)));
57+ bytes32 initCodeHash = keccak256 (
58+ abi.encodePacked (
59+ type (FeeVault).creationCode,
60+ abi.encode (
61+ owner, destinationDomain, recipientAddress, minimumAmount, callFee, bridgeShareBps, otherRecipient
62+ )
63+ )
64+ );
8065
8166 address predicted =
82- address (uint160 (uint256 (keccak256 (abi.encodePacked (bytes1 (0xff ), deployer, salt, bytecodeHash )))));
67+ address (uint160 (uint256 (keccak256 (abi.encodePacked (bytes1 (0xff ), deployer, salt, initCodeHash )))));
8368
8469 console.log ("========== FeeVault Address Computation ========== " );
70+ console.log ("Deployer (EOA): " , deployer);
8571 console.log ("Owner: " , owner);
8672 console.log ("Salt: " , vm.toString (salt));
87- console.log ("Deployer: " , deployer);
8873 console.log ("Predicted address: " , predicted);
8974 console.log ("================================================== " );
9075 }
0 commit comments