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: Added Proposal Canceled Event Handler #15

Merged
merged 2 commits into from
Feb 23, 2024
Merged

Conversation

jyotirmoydotdev
Copy link
Contributor

ProposalCanceled Event

In the latest update of Chamber, a new event called ProposalCanceled has been introduced. This event emits a uint256 representing the Proposal ID of the canceled proposal. To facilitate tracking of this event and storing its data in the graph, the handleProposalCanceled function has been added to the chamber.ts file. Additionally, all necessary changes have been implemented to ensure seamless integration.

export function handleProposalCanceled(event: ProposalCanceledEvent): void {
  const id = createId(event.transaction.hash, event.logIndex);
  const proposalCanceledTx = new ProposalCanceled(id);
  proposalCanceledTx.proposalId = event.params.proposalId;
  proposalCanceledTx.contractAddress = changetype<Bytes>(event.transaction.to);

  proposalCanceledTx.blockNumber = event.block.number;
  proposalCanceledTx.blockTimestamp = event.block.timestamp;
  proposalCanceledTx.transactionHash = event.transaction.hash;

  proposalCanceledTx.save();
}

Testing Done

The changes were thoroughly tested to ensure functionality and reliability. Manual testing involved verifying the new handleProposalCanceled function behaviour, including its ability to track ProposalCanceled events and store corresponding data.

describe("Test ProposalCanceled", () => {
  const createMockProposalCanceledEvent = (proposalId: i32 = 1): ProposalCanceled => {
    const event = createProposalCanceledEvent(proposalId);
    return event;
  };
  test("Handel ProposalCanceled Tx", () => {
    const event = createMockProposalCanceledEvent();
    handleProposalCanceled(event);
    expectProposalCanceledAdded(event);
  });
});

@jyotirmoydotdev jyotirmoydotdev self-assigned this Feb 23, 2024
@xhad xhad merged commit 65b99a4 into main Feb 23, 2024
2 of 3 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.

2 participants