Skip to content

feat: add support for basic vyper project using forge init --vyper#9930

Closed
startup-dreamer wants to merge 2 commits intofoundry-rs:masterfrom
startup-dreamer:feat/add_forge_vyper_init_flag
Closed

feat: add support for basic vyper project using forge init --vyper#9930
startup-dreamer wants to merge 2 commits intofoundry-rs:masterfrom
startup-dreamer:feat/add_forge_vyper_init_flag

Conversation

@startup-dreamer
Copy link
Contributor

@startup-dreamer startup-dreamer commented Feb 21, 2025

Closes: #8340

This PR aims to add forge init --vyper command which instantiate a basic vyper project like this project as suggested here #8340 (comment).

This command mimics forge init --template https://github.com/Patronum-Labs/foundry-vyper currently the standard way of initializing a vyper project.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

Hi @startup-dreamer, thanks for your PR

I would prefer if the Vyper template used local files, see: https://github.com/foundry-rs/foundry/tree/master/crates/forge/assets

We will have to move the Solidity ones in their respective subfolder in the assets directory and create a Vyper equivalent

Thanks!

@startup-dreamer
Copy link
Contributor Author

Makes sense, I'll do the changes.

@startup-dreamer startup-dreamer marked this pull request as draft February 25, 2025 08:28
@zerosnacks
Copy link
Member

Hey @startup-dreamer, if time permits - would be great to get this in! Thanks

@startup-dreamer
Copy link
Contributor Author

Hey @startup-dreamer, if time permits - would be great to get this in! Thanks

I will try to ship this by the end of weekend.

@startup-dreamer startup-dreamer force-pushed the feat/add_forge_vyper_init_flag branch from 5528dc5 to 985132e Compare March 29, 2025 20:07
@startup-dreamer

This comment was marked as outdated.

@startup-dreamer startup-dreamer force-pushed the feat/add_forge_vyper_init_flag branch from 985132e to ec2d2f1 Compare March 30, 2025 15:15
@startup-dreamer startup-dreamer force-pushed the feat/add_forge_vyper_init_flag branch from ec2d2f1 to 5b06b8e Compare March 30, 2025 16:05
@startup-dreamer startup-dreamer marked this pull request as ready for review March 30, 2025 16:18
@zerosnacks
Copy link
Member

Thanks! This is looking great

@jenpaff jenpaff moved this to Ready For Review in Foundry Apr 15, 2025
@startup-dreamer
Copy link
Contributor Author

Hey @zerosnacks! I can continue working on this — I'd also love for this feature to go out ASAP. Just let me know if my approach and semantics look good to you; if not, I’m happy to make changes.

@zerosnacks zerosnacks self-assigned this Jun 5, 2025
Comment on lines +68 to +69
with:
version: nightly
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
with:
version: nightly

We prefer using stable by default

Comment on lines +40 to +64
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: latest
run_install: false

- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT

- name: Restore pnpm cache
uses: actions/cache@v4
id: pnpm-cache
with:
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

- name: Install pnpm project with a clean slate
run: pnpm install --prefer-offline --frozen-lockfile
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: latest
run_install: false
- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache@v4
id: pnpm-cache
with:
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- name: Install pnpm project with a clean slate
run: pnpm install --prefer-offline --frozen-lockfile
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: latest
run_install: false
- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache@v4
id: pnpm-cache
with:
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- name: Install pnpm project with a clean slate
run: pnpm install --prefer-offline --frozen-lockfile

I would prefer keeping this workflow template focused on Vyper + Foundry alone


import {Vm} from "forge-std/Vm.sol";

contract VyperDeployer {
Copy link
Member

Choose a reason for hiding this comment

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

I believe it is possible, per #8181, to deployCode directly like this https://github.com/mpeyfuss/vyper-template/blob/08a0eb515b2f0493d595de3ebf5a048442ea9a0f/script/Counter.s.sol#L10

eliminating the need for VyperDeployer and FFI should also not be required anymore

Comment on lines +177 to +180
// Write the full config with FFI enabled to foundry.toml
if !dest.exists() {
let toml_content = "[profile.default]\nsrc = \"src\"\nout = \"out\"\nlibs = [\"lib\"]\nffi = true\n\n# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options".to_string();
fs::write(dest, toml_content)?;
Copy link
Member

Choose a reason for hiding this comment

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

See above, I don't think we actually need FFI anymore

@zerosnacks
Copy link
Member

Hey @startup-dreamer!

My apologies for my late reply! This got lost in all my notifications

Directionally this is looking good but it includes a few functions / files that are not required anymore

@jenpaff jenpaff mentioned this pull request Jun 4, 2025
7 tasks
@zerosnacks
Copy link
Member

Hi @startup-dreamer, would you be up for making the proposed modifications or would you like me to take this over? Thanks!

@zerosnacks zerosnacks moved this from Ready For Review to In Progress in Foundry Jul 8, 2025
@zerosnacks zerosnacks added this to the v1.4.0 milestone Aug 18, 2025
@zerosnacks zerosnacks removed their assignment Aug 21, 2025
@zerosnacks zerosnacks removed this from the v1.4.0 milestone Aug 21, 2025
@zerosnacks zerosnacks removed this from Foundry Aug 21, 2025
@zerosnacks
Copy link
Member

Closing in favor of #11383

Added you as a co-author

Thanks!

@zerosnacks zerosnacks closed this Aug 21, 2025
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.

feat(forge init): add --vyper flag to initialize a basic Vyper project mirroring Counter

2 participants