From 1f2ad52e7c2d94c08185ad840b126440bec56c29 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 26 Jul 2024 08:34:27 +0000 Subject: [PATCH] version 0.3.8 snapshot --- .github/actions/setup/action.yml | 13 +- .github/workflows/main.yml | 22 +- .github/workflows/publish-js-client.yml | 99 +++++++++ .github/workflows/publish-rust-client.yml | 125 +++++++++++ Cargo.lock | 216 +++++++++---------- Cargo.toml | 3 + clients/js/package.json | 4 +- clients/js/src/generated/programs/counter.ts | 16 +- clients/rust/Cargo.toml | 2 + package.json | 6 +- pnpm-lock.yaml | 30 +-- scripts/check-solana-version.mjs | 18 ++ scripts/ci/set-env.mjs | 3 +- scripts/client/publish-js.mjs | 35 +++ scripts/client/publish-rust.mjs | 40 ++++ scripts/link-solana-version.mjs | 56 +++++ scripts/start-validator.mjs | 3 + scripts/utils.mjs | 17 ++ 18 files changed, 549 insertions(+), 159 deletions(-) create mode 100644 .github/workflows/publish-js-client.yml create mode 100644 .github/workflows/publish-rust-client.yml create mode 100644 scripts/check-solana-version.mjs create mode 100644 scripts/client/publish-js.mjs create mode 100644 scripts/client/publish-rust.mjs create mode 100644 scripts/link-solana-version.mjs diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 037e15f..28323e5 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -13,14 +13,11 @@ inputs: clippy: description: Install Clippy if `true`. Defaults to `false`. required: false - node: - description: The Node.js version to install. Required. - required: true rustfmt: description: Install Rustfmt if `true`. Defaults to `false`. required: false solana: - description: The Solana version to install. Skips if not provided. + description: Install Solana if `true`. Defaults to `false`. required: false runs: @@ -32,7 +29,7 @@ runs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ inputs.node }} + node-version: 18 cache: 'pnpm' - name: Install Dependencies @@ -43,7 +40,6 @@ runs: shell: bash run: pnpm zx ./scripts/ci/set-env.mjs - - name: Install Rustfmt if: ${{ inputs.rustfmt == 'true' }} uses: dtolnay/rust-toolchain@master @@ -59,13 +55,12 @@ runs: components: clippy - name: Install Solana - if: ${{ inputs.solana }} + if: ${{ inputs.solana == 'true' }} uses: metaplex-foundation/actions/install-solana@v1 with: - version: ${{ inputs.solana }} + version: ${{ env.SOLANA_VERSION }} cache: true - - name: Cache Cargo Dependencies if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }} uses: actions/cache@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 454f60b..7f38b0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,10 +6,6 @@ on: pull_request: branches: [main] -env: - NODE_VERSION: 18 - SOLANA_VERSION: 1.18.18 - jobs: format_and_lint_programs: name: Format & Lint Programs @@ -22,7 +18,6 @@ jobs: uses: ./.github/actions/setup with: clippy: true - node: ${{ env.NODE_VERSION }} rustfmt: true - name: Format Programs @@ -40,8 +35,6 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup - with: - node: ${{ env.NODE_VERSION }} - name: Format Client JS run: pnpm clients:js:format @@ -60,7 +53,6 @@ jobs: uses: ./.github/actions/setup with: clippy: true - node: ${{ env.NODE_VERSION }} rustfmt: true - name: Format Client Rust @@ -81,8 +73,7 @@ jobs: uses: ./.github/actions/setup with: cargo-cache-key: cargo-programs - node: ${{ env.NODE_VERSION }} - solana: ${{ env.SOLANA_VERSION }} + solana: true - name: Build Programs run: pnpm programs:build @@ -113,8 +104,7 @@ jobs: with: cargo-cache-key: cargo-program-tests cargo-cache-fallback-key: cargo-programs - node: ${{ env.NODE_VERSION }} - solana: ${{ env.SOLANA_VERSION }} + solana: true - name: Test Programs run: pnpm programs:test @@ -132,7 +122,6 @@ jobs: with: cargo-cache-key: cargo-programs cargo-cache-local-key: cargo-local - node: ${{ env.NODE_VERSION }} - name: Generate IDLs run: pnpm generate:idls @@ -153,7 +142,6 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup with: - node: ${{ env.NODE_VERSION }} rustfmt: true - name: Generate Clients @@ -175,8 +163,7 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup with: - node: ${{ env.NODE_VERSION }} - solana: ${{ env.SOLANA_VERSION }} + solana: true - name: Restore Program Builds uses: actions/cache/restore@v4 @@ -199,8 +186,7 @@ jobs: uses: ./.github/actions/setup with: cargo-cache-key: cargo-rust-client - node: ${{ env.NODE_VERSION }} - solana: ${{ env.SOLANA_VERSION }} + solana: true - name: Restore Program Builds uses: actions/cache/restore@v4 diff --git a/.github/workflows/publish-js-client.yml b/.github/workflows/publish-js-client.yml new file mode 100644 index 0000000..d32f29a --- /dev/null +++ b/.github/workflows/publish-js-client.yml @@ -0,0 +1,99 @@ +name: Publish JS Client + +on: + workflow_dispatch: + inputs: + level: + description: Version level + required: true + default: patch + type: choice + options: + - patch + - minor + - major + - prerelease + - prepatch + - preminor + - premajor + tag: + description: NPM Tag (and preid for pre-releases) + required: true + type: string + default: latest + create_release: + description: Create a GitHub release + required: true + type: boolean + default: true + +jobs: + test_js: + name: Test JS client + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Environment + uses: ./.github/actions/setup + with: + cargo-cache-key: cargo-programs + solana: true + + - name: Format JS Client + run: pnpm clients:js:format + + - name: Lint JS Client + run: pnpm clients:js:lint + + - name: Build Programs + run: pnpm programs:build + + - name: Test JS Client + run: pnpm clients:js:test + + publish_js: + name: Publish JS client + runs-on: ubuntu-latest + needs: test_js + permissions: + contents: write + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Environment + uses: ./.github/actions/setup + + - name: Ensure NPM_TOKEN variable is set + env: + token: ${{ secrets.NPM_TOKEN }} + if: ${{ env.token == '' }} + run: | + echo "The NPM_TOKEN secret variable is not set" + echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"." + exit 1 + + - name: NPM Authentication + run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - 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 JS Client + id: publish + run: pnpm clients:js:publish ${{ inputs.level }} ${{ inputs.tag }} + + - name: Push Commit and Tag + run: git push origin --follow-tags + + - name: Create GitHub release + if: github.event.inputs.create_release == 'true' + uses: ncipollo/release-action@v1 + with: + tag: js@v${{ steps.publish.outputs.new_version }} diff --git a/.github/workflows/publish-rust-client.yml b/.github/workflows/publish-rust-client.yml new file mode 100644 index 0000000..546cee7 --- /dev/null +++ b/.github/workflows/publish-rust-client.yml @@ -0,0 +1,125 @@ +name: Publish Rust Client + +on: + workflow_dispatch: + inputs: + level: + description: Level + required: true + default: patch + type: choice + options: + - patch + - minor + - major + - rc + - beta + - alpha + - release + - version + version: + description: Version + required: false + type: string + dry_run: + description: Dry run + required: true + default: true + type: boolean + create_release: + description: Create a GitHub release + required: true + type: boolean + default: true + +jobs: + test_rust: + name: Test Rust client + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Environment + uses: ./.github/actions/setup + with: + cargo-cache-key: cargo-rust-client + clippy: true + rustfmt: true + solana: true + + - name: Format Rust Client + run: pnpm clients:rust:format + + - name: Lint Rust Client + run: pnpm clients:rust:lint + + - name: Build Programs + run: pnpm programs:build + + - name: Test Rust Client + run: pnpm clients:rust:test + + publish_rust: + name: Publish Rust Client + runs-on: ubuntu-latest + needs: test_rust + permissions: + contents: write + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Environment + uses: ./.github/actions/setup + with: + cargo-cache-key: cargo-publish-rust-client + cargo-cache-fallback-key: cargo-rust-client + clippy: true + rustfmt: true + + - name: Install Cargo Release + run: which cargo-release || cargo install cargo-release + + - name: Ensure CARGO_REGISTRY_TOKEN variable is set + env: + token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + if: ${{ env.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 Rust Client + id: publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: | + if [ "${{ inputs.level }}" == "version" ]; then + LEVEL=${{ inputs.version }} + else + LEVEL=${{ inputs.level }} + fi + + if [ "${{ inputs.dry_run }}" == "true" ]; then + OPTIONS="--dry-run" + else + OPTIONS="" + fi + + pnpm clients:rust:publish $LEVEL $OPTIONS + + - name: Push Commit and Tag + if: github.event.inputs.dry_run != 'true' + run: git push origin --follow-tags + + - name: Create GitHub release + if: github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true' + uses: ncipollo/release-action@v1 + with: + tag: rust@v${{ steps.publish.outputs.new_version }} diff --git a/Cargo.lock b/Cargo.lock index 3e91390..a957918 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2411,9 +2411,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.1" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -2665,15 +2665,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" [[package]] name = "predicates-tree" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" dependencies = [ "predicates-core", "termtree", @@ -3540,9 +3540,9 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "858d76518bc5f4b62f1798d9f34c6cdb7773cd4a58f5024d47c0c059e510ec54" +checksum = "5e621af8405ad85f2c3822bb1794f57389b7bc2e8c8c49e0d5a38b85b8955565" dependencies = [ "Inflector", "base64 0.21.7", @@ -3565,9 +3565,9 @@ dependencies = [ [[package]] name = "solana-accounts-db" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79144855424895cdce15661a6a3ba92dd0741d39dd98cb5df27170a3f428bccc" +checksum = "b420b71476b1c5acd3552ecd5c6e360f46a262c972d02dac1a7d5eacb2d5adf0" dependencies = [ "arrayref", "bincode", @@ -3626,9 +3626,9 @@ dependencies = [ [[package]] name = "solana-address-lookup-table-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca4af36d1f110d45831cde1a0a4f31acfaf13ef93d2e6b65bb82bf93589e0df4" +checksum = "76ed10ab9edfb4bf390cf15c3f5fb075a78b202e4041af3db4d3fd899c4adfc5" dependencies = [ "bincode", "bytemuck", @@ -3647,9 +3647,9 @@ dependencies = [ [[package]] name = "solana-banks-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a2bdb680a1127e5cf37484ceb943380758d1d41c33ba5d247bd4932e5b210" +checksum = "704018ba89029425150d17ae69d668e3ecb076151d3446cf99862f7ca491f8b0" dependencies = [ "borsh 1.5.1", "futures", @@ -3664,9 +3664,9 @@ dependencies = [ [[package]] name = "solana-banks-interface" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c98e1c481511f4ad8de6669f0f58f065fe793532de6dd669a4d051d551c358c" +checksum = "100f1e18910f6c666d8860a675c2cc6a3e4f92c1b99b6948192da8fe1b6156f6" dependencies = [ "serde", "solana-sdk", @@ -3675,9 +3675,9 @@ dependencies = [ [[package]] name = "solana-banks-server" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd4a09141ace7a836379f06a91f719c743528a4383704db2275c0a0526715ef" +checksum = "ac37078f40d968d3e47156ec5f65b392dba76618777c6f7fa915ced84a8f3f99" dependencies = [ "bincode", "crossbeam-channel", @@ -3695,9 +3695,9 @@ dependencies = [ [[package]] name = "solana-bpf-loader-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a86797d4c08b7cf63be9d048f5ae6c1094b6775f6932d314c28b88c8ab44c5b" +checksum = "38d5e8dc69cfae82adf204822398688bc89ad1849964231c28037d7e5bede949" dependencies = [ "bincode", "byteorder", @@ -3714,9 +3714,9 @@ dependencies = [ [[package]] name = "solana-bucket-map" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd83a1eaf6d8b6afa1c6e31905e1067661915cbbf1a3afc11be71a9f868026e" +checksum = "af5cd35ff8bc73727f1eab457e0a3e97d683fcfbef2a324981a3b62d1fe17c15" dependencies = [ "bv", "bytemuck", @@ -3732,9 +3732,9 @@ dependencies = [ [[package]] name = "solana-clap-utils" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f15dfe0df5a51fb9b090f44b5a1c1712adcb23885f7305918572bf2fed03da0" +checksum = "cfefc0f73fab9535c91c5bc4077ca21ce0b966df1fece0c39e5ff3f5617a9f78" dependencies = [ "chrono", "clap 2.34.0", @@ -3749,9 +3749,9 @@ dependencies = [ [[package]] name = "solana-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b53c210eae9e2676e7ba87b61052529a8b32a948b0965e2509718ec562e8b1c5" +checksum = "398c11649c8a1918e84935ca4fbcfe1bcb55ba1aa83d3051994595ba6833d8c6" dependencies = [ "async-trait", "bincode", @@ -3782,9 +3782,9 @@ dependencies = [ [[package]] name = "solana-compute-budget-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b894c589f455d4204eeef7639515cade28df0f76339deb7c1ba1af685609cfa3" +checksum = "36964b228f72bac36a820acde67cd5c80d07af26d30fdf6fe83586a139c4f53c" dependencies = [ "solana-program-runtime", "solana-sdk", @@ -3792,9 +3792,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a7517c2431e8270936838d00f8964d1270f179c42d07075dc37b8f49cbc134" +checksum = "5544b247de63cb2a90f8d8dbbe61468405ed9895d245c1e28f7806c918fe0fb4" dependencies = [ "bincode", "chrono", @@ -3806,9 +3806,9 @@ dependencies = [ [[package]] name = "solana-connection-cache" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b19e22bf5105114ec7a577b9d1c0eaf73790f5b4bb671ab2dcc598b17d45edf" +checksum = "8e3f0556a82d5da2693159f150f3da5b5bdbf2fc0e8b3181b5ed9347096074e8" dependencies = [ "async-trait", "bincode", @@ -3828,9 +3828,9 @@ dependencies = [ [[package]] name = "solana-cost-model" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09be721520e24947c2b78d87923e7873d09f579362cf33eef14a8e32efbe4a98" +checksum = "6bcac1b4ae9a7ed8cb8578d448d713ef4b98cfb7c8cc3ba76fac94b7631b6b9b" dependencies = [ "lazy_static", "log", @@ -3852,9 +3852,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d836521fc3fe09fbc45ccf194c7524a73865e2fa4f2f3316c987e33ffad037ec" +checksum = "0f0c52f25d28a1b5af57d5de3802e49883f68792a343101a9daf9817d8dfffff" dependencies = [ "block-buffer 0.10.4", "bs58", @@ -3877,9 +3877,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce5a9e8a27bce6104994ca8b0fa16b496260fe9e093f76e68c4301fcf93de2d4" +checksum = "fc7d0abca44a21c83305e8650341f67ccc919a1a9dd698ddafc86e78b74b9296" dependencies = [ "proc-macro2", "quote", @@ -3889,9 +3889,9 @@ dependencies = [ [[package]] name = "solana-loader-v4-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a0a87b1b29dcd7b97f1411ce085fadd1704b1b8dd2165ce6e43aa4aaeeabb9" +checksum = "504108d5cb774abf89d0cf673ab6950bfe257aadf2fa872adb32b1473f7818f5" dependencies = [ "log", "solana-measure", @@ -3902,9 +3902,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7b9835d78974f576628a6ae7858813a69e106850a8d3df96f6e5624cc9c5b1" +checksum = "d5bc0644a410b8bff84ad18541a176f27776062b1ad116cb315c6f5f14b94fed" dependencies = [ "env_logger", "lazy_static", @@ -3913,9 +3913,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469f5bf8d065e56a19968453d60294824c78ea99470ba1899e277f0703c305e9" +checksum = "3b2a96265160981b5aab8a73c9830f2cd8ce7b557790d19c18cabb8565563f2f" dependencies = [ "log", "solana-sdk", @@ -3923,9 +3923,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41cb53ebd3e885e4e12149e90fd6f75419fa319706359e74b5076c9d1f4a3d8" +checksum = "d140890d4f906315533de1c9b929e1b3b8f4a0515f45a85ee90859778ea6e6ab" dependencies = [ "crossbeam-channel", "gethostname", @@ -3938,9 +3938,9 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d6d8f92c16bc3afd497f72c6fa6094e8eb23017eecc0ba1d392efac9d6354ef" +checksum = "024848a9557dc5054ed96c3532b95ddefb753d68b677eb0495f69cc456160e8a" dependencies = [ "bincode", "clap 3.2.25", @@ -3966,9 +3966,9 @@ checksum = "8b8a731ed60e89177c8a7ab05fe0f1511cedd3e70e773f288f9de33a9cfdc21e" [[package]] name = "solana-perf" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85f9c7b24eb650f1256685027f4d8df5401cc4107be8874198b2685e79da38b3" +checksum = "599733dcb745a7a346bc9ea540603078c99aa97e2da7395a269774a92231ebd4" dependencies = [ "ahash 0.8.11", "bincode", @@ -3995,9 +3995,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b359778df37b366b137d51ba7cdd884ffb23df7d7602bf1a27f8593df19a290" +checksum = "76a99c3bc26fda40f42db98494271bda4906b0d7ab55f3ea7755fa5f110f58b5" dependencies = [ "ark-bn254", "ark-ec", @@ -4078,9 +4078,9 @@ dependencies = [ [[package]] name = "solana-program-runtime" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cee7681a4dc163bf394f783f0b0d5bafd01bcb15435f63d9534cf5b3af18a1b" +checksum = "11ae79e82b97a66ff00770d9190abc7e6b610c108254cd84fcd0f100a1c4d165" dependencies = [ "base64 0.21.7", "bincode", @@ -4106,9 +4106,9 @@ dependencies = [ [[package]] name = "solana-program-test" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4790760a24699e034797587a621458b3d4e7b9cd14f7f21c17143598b473705c" +checksum = "48bad4093f3dc41967e33e644e09649fb86eabb67ed731cdb18b1303d053a48c" dependencies = [ "assert_matches", "async-trait", @@ -4136,9 +4136,9 @@ dependencies = [ [[package]] name = "solana-pubsub-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42497e99b56426ef8892674826b90588b1cb2d7f8e6dbf45712877e0619ef8d7" +checksum = "de7e67897cf69c207977eaf7923541d026b3de92f313df5f625461609c618325" dependencies = [ "crossbeam-channel", "futures-util", @@ -4161,9 +4161,9 @@ dependencies = [ [[package]] name = "solana-quic-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bb49aae206f2663b20f14a6055b2edb0fee5ec3a96c426f0030d0f07356b79" +checksum = "13b3ca213d9c133d28484ac0eb1c741078d2495ec15fcc62f55357529147b528" dependencies = [ "async-mutex", "async-trait", @@ -4188,9 +4188,9 @@ dependencies = [ [[package]] name = "solana-rayon-threadlimit" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043997fe4be94325a3250387e9935307f332cdf2028327d68fd32065ff833fd9" +checksum = "379bd42e389ae50f7b9c6e4a32f7b2c6f1eb41f064d76158b50003877d4c7844" dependencies = [ "lazy_static", "num_cpus", @@ -4198,9 +4198,9 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24475162f780747091badb38d6dd0e6ae4f68ae42df81a26e0e810cdb4f6d36" +checksum = "d55362fbec27c74974fe9c5a0c89d8fb082d9a5063c9ca7ce30857b61d8003ad" dependencies = [ "console", "dialoguer", @@ -4217,9 +4217,9 @@ dependencies = [ [[package]] name = "solana-rpc-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9632daf7f2f8865c5fcd01cbea830bc8ca016fb83f65a0dd323d03b39f1c6530" +checksum = "d4dc7051e6e999041ac99c011f253012d594325b244ab9b2fd349dee1c1f2276" dependencies = [ "async-trait", "base64 0.21.7", @@ -4243,9 +4243,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-api" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f4ccdd0afcb17cbf096fb63a94c141965c307492df5d21a13cc8d938e5a98b" +checksum = "4c7c5df5da53559461efae1ff370f6d89866246fc1dcbb3c3cb86b6d91cb565a" dependencies = [ "base64 0.21.7", "bs58", @@ -4265,9 +4265,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-nonce-utils" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e66c66a8b22a9e57c7e02e3c92d5c997bcfa0dcbc518775e1d3b0a396b6d628" +checksum = "7c7e57bc4da80bf225ba4835f876c07f66d1fe37b765efc8250beaf05202be46" dependencies = [ "clap 2.34.0", "solana-clap-utils", @@ -4278,9 +4278,9 @@ dependencies = [ [[package]] name = "solana-runtime" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c92605bbd04e6c4221f1d9306e06099929a65d2343626edf196151c117294a" +checksum = "70146346ffa147cc48238bac5bc75defd0016a217baf640957565c12701cccfe" dependencies = [ "aquamarine", "arrayref", @@ -4355,9 +4355,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea6dfe2df7cb0ab6a4e5b5c17653e9cdd9b4bda779f867807dd24fb37821681" +checksum = "90a8affb5b3acd43f7164368b88243bf091e46eccff9bea5b743e4691d7c2600" dependencies = [ "assert_matches", "base64 0.21.7", @@ -4410,9 +4410,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91222f769514bbeb30af1cbe05e6904e8364286dc6253017b1630e7835855b41" +checksum = "4c2ac8d7ef471476164edb2ed105bcf26071835a15f0e74703929d4ec913676b" dependencies = [ "bs58", "proc-macro2", @@ -4429,9 +4429,9 @@ checksum = "468aa43b7edb1f9b7b7b686d5c3aeb6630dc1708e86e31343499dd5c4d775183" [[package]] name = "solana-send-transaction-service" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df03dd6e4cca06dcdec58c72edca1bbcf16feda863e6e4510bca107b2ec014c5" +checksum = "2cb273c3f59950d747ac54396babcc6aca09fcb6ac40c83313ce4a65eb4ea208" dependencies = [ "crossbeam-channel", "log", @@ -4445,9 +4445,9 @@ dependencies = [ [[package]] name = "solana-stake-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642d54ceffa7591ee671107427642cd7ab7db44ccb1c82d180b8e3d3ce803270" +checksum = "ddeec78f830d8d91d4185d4cb92760efcc757013c57347de1dfd19cb3bfd07c1" dependencies = [ "bincode", "log", @@ -4460,9 +4460,9 @@ dependencies = [ [[package]] name = "solana-streamer" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24ec13f6452602acc92fde9a5a25ebedcd5cdf9046ac61abdb858777d705f4c" +checksum = "3027d10aacba000eca43ac59acfec0069f93dbe3ea372d94eb7d25ed490b396d" dependencies = [ "async-channel", "bytes", @@ -4493,9 +4493,9 @@ dependencies = [ [[package]] name = "solana-system-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219911bc2ade84da49e6b61407919b33bb4d73048fd22a2efa698c0673ee4c06" +checksum = "244a998e66934e5a6283f69500da23af5c1d09c1f8493bc1b04d3b2f1553dad9" dependencies = [ "bincode", "log", @@ -4507,9 +4507,9 @@ dependencies = [ [[package]] name = "solana-thin-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdd17f6d058b1d91c30e02378a589b73f6b35f2036404085a2e5c2334086b486" +checksum = "6e49f48b5734d90c9cc6022a2b3dcf31a8794d565850a25ff5b9820e16bd40e9" dependencies = [ "bincode", "log", @@ -4522,9 +4522,9 @@ dependencies = [ [[package]] name = "solana-tpu-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f0a76d7d8bb550362475dbfdcb87a859750ab97a47737958872399edbcb1da" +checksum = "474f9cd741f564f8a92b7a73da1c83ceb80137bad1b25f403bc1c57468c3e6a3" dependencies = [ "async-trait", "bincode", @@ -4546,9 +4546,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2e8166111b92972f50b5d99667826d3e5100dc54d737ac6bfb9f3ead8284ef" +checksum = "65cbdbde85fff3b4c2e134f6bd70d26c0cc9cd2b63892be2afd424a21e2b316b" dependencies = [ "Inflector", "base64 0.21.7", @@ -4571,9 +4571,9 @@ dependencies = [ [[package]] name = "solana-udp-client" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ed56ba6ca891e77b0c0aba8742a5629e064c7578d00d7443f4686998619a422" +checksum = "e1263d731f2ee858b36fc6dac56be7fe7dc46fe223de6867c8a957cd587d565e" dependencies = [ "async-trait", "solana-connection-cache", @@ -4586,9 +4586,9 @@ dependencies = [ [[package]] name = "solana-version" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64bf30455622c1c6c6b404ed40405ec7d2cc3465ad4ce7dea4a87b048372b6c3" +checksum = "c24d542f3b834717e81ac0d44905d3efa27ddf21c265a163e8b54ea0358204f5" dependencies = [ "log", "rustc_version", @@ -4602,9 +4602,9 @@ dependencies = [ [[package]] name = "solana-vote" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e316c5d4e8dd00e211b2165c4811b6cf836620b66b482cea757df4c1acc642" +checksum = "a11718909a64a22de2745be42f4f3f195122b3da8b028af75e3139198da0a373" dependencies = [ "crossbeam-channel", "itertools", @@ -4621,9 +4621,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fabfb416ff1172347fb8fb8e8932884875186a236d7e01a038148f5ce0d0ef" +checksum = "8f26743a7027077e88cd4b136099c926dc04b38dc638e88223e88c5d05b3374a" dependencies = [ "bincode", "log", @@ -4643,9 +4643,9 @@ dependencies = [ [[package]] name = "solana-zk-token-proof-program" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e53293114e6a65d95a73fce6257fe562d9e18b93cc0f7fc5b3a9572df247b87" +checksum = "cdfb619937c8cda3c862151473cf1a8443ac5b2e75a5b8a8675fcf9b1f0aa08c" dependencies = [ "bytemuck", "num-derive 0.4.2", @@ -4657,9 +4657,9 @@ dependencies = [ [[package]] name = "solana-zk-token-sdk" -version = "1.18.19" +version = "1.18.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922f5998e2ceb3d64f64f297445c3ed442320569e4d22a940a7e855bde2a90f5" +checksum = "8cf73fd7e430bf3269539c2fb1d05af0df26fc3b7bc090172ceda5cd4340657c" dependencies = [ "aes-gcm-siv", "base64 0.21.7", @@ -5281,9 +5281,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.0" +version = "1.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3318c4fc7126c339a40fbc025927d0328ca32259f68bfe4321660644c1f626" +checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" dependencies = [ "backtrace", "bytes", @@ -5399,9 +5399,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" [[package]] name = "toml_edit" @@ -5626,9 +5626,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "void" diff --git a/Cargo.toml b/Cargo.toml index ceff85b..6085a5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ resolver = "2" members = ["clients/rust", "program"] +[workspace.metadata.cli] +solana = "1.18.18" + # Specify Rust toolchains for rustfmt, clippy, and build. # Any unprovided toolchains default to stable. [workspace.metadata.toolchains] diff --git a/clients/js/package.json b/clients/js/package.json index 37e4c0e..ffd66bd 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -54,7 +54,9 @@ "typescript": "^5.5.3" }, "ava": { - "nodeArguments": ["--no-warnings"], + "nodeArguments": [ + "--no-warnings" + ], "require": [ "@solana/webcrypto-ed25519-polyfill" ], diff --git a/clients/js/src/generated/programs/counter.ts b/clients/js/src/generated/programs/counter.ts index 109e81a..b7267b7 100644 --- a/clients/js/src/generated/programs/counter.ts +++ b/clients/js/src/generated/programs/counter.ts @@ -6,7 +6,12 @@ * @see https://github.com/kinobi-so/kinobi */ -import { containsBytes, getU8Encoder, type Address } from '@solana/web3.js'; +import { + containsBytes, + getU8Encoder, + type Address, + type ReadonlyUint8Array, +} from '@solana/web3.js'; import { type ParsedCreateInstruction, type ParsedIncrementInstruction, @@ -21,9 +26,9 @@ export enum CounterAccount { } export function identifyCounterAccount( - account: { data: Uint8Array } | Uint8Array + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array ): CounterAccount { - const data = account instanceof Uint8Array ? account : account.data; + const data = 'data' in account ? account.data : account; if (containsBytes(data, getKeyEncoder().encode(Key.Counter), 0)) { return CounterAccount.Counter; } @@ -38,10 +43,9 @@ export enum CounterInstruction { } export function identifyCounterInstruction( - instruction: { data: Uint8Array } | Uint8Array + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array ): CounterInstruction { - const data = - instruction instanceof Uint8Array ? instruction : instruction.data; + const data = 'data' in instruction ? instruction.data : instruction; if (containsBytes(data, getU8Encoder().encode(0), 0)) { return CounterInstruction.Create; } diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index 1e48d0e..d5e4ad1 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -1,6 +1,8 @@ [package] name = "solana-program-counter-client" version = "0.0.0" +description = "A generated Rust library for the Counter program" +repository = "https://github.com/solana-program/counter-shank" edition = "2021" readme = "README.md" license-file = "../../LICENSE" diff --git a/package.json b/package.json index e3ee00c..ad303ff 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "programs:format": "zx ./scripts/program/format.mjs", "programs:lint": "zx ./scripts/program/lint.mjs", "generate:idls": "zx ./scripts/generate-idls.mjs", + "solana:check": "zx ./scripts/check-solana-version.mjs", + "solana:link": "zx ./scripts/link-solana-version.mjs", "generate": "pnpm generate:idls && pnpm generate:clients", "generate:clients": "zx ./scripts/generate-clients.mjs", "validator:start": "zx ./scripts/start-validator.mjs", @@ -14,15 +16,17 @@ "validator:stop": "zx ./scripts/stop-validator.mjs", "clients:js:format": "zx ./scripts/client/format-js.mjs", "clients:js:lint": "zx ./scripts/client/lint-js.mjs", + "clients:js:publish": "zx ./scripts/client/publish-js.mjs", "clients:js:test": "zx ./scripts/client/test-js.mjs", "clients:rust:format": "zx ./scripts/client/format-rust.mjs", "clients:rust:lint": "zx ./scripts/client/lint-rust.mjs", + "clients:rust:publish": "zx ./scripts/client/publish-rust.mjs", "clients:rust:test": "zx ./scripts/client/test-rust.mjs" }, "devDependencies": { "@iarna/toml": "^2.2.5", "@kinobi-so/nodes-from-anchor": "^0.20.9", - "@kinobi-so/renderers-js": "^0.21.0", + "@kinobi-so/renderers-js": "^0.21.2", "@kinobi-so/renderers-rust": "^0.21.0", "@metaplex-foundation/shank-js": "^0.1.7", "kinobi": "^0.21.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85eb095..20aced6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^0.20.9 version: 0.20.9 '@kinobi-so/renderers-js': - specifier: ^0.21.0 - version: 0.21.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) + specifier: ^0.21.2 + version: 0.21.2(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) '@kinobi-so/renderers-rust': specifier: ^0.21.0 version: 0.21.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) @@ -54,8 +54,8 @@ packages: '@kinobi-so/renderers-core@0.20.7': resolution: {integrity: sha512-KJhU8+UMowO9dDkLhEodAkbRkgSxdfBWeY+DIgOCgXcakt0T140K7OREuaAo9fp12Owf+10SAEGx9AzTNySoHA==} - '@kinobi-so/renderers-js@0.21.1': - resolution: {integrity: sha512-qJGalIl2lTO0Y2chjotCTqcLEAbgfAEijROGp6VTdeOGt07SITw5O28xqZc40MDEssToGTUkOm3QvxLd0z2JRg==} + '@kinobi-so/renderers-js@0.21.2': + resolution: {integrity: sha512-G576GAQ10ugmA63EZRlEbv892th37q9ow+AMzZD1vtypRCEJ7znakzySSDG3aeqaZujk2igKXFQTD+FHuY/xPg==} '@kinobi-so/renderers-rust@0.21.0': resolution: {integrity: sha512-BLe1SW6XFBhjtZdCc7cuukMWrJTbhCafCCmXryLmjzF7jaiK9nyZZFinHxljSac4HCk2vDn22mHAwOjabaDQ2Q==} @@ -122,8 +122,8 @@ packages: '@types/minimist@1.2.5': resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} - '@types/node@18.19.41': - resolution: {integrity: sha512-LX84pRJ+evD2e2nrgYCHObGWkiQJ1mL+meAgbvnwk/US6vmMY7S2ygBTGV2Jw91s9vUsLSXeDEkUHZIJGLrhsg==} + '@types/node@18.19.42': + resolution: {integrity: sha512-d2ZFc/3lnK2YCYhos8iaNIYu9Vfhr92nHiyJHRltXWjXUBjEE+A4I58Tdbnw4VhggSW+2j5y5gTrLs4biNnubg==} '@types/ps-tree@1.1.6': resolution: {integrity: sha512-PtrlVaOaI44/3pl3cvnlK+GxOM3re2526TJvPvh7W+keHIXdV4TE0ylpPBAcvFQCbGitaTXwL9u+RF7qtVeazQ==} @@ -427,8 +427,8 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} hasBin: true - yaml@2.4.5: - resolution: {integrity: sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==} + yaml@2.5.0: + resolution: {integrity: sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==} engines: {node: '>= 14'} hasBin: true @@ -467,7 +467,7 @@ snapshots: '@kinobi-so/nodes': 0.21.0 '@kinobi-so/visitors-core': 0.21.0 - '@kinobi-so/renderers-js@0.21.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': + '@kinobi-so/renderers-js@0.21.2(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': dependencies: '@kinobi-so/errors': 0.21.0 '@kinobi-so/nodes': 0.21.0 @@ -572,15 +572,15 @@ snapshots: '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 18.19.41 + '@types/node': 18.19.42 '@types/jsonfile@6.1.4': dependencies: - '@types/node': 18.19.41 + '@types/node': 18.19.42 '@types/minimist@1.2.5': {} - '@types/node@18.19.41': + '@types/node@18.19.42': dependencies: undici-types: 5.26.5 @@ -855,13 +855,13 @@ snapshots: dependencies: isexe: 2.0.0 - yaml@2.4.5: {} + yaml@2.5.0: {} zx@7.2.3: dependencies: '@types/fs-extra': 11.0.4 '@types/minimist': 1.2.5 - '@types/node': 18.19.41 + '@types/node': 18.19.42 '@types/ps-tree': 1.1.6 '@types/which': 3.0.4 chalk: 5.3.0 @@ -873,4 +873,4 @@ snapshots: ps-tree: 1.2.0 webpod: 0.0.2 which: 3.0.1 - yaml: 2.4.5 + yaml: 2.5.0 diff --git a/scripts/check-solana-version.mjs b/scripts/check-solana-version.mjs new file mode 100644 index 0000000..f0844be --- /dev/null +++ b/scripts/check-solana-version.mjs @@ -0,0 +1,18 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { getInstalledSolanaVersion, getSolanaVersion } from './utils.mjs'; + +const expectedVersion = getSolanaVersion(); +const installedVersion = await getInstalledSolanaVersion(); + +if (installedVersion !== expectedVersion) { + echo( + chalk.yellow('[ WARNING ]'), + `The installed Solana version ${installedVersion} does not match the expected version ${expectedVersion}.` + ); +} else { + echo( + chalk.green('[ SUCCESS ]'), + `The expected Solana version ${expectedVersion} is installed.` + ); +} diff --git a/scripts/ci/set-env.mjs b/scripts/ci/set-env.mjs index fce8848..276d37b 100644 --- a/scripts/ci/set-env.mjs +++ b/scripts/ci/set-env.mjs @@ -1,5 +1,6 @@ #!/usr/bin/env zx -import { getToolchain } from '../utils.mjs'; +import { getSolanaVersion, getToolchain } from '../utils.mjs'; +await $`echo "SOLANA_VERSION=${getSolanaVersion()}" >> $GITHUB_ENV`; await $`echo "TOOLCHAIN_FORMAT=${getToolchain('format')}" >> $GITHUB_ENV`; await $`echo "TOOLCHAIN_LINT=${getToolchain('lint')}" >> $GITHUB_ENV`; diff --git a/scripts/client/publish-js.mjs b/scripts/client/publish-js.mjs new file mode 100644 index 0000000..51df188 --- /dev/null +++ b/scripts/client/publish-js.mjs @@ -0,0 +1,35 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { cliArguments, workingDirectory } from '../utils.mjs'; + +const [level, 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, 'clients', '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 JS client v${newVersion}"`; + +// Tag the new version. +await $`git tag -a js@v${newVersion} -m "JS client v${newVersion}"`; diff --git a/scripts/client/publish-rust.mjs b/scripts/client/publish-rust.mjs new file mode 100644 index 0000000..b7a9fa6 --- /dev/null +++ b/scripts/client/publish-rust.mjs @@ -0,0 +1,40 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { cliArguments, getCargo, workingDirectory } from '../utils.mjs'; + +const dryRun = argv['dry-run'] ?? false; +const [level] = 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, 'clients', 'rust')); + +// Publish the new version. +const releaseArgs = dryRun + ? [] + : ['--no-push', '--no-tag', '--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(path.join('clients', 'rust')).package.version; + +// Expose the new version to CI if needed. +if (process.env.CI) { + await $`echo "new_version=${newVersion}" >> $GITHUB_OUTPUT`; +} + +// Soft reset the last commit so we can create our own commit and tag. +await $`git reset --soft HEAD~1`; + +// Commit the new version. +await $`git commit -am "Publish Rust client v${newVersion}"`; + +// Tag the new version. +await $`git tag -a rust@v${newVersion} -m "Rust client v${newVersion}"`; diff --git a/scripts/link-solana-version.mjs b/scripts/link-solana-version.mjs new file mode 100644 index 0000000..acc0a04 --- /dev/null +++ b/scripts/link-solana-version.mjs @@ -0,0 +1,56 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { getInstalledSolanaVersion, getSolanaVersion } from './utils.mjs'; + +const installedVersion = await getInstalledSolanaVersion(); +const expectedVersion = getSolanaVersion(); + +if (installedVersion === expectedVersion) { + echo( + chalk.green('[ SUCCESS ]'), + `The expected Solana version ${expectedVersion} is installed.` + ); + process.exit(0); +} + +const installPath = path.join( + os.homedir(), + '.local', + 'share', + 'solana', + 'install' +); +const releasePath = path.join( + installPath, + 'releases', + expectedVersion, + 'solana-release' +); +const activeReleasePath = path.join(installPath, 'active_release'); +const hasRelease = await fs.exists(releasePath); + +if (hasRelease) { + await $`rm -f "${activeReleasePath}"`; + await $`ln -s "${releasePath}" "${activeReleasePath}"`; + echo( + chalk.green('[ SUCCESS ]'), + `Successfully switched from Solana version ${installedVersion} to ${expectedVersion} to match the project's requirements.` + ); + process.exit(0); +} + +echo( + chalk.yellow('[ WARNING ]'), + `Cannot switch from Solana version ${installedVersion} to ${expectedVersion} because it is not installed.` +); + +const installRelease = await question('Should we install it now? [y/N] '); +if (installRelease === 'y') { + echo(`Installing Solana ${expectedVersion}...`); + await $`sh -c "$(curl -sSfL https://release.solana.com/v${expectedVersion}/install)"`; +} + +echo( + chalk.green('[ SUCCESS ]'), + `Successfully switched from Solana version ${installedVersion} to ${expectedVersion} to match the project's requirements.` +); diff --git a/scripts/start-validator.mjs b/scripts/start-validator.mjs index 278379f..1adbcab 100755 --- a/scripts/start-validator.mjs +++ b/scripts/start-validator.mjs @@ -10,6 +10,9 @@ import { getProgramFolders, } from './utils.mjs'; +// Check Solana version. +await $`pnpm solana:check`; + // Options and arguments. const restart = argv['restart']; diff --git a/scripts/utils.mjs b/scripts/utils.mjs index d72935c..274f217 100644 --- a/scripts/utils.mjs +++ b/scripts/utils.mjs @@ -84,6 +84,10 @@ export function getCargoMetadata(folder) { return folder ? cargo?.package?.metadata : cargo?.workspace?.metadata; } +export function getSolanaVersion() { + return getCargoMetadata()?.cli?.solana; +} + export function getToolchain(operation) { return getCargoMetadata()?.toolchains?.[operation]; } @@ -111,3 +115,16 @@ export function partitionArguments(args, delimiter) { ? [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) { + echo( + chalk.red('[ ERROR ]'), + `No Solana installation found. Please install Solana ${getSolanaVersion()} before proceeding.` + ); + process.exit(1); + } +}