wevm / wagmi

React Hooks for Ethereum

Home Page:https://wagmi.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Injected, okxwallet or okexwallet can't connect with OKX wallet

leonace924 opened this issue · comments

Describe the bug

export const okxConnector = injected({target: 'okxWallet'})

using targeted okx wallet, either okxWallet or oKExWallet is not available to connect with the wallet and return ProviderNotFoundError, while using injected({target: 'metamask'}) is ok to connect with my metamask wallet

Link to Minimal Reproducible Example

No response

Steps To Reproduce

No response

Wagmi Version

2.5.19

Viem Version

2.9.13

TypeScript Version

5.2.2

Check existing issues

Anything else?

No response

OKX supports EIP-6963, you can filter the connector by its id.

@glitch-txs , could you give me a advice to implement it correctly?
I used injected, but didn't work

This was what I did

injected({
      target() {
        return {
          id: "okxwallet",
          name: "OKX Wallet",
          provider: () => {
            if (typeof window !== "undefined") return

            const isOkxWallet = (ethereum) => {
              return !!ethereum?.isOkxWallet
            }

            if (isOkxWallet(window.ethereum)) {
              return window.ethereum
            }

            if (window.ethereum?.providers)
              return window.ethereum.providers.find(isOkxWallet) ?? null

            return window["okxwallet"] ?? null
          }
        }
      }
    })