diff --git a/addresses.txt b/addresses.txt index 368a93c..06b270b 100644 --- a/addresses.txt +++ b/addresses.txt @@ -4,6 +4,6 @@ Hub Address - 0x00fde7695a162a807214e78cd1f3a09c21fc0b7a07aeeb875049dcfaaa1a07a2 Coloniz NFT - 0x01d3ec880419c6714800fc406d0696dde969f51c0521ca0b5c76b1f69af3eb46 Handles - 0x752dd216dcebb660204c7302ff0a99494e7f8c464cb4fe48112d39e12f3df14 Handles Registry - 0x4b5eef8900d4329f8fe60d3d79a6ef8ac79c2d979fce15da18f53ab25e79e83 -Follow NFT - -Community NFT - +Follow NFT (classhash) - 0x05dffad824556defac917572ffe4644a3b652662779bafd346888d09306dfe0d +Community NFT (classhash) - 0x050bea932528781b2da6f85e376df259cee7053f71528e0dbe617b13bae79a21 Admin - 0x02F659cf8CCE41168B8c0A8BedCE468E33BE1B7bd26E920266C025Dc0F8FBD1b diff --git a/src/follownft/follownft.cairo b/src/follownft/follownft.cairo index c8d2ef7..ab0b381 100644 --- a/src/follownft/follownft.cairo +++ b/src/follownft/follownft.cairo @@ -54,6 +54,7 @@ pub mod Follow { ownable: OwnableComponent::Storage, admin: ContractAddress, followed_profile_address: ContractAddress, + token_id: u256, follower_count: u256, follow_id_by_follower_profile_address: Map, follow_data_by_follow_id: Map, @@ -118,12 +119,18 @@ pub mod Follow { ref self: ContractState, hub: ContractAddress, profile_address: ContractAddress, + token_id: u256, admin: ContractAddress ) { self.admin.write(admin); - self.erc721.initializer("Coloniz Followers", "CLZ:FOLLOWERS", ""); + self.token_id.write(token_id); self.coloniz_hub.write(hub); self.followed_profile_address.write(profile_address); + + let prefix: ByteArray = "Coloniz Followers | #"; + let profile_id: felt252 = self.token_id.read().low.into(); + let name = format!("{}{}", prefix, profile_id); + self.erc721.initializer(name, "CLZ:FOLLOWERS", ""); } // ************************************************************************* @@ -277,7 +284,9 @@ pub mod Follow { // ************************************************************************* /// @notice returns the collection name fn name(self: @ContractState) -> ByteArray { - return "Coloniz Followers"; + let prefix: ByteArray = "Coloniz Followers | #"; + let profile_id: felt252 = self.token_id.read().low.into(); + format!("{}{}", prefix, profile_id) } /// @notice returns the collection symbol diff --git a/src/profile/profile.cairo b/src/profile/profile.cairo index d51b8cf..5e21e4c 100644 --- a/src/profile/profile.cairo +++ b/src/profile/profile.cairo @@ -95,7 +95,11 @@ pub mod ProfileComponent { // deploy follow nft contract let mut constructor_calldata: Array = array![ - self.hub_address.read().into(), profile_address.into(), recipient.into() + self.hub_address.read().into(), + profile_address.into(), + token_id.low.into(), + token_id.high.into(), + recipient.into() ]; let (follow_nft_address, _) = deploy_syscall( self.follow_nft_classhash.read(), diff --git a/tests/test_coloniznft.cairo b/tests/test_coloniznft.cairo index 3f6973d..21fc2b4 100644 --- a/tests/test_coloniznft.cairo +++ b/tests/test_coloniznft.cairo @@ -33,8 +33,8 @@ fn test_metadata() { start_cheat_caller_address(nft_contract_address, ADMIN.try_into().unwrap()); let nft_name = dispatcher.name(); let nft_symbol = dispatcher.symbol(); - assert(nft_name == "coloniz", 'invalid name'); - assert(nft_symbol == "KST", 'invalid symbol'); + assert(nft_name == "Coloniz", 'invalid name'); + assert(nft_symbol == "CLZ:PROFILE", 'invalid symbol'); stop_cheat_caller_address(nft_contract_address); } diff --git a/tests/test_follownft.cairo b/tests/test_follownft.cairo index d33f39a..f09a8ef 100644 --- a/tests/test_follownft.cairo +++ b/tests/test_follownft.cairo @@ -30,7 +30,7 @@ const FOLLOWER4: felt252 = 24262; fn __setup__() -> ContractAddress { let follow_nft_contract = declare("Follow").unwrap().contract_class(); - let mut follow_nft_constructor_calldata = array![HUB_ADDRESS, FOLLOWED_ADDRESS, ADMIN]; + let mut follow_nft_constructor_calldata = array![HUB_ADDRESS, FOLLOWED_ADDRESS, 10, 0, ADMIN]; let (follow_nft_contract_address, _) = follow_nft_contract .deploy(@follow_nft_constructor_calldata) .unwrap(); @@ -209,8 +209,9 @@ fn test_metadata() { let dispatcher = IFollowNFTDispatcher { contract_address: follow_nft_contract_address }; let nft_name = dispatcher.name(); let nft_symbol = dispatcher.symbol(); - assert(nft_name == "coloniz:FOLLOWER", 'invalid name'); - assert(nft_symbol == "KFL", 'invalid symbol'); + println!("{:?}", nft_name); + assert(nft_name == "Coloniz Followers | #10", 'invalid name'); + assert(nft_symbol == "CLZ:FOLLOWERS", 'invalid symbol'); stop_cheat_caller_address(follow_nft_contract_address); } diff --git a/tests/test_handle.cairo b/tests/test_handle.cairo index f3a847f..d66e552 100644 --- a/tests/test_handle.cairo +++ b/tests/test_handle.cairo @@ -43,26 +43,21 @@ fn test_mint_handle() { let handles_contract_address = __setup__(); let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); - let token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME); + let token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); let local_name: felt252 = handles_dispatcher.get_local_name(token_id); assert(local_name == TEST_LOCAL_NAME, 'invalid local name'); - - stop_cheat_caller_address(handles_contract_address); } fn test_mint_handle_two() { let handles_contract_address = __setup__(); let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); - let token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME_TWO); + let token_id = handles_dispatcher + .mint_handle(TEST_LOCAL_NAME_TWO, USER_ONE.try_into().unwrap()); let local_name: felt252 = handles_dispatcher.get_local_name(token_id); assert(local_name == TEST_LOCAL_NAME_TWO, 'invalid local name two'); - - stop_cheat_caller_address(handles_contract_address); } #[test] @@ -71,8 +66,7 @@ fn test_mint_handle_with_bad_local_name_1() { let handles_contract_address = __setup__(); let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); - handles_dispatcher.mint_handle(TEST_BAD_LOCAL_NAME_1); + handles_dispatcher.mint_handle(TEST_BAD_LOCAL_NAME_1, USER_ONE.try_into().unwrap()); } #[test] #[should_panic(expected: ('coloniz: invalid local name!',))] @@ -80,8 +74,7 @@ fn test_mint_handle_with_bad_local_name_2() { let handles_contract_address = __setup__(); let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); - handles_dispatcher.mint_handle(TEST_BAD_LOCAL_NAME_2); + handles_dispatcher.mint_handle(TEST_BAD_LOCAL_NAME_2, USER_ONE.try_into().unwrap()); } #[test] @@ -90,8 +83,7 @@ fn test_mint_handle_with_bad_local_name_3() { let handles_contract_address = __setup__(); let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); - handles_dispatcher.mint_handle(TEST_BAD_LOCAL_NAME_3); + handles_dispatcher.mint_handle(TEST_BAD_LOCAL_NAME_3, USER_ONE.try_into().unwrap()); } #[test] @@ -112,8 +104,7 @@ fn test_handle_id_exists_after_mint() { let dispatcher = IHandleDispatcher { contract_address }; let _erc721Dispatcher = IERC721Dispatcher { contract_address }; - start_cheat_caller_address(contract_address, ADMIN_ADDRESS.try_into().unwrap()); - let handle_id: u256 = dispatcher.mint_handle('handle'); + let handle_id: u256 = dispatcher.mint_handle('handle', ADMIN_ADDRESS.try_into().unwrap()); assert(dispatcher.exists(handle_id), 'Handle ID does not exist'); } @@ -126,7 +117,7 @@ fn test_total_supply() { let current_total_supply: u256 = dispatcher.total_supply(); start_cheat_caller_address(contract_address, USER_ONE.try_into().unwrap()); - let handle_id: u256 = dispatcher.mint_handle('handle'); + let handle_id: u256 = dispatcher.mint_handle('handle', USER_ONE.try_into().unwrap()); let total_supply_after_mint: u256 = dispatcher.total_supply(); assert(total_supply_after_mint == current_total_supply + 1, 'WRONG_TOTAL_SUPPLY'); @@ -142,8 +133,7 @@ fn test_burn() { let dispatcher = IHandleDispatcher { contract_address }; let _erc721Dispatcher = IERC721Dispatcher { contract_address }; - start_cheat_caller_address(contract_address, USER_ONE.try_into().unwrap()); - let handle_id: u256 = dispatcher.mint_handle('handle'); + let handle_id: u256 = dispatcher.mint_handle('handle', USER_ONE.try_into().unwrap()); assert(dispatcher.exists(handle_id) == true, 'Handle ID does not exist'); assert(_erc721Dispatcher.owner_of(handle_id) == USER_ONE.try_into().unwrap(), 'Wrong Owner'); @@ -162,7 +152,7 @@ fn test_cannot_burn_if_not_owner_of() { let _erc721Dispatcher = IERC721Dispatcher { contract_address }; start_cheat_caller_address(contract_address, USER_TWO.try_into().unwrap()); - let handle_id: u256 = dispatcher.mint_handle('handle'); + let handle_id: u256 = dispatcher.mint_handle('handle', USER_TWO.try_into().unwrap()); stop_cheat_caller_address(contract_address); start_cheat_caller_address(contract_address, USER_ONE.try_into().unwrap()); @@ -177,14 +167,11 @@ fn test_get_handle() { let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); - let token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME); + let token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); let handle: ByteArray = handles_dispatcher.get_handle(token_id); assert(handle == "coloniz.kst", 'Invalid handle'); - - stop_cheat_caller_address(handles_contract_address); } #[test] @@ -206,10 +193,10 @@ fn test_mint_handle_event() { let handles_dispatcher = IHandleDispatcher { contract_address: handles_contract_address }; - start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); let mut spy = spy_events(); - let test_token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME); + let test_token_id = handles_dispatcher + .mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); let expected_event = Handles::Event::HandleMinted( Handles::HandleMinted { local_name: TEST_LOCAL_NAME, @@ -220,8 +207,6 @@ fn test_mint_handle_event() { ); spy.assert_emitted(@array![(handles_contract_address, expected_event)]); - - stop_cheat_caller_address(handles_contract_address); } #[test] @@ -233,7 +218,8 @@ fn test_burn_handle_event() { start_cheat_caller_address(handles_contract_address, USER_ONE.try_into().unwrap()); let mut spy = spy_events(); - let test_token_id = handles_dispatcher.mint_handle(TEST_LOCAL_NAME); + let test_token_id = handles_dispatcher + .mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); let mut expected_event = Handles::Event::HandleMinted( Handles::HandleMinted { diff --git a/tests/test_handle_registry.cairo b/tests/test_handle_registry.cairo index 65277f6..102e5ea 100644 --- a/tests/test_handle_registry.cairo +++ b/tests/test_handle_registry.cairo @@ -70,7 +70,7 @@ fn test_resolve() { // Mint Handle to USER_ONE start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let token_id = handle_dispatcher.mint_handle(TEST_LOCAL_NAME); + let token_id = handle_dispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); // Link handle to USER_ONE handle_registry_dispatcher.link(token_id, USER_ONE.try_into().unwrap()); @@ -92,7 +92,7 @@ fn test_link() { // mint handle start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); // link token to profile start_cheat_caller_address(handle_registry_address, USER_ONE.try_into().unwrap()); @@ -115,7 +115,7 @@ fn test_linking_fails_if_profile_address_is_not_owner() { // mint handle start_cheat_caller_address(handle_contract_address, USER_TWO.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_TWO.try_into().unwrap()); stop_cheat_caller_address(handle_contract_address); // link token to profile @@ -135,7 +135,7 @@ fn test_does_not_link_twice_for_same_handle() { // mint handle start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); // link token to profile start_cheat_caller_address(handle_registry_address, USER_ONE.try_into().unwrap()); @@ -156,7 +156,7 @@ fn test_unlink() { // mint handle start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); stop_cheat_caller_address(handle_contract_address); // link token to profile @@ -183,7 +183,7 @@ fn test_unlink_fails_if_caller_is_not_owner() { // mint handle start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); stop_cheat_caller_address(handle_contract_address); // link token to profile @@ -206,7 +206,7 @@ fn test_linked_event_emission() { // mint handle start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); stop_cheat_caller_address(handle_contract_address); // link token to profile @@ -238,7 +238,7 @@ fn test_unlinked_event_emission() { // mint handle start_cheat_caller_address(handle_contract_address, USER_ONE.try_into().unwrap()); - let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); + let handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, USER_ONE.try_into().unwrap()); stop_cheat_caller_address(handle_contract_address); // link token to profile diff --git a/tests/test_hub.cairo b/tests/test_hub.cairo index 7cdc347..d45be64 100644 --- a/tests/test_hub.cairo +++ b/tests/test_hub.cairo @@ -124,13 +124,11 @@ fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAd stop_cheat_caller_address(hub_contract_address); // mint and link handle for user_one - start_cheat_caller_address(handle_contract_address, user_one_profile_address); let handleDispatcher = IHandleDispatcher { contract_address: handle_contract_address }; let handleRegistryDispatcher = IHandleRegistryDispatcher { contract_address: handle_registry_contract_address }; - let minted_handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME); - stop_cheat_caller_address(handle_contract_address); + let minted_handle_id = handleDispatcher.mint_handle(TEST_LOCAL_NAME, user_one_profile_address); start_cheat_caller_address(handle_registry_contract_address, user_one_profile_address); handleRegistryDispatcher.link(minted_handle_id, user_one_profile_address);