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

Infinite loop while calling estimateContractGas on linea #2849

Open
1 task done
prevostc opened this issue Oct 13, 2024 · 1 comment
Open
1 task done

Infinite loop while calling estimateContractGas on linea #2849

prevostc opened this issue Oct 13, 2024 · 1 comment

Comments

@prevostc
Copy link

Check existing issues

Viem Version

2.21.24

Current Behavior

Calling estimateContractGas on linea chain results in an infinite loop

Expected Behavior

This method is expected to end in a finite amount of time and return the estimated contract gas

Steps To Reproduce

Reproduction code:

import { createPublicClient, http } from 'viem'
import { linea } from 'viem/chains'
import { toAccount } from 'viem/accounts';

const WETHABI = [
  {
    constant: true,
    inputs: [{ name: '', type: 'address' }],
    name: 'balanceOf',
    outputs: [{ name: '', type: 'uint256' }],
    payable: false,
    stateMutability: 'view',
    type: 'function',
  },
  {
    constant: false,
    inputs: [{ name: 'wad', type: 'uint256' }],
    name: 'withdraw',
    outputs: [],
    payable: false,
    stateMutability: 'nonpayable',
    type: 'function',
  },
] as const;

const publicClient = createPublicClient({
  chain: linea,
  transport: http(undefined, {
    onFetchRequest: async request => {
      const content = await request.clone().text();
      console.log({ msg: 'rpc.http: request', data: content });
    },
    onFetchResponse: async response => {
      const content = await response.clone().text();
      console.log({ msg: 'rpc.http: response', data: content });
    },
  })
});

const main = async () => {
  const account = toAccount({
    address: '0x03d9964f4D93a24B58c0Fc3a8Df3474b59Ba8557',
    signMessage: async (message) => {
      throw new Error('signMessage not implemented');
    },
    signTransaction: async (transaction) => {
      throw new Error('signTransaction not implemented');
    },
    signTypedData: async (typedData) => {
      throw new Error('signTypedData not implemented');
    }
  });

  const wnative = "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f";

  const balance = await publicClient.readContract({
    abi: WETHABI,
    address: wnative,
    functionName: 'balanceOf',
    args: [account.address],
  });

  // this call loops for some reason
  const rawGasEstimation = await publicClient.estimateContractGas({
    abi: WETHABI,
    address: wnative,
    functionName: 'withdraw',
    args: [balance],
    account: account,
  });

  console.log(rawGasEstimation);
}

main()

Link to Minimal Reproducible Example

https://stackblitz.com/edit/viem-getting-started-uc1w5e

Anything else?

No response

@mahmudsudo
Copy link

can i take on this ?

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