Skip to content

Problem with typings #4029

@TrejGun

Description

@TrejGun

Ethers Version

6.3.0

Search Terms

No response

Describe the Problem

Hey there, it's time for me to migrate from v5 to v6 and I have some problems, can you please help me to solve them?!

1 log types are incompatible

import { Interface, JsonRpcProvider, Log, LogDescription } from "ethers";

const provider = new JsonRpcProvider();
const logs: Log[] = await provider.send("eth_getLogs", [
      {
        address,
        fromBlock,
        toBlock,
        topics,
      },
    ]);

const iface = new Interface(ERC721abi);

 for (const log of logs) {
      const description = 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[]'.

I guess the reason is

parseLog(log: { topics: Array<string>, data: string}): null | LogDescription {

that has to be

parseLog(log: Log): null | LogDescription {

Metadata

Metadata

Assignees

Labels

fixed/completeThis Bug is fixed or Enhancement is complete and published.investigateUnder investigation and may be a bug.minor-bumpPlanned for the next minor version bump.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions