MetaMask / snaps

Extend the functionality of MetaMask using Snaps
https://metamask.io/snaps/
Other
711 stars 546 forks source link

MetaMask Flask: RPC Error with wallet_requestSnaps Method in Snap Connection #2536

Open Nick-1979 opened 5 days ago

Nick-1979 commented 5 days ago

I'm using the following code to connect to a published snap:

const connectSnap = async (origin: string): Promise<RequestSnapsResult> => {
  const { version } = SNAPS[origin];

  return await window.ethereum.request({
    method: 'wallet_requestSnaps',
    params: {
      [origin]: {
        version
      }
    }
  });
};

The code works fine on MetaMask, but it fails on Flask with the following error: inpage.js:1 MetaMask - RPC Error: Expected caveat to have a value property of a non-empty object of snap IDs.: At path: value.type -- Expected the value to satisfy a union of intersection | string, but received: "type". {code: -32602, message: 'Expected caveat to have a value property of a non-…of intersection | string, but received: "type".'}

I would appreciate it if you could help me resolve this issue.

FrederikBolding commented 5 days ago

Hmm, it seems like you might have landed in a bad state somehow.

Any idea how to reproduce this?

What Snap ID are you trying to install? Seems like the extension thinks that your input is just type.

What version of MetaMask is this?