Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lana-shanghai authored Aug 21, 2024
2 parents 8610306 + 1f00baf commit a9418ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/src/components/registry/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
24 changes: 22 additions & 2 deletions contracts/src/components/registry/registry.cairo
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
//
Expand All @@ -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 });
}
}
}

0 comments on commit a9418ff

Please sign in to comment.