Skip to content

App crashes during web3auth initialization if the configured RPC is not responsive #127

@DefiCake

Description

@DefiCake

Steps to reproduce

Initialize web3auth with an EthereumPrivateKeyProvider that points pointing to a non-responding RPC provider.

During: Web3Auth::init -> if(sessionId) { ... await this.privateKeyProvider.setupProvider(finalPrivKey); }

Code sample

import * as WebBrowser from '@toruslabs/react-native-web-browser';
import EncryptedStorage from 'react-native-encrypted-storage';

import Web3Auth, {
  ChainNamespace,
  WEB3AUTH_NETWORK,
} from '@web3auth/react-native-sdk';

import { EthereumPrivateKeyProvider } from '@web3auth/ethereum-provider';

const chainConfig = {
  chainNamespace: ChainNamespace.EIP155,
  chainId: ''whatever',
  rpcTarget: 'an rpc that does not respond or overall crashes',
  // Avoid using public rpcTarget in production.
  // Use services like Infura, Quicknode etc
  displayName: 'Ethereum Sepolia Testnet',
  blockExplorerUrl: 'https://sepolia.etherscan.io',
  ticker: 'ETH',
  tickerName: 'Ethereum',
  decimals: 18,
  logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png',
};

const ethereumPrivateKeyProvider = new EthereumPrivateKeyProvider({
  config: {
    chainConfig,
  },
});

const scheme = 'xyz.piopio.app';
const redirectUrl = `${scheme}://auth`;

export const auth = new Web3Auth(WebBrowser, EncryptedStorage, {
  //   clientId: WEB3AUTH_CLIENT_ID,
  clientId:
    'your id',
  redirectUrl,
  network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET, // or other networks
  privateKeyProvider: ethereumPrivateKeyProvider,
  enableLogging: true,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions