Skip to content

Comments

feat: assign a UUID to all BaseProvider requests#399

Closed
cryptodev-2s wants to merge 3 commits intomainfrom
cryptodev2s/add-id-to-requests
Closed

feat: assign a UUID to all BaseProvider requests#399
cryptodev-2s wants to merge 3 commits intomainfrom
cryptodev2s/add-id-to-requests

Conversation

@cryptodev-2s
Copy link
Contributor

@cryptodev-2s cryptodev-2s commented Jan 22, 2025

This PR assigns a UUID to all BaseProvider requests.

@cryptodev-2s cryptodev-2s requested a review from a team January 22, 2025 00:01
@cryptodev-2s cryptodev-2s self-assigned this Jan 22, 2025
@cryptodev-2s cryptodev-2s changed the title feat: add an uuid to all BaseProvider requests feat: add a uuid to all BaseProvider requests Jan 22, 2025
@cryptodev-2s cryptodev-2s changed the title feat: add a uuid to all BaseProvider requests feat: define a uuid to all BaseProvider requests Jan 22, 2025
@cryptodev-2s cryptodev-2s changed the title feat: define a uuid to all BaseProvider requests feat: assign a UUID to all BaseProvider requests Jan 22, 2025
@cryptodev-2s cryptodev-2s changed the title feat: assign a UUID to all BaseProvider requests feat: assign a UUID to all BaseProvider requests Jan 22, 2025
@cryptodev-2s cryptodev-2s requested a review from Gudahtt January 22, 2025 00:15
@socket-security
Copy link

socket-security bot commented Jan 22, 2025

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/@types/uuid@9.0.1

View full report↗︎

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that this hasn't caused a problem so far, but seems like a good idea? Curious to know what others think.

const payload =
params === undefined || params === null
? {
id: uuidV4(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we want to do this in _rpcRequest? I see that we already provide a default value for jsonrpc if it's not given so it seems like this check for id may belong there too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More importantly, can we add a test for this?

@cryptodev-2s
Copy link
Contributor Author

The PR was closed because this functionality should be managed by using an rpc middleware in the rpcMiddleware param available in providers, such as createIdRemapMiddleware, here: https://github.com/MetaMask/providers/blob/main/src/StreamProvider.ts#L58.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants