Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Emit event when fund receives a vote #137

Closed
adrianvrj opened this issue Oct 24, 2024 · 15 comments · Fixed by #148
Closed

[feat] Emit event when fund receives a vote #137

adrianvrj opened this issue Oct 24, 2024 · 15 comments · Fixed by #148
Assignees
Labels
ODHack9 ODHack9.0 issue

Comments

@adrianvrj
Copy link
Member

This issue will be part of ODHack9.0, please apply via Onlydust app

  • Emit an event when a fund contract receives a new vote in the receiveVote method.
  • The event should contain: voter(caller address), the fund contract address that receives the vote, current votes.
  • Please read contributors guide before asking for an issue

Acceptance Criteria

  • Code builds successfully.
  • Event struct has all the attributes needed.
@mexes20
Copy link

mexes20 commented Oct 24, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello I want to be assigned to work on this as a first time contributor to the project.

I am a developer with over 4 years of experience.

@adrianvrj adrianvrj removed the good first issue Good for newcomers label Oct 24, 2024
@PoulavBhowmick03
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a Starknet Wolf. I am a software engineer at Invisible Studios, and a blockchain engineer with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet, Ethereum, Stellar ecosystem.

How I plan on tackling this issue

To solve this issue, I will modify the receiveVote method of the Fund contract to emit an event whenever a new vote is received. The event will contain the voter's address (retrieved using get_caller_address()), the fund contract address (retrieved using get_contract_address()), and the current number of upvotes after the vote is cast. I will define an event structure that includes the fields voter, contract_address, and current_votes. After the vote is successfully recorded and the upvote count is updated, I will emit this event. Additionally, I will write tests to ensure that the event is correctly emitted with the appropriate data when a new vote is received.

ETA - 4 hours

@Lukman-01
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello! My name is Lukman, and I am a passionate Smart Contract Developer with two years of experience in writing smart contracts. My hands-on experience spans various blockchain platforms, including Ethereum and Starknet. I’m eager to leverage my skills in developing efficient, secure, and innovative solutions in the blockchain space.

How I plan on tackling this issue

To tackle this issue, I will first analyze the receiveVote method in the fund contract to understand where to integrate the event emission. Next, I will define the event struct to include the voter address, fund contract address, and current vote count. Finally, I will implement the event emission in the receiveVote method, ensuring that the code builds successfully and meets the acceptance criteria.

@anonfedora
Copy link

anonfedora commented Oct 24, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I'm Eleazar and I'll be working on issue #137.

I estimate this will take 4hours max to complete.

How I plan on tackling this issue

This is how I would tackle this issue:

Review the implementation of receiveVote function and Event struct and emit event with attributes as required

Ensure that the needed attributes of the Event struct are in place

Ensure code builds successfully

@evgongora
Copy link
Contributor

evgongora commented Oct 24, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello my name is Erick! I am a systems engineering student with a focus on fullstack web development, currently working on various blockchain-based projects, including those utilizing Cairo and ZK proofs. My experience includes working with Cairo, and contributing to the open-source community through OnlyDust. My familiarity with these tools equips me to understand the nuances of these systems and ensure clean code.

I am part of Dojo Coding, and here is my OnlyDust profile: https://app.onlydust.com/u/evgongora.

How I plan on tackling this issue

To approach this problem, I would follow these steps:
Define a new event struct in the fund.cairo file with the required attributes: voter (ContractAddress), fund contract address (ContractAddress), and current votes (u32).
Modify the receiveVote function in the fund.cairo file to emit this event after successfully recording a vote.
Update the unit tests in test_fund.cairo to verify that the event is emitted correctly.

Here's a more detailed breakdown

Define the event struct:

#[starknet::contract]
mod Fund {

After these lines, I would add something like:
#[event]
#[derive(Drop, starknet::Event)]
struct VoteReceived {
    voter: ContractAddress,
    fund_address: ContractAddress,
    current_votes: u32
}

Modify the receiveVote function:

        fn receiveVote(ref self: ContractState) {
            assert(self.voters.read(get_caller_address()) == 0, 'User already voted!');
            assert(
                self.state.read() == FundStates::RECOLLECTING_VOTES, 'Fund not recollecting votes!'
            );
            self.up_votes.write(self.up_votes.read() + 1);
            self.voters.write(get_caller_address(), self.up_votes.read());
            if self.up_votes.read() >= FundConstants::UP_VOTES_NEEDED {
                self.state.write(FundStates::RECOLLECTING_DONATIONS);
            }
        }

At the end of this function, just before the closing brace, I would add:

self.emit(VoteReceived {
    voter: get_caller_address(),
    fund_address: starknet::get_contract_address(),
    current_votes: self.up_votes.read()
});

And finally update the unit tests as needed.

@Gianfranco99
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have been a developer for over 4 years and have been contributing to the Starknet ecosystem for more than a year. My recent contributions include work on cairo-lint and scaffold-starknet. I’m eager to participate in this project as I see a lot of potential in it and believe it adds valuable functionality to the Starknet ecosystem. Also I'm part of dojo-coding comunity!

How I plan on tackling this issue

I am going to create the event structure with the necessary parameters and when the function has been carried out correctly I am going to emit this event. It is an easy issue to solve

@ShantelPeters
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain developer with vast knowledge in languages as cairo, typescript, javascript, Html, Css , solidity, React etc. My experience with smart contracts will guide me in creating a robust and efficient implementation.

How I plan on tackling this issue

To address the issue of emitting an event when a fund contract receives a new vote in the receiveVote method, I would start by defining an event structure that includes the caller's address (voter), the fund contract address receiving the vote, and the current vote count. In the receiveVote method of the fund contract, I would implement the logic to emit this event each time a new vote is cast. I will ensure the code compiles successfully and that the event struct includes all necessary attributes.

@saimeunt
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have contributed to several Cairo projects on OnlyDust and I've worked on very similar issues in the past such as ArkProjectNFTs/bridge#236

How I plan on tackling this issue

I will carefully add the necessary Starknet event and will make sure to emit it correctly where it is required.

@SoarinSkySagar
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

GM @adrianvrj, I am Sagar Rana, a smart contract developer and full stack engineer. I have 3 years of experience building robust full stack applications and over a year of writing smart contracts. You can see my projects and contributions to some major repos on my GitHub profile. The tech stack I use mainly includes Solidity, Rust, Cairo and Typescript. I am also contributing to the Starknet and Rust ecosystems and building on Cairo and Rust languages. I am interested in contributing to projects like this to learn more about these technologies and help make these projects better. Please assign me as I would be really glad to be a contributor in this project! :)

How I plan on tackling this issue

  • Add the Event enum in fund.cairo with an event called VoteReceived: VoteReceived, and the struct definition of VoteReceived
  • Use self.emit(VoteReceived{}) before the last if statement in the receiveVotefunction to emit the event when the function is called.
  • The Event will contain the fields voter (fetched using get_caller_address), contract_address and current_votes
  • Update the tests for the function to test for the event being emitted and ensure all tests are passing

ETA: 2 Days

@jorgezerpa
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi! Dojo here🙋⛩️⛩️

I have 4 years of experience in full-stack development and a couple months in web3 development with Cairo and Starknet.

How I plan on tackling this issue

I will work into the contracts/src/fund.cairo on the receiveVote function.

Here is how I will implement event emition:

  • Create an Event enum with it correspondant events
    image

  • Then, I will emit the event from the receiveVote function:
    image

I'll be happy to be assigned🤠, I'm attentive⛩️

@0xprivateChaos
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I bring 2 years of hands-on experience in writing and optimizing tests for Solidity smart contracts, which has given me strong foundation in blockchain testing patterns. Recently, I've expanded my expertise into Cairo development, actively writing contracts and their corresponding tests. My combination of established testing experience in Solidity and fresh perspective in Cairo, along with deep theoretical knowledge, positions me well to tackle this testing challenge effectively.

How I plan on tackling this issue

In the receiveVote method, emit an event when a vote is received. The event should include:

  1. The voter's address (get_caller_address()),
  2. The fund contract address (get_contract_address()),
  3. The current number of votes (self.up_votes.read()).

@aniruddhaaps
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a typescript dev. A new-comer here, willing and ready to contribute to contribute to solve the issue.

@BrunoAmbricca
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello guys, I have been working for the past 4 years as a developer with multiple languages such as ts, and for the past 3 months learning and working with cairo on my own projects.

How I plan on tackling this issue

I would look the method that needs to emit an event, follow the contributor guidelines, do the feature and test all it´s cases.

@ryzen-xp
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain developer specializing in Solidity, Cairo, and Rust, and testing contract .

How I plan on tackling this issue

[1]=>Modify the receiveVote method to emit an event when a vote is cast. The event will [2]=>include the caller’s address, the fund contract address, and the current vote count.
[3]=>Define the event struct with the required attributes.
[4]=>Ensure the code builds successfully without errors.
[5]=>Test the event emission to verify it captures the correct data and passes all tests.
I’ll ensure the event emits correctly, contains the right data, and the code remains functional with passing tests.
Please /assign

@onlydustapp onlydustapp bot assigned Gianfranco99 and jorgezerpa and unassigned Gianfranco99 Oct 24, 2024
@jorgezerpa
Copy link
Contributor

🚀🚀

jorgezerpa added a commit to jorgezerpa/gostarkme that referenced this issue Oct 24, 2024
jorgezerpa added a commit to jorgezerpa/gostarkme that referenced this issue Oct 25, 2024
jorgezerpa added a commit to jorgezerpa/gostarkme that referenced this issue Oct 25, 2024
EmmanuelAR added a commit that referenced this issue Oct 25, 2024
…ve-vote

[test] #137 implement newVoteReceived event on Fund contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ODHack9 ODHack9.0 issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.