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

Fix Interface.parseLog Typings #4459

Closed
wants to merge 1 commit into from

Conversation

nlordell
Copy link

@nlordell nlordell commented Nov 7, 2023

Fixes #4029

This PR fixes typings of the parseLog function. Specifically, parseLog doesn't work with the Logs that you receive from various ethers methods (logs in transaction receipts, when doing an eth_getLogs, etc.).

The typing issue is fairly straight forward, the parseLog function expects topics to be a string[], but the Log.topics field is a readonly string[]. This causes some annoying TypeScript compile issues:

import { Interface, Log } from "ethers";

declare let log: Log;
declare let iface: Interface;
iface.parseLog(log)
error TS2345: Argument of type 'Log' is not assignable to parameter of type '{ topics: string[]; data: string; }'.
  Types of property 'topics' are incompatible.
    The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'string[]'.

5 iface.parseLog(log)
                 ~~~

Fortunately, parseLog doesn't need topics to be mutable, so the fix is fairly straight-forward.

@jm42
Copy link

jm42 commented Nov 25, 2023

Have the same issue. Please merge and release.

@ricmoo ricmoo added investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6 next-patch Issues scheduled for the next arch release. labels Nov 25, 2023
@ricmoo
Copy link
Member

ricmoo commented Feb 9, 2024

Merged in v6.11.0.

Thanks! :)

@ricmoo ricmoo closed this Feb 9, 2024
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. next-patch Issues scheduled for the next arch release. labels Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed/complete This Bug is fixed or Enhancement is complete and published. investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with typings
3 participants