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

Add CLI Foundry Template #854

Open
wants to merge 82 commits into
base: main
Choose a base branch
from

Conversation

timou0911
Copy link

@timou0911 timou0911 commented Sep 9, 2024

Description

Create a CLI foundry template with a sample contract, a deploy script, and tests for it.
The contract itself is the same as in CLI hardhat template.

Related Issue(s)

Closes #185

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run yarn format and yarn lint without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@timou0911 timou0911 requested a review from a team as a code owner September 9, 2024 16:03
@timou0911 timou0911 changed the title New branch Add CLI Foundry Template Sep 9, 2024
Copy link

New branch

Generated at commit: 072b11fc3b6aae2c0f32a5ffa96f6e7a649240d8

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
0
0
4
15
19
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

Copy link
Contributor

@sripwoud sripwoud left a comment

Choose a reason for hiding this comment

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

Thanks @timou0911 that's a great start, I could successfully test executing some of the tasks (make {build,test,coverage,gas-report...}).

I think there is still some work left to do (especially here).
The CLI template should become an npm package that we will publish so it can be selected as template when using the create command of the CLI.
image.

Here is for instance a PR that added a previous template.

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally love Makefile as a task runner.
But I am wondering if it is appropriate for this repo.
This repo is very "node ecosystem" oriented. So we run tasks with yarn.
On one side I agree it may not make much sense to use yarn as a task runner for a template that does not include any js,ts files, making make a good choice.
One the other side, for the sake of consistency maybe we should stick to yarn: meaning all these make tasks belong rather in package.json scripts. And eventually we need a package.json in order to publish the template as an npm package... so...

What do you think @vplasencia @cedoor ?

Copy link
Member

Choose a reason for hiding this comment

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

I agree! As soon as we have 1 non-NPM package only we should make it a NPM package. If there are many other non-NPM packages we can think of a system to download templates that is more language-agnostic.

Copy link
Member

Choose a reason for hiding this comment

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

Good question. Regarding if it's better to use Makefile or yarn, I think it depends on what developers prefer when using Foundry. If most devs prefer to use Makefile, we should provide the Foundry template with Makefile and if they prefer yarn (npm, pnpm) we should provide the Foundry template with yarn. If there are no strong opinions on that we could decide one.

If we have to decide one, I see pros and cons. I think for just contracts, Makefile could be lighter and easier to add but for bigger projects yarn (npm, pnpm) could be better.

I have seen projects using both, so another alternative to discuss could be if it's better to add both.

Copy link
Member

Choose a reason for hiding this comment

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

What about having Makefile as a task runner and a package.json to make it compatible/downloadable with our CLI?

Copy link
Member

Choose a reason for hiding this comment

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

We could also add a package.json to download the template and then remove it after it's downloaded, the same way we create the yarn.lock file but removing a file instead of creating it.

Or if we keep the package.json and add the scripts so that people decide the one they prefer and remove the Makefile or the package.json and yarn.lock files.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I tend to prefer the first option.

@sripwoud ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let's go with the option of keeping the Makefile and removing the package.json after it having been downloaded. (That's was the 1st option right?)

Copy link
Member

Choose a reason for hiding this comment

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

@timou0911 @sripwoud Is this PR ready to be merged?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, I was busy in the past few weeks. I will start handling it next week.

Copy link
Member

Choose a reason for hiding this comment

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

No problem!

@sripwoud sripwoud added the feature 🚀 This is enhancing something existing or creating something new label Sep 10, 2024
@jimmychu0807
Copy link
Contributor

@timou0911 @csiejimmyliu dear Taiwan fellows, may I pick up this PR and continue where it left off?

@timou0911
Copy link
Author

@timou0911 @csiejimmyliu dear Taiwan fellows, may I pick up this PR and continue where it left off?

Sure. I apologize for not being able to complete this issue sooner due to my busy schedule.
The tasks left are:

  1. Make this template an npm package.
  2. Keep the Makefile and remove the package.json after it has been downloaded. (Please refer to the discussion above for details)

@cedoor
Copy link
Member

cedoor commented Nov 22, 2024

Hi @jimmychu0807, be sure to create a branch from this PR, so that we can merge it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 This is enhancing something existing or creating something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create CLI Foundry template
7 participants