Files
aitbc/contracts/scripts/compile_contracts.sh
aitbc dcc08e7569 Migrate contracts directory from npm to pnpm
- Delete package-lock.json and create pnpm-lock.yaml
- Add .npmrc with strict peer deps and frozen lockfile settings
- Update CI workflows to use pnpm instead of npm
- Update shell scripts to use pnpm instead of npm/npx
- Update documentation to reference pnpm commands
- Validate migration with successful hardhat compile
2026-05-22 22:28:32 +02:00

74 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
echo "=== AITBC Smart Contract Compilation ==="
# Check if solc is installed
if ! command -v solc &> /dev/null; then
echo "Error: solc (Solidity compiler) not found"
echo "Please install solc: pnpm add -g solc"
exit 1
fi
# Create artifacts directory
mkdir -p artifacts
mkdir -p cache
# Contract files to compile
contracts=(
"contracts/AIPowerRental.sol"
"contracts/AITBCPaymentProcessor.sol"
"contracts/PerformanceVerifier.sol"
"contracts/DisputeResolution.sol"
"contracts/EscrowService.sol"
"contracts/DynamicPricing.sol"
"test/contracts/MockERC20.sol"
"test/contracts/MockZKVerifier.sol"
"test/contracts/MockGroth16Verifier.sol"
)
echo "Compiling contracts..."
# Compile each contract
for contract in "${contracts[@]}"; do
if [ -f "$contract" ]; then
echo "Compiling $contract..."
# Extract contract name from file path
contract_name=$(basename "$contract" .sol)
# Compile with solc
solc --bin --abi --optimize --output-dir artifacts \
--base-path . \
--include-path node_modules/@openzeppelin/contracts/node_modules/@openzeppelin/contracts \
"$contract"
if [ $? -eq 0 ]; then
echo "$contract_name compiled successfully"
else
echo "$contract_name compilation failed"
exit 1
fi
else
echo "⚠️ Contract file not found: $contract"
fi
done
echo ""
echo "=== Compilation Summary ==="
echo "✅ All contracts compiled successfully"
echo "📁 Artifacts saved to: artifacts/"
echo "📋 ABI files available for integration"
# List compiled artifacts
echo ""
echo "Compiled artifacts:"
ls -la artifacts/*.bin 2>/dev/null | wc -l | xargs echo "Binary files:"
ls -la artifacts/*.abi 2>/dev/null | wc -l | xargs echo "ABI files:"
echo ""
echo "=== Next Steps ==="
echo "1. Review compilation artifacts"
echo "2. Run integration tests"
echo "3. Deploy to testnet"
echo "4. Perform security audit"