Closed Mostafatalaat770 closed 1 year ago
@Mostafatalaat770 👋 can you add the code you are using to create and sign the message?
I've used the useWeb3Modal
hook in another component and it works well. Sometimes it breaks when i change code while running the app, i'll check whats happening there
The signing itself is not the problem, I guess due to the inconsistency of the connection, it throws the error failed to decrypt
, I managed to bypass it by clearing the storage(AsyncStorage) of the app which is not practical of course.
Apparently, due to improper disconnection, the saved state by Walletconnect is corrupted. and when that happens, trust wallet takes more time before showing the connection modal, and when it redirects to the app, it takes so long before it gets connected or it doesn't even connect and throws multiple unhandled promises, and failed to decrypt
is the star of the errors
@Mostafatalaat770 Can you provide steps to reproduce it? I still cannot get the failed to decrypt
error.
And also, can you try reproducing the error disabling fast-refresh
feature? Or in a production build
Having same issue
@StevenBarnett1 @Mostafatalaat770 the disconnect error is probably related with the provider's events unsubscription, can you check if removing this works?
@ignaciosantise Removing this:
made it work perfectly
Didn't work for me, I commented out that entire return block, reset npm cache, same issue
@StevenBarnett1
try to delete the asyncstorage, AsyncStorage.clear()
, but it will delete all data related to the app so be careful
Nope same problem, I ran AsyncStorage.clear() from app root index, commented it out, restarted app, same problem
INFO {"context": "core"} {"context": "core/history"} Emitting history_created
INFO {"context": "core"} {"context": "core/history"} Emitting history_created
INFO {"context": "client"} Unsupported request method wc_pairingDelete
INFO {"context": "core"} {"context": "core/relayer"} {"context": "core/relayer/subscription"} Emitting subscription_deleted
INFO {"context": "core"} {"context": "core/expirer"} Emitting expirer_deleted
WARN Possible Unhandled Promise Rejection (id: 0):
Error: Failed to decrypt
WARN Possible Unhandled Promise Rejection (id: 1):
Error: Failed to decrypt
Transactions are going through but they just hang at signer.sendTransaction(tx) so I can't actually get any data / use anything
@StevenBarnett1 let me check
@StevenBarnett1 check this branch feat/more-methods
, in MethodUtil.ts i added a transaction example. Maybe you can find a solution comparing it with your code. If you are using ethers.Web3Provider
, you have to initialize it after the session is created
Yes that's what I am doing,
const { provider,isConnected } = useWeb3Modal();
useEffect(()=>{
if(provider && isConnected){
const _web3Provider = new ethers.providers.Web3Provider(provider)
setWeb3Provider(_web3Provider)
}
},[provider,isConnected])
async function sendTransaction(){
const formattedAmount = ethers.utils.parseUnits('0.01', 18).toHexString();
const nativeTransfer = {
to:"0x87ee2c49c08039c316F6bdef1Cb27dC61866c92c",
value: formattedAmount,
data: "0x",
};
const signer = web3Provider.getSigner();
const txResponse = await signer.sendTransaction(nativeTransfer)
}
@ignaciosantise So apparently, the cleanup function of the useEffect
is the problem, as when I try to access the provider or use the useWeb3Modal
from other components that are not in the same tree aka conditional rendering from the entry point of the app, so maybe we need a provider(context) wrapping the app for proper access to the provider if needed.
Or, whoever wants to have full access to the walletconnect state is to put the Web3Modal
component at the root of the app, which won't be removed by any chance/event. Tested by me and works nicely.
@ignaciosantise I used this to test: https://github.com/WalletConnect/web3modal-react-native/blob/388090a82e99b3e4cfe6a7b149c1e10ab2fc228a/example/src/utils/MethodUtil.ts#L41-L48
it still causes the failed to decrypt
error, but I found something interesting when opened the wallet provider app this happens:
I added a log when it enters onSessionDelete
in useConfigure
hook, and as you see the sessions are not in sync or something is not right. the first one is from the event and the second is from the clientCtrl
.
and it shows to sign the message normally, but on accepting, it throws the failed to decrypt
error, so most probably it's a wallet connect issue than a modal issue, what do you think?
So any fix here?
Same error for me: Works fine on Rainbow but does not decode the return of a signature ('personal_sign') on TrustWallet.
Could you provide an example repo so i can reproduce the failed to decrypt
error? @StevenBarnett1 @boulinb
Hi @ignaciosantise
Here is the full POC with data on the versions used, let me know if you are missing information to reproduce!
Knowing that a new problem appeared since my last message (I didn't change anything to the code) but the wallets are not displayed anymore and an infinite loader is displayed 👀
thanks @boulinb for the example repo!
I was able to reproduce the error, and i also noticed now it's failing in this sdk example too. The good thing is that the same message works with Alpha Wallet and Rainbow.
I'll talk with the team and come back with more answers, but in the meantime please use Alpha/Rainbow for testing 🙏
@ignaciosantise thanks for confirming!
Let us close this issue and open another one related to the failed to decrypt
issue, as the disconnection error is fixed!
Connecting with the modal works perfectly, although when trying to disconnect the user's session using
provider.disconnect()
, it throws an errorError: Please call connect() before enable()
.How can I disconnect the user in that case? if I try to sign a message, it will open the wallet provider (eg: trust wallet) and prompt the user to sign the message, but then on retrieval, it throws
Error: Failed to decrypt
For more context, this happens only if the provider is accessed using the
useWeb3Modal
hook from another component rather than the one which initiated the connection.Observation: the disconnect function may work, but
isConnected
is still true. I guess the disconnection works but theisConnected
is the problem, and it throwsfailed to decrypt
due to a buggy connection state between the wallet connect and the wallet provider.