diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index c0046a812..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: build - -on: - pull_request: - branches: - - main - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set Node version - uses: actions/setup-node@v3 - with: - node-version: 20.x - - run: corepack enable pnpm - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 8 - run_install: false - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm install - - name: Run build - run: pnpm build - - name: Check linter - run: pnpm lint - - name: Run tests - run: pnpm test:ci diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 000000000..f2b9a7722 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,67 @@ +name: quality + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + RUST_VERSION: 1.78.0 + +jobs: + ensure-wasm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + target: wasm32-unknown-unknown + - run: | + cd packages/account_sdk + cargo build -r --target wasm32-unknown-unknown -p account-sdk + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: asdf-vm/actions/install@v3 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + components: clippy + - run: cargo clippy --all-targets --all-features + + rust-fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + components: rustfmt + - uses: actions-rust-lang/rustfmt@v1 + + ts-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 20.x + - uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + - run: corepack enable pnpm + - uses: pnpm/action-setup@v2 + id: pnpm-install + with: + version: 9 + run_install: false + - run: pnpm install --frozen-lockfile + - run: pnpm lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..cd3fb83a3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: test + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + RUST_VERSION: 1.78.0 + +jobs: + rust-test: + runs-on: ubuntu-latest + container: + image: ghcr.io/dojoengine/dojo-dev:v0.7.0-alpha.2 + steps: + - uses: actions/checkout@v3 + - uses: asdf-vm/actions/install@v3 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + components: llvm-tools-preview + - uses: taiki-e/install-action@cargo-llvm-cov + - run: cargo llvm-cov --all-features --lcov --output-path lcov.info + - uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: lcov.info + + ts-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 20.x + - uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + - run: corepack enable pnpm + - uses: pnpm/action-setup@v2 + id: pnpm-install + with: + version: 9 + run_install: false + - run: pnpm install --frozen-lockfile + - run: pnpm test:ci --coverage + - uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/lcov.info diff --git a/.gitignore b/.gitignore index 9d3efb1d3..7d7a42780 100644 --- a/.gitignore +++ b/.gitignore @@ -148,3 +148,40 @@ node_modules/ # vite **/vite.config.*.timestamp-* + +**/.venv +**/__pycache__ + +# Generated by Cargo +# will have compiled files and executables +**/debug/ +**/target/ +**/abi/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +**/*.pdb + +# Envs +**/.cargo/ + +# Scarb +**/Scarb.lock + +# StarkNet Foundry +**/.snfoundry_cache/ + +# IDEs and editors +**/.vscode/ +**/.idea/ + +# Logs +**/log/ + +lcov.info diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..a3ba4ee76 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +scarb 2.6.3 +starknet-foundry 0.18.0 \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..ea413de3b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,34 @@ +[workspace] +resolver = "2" +members = ["packages/account_sdk"] + +[workspace.package] +edition = "2021" +version = "0.1.0" + +[workspace.dependencies] +anyhow = "1" +async-trait = "0.1" +base64 = "0.21" +cainome = { git = "https://github.com/piniom/cainome", rev = "beb1f1f5" } +cairo-lang-starknet = "2.4.0" +coset = { version = "0.3.4", features = ["std"] } +ecdsa = "0.16.9" +futures = "0.3" +lazy_static = "1" +p256 = "0.13" +primitive-types = { version = "0.12", default-features = false } +rand_core = { version = "0.6", features = ["getrandom"] } +serde = "1" +serde_json = "1" +sha2 = "0.10" +starknet = "0.10.0" +starknet-crypto = "0.6.1" +thiserror = "1" +toml = "0.8" +u256-literal = "1" +url = "2" +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4.42" +wasm-webauthn = { git = "https://github.com/broody/wasm-webauthn", rev = "972693fdeaa5dbcf7eee181c1e4aad5dfdb73a82" } +tokio = { version = "1", features = ["macros", "time"] } diff --git a/package.json b/package.json index 32b3968e5..1c30b5901 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "cartridge", - "packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3", + "name": "controller", + "packageManager": "pnpm@9.1.4", "private": true, "scripts": { "preinstall": "npx only-allow pnpm", @@ -27,4 +27,4 @@ "prettier": "^2.7.1", "turbo": "^1.10.11" } -} +} \ No newline at end of file diff --git a/packages/account_sdk/Cargo.toml b/packages/account_sdk/Cargo.toml index a52d0b267..5c118e408 100644 --- a/packages/account_sdk/Cargo.toml +++ b/packages/account_sdk/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "account-sdk" -edition = "2021" -version = "0.1.0" +edition.workspace = true +version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -9,35 +9,34 @@ version = "0.1.0" crate-type = ["lib"] [dependencies] -anyhow = "1" -async-trait = "0.1" -base64 = "0.21" -cainome = { git = "https://github.com/piniom/cainome", rev = "beb1f1f5" } -cairo-lang-starknet = "2.4.0" -coset = { version = "0.3.4", features = ["std"] } -ecdsa = "0.16.9" -futures = "0.3" -lazy_static = "1" -p256 = "0.13" -primitive-types = { version = "0.12", default-features = false } -rand_core = { version = "0.6", features = ["getrandom"] } -serde = "1" -serde_json = "1" -sha2 = "0.10" -starknet = "0.10.0" -starknet-crypto = "0.6.1" -thiserror = "1" -toml = "0.8" -u256-literal = "1" -url = "2" -wasm-bindgen = "0.2" -wasm-bindgen-futures = "0.4.42" -wasm-webauthn = { git = "https://github.com/broody/wasm-webauthn", rev = "972693fdeaa5dbcf7eee181c1e4aad5dfdb73a82" } -tokio = { version = "1", features = ["macros", "time"] } +anyhow.workspace = true +async-trait.workspace = true +base64.workspace = true +cainome.workspace = true +cairo-lang-starknet.workspace = true +coset.workspace = true +ecdsa.workspace = true +futures.workspace = true +lazy_static.workspace = true +p256.workspace = true +primitive-types.workspace = true +rand_core.workspace = true +serde.workspace = true +serde_json.workspace = true +sha2.workspace = true +starknet.workspace = true +starknet-crypto.workspace = true +thiserror.workspace = true +toml.workspace = true +u256-literal.workspace = true +url.workspace = true +wasm-bindgen-futures.workspace = true +wasm-bindgen.workspace = true +wasm-webauthn.workspace = true web-sys = "0.3.69" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tokio = { version = "1", features = ["macros", "time"] } +tokio.workspace = true [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen-test = "0.3.34" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..371758d2d --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.78.0" \ No newline at end of file