MetaMask / MetaMask/metamask-extension

Add log points to the signature controller for logging signature requests in the logging controller

Open
#19,396 0 comments 0 reactions 0 assignees View on GitHub
team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

### Description
With the logging controller initialized in the extension as part of #19394, and the Logging Controller landed as part of #17751 we can add points to the SignatureController that uses the ControllerMessenger to add logs to the LoggingController state. We need to add three types of logs:

#### First, proposed messages
When a new message is proposed we must log it. There are three methods in the SignatureController that manage this, each starting with newUnsigned
1. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L275
2. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L310
3. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L328

each of those methods will essentially make the same call into the logging controller, the details for the logged message must include:
1. The origin of the proposer for the signature
2. The time is automatically recorded by the logging controller and no need to append a timestamp is required at this level.
3. The data of the message
4. The method (eth_sign, eth_signTypedData_v4, etc)

#### Second, Signed messages
When a message is signed it'll be signed through one of three functions depending on the type of method used:
1. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L346
2. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L363
3. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L382

The same details as above, The origin, the data and the method must be included in these log points, here we are using the "signed" event on the logging controller

#### Third, Rejected messages
When a message is canceled / rejected we need to log the rejection. This will happen in one of three function handlers:
1.https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L413
2. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L423
3. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L433

In addition, on these methods:
1. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L457
2. https://github.com/MetaMask/core/blob/main/packages/signature-controller/src/SignatureController.ts#L467
we actually end up rejecting or clearing all the messages from a given messenger type... we should record this rejection as well.
Again the same details as above must be recorded. this is the "rejected" type.

Contributor guide

Open the contributing guide

Research direction

Start in packages/signature-controller/src/SignatureController.ts at the newUnsigned, signing, rejection, and bulk-clear handlers listed in the issue, then inspect the LoggingController interface exposed through ControllerMessenger. Add log points for proposed, signed, and rejected messages, including origin, data, and method; bulk rejection handlers should record their rejected messages as well. Verify that each listed path produces the corresponding log event.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.