apibara / starknet-react

A collection of React providers and hooks for StarkNet
https://starknet-react.com
MIT License
364 stars 141 forks source link

useEstimateFees returns "Invalid Params, missing non-optional param: simulation_flags" #455

Closed TudorEsan closed 2 months ago

TudorEsan commented 3 months ago

If I try to get the estimated fee I get this rpc error. Additionaly the useEstimateFees hook does not give a ts error that I need to fill other required parameters

rpc error:

{
    "jsonrpc": "2.0",
    "id": 0,
    "error": {
        "code": -32602,
        "message": "Invalid Params",
        "data": "missing non-optional param: simulation_flags"
    }
}
  const calls = useMemo(() => {
    if (!address || !contract) return [];
    const nominatedAmount = nominateNumber(
      formValues.amount,
      formValues.token.decimals
    );

    return contract.populateTransaction.transfer(
      formValues.toAddress,
      cairo.uint256(nominatedAmount)
    );
  }, [contract, address]);

  const { data: fee, isLoading: isFeeLoading } = useEstimateFees({
    calls,
    watch: true,
  });
WhizIkem commented 3 months ago

Hi there,

I've done some research on the useEstimateFees hook and encountered information regarding missing parameters, specifically simulation_flags. It seems this might be causing the issue. I'm interested in contributing to resolving this problem. Could you provide more details or confirm if this parameter needs to be included?

Looking forward to collaborating on this!

Best, WhiZ

Benjtalkshow commented 3 months ago

Hello @TudorEsan,

I am an experienced JavaScript developer, and after my research on this issue, I can assure you that I can take it:

My Analysis

The error message suggests that the simulation_flags parameter, which is non-optional, is missing from the request. This parameter is likely required by the RPC endpoint but is not being included in the useEstimateFees call.

My Proposed Solution

Thank you, and I am looking forward to getting assigned to this task.

fracek commented 2 months ago

What RPC version are you using? It could be you're using an RPC version (0.7) that's newer than what's supported by starknet react v2 (RPC 0.6).

TudorEsan commented 2 months ago

yes im using the latest blast version prob its 0.7. thanks for answering i ll mark it as closed!