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

[Service] Just scaffold the Service module without any params #37

Merged
merged 3 commits into from
Oct 10, 2023

Conversation

Olshansk
Copy link
Member

@Olshansk Olshansk commented Oct 9, 2023

Summary

Ran the following command:

ignite scaffold module service --dep bank

Summary generated by Reviewpad on 10 Oct 23 15:46 UTC

This pull request includes the following changes:

  1. A new file helpers.go has been added in the x/service/simulation directory. It defines a function FindAccount that searches for an account in a given list based on the address. If the account is found, it returns the account and a boolean indicating success. It also includes error handling for invalid addresses.

  2. A new file codec.go has been added in the types package. The file includes import statements for various packages from the Cosmos SDK. It also defines two functions, RegisterCodec and RegisterInterfaces, but they are currently empty. The file also declares two variables, Amino and ModuleCdc, which are instances of the codec package.

  3. A new file genesis_test.go has been added in the x/service directory. It contains a test function TestGenesis that initializes and exports the genesis state of the module. It uses service.InitGenesis and service.ExportGenesis functions to perform the initialization and exporting. The test asserts that the exported genesis state is not nil.

  4. A new file params.go has been added. It includes the package declaration, imports, and two functions: GetParams and SetParams. The GetParams function returns an instance of the Params struct from the types package, while the SetParams function sets the parameters using the paramstore from the types package.

  5. Changes in the file openapi.yml introduce new functionalities related to querying parameters of the module. The changes include the addition of new paths /pocket/service/params and /pocket/supplier/params with GET operations that query the parameters. New definitions for pocket.service.Params and pocket.service.QueryParamsResponse are also added to specify the parameters and response of the module.

  6. A new file query_params.go has been added to the cli package. It contains a command CmdQueryParams that shows the parameters of a module. The command utilizes the Cosmos SDK client and the flag package for command-line flags. It retrieves the parameters using the QueryClient and then prints the response using the clientCtx.

  7. A new module service has been added in the x/service package. It implements the AppModule and AppModuleBasic interfaces required by the Cosmos SDK. The module includes functions for registering the module's codecs, interfaces, gRPC Gateway routes, commands, and services. It also provides functionality for initializing and exporting the module's genesis state, as well as logic for beginning and ending blocks.

  8. A new test file query_params_test.go has been added to the x/service/keeper package. The file includes a test function TestParamsQuery that tests the parameter query functionality. It sets up a test environment, sets the parameters in the keeper, and checks the response against expected values.

  9. The file tx.proto has been added, defining a protocol buffer file with package name pocket.service and a service named Msg in the pocket/x/service/types Go package.

  10. A new file query.proto has been added in the pocket/service directory. The file defines a gRPC service named Query with a single method named Params for querying the parameters of the module. It also includes message types QueryParamsRequest and QueryParamsResponse with relevant fields.

  11. A new file genesis_test.go has been added that contains a test function TestGenesisState_Validate to test the validation of a GenesisState struct. The test cases include a default state and a valid state, but they currently do not contain any test input.

  12. Added a new file errors.go to the x/service/types package, defining a sentinel error called ErrSample with a code of 1100 and a message of "sample error". The error is registered using the sdkerrors.Register function.

  13. Added a new file query.go to the x/service/client/cli package. It contains the implementation of the GetQueryCmd function, which returns the CLI query commands for this module. The function creates a new cobra.Command with specific configurations, adds a subcommand CmdQueryParams, and sets the RunE field to client.ValidateCmd.

  14. A new file msg_server_test.go has been added to the x/service/keeper package. It includes test functions setupMsgServer and TestMsgServer to test the message server functionality. The test functions set up a message server and context using test utilities and assert that they are not nil.

  15. Added a new file expected_keepers.go to the x/service/types package. The file defines two interfaces, AccountKeeper and BankKeeper, used for simulations and retrieving account balances, respectively. These interfaces include methods imported from the types and bank packages.

  16. A new file genesis.go has been added to the x/service package. It defines two functions, InitGenesis and `Export

Issue

Part of #10

Type of change

Select one or more:

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Testing

  • Run all unit tests: make test_all_unit
  • Verify Localnet manually: See the instructions [here](TODO: add link to instructions)

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have performed a self-review of my own code
  • I have commented my code, updated documentation and left TODOs throughout the codebase

@Olshansk Olshansk added the service Anything related to general-purpose RPC service support label Oct 9, 2023
@Olshansk Olshansk added this to the Shannon TestNet milestone Oct 9, 2023
@Olshansk Olshansk self-assigned this Oct 9, 2023
red-0ne
red-0ne previously approved these changes Oct 10, 2023
Copy link
Contributor

@red-0ne red-0ne left a comment

Choose a reason for hiding this comment

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

If we want (could) to start building this without parameters, I'm OK having it merged and start adding types here.

@red-0ne
Copy link
Contributor

red-0ne commented Oct 10, 2023

NIT: In the PR description, there is a typo on the PR description where you used sevice instead of service. It did not affected the code, so nothing to change code wise.

@Olshansk Olshansk requested a review from red-0ne October 10, 2023 19:12
@Olshansk Olshansk merged commit 649e9bd into main Oct 10, 2023
3 checks passed
@Olshansk Olshansk deleted the issues/10/scaffold branch October 10, 2023 20:54
bryanchriswhite added a commit that referenced this pull request Oct 13, 2023
* pokt/main: (25 commits)
  [Gateway] Scaffold the Gateway type (#57)
  [Gateway] Scaffold Gateway module and nothing else
  fix: post-merge imports
  [Session] Adding the Session type (#54)
  [WIP][Session] Adding the Relay type (#53)
  refactor: move `Supplier` protobuf type to `pocket.shared` package (x/shared/types/)
  Reply to final comments and make things compile
  WIP - Adding an alternative session implementation
  Updated comments
  Regenerate openapi.yml
  Updated session.proto
  Added session examples from all the places
  Ran ignite scaffold type session --module session --yes
  [Supplier] Scaffolded the UnstakeSupplier message and nothing else (#50)
  [Supplier] Scaffolded the UnstakeSupplier message and nothing else (#52)
  [Application] Scaffolded the Application type (without CRUD messages) and nothing else (#47)
  [Supplier] Scaffolded the Supplier type (without CRUD messages) and nothing else (#48)
  [Service] Just scaffold the Service module without any params (#37)
  [Supplier] Scaffolded the StakeSupplier message and nothing else (#51)
  [Supplier] Scaffolded the StakeSupplier message and nothing else (#49)
  ...
okdas pushed a commit that referenced this pull request Nov 14, 2024
Ran the following command:

```
ignite scaffold module service --dep bank
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service Anything related to general-purpose RPC service support
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants