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

Error when using the Arbitrum networks #397

Open
3 tasks done
haowang1013 opened this issue Dec 2, 2022 · 1 comment
Open
3 tasks done

Error when using the Arbitrum networks #397

haowang1013 opened this issue Dec 2, 2022 · 1 comment

Comments

@haowang1013
Copy link

haowang1013 commented Dec 2, 2022

โœ… Prerequisites

  • Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • Are you running the latest SDK version?
  • Are you reporting to the correct repository (magic-sdk)?

๐Ÿ› Description

Had some weird errors when using the Arbitrum networks. Tried with Arbitrum one and Arbitrum goerli, same problem.

๐Ÿงฉ Steps to Reproduce

const magic = new Magic(this.options.apiKey, {
    network: {
        rpcUrl: <arbitrum rpc url from infura>,
        chainId: <arbitrum chain id>,
    },
    extensions: [new ConnectExtension()]
}) 

const provider = new Web3(magic.rpcProvider)
const accounts = await provider.eth.getAccounts()

The same code works with goerli so it must be something with the Arbitrum network.

๐Ÿค” Expected behavior

Magic link should work correctly with Arbitrum since I'm providing the chainId and rpc URL.

๐Ÿ˜ฎ Actual behavior

image

@haowang1013
Copy link
Author

haowang1013 commented Dec 3, 2022

Did some digging and it looks like the error originates from one of the minified scripts used by https://auth.magic.link
It has some hardcoded chain configurations

const k = {
    1: {
        chainId: 1,
        network: "ethereum",
        isMainnet: true,
        networkName: "Ethereum Mainnet",
        name: "Ethereum",
        currency: "ETH",
        onramperCurrency: "ETH",
        tokenCompatibility: "ERC-20",
        blockExplorer: "https://etherscan.io",
        icon: u["r"],
        alchemyApi: c["h"]
    },
    5: {
        chainId: 5,
        network: "goerli",
        isMainnet: false,
        networkName: "Goerli Testnet",
        name: "Ethereum",
        currency: "ETH",
        onramperCurrency: "ETH",
        tokenCompatibility: "ERC-20",
        blockExplorer: "https://goerli.etherscan.io",
        icon: u["r"]
    },
    137: {
        chainId: 137,
        network: "polygon-mainnet",
        isMainnet: true,
        networkName: "Polygon Mainnet",
        name: "Polygon",
        currency: "MATIC",
        onramperCurrency: "MATIC",
        tokenCompatibility: "Polygon",
        blockExplorer: "https://polygonscan.com",
        gasStationUrl: "https://gasstation-mainnet.matic.network/v2",
        icon: u["D"],
        alchemyApi: c["w"]
    },
    80001: {
        chainId: 80001,
        network: "polygon-mumbai",
        isMainnet: false,
        networkName: "Mumbai Testnet",
        name: "Polygon",
        currency: "MATIC",
        onramperCurrency: "MATIC",
        tokenCompatibility: "Polygon",
        blockExplorer: "https://mumbai.polygonscan.com",
        gasStationUrl: "https://gasstation-mumbai.matic.today/v2",
        icon: u["D"]
    },
    420: {
        chainId: 420,
        network: "optimistic-goerli",
        isMainnet: false,
        networkName: "Optimism Goerli Testnet",
        name: "Ethereum",
        currency: "ETH",
        onramperCurrency: "ETH_OPTIMISM",
        tokenCompatibility: "ETH",
        blockExplorer: "https://blockscout.com/optimism/goerli",
        icon: u["r"]
    },
    10: {
        chainId: 10,
        network: "optimistic-mainnet",
        isMainnet: true,
        networkName: "Optimism Mainnet",
        name: "Ethereum",
        currency: "ETH",
        onramperCurrency: "ETH_OPTIMISM",
        tokenCompatibility: "ETH",
        blockExplorer: "https://optimistic.etherscan.io",
        icon: u["r"]
    }
}

All the chains in the list work, and since Arbitrum is not part of it, it errored out.

I think 2 things can be improved:

  1. Make it possible to support more chains - I'm already providing the RPC url and the chain Id and I don't see why not the user can provide the rest information listed above, if they really want to use a chain not in this list.
  2. Until (1) is fixed, throw an error with a clear message saying chain XXX is not supported because XYZ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant