diff --git a/Cargo.lock b/Cargo.lock index ddbf675..f1ae297 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,6 +117,184 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "anchor-attribute-access-control" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47fe28365b33e8334dd70ae2f34a43892363012fe239cf37d2ee91693575b1f8" +dependencies = [ + "anchor-syn", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-account" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c288d496168268d198d9b53ee9f4f9d260a55ba4df9877ea1d4486ad6109e0f" +dependencies = [ + "anchor-syn", + "bs58 0.5.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-constant" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b77b6948d0eeaaa129ce79eea5bbbb9937375a9241d909ca8fb9e006bb6e90" +dependencies = [ + "anchor-syn", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-error" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d20bb569c5a557c86101b944721d865e1fd0a4c67c381d31a44a84f07f84828" +dependencies = [ + "anchor-syn", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-event" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cebd8d0671a3a9dc3160c48598d652c34c77de6be4d44345b8b514323284d57" +dependencies = [ + "anchor-syn", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-program" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efb2a5eb0860e661ab31aff7bb5e0288357b176380e985bade4ccb395981b42d" +dependencies = [ + "anchor-lang-idl", + "anchor-syn", + "anyhow", + "bs58 0.5.1", + "heck 0.3.3", + "proc-macro2", + "quote", + "serde_json", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-accounts" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04368b5abef4266250ca8d1d12f4dff860242681e4ec22b885dcfe354fd35aa1" +dependencies = [ + "anchor-syn", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-serde" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0bb0e0911ad4a70cab880cdd6287fe1e880a1a9d8e4e6defa8e9044b9796a6c" +dependencies = [ + "anchor-syn", + "borsh-derive-internal 0.10.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-space" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef415ff156dc82e9ecb943189b0cb241b3a6bfc26a180234dc21bd3ef3ce0cb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-lang" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6620c9486d9d36a4389cab5e37dc34a42ed0bfaa62e6a75a2999ce98f8f2e373" +dependencies = [ + "anchor-attribute-access-control", + "anchor-attribute-account", + "anchor-attribute-constant", + "anchor-attribute-error", + "anchor-attribute-event", + "anchor-attribute-program", + "anchor-derive-accounts", + "anchor-derive-serde", + "anchor-derive-space", + "arrayref", + "base64 0.21.7", + "bincode", + "borsh 0.10.3", + "bytemuck", + "getrandom 0.2.15", + "solana-program", + "thiserror", +] + +[[package]] +name = "anchor-lang-idl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31cf97b4e6f7d6144a05e435660fcf757dbc3446d38d0e2b851d11ed13625bba" +dependencies = [ + "anchor-lang-idl-spec", + "anyhow", + "heck 0.3.3", + "serde", + "serde_json", + "sha2 0.10.8", +] + +[[package]] +name = "anchor-lang-idl-spec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdf143115440fe621bdac3a29a1f7472e09f6cd82b2aa569429a0c13f103838" +dependencies = [ + "anyhow", + "serde", +] + +[[package]] +name = "anchor-syn" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f99daacb53b55cfd37ce14d6c9905929721137fd4c67bbab44a19802aecb622f" +dependencies = [ + "anyhow", + "bs58 0.5.1", + "heck 0.3.3", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.10.8", + "syn 1.0.109", + "thiserror", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -661,6 +839,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -1632,6 +1819,15 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.1" @@ -3501,7 +3697,7 @@ dependencies = [ "Inflector", "base64 0.21.7", "bincode", - "bs58", + "bs58 0.4.0", "bv", "lazy_static", "serde", @@ -3811,7 +4007,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35a0b24cc4d0ebd5fd45d6bd47bed3790f8a75ade67af8ff24a3d719a8bc93bc" dependencies = [ "block-buffer 0.10.4", - "bs58", + "bs58 0.4.0", "bv", "either", "generic-array", @@ -3964,7 +4160,7 @@ dependencies = [ "borsh 0.10.3", "borsh 0.9.3", "borsh 1.5.0", - "bs58", + "bs58 0.4.0", "bv", "bytemuck", "cc", @@ -4150,7 +4346,7 @@ dependencies = [ "async-trait", "base64 0.21.7", "bincode", - "bs58", + "bs58 0.4.0", "indicatif", "log", "reqwest", @@ -4174,7 +4370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31feddef24d3e0aab189571adea7f109639ef6179fcd3cd34ffc8c73d3409f1" dependencies = [ "base64 0.21.7", - "bs58", + "bs58 0.4.0", "jsonrpc-core", "reqwest", "semver", @@ -4290,7 +4486,7 @@ dependencies = [ "bincode", "bitflags 2.5.0", "borsh 1.5.0", - "bs58", + "bs58 0.4.0", "bytemuck", "byteorder", "chrono", @@ -4340,7 +4536,7 @@ version = "1.18.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cb099b2f9c0a65a6f23ced791325141cd68c27b04d11c04fef838a00f613861" dependencies = [ - "bs58", + "bs58 0.4.0", "proc-macro2", "quote", "rustversion", @@ -4480,7 +4676,7 @@ dependencies = [ "base64 0.21.7", "bincode", "borsh 0.10.3", - "bs58", + "bs58 0.4.0", "lazy_static", "log", "serde", @@ -4806,6 +5002,7 @@ dependencies = [ name = "spl-token-2022-client" version = "0.0.0" dependencies = [ + "anchor-lang", "assert_matches", "borsh 0.10.3", "num-derive 0.3.3", @@ -4907,7 +5104,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -5479,6 +5676,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "unicode-width" version = "0.1.12" diff --git a/clients/js/package.json b/clients/js/package.json index a2fca7f..ae0912d 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -34,14 +34,13 @@ }, "license": "Apache-2.0", "peerDependencies": { - "@solana/web3.js": "2.0.0-preview.4" + "@solana/web3.js": "2.0.0-rc.0" }, "devDependencies": { "@ava/typescript": "^4.1.0", - "@solana-program/system": "^0.4.0", "@solana/eslint-config-solana": "^3.0.3", - "@solana/web3.js": "2.0.0-preview.4", - "@solana/webcrypto-ed25519-polyfill": "2.0.0-preview.4", + "@solana/web3.js": "2.0.0-rc.0", + "@solana/webcrypto-ed25519-polyfill": "2.0.0-rc.0", "@types/node": "^20", "@typescript-eslint/eslint-plugin": "^7.16.1", "@typescript-eslint/parser": "^7.16.1", diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index 7162de9..8049e94 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -8,10 +8,12 @@ readme = "README.md" license-file = "../../LICENSE" [features] +anchor = ["dep:anchor-lang"] test-sbf = [] serde = ["dep:serde", "dep:serde_with"] [dependencies] +anchor-lang = { version = "0.30.0", optional = true } borsh = "^0.10" num-derive = "^0.3" num-traits = "^0.2" diff --git a/scripts/check-solana-version.mjs b/scripts/check-solana-version.mjs index f0844be..28c1d19 100644 --- a/scripts/check-solana-version.mjs +++ b/scripts/check-solana-version.mjs @@ -5,7 +5,13 @@ import { getInstalledSolanaVersion, getSolanaVersion } from './utils.mjs'; const expectedVersion = getSolanaVersion(); const installedVersion = await getInstalledSolanaVersion(); -if (installedVersion !== expectedVersion) { +if (!installedVersion) { + echo( + chalk.red('[ ERROR ]'), + `No Solana installation found. Please install Solana ${expectedVersion} before proceeding.` + ); + process.exit(1); +} else if (installedVersion !== expectedVersion) { echo( chalk.yellow('[ WARNING ]'), `The installed Solana version ${installedVersion} does not match the expected version ${expectedVersion}.` diff --git a/scripts/link-solana-version.mjs b/scripts/link-solana-version.mjs index acc0a04..f92ae45 100644 --- a/scripts/link-solana-version.mjs +++ b/scripts/link-solana-version.mjs @@ -2,16 +2,8 @@ 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 installedVersion = await getInstalledSolanaVersion(); const installPath = path.join( os.homedir(), @@ -29,28 +21,54 @@ const releasePath = path.join( const activeReleasePath = path.join(installPath, 'active_release'); const hasRelease = await fs.exists(releasePath); -if (hasRelease) { +if (!installedVersion) { + echo( + chalk.red('[ ERROR ]'), + `No Solana installation found. Solana ${expectedVersion} is required for this project.` + ); + await askToInstallSolana(expectedVersion); +} else if (installedVersion === expectedVersion) { + echo( + chalk.green('[ SUCCESS ]'), + `The expected Solana version ${expectedVersion} is installed.` + ); +} else 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); +} else { + echo( + chalk.yellow('[ WARNING ]'), + `Cannot switch from Solana version ${installedVersion} to ${expectedVersion} because it is not installed.` + ); + await askToInstallSolana(expectedVersion); } -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)"`; +async function askToInstallSolana(version) { + const installRelease = await question('Should we install it now? [y/N] '); + if (installRelease === 'y') { + await installSolana(version); + echo( + chalk.green('[ SUCCESS ]'), + `Successfully installed Solana version ${version}.` + ); + } else { + process.exit(1); + } } -echo( - chalk.green('[ SUCCESS ]'), - `Successfully switched from Solana version ${installedVersion} to ${expectedVersion} to match the project's requirements.` -); +async function installSolana(version) { + echo(`Installing Solana ${version}...`); + const cutoff = '1.18.19'; + const isBeforeCutoff = + (await $`[[ "$(printf '%s\n' "${cutoff}" "${version}" | sort -V | head -n1)" = "${version}" ]] && [[ "${cutoff}" != "${version}" ]]`.quiet() + .exitCode) == 0; + if (isBeforeCutoff) { + await $`sh -c "$(curl -sSfL https://release.solana.com/v${version}/install)"`; + } else { + await $`sh -c "$(curl -sSfL https://release.anza.xyz/v${version}/install)"`; + } +} diff --git a/scripts/utils.mjs b/scripts/utils.mjs index 274f217..44ee564 100644 --- a/scripts/utils.mjs +++ b/scripts/utils.mjs @@ -121,10 +121,6 @@ export async function getInstalledSolanaVersion() { 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); + return ''; } }