-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ pub mod concert_x { | |
concert.ticket_price = ticket_price; | ||
concert.start_date = start_date; | ||
concert.end_date = end_date; | ||
concert.status = 0; | ||
concert.status = 0; | ||
Ok(()) | ||
} | ||
|
||
|
@@ -72,6 +72,7 @@ pub mod concert_x { | |
|
||
//Update the current amount | ||
ctx.accounts.concert.current_amount += amount; | ||
ctx.accounts.concert.contributors.push(*ctx.accounts.backer.key); | ||
|
||
Ok(()) | ||
} | ||
|
@@ -146,7 +147,10 @@ pub struct Concert { | |
/// Unix timestamps when the campaign ends | ||
pub end_date: i64, | ||
/// 0 = active, 1 = completed, 2 = cancelled | ||
pub status: u8, | ||
pub status: u8, | ||
/// Concert contributors | ||
#[max_len(100)] | ||
pub contributors: Vec<Pubkey>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
} | ||
|
||
/// Size of the account discriminator | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: |
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
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.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.