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

46 add contributors to the concert account #47

Conversation

jucoba
Copy link
Collaborator

@jucoba jucoba commented Dec 17, 2024

Logic to add controbutors to the concert

@jucoba jucoba linked an issue Dec 17, 2024 that may be closed by this pull request
Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
concertx-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 9:34pm

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • anchor/.gitignore: Language not supported
Comments suppressed due to low confidence (3)

anchor/tests/concert-x.ts:79

  • The test should verify that the specific backer's public key is included in the 'contributors' list, not just that the list is non-empty.
expect(updatedConcertAccount.contributors.length).greaterThan(0);

anchor/programs/concert-x/src/lib.rs:32

  • The field 'pda' should be named 'creator' to maintain consistency with the rest of the codebase and to accurately reflect its purpose.
concert.pda = ctx.accounts.initializer.key();

anchor/programs/concert-x/src/lib.rs:139

  • The length of 'short_description' is reduced to 100 characters, which might not be sufficient for a brief description. Consider increasing the length to 200 characters as it was previously.
pub short_description: String,


//Update the current amount
ctx.accounts.concert.current_amount += amount;
ctx.accounts.concert.contributors.push(*ctx.accounts.backer.key);
Copy link
Preview

Copilot AI Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line may cause a 'contributor' to be added multiple times if they contribute more than once. Consider checking if the contributor already exists in the list before adding.

Suggested change
ctx.accounts.concert.contributors.push(*ctx.accounts.backer.key);
if !ctx.accounts.concert.contributors.contains(&ctx.accounts.backer.key()) { ctx.accounts.concert.contributors.push(*ctx.accounts.backer.key()); }

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@loganrudd loganrudd changed the base branch from develop to 28-implement-contribution-logic December 18, 2024 12:53
pub status: u8,
/// Concert contributors
#[max_len(100)]
pub contributors: Vec<Pubkey>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to make this a vec of a map with {Pubkey: contribution amount} key:value pairs? Since the logic currently allows people to donate any amount above the ticket price. We can also change the logic easily so that they can only contribute the price of the ticket and nothing above it. What do you think?

@@ -76,6 +76,7 @@ describe("concert-x", () => {

const updatedConcertAccount = await program.account.concert.fetch(concertXPda);
expect(updatedConcertAccount.currentAmount.toNumber()).to.equal(contributionAmount);
expect(updatedConcertAccount.contributors.length).greaterThan(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could check that contributors Pubkey is in the vec instead? Something like copilot suggests above:
ctx.accounts.concert.contributors.contains(&ctx.accounts.backer.key())

@loganrudd loganrudd merged commit 9091545 into 28-implement-contribution-logic Dec 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add contributors to the concert account
2 participants