Error on wallet_requestSnaps
Looks like there is an issue with the wallet_requestSnaps method (possibly with the format of the example)
From @Montoya
It’s this one: https://docs.metamask.io/wallet/reference/wallet_requestsnaps/ If you click Send Request you get an error, I think because the parameters are formatted wrong
Here is what it looks like in the current docs as by-position:
if I just add by-name, we get this:
which isn't correct.
in JSON-RPC you should really be able to swap between by-params and by-name, but the way that the method for wallet_requestSnaps is built now it does not conform to the by-name spec for JSON-RPC
by-name: params MUST be an Object, with member names that match the Server expected parameter names. The absence of expected names MAY result in an error being generated. The names MUST match exactly, including case, to the method's expected parameters.
Source: https://www.jsonrpc.org/specification#parameter_structures
Currently each "npm:@metamask/example-snap" is in the place of the parameter name.
My recommendation here is that the implementation for wallet_requestSnaps should be by-params:
await window.ethereum.request({
"method": "wallet_requestSnaps",
"params": [
{
"npm:@metamask/example-snap": {},
"npm:fooSnap": {
"version": "^1.0.2"
}
}
]
});
This also lines up with the rest of our wallet API (except for the mistake that was wallet_watchAsset that got out with by-name).
we removed the snap methods in this PR because they are dynamic by-name, which isnt supported, the downstream tools needs some work to allow that to happen. maybe an x- extension like x-dynamic-by-name: true.