Skip to content

Commit

Permalink
Merge pull request #121 from argentlabs/cairo1
Browse files Browse the repository at this point in the history
Cairo1
  • Loading branch information
sgc-code authored Aug 18, 2023
2 parents 470b150 + b477446 commit c4b72de
Show file tree
Hide file tree
Showing 126 changed files with 164,135 additions and 4,442 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BASE_URL=https://alpha4.starknet.io/
ADDRESS=0x000000000000000000000000000000000000000000000000000000000000000
PRIVATE_KEY=0x000000000000000000000000000000000000000000000000000000000000000
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"extends": ["plugin:@typescript-eslint/recommended"],
"env": {
"node": true
},
"ignorePatterns": ["dist", "cairo"]
}
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/cairo-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Cairo CI

env:
ARCHIVE_LINK: https://github.com/starkware-libs/cairo/releases/download/v2.0.0/release-x86_64-unknown-linux-musl.tar.gz
ARCHIVE_NAME: cairo.zip

on: push

jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Downloading binaries
run: curl -L -o $ARCHIVE_NAME $ARCHIVE_LINK

- name: Step 3 - Unzipping binaries
run: tar -xvf $ARCHIVE_NAME

- name: Step 4 - Make binaries available
run: echo "./cairo/bin" >> $GITHUB_PATH

- name: Step 5 - Run all tests
run: cairo-test --starknet ./contracts

format:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Downloading binaries
run: curl -L -o $ARCHIVE_NAME $ARCHIVE_LINK

- name: Step 3 - Unzipping binaries
run: tar -xvf $ARCHIVE_NAME

- name: Step 4 - Make binaries available
run: echo "./cairo/bin" >> $GITHUB_PATH

- name: Step 5 - Check formatting
run: cairo-format --check --recursive ./contracts

contract-approvers:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Install project
run: yarn install --frozen-lockfile

- name: Step 3 - Check approvers count
run: yarn ts-node ./scripts/check-contract-approvers.ts 3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 0 additions & 30 deletions .github/workflows/contracts.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/integration-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Integration CI

env:
ARCHIVE_LINK: https://github.com/starkware-libs/cairo/releases/download/v2.0.0/release-x86_64-unknown-linux-musl.tar.gz
ARCHIVE_NAME: cairo_binaries.zip

on: push

jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Install correct python version
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"

- name: Step 3 - Cloning repo
run: make clone-cairo

- name: Step 4 - Downloading binaries, unzipping them and making them available
working-directory: ./cairo
run: |
curl -L -o $ARCHIVE_NAME $ARCHIVE_LINK
tar -xvf $ARCHIVE_NAME
mkdir -p target/release
mv cairo/bin/* target/release
- name: Step 5 - Installing requirements
run: pip3 install -r requirements.txt

- name: Step 6 - Start devnet in background
run: |
make devnet &
./scripts/wait-devnet-ready.sh
- name: Step 7 - Run integrations tests
run: |
yarn install --frozen-lockfile
make test-integration
format:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Install project
run: yarn install --frozen-lockfile

- name: Step 3 - Check correct formatting
run: yarn format:check

lint:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Install project
run: yarn install --frozen-lockfile

- name: Step 3 - Check correct linting
run: yarn lint:check
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
.env
venv/
.idea
.vscode
.DS_Store

venv
.pytest_cache
__pycache__
artifacts
dist
target
node_modules
node.json

cairo
account.json
tests/fixtures/ArgentAccount.json
tests/fixtures/ArgentAccount.casm
tests/fixtures/ArgentMultisig.json
tests/fixtures/ArgentMultisig.casm
tests/fixtures/TestDapp.json
tests/fixtures/TestDapp.casm
dump
package-lock.json
7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extensions": ["ts"],
"test": ["tests/**.ts"],
"node-option": ["loader=ts-node/esm"],
"slow": 5000,
"timeout": 300000
}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cairo
contracts
venv
tests/fixtures
dist
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"useTabs": false,
"trailingComma": "all",
"singleQuote": false,
"semi": true,
"printWidth": 120
}
93 changes: 93 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Won't write the called command in the console
.SILENT:
# Because we have a folder called test we need PHONY to avoid collision
.PHONY: test

CAIRO_VERSION=v2.0.0
INSTALLATION_FOLDER=./cairo
INSTALLATION_FOLDER_CARGO=$(INSTALLATION_FOLDER)/Cargo.toml
ACCOUNT_FOLDER=$(SOURCE_FOLDER)/account
LIB_FOLDER=$(SOURCE_FOLDER)/lib
MULTISIG_FOLDER=$(SOURCE_FOLDER)/multisig
MULTICALL_FOLDER=$(SOURCE_FOLDER)/multicall
SOURCE_FOLDER=./contracts
FIXTURES_FOLDER=./tests/fixtures

all: install build fixtures

install: install-cairo install-integration build vscode

install-cairo:
if [ -d $(INSTALLATION_FOLDER) ]; then \
$(MAKE) update-cairo; \
else \
$(MAKE) clone-cairo; \
fi

install-integration:
yarn

clone-cairo:
mkdir -p $(INSTALLATION_FOLDER)
git clone --branch $(CAIRO_VERSION) https://github.com/starkware-libs/cairo.git

update-cairo:
if [ "$$(git -C $(INSTALLATION_FOLDER) status | grep -e $(CAIRO_VERSION))" ]; then \
echo "Already on $(CAIRO_VERSION)"; \
else \
git -C $(INSTALLATION_FOLDER) checkout main; \
git -C $(INSTALLATION_FOLDER) pull; \
git -C $(INSTALLATION_FOLDER) checkout $(CAIRO_VERSION); \
fi

build:
cargo build --manifest-path $(INSTALLATION_FOLDER_CARGO) --workspace --release

compile-account:
./cairo/target/release/starknet-compile $(SOURCE_FOLDER)/account account.json --allowed-libfuncs-list-name all

fixtures:
./cairo/target/release/starknet-compile $(ACCOUNT_FOLDER) $(FIXTURES_FOLDER)/ArgentAccount.json --allowed-libfuncs-list-name all --contract-path account::argent_account::ArgentAccount
./cairo/target/release/starknet-sierra-compile $(FIXTURES_FOLDER)/ArgentAccount.json $(FIXTURES_FOLDER)/ArgentAccount.casm --allowed-libfuncs-list-name all
./cairo/target/release/starknet-compile $(LIB_FOLDER) $(FIXTURES_FOLDER)/TestDapp.json --allowed-libfuncs-list-name all
./cairo/target/release/starknet-sierra-compile $(FIXTURES_FOLDER)/TestDapp.json $(FIXTURES_FOLDER)/TestDapp.casm --allowed-libfuncs-list-name all
./cairo/target/release/starknet-compile $(MULTISIG_FOLDER) $(FIXTURES_FOLDER)/ArgentMultisig.json --allowed-libfuncs-list-name all --contract-path multisig::argent_multisig::ArgentMultisig
./cairo/target/release/starknet-sierra-compile $(FIXTURES_FOLDER)/ArgentMultisig.json $(FIXTURES_FOLDER)/ArgentMultisig.casm --allowed-libfuncs-list-name all

test:
./cairo/target/release/cairo-test --starknet $(SOURCE_FOLDER)

test-account:
./cairo/target/release/cairo-test --starknet $(ACCOUNT_FOLDER)

test-lib:
./cairo/target/release/cairo-test --starknet $(LIB_FOLDER)

test-multicall:
./cairo/target/release/cairo-test --starknet $(MULTICALL_FOLDER)

test-multisig:
./cairo/target/release/cairo-test --starknet $(MULTISIG_FOLDER)

test-integration: fixtures
yarn test:ci

format:
./cairo/target/release/cairo-format --recursive $(SOURCE_FOLDER) --print-parsing-errors

check-format:
./cairo/target/release/cairo-format --check --recursive $(SOURCE_FOLDER)

devnet:
INSTALLATION_FOLDER_CARGO=$(INSTALLATION_FOLDER_CARGO) ./scripts/start-devnet.sh

kill-devnet:
lsof -t -i tcp:5050 | xargs kill

vscode:
cd cairo/vscode-cairo && cargo build --bin cairo-language-server --release && cd ../..

clean:
rm -rf cairo dist node_modules venv
git reset --hard HEAD
rm dump
Loading

0 comments on commit c4b72de

Please sign in to comment.