diff --git a/crates/pop-contracts/src/new.rs b/crates/pop-contracts/src/new.rs index 256c226e..71f203b4 100644 --- a/crates/pop-contracts/src/new.rs +++ b/crates/pop-contracts/src/new.rs @@ -95,10 +95,19 @@ pub fn rename_contract(name: &str, path: PathBuf, template: &Contract) -> Result // Replace name in the lib.rs file. file_path = path.join("lib.rs"); let name_in_camel_case = name.to_upper_camel_case(); - let mut replacements_in_contract = HashMap::new(); - replacements_in_contract.insert(template_name.as_str(), name); - replacements_in_contract.insert(template.name(), &name_in_camel_case); - replace_in_file(file_path, replacements_in_contract)?; + replace_in_file( + file_path, + HashMap::from([(template_name.as_str(), name), (template.name(), &name_in_camel_case)]), + )?; + // Replace name in the e2e_tests.rs file if exists. + let e2e_tests = path.join("e2e_tests.rs"); + if e2e_tests.exists() { + let name_in_camel_case = format!("\"{}\"", name.to_upper_camel_case()); + replace_in_file( + e2e_tests, + HashMap::from([(template_name.as_str(), name), (template.name(), &name_in_camel_case)]), + )?; + } Ok(()) } @@ -187,6 +196,20 @@ mod tests { mod erc20 "# )?; + + let e2e_code = temp_dir.path().join("e2e_tests.rs"); + let mut e2e_code_file = fs::File::create(e2e_code.clone())?; + writeln!( + e2e_code_file, + r#" + #[ink_e2e::test] + let contract = client + .instantiate("erc20", &ink_e2e::alice(), &mut constructor) + .submit() + .await + .expect("erc20 instantiate failed"); + "# + )?; Ok(temp_dir) } #[test] @@ -200,6 +223,10 @@ mod tests { let generated_code = fs::read_to_string(temp_dir.path().join("lib.rs")).expect("Could not read file"); assert!(generated_code.contains("mod my_contract")); + let generated_e2e_code = + fs::read_to_string(temp_dir.path().join("e2e_tests.rs")).expect("Could not read file"); + assert!(generated_e2e_code + .contains(".instantiate(\"my_contract\", &ink_e2e::alice(), &mut constructor)")); Ok(()) } diff --git a/crates/pop-contracts/src/templates.rs b/crates/pop-contracts/src/templates.rs index a78c71d7..6c39d8c6 100644 --- a/crates/pop-contracts/src/templates.rs +++ b/crates/pop-contracts/src/templates.rs @@ -104,7 +104,7 @@ pub enum Contract { serialize = "PSP34", message = "Psp34", detailed_message = "The implementation of the PSP34 standard in ink!", - props(Type = "PSP", Repository = "https://github.com/Cardinal-Cryptography/PSP34") + props(Type = "PSP", Repository = "https://github.com/r0gue-io/PSP34") )] PSP34, /// Domain name service example implemented in ink! @@ -162,7 +162,7 @@ mod tests { ("erc721".to_string(), "https://github.com/use-ink/ink-examples"), ("erc1155".to_string(), "https://github.com/use-ink/ink-examples"), ("PSP22".to_string(), "https://github.com/Cardinal-Cryptography/PSP22"), - ("PSP34".to_string(), "https://github.com/Cardinal-Cryptography/PSP34"), + ("PSP34".to_string(), "https://github.com/r0gue-io/PSP34"), ("dns".to_string(), "https://github.com/use-ink/ink-examples"), ("cross-contract-calls".to_string(), "https://github.com/use-ink/ink-examples"), ("multisig".to_string(), "https://github.com/use-ink/ink-examples"),