Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_profile_by_id function #38

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading