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

Filter not work using ethers.providers.Web3Provider(web3Provider) #5473

Open
edyth933 opened this issue Dec 7, 2024 · 1 comment
Open

Filter not work using ethers.providers.Web3Provider(web3Provider) #5473

edyth933 opened this issue Dec 7, 2024 · 1 comment

Comments

@edyth933
Copy link

edyth933 commented Dec 7, 2024

Describe the bug
This filter has no impact on the Remix VM (Cancun) environment although it can function properly if it is in the Injected Provider environment.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy a sol file containing event TextMessage(address indexed, string); via Remix IDE
  2. Emits the event more than twice with different addresses
  3. Run this typescript in Remix IDE:
import { ethers } from 'ethers' // the version is v^5

const test = async () => {
    const req = ethers.utils.solidityPack(['address'], [contractAddr])
    const provider = ethers.providers.Web3Provider(web3Provider)
    const signer = provider.getSigner()
    const contract = new ethers.Contract(contractAddr, contractABI, provider)
    const filter = contract.filters.Recovered(await signer.getAddress())
    const logs = await contract.queryFilter(filter)
    console.log(logs.length)
}

const contractABI = ['event TextMessage(address indexed, string)']

test()
  1. See the console
  2. The length of the array in the output is more than one

Expected behavior
Array length should be one.

Desktop (please complete the following information):

  • OS: Windows
  • Browser chrome
@yann300
Copy link
Contributor

yann300 commented Dec 16, 2024

Thanks for the report,
Unfortunately, I am not able to reproduce this issue. In both case (VM and injected/sepolia) I have right values.
The script I am using is:

import { ethers } from 'ethers' // the version is v^5

const test = async (contractAddr) => {
    const provider = new ethers.providers.Web3Provider(web3Provider)
    const signer = provider.getSigner()
    const contract = new ethers.Contract(contractAddr, contractABI, provider)
    const filter = contract.filters.TextMessage(await signer.getAddress())

    const logs = await contract.queryFilter(filter)
    console.log(logs.length)
}

const contractABI = ['event TextMessage(address indexed, string)']

test("0x27b07C05B74c45C8EBfc970aeF6B32180065e801").then(() => {
    test("0xF2404a336381b2138b8D573e7F6b80445cc5F024")
})

The event is emitted with emit TextMessage(msg.sender, "test");

Am I testing it right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants