aepp-sdk-js icon indicating copy to clipboard operation
aepp-sdk-js copied to clipboard

Issues connecting with snap

Open nikita-fuchs opened this issue 11 months ago • 5 comments

Before holidays, the snap integration demo used to fully work for me: https://docs.aeternity.com/aepp-sdk-js/v14.0.0/examples/browser/aepp/#

Now I get this when clicking 'basic functionality' :


Balance
Error: Address not available
Height
1063523
Node info
{
  "name": "testnet",
  "url": "https://testnet.aeternity.io",
  "nodeNetworkId": "ae_uat",
  "version": "7.1.0",
  "consensusProtocolVersion": 6
}
Compiler version
8.0.0

and as status when I click the 'Install Snap' button:

Status
{
  "blocked": false,
  "enabled": true,
  "id": "npm:@aeternity-snap/plugin",
  "initialPermissions": {
    "endowment:network-access": {},
    "endowment:rpc": {
      "dapps": true,
      "snaps": false
    },
    "snap_dialog": {},
    "snap_getBip32Entropy": [
      {
        "curve": "ed25519",
        "path": [
          "m",
          "44'",
          "457'"
        ]
      }
    ],
    "snap_manageState": {}
  },
  "version": "0.0.9"
}
´´´

It feels like it's missing some sort of permissions now ? Can you reproduce ? 

nikita-fuchs avatar Jan 07 '25 14:01 nikita-fuchs

Here is a tiny repro - I tried using the ethereum connector to connect the page to metamask first, but no result, could be an issue inside stackblitz though, I don't know: https://stackblitz.com/edit/stackblitz-starters-wzjs8jwy?file=src%2Fapp%2Fapp.component.ts,src%2Findex.html (check app.component.ts )

nikita-fuchs avatar Jan 07 '25 16:01 nikita-fuchs

The error you have in stackblitz is "UnsupportedPlatformError: Aeternity snap is not installed to MetaMask". You missed calling await accountFactory.installSnap(); before await accountFactory.initialize(0). I've added this and it looks to be working:

Screenshot 2025-01-15 at 21 57 02

The aepp example still works for me, but it requires extra interactions for debugging purposes. Don't you forget to press "Add account" before switching to "Basic functionality"?

Screenshot 2025-01-15 at 21 53 47

davidyuk avatar Jan 15 '25 20:01 davidyuk

Hey, adding that one line indeed seems to help - but the function naming seems to be misleading then ? installSnap() sounds like it would literally ask me to install the snap or whatever, which is already present in my metamask. what is installSnap exactly doing then ?

Same goes for 'add account' - I get the idea now, it requests permission from metamask to interact with the account i added there.

nikita-fuchs avatar Jan 20 '25 11:01 nikita-fuchs

what is installSnap exactly doing then?

If Snap is not installed, it will ask you to install it; otherwise, it will just return its version.

davidyuk avatar Jan 20 '25 12:01 davidyuk

I am having a problem connecting with MM snap.

When the Superhero wallet is present, new AccountMetamaskFactory() does not return the MetaMask provider. Therefore, the .installSnap() method does nothing, and the app hangs.

I previously reported to the SH wallet team about SH conflicting with MM. They made some changes to resolve the issue, but now Snap is not working. I think they are overriding MM provider.. Is it possible to make sure AccountMetamaskFactory returns MM provider?

Image

yusufseyrek avatar Mar 07 '25 23:03 yusufseyrek