Obscure ways how to select certain types
See original GitHub issueHi, (and again, thanks for this library! It’s awesome).
This is a more of a suggestion than a bug. The generated files currently export 2 things per contract - the factory and the contract instance type. However, it’s a bit harder to do the following:
- Parse logs of a contract without instantiating a contract instance. With ethers you can just do this:
const contractInterface = new ethers.utils.Interface(Contract.abi);
const parsedLog = contractInterface.parseLog(log);
I would like to do the same with TypeChain - however, this is not possible as of now.
- I want to get some of the generated types. E.g. the events. For now I have to “rape” the TS with following:
type ClientRequestCreatedEvent = ReturnType<InstanceType<typeof Contract>['filters']['ClientRequestCreated']>
// or to mock the available functions
type MockedContractFunctions = { [key in keyof InstanceType<typeof Contract>['functions']]: jest.Mock };
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Select specific cells or ranges - Microsoft Support
Press F5 or CTRL+G to launch the Go To dialog. In the Go to list, click the name of the cell or range...
Read more >Striking a Balance Between Native and Custom Select Elements
Here's the plan! We're going to build a styled select element. Not just the outside, but the inside too. Total styling control.
Read more >How to make selections in Illustrator - Adobe Support
To select all objects of a certain kind, deselect all artwork, click Select > Object, and then choose an object type (Brush Strokes,...
Read more >CSS selectors - Learn web development | MDN
Next, we'll take a closer look at type, class, and ID selectors. ... This group of selectors gives you different ways to select...
Read more >How to Select Multiple Files on a Windows 10 PC at Once
It's easy to select multiple files on a Windows 10 computer from a folder or ... files on a Windows 10 computer at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
actually https://github.com/dethcrypto/TypeChain/releases/tag/%40typechain%2Fethers-v5%407.1.0 implements the third point. The first two are not really needed.
Actually, I was a bit mistaken with my example in https://github.com/ethereum-ts/TypeChain/issues/376#issue-870686826 and also https://github.com/ethereum-ts/TypeChain/issues/376#issuecomment-829155140. The problem is that the “advanced types” I created don’t give me the
TypedEvent
but ratherTypedEventFilter
- the actualTypedEvent
which I want can bequeryFilter
function on the generated contract.Unfortunately, because
TypedEventFilter
is not exported and there is no way to extract the generic arguments without the original interface I was forced to modify the generated code and export this interface fromindex.ts
file.So for completeness:
I then use it in other parts of codebase like this:
What I propose is to export the interface of generated code. This includes:
commons.d.ts
AirnodeRrpInterface
in my case), such that one can type the following code:parseAirnodeRrpLog
works?