diff --git a/Scarb.toml b/Scarb.toml index a193836..8d00e94 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -6,6 +6,7 @@ edition = "2023_11" [dependencies] starknet = "2.6.3" alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" } +alexandria_bytes = { git = "https://github.com/keep-starknet-strange/alexandria.git" } openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.13.0" } [dev-dependencies] diff --git a/src/core/registry.cairo b/src/core/registry.cairo index 67920fe..fe9ad3a 100644 --- a/src/core/registry.cairo +++ b/src/core/registry.cairo @@ -29,6 +29,8 @@ pub trait IRegistry { } #[starknet::contract] pub mod Registry { + use alexandria_encoding::sol_abi::encode::SolAbiEncodeTrait; + use alexandria_bytes::{Bytes, BytesTrait}; use starknet::ContractAddress; use core::poseidon::PoseidonTrait; use core::hash::HashStateTrait; @@ -212,7 +214,13 @@ 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