Skip to content

Commit 1779402

Browse files
committed
Merge branch 'main' into pr/115
2 parents f3be5c4 + 683bb98 commit 1779402

File tree

6 files changed

+50
-31
lines changed

6 files changed

+50
-31
lines changed

.github/workflows/main.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
ANCHOR_VERSION: 0.30.0
1111
NODE_VERSION : 20
1212
SOLANA_VERSION: 1.18.18
13-
TOOLCHAIN: 1.75.0
13+
TOOLCHAIN: 1.81.0
1414

1515
jobs:
1616
lint:
@@ -59,6 +59,19 @@ jobs:
5959
cache: "pnpm"
6060
- name: Install dependencies
6161
run: pnpm install --frozen-lockfile
62+
- name: Cache cargo crates
63+
uses: actions/cache@v4
64+
with:
65+
path: |
66+
~/.cargo/bin/
67+
~/.cargo/registry/index/
68+
~/.cargo/registry/cache/
69+
~/.cargo/git/db/
70+
./projects/**/.cargo/
71+
./projects/**/target/
72+
key: ${{ runner.os }}-crates-solana-v${{ matrix.solana }}-${{ hashFiles('projects/**/Cargo.lock') }}
73+
restore-keys: |
74+
${{ runner.os }}-crates-solana-v${{ matrix.solana }}
6275
- name: Install Solana
6376
uses: solana-program/actions/install-solana@v1
6477
with:
@@ -80,19 +93,6 @@ jobs:
8093
version: ${{ matrix.anchor }}
8194
- name: Pre-scaffold projects for caching purposes
8295
run: pnpm snapshot ${{ matrix.project }} --scaffold-only
83-
- name: Cache cargo crates
84-
uses: actions/cache@v4
85-
with:
86-
path: |
87-
~/.cargo/bin/
88-
~/.cargo/registry/index/
89-
~/.cargo/registry/cache/
90-
~/.cargo/git/db/
91-
./projects/**/.cargo/
92-
./projects/**/target/
93-
key: ${{ runner.os }}-crates-solana-v${{ matrix.solana }}-${{ hashFiles('projects/**/Cargo.lock') }}
94-
restore-keys: |
95-
${{ runner.os }}-crates-solana-v${{ matrix.solana }}
9696
- name: Build and run tests
9797
run: pnpm snapshot ${{ matrix.project }} --test
9898

@@ -118,16 +118,6 @@ jobs:
118118
cache: "pnpm"
119119
- name: Install Dependencies
120120
run: pnpm install --frozen-lockfile
121-
- name: Install Solana
122-
uses: solana-program/actions/install-solana@v1
123-
with:
124-
version: ${{ env.SOLANA_VERSION }}
125-
- name: Install Anchor
126-
uses: metaplex-foundation/actions/install-anchor-cli@v1
127-
with:
128-
version: ${{ env.ANCHOR_VERSION }}
129-
- name: Pre-scaffold projects for caching purposes
130-
run: pnpm snapshot --scaffold-only
131121
- name: Cache cargo crates
132122
uses: actions/cache@v4
133123
with:
@@ -141,6 +131,16 @@ jobs:
141131
key: ${{ runner.os }}-crates-solana-v${{ env.SOLANA_VERSION }}-${{ hashFiles('projects/**/Cargo.lock') }}
142132
restore-keys: |
143133
${{ runner.os }}-crates-solana-v${{ env.SOLANA_VERSION }}
134+
- name: Install Solana
135+
uses: solana-program/actions/install-solana@v1
136+
with:
137+
version: ${{ env.SOLANA_VERSION }}
138+
- name: Install Anchor
139+
uses: metaplex-foundation/actions/install-anchor-cli@v1
140+
with:
141+
version: ${{ env.ANCHOR_VERSION }}
142+
- name: Pre-scaffold projects for caching purposes
143+
run: pnpm snapshot --scaffold-only
144144
- name: Setup git user
145145
run: |
146146
git config --global user.email "github-actions[bot]@users.noreply.github.com"

template/clients/rust/clients/rust/Cargo.toml.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test-sbf = []
1313
serde = ["dep:serde", "dep:serde_with"]
1414

1515
[dependencies]
16-
anchor-lang = { version = "0.30.0", optional = true }
16+
anchor-lang = { version = "{{ anchorVersion.full }}", optional = true }
1717
borsh = "^0.10"
1818
num-derive = "^0.3"
1919
num-traits = "^0.2"

utils/renderContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ export function getRenderContext({
5757
const repositoryUrl = `https://github.com/${inputs.organizationName}/${inputs.targetDirectoryName}`;
5858

5959
// Versions.
60-
const anchorVersion = resolveAnchorVersion(anchorVersionDetected);
6160
const solanaVersion = resolveSolanaVersion(
6261
language,
6362
inputs.solanaVersion,
6463
solanaVersionDetected
6564
);
65+
const anchorVersion = resolveAnchorVersion(
66+
anchorVersionDetected,
67+
solanaVersion
68+
);
6669
const rustVersion = resolveRustVersion(
6770
language,
6871
solanaVersion,

utils/versionAnchor.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getVersionFromStdout,
66
ResolvedVersion,
77
Version,
8+
VersionWithoutPatch,
89
} from './versionCore';
910

1011
export async function detectAnchorVersion(
@@ -20,10 +21,20 @@ export async function detectAnchorVersion(
2021
}
2122

2223
export function resolveAnchorVersion(
23-
detectedVersion: Version | undefined
24+
detectedVersion: Version | undefined,
25+
solanaVersion: ResolvedVersion
2426
): ResolvedVersion | undefined {
25-
if (!detectedVersion) return undefined;
26-
const [full, withoutPatch] =
27-
getVersionAndVersionWithoutPatch(detectedVersion);
27+
const fallbackVersionMap: Record<VersionWithoutPatch, Version> = {
28+
'1.17': '0.29.0',
29+
'1.18': '0.30.0',
30+
'2.0': '0.30.0',
31+
'2.1': '0.31.0',
32+
'2.2': '0.31.0',
33+
};
34+
const fallbackVersion: Version =
35+
fallbackVersionMap[solanaVersion.withoutPatch] ?? '0.30.0';
36+
const [full, withoutPatch] = getVersionAndVersionWithoutPatch(
37+
detectedVersion ?? fallbackVersion
38+
);
2839
return { full, withoutPatch, detected: detectedVersion };
2940
}

utils/versionRust.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ export function resolveRustVersion(
2929
'1.17': '1.75.0',
3030
'1.18': '1.75.0',
3131
'2.0': '1.75.0',
32+
'2.1': '1.79.0',
33+
'2.2': '1.79.0',
3234
};
3335
const fallbackVersion =
34-
solanaToRustMap[solanaVersion.withoutPatch] ?? '1.75.0';
36+
solanaToRustMap[solanaVersion.withoutPatch] ?? '1.79.0';
3537

3638
const version = inputVersion ?? detectedVersion ?? fallbackVersion;
3739
assertIsValidVersion(language, 'Rust', version);
@@ -53,6 +55,8 @@ function warnAboutSolanaRustVersionMismatch(
5355
'1.17': '1.68.0',
5456
'1.18': '1.75.0',
5557
'2.0': '1.75.0',
58+
'2.1': '1.79.0',
59+
'2.2': '1.79.0',
5660
};
5761
const minimumViableRustVersion: Version | undefined =
5862
minimumViableRustVersionPerSolanaVersion[solanaVersion.withoutPatch];

utils/versionSolana.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export function resolveSolanaVersion(
3030
const [full, withoutPatch] = getVersionAndVersionWithoutPatch(version, {
3131
'1.17': '1.17.34',
3232
'1.18': '1.18.18',
33+
'2.1': '2.1.16',
3334
});
3435
return { full, withoutPatch, detected: detectedVersion };
3536
}

0 commit comments

Comments
 (0)