feat: complete cancun hardhat compile setup for wtf-contract

This commit is contained in:
Bot
2026-08-31 00:12:55 +08:00
parent e1094b09d5
commit 92dc1b5e02
6 changed files with 83 additions and 14 deletions
+5
View File
@@ -0,0 +1,5 @@
# Robinhood Chain Testnet Deployment Env
PRIVATE_KEY=your_testnet_private_key_here
ROBINHOOD_TESTNET_RPC=https://rpc.testnet.chain.robinhood.com
TREASURY_ADDRESS=
COLLATERAL_ADDRESS=
+5
View File
@@ -0,0 +1,5 @@
node_modules
cache
artifacts
deployments
.env
+35
View File
@@ -0,0 +1,35 @@
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!")
+27 -10
View File
@@ -4,22 +4,39 @@ require("dotenv").config();
const PRIVATE_KEY = process.env.PRIVATE_KEY || "0x0000000000000000000000000000000000000000000000000000000000000001"; const PRIVATE_KEY = process.env.PRIVATE_KEY || "0x0000000000000000000000000000000000000000000000000000000000000001";
module.exports = { module.exports = {
solidity: {
version: "0.8.29",
settings: {
evmVersion: "cancun",
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: { paths: {
sources: "./main/src", sources: "./main/src",
tests: "./test", tests: "./test",
cache: "./cache", cache: "./cache",
artifacts: "./artifacts" artifacts: "./artifacts"
}, },
solidity: {
compilers: [
{
version: "0.8.29",
settings: {
evmVersion: "cancun",
optimizer: {
enabled: true,
runs: 200
},
viaIR: true
}
},
{
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
]
},
preprocess: {
// 处理 @wtf/ 别名映射
},
networks: { networks: {
localhost: { localhost: {
url: "http://127.0.0.1:8545" url: "http://127.0.0.1:8545"
+1
View File
@@ -15,6 +15,7 @@ library Errors {
error CurveInvalidCost(uint256 quantity); error CurveInvalidCost(uint256 quantity);
error CurveOtDeltaNotOnTick(uint256 otDelta, uint256 tick); error CurveOtDeltaNotOnTick(uint256 otDelta, uint256 tick);
error CurveInvalidStartEnd(); error CurveInvalidStartEnd();
error CurveInvalidParams();
error RegistryInsufficientOutcomesGiven(); error RegistryInsufficientOutcomesGiven();
error RegistryExceedMaxNames(); error RegistryExceedMaxNames();
+10 -4
View File
@@ -3,15 +3,21 @@
"version": "2.0.0", "version": "2.0.0",
"description": "WTFX Core Smart Contracts & Deployment Scripts", "description": "WTFX Core Smart Contracts & Deployment Scripts",
"scripts": { "scripts": {
"compile": "hardhat compile", "prepare": "python _prepare_compile.py",
"compile": "python _prepare_compile.py && hardhat compile",
"test": "hardhat test", "test": "hardhat test",
"deploy:robinhood-testnet": "hardhat run scripts/deploy.js --network robinhoodTestnet", "deploy:robinhood-testnet": "python _prepare_compile.py && hardhat run scripts/deploy.js --network robinhoodTestnet",
"deploy:robinhood-mainnet": "hardhat run scripts/deploy.js --network robinhoodMainnet", "deploy:robinhood-mainnet": "python _prepare_compile.py && hardhat run scripts/deploy.js --network robinhoodMainnet",
"deploy:local": "hardhat run scripts/deploy.js --network localhost" "deploy:local": "python _prepare_compile.py && hardhat run scripts/deploy.js --network localhost"
}, },
"devDependencies": { "devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^5.0.0", "@nomicfoundation/hardhat-toolbox": "^5.0.0",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"hardhat": "^2.22.5" "hardhat": "^2.22.5"
},
"dependencies": {
"@openzeppelin/contracts": "5.0.2",
"@openzeppelin/contracts-upgradeable": "5.0.2",
"solady": "0.0.219"
} }
} }