Skip to content

Commit

Permalink
Merge pull request #38 from Manush-2005/get_profile_by_id
Browse files Browse the repository at this point in the history
get_profile_by_id function
  • Loading branch information
Akashneelesh authored Aug 28, 2024
2 parents 452f67f + af7039c commit 86b0bca
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/core/registry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub trait IRegistry<TContractState> {
);
fn add_members(ref self: TContractState, profile_Id: u256, members: Array<ContractAddress>);
fn update_profile_metadata(ref self: TContractState, profile_id: u256, metadata: Metadata);
fn get_profile_by_id(self: @TContractState, profile_id: u256) -> Registry::Profile;
}
#[starknet::contract]
pub mod Registry {
Expand Down Expand Up @@ -75,7 +76,7 @@ pub mod Registry {
}

#[derive(Drop, Serde, starknet::Store)]
struct Profile {
pub struct Profile {
id: u256,
nonce: u256,
name: ByteArray,
Expand Down Expand Up @@ -143,6 +144,10 @@ pub mod Registry {
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L94
// Use _profileID as u256

fn get_profile_by_id(self: @ContractState, profile_id: u256) -> Profile {
return self.profiles_by_id.read(profile_id);
}

// Issue no. #14 Implement the functionality to retrieve profile by anchor
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L102
Expand Down Expand Up @@ -264,13 +269,6 @@ pub mod Registry {
// Issue no. #18 Implement the functionality of _generateAnchor
// Internal function to create a _generateAnchor
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L340
fn _generateProfileId(_nonce: u256, owner: ContractAddress) -> u256 {
let profileId = BytesTrait::new_empty()
.encode_packed(_nonce)
.encode_packed(owner)
.keccak();
return profileId;
}
// Issue no. #17 Implement the functionality of _checkOnlyProfileOwner
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L331
Expand All @@ -279,6 +277,13 @@ pub mod Registry {
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L375C14-L375C31

fn _generateProfileId(_nonce: u256, owner: ContractAddress) -> u256 {
let profileId = BytesTrait::new_empty()
.encode_packed(_nonce)
.encode_packed(owner)
.keccak();
return profileId;
}
// Issue no. #3 Implement the functionality of _isOwnerOfProfile
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L375C14-L375C31
Expand Down

0 comments on commit 86b0bca

Please sign in to comment.