Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/mods/errors.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod Errors {
pub const USER_ALREADY_REGISTERED: felt252 = 'USER_ALREADY_REGISTERED';
pub const USER_NOT_REGISTERED: felt252 = 'USER_NOT_REGISTERED';
pub const PROTOCOL_NOT_REGISTERED: felt252 = 'PROTOCOL_NOT_REGISTERED';
pub const TASK_ALREADY_EXISTS: felt252 = 'TASK_ALREADY_EXISTS';
pub const TASK_NOT_EXISTS: felt252 = 'TASK_NOT_EXISTS';
pub const PROTOCOL_ALREADY_REGISTERED: felt252 = 'PROTOCOL_ALREADY_REGISTERED';
Expand Down
1 change: 1 addition & 0 deletions src/mods/events.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use starknet::{ClassHash, ContractAddress};

#[derive(Copy, Drop, Debug, PartialEq, starknet::Event)]
pub struct Upgraded {
#[key]
pub implementation: ClassHash,
}

Expand Down
1 change: 1 addition & 0 deletions src/mods/interfaces/Iprotocol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub trait IProtocol<TState> {
fn set_protocol_matadata_uri(ref self: TState, protocol_id: u256, matadata_uri: ByteArray);
fn create_task(ref self: TState, task_description: ByteArray) -> u256;
fn protocol_register(ref self: TState, protocol_Details: ByteArray);
fn verfify_protocol(ref self: TState, protocol_address: ContractAddress);


// *************************************************************************
Expand Down
28 changes: 28 additions & 0 deletions src/mods/protocol/protocolcomponent.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub mod ProtocolCampagin {
protocol_register: Map<
ContractAddress, ProtocolInfo
>, // map the protocol owner to the protocol info
owner: ContractAddress, // The owner of the contract
}


Expand Down Expand Up @@ -170,6 +171,33 @@ pub mod ProtocolCampagin {
}


/// @notice verify protocols after registeration, this is done by the admin

fn verfify_protocol(
ref self: ComponentState<TContractState>, protocol_address: ContractAddress
) {
let caller = get_caller_address();
assert(caller == self.owner.read(), Errors::UNAUTHORIZED);

let protocol_info = self.protocol_register.read(protocol_address);
assert(protocol_info.registered, Errors::PROTOCOL_NOT_REGISTERED);

self
.protocol_register
.write(protocol_address, ProtocolInfo { verified: true, ..protocol_info });

self
.emit(
ProtocolRegistered {
protocol_id: protocol_info.protocol_id,
protocol_owner: get_caller_address(),
event_type: UserEventType::Verify,
block_timestamp: get_block_timestamp()
}
);
}


/// @notice Create a new protocol campaign
fn create_protocol_campaign(
ref self: ComponentState<TContractState>, protocol_id: u256, protocol_info: ByteArray
Expand Down