Skip to content

BREAKING: Split AssetsDetectionController - #619

Merged
adonesky1 merged 8 commits into
mainfrom
split-assets-detection-controller
Nov 2, 2021
Merged

adonesky1 merged 8 commits into
mainfrom
split-assets-detection-controller

Conversation

@adonesky1

@adonesky1 adonesky1 commented Oct 27, 2021 •

Copy link
Copy Markdown
Contributor

Split AssetsDetectionController into TokenDetectionController and CollectibleDetectionController

This splits the AssetsDetectionController into a TokenDetectionController and CollectibleDetectionController in the same way we split AssetController into TokensController and CollectiblesController without any functional changes to the API exposed by the original controller.

The immediate purpose of this PR is to enable integration of collectibles detection into the extension (part 1 found here) without introducing duplicate token detection functionality (the extension has its own TokenDetectionController atm)
However a fast follow should be to make the TokenDetectionController shared code (merge the two controllers adding any missing functionality from either into the merged version).

  • BREAKING:
    • Consumers of the AssetsDetectionController will have to now import both TokenDetectionController and CollectibleDetectionController and split up the calling of any methods accordingly (e.g. AssetDetectionController.detectAssets() => TokenDetectionController.detectTokens() and CollectibleDetectionController.detectCollectibles()).

@adonesky1
adonesky1 requested a review from a team as a code owner October 27, 2021 16:25
@adonesky1
adonesky1 force-pushed the split-assets-detection-controller branch 2 times, most recently from 88b0985 to e0df4b0 Compare October 27, 2021 17:11
@adonesky1 adonesky1 changed the title Split AssetsDetectionController BREAKING: Split AssetsDetectionController Oct 27, 2021

@gantunesr gantunesr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! This will have some conflicts with #615 and/or #616, I can help you dealing with those and also integrating it to the mobile code.

@gantunesr gantunesr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left a non-blocker comment to have in mind

Comment thread src/assets/TokenDetectionController.ts Outdated
Comment on lines 166 to 171

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For a future development, this method could be moved to a utils file

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.

Should this.disabled be factored in to the mainnet check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It could be refactored outside the method, something like !(isMainnet()) || this.disabled

@gantunesr gantunesr Oct 29, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and isMainnet could be simplified to

const isMainnet = (network: string): boolean => networkType === MAINNET;

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.

Sure! I copied this over from what existed on AssetsDetectionController but happy to make this change.

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.

addressed here: 5bc8053

@adonesky1
adonesky1 requested a review from danjm October 28, 2021 15:48
@adonesky1
adonesky1 force-pushed the split-assets-detection-controller branch 2 times, most recently from 59fa76b to 05864f9 Compare October 28, 2021 18:44
@adonesky1
adonesky1 requested a review from gantunesr October 28, 2021 18:46
@adonesky1
adonesky1 force-pushed the split-assets-detection-controller branch from 05864f9 to b7bceca Compare October 28, 2021 22:04
@adonesky1
adonesky1 requested a review from ryanml October 29, 2021 15:22
@adonesky1
adonesky1 force-pushed the split-assets-detection-controller branch from 5bc8053 to 7d9aff8 Compare October 29, 2021 15:34
@adonesky1
adonesky1 force-pushed the split-assets-detection-controller branch from 7d9aff8 to 4170508 Compare October 29, 2021 15:50
@adonesky1

Copy link
Copy Markdown
Contributor Author

@gantunesr @ryanml feedback addressed and rebased on Gustavo's recently merged changes.

@adonesky1

Copy link
Copy Markdown
Contributor Author

@Gudahtt if you have some bandwidth too.

@ryanml ryanml left a comment

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.

looks good from my end

sliceOfTokensToDetect[1] = tokensToDetect.slice(
1000,
tokensToDetect.length - 1,
);

@NiranjanaBinoy NiranjanaBinoy Nov 1, 2021 •

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.

[NIT]: Can we update this to the following code? This is the pattern we use in the extension detect-token.

    const sliceOfTokensToDetect = [
      tokensToDetect.slice(0, 1000),
      tokensToDetect.slice(1000, tokensToDetect.length - 1),
    ];

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.

This is a tiny semantic change and we can make the change in a followup PR to clean up code. We also will want to do an audit of difference between the extension token-detection controller and this one so we can handle that when we switch the extension to use of the controllers repo version.

@gantunesr gantunesr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@adonesky1
adonesky1 merged commit 244207b into main Nov 2, 2021
@adonesky1
adonesky1 deleted the split-assets-detection-controller branch November 2, 2021 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants