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

[BUG] Cannot read properties of undefined (reading 'request') on transaction execution with wagmi #176

Open
polus-arcticus opened this issue Nov 14, 2024 · 8 comments
Assignees

Comments

@polus-arcticus
Copy link

Describe the Bug

when trying to execute a transaction through the wallet while connected with the wagmi/viem stack we receive an error when metamask does fine

https://github.com/polus-arcticus/flow-wagmi-bug

Expected experience

should execute the transaction, see the hash in the console, than see the receipt henceafter

Steps To Reproduce

git clone https://github.com/polus-arcticus/flow-wagmi-bug
npm install, npm run dev
connect wallet while on 747 chain
try to set the number of the deployed Counter.sol contract
see request errror

Environment

- OS: linux
- Node: 23
- npm: 10.9
@lmcmz
Copy link
Member

lmcmz commented Nov 20, 2024

Thanks for reporting @polus-arcticus , We are working on investigation.

@lmcmz
Copy link
Member

lmcmz commented Nov 21, 2024

Hey @polus-arcticus

Could you try following wagmi config ?

export const config = createConfig({
  chains: [flowMainnet, flowTestnet],
  connectors: [
    injected()
  ],
  transports: {
    [flowMainnet.id]: http(),
    [flowTestnet.id]: http(),
  },
})

@polus-arcticus
Copy link
Author

Hi @lmcmz thanks for taking a look at this

I can try it, however that config is unfortunately not fit to my use case. we see
https://wagmi.sh/core/api/transports/http#http

If no URL is provided, then the transport will fall back to a public RPC URL on the chain. It is highly recommended to provide an authenticated RPC URL to prevent rate-limiting.

For my dapp its absolutely essential to use the rpc url provided by the browser wallet. Last time i checked wagmi prefered using the custom transport with window.ethereum or the https://wagmi.sh/core/api/transports/unstable_connector (which takes the wagmi injected object)

I have found success with both metamask and (with walletConnect as transport) wallet connect.

Admittantly it is a rarer config, but the one that is most decentralized in a sense as it does rely on the public rpc or one provided by a central hosting service of the dapp

@lmcmz
Copy link
Member

lmcmz commented Nov 21, 2024

Yeah, we're still trying to find out the root cause behind the scene.
The above code is just a walk around for it.

@lmcmz
Copy link
Member

lmcmz commented Nov 21, 2024

BTW, our wallet is also using the public getaway URL at the moment.
So it's the same to http() directly.

@tombeckenham
Copy link
Collaborator

When using the latest version of wagmi, you need to add @wagmi/core (2.15 or later) to the package. I noticed that pnpm did not install it as a dependency at all. npm and yarn did install it but it was the wrong version - 2.14. The package-lock.json was referencing 2.14. Adding @wagmi/core as a direct dependency resolves the issue. Also removing package-lock.json and recreating it seems to resolve the issue with npm but you are better off adding the dependency so that pnpm works as well

@polus-arcticus
Copy link
Author

BTW, our wallet is also using the public getaway URL at the moment. So it's the same to http() directly.

Thanks, is there a place to change the default RPC? I didn't look as the alchemy flow rpc for mainnet was also having issues raised https://github.com/polus-arcticus/alchemy-flow-bug and i cant seem to find a networks tab

@tombeckenham thanks for checking, however even when i added @wagmi/core as a deps i still got the same error with 2.15 https://github.com/polus-arcticus/flow-wagmi-bug/blob/default/errors/wagmi-core2.15.png

@Peppermint1020 Peppermint1020 moved this from In Progress to Done in Flow Wallet Nov 22, 2024
@tombeckenham tombeckenham reopened this Nov 22, 2024
@tombeckenham tombeckenham moved this from Done to In Progress in Flow Wallet Nov 22, 2024
@tombeckenham tombeckenham self-assigned this Nov 22, 2024
@tombeckenham
Copy link
Collaborator

I've reopened this ticket @polus-arcticus. I can't repeat the problem at the moment. I'm doing some work right now to upgrade the extension to latest versions of node and later dependency versions. I'm going to look into any changes that might have caused this issue and get back to you.

@lmcmz lmcmz closed this as completed Nov 27, 2024
@lmcmz lmcmz moved this from Todo to Done in Flow Wallet Nov 27, 2024
@lmcmz lmcmz reopened this Nov 27, 2024
@lmcmz lmcmz moved this from Done to Todo in Flow Wallet Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants