Skip to content

Commit d4c09a5

Browse files
committed
🐛 fix stylus deploy and cast
1 parent 480b8b6 commit d4c09a5

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

paradigmctf.py/ctf_launchers/utils.py

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,22 @@ def deploy_no_impersonate(
115115
deploy_script: str = "script/Deploy.s.sol:Deploy",
116116
env: Dict = {}
117117
) -> str:
118-
rfd, wfd = os.pipe2(os.O_NONBLOCK)
119-
120118
proc = subprocess.Popen(
121119
args=[
122120
"/opt/foundry/bin/forge",
123-
"script",
121+
"create",
122+
"src/Challenge.sol:Challenge",
123+
"--constructor-args",
124+
token,
124125
"--rpc-url",
125126
web3.provider.endpoint_uri,
126-
"--out",
127-
"/artifacts/out",
128-
"--cache-path",
129-
"/artifacts/cache",
130-
"--broadcast",
131-
"--unlocked",
132-
"--sender",
133-
"0x0000000000000000000000000000000000000000",
134-
deploy_script,
127+
"--private-key",
128+
"0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659"
135129
],
136130
env={
137131
"PATH": "/opt/huff/bin:/opt/foundry/bin:/usr/bin:" + os.getenv("PATH", "/fake"),
138-
"MNEMONIC": mnemonic,
139-
"OUTPUT_FILE": f"/proc/self/fd/{wfd}",
140132
}
141133
| env,
142-
pass_fds=[wfd],
143134
cwd=project_location,
144135
text=True,
145136
encoding="utf8",
@@ -154,14 +145,12 @@ def deploy_no_impersonate(
154145
print(stderr)
155146
raise Exception("forge failed to run")
156147

157-
result = os.read(rfd, 256).decode("utf8")
148+
address = stdout.split('Deployed to: ')[
149+
1].replace("\\n", "")[:42]
158150

159-
os.close(rfd)
160-
os.close(wfd)
151+
cast_initialize(web3, project_location, token, address)
161152

162-
# cast_initialize(web3, project_location, token, result)
163-
164-
return result
153+
return address
165154

166155

167156
def cast_initialize(
@@ -170,45 +159,32 @@ def cast_initialize(
170159
token: str,
171160
entrypoint: str
172161
) -> str:
173-
rfd, wfd = os.pipe2(os.O_NONBLOCK)
174-
175162
proc = subprocess.Popen(
176163
args=[
177164
"/opt/foundry/bin/cast",
178165
"send",
179166
token,
180-
'"initialize(address)"',
181-
entrypoint,
167+
"0xc4d66de8000000000000000000000000" + entrypoint[2:],
182168
"--rpc-url",
183169
web3.provider.endpoint_uri,
184170
"--private-key",
185171
"0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659"
186172
],
187-
pass_fds=[wfd],
188173
cwd=project_location,
189174
text=True,
190175
encoding="utf8",
191176
stdin=subprocess.DEVNULL,
192177
stdout=subprocess.PIPE,
193178
stderr=subprocess.PIPE,
194179
)
180+
195181
stdout, stderr = proc.communicate()
196182

197183
if proc.returncode != 0:
198184
print(stdout)
199185
print(stderr)
200186
raise Exception("cast failed to run")
201187

202-
result = os.read(rfd, 256).decode("utf8")
203-
204-
os.close(rfd)
205-
os.close(wfd)
206-
207-
return result
208-
209-
210-
211-
212188

213189
def deploy_nitro(
214190
web3: Web3,

0 commit comments

Comments
 (0)