فهرست منبع

feat: remove solang (#3824)

* feat: remove solang

solang is unmaintained. Removing dead code in prep for Anchor V1

* chore: fmt

* fix: clippy
Jacob Creech 2 ماه پیش
والد
کامیت
cac1421e02

+ 0 - 3
.github/workflows/reusable-tests.yaml

@@ -462,9 +462,6 @@ jobs:
             path: tests/idl
           - cmd: cd tests/lazy-account && anchor test
             path: tests/lazy-account
-          # TODO: Enable when `solang` becomes compatible with the new IDL spec
-          # - cmd: cd tests/solang && anchor test
-          #   path: tests/solang
     steps:
       - uses: actions/checkout@v3
       - uses: ./.github/actions/setup/

+ 0 - 220
Cargo.lock

@@ -193,7 +193,6 @@ dependencies = [
  "solana-client",
  "solana-faucet",
  "solana-sdk",
- "solang-parser",
  "syn 1.0.109",
  "tar",
  "toml 0.7.8",
@@ -536,15 +535,6 @@ version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e"
 
-[[package]]
-name = "ascii-canvas"
-version = "3.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6"
-dependencies = [
- "term",
-]
-
 [[package]]
 name = "asn1-rs"
 version = "0.5.2"
@@ -713,21 +703,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "bit-set"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
-dependencies = [
- "bit-vec",
-]
-
-[[package]]
-name = "bit-vec"
-version = "0.6.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
-
 [[package]]
 name = "bitflags"
 version = "1.3.2"
@@ -1405,12 +1380,6 @@ dependencies = [
  "zeroize",
 ]
 
-[[package]]
-name = "diff"
-version = "0.1.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
-
 [[package]]
 name = "digest"
 version = "0.9.0"
@@ -1553,15 +1522,6 @@ version = "1.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
 
-[[package]]
-name = "ena"
-version = "0.14.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1"
-dependencies = [
- "log",
-]
-
 [[package]]
 name = "encode_unicode"
 version = "0.3.6"
@@ -1709,12 +1669,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "94474d15a76982be62ca8a39570dccce148d98c238ebb7408b0a21b2c4bdddc4"
 
-[[package]]
-name = "fixedbitset"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
-
 [[package]]
 name = "flate2"
 version = "1.0.27"
@@ -2209,17 +2163,6 @@ version = "2.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
 
-[[package]]
-name = "is-terminal"
-version = "0.4.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
-dependencies = [
- "hermit-abi 0.3.3",
- "rustix",
- "windows-sys 0.48.0",
-]
-
 [[package]]
 name = "is_terminal_polyfill"
 version = "1.70.1"
@@ -2235,15 +2178,6 @@ dependencies = [
  "either",
 ]
 
-[[package]]
-name = "itertools"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
-dependencies = [
- "either",
-]
-
 [[package]]
 name = "itertools"
 version = "0.12.1"
@@ -2321,34 +2255,6 @@ dependencies = [
  "cpufeatures",
 ]
 
-[[package]]
-name = "lalrpop"
-version = "0.20.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8"
-dependencies = [
- "ascii-canvas",
- "bit-set",
- "diff",
- "ena",
- "is-terminal",
- "itertools 0.10.5",
- "lalrpop-util",
- "petgraph",
- "regex",
- "regex-syntax",
- "string_cache",
- "term",
- "tiny-keccak",
- "unicode-xid",
-]
-
-[[package]]
-name = "lalrpop-util"
-version = "0.20.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d"
-
 [[package]]
 name = "lazy_static"
 version = "1.5.0"
@@ -2522,12 +2428,6 @@ dependencies = [
  "thiserror",
 ]
 
-[[package]]
-name = "new_debug_unreachable"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
-
 [[package]]
 name = "nix"
 version = "0.29.0"
@@ -2833,67 +2733,6 @@ dependencies = [
  "num",
 ]
 
-[[package]]
-name = "petgraph"
-version = "0.6.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
-dependencies = [
- "fixedbitset",
- "indexmap 2.6.0",
-]
-
-[[package]]
-name = "phf"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
-dependencies = [
- "phf_macros",
- "phf_shared 0.11.2",
-]
-
-[[package]]
-name = "phf_generator"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
-dependencies = [
- "phf_shared 0.11.2",
- "rand 0.8.5",
-]
-
-[[package]]
-name = "phf_macros"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
-dependencies = [
- "phf_generator",
- "phf_shared 0.11.2",
- "proc-macro2",
- "quote",
- "syn 2.0.86",
-]
-
-[[package]]
-name = "phf_shared"
-version = "0.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096"
-dependencies = [
- "siphasher",
-]
-
-[[package]]
-name = "phf_shared"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
-dependencies = [
- "siphasher",
-]
-
 [[package]]
 name = "pin-project-lite"
 version = "0.2.13"
@@ -2951,12 +2790,6 @@ version = "0.2.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
 
-[[package]]
-name = "precomputed-hash"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
-
 [[package]]
 name = "proc-macro-crate"
 version = "0.1.5"
@@ -3518,12 +3351,6 @@ dependencies = [
  "untrusted 0.9.0",
 ]
 
-[[package]]
-name = "rustversion"
-version = "1.0.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
-
 [[package]]
 name = "ryu"
 version = "1.0.15"
@@ -5173,20 +5000,6 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "solang-parser"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26"
-dependencies = [
- "itertools 0.11.0",
- "lalrpop",
- "lalrpop-util",
- "phf",
- "thiserror",
- "unicode-xid",
-]
-
 [[package]]
 name = "spin"
 version = "0.5.2"
@@ -5683,19 +5496,6 @@ dependencies = [
  "thiserror",
 ]
 
-[[package]]
-name = "string_cache"
-version = "0.8.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b"
-dependencies = [
- "new_debug_unreachable",
- "once_cell",
- "parking_lot",
- "phf_shared 0.10.0",
- "precomputed-hash",
-]
-
 [[package]]
 name = "strsim"
 version = "0.8.0"
@@ -5826,17 +5626,6 @@ dependencies = [
  "windows-sys 0.48.0",
 ]
 
-[[package]]
-name = "term"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
-dependencies = [
- "dirs-next",
- "rustversion",
- "winapi",
-]
-
 [[package]]
 name = "termcolor"
 version = "1.3.0"
@@ -5925,15 +5714,6 @@ dependencies = [
  "zeroize",
 ]
 
-[[package]]
-name = "tiny-keccak"
-version = "2.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
-dependencies = [
- "crunchy",
-]
-
 [[package]]
 name = "tinyvec"
 version = "1.6.0"

+ 0 - 2
cli/Cargo.toml

@@ -40,8 +40,6 @@ solana-client = "2"
 solana-cli-config = "2"
 solana-faucet = "2"
 solana-sdk = "2"
-# Pin solang-parser because it may break in a backwards incompatible way in minor versions
-solang-parser = "=0.3.3"
 syn = { version = "1.0.60", features = ["full", "extra-traits"] }
 tar = "0.4.35"
 toml = "0.7.6"

+ 2 - 70
cli/src/config.rs

@@ -1,7 +1,7 @@
 use crate::{get_keypair, is_hidden, keys_sync};
 use anchor_client::Cluster;
 use anchor_lang_idl::types::Idl;
-use anyhow::{anyhow, bail, Context, Error, Result};
+use anyhow::{anyhow, Context, Error, Result};
 use clap::{Parser, ValueEnum};
 use dirs::home_dir;
 use heck::ToSnakeCase;
@@ -13,10 +13,8 @@ use solana_cli_config::{Config as SolanaConfig, CONFIG_FILE};
 use solana_sdk::clock::Slot;
 use solana_sdk::pubkey::Pubkey;
 use solana_sdk::signature::{Keypair, Signer};
-use solang_parser::pt::{ContractTy, SourceUnitPart};
 use std::collections::{BTreeMap, HashMap};
 use std::convert::TryFrom;
-use std::ffi::OsStr;
 use std::fs::{self, File};
 use std::io::prelude::*;
 use std::marker::PhantomData;
@@ -182,53 +180,6 @@ impl WithPath<Config> {
             .collect())
     }
 
-    /// Parse all the files with the .sol extension, and get a list of the all
-    /// contracts defined in them along with their path. One Solidity file may
-    /// define multiple contracts.
-    pub fn get_solidity_program_list(&self) -> Result<Vec<(String, PathBuf)>> {
-        let path = self.path().parent().unwrap().join("solidity");
-        let mut res = Vec::new();
-
-        if let Ok(entries) = fs::read_dir(path) {
-            for entry in entries {
-                let path = entry?.path();
-
-                if !path.is_file() || path.extension() != Some(OsStr::new("sol")) {
-                    continue;
-                }
-
-                let source = fs::read_to_string(&path)?;
-
-                let tree = match solang_parser::parse(&source, 0) {
-                    Ok((tree, _)) => tree,
-                    Err(diag) => {
-                        // The parser can return multiple errors, however this is exceedingly rare.
-                        // Just use the first one, else the formatting will be a mess.
-                        bail!(
-                            "{}: {}: {}",
-                            path.display(),
-                            diag[0].level.to_string(),
-                            diag[0].message
-                        );
-                    }
-                };
-
-                tree.0.iter().for_each(|part| {
-                    if let SourceUnitPart::ContractDefinition(contract) = part {
-                        // Must be a contract, not library/interface/abstract contract
-                        if matches!(&contract.ty, ContractTy::Contract(..)) {
-                            if let Some(name) = &contract.name {
-                                res.push((name.name.clone(), path.clone()));
-                            }
-                        }
-                    }
-                });
-            }
-        }
-
-        Ok(res)
-    }
-
     pub fn read_all_programs(&self) -> Result<Vec<Program>> {
         let mut r = vec![];
         for path in self.get_rust_program_list()? {
@@ -246,24 +197,6 @@ impl WithPath<Config> {
 
             r.push(Program {
                 lib_name,
-                solidity: false,
-                path,
-                idl,
-            });
-        }
-        for (lib_name, path) in self.get_solidity_program_list()? {
-            let idl_filepath = Path::new("target")
-                .join("idl")
-                .join(&lib_name)
-                .with_extension("json");
-            let idl = fs::read(idl_filepath)
-                .ok()
-                .map(|bytes| serde_json::from_reader(&*bytes))
-                .transpose()?;
-
-            r.push(Program {
-                lib_name,
-                solidity: true,
                 path,
                 idl,
             });
@@ -1308,8 +1241,7 @@ impl Merge for _Validator {
 #[derive(Debug, Clone)]
 pub struct Program {
     pub lib_name: String,
-    pub solidity: bool,
-    // Canonicalized path to the program directory or Solidity source file
+    // Canonicalized path to the program directory
     pub path: PathBuf,
     pub idl: Option<Idl>,
 }

+ 23 - 175
cli/src/lib.rs

@@ -44,7 +44,6 @@ use std::string::ToString;
 mod checks;
 pub mod config;
 pub mod rust_template;
-pub mod solidity_template;
 
 // Version of the docker image.
 pub const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -68,9 +67,6 @@ pub enum Command {
         /// Use JavaScript instead of TypeScript
         #[clap(short, long)]
         javascript: bool,
-        /// Use Solidity instead of Rust
-        #[clap(short, long)]
-        solidity: bool,
         /// Don't install JavaScript dependencies
         #[clap(long)]
         no_install: bool,
@@ -218,9 +214,6 @@ pub enum Command {
     New {
         /// Program name
         name: String,
-        /// Use Solidity instead of Rust
-        #[clap(short, long)]
-        solidity: bool,
         /// Rust program template to use
         #[clap(value_enum, short, long, default_value = "single")]
         template: ProgramTemplate,
@@ -724,7 +717,6 @@ fn process_command(opts: Opts) -> Result<()> {
         Command::Init {
             name,
             javascript,
-            solidity,
             no_install,
             package_manager,
             no_git,
@@ -735,7 +727,6 @@ fn process_command(opts: Opts) -> Result<()> {
             &opts.cfg_override,
             name,
             javascript,
-            solidity,
             no_install,
             package_manager,
             no_git,
@@ -744,11 +735,10 @@ fn process_command(opts: Opts) -> Result<()> {
             force,
         ),
         Command::New {
-            solidity,
             name,
             template,
             force,
-        } => new(&opts.cfg_override, solidity, name, template, force),
+        } => new(&opts.cfg_override, name, template, force),
         Command::Build {
             no_idl,
             idl,
@@ -903,7 +893,6 @@ fn init(
     cfg_override: &ConfigOverride,
     name: String,
     javascript: bool,
-    solidity: bool,
     no_install: bool,
     package_manager: PackageManager,
     no_git: bool,
@@ -975,21 +964,17 @@ fn init(
     if force {
         fs::remove_dir_all(
             std::env::current_dir()?
-                .join(if solidity { "solidity" } else { "programs" })
+                .join("programs")
                 .join(&project_name),
         )?;
     }
 
     // Build the program.
-    if solidity {
-        solidity_template::create_program(&project_name)?;
-    } else {
-        rust_template::create_program(
-            &project_name,
-            template,
-            TestTemplate::Mollusk == test_template,
-        )?;
-    }
+    rust_template::create_program(
+        &project_name,
+        template,
+        TestTemplate::Mollusk == test_template,
+    )?;
 
     // Build the migrations directory.
     let migrations_path = Path::new("migrations");
@@ -1017,12 +1002,7 @@ fn init(
         deploy.write_all(rust_template::ts_deploy_script().as_bytes())?;
     }
 
-    test_template.create_test_files(
-        &project_name,
-        javascript,
-        solidity,
-        &program_id.to_string(),
-    )?;
+    test_template.create_test_files(&project_name, javascript, &program_id.to_string())?;
 
     if !no_install {
         let package_manager_result = install_node_modules(&package_manager_cmd)?;
@@ -1073,7 +1053,6 @@ fn install_node_modules(cmd: &str) -> Result<std::process::Output> {
 // Creates a new program crate in the `programs/<name>` directory.
 fn new(
     cfg_override: &ConfigOverride,
-    solidity: bool,
     name: String,
     template: ProgramTemplate,
     force: bool,
@@ -1094,18 +1073,10 @@ fn new(
                     }
 
                     // Delete all files within the program folder
-                    fs::remove_dir_all(
-                        std::env::current_dir()?
-                            .join(if solidity { "solidity" } else { "programs" })
-                            .join(&name),
-                    )?;
+                    fs::remove_dir_all(std::env::current_dir()?.join("programs").join(&name))?;
                 }
 
-                if solidity {
-                    solidity_template::create_program(&name)?;
-                } else {
-                    rust_template::create_program(&name, template, false)?;
-                }
+                rust_template::create_program(&name, template, false)?;
 
                 programs.insert(
                     name.clone(),
@@ -1432,19 +1403,6 @@ fn build_all(
                     &arch,
                 )?;
             }
-            for (name, path) in cfg.get_solidity_program_list()? {
-                build_solidity_cwd(
-                    cfg,
-                    name,
-                    path,
-                    idl_out.clone(),
-                    idl_ts_out.clone(),
-                    build_config,
-                    stdout.as_ref().map(|f| f.try_clone()).transpose()?,
-                    stderr.as_ref().map(|f| f.try_clone()).transpose()?,
-                    cargo_args.clone(),
-                )?;
-            }
             Ok(())
         }
     };
@@ -1492,31 +1450,6 @@ fn build_rust_cwd(
     }
 }
 
-// Runs the build command outside of a workspace.
-#[allow(clippy::too_many_arguments)]
-fn build_solidity_cwd(
-    cfg: &WithPath<Config>,
-    name: String,
-    path: PathBuf,
-    idl_out: Option<PathBuf>,
-    idl_ts_out: Option<PathBuf>,
-    build_config: &BuildConfig,
-    stdout: Option<File>,
-    stderr: Option<File>,
-    cargo_args: Vec<String>,
-) -> Result<()> {
-    match path.parent() {
-        None => return Err(anyhow!("Unable to find parent")),
-        Some(p) => std::env::set_current_dir(p)?,
-    };
-    match build_config.verifiable {
-        false => _build_solidity_cwd(
-            cfg, &name, &path, idl_out, idl_ts_out, stdout, stderr, cargo_args,
-        ),
-        true => panic!("verifiable solidity not supported"),
-    }
-}
-
 // Builds an anchor program in a docker image and copies the build artifacts
 // into the `target/` directory.
 #[allow(clippy::too_many_arguments)]
@@ -1911,81 +1844,6 @@ fn _build_rust_cwd(
     Ok(())
 }
 
-#[allow(clippy::too_many_arguments)]
-fn _build_solidity_cwd(
-    cfg: &WithPath<Config>,
-    name: &str,
-    path: &Path,
-    idl_out: Option<PathBuf>,
-    idl_ts_out: Option<PathBuf>,
-    stdout: Option<File>,
-    stderr: Option<File>,
-    solang_args: Vec<String>,
-) -> Result<()> {
-    let mut cmd = std::process::Command::new("solang");
-    let cmd = cmd.args(["compile", "--target", "solana", "--contract", name]);
-
-    if let Some(idl_out) = &idl_out {
-        cmd.arg("--output-meta");
-        cmd.arg(idl_out);
-    }
-
-    let target_bin = cfg.path().parent().unwrap().join("target").join("deploy");
-
-    cmd.arg("--output");
-    cmd.arg(target_bin);
-    cmd.arg("--verbose");
-    cmd.arg(path);
-
-    let exit = cmd
-        .args(solang_args)
-        .stdout(match stdout {
-            None => Stdio::inherit(),
-            Some(f) => f.into(),
-        })
-        .stderr(match stderr {
-            None => Stdio::inherit(),
-            Some(f) => f.into(),
-        })
-        .output()
-        .map_err(|e| anyhow::format_err!("{}", e.to_string()))?;
-    if !exit.status.success() {
-        std::process::exit(exit.status.code().unwrap_or(1));
-    }
-
-    // idl is written to idl_out or .
-    let idl_path = idl_out
-        .unwrap_or(PathBuf::from("."))
-        .join(format!("{name}.json"));
-
-    let idl = fs::read(idl_path)?;
-    let idl = convert_idl(&idl)?;
-
-    // TS out path.
-    let ts_out = match idl_ts_out {
-        None => PathBuf::from(".")
-            .join(&idl.metadata.name)
-            .with_extension("ts"),
-        Some(o) => PathBuf::from(&o.join(&idl.metadata.name).with_extension("ts")),
-    };
-
-    // Write out the TypeScript type.
-    fs::write(&ts_out, idl_ts(&idl)?)?;
-    // Copy out the TypeScript type.
-    let cfg_parent = cfg.path().parent().expect("Invalid Anchor.toml");
-    if !&cfg.workspace.types.is_empty() {
-        fs::copy(
-            &ts_out,
-            cfg_parent
-                .join(&cfg.workspace.types)
-                .join(&idl.metadata.name)
-                .with_extension("ts"),
-        )?;
-    }
-
-    Ok(())
-}
-
 pub fn verify(
     program_id: Pubkey,
     repo_url: Option<String>,
@@ -2051,27 +1909,20 @@ fn cd_member(cfg_override: &ConfigOverride, program_name: &str) -> Result<()> {
     let cfg = Config::discover(cfg_override)?.expect("Not in workspace.");
 
     for program in cfg.read_all_programs()? {
-        if program.solidity {
-            if let Some(path) = program.path.parent() {
-                std::env::set_current_dir(path)?;
-                return Ok(());
-            }
-        } else {
-            let cargo_toml = program.path.join("Cargo.toml");
-            if !cargo_toml.exists() {
-                return Err(anyhow!(
-                    "Did not find Cargo.toml at the path: {}",
-                    program.path.display()
-                ));
-            }
+        let cargo_toml = program.path.join("Cargo.toml");
+        if !cargo_toml.exists() {
+            return Err(anyhow!(
+                "Did not find Cargo.toml at the path: {}",
+                program.path.display()
+            ));
+        }
 
-            let manifest = Manifest::from_path(&cargo_toml)?;
-            let pkg_name = manifest.package().name();
-            let lib_name = manifest.lib_name()?;
-            if program_name == pkg_name || program_name == lib_name {
-                std::env::set_current_dir(&program.path)?;
-                return Ok(());
-            }
+        let manifest = Manifest::from_path(&cargo_toml)?;
+        let pkg_name = manifest.package().name();
+        let lib_name = manifest.lib_name()?;
+        if program_name == pkg_name || program_name == lib_name {
+            std::env::set_current_dir(&program.path)?;
+            return Ok(());
         }
     }
 
@@ -4531,7 +4382,6 @@ mod tests {
             },
             "await".to_string(),
             true,
-            false,
             true,
             PackageManager::default(),
             false,
@@ -4552,7 +4402,6 @@ mod tests {
             },
             "fn".to_string(),
             true,
-            false,
             true,
             PackageManager::default(),
             false,
@@ -4573,7 +4422,6 @@ mod tests {
             },
             "1project".to_string(),
             true,
-            false,
             true,
             PackageManager::default(),
             false,

+ 6 - 24
cli/src/rust_template.rs

@@ -1,6 +1,6 @@
 use crate::{
-    config::ProgramWorkspace, create_files, override_or_create_files, solidity_template, Files,
-    PackageManager, VERSION,
+    config::ProgramWorkspace, create_files, override_or_create_files, Files, PackageManager,
+    VERSION,
 };
 use anyhow::Result;
 use clap::{Parser, ValueEnum};
@@ -654,13 +654,7 @@ impl TestTemplate {
         }
     }
 
-    pub fn create_test_files(
-        &self,
-        project_name: &str,
-        js: bool,
-        solidity: bool,
-        program_id: &str,
-    ) -> Result<()> {
+    pub fn create_test_files(&self, project_name: &str, js: bool, program_id: &str) -> Result<()> {
         match self {
             Self::Mocha => {
                 // Build the test suite.
@@ -668,18 +662,10 @@ impl TestTemplate {
 
                 if js {
                     let mut test = File::create(format!("tests/{}.js", &project_name))?;
-                    if solidity {
-                        test.write_all(solidity_template::mocha(project_name).as_bytes())?;
-                    } else {
-                        test.write_all(mocha(project_name).as_bytes())?;
-                    }
+                    test.write_all(mocha(project_name).as_bytes())?;
                 } else {
                     let mut mocha = File::create(format!("tests/{}.ts", &project_name))?;
-                    if solidity {
-                        mocha.write_all(solidity_template::ts_mocha(project_name).as_bytes())?;
-                    } else {
-                        mocha.write_all(ts_mocha(project_name).as_bytes())?;
-                    }
+                    mocha.write_all(ts_mocha(project_name).as_bytes())?;
                 }
             }
             Self::Jest => {
@@ -687,11 +673,7 @@ impl TestTemplate {
                 fs::create_dir_all("tests")?;
 
                 let mut test = File::create(format!("tests/{}.test.js", &project_name))?;
-                if solidity {
-                    test.write_all(solidity_template::jest(project_name).as_bytes())?;
-                } else {
-                    test.write_all(jest(project_name).as_bytes())?;
-                }
+                test.write_all(jest(project_name).as_bytes())?;
             }
             Self::Rust => {
                 // Do not initialize git repo

+ 0 - 161
cli/src/solidity_template.rs

@@ -1,161 +0,0 @@
-use crate::create_files;
-use anyhow::Result;
-use heck::{ToSnakeCase, ToUpperCamelCase};
-use std::path::Path;
-
-/// Create a solidity program.
-pub fn create_program(name: &str) -> Result<()> {
-    let files = vec![(
-        Path::new("solidity").join(name).with_extension("sol"),
-        solidity(name),
-    )];
-    create_files(&files)
-}
-
-fn solidity(name: &str) -> String {
-    format!(
-        r#"
-contract {} {{
-    bool private value = true;
-
-    @payer(payer)
-    constructor() {{
-        print("Hello, World!");
-    }}
-
-    /// A message that can be called on instantiated contracts.
-    /// This one flips the value of the stored `bool` from `true`
-    /// to `false` and vice versa.
-    function flip() public {{
-            value = !value;
-    }}
-
-    /// Simply returns the current value of our `bool`.
-    function get() public view returns (bool) {{
-            return value;
-    }}
-}}
-"#,
-        name.to_snake_case(),
-    )
-}
-
-pub fn mocha(name: &str) -> String {
-    format!(
-        r#"const anchor = require("@coral-xyz/anchor");
-
-describe("{}", () => {{
-  // Configure the client to use the local cluster.
-  anchor.setProvider(anchor.AnchorProvider.env());
-
-  it("Is initialized!", async () => {{
-    // Add your test here.
-    const program = anchor.workspace.{};
-    const dataAccount = anchor.web3.Keypair.generate();
-
-    const tx = await program.methods
-       .new()
-       .accounts({{ dataAccount: dataAccount.publicKey }})
-       .signers([dataAccount])
-       .rpc();
-
-    console.log("Your transaction signature", tx);
-
-    const val1 = await program.methods
-      .get()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .view();
-
-    console.log("state", val1);
-
-    await program.methods
-      .flip()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .rpc();
-
-    const val2 = await program.methods
-      .get()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .view();
-
-    console.log("state", val2);
-  }});
-}});
-"#,
-        name,
-        name.to_upper_camel_case(),
-    )
-}
-
-pub fn jest(name: &str) -> String {
-    format!(
-        r#"const anchor = require("@coral-xyz/anchor");
-
-describe("{}", () => {{
-  // Configure the client to use the local cluster.
-  anchor.setProvider(anchor.AnchorProvider.env());
-
-  it("Is initialized!", async () => {{
-    // Add your test here.
-    const program = anchor.workspace.{};
-    const tx = await program.methods.initialize().rpc();
-    console.log("Your transaction signature", tx);
-  }});
-}});
-"#,
-        name,
-        name.to_upper_camel_case(),
-    )
-}
-
-pub fn ts_mocha(name: &str) -> String {
-    format!(
-        r#"import * as anchor from "@coral-xyz/anchor";
-import {{ Program }} from "@coral-xyz/anchor";
-import {{ {} }} from "../target/types/{}";
-
-describe("{}", () => {{
-  // Configure the client to use the local cluster.
-  const provider = anchor.AnchorProvider.env();
-  anchor.setProvider(provider);
-
-  const dataAccount = anchor.web3.Keypair.generate();
-
-  const program = anchor.workspace.{} as Program<{}>;
-
-  it("Is initialized!", async () => {{
-    // Add your test here.
-    const tx = await program.methods
-      .new()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .signers([dataAccount])
-      .rpc();
-    console.log("Your transaction signature", tx);
-
-    const val1 = await program.methods
-      .get()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .view();
-
-    console.log("state", val1);
-
-    await program.methods
-      .flip()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .rpc();
-
-    const val2 = await program.methods
-      .get()
-      .accounts({{ dataAccount: dataAccount.publicKey }})
-      .view();
-
-    console.log("state", val2);  }});
-}});
-"#,
-        name.to_upper_camel_case(),
-        name.to_snake_case(),
-        name,
-        name.to_upper_camel_case(),
-        name.to_upper_camel_case(),
-    )
-}

+ 1 - 2
tests/package.json

@@ -50,8 +50,7 @@
     "cpi-returns",
     "multiple-suites",
     "multiple-suites-run-single",
-    "bpf-upgradeable-state",
-    "solang"
+    "bpf-upgradeable-state"
   ],
   "dependencies": {
     "@project-serum/common": "^0.0.1-beta.3",

+ 0 - 8
tests/solang/.gitignore

@@ -1,8 +0,0 @@
-
-.anchor
-.DS_Store
-target
-**/*.rs.bk
-node_modules
-test-ledger
-.yarn

+ 0 - 8
tests/solang/.prettierignore

@@ -1,8 +0,0 @@
-
-.anchor
-.DS_Store
-target
-node_modules
-dist
-build
-test-ledger

+ 0 - 13
tests/solang/Anchor.toml

@@ -1,13 +0,0 @@
-[features]
-seeds = false
-skip-lint = false
-
-[programs.localnet]
-flipper = "F1ipperKF9EfD821ZbbYjS319LXYiBmjhzkkf5a26rC"
-
-[provider]
-cluster = "Localnet"
-wallet = "~/.config/solana/id.json"
-
-[scripts]
-test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

+ 0 - 12
tests/solang/migrations/deploy.ts

@@ -1,12 +0,0 @@
-// Migrations are an early feature. Currently, they're nothing more than this
-// single deploy script that's invoked from the CLI, injecting a provider
-// configured from the workspace's Anchor.toml.
-
-const anchor = require("@coral-xyz/anchor");
-
-module.exports = async function (provider) {
-  // Configure client to use the provider.
-  anchor.setProvider(provider);
-
-  // Add your deploy script here.
-};

+ 0 - 19
tests/solang/package.json

@@ -1,19 +0,0 @@
-{
-  "name": "solang",
-  "version": "0.31.1",
-  "license": "(MIT OR Apache-2.0)",
-  "homepage": "https://github.com/coral-xyz/anchor#readme",
-  "bugs": {
-    "url": "https://github.com/coral-xyz/anchor/issues"
-  },
-  "repository": {
-    "type": "git",
-    "url": "https://github.com/coral-xyz/anchor.git"
-  },
-  "engines": {
-    "node": ">=17"
-  },
-  "scripts": {
-    "test": "anchor run test-with-build"
-  }
-}

+ 0 - 21
tests/solang/solidity/flipper.sol

@@ -1,21 +0,0 @@
-
-contract flipper {
-    bool private value = true;
-
-    @payer(payer)
-    constructor() {
-        print("Hello, World!");
-    }
-
-    /// A message that can be called on instantiated contracts.
-    /// This one flips the value of the stored `bool` from `true`
-    /// to `false` and vice versa.
-    function flip() public {
-            value = !value;
-    }
-
-    /// Simply returns the current value of our `bool`.
-    function get() public view returns (bool) {
-            return value;
-    }
-}

+ 0 - 43
tests/solang/tests/solang.ts

@@ -1,43 +0,0 @@
-import * as anchor from "@coral-xyz/anchor";
-import { Program } from "@coral-xyz/anchor";
-import { Flipper } from "../target/types/flipper";
-
-describe("flipper", () => {
-  // Configure the client to use the local cluster.
-  const provider = anchor.AnchorProvider.env();
-  anchor.setProvider(provider);
-
-  const dataAccount = anchor.web3.Keypair.generate();
-  const wallet = provider.wallet;
-
-  const program = anchor.workspace.Flipper as Program<Flipper>;
-
-  it("Is initialized!", async () => {
-    // Add your test here.
-    const tx = await program.methods
-      .new()
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .signers([dataAccount])
-      .rpc();
-    console.log("Your transaction signature", tx);
-
-    const val1 = await program.methods
-      .get()
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .view();
-
-    console.log("state", val1);
-
-    await program.methods
-      .flip()
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .rpc();
-
-    const val2 = await program.methods
-      .get()
-      .accounts({ dataAccount: dataAccount.publicKey })
-      .view();
-
-    console.log("state", val2);
-  });
-});

+ 0 - 11
tests/solang/tsconfig.json

@@ -1,11 +0,0 @@
-{
-  "compilerOptions": {
-    "types": ["mocha", "chai"],
-    "typeRoots": ["./node_modules/@types"],
-    "lib": ["es2015"],
-    "module": "commonjs",
-    "target": "es6",
-    "esModuleInterop": true,
-    "skipLibCheck": true
-  }
-}