62 lines
1.9 KiB
Bash
Executable File
62 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script to generate Go bindings for smart contracts using abigen
|
|
# This script generates bindings for contracts in the Mev-Alpha project
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "Generating Go bindings for smart contracts..."
|
|
|
|
# Define paths
|
|
MEV_ALPHA_PATH="/home/administrator/projects/Mev-Alpha"
|
|
MEV_BETA_PATH="/home/administrator/projects/mev-beta"
|
|
BINDINGS_PATH="$MEV_BETA_PATH/bindings"
|
|
|
|
# Create bindings directory if it doesn't exist
|
|
mkdir -p "$BINDINGS_PATH"
|
|
|
|
# Function to generate binding for a contract
|
|
generate_binding() {
|
|
local contract_name=$1
|
|
local package_name=$2
|
|
local output_file=$3
|
|
local type_name=$4
|
|
|
|
echo "Generating bindings for $contract_name..."
|
|
|
|
# Define output directory
|
|
OUTPUT_DIR="$BINDINGS_PATH/$package_name"
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
# Define JSON file path
|
|
JSON_FILE="$MEV_ALPHA_PATH/out/${contract_name}.sol/${contract_name}.json"
|
|
|
|
# Check if JSON file exists
|
|
if [ ! -f "$JSON_FILE" ]; then
|
|
echo "Error: JSON file not found for $contract_name at $JSON_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Extract ABI to a temporary file
|
|
TEMP_ABI=$(mktemp)
|
|
cat "$JSON_FILE" | jq -r '.abi' > "$TEMP_ABI"
|
|
|
|
# Generate Go bindings
|
|
abigen --abi "$TEMP_ABI" \
|
|
--pkg "$package_name" \
|
|
--out "$OUTPUT_DIR/$output_file" \
|
|
--type "$type_name"
|
|
|
|
# Clean up temporary file
|
|
rm "$TEMP_ABI"
|
|
|
|
echo "Generated bindings for $contract_name in $OUTPUT_DIR/$output_file"
|
|
}
|
|
|
|
# Generate bindings for each contract
|
|
generate_binding "IArbitrage" "interfaces" "arbitrage.go" "IArbitrage"
|
|
generate_binding "IFlashSwapper" "interfaces" "flash_swapper.go" "IFlashSwapper"
|
|
generate_binding "BaseFlashSwapper" "flashswap" "base_flash_swapper.go" "BaseFlashSwapper"
|
|
generate_binding "ArbitrageExecutor" "arbitrage" "arbitrage_executor.go" "ArbitrageExecutor"
|
|
|
|
echo "All bindings generated successfully!" |