Skip to content

Commit 7b1131e

Browse files
authored
Merge pull request #72 from Samuel1-ona/main
chores: fixed the create task function
2 parents 140292c + a4232f5 commit 7b1131e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/mods/interfaces/Iprotocol.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub trait IProtocol<TState> {
1010
fn create_protocol_campaign(ref self: TState, protocol_id: u256) -> u256;
1111
fn join_protocol_campaign(ref self: TState, campaign_user: ContractAddress, protocol_id: u256);
1212
fn set_protocol_matadata_uri(ref self: TState, protocol_id: u256, matadata_uri: ByteArray);
13-
fn create_task(ref self: TState, task_id: u256, task_description: ByteArray) -> u256;
13+
fn create_task(ref self: TState, task_description: ByteArray) -> u256;
1414

1515

1616
fn is_task_complete(ref self: TState, campaign_user: ContractAddress, task_id: u256) -> bool;

src/mods/protocol/protocolcomponent.cairo

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ pub mod ProtocolCampagin {
2727

2828
#[storage]
2929
pub struct Storage {
30-
protocol_id: u256,
30+
pub protocol_id: u256,
3131
protocol_counter: u256,
32-
protocol_nft_class_hash: ClassHash, // The protocol nft class hash
32+
pub protocol_nft_class_hash: ClassHash, // The protocol nft class hash
3333
protocol_owner: Map<u256, ContractAddress>, // map the owner address and the protocol id
3434
protocols: Map<u256, ProtocolDetails>, // map the protocol details and the protocol id
3535
protocol_initialized: Map<u256, bool>, // track if the protocol id has been used or not
3636
users_count: u256,
37-
Campaign_members: Map<
37+
pub Campaign_members: Map<
3838
(u256, ContractAddress), CampaignMembers
3939
>, // map the protocol id and the users interested on the protocol campaign
4040
protocol_info: Map<u256, ByteArray>, // map the protocol id to the protocol details
4141
protocol_tasks: Map<
4242
u256, ProtocolCreateTask
4343
>, // map the protocol create task to the task_id
44-
protocol_task_id: u256,
44+
pub protocol_task_id: u256,
4545
protocol_task_descriptions: Map<
4646
(u256, u256), ByteArray
4747
>, // map the task description to the protocol_id and to the task_id
48-
tasks: Map<
48+
pub tasks: Map<
4949
(u256, ContractAddress), u256
5050
>, // map the protocol_id and the protocol_owner to the task_id
5151
tasks_initialized: Map<u256, bool>, // track if the task_id has been used or not
@@ -171,11 +171,13 @@ pub mod ProtocolCampagin {
171171

172172

173173
fn create_task(
174-
ref self: ComponentState<TContractState>, task_id: u256, task_description: ByteArray
174+
ref self: ComponentState<TContractState>, task_description: ByteArray
175175
) -> u256 {
176176
// Get the caller as the protocol owner by using the get_caller_address()
177177
let protocol_owner = get_caller_address();
178178

179+
let task_id = self.protocol_task_id.read()+1;
180+
179181
// Check if the task_id exist by reading from state i.e tasks_initialized
180182
// and also assert if it exist Errors::TASK_ALREADY_EXIST
181183
let task_exists = self.tasks_initialized.read(task_id);

0 commit comments

Comments
 (0)