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

Feature/init convert #136

Merged
merged 49 commits into from
May 17, 2023
Merged

Feature/init convert #136

merged 49 commits into from
May 17, 2023

Conversation

codespool
Copy link
Collaborator

@codespool codespool commented Apr 3, 2023

Main feature is introducing a --convert flag to init command. (#111 )
Also handled are #113 and #83 .

Some changes to how init works are introduced:

  • all "tasks" now get pushed into the task queue and only executed after all the options are confirmed
  • config is also gathered in the global configBuilder, and written as the last step

To test:

  • have an existing project cloned to your filesystem (for example dex, or nft from https://github.com/swanky-dapps)
  • run swanky init proj_name --convert path_to_existing_project
  • it will check for Cargo.toml with workspace members and exclude fields
  • it assumes members are contracts, and exclude are extra crates
  • you can also specify manually
  • when done, you still need to manually adjust import paths in the contracts' Cargo.toml

Note: the converted project is not expected to work out-of-the-box when converted, but should require minimum adjustments.

@codespool codespool marked this pull request as ready for review May 8, 2023 09:07
@codespool codespool requested a review from shunsukew May 15, 2023 06:49
packages/cli/src/commands/contract/compile.ts Show resolved Hide resolved
packages/cli/src/commands/contract/new.ts Outdated Show resolved Hide resolved
packages/core/src/lib/tasks.ts Show resolved Hide resolved
packages/core/src/types/index.ts Show resolved Hide resolved
packages/cli/src/commands/init/index.ts Outdated Show resolved Hide resolved
@codespool codespool requested a review from shunsukew May 16, 2023 14:01
Copy link
Contributor

@shunsukew shunsukew left a comment

Choose a reason for hiding this comment

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

What's the distinction between contractName and moduleName?

@@ -1,7 +1,7 @@
import { expect, use } from "chai";
import chaiAsPromised from "chai-as-promised";
import {{contract_name_pascal}}Factory from "./typedContract/constructors/{{contract_name}}";
import {{contract_name_pascal}} from "./typedContract/contracts/{{contract_name}}";
import {{contract_name_pascal}}Factory from "../../typedContracts/{{contract_name}}/constructors/{{contract_name}}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Not only PSP22 template, but also all other ink!&ask! test templates as well, such as flipper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, a mistake on flipper, but ask! I left out on purpose since I'll remove them in next PR.

@codespool
Copy link
Collaborator Author

What's the distinction between contractName and moduleName?

I noticed on imported contracts that directory name (used for contractName) is often different than [package] name = value. (used now for moduleName)
Typechain used that package name value when creating it's directory structure and file names, so bugs were popping up when contactName was used in constructing the paths for artifacts, tests etc.
I believe that was also the cause of some of the bugs reported.

@codespool codespool requested a review from shunsukew May 17, 2023 07:53
@shunsukew
Copy link
Contributor

What's the distinction between contractName and moduleName?

I noticed on imported contracts that directory name (used for contractName) is often different than [package] name = value. (used now for moduleName) Typechain used that package name value when creating it's directory structure and file names, so bugs were popping up when contactName was used in constructing the paths for artifacts, tests etc. I believe that was also the cause of some of the bugs reported.

I see,
And when user name contract with Camel case, compile fails, this should be fixed in future PRs #151

@codespool
Copy link
Collaborator Author

Oh, this is actually a bug in this PR, good catch!
When generated, the moduleName should be snake_case.
I'll fix it right away. (that'll close #151 )

@codespool codespool merged commit 0fde90c into master May 17, 2023
@codespool codespool deleted the feature/init-convert branch May 17, 2023 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment