From e01e07e602b04e95148a86c34d4b41781f0979e8 Mon Sep 17 00:00:00 2001 From: mubarak23 Date: Sun, 20 Oct 2024 12:31:10 +0100 Subject: [PATCH] chore:remove chain_id from create profile interface --- src/interfaces/IHub.cairo | 3 +-- src/interfaces/IProfile.cairo | 3 +-- src/mocks/interfaces/IComposable.cairo | 3 +-- src/profile/profile.cairo | 7 ++++--- tests/test_hub.cairo | 3 --- tests/test_profile.cairo | 6 +++--- tests/test_publication.cairo | 9 +++------ 7 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/interfaces/IHub.cairo b/src/interfaces/IHub.cairo index b21d08a..79164e5 100644 --- a/src/interfaces/IHub.cairo +++ b/src/interfaces/IHub.cairo @@ -16,8 +16,7 @@ pub trait IHub { karstnft_contract_address: ContractAddress, registry_hash: felt252, implementation_hash: felt252, - salt: felt252, - chain_id: felt252 + salt: felt252 ) -> ContractAddress; fn set_profile_metadata_uri( diff --git a/src/interfaces/IProfile.cairo b/src/interfaces/IProfile.cairo index c1a88d4..6f7f554 100644 --- a/src/interfaces/IProfile.cairo +++ b/src/interfaces/IProfile.cairo @@ -13,8 +13,7 @@ pub trait IProfile { karstnft_contract_address: ContractAddress, registry_hash: felt252, implementation_hash: felt252, - salt: felt252, - chain_id: felt252 + salt: felt252 ) -> ContractAddress; fn set_profile_metadata_uri( ref self: TState, profile_address: ContractAddress, metadata_uri: ByteArray diff --git a/src/mocks/interfaces/IComposable.cairo b/src/mocks/interfaces/IComposable.cairo index 12ceebe..1e9fc51 100644 --- a/src/mocks/interfaces/IComposable.cairo +++ b/src/mocks/interfaces/IComposable.cairo @@ -15,8 +15,7 @@ pub trait IComposable { karstnft_contract_address: ContractAddress, registry_hash: felt252, implementation_hash: felt252, - salt: felt252, - chain_id: felt252, + salt: felt252 ) -> ContractAddress; fn set_profile_metadata_uri( ref self: TState, profile_address: ContractAddress, metadata_uri: ByteArray diff --git a/src/profile/profile.cairo b/src/profile/profile.cairo index 5a7c5c5..bd84298 100644 --- a/src/profile/profile.cairo +++ b/src/profile/profile.cairo @@ -5,7 +5,7 @@ pub mod ProfileComponent { // ************************************************************************* use core::{traits::TryInto}; use starknet::{ - ContractAddress, get_caller_address, get_block_timestamp, ClassHash, + get_tx_info, ContractAddress, get_caller_address, get_block_timestamp, ClassHash, syscalls::deploy_syscall, SyscallResultTrait, storage::{ StoragePointerWriteAccess, StoragePointerReadAccess, Map, StorageMapReadAccess, @@ -65,8 +65,7 @@ pub mod ProfileComponent { karstnft_contract_address: ContractAddress, registry_hash: felt252, implementation_hash: felt252, - salt: felt252, - chain_id: felt252, + salt: felt252 ) -> ContractAddress { // mint karst nft let recipient = get_caller_address(); @@ -78,6 +77,8 @@ pub mod ProfileComponent { } let token_id = IKarstNFTDispatcher { contract_address: karstnft_contract_address } .get_user_token_id(recipient); + let tx_info = get_tx_info().unbox(); + let chain_id = tx_info.chain_id; // create tokenbound account let profile_address = IRegistryLibraryDispatcher { class_hash: registry_hash.try_into().unwrap() diff --git a/tests/test_hub.cairo b/tests/test_hub.cairo index be8f71a..9f046f5 100644 --- a/tests/test_hub.cairo +++ b/tests/test_hub.cairo @@ -69,7 +69,6 @@ fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAd nft_contract_address, (*registry_class_hash.class_hash).into(), (*account_class_hash.class_hash).into(), - 2478, 2478 ); stop_cheat_caller_address(hub_contract_address); @@ -80,7 +79,6 @@ fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAd nft_contract_address, (*registry_class_hash.class_hash).into(), (*account_class_hash.class_hash).into(), - 2478, 2478 ); @@ -92,7 +90,6 @@ fn __setup__() -> (ContractAddress, ContractAddress, ContractAddress, ContractAd nft_contract_address, (*registry_class_hash.class_hash).into(), (*account_class_hash.class_hash).into(), - 2478, 2478 ); stop_cheat_caller_address(hub_contract_address); diff --git a/tests/test_profile.cairo b/tests/test_profile.cairo index 9cc1aec..6db0d08 100644 --- a/tests/test_profile.cairo +++ b/tests/test_profile.cairo @@ -71,7 +71,7 @@ fn test_profile_creation() { start_cheat_caller_address(profile_contract_address, USER.try_into().unwrap()); start_cheat_caller_address(nft_contract_address, USER.try_into().unwrap()); let profile_address = profileDispatcher - .create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456, 2456); + .create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456); // test a new karst nft is minted let last_minted_id = karstNFTDispatcher.get_last_minted_id(); @@ -103,7 +103,7 @@ fn test_profile_metadata() { start_cheat_caller_address(profile_contract_address, USER.try_into().unwrap()); start_cheat_caller_address(nft_contract_address, USER.try_into().unwrap()); let profile_address = profileDispatcher - .create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456, 2456); + .create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456); profileDispatcher .set_profile_metadata_uri( @@ -137,7 +137,7 @@ fn test_profile_creation_event() { start_cheat_caller_address(nft_contract_address, USER.try_into().unwrap()); let profile_address = profileDispatcher - .create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456, 2456); + .create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456); let token_id = karstNFTDispatcher.get_user_token_id(USER.try_into().unwrap()); diff --git a/tests/test_publication.cairo b/tests/test_publication.cairo index 0bd06c1..45b95ba 100644 --- a/tests/test_publication.cairo +++ b/tests/test_publication.cairo @@ -80,8 +80,7 @@ fn __setup__() -> ( nft_contract_address, (*registry_class_hash.class_hash).into(), (*account_class_hash.class_hash).into(), - 2478, - 2479 + 2478 ); let content_URI: ByteArray = "ipfs://helloworld"; let mut spy = spy_events(); @@ -100,8 +99,7 @@ fn __setup__() -> ( nft_contract_address, (*registry_class_hash.class_hash).into(), (*account_class_hash.class_hash).into(), - 2479, - 2482 + 2479 ); let content_URI: ByteArray = "ipfs://helloworld"; dispatcher @@ -120,8 +118,7 @@ fn __setup__() -> ( nft_contract_address, (*registry_class_hash.class_hash).into(), (*account_class_hash.class_hash).into(), - 2480, - 2481 + 2480 ); let content_URI: ByteArray = "ipfs://helloworld"; dispatcher