diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 143a80a..b29536c 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: @@ -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/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/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" 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, 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 039f0ad..f529b95 100644 --- a/utils/versionAnchor.ts +++ b/utils/versionAnchor.ts @@ -5,6 +5,7 @@ import { getVersionFromStdout, ResolvedVersion, Version, + VersionWithoutPatch, } from './versionCore'; export async function detectAnchorVersion( @@ -20,10 +21,20 @@ export async function detectAnchorVersion( } export function resolveAnchorVersion( - detectedVersion: Version | undefined + detectedVersion: Version | undefined, + solanaVersion: ResolvedVersion ): ResolvedVersion | undefined { - if (!detectedVersion) return undefined; - const [full, withoutPatch] = - getVersionAndVersionWithoutPatch(detectedVersion); + 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 ?? fallbackVersion + ); return { full, withoutPatch, detected: detectedVersion }; } 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 }; }