diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index f878470f..00000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Setup environment - -inputs: - cargo-cache-key: - description: The key to cache cargo dependencies. Skips cargo caching if not provided. - required: false - cargo-cache-fallback-key: - description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key. - required: false - cargo-cache-local-key: - description: The key to cache local cargo dependencies. Skips local cargo caching if not provided. - required: false - clippy: - description: Install Clippy if `true`. Defaults to `false`. - required: false - rustfmt: - description: Install Rustfmt if `true`. Defaults to `false`. - required: false - nightly-toolchain: - description: Install nightly toolchain if `true`. Defaults to `false`. - required: false - solana: - description: Install Solana if `true`. Defaults to `false`. - required: false - -runs: - using: 'composite' - steps: - - name: Setup pnpm - uses: pnpm/action-setup@v3 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --frozen-lockfile - shell: bash - - - name: Set Environment Variables - shell: bash - run: pnpm zx ./scripts/ci/set-env.mjs - - - name: Install Rustfmt - if: ${{ inputs.rustfmt == 'true' }} - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ env.TOOLCHAIN_NIGHTLY }} - components: rustfmt - - - name: Install Clippy - if: ${{ inputs.clippy == 'true' }} - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ env.TOOLCHAIN_NIGHTLY }} - components: clippy - - - name: Install nightly toolchain - if: ${{ inputs.nightly-toolchain == 'true' }} - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ env.TOOLCHAIN_NIGHTLY }} - - - name: Install Solana - if: ${{ inputs.solana == 'true' }} - uses: solana-program/actions/install-solana@v1 - with: - version: ${{ env.SOLANA_VERSION }} - cache: true - - - name: Cache Cargo Dependencies - if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }} - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }} - - - name: Cache Cargo Dependencies With Fallback - if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }} - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-${{ inputs.cargo-cache-key }} - ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }} - - - name: Cache Local Cargo Dependencies - if: ${{ inputs.cargo-cache-local-key }} - uses: actions/cache@v4 - with: - path: | - .cargo/bin/ - .cargo/registry/index/ - .cargo/registry/cache/ - .cargo/git/db/ - key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e391fe0..0efd72c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,160 +6,46 @@ on: pull_request: branches: [main] -jobs: - format_and_lint_rust: - name: Format & Lint Rust - runs-on: ubuntu-latest - strategy: - matrix: - library: [discriminator, generic-token, generic-token-tests, pod, program-error, tlv-account-resolution, type-length-value, type-length-value-derive-test] - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - clippy: true - rustfmt: true - - - name: Format - run: pnpm ${{ matrix.library }}:format - - - name: Lint - run: pnpm ${{ matrix.library }}:lint - - format_and_lint_js: - name: Format & Lint JS - runs-on: ubuntu-latest - strategy: - matrix: - library: [type-length-value] - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - - - name: Format - run: pnpm ${{ matrix.library }}:js:format - - - name: Lint - run: pnpm ${{ matrix.library }}:js:lint - - audit_rust: - name: Audit Rust - runs-on: ubuntu-latest - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - cargo-cache-key: cargo-audit - - - name: Install cargo-audit - uses: taiki-e/install-action@v2 - with: - tool: cargo-audit - - - name: Run cargo-audit - run: pnpm rust:audit - - spellcheck_rust: - name: Spellcheck Rust - runs-on: ubuntu-latest - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - cargo-cache-key: cargo-spellcheck - - - name: Install cargo-spellcheck - uses: taiki-e/install-action@v2 - with: - tool: cargo-spellcheck +env: + JS_PACKAGES: "['type-length-value-js']" + SBPF_PROGRAM_PACKAGES: "['discriminator', 'generic-token', 'pod', 'program-error', 'tlv-account-resolution', 'type-length-value']" + RUST_PACKAGES: "['discriminator', 'discriminator-derive', 'discriminator-syn', 'generic-token', 'generic-token-tests', 'pod', 'program-error', 'program-error-derive', 'tlv-account-resolution', 'type-length-value', 'type-length-value-derive', 'type-length-value-derive-test']" + WASM_PACKAGES: "['discriminator', 'generic-token', 'pod', 'program-error', 'tlv-account-resolution', 'type-length-value']" - - name: Run cargo-spellcheck - run: pnpm rust:spellcheck - - build_sbf: - name: Build SBF - runs-on: ubuntu-latest - strategy: - matrix: - library: [discriminator, generic-token, pod, program-error, tlv-account-resolution, type-length-value, type-length-value-derive-test] - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - cargo-cache-key: cargo-build-${{ matrix.library }} - solana: true - - - name: Build - run: pnpm ${{ matrix.library }}:build - - hack_rust: - name: Check Powerset - runs-on: ubuntu-latest - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - nightly-toolchain: true - cargo-cache-key: cargo-hack-check - cargo-cache-fallback-key: cargo-hack - - - name: Install cargo-hack - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: cargo-hack - - - name: Hack check - run: pnpm rust:hack - - test_rust: - name: Test Rust - runs-on: ubuntu-latest - strategy: - matrix: - library: [discriminator, generic-token, generic-token-tests, pod, program-error, tlv-account-resolution, type-length-value, type-length-value-derive-test] - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - cargo-cache-key: cargo-${{ matrix.library }}-tests - cargo-cache-fallback-key: cargo-${{ matrix.library }} - - - name: Test - run: pnpm ${{ matrix.library }}:test - - test_js: - name: Test JS - runs-on: ubuntu-latest - strategy: - matrix: - library: [type-length-value] - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - - - name: Test - run: pnpm ${{ matrix.library }}:js:test +jobs: + set_env: + name: Set variables to be used in strategy definitions in reusable workflow + runs-on: ubuntu-latest + outputs: + JS_PACKAGES: ${{ steps.compute.outputs.JS_PACKAGES }} + SBPF_PROGRAM_PACKAGES: ${{ steps.compute.outputs.SBPF_PROGRAM_PACKAGES }} + RUST_PACKAGES: ${{ steps.compute.outputs.RUST_PACKAGES }} + WASM_PACKAGES: ${{ steps.compute.outputs.WASM_PACKAGES }} + RUST_TOOLCHAIN_NIGHTLY: ${{ steps.compute.outputs.RUST_TOOLCHAIN_NIGHTLY }} + SOLANA_CLI_VERSION: ${{ steps.compute.outputs.SOLANA_CLI_VERSION }} + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Compute variables + id: compute + shell: bash + run: | + echo "JS_PACKAGES=${{ env.JS_PACKAGES }}" >> $GITHUB_OUTPUT + echo "SBPF_PROGRAM_PACKAGES=${{ env.SBPF_PROGRAM_PACKAGES }}" >> $GITHUB_OUTPUT + echo "RUST_PACKAGES=${{ env.RUST_PACKAGES }}" >> $GITHUB_OUTPUT + echo "WASM_PACKAGES=${{ env.WASM_PACKAGES }}" >> $GITHUB_OUTPUT + echo "RUST_TOOLCHAIN_NIGHTLY=$(make rust-toolchain-nightly)" >> "$GITHUB_OUTPUT" + echo "SOLANA_CLI_VERSION=$(make solana-cli-version)" >> "$GITHUB_OUTPUT" + + main: + needs: set_env + uses: solana-program/actions/.github/workflows/main.yml@main + with: + js-packages: ${{ needs.set_env.outputs.JS_PACKAGES }} + sbpf-program-packages: ${{ needs.set_env.outputs.SBPF_PROGRAM_PACKAGES }} + rust-packages: ${{ needs.set_env.outputs.RUST_PACKAGES }} + wasm-packages: ${{ needs.set_env.outputs.WASM_PACKAGES }} + rustfmt-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} + clippy-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} + solana-cli-version: ${{ needs.set_env.outputs.SOLANA_CLI_VERSION }} diff --git a/.github/workflows/publish-rust.yml b/.github/workflows/publish-rust.yml index 8810f080..e370062f 100644 --- a/.github/workflows/publish-rust.yml +++ b/.github/workflows/publish-rust.yml @@ -3,22 +3,22 @@ name: Publish Rust Crate on: workflow_dispatch: inputs: - package_path: + package-path: description: Path to directory with package to release required: true default: 'discriminator' type: choice options: - discriminator - - discriminator/derive - - discriminator/syn + - discriminator-derive + - discriminator-syn - generic-token - pod - program-error - - program-error/derive + - program-error-derive - tlv-account-resolution - type-length-value - - type-length-value/derive + - type-length-value-derive level: description: Level required: true @@ -28,156 +28,58 @@ on: - patch - minor - major - dry_run: + - rc + - beta + - alpha + - release + - version + version: + description: Version (used with level "version") + required: false + type: string + dry-run: description: Dry run required: true default: true type: boolean - create_release: + create-release: description: Create a GitHub release required: true type: boolean default: true jobs: - test: - name: Test Rust Crate + set_env: + name: Set variables to be used in strategy definitions runs-on: ubuntu-latest + outputs: + RUST_TOOLCHAIN_NIGHTLY: ${{ steps.compute.outputs.RUST_TOOLCHAIN_NIGHTLY }} + SOLANA_CLI_VERSION: ${{ steps.compute.outputs.SOLANA_CLI_VERSION }} + TARGET: ${{ steps.compute.outputs.TARGET }} steps: - name: Git Checkout uses: actions/checkout@v4 - - name: Setup Environment - uses: ./.github/actions/setup - with: - clippy: true - rustfmt: true - cargo-cache-key: cargo-test-publish-${{ inputs.package_path }} - cargo-cache-fallback-key: cargo-test-publish - - - name: Format - run: pnpm zx ./scripts/rust/format.mjs "${{ inputs.package_path }}" - - - name: Lint - run: pnpm zx ./scripts/rust/lint.mjs "${{ inputs.package_path }}" - - - name: Test - run: pnpm zx ./scripts/rust/test.mjs "${{ inputs.package_path }}" - - semver: - name: Check Semver - runs-on: ubuntu-latest - steps: - - name: Git checkout - uses: actions/checkout@v4 - - - name: Setup Environment - uses: ./.github/actions/setup - with: - cargo-cache-key: cargo-publish-semver-${{ inputs.package_path }} - cargo-cache-fallback-key: cargo-publish-semver - - - name: Install cargo-semver-checks - uses: taiki-e/install-action@v2 - with: - tool: toml-cli,cargo-semver-checks@0.42.0,cargo-release@0.25.18 - - - name: Check if crate has a lib target - id: has_lib + - name: Compute variables + id: compute shell: bash run: | - set +e # toml crashes the whole shell if it fails to find the key - result=$(toml get "${{ inputs.package_path }}/Cargo.toml" lib.crate-type) - if [[ "$result" == *"lib"* ]]; then - echo "has_lib=true" >> "$GITHUB_OUTPUT" - else - echo "has_lib=false" >> "$GITHUB_OUTPUT" - fi - - - name: Set Git Author (required for cargo-release) - if: ${{ steps.has_lib.outputs.has_lib == 'true' }} - run: | - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - - name: Set Version - if: ${{ steps.has_lib.outputs.has_lib == 'true' }} - run: | - if [ "${{ inputs.level }}" == "version" ]; then - LEVEL=${{ inputs.version }} - else - LEVEL=${{ inputs.level }} - fi - cargo release $LEVEL --manifest-path "${{ inputs.package_path }}/Cargo.toml" --no-tag --no-publish --no-push --no-confirm --execute - - - name: Check semver - if: ${{ steps.has_lib.outputs.has_lib == 'true' }} - run: pnpm rust:semver --manifest-path "${{ inputs.package_path }}/Cargo.toml" - - publish: - name: Publish Rust Crate - runs-on: ubuntu-latest - needs: [semver, test] - permissions: - contents: write - steps: - - name: Git Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.ANZA_TEAM_PAT }} - fetch-depth: 0 # get the whole history for git-cliff - - - name: Setup Environment - uses: ./.github/actions/setup - with: - cargo-cache-key: cargo-publish-${{ inputs.package_path }} - cargo-cache-fallback-key: cargo-publish - - - name: Install cargo-release - uses: taiki-e/install-action@v2 - with: - tool: cargo-release@0.25.18 - - - name: Ensure CARGO_REGISTRY_TOKEN variable is set - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - if: ${{ env.CARGO_REGISTRY_TOKEN == '' }} - run: | - echo "The CARGO_REGISTRY_TOKEN secret variable is not set" - echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"." - exit 1 - - - name: Set Git Author - run: | - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - - name: Publish Crate - id: publish - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: | - if [ "${{ inputs.dry_run }}" == "true" ]; then - OPTIONS="--dry-run" - else - OPTIONS="" - fi - - pnpm rust:publish "${{ inputs.package_path }}" "${{ inputs.level }}" $OPTIONS - - - name: Generate a changelog - if: github.event.inputs.create_release == 'true' - uses: orhun/git-cliff-action@v4 - with: - config: "scripts/cliff.toml" - args: ${{ steps.publish.outputs.old_git_tag }}..HEAD --include-path "${{ inputs.package_path }}/**" --github-repo ${{ github.repository }} - env: - OUTPUT: TEMP_CHANGELOG.md - GITHUB_REPO: ${{ github.repository }} - - - name: Create GitHub release - if: github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true' - uses: ncipollo/release-action@v1 - with: - tag: ${{ steps.publish.outputs.new_git_tag }} - bodyFile: TEMP_CHANGELOG.md + echo "RUST_TOOLCHAIN_NIGHTLY=$(make rust-toolchain-nightly)" >> "$GITHUB_OUTPUT" + echo "SOLANA_CLI_VERSION=$(make solana-cli-version)" >> "$GITHUB_OUTPUT" + TARGET=$(echo ${{ inputs.package-path }} | sed 's#/#-#') + echo "TARGET=$TARGET" >> "$GITHUB_OUTPUT" + + main: + needs: set_env + uses: solana-program/actions/.github/workflows/publish-rust.yml@main + with: + solana-cli-version: ${{ needs.set_env.outputs.SOLANA_CLI_VERSION }} + clippy-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} + rustfmt-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }} + target: ${{ needs.set_env.outputs.TARGET }} + package-path: ${{ inputs.package-path }} + level: ${{ inputs.level }} + version: ${{ inputs.version }} + create-release: ${{ inputs.create-release }} + dry-run: ${{ inputs.dry-run }} + secrets: inherit diff --git a/Cargo.toml b/Cargo.toml index 6410ba1e..2d3e07f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,16 +2,16 @@ resolver = "2" members = [ "discriminator", - "discriminator/derive", - "discriminator/syn", + "discriminator-derive", + "discriminator-syn", "generic-token", "generic-token-tests", "pod", "program-error", - "program-error/derive", + "program-error-derive", "tlv-account-resolution", "type-length-value", - "type-length-value/derive", + "type-length-value-derive", "type-length-value-derive-test", ] diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..92653c4c --- /dev/null +++ b/Makefile @@ -0,0 +1,107 @@ +RUST_TOOLCHAIN_NIGHTLY = nightly-2025-02-16 +SOLANA_CLI_VERSION = 2.3.4 + +nightly = +${RUST_TOOLCHAIN_NIGHTLY} + +make-path = $1 + +rust-toolchain-nightly: + @echo ${RUST_TOOLCHAIN_NIGHTLY} + +solana-cli-version: + @echo ${SOLANA_CLI_VERSION} + +cargo-nightly: + cargo $(nightly) $(ARGS) + +# Keep js entries early in the list because Mac's version of Make will fail to +# find them otherwise. +format-check-js-%: + cd $(call make-path,$*) && pnpm install --frozen-lockfile && pnpm format $(ARGS) + +lint-js-%: + cd $(call make-path,$*) && pnpm install --frozen-lockfile && pnpm lint $(ARGS) + +test-js-%: + cd $(call make-path,$*) && pnpm install --frozen-lockfile && pnpm build && pnpm test $(ARGS) + +audit: + cargo audit \ + --ignore RUSTSEC-2022-0093 \ + --ignore RUSTSEC-2024-0421 \ + --ignore RUSTSEC-2024-0344 \ + --ignore RUSTSEC-2024-0376 $(ARGS) + +spellcheck: + cargo spellcheck --code 1 $(ARGS) + +clippy-%: + cargo $(nightly) clippy --manifest-path $(call make-path,$*)/Cargo.toml \ + --all-targets \ + --all-features \ + -- \ + --deny=warnings \ + --deny=clippy::default_trait_access \ + --deny=clippy::arithmetic_side_effects \ + --deny=clippy::manual_let_else \ + --deny=clippy::used_underscore_binding $(ARGS) + +format-check-%: + cargo $(nightly) fmt --check --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +powerset-%: + cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +semver-check-%: + cargo semver-checks --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +shellcheck: + git ls-files -- '*.sh' | xargs shellcheck --color=always --external-sources --shell=bash $(ARGS) + +sort-check: + cargo $(nightly) sort --workspace --check $(ARGS) + +bench-%: + cargo $(nightly) bench --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +format-rust: + cargo $(nightly) fmt --all $(ARGS) + +build-sbf-%: + cargo build-sbf --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +build-wasm-%: + cargo build --target wasm32-unknown-unknown --manifest-path $(call make-path,$*)/Cargo.toml --all-features $(ARGS) + +build-doc-%: + RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo $(nightly) doc --all-features --no-deps --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +test-doc-%: + cargo $(nightly) test --doc --all-features --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +test-%: + SBF_OUT_DIR=$(PWD)/target/deploy cargo $(nightly) test --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS) + +generate-clients: + @echo "No clients to generate" + +# Helpers for publishing +tag-name = $(lastword $(subst /, ,$(call make-path,$1))) +preid-arg = $(subst pre,--preid $2,$(findstring pre,$1)) +package-version = $(subst ",,$(shell jq -r '.version' $(call make-path,$1)/package.json)) +crate-version = $(subst ",,$(shell toml get $(call make-path,$1)/Cargo.toml package.version)) + +git-tag-js-%: + @echo "$(call tag-name,$*)@v$(call package-version,$*)" + +publish-js-%: + cd "$(call make-path,$*)" && pnpm install --frozen-lockfile && pnpm version $(LEVEL) --no-git-tag-version $(call preid-arg,$(LEVEL),$(TAG)) && pnpm publish --no-git-checks --tag $(TAG) + +git-tag-rust-%: + @echo "$(call tag-name,$*)@v$(call crate-version,$*)" + +publish-rust-%: + cd "$(call make-path,$*)" && cargo release $(LEVEL) --tag-name "$(call tag-name,$*)@v{{version}}" --execute --no-confirm --dependent-version fix + +publish-rust-dry-run-%: + cd "$(call make-path,$*)" && cargo release $(LEVEL) --tag-name "$(call tag-name,$*)@v{{version}}" diff --git a/discriminator/derive/Cargo.toml b/discriminator-derive/Cargo.toml similarity index 85% rename from discriminator/derive/Cargo.toml rename to discriminator-derive/Cargo.toml index 67a13927..5da9d4d3 100644 --- a/discriminator/derive/Cargo.toml +++ b/discriminator-derive/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] quote = "1.0" -spl-discriminator-syn = { version = "0.2.1", path = "../syn" } +spl-discriminator-syn = { version = "0.2.1", path = "../discriminator-syn" } syn = { version = "2.0", features = ["full"] } [lib] diff --git a/discriminator/derive/src/lib.rs b/discriminator-derive/src/lib.rs similarity index 100% rename from discriminator/derive/src/lib.rs rename to discriminator-derive/src/lib.rs diff --git a/discriminator/syn/Cargo.toml b/discriminator-syn/Cargo.toml similarity index 100% rename from discriminator/syn/Cargo.toml rename to discriminator-syn/Cargo.toml diff --git a/discriminator/syn/src/error.rs b/discriminator-syn/src/error.rs similarity index 100% rename from discriminator/syn/src/error.rs rename to discriminator-syn/src/error.rs diff --git a/discriminator/syn/src/lib.rs b/discriminator-syn/src/lib.rs similarity index 100% rename from discriminator/syn/src/lib.rs rename to discriminator-syn/src/lib.rs diff --git a/discriminator/syn/src/parser.rs b/discriminator-syn/src/parser.rs similarity index 94% rename from discriminator/syn/src/parser.rs rename to discriminator-syn/src/parser.rs index 950f2869..db4bf0b4 100644 --- a/discriminator/syn/src/parser.rs +++ b/discriminator-syn/src/parser.rs @@ -14,14 +14,13 @@ use { /// `#[discriminator_hash_input("...")]` struct HashInputValueParser { value: LitStr, - _comma: Option, } impl Parse for HashInputValueParser { fn parse(input: ParseStream) -> syn::Result { let value: LitStr = input.parse()?; let _comma: Option = input.parse().unwrap_or(None); - Ok(HashInputValueParser { value, _comma }) + Ok(HashInputValueParser { value }) } } diff --git a/discriminator/Cargo.toml b/discriminator/Cargo.toml index 1248e49a..6dfb2318 100644 --- a/discriminator/Cargo.toml +++ b/discriminator/Cargo.toml @@ -15,7 +15,7 @@ borsh = { version = "1", optional = true, features = ["derive"] } bytemuck = { version = "1.23.2", features = ["derive"] } solana-program-error = "3.0.0" solana-sha256-hasher = { version = "3.0.0", features = ["sha2"] } -spl-discriminator-derive = { version = "0.2.0", path = "./derive" } +spl-discriminator-derive = { version = "0.2.0", path = "../discriminator-derive" } [dev-dependencies] spl-discriminator = { path = ".", features = ["borsh"] } diff --git a/package.json b/package.json index 7e485331..90bd14c7 100644 --- a/package.json +++ b/package.json @@ -1,54 +1,4 @@ { "private": true, - "scripts": { - "discriminator:build": "zx ./scripts/rust/build-sbf.mjs discriminator", - "discriminator:test": "zx ./scripts/rust/test.mjs discriminator", - "discriminator:format": "zx ./scripts/rust/format.mjs discriminator", - "discriminator:lint": "zx ./scripts/rust/lint.mjs discriminator", - "generic-token:build": "zx ./scripts/rust/build-sbf.mjs generic-token", - "generic-token:test": "zx ./scripts/rust/test.mjs generic-token", - "generic-token:format": "zx ./scripts/rust/format.mjs generic-token", - "generic-token:lint": "zx ./scripts/rust/lint.mjs generic-token", - "generic-token-tests:test": "zx ./scripts/rust/test.mjs generic-token-tests", - "generic-token-tests:format": "zx ./scripts/rust/format.mjs generic-token-tests", - "generic-token-tests:lint": "zx ./scripts/rust/lint.mjs generic-token-tests", - "program-error:build": "zx ./scripts/rust/build-sbf.mjs program-error", - "program-error:test": "zx ./scripts/rust/test.mjs program-error", - "program-error:format": "zx ./scripts/rust/format.mjs program-error", - "program-error:lint": "zx ./scripts/rust/lint.mjs program-error", - "pod:build": "zx ./scripts/rust/build-sbf.mjs pod", - "pod:test": "zx ./scripts/rust/test.mjs pod", - "pod:format": "zx ./scripts/rust/format.mjs pod", - "pod:lint": "zx ./scripts/rust/lint.mjs pod", - "tlv-account-resolution:build": "zx ./scripts/rust/build-sbf.mjs tlv-account-resolution", - "tlv-account-resolution:test": "zx ./scripts/rust/test.mjs tlv-account-resolution", - "tlv-account-resolution:format": "zx ./scripts/rust/format.mjs tlv-account-resolution", - "tlv-account-resolution:lint": "zx ./scripts/rust/lint.mjs tlv-account-resolution", - "type-length-value:build": "zx ./scripts/rust/build-sbf.mjs type-length-value", - "type-length-value:test": "zx ./scripts/rust/test.mjs type-length-value", - "type-length-value:format": "zx ./scripts/rust/format.mjs type-length-value", - "type-length-value:lint": "zx ./scripts/rust/lint.mjs type-length-value", - "type-length-value:js:test": "zx ./scripts/js/test.mjs type-length-value", - "type-length-value:js:format": "zx ./scripts/js/format.mjs type-length-value", - "type-length-value:js:lint": "zx ./scripts/js/lint.mjs type-length-value", - "type-length-value-derive-test:build": "zx ./scripts/rust/build-sbf.mjs type-length-value-derive-test", - "type-length-value-derive-test:test": "zx ./scripts/rust/test.mjs type-length-value-derive-test", - "type-length-value-derive-test:format": "zx ./scripts/rust/format.mjs type-length-value-derive-test", - "type-length-value-derive-test:lint": "zx ./scripts/rust/lint.mjs type-length-value-derive-test", - "template:upgrade": "zx ./scripts/upgrade-template.mjs", - "rust:spellcheck": "cargo spellcheck --code 1", - "rust:audit": "zx ./scripts/rust/audit.mjs", - "rust:publish": "zx ./scripts/rust/publish.mjs", - "rust:hack": "zx ./scripts/rust/hack.mjs", - "rust:semver": "cargo semver-checks" - }, - "devDependencies": { - "@iarna/toml": "^2.2.5", - "typescript": "^5.9.3", - "zx": "^8.8.5" - }, - "engines": { - "node": ">=v20.0.0" - }, "packageManager": "pnpm@9.1.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd1352b0..9b60ae17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,37 +6,4 @@ settings: importers: - .: - devDependencies: - '@iarna/toml': - specifier: ^2.2.5 - version: 2.2.5 - typescript: - specifier: ^5.9.3 - version: 5.9.3 - zx: - specifier: ^8.8.5 - version: 8.8.5 - -packages: - - '@iarna/toml@2.2.5': - resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - - typescript@5.9.3: - resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} - engines: {node: '>=14.17'} - hasBin: true - - zx@8.8.5: - resolution: {integrity: sha512-SNgDF5L0gfN7FwVOdEFguY3orU5AkfFZm9B5YSHog/UDHv+lvmd82ZAsOenOkQixigwH2+yyH198AwNdKhj+RA==} - engines: {node: '>= 12.17.0'} - hasBin: true - -snapshots: - - '@iarna/toml@2.2.5': {} - - typescript@5.9.3: {} - - zx@8.8.5: {} + .: {} diff --git a/program-error/derive/Cargo.toml b/program-error-derive/Cargo.toml similarity index 100% rename from program-error/derive/Cargo.toml rename to program-error-derive/Cargo.toml diff --git a/program-error/derive/src/lib.rs b/program-error-derive/src/lib.rs similarity index 100% rename from program-error/derive/src/lib.rs rename to program-error-derive/src/lib.rs diff --git a/program-error/derive/src/macro_impl.rs b/program-error-derive/src/macro_impl.rs similarity index 100% rename from program-error/derive/src/macro_impl.rs rename to program-error-derive/src/macro_impl.rs diff --git a/program-error/derive/src/parser.rs b/program-error-derive/src/parser.rs similarity index 89% rename from program-error/derive/src/parser.rs rename to program-error-derive/src/parser.rs index f8436d5a..7cdd0f19 100644 --- a/program-error/derive/src/parser.rs +++ b/program-error-derive/src/parser.rs @@ -75,16 +75,8 @@ impl Parse for SplProgramErrorArgs { /// Parser for args to the `#[spl_program_error]` attribute. /// For example, `#[spl_program_error(hash_error_code_start = 1275525928)]`. enum SplProgramErrorArgParser { - HashErrorCodes { - _equals_sign: Token![=], - value: LitInt, - _comma: Option, - }, - SolanaProgramErrorCrate { - _equals_sign: Token![=], - value: LitStr, - _comma: Option, - }, + HashErrorCodes { value: LitInt }, + SolanaProgramErrorCrate { value: LitStr }, } impl Parse for SplProgramErrorArgParser { @@ -95,21 +87,13 @@ impl Parse for SplProgramErrorArgParser { let _equals_sign = input.parse::()?; let value = input.parse::()?; let _comma: Option = input.parse().unwrap_or(None); - Ok(Self::HashErrorCodes { - _equals_sign, - value, - _comma, - }) + Ok(Self::HashErrorCodes { value }) } "solana_program_error" => { let _equals_sign = input.parse::()?; let value = input.parse::()?; let _comma: Option = input.parse().unwrap_or(None); - Ok(Self::SolanaProgramErrorCrate { - _equals_sign, - value, - _comma, - }) + Ok(Self::SolanaProgramErrorCrate { value }) } _ => { Err(input diff --git a/program-error/Cargo.toml b/program-error/Cargo.toml index 52ea132b..173956c7 100644 --- a/program-error/Cargo.toml +++ b/program-error/Cargo.toml @@ -13,7 +13,7 @@ num_enum = "0.7" num-traits = "0.2" solana-msg = "3.0.0" solana-program-error = "3.0.0" -spl-program-error-derive = { version = "0.6.0", path = "./derive" } +spl-program-error-derive = { version = "0.6.0", path = "../program-error-derive" } thiserror = "2.0" [dev-dependencies] diff --git a/scripts/ci/set-env.mjs b/scripts/ci/set-env.mjs deleted file mode 100644 index 44f3b036..00000000 --- a/scripts/ci/set-env.mjs +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env zx -import { getSolanaVersion, getToolchain } from '../utils.mjs'; - -await $`echo "SOLANA_VERSION=${getSolanaVersion()}" >> $GITHUB_ENV`; -await $`echo "TOOLCHAIN_NIGHTLY=${getToolchain('nightly')}" >> $GITHUB_ENV`; diff --git a/scripts/js/format.mjs b/scripts/js/format.mjs deleted file mode 100644 index 30ae83be..00000000 --- a/scripts/js/format.mjs +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { cliArguments, workingDirectory } from '../utils.mjs'; - -const [folder, ...formatArgs] = cliArguments(); - -// Format the client using Prettier. -cd(path.join(workingDirectory, folder, 'js')); -await $`pnpm install`; -await $`pnpm format ${formatArgs}`; diff --git a/scripts/js/lint.mjs b/scripts/js/lint.mjs deleted file mode 100644 index c6aa6128..00000000 --- a/scripts/js/lint.mjs +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { cliArguments, workingDirectory } from '../utils.mjs'; - -const [folder, ...args] = cliArguments(); - -// Check the client using ESLint. -cd(path.join(workingDirectory, folder, 'js')); -await $`pnpm install`; -await $`pnpm lint ${args}`; diff --git a/scripts/js/publish.mjs b/scripts/js/publish.mjs deleted file mode 100644 index 26955f6e..00000000 --- a/scripts/js/publish.mjs +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { cliArguments, workingDirectory } from '../utils.mjs'; - -const [level, folder, tag = 'latest'] = cliArguments(); -if (!level) { - throw new Error('A version level — e.g. "path" — must be provided.'); -} - -// Go to the client directory and install the dependencies. -cd(path.join(workingDirectory, folder, 'js')); -await $`pnpm install`; - -// Update the version. -const versionArgs = [ - '--no-git-tag-version', - ...(level.startsWith('pre') ? [`--preid ${tag}`] : []), -]; -let { stdout } = await $`pnpm version ${level} ${versionArgs}`; -const newVersion = stdout.slice(1).trim(); - -// Expose the new version to CI if needed. -if (process.env.CI) { - await $`echo "new_version=${newVersion}" >> $GITHUB_OUTPUT`; -} - -// Publish the package. -// This will also build the package before publishing (see prepublishOnly script). -await $`pnpm publish --no-git-checks --tag ${tag}`; - -// Commit the new version. -await $`git commit -am "Publish ${folder} JS client v${newVersion}"`; - -// Tag the new version. -await $`git tag -a ${folder}-js@v${newVersion} -m "${folder} JS client v${newVersion}"`; diff --git a/scripts/js/test.mjs b/scripts/js/test.mjs deleted file mode 100644 index 46a8a2de..00000000 --- a/scripts/js/test.mjs +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { cliArguments, workingDirectory } from '../utils.mjs'; - -const [folder, ...args] = cliArguments(); - -// Build the client and run the tests. -cd(path.join(workingDirectory, folder, 'js')); -await $`pnpm install`; -await $`pnpm build`; -await $`pnpm test ${args}`; diff --git a/scripts/rust/audit.mjs b/scripts/rust/audit.mjs deleted file mode 100644 index 43bd2cfb..00000000 --- a/scripts/rust/audit.mjs +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; - -const advisories = [ - // ed25519-dalek: Double Public Key Signing Function Oracle Attack - // - // Remove once repo upgrades to ed25519-dalek v2 - 'RUSTSEC-2022-0093', - - // curve25519-dalek - // - // Remove once repo upgrades to curve25519-dalek v4 - 'RUSTSEC-2024-0344', - - // Crate: tonic - // Version: 0.9.2 - // Title: Remotely exploitable Denial of Service in Tonic - // Date: 2024-10-01 - // ID: RUSTSEC-2024-0376 - // URL: https://rustsec.org/advisories/RUSTSEC-2024-0376 - // Solution: Upgrade to >=0.12.3 - 'RUSTSEC-2024-0376', -]; -const ignores = [] -advisories.forEach(x => { - ignores.push('--ignore'); - ignores.push(x); -}); - -// Check Solana version. -await $`cargo audit ${ignores}`; diff --git a/scripts/rust/build-sbf.mjs b/scripts/rust/build-sbf.mjs deleted file mode 100644 index 64a80d34..00000000 --- a/scripts/rust/build-sbf.mjs +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { - cliArguments, - workingDirectory, -} from '../utils.mjs'; - -const [folder, ...args] = cliArguments(); -const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); -await $`cargo-build-sbf --manifest-path ${manifestPath} ${args}`; diff --git a/scripts/rust/format.mjs b/scripts/rust/format.mjs deleted file mode 100644 index 7e24c575..00000000 --- a/scripts/rust/format.mjs +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { - cliArguments, - getToolchainArgument, - partitionArguments, - popArgument, - workingDirectory, -} from '../utils.mjs'; - -const [folder, ...formatArgs] = cliArguments(); - -const fix = popArgument(formatArgs, '--fix'); -const [cargoArgs, fmtArgs] = partitionArguments(formatArgs, '--'); -const toolchain = getToolchainArgument('nightly'); - -const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); - -if (fix) { - await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`; -} else { - await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`; -} diff --git a/scripts/rust/hack.mjs b/scripts/rust/hack.mjs deleted file mode 100644 index 2e90c7a2..00000000 --- a/scripts/rust/hack.mjs +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { cliArguments, getToolchainArgument } from '../utils.mjs'; - -const toolchain = getToolchainArgument('nightly'); -await $`cargo ${toolchain} hack check --all-targets --feature-powerset ${cliArguments()}`; diff --git a/scripts/rust/lint.mjs b/scripts/rust/lint.mjs deleted file mode 100644 index 17be05a0..00000000 --- a/scripts/rust/lint.mjs +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { - cliArguments, - getToolchainArgument, - popArgument, - workingDirectory, -} from '../utils.mjs'; - -const [folder, ...args] = cliArguments(); - -// Configure arguments here. -const lintArgs = [ - '-Zunstable-options', - '--all-targets', - '--all-features', - '--', - '--deny=warnings', - '--deny=clippy::arithmetic_side_effects', - ...args, -]; - -const fix = popArgument(lintArgs, '--fix'); -const toolchain = getToolchainArgument('nightly'); - -const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); - -if (fix) { - await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} --fix ${lintArgs}`; -} else { - await $`cargo ${toolchain} clippy --manifest-path ${manifestPath} ${lintArgs}`; -} diff --git a/scripts/rust/publish.mjs b/scripts/rust/publish.mjs deleted file mode 100644 index 7141f9e6..00000000 --- a/scripts/rust/publish.mjs +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { cliArguments, getCargo, workingDirectory } from '../utils.mjs'; - -const dryRun = argv['dry-run'] ?? false; -const [folder, level] = cliArguments(); -if (!folder) { - throw new Error('A path to a directory with a Rust package — e.g. "clients/cli" — must be provided.'); -} -if (!level) { - throw new Error('A version level — e.g. "patch" — must be provided.'); -} - -cd(path.join(workingDirectory, folder)); - -const packageToml = getCargo(folder).package; -const oldVersion = packageToml.version; -const packageName = packageToml.name; -const tagName = packageName.replace(/spl-/, ''); - -// Publish the new version, commit the repo change, tag it, and push it all. -const releaseArgs = dryRun - ? [] - : ['--tag-name', `${tagName}@v{{version}}`, '--no-confirm', '--execute']; -await $`cargo release ${level} ${releaseArgs}`; - -// Stop here if this is a dry run. -if (dryRun) { - process.exit(0); -} - -// Get the new version. -const newVersion = getCargo(folder).package.version; -const newGitTag = `${tagName}@v${newVersion}`; -const oldGitTag = `${tagName}@v${oldVersion}`; - -// Expose the new version to CI if needed. -if (process.env.CI) { - await $`echo "new_git_tag=${newGitTag}" >> $GITHUB_OUTPUT`; - await $`echo "old_git_tag=${oldGitTag}" >> $GITHUB_OUTPUT`; -} diff --git a/scripts/rust/test.mjs b/scripts/rust/test.mjs deleted file mode 100644 index 6c5e0f9a..00000000 --- a/scripts/rust/test.mjs +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { - cliArguments, - workingDirectory, -} from '../utils.mjs'; - -const [folder, ...args] = cliArguments(); -const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); - -await $`RUST_LOG=error cargo test --manifest-path ${manifestPath} ${args}`; diff --git a/scripts/upgrade-template.mjs b/scripts/upgrade-template.mjs deleted file mode 100644 index a1e01b45..00000000 --- a/scripts/upgrade-template.mjs +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { getCargo } from './utils.mjs'; - -// Arguments to pass to the `create-solana-program` command. -const rustClientCargo = getCargo(path.join('clients', 'rust')); -const jsClientPkg = require( - path.join(__dirname, '..', 'clients', 'js', 'package.json') -); -const templateArgs = [ - 'memo', - '--address', - 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr', - '--org', - 'solana-program', - '--rust-client-crate-name', - rustClientCargo.package.name, - '--js-client-package-name', - jsClientPkg.name, - '--default', - '--force', -]; - -// File and folder patterns that should not be overwritten by the template upgrade. -const unchangedGlobs = [ - 'clients/**/src/**', - 'clients/**/src/*', - 'clients/js/test/*', - 'clients/rust/tests/*', - 'program/**/*', - 'program/*', - 'scripts/generate-clients.mjs', - 'scripts/generate-idls.mjs', - 'scripts/upgrade-template.mjs', - 'scripts/program/*', - 'Cargo.lock', - '**/pnpm-lock.yaml', - 'pnpm-lock.yaml', -]; - -// Prevent CLI arguments from being escaped. -$.quote = (command) => command; - -// Re-generate the repo from the parent directory. -cd('..'); -await $`pnpm create solana-program@latest ${templateArgs}`; - -// Go back inside the updated repo. -cd('memo'); - -// Restore files and folders that should not be overwritten. -await $`git add --all`; -for (const glob of unchangedGlobs) { - await $`git restore --worktree --staged "${glob}"`; -} - -// Re-install dependencies. -await $`pnpm install`; diff --git a/scripts/utils.mjs b/scripts/utils.mjs deleted file mode 100644 index e298a4c7..00000000 --- a/scripts/utils.mjs +++ /dev/null @@ -1,127 +0,0 @@ -import 'zx/globals'; -import { parse as parseToml } from '@iarna/toml'; - -$.verbose = true; -process.env.FORCE_COLOR = 3; -process.env.CARGO_TERM_COLOR = 'always'; - -export const workingDirectory = (await $`pwd`.quiet()).toString().trim(); - -export function getAllProgramIdls() { - return getAllProgramFolders().map((folder) => - path.join(workingDirectory, folder, 'idl.json') - ); -} - -export function getExternalProgramOutputDir() { - const config = getCargoMetadata()?.solana?.['external-programs-output']; - return path.join(workingDirectory, config ?? 'target/deploy'); -} - -export function getExternalProgramAddresses() { - const addresses = getProgramFolders().flatMap( - (folder) => getCargoMetadata(folder)?.solana?.['program-dependencies'] ?? [] - ); - return Array.from(new Set(addresses)); -} - -export function getExternalAccountAddresses() { - const addresses = getProgramFolders().flatMap( - (folder) => getCargoMetadata(folder)?.solana?.['account-dependencies'] ?? [] - ); - return Array.from(new Set(addresses)); -} - -let didWarnAboutMissingPrograms = false; -export function getProgramFolders() { - let programs; - - if (process.env.PROGRAMS) { - try { - programs = JSON.parse(process.env.PROGRAMS); - } catch (error) { - programs = process.env.PROGRAMS.split(/\s+/); - } - } else { - programs = getAllProgramFolders(); - } - - const filteredPrograms = programs.filter((program) => - fs.existsSync(path.join(workingDirectory, program)) - ); - - if ( - filteredPrograms.length !== programs.length && - !didWarnAboutMissingPrograms - ) { - didWarnAboutMissingPrograms = true; - programs - .filter((program) => !filteredPrograms.includes(program)) - .forEach((program) => { - echo(chalk.yellow(`Program not found: ${workingDirectory}/${program}`)); - }); - } - - return filteredPrograms; -} - -export function getAllProgramFolders() { - return getCargo().workspace.members.filter((member) => - (getCargo(member).lib?.['crate-type'] ?? []).includes('cdylib') - ); -} - -export function getCargo(folder) { - return parseToml( - fs.readFileSync( - path.join(workingDirectory, folder ? folder : '.', 'Cargo.toml'), - 'utf8' - ) - ); -} - -export function getCargoMetadata(folder) { - const cargo = getCargo(folder); - return folder ? cargo?.package?.metadata : cargo?.workspace?.metadata; -} - -export function getSolanaVersion() { - return getCargoMetadata()?.cli?.solana; -} - -export function getToolchain(operation) { - return getCargoMetadata()?.toolchains?.[operation]; -} - -export function getToolchainArgument(operation) { - const channel = getToolchain(operation); - return channel ? `+${channel}` : ''; -} - -export function cliArguments() { - return process.argv.slice(3); -} - -export function popArgument(args, arg) { - const index = args.indexOf(arg); - if (index >= 0) { - args.splice(index, 1); - } - return index >= 0; -} - -export function partitionArguments(args, delimiter) { - const index = args.indexOf(delimiter); - return index >= 0 - ? [args.slice(0, index), args.slice(index + 1)] - : [args, []]; -} - -export async function getInstalledSolanaVersion() { - try { - const { stdout } = await $`solana --version`.quiet(); - return stdout.match(/(\d+\.\d+\.\d+)/)?.[1]; - } catch (error) { - return ''; - } -} diff --git a/type-length-value/derive/Cargo.toml b/type-length-value-derive/Cargo.toml similarity index 100% rename from type-length-value/derive/Cargo.toml rename to type-length-value-derive/Cargo.toml diff --git a/type-length-value/derive/src/builder.rs b/type-length-value-derive/src/builder.rs similarity index 100% rename from type-length-value/derive/src/builder.rs rename to type-length-value-derive/src/builder.rs diff --git a/type-length-value/derive/src/lib.rs b/type-length-value-derive/src/lib.rs similarity index 100% rename from type-length-value/derive/src/lib.rs rename to type-length-value-derive/src/lib.rs diff --git a/type-length-value/js/.gitignore b/type-length-value-js/.gitignore similarity index 100% rename from type-length-value/js/.gitignore rename to type-length-value-js/.gitignore diff --git a/type-length-value/js/.mocharc.json b/type-length-value-js/.mocharc.json similarity index 100% rename from type-length-value/js/.mocharc.json rename to type-length-value-js/.mocharc.json diff --git a/type-length-value/js/.nojekyll b/type-length-value-js/.nojekyll similarity index 100% rename from type-length-value/js/.nojekyll rename to type-length-value-js/.nojekyll diff --git a/type-length-value/js/.prettierrc b/type-length-value-js/.prettierrc similarity index 100% rename from type-length-value/js/.prettierrc rename to type-length-value-js/.prettierrc diff --git a/type-length-value/js/LICENSE b/type-length-value-js/LICENSE similarity index 100% rename from type-length-value/js/LICENSE rename to type-length-value-js/LICENSE diff --git a/type-length-value/js/README.md b/type-length-value-js/README.md similarity index 100% rename from type-length-value/js/README.md rename to type-length-value-js/README.md diff --git a/type-length-value/js/eslint.config.mjs b/type-length-value-js/eslint.config.mjs similarity index 100% rename from type-length-value/js/eslint.config.mjs rename to type-length-value-js/eslint.config.mjs diff --git a/type-length-value/js/package.json b/type-length-value-js/package.json similarity index 100% rename from type-length-value/js/package.json rename to type-length-value-js/package.json diff --git a/type-length-value/js/pnpm-lock.yaml b/type-length-value-js/pnpm-lock.yaml similarity index 100% rename from type-length-value/js/pnpm-lock.yaml rename to type-length-value-js/pnpm-lock.yaml diff --git a/type-length-value/js/src/errors.ts b/type-length-value-js/src/errors.ts similarity index 100% rename from type-length-value/js/src/errors.ts rename to type-length-value-js/src/errors.ts diff --git a/type-length-value/js/src/index.ts b/type-length-value-js/src/index.ts similarity index 100% rename from type-length-value/js/src/index.ts rename to type-length-value-js/src/index.ts diff --git a/type-length-value/js/src/splDiscriminate.ts b/type-length-value-js/src/splDiscriminate.ts similarity index 100% rename from type-length-value/js/src/splDiscriminate.ts rename to type-length-value-js/src/splDiscriminate.ts diff --git a/type-length-value/js/src/tlvState.ts b/type-length-value-js/src/tlvState.ts similarity index 100% rename from type-length-value/js/src/tlvState.ts rename to type-length-value-js/src/tlvState.ts diff --git a/type-length-value/js/test/splDiscriminate.test.ts b/type-length-value-js/test/splDiscriminate.test.ts similarity index 100% rename from type-length-value/js/test/splDiscriminate.test.ts rename to type-length-value-js/test/splDiscriminate.test.ts diff --git a/type-length-value/js/test/tlvData.test.ts b/type-length-value-js/test/tlvData.test.ts similarity index 100% rename from type-length-value/js/test/tlvData.test.ts rename to type-length-value-js/test/tlvData.test.ts diff --git a/type-length-value/js/tsconfig.all.json b/type-length-value-js/tsconfig.all.json similarity index 100% rename from type-length-value/js/tsconfig.all.json rename to type-length-value-js/tsconfig.all.json diff --git a/type-length-value/js/tsconfig.base.json b/type-length-value-js/tsconfig.base.json similarity index 100% rename from type-length-value/js/tsconfig.base.json rename to type-length-value-js/tsconfig.base.json diff --git a/type-length-value/js/tsconfig.cjs.json b/type-length-value-js/tsconfig.cjs.json similarity index 100% rename from type-length-value/js/tsconfig.cjs.json rename to type-length-value-js/tsconfig.cjs.json diff --git a/type-length-value/js/tsconfig.esm.json b/type-length-value-js/tsconfig.esm.json similarity index 100% rename from type-length-value/js/tsconfig.esm.json rename to type-length-value-js/tsconfig.esm.json diff --git a/type-length-value/js/tsconfig.json b/type-length-value-js/tsconfig.json similarity index 100% rename from type-length-value/js/tsconfig.json rename to type-length-value-js/tsconfig.json diff --git a/type-length-value/js/tsconfig.root.json b/type-length-value-js/tsconfig.root.json similarity index 100% rename from type-length-value/js/tsconfig.root.json rename to type-length-value-js/tsconfig.root.json diff --git a/type-length-value/js/typedoc.json b/type-length-value-js/typedoc.json similarity index 100% rename from type-length-value/js/typedoc.json rename to type-length-value-js/typedoc.json diff --git a/type-length-value/Cargo.toml b/type-length-value/Cargo.toml index c490682e..7be69d4b 100644 --- a/type-length-value/Cargo.toml +++ b/type-length-value/Cargo.toml @@ -20,7 +20,7 @@ solana-account-info = "3.0.0" solana-msg = "3.0.0" solana-program-error = "3.0.0" spl-discriminator = { version = "0.5.1", path = "../discriminator" } -spl-type-length-value-derive = { version = "0.2", path = "./derive", optional = true } +spl-type-length-value-derive = { version = "0.2", path = "../type-length-value-derive", optional = true } spl-pod = { version = "0.7.1", path = "../pod" } thiserror = "2.0"