apibara / starknet-react

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

bug: address & connector from useAccount are undefined #466

Closed irisdv closed 2 weeks ago

irisdv commented 1 month ago

When I test our connection button with v3 of starknet-react, the value of account from useAccount is defined correctly, isConnected is true, but address is undefined and connector is undefined.

Here is how I connect :

import { InjectedConnector } from "starknetkit/injected";
import { Connector } from "@starknet-react/core";

 const connectors = [
    new InjectedConnector({ options: { id: "argentX" } }),
    new InjectedConnector({ options: { id: "braavos" } }),
  ];
 <StarknetConfig
              chains={chains}
              provider={providers}
              connectors={connectors as Connector[]}
              autoConnect
            ></StarknetConfig>
import { Connector, useConnect } from "@starknet-react/core";

const { connectAsync } = useConnect();
const connectWallet = async (connector: Connector) => {
    await connectAsync({ connector });
}

I'm testing with

"@starknet-react/chains": "^3.0.0-beta.1",
"@starknet-react/core": "^3.0.0-beta.1",
"starknetkit": "^2.2.15",
"starknet": "^6.11.0",
fracek commented 1 month ago

Thank you for the report! I will check what's going on and fix it.

jrmncos commented 1 month ago

hey @fracek if you like I can take it too

fracek commented 1 month ago

Hey @jrmncos if you are able to reproduce and can open a PR with a fix I'm happy to review it. Notice this is with the code in the develop branch.

kseikyo commented 3 weeks ago

Is someone working on it? I'm currently debugging this issue, might send a patch PR later if I figure what's going on.

Edit: I looked around and from my testings when calling useAccount it seems to always go to here, where it's not connected to any connector. connAccount is a WalletAccount instance, but the address is an empty string (which is set in the constructor) when comparing with connectedAccount.address.

fracek commented 2 weeks ago

I couldn't reproduce the issue. If you can and can submit a fix I'll be happy to review it!

kseikyo commented 2 weeks ago

I couldn't reproduce the issue. If you can and can submit a fix I'll be happy to review it!

I got the issue in my work project and this sandbox here for reference. I'm still investigating the issue, but so far I understand that the address is set when connected, but then reverts back to an empty string, while the connector is always undefined.

Tested with the following wallet versions: Argent X: v5.17.8 Braavos: v3.69.2

Chromium Engine Version 127.0.6533.100

fracek commented 2 weeks ago

I couldn't reproduce the issue. If you can and can submit a fix I'll be happy to review it!

I got the issue in my work project and this sandbox here for reference. I'm still investigating the issue, but so far I understand that the address is set when connected, but then reverts back to an empty string, while the connector is always undefined.

Tested with the following wallet versions: Argent X: v5.17.8 Braavos: v3.69.2

Chromium Engine Version 127.0.6533.100

That's super helpful thank you!

NGUYENDANGVU-coder commented 2 weeks ago

I'm currently debugging this issue. Can anyone help me?

NGUYENDANGVU-coder commented 2 weeks ago

hey @fracek can you help me?

jaipaljadeja commented 2 weeks ago

Hey @irisdv @kseikyo , this issue has been fixed in the latest beta release. Please update the starknet-react and starknet packages to the latest versions. Here's the updated sandbox if it helps.

Also thank you @NGUYENDANGVU-coder and @jrmncos for offering to help with this issue. it's already been resolved now, so no further action is needed. : )