Skip to content

Commit

Permalink
Added remove last ticket to state manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aii23 committed Jul 25, 2024
1 parent dcc243e commit 844704d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "l1-lottery-contracts",
"version": "0.7.10",
"version": "0.7.11",
"description": "",
"author": "",
"license": "Apache-2.0",
Expand Down
16 changes: 16 additions & 0 deletions src/StateManager/PStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ export class PStateManager extends BaseStateManager {
return [roundWitness, ticketRoundWitness, bankWitness, bankValue];
}

async removeLastTicket(round: number) {
const ticket = this.roundTickets[round].pop()!;
this.lastTicketInRound[round]--;
const bankValue = this.bankMap.get(Field.from(round));
this.roundTicketMap[round].set(
Field.from(this.lastTicketInRound[round] - 1),
Field(0)
);
this.ticketMap.set(Field.from(round), this.roundTicketMap[round].getRoot());

this.bankMap.set(
Field.from(round),
bankValue.sub(TICKET_PRICE.mul(ticket.amount).value)
);
}

async reduceTickets(): Promise<TicketReduceProof> {
const initialState = this.contract.lastProcessedState.get();

Expand Down

0 comments on commit 844704d

Please sign in to comment.