diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3b85c6d59..3b93ab3c0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -28,11 +28,11 @@ jobs: - name: Install Cargo toolchain uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: nightly-2025-04-01 profile: minimal components: rustc - name: Install packages - run: yarn install --frozen-lockfile && rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt + run: yarn install --frozen-lockfile && rustup component add --toolchain nightly-2025-04-01-x86_64-unknown-linux-gnu rustfmt - name: Lint js shell: bash run: yarn lint-js @@ -69,7 +69,7 @@ jobs: - name: Install Cargo toolchain uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: nightly-2025-04-01 profile: minimal components: rustc - name: Cache Cargo dependencies diff --git a/package.json b/package.json index 0109d9c83..920b1db30 100644 --- a/package.json +++ b/package.json @@ -22,24 +22,25 @@ "lint": "yarn lint-solidity && yarn lint-js && yarn lint-rust", "lint-solidity": "yarn solhint ./contracts/**/*.sol", "lint-js": "yarn prettier --list-different **/*.js **/*.ts", - "lint-rust": "cargo +nightly fmt --all -- --check && cargo clippy", - "lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly fmt --all && cargo clippy", + "lint-rust": "cargo +nightly-2025-04-01 fmt --all -- --check && cargo clippy", + "lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly-2025-04-01 fmt --all && cargo clippy", "clean-fast": "for dir in node_modules cache cache-zk artifacts artifacts-zk dist typechain; do mv \"${dir}\" \"_${dir}\"; rm -rf \"_${dir}\" &; done", "clean": "rm -rf node_modules cache cache-zk artifacts artifacts-zk dist typechain", "generate-svm-assets": "sh ./scripts/generate-svm-assets.sh && yarn generate-svm-clients", "generate-svm-clients": "yarn ts-node ./scripts/svm/utils/generate-svm-clients.ts && yarn ts-node ./scripts/svm/utils/rename-clients-imports.ts", "build-evm": "hardhat compile", - "build-svm": "echo 'Generating IDLs...' && anchor build > /dev/null 2>&1 || true && anchor run generateExternalTypes && anchor build", + "build-svm": "echo 'Generating IDLs...' && yarn anchor-build > /dev/null 2>&1 || true && anchor run generateExternalTypes && yarn anchor-build", "build-ts": "rm -rf ./dist && tsc && rsync -a --include '*/' --include '*.d.ts' --exclude '*' ./typechain ./dist/", "copy-idl": "mkdir -p dist/src/svm/assets/idl && cp src/svm/assets/idl/*.json dist/src/svm/assets/idl/", "build": "yarn build-evm && yarn build-svm && yarn generate-svm-assets && yarn build-ts && yarn copy-idl", "test-evm": "IS_TEST=true hardhat test", - "test-svm": "anchor test -- --features test", + "test-svm": "sh ./scripts/anchor-test.sh", "test": "yarn test-evm && yarn test-svm", "test:report-gas": "IS_TEST=true REPORT_GAS=true hardhat test", "generate-evm-assets": "rm -rf typechain && TYPECHAIN=ethers yarn hardhat typechain", "prepublish": "yarn build && hardhat export --export-all ./cache/massExport.json && ts-node ./scripts/processHardhatExport.ts && prettier --write ./deployments/deployments.json && yarn generate-evm-assets", - "pre-commit-hook": "sh scripts/preCommitHook.sh" + "pre-commit-hook": "sh scripts/preCommitHook.sh", + "anchor-build": "sh ./scripts/anchor-build.sh" }, "dependencies": { "@across-protocol/constants": "^3.1.46", diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..e5cd56d0f --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly-2025-04-01" diff --git a/scripts/anchor-build.sh b/scripts/anchor-build.sh new file mode 100644 index 000000000..73752644c --- /dev/null +++ b/scripts/anchor-build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "๐Ÿ”จ Building anchor programs (no IDL)..." +anchor build --no-idl + +echo "๐Ÿ“ฆ Generating IDLs (using nightly)..." + +for program in programs/*; do + [ -d "$program" ] || continue + + dir_name=$(basename "$program") + program_name=$(echo "$dir_name" | tr '-' '_') + + echo "โ†’ IDL for $program_name" + RUSTUP_TOOLCHAIN="nightly-2025-04-01" anchor idl build -p "$dir_name" -o "target/idl/$program_name.json" -t "target/types/$program_name.ts" +done diff --git a/scripts/anchor-test.sh b/scripts/anchor-test.sh new file mode 100644 index 000000000..a5f121bfa --- /dev/null +++ b/scripts/anchor-test.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +echo "๐Ÿ”จ Building anchor programs (with test feature, no IDL)..." +anchor build --no-idl -- --features test + +echo "๐Ÿ“ฆ Generating IDLs (using nightly)..." + +for program in programs/*; do + [ -d "$program" ] || continue + + dir_name=$(basename "$program") + program_name=$(echo "$dir_name" | tr '-' '_') + + echo "โ†’ IDL for $program_name" + RUSTUP_TOOLCHAIN="nightly-2025-04-01" anchor idl build -p "$dir_name" -o "target/idl/$program_name.json" -t "target/types/$program_name.ts" +done + +echo "๐Ÿงช Running anchor tests..." +anchor test --skip-build