-
Notifications
You must be signed in to change notification settings - Fork 16
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](snap): Error during credential query, error message unhelpful #632
Comments
Hi @c4bade6fdec3d9cb86a281668cbab42b , thanks for reporting the issue. Before you can use Masca RPC methods, you need to set your current account inside Masca, as switching MetaMask accounts does not change Masca accounts. This can be done like this: // After your code here
console.log('Snap: ' + JSON.stringify(snap));
// Call this
const response = await ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId: snapId,
request: {
method: 'setCurrentAccount',
params: {
currentAccount: address
},
},
},
}); I am not sure if this is the main issue, as I couldn't replicate your error. The error I was getting with your code was: {
"success": false,
"error": "Error: No current account set. Please call the `setCurrentAccount` RPC method first."
} If I understand correctly you are developing your own dapp, right ? So you are probably testing things on localhost. May I ask which version of MetaMask you are using and which browser you are testing it with ? Things to note that could help resolve your issue:
Please report your findings after you try again, and I can try to help you further if the issue persists. |
Hey, my Metamask was indeed version 11.13.1! But, after updating it to 11.14.0 I get a different error: 'Session has expired', so it still doesn't work. However, I tried it using Masca connector instead of using JSON-RPC and that does work. My code for JSON-RPC was the identical to the one in the initial comment, except I updated the code to call the set account function before calling query credentials function. Just a note for the account switching: in your example and your documentation it says the property is The type that gets passed as argument is
So, I guess this may be closed, I'll just use the Masca connector library instead of JSON-RPC, not going to hunt down what's going on (for now at least). Thank you. |
Thanks for pointing out the mistake in the documentation, we will fix 👍. I am also happy we resolved your issue. Regarding the expired session, this is related to Ceramic (I forgot to mention this in my example, sorry). We handle this inside our Masca Connector and without it you would need to handle it through separate JSON RPC calls. It is easier using Masca Connector. If you are interested in the details, this are the steps we do inside the Connector SDK:
Steps 2 to 5 need to be repeated each time the user changes his MetaMask account. May I ask what you are building with Masca ? 🚀 |
Describe the bug
I am trying to query for credentials using JSON-RPC API, here's my code:
And the output of the logs are:
So the snap is enabled and the provider is valid, while trying to fetch the credentials I get '[object Object]' error, which doesn't tell me much.
I've tried using Masca connector as well, same thing happens.
Have I run into a real bug or am I just not doing something correctly? If it's the latter, I apologize.
Versions:
To Reproduce
No response
Expected behavior
No response
The text was updated successfully, but these errors were encountered: