-
Notifications
You must be signed in to change notification settings - Fork 133
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
Provide TypeScript type definitions #122
Comments
@bruce-plutusds is there a chance we could see your port of this library to TypeScript? |
I tried running TypeScript to generate type declarations from our current JavaScript files, but it's triggering a compiler bug, and it doesn't seem feasible to fix it. So we will have to migrate everything to TypeScript. We can do this in two steps:
Things to watch out for:
|
Are there any plans to tackle this soon? 😁 |
@nventuro Sorry we don't have the time to tackle this right now, but would welcome and review any PRs. 🙂 |
Big fan of this library. I started a PR to add type definitions: #141. |
Hey! Any news on this one? |
No news, sorry. |
+1. Haven't had much time to continue this. Happy to pass the torch to someone else if they want to run with it. |
Hope that base configuration can be integrated, then other people can convert partially |
I think I can spare the bandwidth to finish this off, provided the scope is set in advance. OS dev is frustrating, and so is submitting PR's that immediately fall by the way because they don't check box (X) :-) |
Are there any plans on tackling this? Anybody doing the port? Thanks! |
I also ran into this trying to test events so I added: // types/openzeppelin-test-helpers.d.ts
declare module '@openzeppelin/test-helpers' {
import { ContractReceipt } from 'ethers'
export function expectEvent(receipt: ContractReceipt, eventName: string, eventArgs: Record<string, any>): void
} which gets picked up by default via import { expectEvent } from '@openzeppelin/test-helpers' in my But strangely it was throwing errors that it couldn't find events which were clearly there due to my hand-written test code that validated it. So ultimately I decided to remove the dependency on import { ContractReceipt } from "@ethersproject/contracts";
import { EventFilter } from "@ethersproject/abstract-provider";
import { expect } from "chai";
// Asserts that the logs in receipt contain an event with name eventName and arguments
// that match those specified in eventArgs.
function expectEvent(
receipt: ContractReceipt,
eventName: string,
eventArgs: Record<string, any>
) {
expect(receipt.events).to.not.be.undefined;
const event = receipt.events?.find((e) => e.event === eventName);
expect(event, `Event '${eventName}' not found`).to.not.be.undefined;
for (const [key, value] of Object.entries(eventArgs)) {
expect(event?.args?.[key], `Event argument '${key}' not found`).to.equal(value);
}
}
// Asserts that the logs in receipt contain a single event with name eventName and arguments
// that match those specified in eventArgs.
function expectOneEvent(receipt: ContractReceipt, eventName: string, eventArgs: Record<string, any>) {
expect(receipt.events).to.not.be.undefined
expect(receipt.events?.length, `Expected exactly 1 event`).to.equal(1)
expectEvent(receipt, eventName, eventArgs)
} which readers are welcome to use or adapt to their use case. |
Requested in OpenZeppelin/openzeppelin-test-environment#73 (comment).
Some prior conversation in #116 (comment).
The text was updated successfully, but these errors were encountered: