Skip to content
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

Automatic connections FAILED on local setup #2529

Open
noahsilencelab opened this issue Jul 2, 2024 · 10 comments
Open

Automatic connections FAILED on local setup #2529

noahsilencelab opened this issue Jul 2, 2024 · 10 comments

Comments

@noahsilencelab
Copy link

noahsilencelab commented Jul 2, 2024

Hi team,

Today, I tried your new feature https://docs.metamask.io/snaps/how-to/allow-automatic-connections/ but immediately got some weird error that I couldn't debug myself. Please shed some light for my debugging. The error is thrown after I send RPC wallet_requestSnaps like below:

    return await provider.request({
      method: 'wallet_requestSnaps',
      params: {
        [SNAP_ID]: snapVersion
          ? {
              version: snapVersion,
            }
          : {},
      } as any,
    });

The error:

Screenshot 2024-07-02 at 20 58 36

Environment:

  • Chrome + Flask MetaMask
  • Node v18.20.2

Metamask dependencies package.json:

    "@metamask/eth-sig-util": "^7.0.1",
    "@metamask/keyring-api": "^1.1.0",
    "@metamask/snaps-sdk": "^5.0.0",
    "@metamask/snaps-types": "^3.1.0",
    "@metamask/snaps-ui": "^3.1.0",
    "@metamask/utils": "^8.5.0",

Snap Manifest:

{
  "version": "1.2.9-alpha.2",
  "description": "Silent Shard creates a distributed self-custody account in MetaMask by generating a Distributed Private key between the browser extension and the Silent Shard mobile app using Multi-Party Computation (MPC). Thereby enabling a seamless 2FA experience for secure transactions.",
  "proposedName": "Silent Shard",
  "repository": {
    "type": "git",
    "url": "https://www.npmjs.com/package/@silencelaboratories/silent-shard-snap-staging"
  },
  "source": {
    "shasum": "kgUGyPyxOt+5t2kbxCOHu4vPY0l+oj0EvWda5vOY8B4=",
    "location": {
      "npm": {
        "filePath": "dist/bundle.js",
        "iconPath": "images/silentShardLogo.svg",
        "packageName": "@silencelaboratories/silent-shard-snap-staging",
        "registry": "https://registry.npmjs.org/"
      }
    }
  },
  "initialConnections": {
    "https://snap-staging.silencelaboratories.com": {},
    "http://localhost:3000": {}
  },
  "initialPermissions": {
    "endowment:keyring": {
      "allowedOrigins": [
        "https://snap-staging.silencelaboratories.com",
        "http://localhost:3000"
      ]
    },
    "snap_dialog": {},
    "snap_notify": {},
    "snap_manageState": {},
    "endowment:network-access": {},
    "endowment:rpc": {
      "allowedOrigins": [
        "https://snap-staging.silencelaboratories.com",
        "http://localhost:3000"
      ]
    },
    "snap_getEntropy": {},
    "snap_manageAccounts": {}
  },
  "manifestVersion": "0.1"
}
@Montoya
Copy link
Collaborator

Montoya commented Jul 2, 2024

Hi, please update your dapp connect code to use a string as the key for the Snap ID instead of an array, like so:

await window.ethereum.request({
  "method": "wallet_requestSnaps",
  "params": [
    {
      `${SNAP_ID}`: {
        "version": `^${snapVersion}`
      }
    }
  ]
});

Please let me know if you still see the error after making this change.

@noahsilencelab
Copy link
Author

noahsilencelab commented Jul 2, 2024

Hi, its not an array but a Computed property names syntax. It's actually a string key.

@Montoya
Copy link
Collaborator

Montoya commented Jul 2, 2024

What is the value of SNAP_ID? Usually this error is the result of an invalid ID.

@noahsilencelab
Copy link
Author

The value of SNAP_ID local:http://localhost:8080

@Montoya
Copy link
Collaborator

Montoya commented Jul 2, 2024

And just to be certain, snapVersion is resolving to a string?

@noahsilencelab
Copy link
Author

snapVersion is an empty string in this case

@Montoya
Copy link
Collaborator

Montoya commented Jul 2, 2024

Hmmm... what happens if you remove it entirely? Just:

return await provider.request({
  method: 'wallet_requestSnaps',
  params: {
    [SNAP_ID]: {},
  } as any,
});

@Montoya
Copy link
Collaborator

Montoya commented Jul 2, 2024

Also, sorry, I'm noticing one other things that may or may not be an issue, we have params for wallet_requestSnaps as an array of objects in our docs, may be just optional but you can try:

return await provider.request({
  method: 'wallet_requestSnaps',
  params: [ {
    [SNAP_ID]: {},
  } ] as Array<any>,
});

@noahsilencelab
Copy link
Author

If I have params as an array, I will face the error '"params" must be an object.'

Screenshot 2024-07-03 at 12 27 08

@noahsilencelab
Copy link
Author

Hmmm... what happens if you remove it entirely? Just:

The same error happened.
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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants