@@ -8,30 +8,12 @@ import {LiquidDelegation} from "src/LiquidDelegation.sol";
8
8
import {NonLiquidDelegation} from "src/NonLiquidDelegation.sol " ;
9
9
import {ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol " ;
10
10
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol " ;
11
- import {Console} from "script/Console.sol " ;
11
+ import {Console} from "script/Console.s. sol " ;
12
12
13
13
contract Deploy is Script {
14
14
using Strings for string ;
15
15
16
- function liquidDelegation (string calldata name , string calldata symbol ) external {
17
- uint256 deployerPrivateKey = vm.envUint ("PRIVATE_KEY " );
18
- address owner = vm.addr (deployerPrivateKey);
19
- Console.log ("Signer is %s " , owner);
20
-
21
- vm.startBroadcast (deployerPrivateKey);
22
-
23
- address implementation;
24
- bytes memory initializerCall;
25
-
26
-
27
- implementation = address (new LiquidDelegation ());
28
- initializerCall = abi.encodeWithSignature (
29
- "initialize(address,string,string) " ,
30
- owner,
31
- name,
32
- symbol
33
- );
34
-
16
+ function _run (address implementation , bytes memory initializerCall ) internal {
35
17
address payable proxy = payable (
36
18
new ERC1967Proxy (implementation, initializerCall)
37
19
);
@@ -66,62 +48,41 @@ contract Deploy is Script {
66
48
uint256 (minor),
67
49
uint256 (patch)
68
50
);
69
-
70
- vm.stopBroadcast ();
71
-
72
51
}
73
52
74
- function nonLiquidDelegation ( ) external {
53
+ function liquidDelegation ( string calldata name , string calldata symbol ) external {
75
54
uint256 deployerPrivateKey = vm.envUint ("PRIVATE_KEY " );
76
55
address owner = vm.addr (deployerPrivateKey);
77
56
Console.log ("Signer is %s " , owner);
78
57
79
58
vm.startBroadcast (deployerPrivateKey);
80
59
81
- address implementation;
82
- bytes memory initializerCall;
83
-
84
-
85
- implementation = address (new NonLiquidDelegation ());
86
- initializerCall = abi.encodeWithSignature (
87
- "initialize(address) " ,
88
- owner
60
+ bytes memory initializerCall = abi.encodeWithSignature (
61
+ "initialize(address,string,string) " ,
62
+ owner,
63
+ name,
64
+ symbol
89
65
);
90
66
91
- address payable proxy = payable (
92
- new ERC1967Proxy (implementation, initializerCall)
93
- );
67
+ _run (address (new LiquidDelegation ()), initializerCall);
94
68
95
- Console.log (
96
- "Proxy deployed: %s \r\n Implementation deployed: %s " ,
97
- proxy,
98
- implementation
99
- );
69
+ vm.stopBroadcast ();
100
70
101
- BaseDelegation delegation = BaseDelegation (
102
- proxy
103
- );
71
+ }
104
72
105
- Console.log ("Owner is %s " ,
106
- delegation.owner ()
107
- );
73
+ function nonLiquidDelegation () external {
74
+ uint256 deployerPrivateKey = vm.envUint ("PRIVATE_KEY " );
75
+ address owner = vm.addr (deployerPrivateKey);
76
+ Console.log ("Signer is %s " , owner);
108
77
109
- bytes memory reinitializerCall = abi.encodeWithSignature (
110
- "reinitialize(uint64) " ,
111
- 1
112
- );
78
+ vm.startBroadcast (deployerPrivateKey);
113
79
114
- delegation. upgradeToAndCall (
115
- implementation ,
116
- reinitializerCall
80
+ bytes memory initializerCall = abi.encodeWithSignature (
81
+ " initialize(address) " ,
82
+ owner
117
83
);
118
84
119
- (uint24 major , uint24 minor , uint24 patch ) = delegation.decodedVersion ();
120
- Console.log ("Upgraded to version: %s.%s.%s " ,
121
- uint256 (major),
122
- uint256 (minor),
123
- uint256 (patch)
124
- );
85
+ _run (address (new NonLiquidDelegation ()), initializerCall);
125
86
126
87
vm.stopBroadcast ();
127
88
}
0 commit comments