diff --git a/contracts/deployer/src/lib.rs b/contracts/deployer/src/lib.rs index efa9548..c33195d 100644 --- a/contracts/deployer/src/lib.rs +++ b/contracts/deployer/src/lib.rs @@ -63,7 +63,7 @@ impl CollectionsDeployer { let _: Val = env.invoke_contract(&deployed_collection, &init_fn, init_fn_args); save_collection_with_generic_key(&env, name.clone()); - save_collection_with_admin_address_as_key(&env, admin, collection_addres, name); + save_collection_with_admin_address_as_key(&env, admin, deployed_collection.clone(), name); deployed_collection } @@ -113,7 +113,7 @@ impl CollectionsDeployer { // ---------- Storage types ---------- #[contracttype] -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct CollectionByCreatorResponse { collection: Address, name: String, diff --git a/contracts/deployer/src/tests.rs b/contracts/deployer/src/tests.rs index 9156000..2ca6440 100644 --- a/contracts/deployer/src/tests.rs +++ b/contracts/deployer/src/tests.rs @@ -1,4 +1,4 @@ -use crate::{CollectionsDeployer, CollectionsDeployerClient}; +use crate::{CollectionByCreatorResponse, CollectionsDeployer, CollectionsDeployerClient}; #[cfg(test)] use soroban_sdk::{testutils::Address as _, vec, Address, BytesN, Env, String}; @@ -33,12 +33,12 @@ fn test_deploy_collection_from_contract() { let name = String::from_str(&env, "Stellar Kitties"); let symbol = String::from_str(&env, "STK"); - client.deploy_new_collection(&salt, &creator, &name, &symbol); + let collection = client.deploy_new_collection(&salt, &creator, &name, &symbol); assert_eq!(client.query_all_collections(), vec![&env, name.clone()]); assert_eq!( client.query_collection_by_creator(&creator), - vec![&env, name] + vec![&env, CollectionByCreatorResponse { collection, name }] ); } @@ -71,19 +71,19 @@ fn test_deploy_multiple_collections() { let third_collection_name = String::from_str(&env, "Horror of Cthulhu"); let third_collection_symbol = String::from_str(&env, "HoC"); - client.deploy_new_collection( + let first = client.deploy_new_collection( &first_salt, &creator, &first_collection_name, &first_collection_symbol, ); - client.deploy_new_collection( + let second = client.deploy_new_collection( &second_salt, &creator, &second_collection_name, &second_collection_symbol, ); - client.deploy_new_collection( + let third = client.deploy_new_collection( &third_salt, &bob, &third_collection_name, @@ -102,12 +102,28 @@ fn test_deploy_multiple_collections() { assert_eq!( client.query_collection_by_creator(&creator), - vec![&env, first_collection_name, second_collection_name] + vec![ + &env, + CollectionByCreatorResponse { + collection: first, + name: first_collection_name, + }, + CollectionByCreatorResponse { + collection: second, + name: second_collection_name, + }, + ] ); assert_eq!( client.query_collection_by_creator(&bob), - vec![&env, third_collection_name] + vec![ + &env, + CollectionByCreatorResponse { + collection: third, + name: third_collection_name + } + ] ); }