EveripediaNetwork/wagmi-magic-connector

Keep getting user [UserRejectedRequestError: User rejected request]

chazzaoui opened this issue · 1 comments

Describe the bug
I have setup the wagmi connector with my wagmi and magic link API. Somehow everytime I try to login it throws the error:
[UserRejectedRequestError: User rejected request]

I am kind of confused as to how to setup correctly with wagmi

Package.json:
"dependencies": {
"@ethersproject/shims": "^5.7.0",
"@everipedia/wagmi-magic-connector": "^0.10.1",
"@expo/webpack-config": "^18.0.1",
"@magic-ext/bitcoin": "^8.2.1",
"@magic-ext/connect": "6.2.0",
"@magic-ext/react-native-expo-oauth": "^8.7.0",
"@magic-sdk/react-native-expo": "^14.6.0",
"@magic-sdk/types": "^11.6.0",
"@react-navigation/bottom-tabs": "^6.5.2",
"@react-navigation/native": "^6.1.1",
"@react-navigation/native-stack": "^6.9.7",
"@types/react": "~18.0.27",
"@types/react-native": "~0.70.6",
"assert": "^1.5.0",
"bitcoinjs-lib": "^5.2.0",
"buffer": "^6.0.3",
"ethers": "^5.7.2",
"events": "^1.1.1",
"expo": "^48.0.4",
"expo-barcode-scanner": "~12.3.2",
"expo-crypto": "~12.2.1",
"expo-linking": "~4.0.1",
"expo-splash-screen": "~0.18.1",
"expo-status-bar": "~1.4.4",
"expo-web-browser": "~12.1.1",
"lodash": "^4.17.21",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.3",
"react-native-crypto": "^2.2.0",
"react-native-elements": "^3.4.3",
"react-native-gesture-handler": "~2.9.0",
"react-native-get-random-values": "^1.8.0",
"react-native-randombytes": "^3.6.1",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-vector-icons": "^9.2.0",
"react-native-web": "~0.18.10",
"react-native-webview": "11.26.0",
"readable-stream": "^4.3.0",
"stream-browserify": "^1.0.0",
"typescript": "^4.6.3",
"vm-browserify": "^0.0.4",
"wagmi": "^0.12.3",
"web3": "^1.8.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"rn-nodeify": "^10.3.0"
},

Expected behavior
Magiclink modal to pop-up so I can login using email
Screenshots
Screenshot 2023-03-21 at 17 41 09
Screenshot 2023-03-21 at 17 45 04

Code loginscreen
const [email, onChangeEmail] = React.useState('charafazzaoui@gmail.com');
const [recoveryEmail, onChangerecoveryEmail] = React.useState();
const [phoneNumber, onChangePhoneNumber] = React.useState('+18888888888');
const { disconnectAsync } = useDisconnect();
const { isConnected } = useAccount();

const { connectAsync } = useConnect({
connector: new MagicAuthConnector({
options: {
apiKey: API_KEY[ENV.PROD]
}
}) as unknown as Connector
});

/**

  • regular sign in

  • */
    const login = async () => {
    if (isConnected) {
    await disconnectAsync();
    }
    try {
    const { account } = await connectAsync();

    console.log(account);
    } catch (error) {
    console.log(error);
    }
    };

Code App.tsx
import 'react-native-get-random-values';
import './shim'; // Required for Bitcoin Blockchain interaction
import '@ethersproject/shims';
import { StatusBar } from 'expo-status-bar';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { useState } from 'react';
import useColorScheme from './hooks/useColorScheme';
import Navigation from './navigation';
import { API_KEY, ENV } from './config/env';

import { WagmiConfig, createClient, configureChains } from 'wagmi';
import { publicProvider } from 'wagmi/providers/public';
import { mainnet, polygon, polygonMumbai } from 'wagmi/chains';
import { MagicAuthConnector } from '@everipedia/wagmi-magic-connector';

export default function App() {
// const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();

const [env, setEnv] = useState(ENV.PROD);
const { chains, provider, webSocketProvider } = configureChains(
[mainnet, polygon, polygonMumbai],
[publicProvider()]
);

const client = createClient({
autoConnect: true,
provider,
webSocketProvider
});
//ignore this any here, pls dont judge me
const magicProps = {
setEnv,
env
};

return (






);
}

Hi ! did you give required permissions on magic dashboard ? also i believe the error message is inappropriate too. will create a pr for producing better errors