diff --git a/contracts/src/components/registry/interface.cairo b/contracts/src/components/registry/interface.cairo index dc271c2..60c5304 100644 --- a/contracts/src/components/registry/interface.cairo +++ b/contracts/src/components/registry/interface.cairo @@ -2,7 +2,7 @@ use core::hash::HashStateExTrait; use starknet::ContractAddress; use zkramp::utils::hash::HashSerializable; -#[derive(Drop, Serde)] +#[derive(Drop, Serde, Clone)] pub enum OffchainId { Revolut: ByteArray } diff --git a/contracts/src/components/registry/registry.cairo b/contracts/src/components/registry/registry.cairo index 6b317f8..d3b301e 100644 --- a/contracts/src/components/registry/registry.cairo +++ b/contracts/src/components/registry/registry.cairo @@ -1,7 +1,7 @@ #[starknet::component] pub mod RegistryComponent { use core::num::traits::Zero; -use starknet::storage::Map; + use starknet::storage::Map; use starknet::{ContractAddress, get_caller_address}; use zkramp::components::registry::interface::OffchainId; use zkramp::components::registry::interface; @@ -23,6 +23,23 @@ use starknet::storage::Map; pub const ZERO_ADDRESS_CALLER: felt252 = 'Caller is the zero address'; } + // + // Registration Event + // + + #[event] + #[derive(Drop, starknet::Event)] + pub enum Event { + RegistrationEvent: RegistrationEvent, + } + + #[derive(Drop, starknet::Event)] + pub struct RegistrationEvent { + #[key] + caller: ContractAddress, + offchain_id: OffchainId, + } + // // Registry impl // @@ -48,7 +65,10 @@ use starknet::storage::Map; // TODO: caller a processor to verify the proof of registration // save registration - self.Registry_registrations.write((caller, offchain_id), true) + self.Registry_registrations.write((caller, offchain_id.clone()), true); + + // emit registration event + self.emit(RegistrationEvent { caller : caller, offchain_id : offchain_id }); } } }