Open LogeswaranA opened 1 year ago
What DApp service is causing the problem? Please provide URL information.
We are trying to integrate "React-Native" application with Dcent Wallet.
Using this package -> https://www.npmjs.com/package/@walletconnect/react-native-dapp
We are able sto succesfully connect with "Metamask" & access XDC Network.
But unable to connect with "D'Cent" wallet. It is not showing "Connect" page consistently!. One time, it is showing, then automatically, getting disconnected.
Hi Team - Any update on this issue?
I am also facing the same issue
import React, { useEffect, useState } from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View, Button } from 'react-native';
// import { // withWalletConnect, // useWalletConnect, // } from "@walletconnect/react-native-dapp"; import AsyncStorage from "@react-native-async-storage/async-storage";
import WalletConnectProvider from '@walletconnect/web3-provider'; import { useWalletConnect, withWalletConnect } from '@walletconnect/react-native-dapp'; import { ethers } from 'ethers'; const abi = require("./abi.json"); const contractaddress = "0x05d2259Eb45309De47C267638721Cd91e7470680"; const App = () => { const connector = useWalletConnect(); // valid const [connected, setconnected] = useState(false)
useEffect(() => { onProvider(); }, [connected])
const sendTx = async (contract, functionname, input) => { console.log("sendTx Sending tx to set", input); const tx = await contractfunctionname; const txresponse = await tx.wait(); const blkno = txresponse.blockNumber ? txresponse.blockNumber : 0; const txnevnts = txresponse.events ? txresponse.events : ""; let obj = { txHash: txresponse.transactionHash, blockNumber: blkno, event: txnevnts } console.log("sendTx,Responses", obj); return obj; }
const onProvider = async () => { console.log("connector.connected", connector.connected) if (connector.connected) { const provider = new WalletConnectProvider({ bridge: "https://bridge.walletconnect.org/", rpc: { 1: "https://rpc.ankr.com/eth", 3: "https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161" }, infuraId: "8043bb2cf99347b1bfadfb233c5325c0", connector: connector, connected: true, qrcode: false, }); await provider.enable(); console.log("connector", connector) const ethers_provider = new ethers.providers.Web3Provider(provider); const signer = await ethers_provider.getSigner(); console.log("signer", signer) const userNetwork = await ethers_provider.getNetwork(); console.log("userNetwork", userNetwork)
console.log("addresss", await signer.getAddress())
console.log("accounts22", signer.provider.provider.accounts[0]) const balance = await ethers_provider.getBalance(signer.provider.provider.accounts[0]); console.log("balance", balance) const instance = new ethers.Contract(contractaddress, abi, ethers_provider); console.log("INtsance is", instance); const c = ethers.utils.parseUnits("1", 'ether') const b = await sendTx(instance'connect', "load", [c]) console.log("B", b) // const account = await signer.getAccounts(); } } const onConnect = async () => { await connector.connect() console.log("data", connector.uri) console.log("data", connector)
setconnected(true) }
const onDisConnect = () => { connector.killSession() setconnected(false) }
if (!connector.connected) { return <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> <Button title="Connect" onPress={() => onConnect()} />
} return <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> <Button title="Kill Session" onPress={() => onDisConnect()} /> Connected Wallet:{connector.accounts[0]} };
const styles = StyleSheet.create({ sectionContainer: { marginTop: 32, paddingHorizontal: 24, }, sectionTitle: { fontSize: 24, fontWeight: '600', }, sectionDescription: { marginTop: 8, fontSize: 18, fontWeight: '400', }, highlight: { fontWeight: '700', }, });
// export default App; export default withWalletConnect(App, { clientMeta: { description: "Connect with WalletConnect", }, redirectUrl: Platform.OS === "web" ? window.location.origin : "plugin://", storageOptions: { asyncStorage: AsyncStorage, }, });
Above code working fine in metamask but its not working in dcent wallet
While integrating the "wallet connect" with Mobile APplication, we were able to successfully load D'cent wallet. But it is frequently gettind disconnected.
After we do "Discovery clear Cache", it is getting connected again.
Do we have any workaround for Mobile App Integration with "D'cent" to access XDC network.
Thanks