From c61f9da14dee2b46de485e0f897091d5ede4b1f8 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Fri, 28 Mar 2025 23:06:35 +0000 Subject: [PATCH 1/9] Bump CI to Rust 1.81.0 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 143a80a..bd58e06 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ env: ANCHOR_VERSION: 0.30.0 NODE_VERSION : 20 SOLANA_VERSION: 1.18.18 - TOOLCHAIN: 1.75.0 + TOOLCHAIN: 1.81.0 jobs: lint: From 07bdb990e29fab9f13c1ab6a45922272103c53ff Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 11:45:59 +0000 Subject: [PATCH 2/9] Bump Solana to 2.1.9 in CI --- .github/workflows/main.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd58e06..a95ec92 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,8 +8,8 @@ on: env: ANCHOR_VERSION: 0.30.0 - NODE_VERSION : 20 - SOLANA_VERSION: 1.18.18 + NODE_VERSION : 22 + SOLANA_VERSION: 2.1.9 TOOLCHAIN: 1.81.0 jobs: @@ -37,14 +37,10 @@ jobs: strategy: matrix: project: ["counter-anchor", "counter-shank"] - solana: ["1.17.34", "1.18.18"] + solana: ["1.18.18", "2.1.9"] include: - anchor: "0.30.0" project: "counter-anchor" - solana: "1.18.18" - - anchor: "0.29.0" - project: "counter-anchor" - solana: "1.17.34" steps: - name: Git checkout uses: actions/checkout@v4 From 29d98cad74bf49303a60abb366ddab2fa88d5870 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 11:55:54 +0000 Subject: [PATCH 3/9] Update Anchor --- .github/workflows/main.yml | 6 +++++- template/clients/rust/clients/rust/Cargo.toml.njk | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a95ec92..96b3ea3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: branches: [main] env: - ANCHOR_VERSION: 0.30.0 + ANCHOR_VERSION: 0.31.0 NODE_VERSION : 22 SOLANA_VERSION: 2.1.9 TOOLCHAIN: 1.81.0 @@ -39,8 +39,12 @@ jobs: project: ["counter-anchor", "counter-shank"] solana: ["1.18.18", "2.1.9"] include: + - anchor: "0.31.0" + project: "counter-anchor" + solana: "2.1.9" - anchor: "0.30.0" project: "counter-anchor" + solana: "1.18.18" steps: - name: Git checkout uses: actions/checkout@v4 diff --git a/template/clients/rust/clients/rust/Cargo.toml.njk b/template/clients/rust/clients/rust/Cargo.toml.njk index 17d491e..0593cdb 100644 --- a/template/clients/rust/clients/rust/Cargo.toml.njk +++ b/template/clients/rust/clients/rust/Cargo.toml.njk @@ -13,7 +13,7 @@ test-sbf = [] serde = ["dep:serde", "dep:serde_with"] [dependencies] -anchor-lang = { version = "0.30.0", optional = true } +anchor-lang = { version = "{{ anchorVersion.full }}", optional = true } borsh = "^0.10" num-derive = "^0.3" num-traits = "^0.2" From 91429fff0cbf4a70b5f36c76746767fc4775fe56 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 12:11:36 +0000 Subject: [PATCH 4/9] Provide fallback Anchor version --- utils/versionAnchor.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/versionAnchor.ts b/utils/versionAnchor.ts index 039f0ad..97077a1 100644 --- a/utils/versionAnchor.ts +++ b/utils/versionAnchor.ts @@ -7,6 +7,8 @@ import { Version, } from './versionCore'; +export const FALLBACK_ANCHOR_VERSION: Version = '0.31.0'; + export async function detectAnchorVersion( language: Language ): Promise { @@ -22,8 +24,8 @@ export async function detectAnchorVersion( export function resolveAnchorVersion( detectedVersion: Version | undefined ): ResolvedVersion | undefined { - if (!detectedVersion) return undefined; - const [full, withoutPatch] = - getVersionAndVersionWithoutPatch(detectedVersion); + const [full, withoutPatch] = getVersionAndVersionWithoutPatch( + detectedVersion ?? FALLBACK_ANCHOR_VERSION + ); return { full, withoutPatch, detected: detectedVersion }; } From 0782ce4c21ae78795325dbc2973c3b18b13be97b Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 12:23:06 +0000 Subject: [PATCH 5/9] Add more entries to Solana version maps --- utils/versionRust.ts | 6 +++++- utils/versionSolana.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/versionRust.ts b/utils/versionRust.ts index 7511344..c1ee85f 100644 --- a/utils/versionRust.ts +++ b/utils/versionRust.ts @@ -29,9 +29,11 @@ export function resolveRustVersion( '1.17': '1.75.0', '1.18': '1.75.0', '2.0': '1.75.0', + '2.1': '1.79.0', + '2.2': '1.79.0', }; const fallbackVersion = - solanaToRustMap[solanaVersion.withoutPatch] ?? '1.75.0'; + solanaToRustMap[solanaVersion.withoutPatch] ?? '1.79.0'; const version = inputVersion ?? detectedVersion ?? fallbackVersion; assertIsValidVersion(language, 'Rust', version); @@ -53,6 +55,8 @@ function warnAboutSolanaRustVersionMismatch( '1.17': '1.68.0', '1.18': '1.75.0', '2.0': '1.75.0', + '2.1': '1.79.0', + '2.2': '1.79.0', }; const minimumViableRustVersion: Version | undefined = minimumViableRustVersionPerSolanaVersion[solanaVersion.withoutPatch]; diff --git a/utils/versionSolana.ts b/utils/versionSolana.ts index c02341c..0f20a3a 100644 --- a/utils/versionSolana.ts +++ b/utils/versionSolana.ts @@ -30,6 +30,7 @@ export function resolveSolanaVersion( const [full, withoutPatch] = getVersionAndVersionWithoutPatch(version, { '1.17': '1.17.34', '1.18': '1.18.18', + '2.1': '2.1.16', }); return { full, withoutPatch, detected: detectedVersion }; } From d1061edc21317976884c0f2d45e2fbf013ccf226 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 13:07:31 +0000 Subject: [PATCH 6/9] Try to make Anchor 0.30.0 work first --- .github/workflows/main.yml | 50 +++++++++++++++++++------------------- utils/versionAnchor.ts | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96b3ea3..f4ecca2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: branches: [main] env: - ANCHOR_VERSION: 0.31.0 + ANCHOR_VERSION: 0.30.0 NODE_VERSION : 22 SOLANA_VERSION: 2.1.9 TOOLCHAIN: 1.81.0 @@ -39,7 +39,7 @@ jobs: project: ["counter-anchor", "counter-shank"] solana: ["1.18.18", "2.1.9"] include: - - anchor: "0.31.0" + - anchor: "0.30.0" project: "counter-anchor" solana: "2.1.9" - anchor: "0.30.0" @@ -59,6 +59,19 @@ jobs: cache: "pnpm" - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Cache cargo crates + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./projects/**/.cargo/ + ./projects/**/target/ + key: ${{ runner.os }}-crates-solana-v${{ matrix.solana }}-${{ hashFiles('projects/**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-crates-solana-v${{ matrix.solana }} - name: Install Solana uses: solana-program/actions/install-solana@v1 with: @@ -80,19 +93,6 @@ jobs: version: ${{ matrix.anchor }} - name: Pre-scaffold projects for caching purposes run: pnpm snapshot ${{ matrix.project }} --scaffold-only - - name: Cache cargo crates - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ./projects/**/.cargo/ - ./projects/**/target/ - key: ${{ runner.os }}-crates-solana-v${{ matrix.solana }}-${{ hashFiles('projects/**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-crates-solana-v${{ matrix.solana }} - name: Build and run tests run: pnpm snapshot ${{ matrix.project }} --test @@ -118,16 +118,6 @@ jobs: cache: "pnpm" - name: Install Dependencies run: pnpm install --frozen-lockfile - - name: Install Solana - uses: solana-program/actions/install-solana@v1 - with: - version: ${{ env.SOLANA_VERSION }} - - name: Install Anchor - uses: metaplex-foundation/actions/install-anchor-cli@v1 - with: - version: ${{ env.ANCHOR_VERSION }} - - name: Pre-scaffold projects for caching purposes - run: pnpm snapshot --scaffold-only - name: Cache cargo crates uses: actions/cache@v4 with: @@ -141,6 +131,16 @@ jobs: key: ${{ runner.os }}-crates-solana-v${{ env.SOLANA_VERSION }}-${{ hashFiles('projects/**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-crates-solana-v${{ env.SOLANA_VERSION }} + - name: Install Solana + uses: solana-program/actions/install-solana@v1 + with: + version: ${{ env.SOLANA_VERSION }} + - name: Install Anchor + uses: metaplex-foundation/actions/install-anchor-cli@v1 + with: + version: ${{ env.ANCHOR_VERSION }} + - name: Pre-scaffold projects for caching purposes + run: pnpm snapshot --scaffold-only - name: Setup git user run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" diff --git a/utils/versionAnchor.ts b/utils/versionAnchor.ts index 97077a1..9d0945a 100644 --- a/utils/versionAnchor.ts +++ b/utils/versionAnchor.ts @@ -7,7 +7,7 @@ import { Version, } from './versionCore'; -export const FALLBACK_ANCHOR_VERSION: Version = '0.31.0'; +export const FALLBACK_ANCHOR_VERSION: Version = '0.30.0'; export async function detectAnchorVersion( language: Language From 55b3cc1139c644710aa6828c0fb5b0361e749da4 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 13:16:50 +0000 Subject: [PATCH 7/9] Make Anchor version fallback depend on Solana version --- utils/renderContext.ts | 5 ++++- utils/versionAnchor.ts | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/utils/renderContext.ts b/utils/renderContext.ts index 00d1a8a..a027d38 100644 --- a/utils/renderContext.ts +++ b/utils/renderContext.ts @@ -57,12 +57,15 @@ export function getRenderContext({ const repositoryUrl = `https://github.com/${inputs.organizationName}/${inputs.targetDirectoryName}`; // Versions. - const anchorVersion = resolveAnchorVersion(anchorVersionDetected); const solanaVersion = resolveSolanaVersion( language, inputs.solanaVersion, solanaVersionDetected ); + const anchorVersion = resolveAnchorVersion( + anchorVersionDetected, + solanaVersion + ); const rustVersion = resolveRustVersion( language, solanaVersion, diff --git a/utils/versionAnchor.ts b/utils/versionAnchor.ts index 9d0945a..f529b95 100644 --- a/utils/versionAnchor.ts +++ b/utils/versionAnchor.ts @@ -5,10 +5,9 @@ import { getVersionFromStdout, ResolvedVersion, Version, + VersionWithoutPatch, } from './versionCore'; -export const FALLBACK_ANCHOR_VERSION: Version = '0.30.0'; - export async function detectAnchorVersion( language: Language ): Promise { @@ -22,10 +21,20 @@ export async function detectAnchorVersion( } export function resolveAnchorVersion( - detectedVersion: Version | undefined + detectedVersion: Version | undefined, + solanaVersion: ResolvedVersion ): ResolvedVersion | undefined { + const fallbackVersionMap: Record = { + '1.17': '0.29.0', + '1.18': '0.30.0', + '2.0': '0.30.0', + '2.1': '0.31.0', + '2.2': '0.31.0', + }; + const fallbackVersion: Version = + fallbackVersionMap[solanaVersion.withoutPatch] ?? '0.30.0'; const [full, withoutPatch] = getVersionAndVersionWithoutPatch( - detectedVersion ?? FALLBACK_ANCHOR_VERSION + detectedVersion ?? fallbackVersion ); return { full, withoutPatch, detected: detectedVersion }; } From 9eaf3a7106c28c8c0210eea299e24de6e4f91241 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 13:27:03 +0000 Subject: [PATCH 8/9] Update @solana/web3.js imports in templates --- template/anchor/clients/js/clients/js/test/_setup.ts | 2 +- template/anchor/clients/js/clients/js/test/create.test.ts | 2 +- .../anchor/clients/js/clients/js/test/increment.test.ts.njk | 2 +- template/clients/js/clients/js/package.json.njk | 4 ++-- template/shank/clients/js/clients/js/test/_setup.ts | 2 +- template/shank/clients/js/clients/js/test/create.test.ts | 2 +- .../shank/clients/js/clients/js/test/increment.test.ts.njk | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/template/anchor/clients/js/clients/js/test/_setup.ts b/template/anchor/clients/js/clients/js/test/_setup.ts index c88a54a..6aa35b4 100644 --- a/template/anchor/clients/js/clients/js/test/_setup.ts +++ b/template/anchor/clients/js/clients/js/test/_setup.ts @@ -21,7 +21,7 @@ import { setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, signTransactionMessageWithSigners, -} from '@solana/web3.js'; +} from '@solana/kit'; import { getCreateInstruction } from '../src'; type Client = { diff --git a/template/anchor/clients/js/clients/js/test/create.test.ts b/template/anchor/clients/js/clients/js/test/create.test.ts index 2c12a7e..cde9463 100644 --- a/template/anchor/clients/js/clients/js/test/create.test.ts +++ b/template/anchor/clients/js/clients/js/test/create.test.ts @@ -3,7 +3,7 @@ import { appendTransactionMessageInstruction, generateKeyPairSigner, pipe, -} from '@solana/web3.js'; +} from '@solana/kit'; import test from 'ava'; import { Counter, fetchCounter, getCreateInstruction } from '../src'; import { diff --git a/template/anchor/clients/js/clients/js/test/increment.test.ts.njk b/template/anchor/clients/js/clients/js/test/increment.test.ts.njk index d759883..4428a74 100644 --- a/template/anchor/clients/js/clients/js/test/increment.test.ts.njk +++ b/template/anchor/clients/js/clients/js/test/increment.test.ts.njk @@ -6,7 +6,7 @@ import { isSolanaError, lamports, pipe, -} from '@solana/web3.js'; +} from '@solana/kit'; import test from 'ava'; import { {{ programName | snakeCase | upper }}_ERROR__INVALID_AUTHORITY, diff --git a/template/clients/js/clients/js/package.json.njk b/template/clients/js/clients/js/package.json.njk index fc4c773..e67e4a7 100644 --- a/template/clients/js/clients/js/package.json.njk +++ b/template/clients/js/clients/js/package.json.njk @@ -42,12 +42,12 @@ "homepage": "{{ repositoryUrl }}#readme", "license": "MIT", "peerDependencies": { - "@solana/web3.js": "^2.0.0" + "@solana/kit": "^2.1.0" }, "devDependencies": { "@ava/typescript": "^4.1.0", "@solana/eslint-config-solana": "^3.0.3", - "@solana/web3.js": "^2.0.0", + "@solana/kit": "^2.1.0", "@types/node": "^20", "@typescript-eslint/eslint-plugin": "^7.16.1", "@typescript-eslint/parser": "^7.16.1", diff --git a/template/shank/clients/js/clients/js/test/_setup.ts b/template/shank/clients/js/clients/js/test/_setup.ts index aaabfc2..c2a2977 100644 --- a/template/shank/clients/js/clients/js/test/_setup.ts +++ b/template/shank/clients/js/clients/js/test/_setup.ts @@ -22,7 +22,7 @@ import { setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, signTransactionMessageWithSigners, -} from '@solana/web3.js'; +} from '@solana/kit'; import { findCounterPda, getCreateInstructionAsync } from '../src'; type Client = { diff --git a/template/shank/clients/js/clients/js/test/create.test.ts b/template/shank/clients/js/clients/js/test/create.test.ts index b1a5376..0b12bb3 100644 --- a/template/shank/clients/js/clients/js/test/create.test.ts +++ b/template/shank/clients/js/clients/js/test/create.test.ts @@ -2,7 +2,7 @@ import { Account, appendTransactionMessageInstruction, pipe, -} from '@solana/web3.js'; +} from '@solana/kit'; import test from 'ava'; import { Counter, diff --git a/template/shank/clients/js/clients/js/test/increment.test.ts.njk b/template/shank/clients/js/clients/js/test/increment.test.ts.njk index ba3e576..b8b760b 100644 --- a/template/shank/clients/js/clients/js/test/increment.test.ts.njk +++ b/template/shank/clients/js/clients/js/test/increment.test.ts.njk @@ -5,7 +5,7 @@ import { isSolanaError, lamports, pipe, -} from '@solana/web3.js'; +} from '@solana/kit'; import test from 'ava'; import { {{ programName | snakeCase | upper }}_ERROR__INVALID_PDA, From a908b04c9b1f05798fdbb01fff42071a0b33d9ac Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Sat, 29 Mar 2025 13:57:58 +0000 Subject: [PATCH 9/9] Revert 2.1 changes for now Anchor CLI 0.31.0 is not installable as standalone and breaks CI --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4ecca2..b29536c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,8 +8,8 @@ on: env: ANCHOR_VERSION: 0.30.0 - NODE_VERSION : 22 - SOLANA_VERSION: 2.1.9 + NODE_VERSION : 20 + SOLANA_VERSION: 1.18.18 TOOLCHAIN: 1.81.0 jobs: @@ -37,14 +37,14 @@ jobs: strategy: matrix: project: ["counter-anchor", "counter-shank"] - solana: ["1.18.18", "2.1.9"] + solana: ["1.17.34", "1.18.18"] include: - - anchor: "0.30.0" - project: "counter-anchor" - solana: "2.1.9" - anchor: "0.30.0" project: "counter-anchor" solana: "1.18.18" + - anchor: "0.29.0" + project: "counter-anchor" + solana: "1.17.34" steps: - name: Git checkout uses: actions/checkout@v4