@@ -107,11 +107,64 @@ def deploy_cairo(
107
107
return output [:65 ]
108
108
109
109
110
+ def deploy_no_impersonate (
111
+ web3 : Web3 ,
112
+ project_location : str ,
113
+ mnemonic : str ,
114
+ deploy_script : str = "script/Deploy.s.sol:Deploy" ,
115
+ env : Dict = {},
116
+ ) -> str :
117
+ rfd , wfd = os .pipe2 (os .O_NONBLOCK )
118
+
119
+ proc = subprocess .Popen (
120
+ args = [
121
+ "/opt/foundry/bin/forge" ,
122
+ "script" ,
123
+ "--rpc-url" ,
124
+ web3 .provider .endpoint_uri ,
125
+ "--out" ,
126
+ "/artifacts/out" ,
127
+ "--cache-path" ,
128
+ "/artifacts/cache" ,
129
+ "--broadcast" ,
130
+ "--unlocked" ,
131
+ "--sender" ,
132
+ "0x0000000000000000000000000000000000000000" ,
133
+ deploy_script ,
134
+ ],
135
+ env = {
136
+ "PATH" : "/opt/huff/bin:/opt/foundry/bin:/usr/bin:" + os .getenv ("PATH" , "/fake" ),
137
+ "MNEMONIC" : mnemonic ,
138
+ "OUTPUT_FILE" : f"/proc/self/fd/{ wfd } " ,
139
+ }
140
+ | env ,
141
+ pass_fds = [wfd ],
142
+ cwd = project_location ,
143
+ text = True ,
144
+ encoding = "utf8" ,
145
+ stdin = subprocess .DEVNULL ,
146
+ stdout = subprocess .PIPE ,
147
+ stderr = subprocess .PIPE ,
148
+ )
149
+ stdout , stderr = proc .communicate ()
150
+
151
+ if proc .returncode != 0 :
152
+ print (stdout )
153
+ print (stderr )
154
+ raise Exception ("forge failed to run" )
155
+
156
+ result = os .read (rfd , 256 ).decode ("utf8" )
157
+
158
+ os .close (rfd )
159
+ os .close (wfd )
160
+
161
+ return result
162
+
163
+
110
164
def deploy_nitro (
111
165
web3 : Web3 ,
112
166
project_location : str ,
113
- credentials : list ,
114
- deploy_script : str = "deploy.py" ,
167
+ mnemonic : list ,
115
168
env : Dict = {},
116
169
) -> str :
117
170
rfd , wfd = os .pipe2 (os .O_NONBLOCK )
@@ -141,11 +194,26 @@ def deploy_nitro(
141
194
print (stderr )
142
195
raise Exception ("script failed to run" )
143
196
144
- address = stdout .split ('Activating program at address ' )[1 ].replace ("\\ n" , "" )
197
+ address = stdout .split ('Activating program at address ' )[
198
+ 1 ].replace ("\\ n" , "" )
145
199
146
200
ansi_escape = re .compile (r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])' )
147
201
148
- output = ansi_escape .sub ('' , address )[:42 ]
202
+ token = ansi_escape .sub ('' , address )[:42 ]
203
+
204
+ env = {
205
+ "PATH" : "/opt/huff/bin:/opt/foundry/bin:/usr/bin:" + os .getenv ("PATH" , "/fake" ),
206
+ "MNEMONIC" : mnemonic ,
207
+ "OUTPUT_FILE" : f"/proc/self/fd/{ wfd } " ,
208
+ "TOKEN" : token
209
+ }
210
+
211
+ output = deploy_no_impersonate (
212
+ web3 ,
213
+ project_location ,
214
+ "" ,
215
+ env = env ,
216
+ )
149
217
150
218
return output
151
219
0 commit comments