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

feat: dependencies option for module create #1287

Merged
merged 41 commits into from
Jul 5, 2021
Merged

Conversation

lumtis
Copy link
Contributor

@lumtis lumtis commented Jun 22, 2021

Add a --dep option for the module create command. This option allows to provide a comma-separated list of module name that will be dependencies of the module to scaffold.

  • The module will contain instances of the dep keepers in its keeper
  • The module will have this additional argument in its contructor
  • A file expected_keepers.go with interfaces will be created as the current standard with Cosmos SDK

The scaffolder will add the keeper instance in app.go with the form app.[DependencyName]Keeper if this value is not present in app.go we will have the same behavior as when there is a missing placeholder in app.go: app.go will be left untouched but the module will still be scaffolded.
The module will then not be registered in app.go but it will be scaffolded with the dependencies in its keeper

Small issue with previously scaffolded app if using gov dependency: #818 (comment)

One way to test:

// Create an app
starport scaffold chain github.com/lubtd/venus
cd venus

// Create a module with an internal list
starport module create haha
starport type foo bar --no-message --module haha

// Create another module that depends on the previous one and add a message
starport module create hehe --dep haha
starport message create-foo bar --module hehe

Then add AppendFoo(ctx sdk.Context, foo types.Foo) uint64 in expected_keepers.go in hehe/keeper
Then add k.hahaKeeper.AppendFoo(ctx, hahamoduletypes.Foo{Bar:msg.Bar}) in the handler of the create-foo message of hehe

Finally, strings can be added from module hehe venusd tx hehe create-foo hello --from alice into the list of the haha module venusd q haha list-foo

@lumtis lumtis linked an issue Jun 22, 2021 that may be closed by this pull request
@lumtis lumtis marked this pull request as ready for review June 22, 2021 17:50
@lumtis lumtis requested a review from Pantani as a code owner June 24, 2021 06:40
fadeev
fadeev previously approved these changes Jun 25, 2021
Copy link
Contributor

@fadeev fadeev left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@ilgooz ilgooz left a comment

Choose a reason for hiding this comment

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

Nice addition! 🍰

starport/cmd/module-create.go Outdated Show resolved Hide resolved
starport/cmd/module-create.go Outdated Show resolved Hide resolved
starport/templates/module/create/stargate.go Outdated Show resolved Hide resolved
Co-authored-by: İlker G. Öztürk <ilkergoktugozturk@gmail.com>
@lumtis lumtis requested a review from fadeev June 29, 2021 13:22
starport/pkg/cosmosanalysis/app/app.go Outdated Show resolved Hide resolved
starport/cmd/module-create.go Outdated Show resolved Hide resolved
starport/cmd/module-create.go Outdated Show resolved Hide resolved
starport/pkg/cosmosanalysis/app/app.go Outdated Show resolved Hide resolved
@lumtis lumtis requested a review from ilgooz July 1, 2021 17:45
ilgooz
ilgooz previously approved these changes Jul 2, 2021
Copy link
Member

@ilgooz ilgooz left a comment

Choose a reason for hiding this comment

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

👍

fadeev
fadeev previously approved these changes Jul 5, 2021
@lumtis lumtis dismissed stale reviews from fadeev and ilgooz via 5e50910 July 5, 2021 07:52
@lumtis lumtis requested review from fadeev and ilgooz July 5, 2021 07:52
@lumtis lumtis merged commit c4782cc into develop Jul 5, 2021
@lumtis lumtis deleted the feat/module-deps branch July 5, 2021 11:51
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
Co-authored-by: İlker G. Öztürk <ilkergoktugozturk@gmail.com>
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.

module create: add option to specify module dependency
4 participants