Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(templates): Make templates and providers generic #226

Merged
merged 16 commits into from
Jul 2, 2024

Conversation

peterwht
Copy link
Contributor

@peterwht peterwht commented Jun 25, 2024

With the introduction of contract generation, with specific types (ERC, Examples, etc), duplicate code was introduced for Template types (such as Provider and ContractTypes and parachain & contract templates).

This PR introduces two traits to simplify template handling:

  • Template -> the types of a TemplateType.
  • TemplateType -> the type, category, or "parent" of a Template

For example:
ERC -> TemplateType has many types ERC20, ERC721
Pop -> TemplateType has many types Assets, Contracts, EVM

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 76.36364% with 39 lines in your changes missing coverage. Please review.

Project coverage is 70.03%. Comparing base (209024b) to head (fbd9f50).

@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
- Coverage   70.07%   70.03%   -0.04%     
==========================================
  Files          44       44              
  Lines        6596     6565      -31     
  Branches     6596     6565      -31     
==========================================
- Hits         4622     4598      -24     
+ Misses       1236     1230       -6     
+ Partials      738      737       -1     
Files Coverage Δ
crates/pop-common/src/errors.rs 0.00% <ø> (ø)
crates/pop-contracts/src/templates.rs 97.67% <100.00%> (+7.07%) ⬆️
crates/pop-contracts/src/utils/helpers.rs 78.72% <100.00%> (ø)
crates/pop-parachains/src/errors.rs 0.00% <ø> (ø)
crates/pop-cli/src/commands/mod.rs 0.00% <0.00%> (ø)
crates/pop-cli/src/commands/new/contract.rs 50.00% <80.00%> (ø)
crates/pop-contracts/src/call.rs 69.84% <0.00%> (ø)
crates/pop-contracts/src/up.rs 63.80% <0.00%> (ø)
crates/pop-parachains/src/new_parachain.rs 81.81% <75.00%> (ø)
crates/pop-parachains/src/templates.rs 97.91% <97.77%> (+6.80%) ⬆️
... and 3 more

... and 2 files with indirect coverage changes

Copy link
Collaborator

@AlexD10S AlexD10S left a comment

Choose a reason for hiding this comment

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

Nicely done.
I'm not completely convinced by the name TemplateType, but it seems the best approach to include both providers for parachains and categories for contracts.

Copy link
Contributor

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Great start, left a number of suggestions for improvement.

crates/pop-cli/src/commands/mod.rs Show resolved Hide resolved
crates/pop-common/src/errors.rs Outdated Show resolved Hide resolved
crates/pop-common/src/templates.rs Outdated Show resolved Hide resolved
crates/pop-common/src/templates.rs Outdated Show resolved Hide resolved
crates/pop-common/src/templates.rs Outdated Show resolved Hide resolved
crates/pop-parachains/src/templates.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/new/contract.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/new/contract.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/new/parachain.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/new/parachain.rs Outdated Show resolved Hide resolved
@peterwht
Copy link
Contributor Author

Comments resolved! Seems much better now :)

Copy link
Collaborator

@brunopgalvao brunopgalvao left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

LGTM!

@AlexD10S AlexD10S merged commit 9644bb4 into main Jul 2, 2024
14 of 15 checks passed
@AlexD10S AlexD10S deleted the peter/refactor-to-generic-templates branch July 2, 2024 12:03
@AlexD10S AlexD10S mentioned this pull request Jul 2, 2024
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.

4 participants