-
-
Notifications
You must be signed in to change notification settings - Fork 936
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
[bug] WalletConnect Transaction promises not returning #116
Comments
@critesjosh any chance you can create a basic CodeSandbox to help with debugging? You can fork this template to get started. |
What does your ether.js |
Here are the connectors and the root component. const connectors = [
new InjectedConnector({ chains: [Celo, Alfajores, Localhost] }),
new WalletConnectConnector({
chains: [Celo, Alfajores, Localhost],
options: {
qrcode: true,
rpc: {
// There is a bug where on the first connection the provider URL defaults to network id 1 (ETH mainnet).
// Set the RPC endpoint of your default network of choice as the #1
// 1: "https://alfajores-forno.celo-testnet.org",
44787: "https://alfajores-forno.celo-testnet.org",
42220: "https://forno.celo.org",
},
},
}),
];
function MyApp({ Component, pageProps }) {
return (
<>
<Head>
<title>Celo DApp Starter</title>
<meta name="description" content="Celo DApp Starter" />
</Head>
<Provider connectors={connectors}>
<Component {...pageProps} />
</Provider>
</>
);
} |
I've been trying to update the codesandbox, but the site won't save my changes. 🤷 |
You might need to fork it or sign in. |
ok i got it. you can view the example here: https://codesandbox.io/s/staging-tree-kotvr?file=/src/index.tsx try connecting to the dapp using WalletConnect with a wallet that is not connected to mainnet. the app will log the http connection of the and if you refresh the page, it should update to the correct endpoint. |
Thanks! Will check out the CodeSandbox when I have a moment. In the meantime, I would try updating the import { getNetwork } from '@ethersproject/providers'
import { providers } from 'ethers'
const infuraId = 'Your Infura API Key'
const chains = [Celo, Alfajores]
type ConnectorsConfig = { chainId?: number };
const connectors = (_config: ConnectorsConfig) => {
const network = getNetwork(chainId ?? defaultChain.id)
const infuraRpcUrl = providers.InfuraProvider.getUrl(network, infuraId).url
return [
new InjectedConnector({ chains }),
new WalletConnectConnector({
chains,
options: {
infuraId,
qrcode: true,
rpc: {
[`${network.chainId}`]: infuraRpcUrl,
},
},
}),
]
} |
Unfortunately Infura doesn't support Celo yet. |
Oh that was just a convenience method to get the RPC URL. You can swap that with this: const rpcMap = {
44787: "https://alfajores-forno.celo-testnet.org",
42220: "https://forno.celo.org",
}
const connectors = (_config: ConnectorsConfig) => {
const rpcUrl = rpcMap[chainId]
return [
new InjectedConnector({ chains }),
new WalletConnectConnector({
chains,
options: {
qrcode: true,
rpc: {
[`${chainId}`]: rpcUrl,
},
},
}),
]
} |
just tried the updates you suggested, still no luck https://codesandbox.io/s/staging-tree-kotvr?file=/src/index.tsx:432-433 |
Perhaps this is a bug with the Update: When I log the |
Just curious why web3-provider works for me as expected. |
currently I stumbled upon this problem. Can confirm that somehow The next problem is when I send the transaction using the following code: const vaultContract = new ethers.Contract(metadata.vaultAddress, VaultABI, signer);
const result = await vaultContract.mint(address, { value: ethers.utils.parseUnits(mintState.amount ? mintState.amount.toString() : "0", metadata.collateralDecimals) }); Request to confirm the tx is appear on the wallet. I tried to use I tried to create and sign tx manually but error due to signer.sign is not supported:
@critesjosh Would u mind to share ur solution using |
I was testing another web3-provider with another repo. it doesn't actually fix the problem sorry. I pulled I think it may be a problem with ethers wrapping the |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done This issue now has a funding of 250.0 cUSD (249.76 USD @ $1.0/cUSD) attached to it.
|
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work has been started. These users each claimed they can complete the work by 264 years, 9 months from now. 1) maxx6262 has been approved to start work. I think with use of try/catch block (and debug with full verbose run) we would find that makes this issue making no return from your promise. I believe this has to do with the poor support for promises in the Web3 library itself and not WalletConnect for the sending of transactions. I implemented this at my work for our Wallet and ran into a similar issue. My action plan would be to try out the event subscriptions to see if that works as that's the recommended way in my experience. I have a decent amount of experience integrating WalletConnect as I did it for my company. I should be able to debug it for you.
Learn more on the Gitcoin Issue Details page. |
@critesjosh what wallet are you using? Standard Celo? |
The Valora wallets (celo mobile wallets) for android, testnet and mainnet. |
@critesjosh I tried to connect both with Valora (mainnet) and testnet app (on alfalojes) but it souds also app can't match QR code... |
That's right, I'm now also connected . Thank you ;) |
Did anyone find anything more than @critesjosh ? I stayed tonight on This issue but the lonely one way to use promise is when I use others web3 library I already used. Now all sign transactions are ok, I'm trying to make the more log I'm able and to switch any piece at each step to get point when issue would appear.... |
Does anyone get an error due to bad privider we can't use for Celo ? |
I'm going to make clean repo to submit you @critesjosh . |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work for 250.0 cUSD (248.6 USD @ $0.99/cUSD) has been submitted by: @ericnakagawa please take a look at the submitted work:
|
@critesjosh I know, but you didn't get Promise return when calling 'store' function isn't ? |
You have to define Hook before rendering function 👍 |
I though it would be something related with walletconnect. I switched to other networks(like matic or rinkeby) and providers also didn't get updated. good to see @maxx6262 solved this. |
This doesn't solve the original issue, it uses a different hook. You are correct in that I am using the |
i'll try to check the walletconnect side since it seems it's not getting sovled yet |
Might be worth taking a look at this issue in the It looks like it could be the same or a similar issue, and I was able to successfully use the workaround posted at the bottom of OP's post, although it only worked when executing a transaction right after connecting -- hard refreshing after connecting and executing a transaction did not work. |
Sorry, I connect with Wallet Connect on Alfajores |
@maxx6262 I am not getting any response in the console when sending the update transaction from your codesandbox. I am using the Valora Alfajores testnet wallet for Android connected via WalletConnect. There is another issue, which is described above. The first time I log in to your app using wallet connect, I get an error when trying to send a transaction. Here is the error: If I refresh the UI, it works as expected. This just happens when the connection is first established. |
Thanks @critesjosh ... unbelievable that I get returns and no other one... That's why I keeped this one because it sounds having different comportment from my device and yours... (Did you also use Avast wich currently throw security alarm and disallowed me to reach any part of walletconnect as from siasky.net
I'm now on this one getting back on first way : decompose wagmi write components and walletConnect Connector into all web3 steps from web3 and web3.eth (to try as I saw in official documentation when this bug appeared at version 1.3.0). |
I attached Log file : I see on this that the bug about first connection souds due to "Infura" provider being first loaded before next rendering call. @critesjosh : When Connection is OK, you'll see that I get Promises return into console as requested, do you still have no returns from your device ? |
I just find how I succesfully get these returns within 3 steps to reproduce :
I'm searching what would be unreachable datas that get dapp on second connection, but I don't see at the moment why WalletConnect has this bug... As you'll see above, it sounds as valora get connection out... Record_2022-02-11-20-37-18.mp4 |
i'm currently testing on this dapp with traceable call requests. |
@maxx6262 ya,
|
Yes it first try to reach transaction request via Infura, despite I maked manually provider without it. For the second issue, WalletConnect sounds unable to sync as UI being refreshed (new wctoken ?). In same time, connector doesn't reach disconnection from wallet app.... |
I tried to make new Provider from WalletConnectProvider to overrice current one to see if it could fix it... I'm now seeing to set good Signer to see if it would help, and then in case it would not fix it, I think I'll reach into Connector builders... |
As a workaround, I have set the const connectors = ({ chainId }: { chainId?: number | undefined }) => {
return [
new WalletConnectConnector({
chains,
options: {
qrcode: true,
chainId: networkId,
rpc: {
[networkId]: alchemyApiUrl,
},
},
}),
]
} As seen in the WalletConnect source code (https://github.com/WalletConnect/walletconnect-monorepo/blob/ad1670bff2186b6e0a1456fd3704c560edf11125/packages/ethereum-provider/src/index.ts#L88), if chainId is not provided, the default one is used in the constructor (Mainnet). Although it should update to the selected network, somehow it does not do that. |
In fact I think due to Hook process, it needs first rendering without our settings before WalletConnect uses chainId as requested, that sounds why we've to make refresh and reconnect wallet to get this fully operational as attended... |
the workaround does work if we add the chainId in the EthereumProvider. it seems EthereumProvider does try to update when network connected or signer_events gets updated. I'm checking isCompatibleChainId method. EthereumProvider would first check whether isCompatibleChainId and then update the chainid. it could be the cause. |
anyone find a solution to this? I agree with @maxx6262 that I think it's a hooks issue. On first mount for me (on mainnet), trying the useSigner hook doesn't return a promise properly. When I disconnect and reconnect my wallet, however, it works fine |
having a similar issue trying to listen an event "SignMsg" from contract, I need to reload after connect the wallet to be able to listen events, seems is looking on the wrong network. |
Check out the upcoming version of wagmi |
@tmm I did the migration to the new version and sadly wasn't fixed. I will explain in case we are talking about different problems. If I just reload the page the signer now is rinkeby (the right one) This is how my connectors is setup: const infuraId = process.env.NEXT_PUBLIC_INFURA_ID
const chains = defaultChains
const defaultChain = chain.mainnet
const connectors = ({ chainId }) => {
const chain = chains.find((x) => x.id === chainId) ?? defaultChain
const rpcUrl = chain.rpcUrls.infura
? `${chain.rpcUrls.infura}/${infuraId}`
: typeof chain.rpcUrls.default === 'string'
? chain.rpcUrls.default
: chain.rpcUrls.default[0]
return [
new InjectedConnector({
chains,
options: { shimDisconnect: true },
}),
new WalletConnectConnector({
options: {
qrcode: true,
rpc: {
[chain.id]: rpcUrl,
},
},
}),
new CoinbaseWalletConnector({
options: {
appName: 'My wagmi app',
chainId: chain.id,
jsonRpcUrl: rpcUrl,
},
}),
]
}
export default connectors; So seems the network by default is set to mainnet, then it change to the right one but doesn't change chainId on the connectors as the new WalletConnectConnector was already setup with Any ideas? Thanks in advance. |
Got it. Thanks for the info. Don't be sad, the next version isn't out yet! Will look into this more. Possible that there's a WalletConnect issue somewhere in the stack here, signer/connector is getting stale in wagmi, etc. (Would check out this one too since you are using gnosis. Just something to be aware of.) |
Maybe on connect need to update the hooks data?
https://docs.walletconnect.com/quick-start/dapps/client Just guessing but maybe something like
in https://github.com/tmm/wagmi/blob/main/packages/core/src/connectors/walletConnect.ts#L34 |
Got it to work with chainId: chain.id in case somebody find it useful but still using env variable to force rinkeby import { chain, defaultChains } from 'wagmi'
import { InjectedConnector } from 'wagmi/connectors/injected'
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect'
import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet'
const infuraId = process.env.NEXT_PUBLIC_INFURA_ID
const env = process.env.NODE_ENV
const chains = defaultChains
const defaultChain = env === "development" ? chain.rinkeby : chain.mainnet
const connectors = ({ chainId }) => {
const chain = chains.find((x) => x.id === chainId) ?? defaultChain
const rpcUrl = chain.rpcUrls.infura
? `${chain.rpcUrls.infura}/${infuraId}`
: typeof chain.rpcUrls.default === 'string'
? chain.rpcUrls.default
: chain.rpcUrls.default[0]
return [
new InjectedConnector({
chains,
options: { shimDisconnect: true },
}),
new WalletConnectConnector({
options: {
qrcode: true,
chainId: chain.id,
rpc: {
[chain.id]: rpcUrl,
},
},
}),
new CoinbaseWalletConnector({
options: {
appName: 'My wagmi app',
chainId: chain.id,
jsonRpcUrl: rpcUrl,
},
}),
]
}
export default connectors; |
Closing as this is for an older version of wagmi. If this issue persists in current versions (now 0.4.x), please file a new issue. |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion. |
Is there an existing issue for this?
Package Version
0.2.1
Current Behavior
I am using the package in my next.js application.
When I send transactions to a wallet connected with WalletConnect, the transaction promise never returns.
In the following code snippet, the transaction is picked up by the wallet and will successfully send, but the notifications aren't displayed and the receipt isn't logged.
I tried this with multiple wallets (Metamask and Valora) and neither of them work. Metamask works as expected.
Expected Behavior
I expect the transaction promise to resolve when it is sent by the wallet.
Steps To Reproduce
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: