diff --git a/.gitignore b/.gitignore index 2f359c4d..50374163 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ venv.bak/ # Typings typings + +multiversx_sdk_cli/tests/testdata-out diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index ebf431e4..27be0001 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -18,6 +18,8 @@ from multiversx_sdk_cli.docker import is_docker_installed, run_docker from multiversx_sdk_cli.errors import DockerMissingError, NoWalletProvided from multiversx_sdk_cli.projects.core import get_project_paths_recursively +from multiversx_sdk_cli.projects.templates import Contract +from multiversx_sdk_cli.ux import show_message logger = logging.getLogger("cli.contracts") @@ -28,14 +30,16 @@ def setup_parser(args: List[str], subparsers: Any) -> Any: sub = cli_shared.add_command_subparser(subparsers, "contract", "new", "Create a new Smart Contract project based on a template.") - sub.add_argument("name") + sub.add_argument("--name", help="The name of the contract. If missing, the name of the template will be used.") sub.add_argument("--template", required=True, help="the template to use") - sub.add_argument("--directory", type=str, default=os.getcwd(), - help="🗀 the parent directory of the project (default: current directory)") + sub.add_argument("--tag", help="the framework version on which the contract should be created") + sub.add_argument("--path", type=str, default=os.getcwd(), + help="the parent directory of the project (default: current directory)") sub.set_defaults(func=create) sub = cli_shared.add_command_subparser(subparsers, "contract", "templates", "List the available Smart Contract templates.") + sub.add_argument("--tag", help="the sc-meta framework version referred to") sub.set_defaults(func=list_templates) sub = cli_shared.add_command_subparser(subparsers, "contract", "build", @@ -242,15 +246,20 @@ def _add_metadata_arg(sub: Any): def list_templates(args: Any): - projects.list_project_templates() + tag = args.tag + contract = Contract(tag) + templates = contract.get_contract_templates() + show_message(templates) def create(args: Any): name = args.name template = args.template - directory = Path(args.directory) + tag = args.tag + path = Path(args.path) - projects.create_from_template(name, template, directory) + contract = Contract(tag, name, template, path) + contract.create_from_template() def get_project_paths(args: Any) -> List[Path]: diff --git a/multiversx_sdk_cli/projects/__init__.py b/multiversx_sdk_cli/projects/__init__.py index 284a7ca8..0607f0cd 100644 --- a/multiversx_sdk_cli/projects/__init__.py +++ b/multiversx_sdk_cli/projects/__init__.py @@ -1,13 +1,12 @@ from multiversx_sdk_cli.projects.core import (build_project, clean_project, - get_projects_in_workspace, load_project, - run_tests) + get_projects_in_workspace, + load_project, run_tests) from multiversx_sdk_cli.projects.project_base import Project from multiversx_sdk_cli.projects.project_clang import ProjectClang from multiversx_sdk_cli.projects.project_cpp import ProjectCpp from multiversx_sdk_cli.projects.project_rust import ProjectRust from multiversx_sdk_cli.projects.project_sol import ProjectSol from multiversx_sdk_cli.projects.report.do_report import do_report -from multiversx_sdk_cli.projects.templates import (create_from_template, - list_project_templates) +from multiversx_sdk_cli.projects.templates import Contract -__all__ = ["build_project", "clean_project", "do_report", "run_tests", "get_projects_in_workspace", "load_project", "Project", "ProjectClang", "ProjectCpp", "ProjectRust", "ProjectSol", "create_from_template", "list_project_templates"] +__all__ = ["build_project", "clean_project", "do_report", "run_tests", "get_projects_in_workspace", "load_project", "Project", "ProjectClang", "ProjectCpp", "ProjectRust", "ProjectSol", "Contract"] diff --git a/multiversx_sdk_cli/projects/templates.py b/multiversx_sdk_cli/projects/templates.py index d5589f4b..bfd9fdb2 100644 --- a/multiversx_sdk_cli/projects/templates.py +++ b/multiversx_sdk_cli/projects/templates.py @@ -1,254 +1,55 @@ -import json import logging -import shutil from pathlib import Path -from typing import Any, List, Tuple +from typing import Union -from multiversx_sdk_cli import errors, utils -from multiversx_sdk_cli.projects import shared -from multiversx_sdk_cli.projects.project_rust import CargoFile -from multiversx_sdk_cli.projects.templates_config import \ - get_templates_repositories -from multiversx_sdk_cli.projects.templates_repository import \ - TemplatesRepository +from multiversx_sdk_cli import myprocess +from multiversx_sdk_cli.dependencies.install import install_module logger = logging.getLogger("projects.templates") -def list_project_templates(): - summaries: List[TemplateSummary] = [] - - for repository in get_templates_repositories(): - repository.download() - for template in repository.get_templates(): - summaries.append(TemplateSummary(template, repository)) - - summaries = sorted(summaries, key=lambda item: item.name) - - pretty_json = json.dumps([item.__dict__ for item in summaries], indent=4) - print(pretty_json) - - -class TemplateSummary(): - def __init__(self, name: str, repository: TemplatesRepository): +class Contract: + def __init__(self, + tag: Union[str, None] = None, + name: Union[str, None] = None, + template: str = "", + path: Path = Path() + ) -> None: + self.tag = tag self.name = name - self.github = repository.github - self.language = repository.get_language(name) - - -def create_from_template(project_name: str, template_name: str, directory: Path): - directory = directory.expanduser() - - logger.info("create_from_template.project_name: %s", project_name) - logger.info("create_from_template.template_name: %s", template_name) - logger.info("create_from_template.directory: %s", directory) - - if not directory: - logger.info("Using current directory") - directory = Path.cwd() - - project_directory = Path(directory) / project_name - if project_directory.exists(): - raise errors.BadDirectory(str(project_directory)) - - _download_templates_repositories() - _copy_template(template_name, project_directory, project_name) - - template = _load_as_template(project_directory) - template.apply(template_name, project_name) - - logger.info("Project created, template applied.") - - -def _download_templates_repositories(): - for repo in get_templates_repositories(): - repo.download() - - -def _copy_template(template: str, destination_path: Path, project_name: str): - for repo in get_templates_repositories(): - if repo.has_template(template): - source_path = repo.get_template_folder(template) - shutil.copytree(source_path, destination_path) - return - - raise errors.TemplateMissingError(template) - - -def _load_as_template(directory: Path): - if shared.is_source_rust(directory): - return TemplateRust(directory) - raise errors.BadTemplateError(directory) - - -class Template: - def __init__(self, directory: Path): - self.directory = directory - - def apply(self, template_name: str, project_name: str): - self.template_name = template_name - self.project_name = project_name - self._patch() - - def _patch(self): - """Implemented by derived classes""" - pass - - -class TemplateRust(Template): - CARGO_TOML = "Cargo.toml" - - def _patch(self): - logger.info("Patching cargo files...") - self._patch_cargo() - self._patch_sub_crate("wasm") - self._patch_sub_crate("abi") - self._patch_sub_crate("meta") - template_name = self._with_underscores(self.template_name) - - tests = (self.directory / "tests").glob("*.rs") - - source_code_files = [ - self.directory / "src" / f"{template_name}.rs", - self.directory / "src" / "lib.rs", - self.directory / "abi" / "src" / "main.rs", - self.directory / "wasm" / "src" / "lib.rs", - self.directory / "meta" / "src" / "main.rs", - ] - - source_code_files.extend(tests) - - logger.info("Patching source code...") - self._patch_source_code_files(source_code_files, ignore_missing=True) - self._patch_source_code_tests() - - logger.info("Patching test files...") - self._patch_scenarios_tests() - - def _patch_cargo(self): - cargo_path = self.directory / TemplateRust.CARGO_TOML - - cargo_file = CargoFile(cargo_path) - cargo_file.package_name = self.project_name - cargo_file.version = "0.0.0" - cargo_file.authors = ["you"] - cargo_file.edition = "2018" - cargo_file.publish = False - - remove_path_from_dependencies(cargo_file) - - cargo_file.save() - - def _patch_sub_crate(self, sub_name: str) -> None: - cargo_path = self.directory / sub_name / TemplateRust.CARGO_TOML - if not cargo_path.is_file(): - return - - cargo_file = CargoFile(cargo_path) - cargo_file.package_name = f"{self.project_name}-{sub_name}" - cargo_file.version = "0.0.0" - cargo_file.authors = ["you"] - cargo_file.edition = "2018" - cargo_file.publish = False - - remove_path_from_dependencies(cargo_file) - - # Patch the path towards the project crate (one folder above): - cargo_file.get_dependency(self.template_name)["path"] = ".." - - cargo_file.save() - - self._replace_in_files( - [cargo_path], - [ - (f"[dependencies.{self.template_name}]", f"[dependencies.{self.project_name}]") - ], - ignore_missing=False - ) - - def _with_underscores(self, name: str) -> str: - return name.replace('-', '_') - - def _contract_name(self, name: str) -> str: - chars = name.replace("-", " ").replace("_", " ").split() - return ''.join(i.capitalize() for i in chars[0:]) - - def _patch_source_code_files(self, source_paths: List[Path], ignore_missing: bool) -> None: - template_name = self._with_underscores(self.template_name) - project_name = self._with_underscores(self.project_name) - template_contract_name = self._contract_name(self.template_name) - project_contract_name = self._contract_name(self.project_name) - - self._replace_in_files( - source_paths, - [ - # Example: replace contract name "pub trait SimpleERC20" to "pub trait MyContract" - (f"pub trait {template_contract_name}", f"pub trait {project_contract_name}"), - # Example: replace "simple_erc20.wasm" to "my_token.wasm" - (f"{self.template_name}.wasm", f"{self.project_name}.wasm"), - # Example: replace "use simple_erc20::*" to "use my_token::*" - (f"use {template_name}::*", f"use {project_name}::*"), - # Example: replace "()" to "()" - (f"<{template_name}::AbiProvider>()", f"<{project_name}::AbiProvider>()"), - # Example: replace "extern crate adder;" to "extern crate myadder;" - (f"extern crate {template_name};", f"extern crate {project_name};"), - # Example: replace "empty::ContractObj" to "foo_bar::ContractObj" - (f"{template_name}::ContractObj", f"{project_name}::ContractObj"), - (f"{template_name}::ContractBuilder", f"{project_name}::ContractBuilder"), - (f"{template_name}::contract_obj", f"{project_name}::contract_obj"), - ], - ignore_missing - ) - - def _patch_source_code_tests(self): - test_dir_path = self.directory / "tests" - if not test_dir_path.is_dir(): - return - - test_paths = utils.list_files(test_dir_path) - self._patch_source_code_files(test_paths, ignore_missing=False) + self.template = template + self.path = path - def _patch_scenarios_tests(self): - test_dir_path = self.directory / "scenarios" - if not test_dir_path.is_dir(): - return + def get_contract_templates(self) -> str: + self._ensure_dependencies_installed() + args = self._prepare_args_to_list_templates() + templates = myprocess.run_process(args=args, dump_to_stdout=False) + return templates - test_paths = utils.list_files(test_dir_path, suffix=".json") - self._replace_in_files( - test_paths, - [ - (f"{self.template_name}.wasm", f"{self.project_name}.wasm") - ], - ignore_missing=False - ) + def create_from_template(self) -> None: + self._ensure_dependencies_installed() + args = self._prepare_args_to_create_new_contract_from_template() + myprocess.run_process(args) - for file in test_paths: - data = utils.read_json_file(file) - # Patch fields - data["name"] = data.get("name", "").replace(self.template_name, self.project_name) - utils.write_json_file(str(file), data) + def _ensure_dependencies_installed(self): + logger.info("Checking if the necessarry dependencies are installed.") + install_module("rust") - def _replace_in_files(self, files: List[Path], replacements: List[Tuple[str, str]], ignore_missing: bool) -> None: - for file in files: - if ignore_missing and not file.exists(): - continue - content = file.read_text() + def _prepare_args_to_list_templates(self) -> list[str]: + args = ["sc-meta", "templates"] - for to_replace, replacement in replacements: - content = content.replace(to_replace, replacement) + if self.tag: + args.extend(["--tag", self.tag]) - utils.write_file(file, content) + return args + def _prepare_args_to_create_new_contract_from_template(self) -> list[str]: + args = ["sc-meta", "new", "--template", self.template, "--path", str(self.path)] -def remove_path(dependency: Any) -> None: - try: - del dependency["path"] - except TypeError: - pass + if self.name: + args.extend(["--name", self.name]) + if self.tag: + args.extend(["--tag", self.tag]) -def remove_path_from_dependencies(cargo_file: CargoFile) -> None: - for dependency in cargo_file.get_dependencies().values(): - remove_path(dependency) - for dependency in cargo_file.get_dev_dependencies().values(): - remove_path(dependency) + return args diff --git a/multiversx_sdk_cli/projects/templates_config.py b/multiversx_sdk_cli/projects/templates_config.py deleted file mode 100644 index 2fbd6b45..00000000 --- a/multiversx_sdk_cli/projects/templates_config.py +++ /dev/null @@ -1,38 +0,0 @@ -import time - -from multiversx_sdk_cli import config -from multiversx_sdk_cli.projects.templates_repository import \ - TemplatesRepository -from multiversx_sdk_cli.utils import query_latest_release_tag - - -def get_templates_repositories(): - timestamp = int(time.time()) - examples_rs_tag = config.get_dependency_tag('mx_sdk_rs') - - if examples_rs_tag == 'latest': - examples_rs_tag = query_latest_release_tag('multiversx/mx-sdk-rs') - - examples_rs_tag_no_v = remove_initial_v_from_version(examples_rs_tag) - - return [ - TemplatesRepository( - key="mx-sdk-rs", - url=f"https://github.com/multiversx/mx-sdk-rs/archive/{examples_rs_tag}.zip?t={timestamp}", - github="multiversx/mx-sdk-rs", - relative_path=f"mx-sdk-rs-{examples_rs_tag_no_v}/contracts/examples" - ) - ] - - -def remove_initial_v_from_version(version: str) -> str: - """Remove the initial 'v' from semver strings 'vX.XX.XX', but leave branch - names or non-semver tags unchanged""" - if version[0] != 'v': - return version - - version_no_v = version[1:] - if not version_no_v[0].isnumeric(): - return version - - return version_no_v diff --git a/multiversx_sdk_cli/projects/templates_repository.py b/multiversx_sdk_cli/projects/templates_repository.py deleted file mode 100644 index 5d4f2ee0..00000000 --- a/multiversx_sdk_cli/projects/templates_repository.py +++ /dev/null @@ -1,77 +0,0 @@ -import shutil -import time -from os import path -from pathlib import Path - -from multiversx_sdk_cli import downloader, utils, workstation -from multiversx_sdk_cli.projects.constants import PROJECT_CONFIG_FILENAME -from multiversx_sdk_cli.projects.migrations import migrate_project_templates - - -class TemplatesRepository: - def __init__(self, key: str, url: str, github: str, relative_path: str): - self.key = key - self.url = url - self.github = github - self.relative_path = relative_path - - def download(self): - self._download_if_old() - - templates_folder = self.get_folder() - try: - shutil.rmtree(templates_folder) - except FileNotFoundError: - pass - - archive = self._get_archive_path() - utils.unzip(archive, templates_folder) - migrate_project_templates(self.get_payload_folder()) - - def _download_if_old(self): - CACHE_DURATION = 30 - archive = self._get_archive_path() - - if path.isfile(archive): - if time.time() - path.getmtime(archive) < CACHE_DURATION: - return - - downloader.download(self.url, str(archive)) - - def _get_archive_path(self) -> Path: - tools_folder = workstation.get_tools_folder() - archive = tools_folder / f"{self.key}.zip" - return archive - - def get_folder(self) -> Path: - tools_folder = workstation.get_tools_folder() - folder = tools_folder / "templates" / self.key - return folder - - def has_template(self, template: str) -> bool: - folder = self.get_template_folder(template) - has = folder.is_dir() - return has - - def get_template_folder(self, template: str) -> Path: - return self.get_payload_folder() / template - - def get_templates(self): - templates = utils.get_subfolders(self.get_payload_folder()) - templates = [item for item in templates if self.is_template(item)] - return templates - - def is_template(self, subfolder: str) -> bool: - project_config_file = self.get_metadata_file(subfolder) - return project_config_file.is_file() - - def get_metadata_file(self, template: str) -> Path: - return self.get_payload_folder() / template / PROJECT_CONFIG_FILENAME - - def get_language(self, template: str): - metadata_file = self.get_metadata_file(template) - metadata = utils.read_json_file(metadata_file) - return metadata.get("language", "unknown") - - def get_payload_folder(self) -> Path: - return self.get_folder() / self.relative_path diff --git a/multiversx_sdk_cli/tests/test_cli_contracts.py b/multiversx_sdk_cli/tests/test_cli_contracts.py index 46f5cddd..259b1a0e 100644 --- a/multiversx_sdk_cli/tests/test_cli_contracts.py +++ b/multiversx_sdk_cli/tests/test_cli_contracts.py @@ -14,9 +14,8 @@ def test_contract_new(): "new", "--template", "adder", - "--directory", - f"{parent}/testdata-out/SANDBOX", - "adder" + "--path", + f"{parent}/testdata-out/SANDBOX" ]) assert Path.is_dir(parent / "testdata-out" / "SANDBOX" / "adder") @@ -28,18 +27,19 @@ def test_contract_new_with_bad_code(): "new", "--template", "adder", - "--directory", + "--path", f"{parent}/testdata-out/SANDBOX", + "--name", "adder-bad-src" ]) assert Path.is_dir(parent / "testdata-out" / "SANDBOX" / "adder-bad-src") - replace_variable_with_unknown_variable() + replace_variable_with_unknown_variable_for_adder() -def replace_variable_with_unknown_variable(): +def replace_variable_with_unknown_variable_for_adder(): # this is done in order to replace the value added in the adder contract with a unknown variable - with open(parent / "testdata-out" / "SANDBOX" / "adder-bad-src" / "src" / "adder.rs", "r") as f: + with open(parent / "testdata-out" / "SANDBOX" / "adder-bad-src" / "src" / "adder_bad_src.rs", "r") as f: contract_lines = f.readlines() for index, line in reversed(list(enumerate(contract_lines))): @@ -47,7 +47,7 @@ def replace_variable_with_unknown_variable(): contract_lines[index] = line.replace("value", "unknown_variable") break - with open(parent / "testdata-out" / "SANDBOX" / "adder-bad-src" / "src" / "adder.rs", "w") as f: + with open(parent / "testdata-out" / "SANDBOX" / "adder-bad-src" / "src" / "adder_bad_src.rs", "w") as f: f.writelines(contract_lines) diff --git a/multiversx_sdk_cli/tests/test_cli_contracts.sh b/multiversx_sdk_cli/tests/test_cli_contracts.sh index 174e0b2f..fe980cfe 100755 --- a/multiversx_sdk_cli/tests/test_cli_contracts.sh +++ b/multiversx_sdk_cli/tests/test_cli_contracts.sh @@ -9,12 +9,9 @@ testTrivialCommands() { testCreateContracts() { echo "testCreateContracts" - ${CLI} contract new --template adder --directory ${SANDBOX} myadder-rs || return 1 - ${CLI} contract new --template factorial --directory ${SANDBOX} myfactorial-rs || return 1 - ${CLI} contract new --template crypto-bubbles --directory ${SANDBOX} mybubbles-rs || return 1 - ${CLI} contract new --template lottery-esdt --directory ${SANDBOX} mylottery-rs || return 1 - ${CLI} contract new --template crowdfunding-esdt --directory ${SANDBOX} myfunding-rs || return 1 - ${CLI} contract new --template multisig --directory ${SANDBOX} multisig-rs || return 1 + ${CLI} contract new --template adder --path ${SANDBOX} || return 1 + ${CLI} contract new --template crypto-zombies --path ${SANDBOX} || return 1 + ${CLI} contract new --template empty --path ${SANDBOX} || return 1 } testBuildContracts() { @@ -24,77 +21,55 @@ testBuildContracts() { export TARGET_DIR=$(pwd)/${SANDBOX}/TARGET mkdir -p ${TARGET_DIR} - ${CLI} contract build --path=${SANDBOX}/myadder-rs --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/myadder-rs/output/myadder-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myadder-rs/output/myadder-rs.abi.json || return 1 + ${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 - ${CLI} contract build --path=${SANDBOX}/myfactorial-rs --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.abi.json || return 1 + ${CLI} contract build --path=${SANDBOX}/crypto-zombies --target-dir=${TARGET_DIR} || return 1 + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 - ${CLI} contract build --path=${SANDBOX}/mybubbles-rs --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.wasm || return 1 - assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.abi.json || return 1 - - ${CLI} contract build --path=${SANDBOX}/mylottery-rs --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.wasm || return 1 - assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.abi.json || return 1 - - ${CLI} contract build --path=${SANDBOX}/myfunding-rs --target-dir=${TARGET_DIR} || return 1 - assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.abi.json || return 1 + ${CLI} contract build --path=${SANDBOX}/empty --target-dir=${TARGET_DIR} || return 1 + assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 + assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 } testRunScenarios() { echo "testRunScenarios" - ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/myadder-rs || return 1 - ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/mybubbles-rs || return 1 - ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/mylottery-rs || return 1 - ${CLI} --verbose contract test --directory="scenarios" --recursive ${SANDBOX}/myfunding-rs || return 1 + ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/adder || return 1 + ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/empty || return 1 } testWasmName() { echo "testWasmName" - ${CLI} contract clean --path ${SANDBOX}/myadder-rs - assertFileDoesNotExist ${SANDBOX}/myadder-rs/output/myadder-2-rs.wasm || return 1 - ${CLI} contract build --path=${SANDBOX}/myadder-rs --target-dir=${TARGET_DIR} --wasm-name myadder-2-rs || return 1 - assertFileExists ${SANDBOX}/myadder-rs/output/myadder-2-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myadder-rs/output/myadder-rs.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/adder + assertFileDoesNotExist ${SANDBOX}/adder/output/adder-2.wasm || return 1 + ${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} --wasm-name adder-2 || return 1 + assertFileExists ${SANDBOX}/adder/output/adder-2.wasm || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 } testCleanContracts() { echo "testCleanContracts" - assertFileExists ${SANDBOX}/myadder-rs/output/myadder-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myadder-rs/output/myadder-rs.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/myadder-rs || return 1 - assertFileDoesNotExist ${SANDBOX}/myadder-rs/output/myadder-rs.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/myadder-rs/output/myadder-rs.abi.json || return 1 - - assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/myfactorial-rs || return 1 - assertFileDoesNotExist ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.abi.json || return 1 - - assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.wasm || return 1 - assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/mybubbles-rs || return 1 - assertFileDoesNotExist ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.abi.json || return 1 - - assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.wasm || return 1 - assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/mylottery-rs || return 1 - assertFileDoesNotExist ${SANDBOX}/mylottery-rs/output/mylottery-rs.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/mylottery-rs/output/mylottery-rs.abi.json || return 1 - - assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.wasm || return 1 - assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.abi.json || return 1 - ${CLI} contract clean --path ${SANDBOX}/myfunding-rs || return 1 - assertFileDoesNotExist ${SANDBOX}/myfunding-rs/output/myfunding-rs.wasm || return 1 - assertFileDoesNotExist ${SANDBOX}/myfunding-rs/output/myfunding-rs.abi.json || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 + assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/adder || return 1 + assertFileDoesNotExist ${SANDBOX}/adder/output/adder.wasm || return 1 + assertFileDoesNotExist ${SANDBOX}/adder/output/adder.abi.json || return 1 + + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 + assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/crypto-zombies || return 1 + assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 + assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 + + assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 + assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 + ${CLI} contract clean --path ${SANDBOX}/empty || return 1 + assertFileDoesNotExist ${SANDBOX}/empty/output/empty.wasm || return 1 + assertFileDoesNotExist ${SANDBOX}/empty/output/empty.abi.json || return 1 } testVerifyContract(){ diff --git a/multiversx_sdk_cli/tests/testdata-out/.gitignore b/multiversx_sdk_cli/tests/testdata-out/.gitignore deleted file mode 100644 index 210accf2..00000000 --- a/multiversx_sdk_cli/tests/testdata-out/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# Ignore everything -* - -# But not these files... -!.gitignore -