i can't figured out why when i call a method with provider, walletconnect keeps redirecting me in https://link.trustwallet.com instead of open me the app to approve the transaction. I've wrote the code for metamask and walletconnect and i used ethersjs to handle the provider.
Here's code for connection
const getBlockchain = (typew) =>
new Promise(async (resolve) => {
var provider;
if(typew == "metamask"){
/* @ts-ignore */
if(window.ethereum) {
/* @ts-ignore */
await window.ethereum.enable();
/* @ts-ignore */
provider = new ethers.providers.Web3Provider(window.ethereum);
}
}
if(typew == "walletconnect"){
providerEth = new WalletConnectProvider({
chainId: 56,
rpc: {
56: "https://bsc-dataseed.binance.org",
}
});
await providerEth.enable();
provider = new ethers.providers.Web3Provider(providerEth);
provider.off("disconnect");
provider.on("disconnect", () => {
closeBlockhain();
})
}
if(provider !== undefined){
const signer = provider.getSigner();
/* @ts-ignore */
const signerAddress:any = await signer.getAddress();
const contract = new Contract(
Contract.networks[56].address,
Contract.abi,
signer
);
const contract_two = new Contract(
Contract_two.networks[56].address,
Contract_two.abi,
signer
);
configConnections = {
connected: true,
provider,
contract,
contract_two,
signerAddress: signerAddress
}
resolve(configConnections);
}
resolve(configConnections);
});
Here's the code for method
let test = await configConnections.contract.awardItem(ethers.utils.formatBytes32String("1"),res.data.hash);
Can't explain to myself why if i open the app on mobile and try to call method, the browser redirects me on other page not on the TrustWallet or Metamask App.
Thank you.