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

Use prebuilt binaries on Cairo installation #399

Merged
merged 8 commits into from
Jul 14, 2023
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ starknet-hardhat-example
starknet-hardhat-example-link
cache
.vscode
my-venv
my-venv
cairo-compiler
33 changes: 33 additions & 0 deletions scripts/setup-compiler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -eu


CAIRO_COMPILER_TARGET_TAG=$(jq -r .CAIRO_COMPILER config.json)

echo "Installing cairo compiler $CAIRO_COMPILER_TARGET_TAG"

CAIRO_COMPILER_ASSET_NAME="release-x86_64-unknown-linux-musl.tar.gz"

if [[ "$OSTYPE" == "darwin"* ]]; then
CAIRO_COMPILER_ASSET_NAME="release-aarch64-apple-darwin.tar"
fi

COMPILER_BINARY_URL="https://github.com/starkware-libs/cairo/releases/download/$CAIRO_COMPILER_TARGET_TAG/$CAIRO_COMPILER_ASSET_NAME"

if [ -z "${CAIRO_1_COMPILER_DIR+x}" ]; then
# Setup cairo1 compiler
echo $COMPILER_BINARY_URL
mkdir -p cairo-compiler/target/release
curl --location -O --request GET "$COMPILER_BINARY_URL"
# Unzip asset and move to correct target
tar -zxvf $CAIRO_COMPILER_ASSET_NAME -C cairo-compiler --strip-components=1
mv cairo-compiler/bin/* cairo-compiler/target/release/
mv cairo-compiler/corelib cairo-compiler/target/corelib
# Remove empty directory and asset
rm -rf $CAIRO_COMPILER_ASSET_NAME cairo-compiler/bin
export CAIRO_1_COMPILER_DIR="$(readlink -f "cairo-compiler/target/release")"
fi

$CAIRO_1_COMPILER_DIR/starknet-compile --version

35 changes: 0 additions & 35 deletions scripts/setup-config-test-dependencies.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/test-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fi

if [[ "y" == "$RUN_SETUP" ]]; then
echo ""
source ./scripts/setup-config-test-dependencies.sh
source ./scripts/setup-compilers.sh
rm -rf starknet-hardhat-example
git clone -b "${EXAMPLE_REPO_BRANCH:=plugin}" --single-branch https://github.com/0xSpaceShard/starknet-hardhat-example.git
cd starknet-hardhat-example
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [[ -z "${STARKNET_HARDHAT_DEV:-}" ]]; then
./scripts/test-setup.sh
./scripts/install-devnet.sh
fi
source ./scripts/setup-config-test-dependencies.sh
source ./scripts/setup-compiler.sh

cd ./starknet-hardhat-example

Expand Down
4 changes: 2 additions & 2 deletions src/task-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function loadScarbTomlFromPath(tomlPath: string, validate: boolean): ScarbConfig
if (!contractTargetConfig || !contractTargetConfig.sierra || !contractTargetConfig.casm) {
throw new ScarbConfigValidationError(
tomlPath,
"To allow later loading of this projet's contracts, " +
"To allow later loading of this project's contracts, " +
"your TOML file must set 'sierra' and 'casm' to `true` under [[target.starknet-contract]]"
);
}
Expand Down Expand Up @@ -367,7 +367,7 @@ export async function starknetBuildAction(args: TaskArguments, hre: HardhatRunti
const ourArtifactDirPath = path.join(artifactDirPath, `${fileName}.cairo`);
fs.mkdirSync(ourArtifactDirPath, { recursive: true });

// We want to create artifacts compatible with our contract loading mehacnims.
// We want to create artifacts compatible with our contract loading mechanisms.
// To achieve this, we will now copy scarb artifacts

// this is false if user skipped validation
Expand Down