Skip to content

Commit 4d55a86

Browse files
committed
feat(data): feat(data) add semaphore event listeners
fix name listener of GroupAdminUpdated event re #326
1 parent 86a07d7 commit 4d55a86

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/data/src/ethers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ export default class SemaphoreEthers {
414414
* Listens to the GroupAdminUpdated event.
415415
* @param callback Called with the old admin and new admin addresses.
416416
*/
417-
onGroupAdmin(callback: (oldAdmin: string, newAdmin: string, event: any) => void): void {
417+
onGroupAdminUpdated(callback: (oldAdmin: string, newAdmin: string, event: any) => void): void {
418418
this._contract.on("GroupAdminUpdated", (oldAdmin, newAdmin, event) => {
419419
callback(oldAdmin.toString(), newAdmin.toString(), event)
420420
})
421421
}
422422

423-
offGroupAdmin(): void {
423+
offGroupAdminUpdated(): void {
424424
this._contract.removeAllListeners("GroupAdminUpdated")
425425
}
426426
}

packages/data/tests/ethers.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,11 @@ describe("SemaphoreEthers", () => {
374374
expect(mockRemove).toHaveBeenCalledWith("ProofValidated")
375375
})
376376

377-
it("onGroupAdmin should call callback with groupId, oldAdmin, newAdmin and event", () => {
377+
it("onGroupAdminUpdated should call callback with groupId, oldAdmin, newAdmin and event", () => {
378378
const semaphore = new SemaphoreEthers("sepolia", { address: "0x0000" })
379379
const cb = jest.fn()
380380

381-
semaphore.onGroupAdmin(cb)
381+
semaphore.onGroupAdminUpdated(cb)
382382
const handler = mockOn.mock.calls.find(([e]) => e === "GroupAdminUpdated")![1]
383383
const fakeEvent = { txHash: "0xbeef" }
384384

@@ -387,9 +387,9 @@ describe("SemaphoreEthers", () => {
387387
expect(cb).toHaveBeenCalledWith("0xOLD", "0xNEW", fakeEvent)
388388
})
389389

390-
it("offGroupAdmin should remove all GroupAdminUpdated listeners", () => {
390+
it("offGroupAdminUpdated should remove all GroupAdminUpdated listeners", () => {
391391
const semaphore = new SemaphoreEthers("sepolia", { address: "0x0000" })
392-
semaphore.offGroupAdmin()
392+
semaphore.offGroupAdminUpdated()
393393
expect(mockRemove).toHaveBeenCalledWith("GroupAdminUpdated")
394394
})
395395
})

0 commit comments

Comments
 (0)