Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: Rename bash variable #665

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions scripts/abi_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

set -e

TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)

source $TELEPORTER_PATH/scripts/constants.sh
source $TELEPORTER_PATH/scripts/versions.sh
source $ICM_CONTRACTS_PATH/scripts/constants.sh
source $ICM_CONTRACTS_PATH/scripts/versions.sh

export ARCH=$(uname -m)
[ $ARCH = x86_64 ] && ARCH=amd64
Expand Down Expand Up @@ -47,7 +47,7 @@ if [ "$HELP" = true ]; then
fi

if ! command -v forge &> /dev/null; then
echo "forge not found. You can install by calling $TELEPORTER_PATH/scripts/install_foundry.sh" && exit 1
echo "forge not found. You can install by calling $ICM_CONTRACTS_PATH/scripts/install_foundry.sh" && exit 1
fi

if ! command -v solc &> /dev/null; then
Expand All @@ -70,20 +70,20 @@ echo "Building subnet-evm abigen"
go install github.com/ava-labs/subnet-evm/cmd/abigen@${SUBNET_EVM_VERSION}

# Solc does not recursively expand remappings, so we must construct them manually
remappings=$(cat $TELEPORTER_PATH/remappings.txt)
remappings=$(cat $ICM_CONTRACTS_PATH/remappings.txt)

# Recursively search for all remappings.txt files in the lib directory.
# For each file, prepend the remapping with the relative path to the file.
while read -r filepath; do
relative_path="${filepath#$TELEPORTER_PATH/}"
relative_path="${filepath#$ICM_CONTRACTS_PATH/}"
dir_path=$(dirname "$relative_path")
echo $dir_path

# Use sed to transform each line with the relative path if it matches the @token=remapping pattern,
# so that each remapping is of the form @token=lib/path/to/remapping
transformed_lines=$(sed -n "s|^\(@[^=]*=\)\(.*\)|\1$dir_path/\2|p" "$filepath")
remappings+=" $transformed_lines "
done < <(find "$TELEPORTER_PATH/lib" -type f -name "remappings.txt" )
done < <(find "$ICM_CONTRACTS_PATH/lib" -type f -name "remappings.txt" )

function convertToLower() {
if [ "$ARCH" = 'arm64' ]; then
Expand Down Expand Up @@ -125,12 +125,12 @@ function generate_bindings() {
dir="${dir#./}"

echo "Building $contract_name..."
mkdir -p $TELEPORTER_PATH/out/$contract_name.sol
mkdir -p $ICM_CONTRACTS_PATH/out/$contract_name.sol

combined_json=$TELEPORTER_PATH/out/$contract_name.sol/combined-output.json
combined_json=$ICM_CONTRACTS_PATH/out/$contract_name.sol/combined-output.json

cwd=$(pwd)
cd $TELEPORTER_PATH
cd $ICM_CONTRACTS_PATH
solc --optimize --evm-version $EVM_VERSION --combined-json abi,bin,metadata,ast,devdoc,userdoc --pretty-json $cwd/$dir/$contract_name.sol $remappings > $combined_json
cd $cwd

Expand All @@ -140,7 +140,7 @@ function generate_bindings() {
# Filter out the contract we are generating bindings for
filtered_contracts=$(remove_matching_string $contracts $contract_name)

gen_path=$TELEPORTER_PATH/abi-bindings/go/$dir/$contract_name
gen_path=$ICM_CONTRACTS_PATH/abi-bindings/go/$dir/$contract_name
mkdir -p $gen_path
echo "Generating Go bindings for $contract_name..."

Expand Down Expand Up @@ -174,15 +174,15 @@ if [[ -z "${CONTRACT_LIST}" ]]; then
contract_names=($DEFAULT_CONTRACT_LIST)
fi

cd $TELEPORTER_PATH/contracts
cd $ICM_CONTRACTS_PATH/contracts
generate_bindings "${contract_names[@]}"

contract_names=($PROXY_LIST)
cd $TELEPORTER_PATH/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/transparent
cd $ICM_CONTRACTS_PATH/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/transparent
generate_bindings "${contract_names[@]}"

contract_names=($SUBNET_EVM_LIST)
cd $TELEPORTER_PATH/lib/subnet-evm/contracts/contracts/interfaces
cd $ICM_CONTRACTS_PATH/lib/subnet-evm/contracts/contracts/interfaces
generate_bindings "${contract_names[@]}"

exit 0
4 changes: 2 additions & 2 deletions scripts/deploy_registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

set -e

TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)

# Check that foundry (specifically cast) is installed.
if ! command -v cast &> /dev/null; then
echo "cast not found. You can install by calling $TELEPORTER_PATH/scripts/install_foundry.sh" && exit 1
echo "cast not found. You can install by calling $ICM_CONTRACTS_PATH/scripts/install_foundry.sh" && exit 1
fi

# Check that jq is installed.
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy_teleporter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

set -e

TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)

# Check that foundry (specifically cast) is installed.
if ! command -v cast &> /dev/null; then
echo "cast not found. You can install by calling $TELEPORTER_PATH/scripts/install_foundry.sh" && exit 1
echo "cast not found. You can install by calling $ICM_CONTRACTS_PATH/scripts/install_foundry.sh" && exit 1
fi

# Check that jq is installed.
Expand Down
16 changes: 8 additions & 8 deletions scripts/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set -e

TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd ../ && pwd
)
Expand All @@ -26,7 +26,7 @@ Options:
EOF
}

valid_components=$(ls -d $TELEPORTER_PATH/tests/suites/*/ | xargs -n 1 basename)
valid_components=$(ls -d $ICM_CONTRACTS_PATH/tests/suites/*/ | xargs -n 1 basename)
components=

while [ $# -gt 0 ]; do
Expand Down Expand Up @@ -58,31 +58,31 @@ for component in $(echo $components | tr ',' ' '); do
fi
done

source "$TELEPORTER_PATH"/scripts/constants.sh
source "$TELEPORTER_PATH"/scripts/versions.sh
source "$ICM_CONTRACTS_PATH"/scripts/constants.sh
source "$ICM_CONTRACTS_PATH"/scripts/versions.sh

BASEDIR=${BASEDIR:-"$HOME/.teleporter-deps"}

cwd=$(pwd)
# Install the avalanchego and subnet-evm binaries
rm -rf $BASEDIR/avalanchego
BASEDIR=$BASEDIR AVALANCHEGO_BUILD_PATH=$BASEDIR/avalanchego "${TELEPORTER_PATH}/scripts/install_avalanchego_release.sh"
BASEDIR=$BASEDIR "${TELEPORTER_PATH}/scripts/install_subnetevm_release.sh"
BASEDIR=$BASEDIR AVALANCHEGO_BUILD_PATH=$BASEDIR/avalanchego "${ICM_CONTRACTS_PATH}/scripts/install_avalanchego_release.sh"
BASEDIR=$BASEDIR "${ICM_CONTRACTS_PATH}/scripts/install_subnetevm_release.sh"

cp ${BASEDIR}/subnet-evm/subnet-evm ${BASEDIR}/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
echo "Copied ${BASEDIR}/subnet-evm/subnet-evm binary to ${BASEDIR}/avalanchego/plugins/"

export AVALANCHEGO_BUILD_PATH=$BASEDIR/avalanchego

cd $TELEPORTER_PATH
cd $ICM_CONTRACTS_PATH
if command -v forge &> /dev/null; then
forge build --skip test
else
echo "Forge command not found, attempting to use from $HOME"
$HOME/.foundry/bin/forge build
fi

cd "$TELEPORTER_PATH"
cd "$ICM_CONTRACTS_PATH"
# Build ginkgo
# to install the ginkgo binary (required for test build and run)
go install -v github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION}
Expand Down
6 changes: 3 additions & 3 deletions scripts/install_avalanchego_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
set -e

# Load the versions
TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)
source "$TELEPORTER_PATH"/scripts/versions.sh
source "$ICM_CONTRACTS_PATH"/scripts/versions.sh

# Load the constants
source "$TELEPORTER_PATH"/scripts/constants.sh
source "$ICM_CONTRACTS_PATH"/scripts/constants.sh

############################
# download avalanchego
Expand Down
6 changes: 3 additions & 3 deletions scripts/install_subnetevm_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
set -e

# Load the versions
TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)
source "$TELEPORTER_PATH"/scripts/versions.sh
source "$TELEPORTER_PATH"/scripts/constants.sh
source "$ICM_CONTRACTS_PATH"/scripts/versions.sh
source "$ICM_CONTRACTS_PATH"/scripts/constants.sh

############################
# download subnet-evm
Expand Down
14 changes: 7 additions & 7 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

set -e

TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)

source $TELEPORTER_PATH/scripts/versions.sh
source $ICM_CONTRACTS_PATH/scripts/versions.sh

function solFormat() {
# format solidity contracts
echo "Formatting Solidity contracts..."
forge fmt --root $TELEPORTER_PATH $TELEPORTER_PATH/contracts/**
forge fmt --root $ICM_CONTRACTS_PATH $ICM_CONTRACTS_PATH/contracts/**
}

function solFormatCheck() {
# format solidity contracts
echo "Checking formatting of Solidity contracts..."
forge fmt --check --root $TELEPORTER_PATH $TELEPORTER_PATH/contracts/**
forge fmt --check --root $ICM_CONTRACTS_PATH $ICM_CONTRACTS_PATH/contracts/**
}

function solLinter() {
# lint solidity contracts
echo "Linting Solidity contracts..."
cd $TELEPORTER_PATH
cd $ICM_CONTRACTS_PATH
# "solhint **/*.sol" runs differently than "solhint '**/*.sol'", where the latter checks sol files
# in subdirectories. The former only checks sol files in the current directory and directories one level down.
solhint '**/*.sol' --config ./.solhint.json --ignore-path ./.solhintignore --max-warnings 0
Expand All @@ -37,8 +37,8 @@ function golangLinter() {
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}

echo "Linting Golang code..."
cd $TELEPORTER_PATH
golangci-lint run --config=$TELEPORTER_PATH/.golangci.yml ./...
cd $ICM_CONTRACTS_PATH
golangci-lint run --config=$ICM_CONTRACTS_PATH/.golangci.yml ./...
}

function runAll() {
Expand Down
8 changes: 4 additions & 4 deletions scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
set -e
set -o pipefail

TELEPORTER_PATH=$(
ICM_CONTRACTS_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)

# Pass in the full name of the dependency.
# Parses go.mod for a matching entry and extracts the version number.
function getDepVersion() {
grep -m1 "^\s*$1" $TELEPORTER_PATH/go.mod | cut -d ' ' -f2
grep -m1 "^\s*$1" $ICM_CONTRACTS_PATH/go.mod | cut -d ' ' -f2
}

function extract_commit() {
Expand Down Expand Up @@ -44,5 +44,5 @@ SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-$(extract_commit "$(getDepVersion githu
GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION:-'v1.60'}

# Extract the Solidity version from foundry.toml
SOLIDITY_VERSION=$(awk -F"'" '/^solc_version/ {print $2}' $TELEPORTER_PATH/foundry.toml)
EVM_VERSION=$(awk -F"'" '/^evm_version/ {print $2}' $TELEPORTER_PATH/foundry.toml)
SOLIDITY_VERSION=$(awk -F"'" '/^solc_version/ {print $2}' $ICM_CONTRACTS_PATH/foundry.toml)
EVM_VERSION=$(awk -F"'" '/^evm_version/ {print $2}' $ICM_CONTRACTS_PATH/foundry.toml)
Loading