Open mubarak23 opened 2 days ago
I am applying to this issue via OnlyDust platform.
Mid level Cairo Developer
I will write a function that takes event_id as a parameter, check if the caller is the event owner, set the is_closed field in the event details to true, then emit an end_event_registration event. Also, I will ensure the function verifies only when the event owner calls it, then revert it when the caller is not the owner. Test included as well.
I am applying to this issue via OnlyDust platform.
A fullstack Blockchain developer, with extensive experience in building smart contracts.
The end_event_registration function must: Ensure only the owner can end the registration. Set the is_closed field to true when the registration ends. Emit the EndEventRegistration event upon successful closure.
I am applying to this issue via OnlyDust platform.
I am a blockchain developer with experience with solidity and cairo
Define the function signature with the required parameters and return types.
cairo
fn end_event_registration(ref self: TContractState, event_id: u256);
Step 2: Check Caller Permission
Verify that only the event owner can call the function by comparing the caller's address with the event owner's address.
cairo
assert self.get_event_owner(event_id) == self.get_caller(), "Only event owner can call this function";
Step 3: Update Event Details
Retrieve the event details, set is_closed
to TRUE
, and update the event details.
cairo
let event_details = self.get_event_details(event_id);
event_details.is_closed = TRUE;
self.set_event_details(event_id, event_details);
Step 4: Emit EndEventRegistration Event
Emit the EndEventRegistration
event with the event ID.
cairo
emit EndEventRegistration(event_id);
Step 5: Write Unit Tests
Write unit tests to cover the following scenarios:
EndEventRegistration
event.Example unit test:
cairo
#[test]
fn test_end_event_registration_success() {
// Setup
let contract = TContractState::new();
let event_id = 1;
let owner = 0x1234567890abcdef;
// Set event owner
contract.set_event_owner(event_id, owner);
// Call end_event_registration as owner
contract.end_event_registration(event_id);
// Assert is_closed is TRUE
[21/10, 1:03 pm] Meta AI: Here are 5 steps to solve the "End Event Registration" function:
Step 1: Define the Function Signature
Define the function signature with the required parameters and return types.
cairo
fn end_event_registration(ref self: TContractState, event_id: u256);
Step 2: Check Caller Permission
Verify that only the event owner can call the function by comparing the caller's address with the event owner's address.
cairo
assert self.get_event_owner(event_id) == self.get_caller(), "Only event owner can call this function";
Step 3: Update Event Details
Retrieve the event details, set is_closed
to TRUE
, and update the event details.
cairo
let event_details = self.get_event_details(event_id);
event_details.is_closed = TRUE;
self.set_event_details(event_id, event_details);
Step 4: Emit EndEventRegistration Event
Emit the EndEventRegistration
event with the event ID.
cairo
emit EndEventRegistration(event_id);
Step 5: Write Unit Tests
Write unit tests to cover the following scenarios:
EndEventRegistration
event.Example unit test:
cairo
#[test]
fn test_end_event_registration_success() {
// Setup
let contract = TContractState::new();
let event_id = 1;
let owner = 0x1234567890abcdef;
// Set event owner
contract.set_event_owner(event_id, owner);
// Call end_event_registration as owner
contract.end_event_registration(event_id);
// Assert is_closed is TRUE
assert contract.get_event_details(event_id).is_closed == TRUE;
}
I am applying to this issue via OnlyDust platform.
Member of Dojo Coding. I have contributed before to other Cairo projects like:
Raito
kakarot-ssj
Can I work on this issue?
Check my OnlyDust profile, I've contributed to many projects: Profile
I am applying to this issue via OnlyDust platform.
Hi, I'm data analyst / SC dev. For last half a year i ve been helping CarmineFinance improving their option AMM as well as developing new products, thus i have quite extensive hand on experience with Cairo. I would love to contribute to this issue or tackle something more challenging.
fn end_event_registration
event_owners
or alernatively i can properly implement fn event_owner
and use it)is_closed
to true in event details for given event_id, could be found in storage event_details
map. EndEventRegistration
(event_id and owner are known by now. name can be obtained from event details.)I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
Hi, I'm data analyst / SC dev. For last half a year i ve been helping CarmineFinance improving their option AMM as well as developing new products, thus i have quite extensive hand on experience with Cairo. I would love to contribute to this issue or tackle something more challenging.
How I plan on tackling this issue
- Add body for
fn end_event_registration
- assert if caller is event owner. Owner for given event_id can be obtained from storage map
event_owners
or alernatively i can properly implementfn event_owner
and use it)- update i.e set
is_closed
to true in event details for given event_id, could be found in storageevent_details
map.- emit
EndEventRegistration
(event_id and owner are known by now. name can be obtained from event details.)
- Add 3 unit test.
- in first test we just need to add_event and use end_event_registration with same caller mock. then assert is_close in event details of given event.
- in second test we mock different callers for add_event and end_event_registration. -> then func will panuc due to assert
- the same as first but instead of assert - check if appropriate event is present and check if it contains correct data
ETA - friday morning CET
I am applying to this issue via OnlyDust platform.
I am a full-stack developer with experience in QA testing and languages like Python, Cairo, Solidity, React, and JavaScript.
I will Test for the following Valid event owner: Verify the function sets is_closed to true. Non-event owner: Verify the function panics with the expected error message. Emitted event: Verify the EndEventRegistration event is emitted with the correct event_id.
As an event owner, i should be able end event registration,
Only event owner can call this function
set is_closed inside event details to TRUE and emit EndEventRegistration event
Write unit test for this function that cover the following
Provide an ETH