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

state is not defined ReferenceError: state is not defined #2025

Open
1 task done
gpehartz opened this issue Dec 12, 2023 · 0 comments
Open
1 task done

state is not defined ReferenceError: state is not defined #2025

gpehartz opened this issue Dec 12, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@gpehartz
Copy link

Current Behavior

I'm using web3 onboard react in my app. If you configure a chain in web3onboard init and that chain is not in your wallet and you call web3OnBoard.setChain method then web3onboard crashes with the following error message:
state is not defined
ReferenceError: state is not defined

Expected Behavior

Two options:

  1. (Preferred) Add the missing chain in the wallet automatically
  2. Return a specific response from setChain to indicate that the target chain is not in the wallet

Steps To Reproduce

  1. Init web3onboard with two chains
  • {
    "id": "0x61",
    "token": "Binance Chain Native Token",
    "label": "Binance Smart Chain Testnet",
    "rpcUrl": "https://data-seed-prebsc-1-s1.binance.org:8545",
    "icon": "/img/cryptologo/binance.svg",
    "color": "#FFFFFF"
    }

  • {
    "id": "0x13881",
    "token": "MATIC",
    "label": "Mumbai (Matic Testnet)",
    "rpcUrl": "https://rpc-mumbai.maticvigil.com",
    "icon": "/img/cryptologo/polygon.svg",
    "color": "#FFFFFF"
    }

  1. Add these chains to your metamask wallet
  2. Use injectedModule()
  3. Connect to Metamask with web3onboard modal
  4. Try changing chains from web3onboard -> everything is working fine, metamask pops up the confirmation for chain change
  5. Remove Binance testnet chain from metamask
  6. Try changing chains from web3onboard again -> state is not defined error message

What package is effected by this issue?

@web3-onboard/react

Is this a build or a runtime issue?

Runtime

Package Version

2.8.13

Node Version

No response

What browsers are you seeing the problem on?

Chrome

Relevant log output

Uncaught (in promise) ReferenceError: state is not defined
    at instance$3 (index-4c4d8815.js:8546:1)
    at init$1 (index-4c4d8815.js:1843:1)
    at new SwitchChain (index-4c4d8815.js:8554:1)
    at create_if_block_18 (index-4c4d8815.js:8903:1)
    at Object.p (index-4c4d8815.js:10414:1)
    at update (index-4c4d8815.js:1293:1)
    at flush (index-4c4d8815.js:1253:1)

Anything else?

No response

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.
@gpehartz gpehartz added the bug Something isn't working label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants