Steven Luscher преди 7 месеца
родител
ревизия
683bb985c1

+ 24 - 24
.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"

+ 1 - 1
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 = {

+ 1 - 1
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 {

+ 1 - 1
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,

+ 2 - 2
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",

+ 1 - 1
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"

+ 1 - 1
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 = {

+ 1 - 1
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,

+ 1 - 1
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,

+ 4 - 1
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,

+ 15 - 4
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<VersionWithoutPatch, Version> = {
+    '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 };
 }

+ 5 - 1
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];

+ 1 - 0
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 };
 }