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: add rollkit app #88

Merged
merged 7 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/ignite/cli/v28/ignite/services/plugin"
)

var _ plugin.Interface = app{}

type app struct{}

func (app) Manifest(context.Context) (*plugin.Manifest, error) {
Expand Down
2 changes: 2 additions & 0 deletions explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/ignite/apps/explorer/cmd"
)

var _ plugin.Interface = app{}

type app struct{}

func (app) Manifest(context.Context) (*plugin.Manifest, error) {
Expand Down
1 change: 1 addition & 0 deletions go.work.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ use (
./explorer
./hermes
./marketplace
./rollkit
)
2 changes: 2 additions & 0 deletions hermes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/ignite/apps/hermes/cmd"
)

var _ plugin.Interface = app{}

type app struct{}

func (app) Manifest(context.Context) (*plugin.Manifest, error) {
Expand Down
2 changes: 2 additions & 0 deletions marketplace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/ignite/apps/marketplace/cmd"
)

var _ plugin.Interface = app{}

type app struct{}

func (app) Manifest(context.Context) (*plugin.Manifest, error) {
Expand Down
5 changes: 5 additions & 0 deletions rollkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Rollkit App Changelog

## [`v0.1.0`](https://github.com/ignite/apps/releases/tag/rollkit/v0.1.0)

* First release of the Rollkit app compatible with Ignite >= v28.x.y
22 changes: 22 additions & 0 deletions rollkit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# RollKit

This Ignite App is aimed to extend [Ignite CLI](https://github.com/ignite/cli) and bootstrap the development of a [RollKit](https://rollkit.dev) rollup.

## Prerequisites

* Ignite CLI version v28.4.0 or greater.
* Knowledge of blockchain development (Cosmos SDK).

## Usage

```sh
ignite s chain gm --address-prefix gm
ignite app install -g github.com/ignite/apps/rollkit
ignite rollkit add
ignite chain build
```

Learn more about Rollkit and Ignite in their respective documentation:

* <https://docs.ignite.com>
* <https://rollkit.dev/>
87 changes: 87 additions & 0 deletions rollkit/cmd/add.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package cmd

import (
"context"
"path/filepath"

"github.com/spf13/cobra"

"github.com/ignite/cli/v28/ignite/pkg/cliui"
"github.com/ignite/cli/v28/ignite/pkg/gocmd"
"github.com/ignite/cli/v28/ignite/pkg/placeholder"
"github.com/ignite/cli/v28/ignite/pkg/xgenny"
"github.com/ignite/cli/v28/ignite/services/chain"

"github.com/ignite/apps/rollkit/template"
)

const (
statusScaffolding = "Scaffolding..."

flagPath = "path"
)

func NewRollkitAdd() *cobra.Command {
c := &cobra.Command{
Use: "add",
Short: "Add rollkit support",
Long: "Add rollkit support to your Cosmos SDK chain",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding))
defer session.End()

appPath, err := cmd.Flags().GetString(flagPath)
if err != nil {
return err
}
absPath, err := filepath.Abs(appPath)
if err != nil {
return err
}

chain, err := chain.New(absPath)
if err != nil {
return err
}

g, err := template.NewRollKitGenerator(chain)
if err != nil {
return err
}

_, err = xgenny.RunWithValidation(placeholder.New(), g)
if err != nil {
return err
}

if finish(cmd.Context(), session, chain.AppPath()) != nil {
return err
}

session.Printf("\n🎉 RollKit added (`%[1]v`).\n\n", chain.AppPath())
return nil
},
}

c.Flags().StringP(flagPath, "p", ".", "path of the app")

return c
}

// finish finalize the scaffolded code (formating, dependencies)
func finish(ctx context.Context, session *cliui.Session, path string) error {
session.StartSpinner("go mod tidy...")
if err := gocmd.ModTidy(ctx, path); err != nil {
return err
}

session.StartSpinner("Formatting code...")
if err := gocmd.Fmt(ctx, path); err != nil {
return err
}

_ = gocmd.GoImports(ctx, path) // goimports installation could fail, so ignore the error

return nil
}
21 changes: 21 additions & 0 deletions rollkit/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import "github.com/spf13/cobra"

// NewRollkit creates a new rollkit command that holds
// some other sub commands related to Rollkit.
func NewRollkit() *cobra.Command {
c := &cobra.Command{
Use: "rollkit [command]",
Aliases: []string{"r"},
Short: "Ignite rollkit integration",
SilenceUsage: true,
SilenceErrors: true,
}

// add sub commands.
c.AddCommand(
NewRollkitAdd(),
)
return c
}
Loading
Loading