Files
wtf-contract/_prepare_compile.py
T

36 lines
1.2 KiB
Python

import os
import shutil
import json
base = r"C:\Users\splea\Desktop\WTFX\wtf-contract"
# 1. 链接 @solady/utils
solady_pkg = os.path.join(base, "node_modules", "@solady", "utils")
os.makedirs(solady_pkg, exist_ok=True)
with open(os.path.join(solady_pkg, "package.json"), "w") as f:
json.dump({"name": "@solady/utils", "version": "1.0.0"}, f)
src_utils = os.path.join(base, "node_modules", "solady", "src", "utils")
if os.path.exists(src_utils):
for item in os.listdir(src_utils):
s = os.path.join(src_utils, item)
d = os.path.join(solady_pkg, item)
if os.path.isfile(s):
shutil.copy2(s, d)
# 2. 保证 curve/src 下的合约也可以被扫描到 main/src
curve_src = os.path.join(base, "curve", "src")
main_curves = os.path.join(base, "main", "src", "curves")
if os.path.exists(curve_src):
shutil.rmtree(main_curves, ignore_errors=True)
shutil.copytree(curve_src, main_curves)
# 3. 复制 mock
mock_src = os.path.join(base, "mock")
main_mock = os.path.join(base, "main", "src", "mock")
if os.path.exists(mock_src):
shutil.rmtree(main_mock, ignore_errors=True)
shutil.copytree(mock_src, main_mock)
print("Pre-compile sync complete!")