Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/network-controller/src/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export type ProviderProxy = SwappableProxy<Provider>;

type BlockTracker = any;

type BlockTrackerProxy = SwappableProxy<BlockTracker>;
export type BlockTrackerProxy = SwappableProxy<BlockTracker>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As this is now an exported type, doesn't it warrant constraining BlockTracker to something more specific than any?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Perhaps! But I don't believe that's appropriately scoped to this PR. As you can see directly above this we are doing the same with Provider:

type Provider = any;

export type ProviderProxy = SwappableProxy<Provider>;

Copy link
Copy Markdown
Contributor

@legobeat legobeat Apr 10, 2023

Choose a reason for hiding this comment

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

How does the type of Provider reduce the scope of this PR?

The impacts of the type being any is different for public and private interfaces. A type which is acceptable as any internally may require constraining before being appropriate for exposure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How does the type of Provider reduce the scope of this PR?

On that point I was just noting that we're already exporting the ProviderProxy object with a Provider type parameter that is also typed as any.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently the BlockTracker is set here, where it is a property on the Provider. I believe there is an intention to follow back here and improve typing soon. cc @Gudahtt @mcmire

If we think it makes sense to add the types for both Provider and BlockTracker in this PR I'm open to that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, that's right. We're using any at the moment because web3-provider-engine doesn't provide types at all, and we're about to replace it anyway (see #1116). Once the replacement is complete, then we can just use the correct types from @metamask/eth-json-rpc-provider and eth-block-tracker.


export type NetworkControllerStateChangeEvent = {
type: `NetworkController:stateChange`;
Expand Down
1 change: 1 addition & 0 deletions packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"eth-query": "^2.1.2",
"eth-rpc-errors": "^4.0.0",
"ethereumjs-util": "^7.0.10",
"nonce-tracker": "^1.1.0",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
Loading