MetaMask / eth-snap-keyring

Snap Keyring bridge
6 stars 2 forks source link

feat: add logger + now log Snap requests #254

Closed ccharly closed 6 months ago

ccharly commented 6 months ago

Description

This uses the same logging mechanism than the extension (using @metamask/utils logging).

You can configure the logger using the DEBUG "env variable" from your .metamaskrc. Every MetaMask logs are prefixed by metamask:.

In our case, the log prefix would be: metamask:eth-snap-keyring.

Screenshots

Screenshot 2024-03-14 at 12 26 04 Screenshot 2024-03-14 at 12 26 18

Manual testing

Add this resolution to your extension's package.json:

...
"resolutions": {
  "@metamask/eth-snap-keyring@^2.2.0": "metamask/eth-snap-keyring#fb923891d9497ad4b207191699e79f364aad74ce",
},
... 

You might need more version resolutions depending on your dependency, you can check them with yarn why @metamask/eth-snap-keyring

Then, run some actions (using the e2e dapp for example) and check logs of your extension (see the screenshots for an example).

Note

For now we do log every Snap requests (and only the requestId in case of failure). I thought that "masking" some properties would be great (using superstruct), however the Snap controller already logs the entire request object, so I guess this is "ok".

You can check that by filtering the logs in your console with metamask:snaps:snaps-controllers